@covalenthq/client-sdk 2.3.7 → 2.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "2.3.7";
3
+ var version = "2.3.8";
4
4
 
5
5
  const bigIntParser = (val) => {
6
6
  if (val === null || val === undefined) {
@@ -39,6 +39,8 @@ class AllChainsService {
39
39
  *
40
40
  * Commonly used to locate chains which an address is active on with a single API call.
41
41
  *
42
+ * **Credit Cost**: 0.5 per call
43
+ *
42
44
  * @param {string} walletAddress - The requested wallet address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
43
45
  * @param {GetAddressActivityQueryParamOpts} queryParamOpts
44
46
  * - `testnets`: Set to true to include testnets with activity in the response. By default, it's set to `false` and only returns mainnet activity.
@@ -165,6 +167,10 @@ class AllChainsService {
165
167
  return await this.getMultiChainMultiAddressTransactions(queryParamOpts);
166
168
  }
167
169
  /**
170
+ *
171
+ * Fetch paginated spot & historical native and token balances for a single address on up to 10 EVM chains with one API call.
172
+ *
173
+ * **Credit Cost**: 2.5 per call
168
174
  *
169
175
  * @param {string} walletAddress - The requested wallet Address.
170
176
  * @param {GetMultiChainBalanceQueryParamOpts} queryParamOpts
@@ -253,13 +259,12 @@ async function* paginateEndpoint(endpoint, execution, parseData, implementation)
253
259
  }
254
260
  catch (error) {
255
261
  hasMore = false;
262
+ const err = error;
256
263
  yield {
257
264
  data: null,
258
265
  error: true,
259
- error_code: error?.cause?.code || error?.error_code || 500,
260
- error_message: error?.cause?.message ||
261
- error?.error_message ||
262
- "Internal server error",
266
+ error_code: err?.cause?.code || err?.error_code || 500,
267
+ error_message: err?.cause?.message || err?.error_message || "Internal server error",
263
268
  };
264
269
  }
265
270
  }
@@ -275,7 +280,9 @@ class BalanceService {
275
280
  }
276
281
  /**
277
282
  *
278
- * Commonly used to fetch the native, fungible (ERC20), and non-fungible (ERC721 & ERC1155) tokens held by an address. Response includes spot prices and other metadata.
283
+ * Commonly used to fetch the native and fungible (ERC20) tokens held by an address. Response includes spot prices and other metadata.
284
+ *
285
+ * **Credit Cost**: 1 per call
279
286
  *
280
287
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
281
288
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
@@ -342,6 +349,8 @@ class BalanceService {
342
349
  *
343
350
  * Commonly used to render a daily portfolio balance for an address broken down by the token. The timeframe is user-configurable, defaults to 30 days.
344
351
  *
352
+ * **Credit Cost**: 2 per 30 days
353
+ *
345
354
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
346
355
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
347
356
  * @param {GetHistoricalPortfolioForWalletAddressQueryParamOpts} queryParamOpts
@@ -400,6 +409,8 @@ class BalanceService {
400
409
  *
401
410
  * Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address.
402
411
  *
412
+ * **Credit Cost**: 0.05 per item
413
+ *
403
414
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
404
415
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
405
416
  * @param {GetErc20TransfersForWalletAddressQueryParamOpts} queryParamOpts
@@ -474,6 +485,8 @@ class BalanceService {
474
485
  *
475
486
  * Commonly used to render the transfer-in and transfer-out of a token along with historical prices from an address.
476
487
  *
488
+ * **Credit Cost**: 0.05 per item
489
+ *
477
490
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
478
491
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
479
492
  * @param {GetErc20TransfersForWalletAddressQueryParamOpts} queryParamOpts
@@ -542,7 +555,9 @@ class BalanceService {
542
555
  }
543
556
  /**
544
557
  *
545
- * Commonly used to get a list of all the token holders for a specified ERC20 or ERC721 token. Returns historic token holders when block-height is set (defaults to `latest`). Useful for building pie charts of token holders.
558
+ * Used to get a paginated list of current or historical token holders for a specified ERC20 or ERC721 token.
559
+ *
560
+ * **Credit Cost**: 0.02 per item
546
561
  *
547
562
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
548
563
  * @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
@@ -593,7 +608,9 @@ class BalanceService {
593
608
  }
594
609
  /**
595
610
  *
596
- * Commonly used to get a list of all the token holders for a specified ERC20 or ERC721 token. Returns historic token holders when block-height is set (defaults to `latest`). Useful for building pie charts of token holders.
611
+ * Used to get a paginated list of current or historical token holders for a specified ERC20 or ERC721 token.
612
+ *
613
+ * **Credit Cost**: 0.02 per item
597
614
  *
598
615
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
599
616
  * @param {string} tokenAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
@@ -642,7 +659,9 @@ class BalanceService {
642
659
  }
643
660
  /**
644
661
  *
645
- * Commonly used to fetch the historical native, fungible (ERC20), and non-fungible (ERC721 & ERC1155) tokens held by an address at a given block height or date. Response includes daily prices and other metadata.
662
+ * Commonly used to fetch the historical native and fungible (ERC20) tokens held by an address at a given block height or date. Response includes daily prices and other metadata.
663
+ *
664
+ * **Credit Cost**: 1 per call
646
665
  *
647
666
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
648
667
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
@@ -715,6 +734,10 @@ class BalanceService {
715
734
  return await this.execution.execute(endpoint, parseData);
716
735
  }
717
736
  /**
737
+ *
738
+ * Lightweight endpoint to just get the native token balance for an EVM address.
739
+ *
740
+ * **Credit Cost**: 0.5 per call
718
741
  *
719
742
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
720
743
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
@@ -764,6 +787,8 @@ class BaseService {
764
787
  *
765
788
  * Commonly used to fetch and render a single block for a block explorer.
766
789
  *
790
+ * **Credit Cost**: 1 per call
791
+ *
767
792
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
768
793
  * @param {string} blockHeight - The block height or `latest` for the latest block available.
769
794
  *
@@ -790,7 +815,9 @@ class BaseService {
790
815
  }
791
816
  /**
792
817
  *
793
- * Commonly used to resolve ENS, RNS and Unstoppable Domains addresses.
818
+ * Commonly used to resolve ENS, RNS and Unstoppable Domains addresses. Only supports the resolution of a registered domain to an address.
819
+ *
820
+ * **Credit Cost**: 1 per call
794
821
  *
795
822
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
796
823
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
@@ -807,6 +834,8 @@ class BaseService {
807
834
  *
808
835
  * Commonly used to get all the block heights within a particular date range. Useful for rendering a display where you sort blocks by day.
809
836
  *
837
+ * **Credit Cost**: 1 per call
838
+ *
810
839
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
811
840
  * @param {string} startDate - The start date in YYYY-MM-DD format.
812
841
  * @param {string | "latest"} endDate - The end date in YYYY-MM-DD format. Also accepts "latest" for the latest block height
@@ -850,6 +879,8 @@ class BaseService {
850
879
  *
851
880
  * Commonly used to get all the block heights within a particular date range. Useful for rendering a display where you sort blocks by day.
852
881
  *
882
+ * **Credit Cost**: 1 per call
883
+ *
853
884
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
854
885
  * @param {string} startDate - The start date in YYYY-MM-DD format.
855
886
  * @param {string | "latest"} endDate - The end date in YYYY-MM-DD format. Also accepts "latest" for the latest block height
@@ -891,6 +922,8 @@ class BaseService {
891
922
  *
892
923
  * Commonly used to get all the event logs of the latest block, or for a range of blocks. Includes sender contract metadata as well as decoded logs.
893
924
  *
925
+ * **Credit Cost**: 0.01 per item
926
+ *
894
927
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
895
928
  * @param {GetLogsQueryParamOpts} queryParamOpts
896
929
  * - `startingBlock`: The first block to retrieve log events with. Accepts decimals, hexadecimals, or the strings `earliest` and `latest`.
@@ -950,6 +983,8 @@ class BaseService {
950
983
  *
951
984
  * Commonly used to get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions.
952
985
  *
986
+ * **Credit Cost**: 0.01 per item
987
+ *
953
988
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
954
989
  * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
955
990
  * @param {GetLogEventsByAddressQueryParamOpts} queryParamOpts
@@ -1002,6 +1037,8 @@ class BaseService {
1002
1037
  *
1003
1038
  * Commonly used to get all the event logs emitted from a particular contract address. Useful for building dashboards that examine on-chain interactions.
1004
1039
  *
1040
+ * **Credit Cost**: 0.01 per item
1041
+ *
1005
1042
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1006
1043
  * @param {string} contractAddress - The requested contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1007
1044
  * @param {GetLogEventsByAddressQueryParamOpts} queryParamOpts
@@ -1052,6 +1089,8 @@ class BaseService {
1052
1089
  *
1053
1090
  * Commonly used to get all event logs of the same topic hash across all contracts within a particular chain. Useful for cross-sectional analysis of event logs that are emitted on-chain.
1054
1091
  *
1092
+ * **Credit Cost**: 0.01 per item
1093
+ *
1055
1094
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1056
1095
  * @param {string} topicHash - The endpoint will return event logs that contain this topic hash.
1057
1096
  * @param {GetLogEventsByTopicHashQueryParamOpts} queryParamOpts
@@ -1109,6 +1148,8 @@ class BaseService {
1109
1148
  *
1110
1149
  * Commonly used to get all event logs of the same topic hash across all contracts within a particular chain. Useful for cross-sectional analysis of event logs that are emitted on-chain.
1111
1150
  *
1151
+ * **Credit Cost**: 0.01 per item
1152
+ *
1112
1153
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1113
1154
  * @param {string} topicHash - The endpoint will return event logs that contain this topic hash.
1114
1155
  * @param {GetLogEventsByTopicHashQueryParamOpts} queryParamOpts
@@ -1164,6 +1205,7 @@ class BaseService {
1164
1205
  *
1165
1206
  * Commonly used to build internal dashboards for all supported chains on Covalent.
1166
1207
  *
1208
+ * **Credit Cost**: 0.01 per call
1167
1209
  *
1168
1210
  */
1169
1211
  async getAllChains() {
@@ -1188,6 +1230,7 @@ class BaseService {
1188
1230
  *
1189
1231
  * Commonly used to build internal status dashboards of all supported chains.
1190
1232
  *
1233
+ * **Credit Cost**: 1 per call
1191
1234
  *
1192
1235
  */
1193
1236
  async getAllChainStatus() {
@@ -1209,6 +1252,11 @@ class BaseService {
1209
1252
  return await this.execution.execute(endpoint, parseData);
1210
1253
  }
1211
1254
  /**
1255
+ *
1256
+ * Commonly used to locate chains which an address is active on with a single API call.
1257
+ *
1258
+ * **Credit Cost**: 0.5 per call
1259
+ *
1212
1260
  * @deprecated This method is deprecated and will be removed in the upcoming versions. Please use `AllChainsService.getAddressActivity` instead.
1213
1261
  *
1214
1262
  * Commonly used to locate chains which an address is active on with a single API call.
@@ -1244,6 +1292,10 @@ class BaseService {
1244
1292
  return await this.execution.execute(endpoint, parseData);
1245
1293
  }
1246
1294
  /**
1295
+ *
1296
+ * Get real-time gas estimates for different transaction speeds on a specific network, enabling users to optimize transaction costs and confirmation times.
1297
+ *
1298
+ * **Credit Cost**: 1 per call
1247
1299
  *
1248
1300
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
1249
1301
  * @param {string} eventType - The desired event type to retrieve gas prices for. Supports `erc20` transfer events, `uniswapv3` swap events and `nativetokens` transfers.
@@ -1407,6 +1459,10 @@ class BitcoinService {
1407
1459
  this.execution = execution;
1408
1460
  }
1409
1461
  /**
1462
+ *
1463
+ * Commonly used to fetch the historical Bitcoin balance held by an address at a given block height or date. Response includes daily prices and other metadata.
1464
+ *
1465
+ * **Credit Cost**: 1 per call
1410
1466
  *
1411
1467
  * @param {string} walletAddress - The requested Bitcoin HD address.
1412
1468
  * @param {GetBitcoinHdWalletBalancesQueryParamOpts} queryParamOpts
@@ -1482,7 +1538,9 @@ class BitcoinService {
1482
1538
  }
1483
1539
  /**
1484
1540
  *
1485
- * Commonly used to fetch the tokens held by an address. Response includes spot prices and other metadata.
1541
+ * Fetch Bitcoin balance for a non-HD address. Response includes spot prices and other metadata.
1542
+ *
1543
+ * **Credit Cost**: 1 per call
1486
1544
  *
1487
1545
  * @param {string} walletAddress - The requested Bitcoin Non HD address.
1488
1546
  * @param {GetBitcoinNonHdWalletBalancesQueryParamOpts} queryParamOpts
@@ -1544,6 +1602,7 @@ class NftService {
1544
1602
  * - `pageNumber`: 0-indexed page number to begin pagination.
1545
1603
  * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1546
1604
  *
1605
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
1547
1606
  */
1548
1607
  async *getChainCollections(chainName, queryParamOpts) {
1549
1608
  const endpoint = endpointGenerator(`${chainName}/nft/collections`, [
@@ -1590,6 +1649,7 @@ class NftService {
1590
1649
  * - `pageNumber`: 0-indexed page number to begin pagination.
1591
1650
  * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1592
1651
  *
1652
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
1593
1653
  */
1594
1654
  async getChainCollectionsByPage(chainName, queryParamOpts) {
1595
1655
  const endpoint = endpointGenerator(`${chainName}/nft/collections`, [
@@ -1628,6 +1688,8 @@ class NftService {
1628
1688
  *
1629
1689
  * Commonly used to render the NFTs (including ERC721 and ERC1155) held by an address.
1630
1690
  *
1691
+ * **Credit Cost**: 1 per call
1692
+ *
1631
1693
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
1632
1694
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1633
1695
  * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
@@ -1688,6 +1750,7 @@ class NftService {
1688
1750
  * - `valuesFilter`: Filters NFTs based on a specific trait value. If this filter is used, the API will return all NFTs with the specified trait value. If used with "traits-filter", only NFTs matching both filters will be returned. Accepts comma-separated values, is case-sensitive, and requires proper URL encoding.
1689
1751
  * - `withUncached`: By default, this endpoint only works on chains where we've cached the assets and the metadata. When set to `true`, the API will fetch metadata from upstream servers even if it's not cached - the downside being that the upstream server can block or rate limit the call and therefore resulting in time outs or slow response times on the Covalent side.
1690
1752
  *
1753
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
1691
1754
  */
1692
1755
  async *getTokenIdsForContractWithMetadata(chainName, contractAddress, queryParamOpts) {
1693
1756
  const endpoint = endpointGenerator(`${chainName}/nft/${contractAddress}/metadata`, [
@@ -1751,6 +1814,7 @@ class NftService {
1751
1814
  * - `valuesFilter`: Filters NFTs based on a specific trait value. If this filter is used, the API will return all NFTs with the specified trait value. If used with "traits-filter", only NFTs matching both filters will be returned. Accepts comma-separated values, is case-sensitive, and requires proper URL encoding.
1752
1815
  * - `withUncached`: By default, this endpoint only works on chains where we've cached the assets and the metadata. When set to `true`, the API will fetch metadata from upstream servers even if it's not cached - the downside being that the upstream server can block or rate limit the call and therefore resulting in time outs or slow response times on the Covalent side.
1753
1816
  *
1817
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
1754
1818
  */
1755
1819
  async getTokenIdsForContractWithMetadataByPage(chainName, contractAddress, queryParamOpts) {
1756
1820
  const endpoint = endpointGenerator(`${chainName}/nft/${contractAddress}/metadata`, [
@@ -1809,6 +1873,7 @@ class NftService {
1809
1873
  * - `noMetadata`: Omit metadata.
1810
1874
  * - `withUncached`: By default, this endpoint only works on chains where we've cached the assets and the metadata. When set to `true`, the API will fetch metadata from upstream servers even if it's not cached - the downside being that the upstream server can block or rate limit the call and therefore resulting in time outs or slow response times on the Covalent side.
1811
1875
  *
1876
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
1812
1877
  */
1813
1878
  async getNftMetadataForGivenTokenIdForContract(chainName, contractAddress, tokenId, queryParamOpts) {
1814
1879
  const endpoint = endpointGenerator(`${chainName}/nft/${contractAddress}/metadata/${tokenId}`, [
@@ -1850,6 +1915,7 @@ class NftService {
1850
1915
  * @param {GetNftTransactionsForContractTokenIdQueryParamOpts} queryParamOpts
1851
1916
  * - `noSpam`: If `true`, the suspected spam tokens are removed. Supports `eth-mainnet` and `matic-mainnet`.
1852
1917
  *
1918
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
1853
1919
  */
1854
1920
  async getNftTransactionsForContractTokenId(chainName, contractAddress, tokenId, queryParamOpts) {
1855
1921
  const endpoint = endpointGenerator(`${chainName}/tokens/${contractAddress}/nft_transactions/${tokenId}`, [
@@ -1898,6 +1964,7 @@ class NftService {
1898
1964
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
1899
1965
  * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1900
1966
  *
1967
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
1901
1968
  */
1902
1969
  async getTraitsForCollection(chainName, collectionContract) {
1903
1970
  const endpoint = endpointGenerator(`${chainName}/nft/${collectionContract}/traits`, []);
@@ -1919,6 +1986,7 @@ class NftService {
1919
1986
  * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1920
1987
  * @param {string} trait - The requested trait.
1921
1988
  *
1989
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
1922
1990
  */
1923
1991
  async getAttributesForTraitInCollection(chainName, collectionContract, trait) {
1924
1992
  const endpoint = endpointGenerator(`${chainName}/nft/${collectionContract}/traits/${trait}/attributes`, []);
@@ -1939,6 +2007,7 @@ class NftService {
1939
2007
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
1940
2008
  * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
1941
2009
  *
2010
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
1942
2011
  */
1943
2012
  async getCollectionTraitsSummary(chainName, collectionContract) {
1944
2013
  const endpoint = endpointGenerator(`${chainName}/nft/${collectionContract}/traits_summary`, []);
@@ -1962,6 +2031,7 @@ class NftService {
1962
2031
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
1963
2032
  * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
1964
2033
  *
2034
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
1965
2035
  */
1966
2036
  async getHistoricalFloorPricesForCollection(chainName, collectionAddress, queryParamOpts) {
1967
2037
  const endpoint = endpointGenerator(`${chainName}/nft_market/${collectionAddress}/floor_price`, [
@@ -2000,6 +2070,7 @@ class NftService {
2000
2070
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
2001
2071
  * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
2002
2072
  *
2073
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
2003
2074
  */
2004
2075
  async getHistoricalVolumeForCollection(chainName, collectionAddress, queryParamOpts) {
2005
2076
  const endpoint = endpointGenerator(`${chainName}/nft_market/${collectionAddress}/volume`, [
@@ -2038,6 +2109,7 @@ class NftService {
2038
2109
  * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
2039
2110
  * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
2040
2111
  *
2112
+ * @deprecated This endpoint is no longer supported by the GoldRush API.
2041
2113
  */
2042
2114
  async getHistoricalSalesCountForCollection(chainName, collectionAddress, queryParamOpts) {
2043
2115
  const endpoint = endpointGenerator(`${chainName}/nft_market/${collectionAddress}/sale_count`, [
@@ -2070,6 +2142,8 @@ class NftService {
2070
2142
  *
2071
2143
  * Commonly used to verify ownership of NFTs (including ERC-721 and ERC-1155) within a collection.
2072
2144
  *
2145
+ * **Credit Cost**: 1 per call
2146
+ *
2073
2147
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
2074
2148
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
2075
2149
  * @param {string} collectionContract - The requested collection address.
@@ -2115,6 +2189,8 @@ class NftService {
2115
2189
  *
2116
2190
  * Commonly used to verify ownership of a specific token (ERC-721 or ERC-1155) within a collection.
2117
2191
  *
2192
+ * **Credit Cost**: 1 per call
2193
+ *
2118
2194
  * @param {string} chainName - The chain name eg: `eth-mainnet`.
2119
2195
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
2120
2196
  * @param {string} collectionContract - The requested collection address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
@@ -2156,7 +2232,9 @@ class PricingService {
2156
2232
  }
2157
2233
  /**
2158
2234
  *
2159
- * Commonly used to get historic prices of a token between date ranges. Supports native tokens.
2235
+ * Get the historical prices of one (or many) large cap ERC20 tokens between specified date ranges. Also supports native tokens.
2236
+ *
2237
+ * **Credit Cost**: 1 per call
2160
2238
  *
2161
2239
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
2162
2240
  * @param {string} quoteCurrency - The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
@@ -2204,6 +2282,8 @@ class PricingService {
2204
2282
  *
2205
2283
  * Get the spot token pair prices for a specified pool contract address. Supports pools on Uniswap V2, V3 and their forks.
2206
2284
  *
2285
+ * **Credit Cost**: 1 per call
2286
+ *
2207
2287
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
2208
2288
  * @param {string} contractAddress - The pool contract address.
2209
2289
  * @param {GetTokenPricesQueryParamOpts} queryParamOpts
@@ -2243,6 +2323,8 @@ class SecurityService {
2243
2323
  *
2244
2324
  * Commonly used to get a list of approvals across all token contracts categorized by spenders for a wallet’s assets.
2245
2325
  *
2326
+ * **Credit Cost**: 2 per call
2327
+ *
2246
2328
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
2247
2329
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
2248
2330
  *
@@ -3061,7 +3143,12 @@ class StreamingService {
3061
3143
  });
3062
3144
  }
3063
3145
  /**
3064
- * Subscribe to OHLCV data for specific pairs
3146
+ *
3147
+ * The OHLCV Pairs stream provides real-time updates on the Open, High, Low, Close prices and Volume of one or many token pairs at configurable intervals.
3148
+ *
3149
+ * **Credit Cost**: 0 per call
3150
+ *
3151
+ * **Beta**: This endpoint is in beta.
3065
3152
  *
3066
3153
  * @param params - Parameters for the OHLCV pairs stream
3067
3154
  * @param callbacks - Subscription callbacks
@@ -3089,42 +3176,42 @@ class StreamingService {
3089
3176
  const pairAddressesString = params.pair_addresses
3090
3177
  .map((addr) => `"${addr}"`)
3091
3178
  .join(", ");
3092
- const query = `
3093
- subscription {
3094
- ohlcvCandlesForPair(
3095
- chain_name: ${params.chain_name}
3096
- pair_addresses: [${pairAddressesString}]
3097
- interval: ${params.interval}
3098
- timeframe: ${params.timeframe}
3099
- ${params.limit ? `limit: ${params.limit}` : ""}
3100
- ) {
3101
- chain_name
3102
- pair_address
3103
- interval
3104
- timeframe
3105
- timestamp
3106
- open
3107
- high
3108
- low
3109
- close
3110
- volume
3111
- volume_usd
3112
- quote_rate
3113
- quote_rate_usd
3114
- base_token {
3115
- contract_name
3116
- contract_address
3117
- contract_decimals
3118
- contract_ticker_symbol
3119
- }
3120
- quote_token {
3121
- contract_name
3122
- contract_address
3123
- contract_decimals
3124
- contract_ticker_symbol
3125
- }
3126
- }
3127
- }
3179
+ const query = `
3180
+ subscription {
3181
+ ohlcvCandlesForPair(
3182
+ chain_name: ${params.chain_name}
3183
+ pair_addresses: [${pairAddressesString}]
3184
+ interval: ${params.interval}
3185
+ timeframe: ${params.timeframe}
3186
+ ${params.limit ? `limit: ${params.limit}` : ""}
3187
+ ) {
3188
+ chain_name
3189
+ pair_address
3190
+ interval
3191
+ timeframe
3192
+ timestamp
3193
+ open
3194
+ high
3195
+ low
3196
+ close
3197
+ volume
3198
+ volume_usd
3199
+ quote_rate
3200
+ quote_rate_usd
3201
+ base_token {
3202
+ contract_name
3203
+ contract_address
3204
+ contract_decimals
3205
+ contract_ticker_symbol
3206
+ }
3207
+ quote_token {
3208
+ contract_name
3209
+ contract_address
3210
+ contract_decimals
3211
+ contract_ticker_symbol
3212
+ }
3213
+ }
3214
+ }
3128
3215
  `;
3129
3216
  const client = StreamingWebSocketClient.getClient();
3130
3217
  return client.subscribe({
@@ -3146,7 +3233,12 @@ class StreamingService {
3146
3233
  });
3147
3234
  }
3148
3235
  /**
3149
- * Subscribe to OHLCV data for specific tokens
3236
+ *
3237
+ * The OHLCV Tokens stream provides real-time updates on the Open, High, Low, Close prices and Volume of one or many tokens at configurable intervals.
3238
+ *
3239
+ * **Credit Cost**: 0 per call
3240
+ *
3241
+ * **Beta**: This endpoint is in beta.
3150
3242
  *
3151
3243
  * @param params - Parameters for the OHLCV tokens stream
3152
3244
  * @param callbacks - Subscription callbacks
@@ -3174,42 +3266,42 @@ class StreamingService {
3174
3266
  const tokenAddressesString = params.token_addresses
3175
3267
  .map((addr) => `"${addr}"`)
3176
3268
  .join(", ");
3177
- const query = `
3178
- subscription {
3179
- ohlcvCandlesForToken(
3180
- chain_name: ${params.chain_name}
3181
- token_addresses: [${tokenAddressesString}]
3182
- interval: ${params.interval}
3183
- timeframe: ${params.timeframe}
3184
- ${params.limit ? `limit: ${params.limit}` : ""}
3185
- ) {
3186
- chain_name
3187
- pair_address
3188
- interval
3189
- timeframe
3190
- timestamp
3191
- open
3192
- high
3193
- low
3194
- close
3195
- volume
3196
- volume_usd
3197
- quote_rate
3198
- quote_rate_usd
3199
- base_token {
3200
- contract_name
3201
- contract_address
3202
- contract_decimals
3203
- contract_ticker_symbol
3204
- }
3205
- quote_token {
3206
- contract_name
3207
- contract_address
3208
- contract_decimals
3209
- contract_ticker_symbol
3210
- }
3211
- }
3212
- }
3269
+ const query = `
3270
+ subscription {
3271
+ ohlcvCandlesForToken(
3272
+ chain_name: ${params.chain_name}
3273
+ token_addresses: [${tokenAddressesString}]
3274
+ interval: ${params.interval}
3275
+ timeframe: ${params.timeframe}
3276
+ ${params.limit ? `limit: ${params.limit}` : ""}
3277
+ ) {
3278
+ chain_name
3279
+ pair_address
3280
+ interval
3281
+ timeframe
3282
+ timestamp
3283
+ open
3284
+ high
3285
+ low
3286
+ close
3287
+ volume
3288
+ volume_usd
3289
+ quote_rate
3290
+ quote_rate_usd
3291
+ base_token {
3292
+ contract_name
3293
+ contract_address
3294
+ contract_decimals
3295
+ contract_ticker_symbol
3296
+ }
3297
+ quote_token {
3298
+ contract_name
3299
+ contract_address
3300
+ contract_decimals
3301
+ contract_ticker_symbol
3302
+ }
3303
+ }
3304
+ }
3213
3305
  `;
3214
3306
  const client = StreamingWebSocketClient.getClient();
3215
3307
  return client.subscribe({
@@ -3231,7 +3323,12 @@ class StreamingService {
3231
3323
  });
3232
3324
  }
3233
3325
  /**
3234
- * Subscribe to new DEX pairs created on supported decentralized exchanges
3326
+ *
3327
+ * The New DEX Pairs stream provides real-time updates when new liquidity pairs are created on decentralized exchanges (DEXes). This documentation follows our standard streaming API structure.
3328
+ *
3329
+ * **Credit Cost**: 0 per call
3330
+ *
3331
+ * **Beta**: This endpoint is in beta.
3235
3332
  *
3236
3333
  * @param params - Parameters for the new pairs stream
3237
3334
  * @param callbacks - Subscription callbacks
@@ -3253,45 +3350,45 @@ class StreamingService {
3253
3350
  * ```
3254
3351
  */
3255
3352
  subscribeToNewPairs(params, callbacks) {
3256
- const query = `
3257
- subscription {
3258
- newPairs(
3259
- chain_name: ${params.chain_name},
3260
- protocols: [${params.protocols.join(", ")}]
3261
- ) {
3262
- chain_name
3263
- protocol
3264
- protocol_version
3265
- pair_address
3266
- deployer_address
3267
- tx_hash
3268
- block_signed_at
3269
- liquidity
3270
- supply
3271
- market_cap
3272
- event_name
3273
- quote_rate
3274
- quote_rate_usd
3275
- base_token_metadata {
3276
- contract_address
3277
- contract_decimals
3278
- contract_name
3279
- contract_ticker_symbol
3280
- }
3281
- pair_metadata {
3282
- contract_address
3283
- contract_decimals
3284
- contract_name
3285
- contract_ticker_symbol
3286
- }
3287
- quote_token_metadata {
3288
- contract_address
3289
- contract_decimals
3290
- contract_name
3291
- contract_ticker_symbol
3292
- }
3293
- }
3294
- }
3353
+ const query = `
3354
+ subscription {
3355
+ newPairs(
3356
+ chain_name: ${params.chain_name},
3357
+ protocols: [${params.protocols.join(", ")}]
3358
+ ) {
3359
+ chain_name
3360
+ protocol
3361
+ protocol_version
3362
+ pair_address
3363
+ deployer_address
3364
+ tx_hash
3365
+ block_signed_at
3366
+ liquidity
3367
+ supply
3368
+ market_cap
3369
+ event_name
3370
+ quote_rate
3371
+ quote_rate_usd
3372
+ base_token {
3373
+ contract_address
3374
+ contract_decimals
3375
+ contract_name
3376
+ contract_ticker_symbol
3377
+ }
3378
+ pair {
3379
+ contract_address
3380
+ contract_decimals
3381
+ contract_name
3382
+ contract_ticker_symbol
3383
+ }
3384
+ quote_token {
3385
+ contract_address
3386
+ contract_decimals
3387
+ contract_name
3388
+ contract_ticker_symbol
3389
+ }
3390
+ }
3391
+ }
3295
3392
  `;
3296
3393
  const client = StreamingWebSocketClient.getClient();
3297
3394
  return client.subscribe({
@@ -3313,7 +3410,12 @@ class StreamingService {
3313
3410
  });
3314
3411
  }
3315
3412
  /**
3316
- * Subscribe to real-time updates for specific trading pairs including price, volume, and liquidity data
3413
+ *
3414
+ * The Update DEX Pairs stream provides real-time event updates on the prices, volumes, market cap and liquidity of one or many token pairs.
3415
+ *
3416
+ * **Credit Cost**: 0 per call
3417
+ *
3418
+ * **Beta**: This endpoint is in beta.
3317
3419
  *
3318
3420
  * @param params - Parameters for the update pairs stream
3319
3421
  * @param callbacks - Subscription callbacks
@@ -3340,47 +3442,47 @@ class StreamingService {
3340
3442
  const pairAddressesString = params.pair_addresses
3341
3443
  .map((addr) => `"${addr}"`)
3342
3444
  .join(", ");
3343
- const query = `
3344
- subscription {
3345
- updatePairs(
3346
- chain_name: ${params.chain_name}
3347
- pair_addresses: [${pairAddressesString}]
3348
- ) {
3349
- chain_name
3350
- pair_address
3351
- timestamp
3352
- quote_rate
3353
- quote_rate_usd
3354
- volume
3355
- volume_usd
3356
- market_cap
3357
- liquidity
3358
- base_token {
3359
- contract_name
3360
- contract_address
3361
- contract_decimals
3362
- contract_ticker_symbol
3363
- }
3364
- quote_token {
3365
- contract_name
3366
- contract_address
3367
- contract_decimals
3368
- contract_ticker_symbol
3369
- }
3370
- price_deltas {
3371
- last_5m
3372
- last_1hr
3373
- last_6hr
3374
- last_24hr
3375
- }
3376
- swap_counts {
3377
- last_5m
3378
- last_1hr
3379
- last_6hr
3380
- last_24hr
3381
- }
3382
- }
3383
- }
3445
+ const query = `
3446
+ subscription {
3447
+ updatePairs(
3448
+ chain_name: ${params.chain_name}
3449
+ pair_addresses: [${pairAddressesString}]
3450
+ ) {
3451
+ chain_name
3452
+ pair_address
3453
+ timestamp
3454
+ quote_rate
3455
+ quote_rate_usd
3456
+ volume
3457
+ volume_usd
3458
+ market_cap
3459
+ liquidity
3460
+ base_token {
3461
+ contract_name
3462
+ contract_address
3463
+ contract_decimals
3464
+ contract_ticker_symbol
3465
+ }
3466
+ quote_token {
3467
+ contract_name
3468
+ contract_address
3469
+ contract_decimals
3470
+ contract_ticker_symbol
3471
+ }
3472
+ price_deltas {
3473
+ last_5m
3474
+ last_1hr
3475
+ last_6hr
3476
+ last_24hr
3477
+ }
3478
+ swap_counts {
3479
+ last_5m
3480
+ last_1hr
3481
+ last_6hr
3482
+ last_24hr
3483
+ }
3484
+ }
3485
+ }
3384
3486
  `;
3385
3487
  const client = StreamingWebSocketClient.getClient();
3386
3488
  return client.subscribe({
@@ -3402,7 +3504,12 @@ class StreamingService {
3402
3504
  });
3403
3505
  }
3404
3506
  /**
3405
- * Subscribe to real-time wallet activity including transactions, token transfers, and smart contract interactions
3507
+ *
3508
+ * The Wallet Activity stream provides real-time updates on wallet transactions, token transfers, and interactions with smart contracts . This documentation follows our standard Streaming API structure.
3509
+ *
3510
+ * **Credit Cost**: 0 per call
3511
+ *
3512
+ * **Beta**: This endpoint is in beta.
3406
3513
  *
3407
3514
  * @param params - Parameters for the wallet activity stream
3408
3515
  * @param callbacks - Subscription callbacks
@@ -3428,110 +3535,110 @@ class StreamingService {
3428
3535
  const walletAddressesString = params.wallet_addresses
3429
3536
  .map((addr) => `"${addr}"`)
3430
3537
  .join(", ");
3431
- const query = `
3432
- subscription {
3433
- walletTxs(
3434
- chain_name: ${params.chain_name},
3435
- wallet_addresses: [${walletAddressesString}]
3436
- ) {
3437
- tx_hash
3438
- from_address
3439
- to_address
3440
- value
3441
- chain_name
3442
- block_signed_at
3443
- block_height
3444
- block_hash
3445
- miner_address
3446
- gas_used
3447
- tx_offset
3448
- successful
3449
- decoded_type
3450
- decoded_details {
3451
- ... on TransferTransaction {
3452
- from
3453
- to
3454
- amount
3455
- quote_usd
3456
- quote_rate_usd
3457
- contract_metadata {
3458
- contract_name
3459
- contract_address
3460
- contract_decimals
3461
- contract_ticker_symbol
3462
- }
3463
- }
3464
- ... on SwapTransaction {
3465
- token_in
3466
- token_out
3467
- amount_in
3468
- amount_out
3469
- }
3470
- ... on BridgeTransaction {
3471
- type
3472
- typeString
3473
- from
3474
- to
3475
- amount
3476
- quote_usd
3477
- quote_rate_usd
3478
- contract_metadata {
3479
- contract_name
3480
- contract_address
3481
- contract_decimals
3482
- contract_ticker_symbol
3483
- }
3484
- }
3485
- ... on DepositTransaction {
3486
- from
3487
- to
3488
- amount
3489
- quote_usd
3490
- quote_rate_usd
3491
- contract_metadata {
3492
- contract_name
3493
- contract_address
3494
- contract_decimals
3495
- contract_ticker_symbol
3496
- }
3497
- }
3498
- ... on WithdrawTransaction {
3499
- from
3500
- to
3501
- amount
3502
- quote_usd
3503
- quote_rate_usd
3504
- contract_metadata {
3505
- contract_name
3506
- contract_address
3507
- contract_decimals
3508
- contract_ticker_symbol
3509
- }
3510
- }
3511
- ... on ApproveTransaction {
3512
- spender
3513
- amount
3514
- quote_usd
3515
- quote_rate_usd
3516
- contract_metadata {
3517
- contract_name
3518
- contract_address
3519
- contract_decimals
3520
- contract_ticker_symbol
3521
- }
3522
- }
3523
- ... on ErrorDetails {
3524
- message
3525
- }
3526
- }
3527
- logs {
3528
- emitter_address
3529
- log_offset
3530
- data
3531
- topics
3532
- }
3533
- }
3534
- }
3538
+ const query = `
3539
+ subscription {
3540
+ walletTxs(
3541
+ chain_name: ${params.chain_name},
3542
+ wallet_addresses: [${walletAddressesString}]
3543
+ ) {
3544
+ tx_hash
3545
+ from_address
3546
+ to_address
3547
+ value
3548
+ chain_name
3549
+ block_signed_at
3550
+ block_height
3551
+ block_hash
3552
+ miner_address
3553
+ gas_used
3554
+ tx_offset
3555
+ successful
3556
+ decoded_type
3557
+ decoded_details {
3558
+ ... on TransferTransaction {
3559
+ from
3560
+ to
3561
+ amount
3562
+ quote_usd
3563
+ quote_rate_usd
3564
+ contract_metadata {
3565
+ contract_name
3566
+ contract_address
3567
+ contract_decimals
3568
+ contract_ticker_symbol
3569
+ }
3570
+ }
3571
+ ... on SwapTransaction {
3572
+ token_in
3573
+ token_out
3574
+ amount_in
3575
+ amount_out
3576
+ }
3577
+ ... on BridgeTransaction {
3578
+ type
3579
+ typeString
3580
+ from
3581
+ to
3582
+ amount
3583
+ quote_usd
3584
+ quote_rate_usd
3585
+ contract_metadata {
3586
+ contract_name
3587
+ contract_address
3588
+ contract_decimals
3589
+ contract_ticker_symbol
3590
+ }
3591
+ }
3592
+ ... on DepositTransaction {
3593
+ from
3594
+ to
3595
+ amount
3596
+ quote_usd
3597
+ quote_rate_usd
3598
+ contract_metadata {
3599
+ contract_name
3600
+ contract_address
3601
+ contract_decimals
3602
+ contract_ticker_symbol
3603
+ }
3604
+ }
3605
+ ... on WithdrawTransaction {
3606
+ from
3607
+ to
3608
+ amount
3609
+ quote_usd
3610
+ quote_rate_usd
3611
+ contract_metadata {
3612
+ contract_name
3613
+ contract_address
3614
+ contract_decimals
3615
+ contract_ticker_symbol
3616
+ }
3617
+ }
3618
+ ... on ApproveTransaction {
3619
+ spender
3620
+ amount
3621
+ quote_usd
3622
+ quote_rate_usd
3623
+ contract_metadata {
3624
+ contract_name
3625
+ contract_address
3626
+ contract_decimals
3627
+ contract_ticker_symbol
3628
+ }
3629
+ }
3630
+ ... on ErrorDetails {
3631
+ message
3632
+ }
3633
+ }
3634
+ logs {
3635
+ emitter_address
3636
+ log_offset
3637
+ data
3638
+ topics
3639
+ }
3640
+ }
3641
+ }
3535
3642
  `;
3536
3643
  const client = StreamingWebSocketClient.getClient();
3537
3644
  return client.subscribe({
@@ -3552,6 +3659,181 @@ class StreamingService {
3552
3659
  complete: callbacks.complete || (() => { }),
3553
3660
  });
3554
3661
  }
3662
+ /**
3663
+ * Search for tokens by keyword, ticker, or contract address
3664
+ *
3665
+ * @param params - Parameters for the token search query
3666
+ * @returns Promise resolving to an array of matching tokens
3667
+ *
3668
+ * @example
3669
+ * ```typescript
3670
+ * const results = await streamingService.searchToken({
3671
+ * query: "PEPE"
3672
+ * });
3673
+ * console.log("Search Results:", results);
3674
+ * ```
3675
+ */
3676
+ searchToken(params) {
3677
+ const query = `
3678
+ query SearchToken($query: String!) {
3679
+ searchToken(query: $query) {
3680
+ pair_address
3681
+ chain_name
3682
+ quote_rate
3683
+ quote_rate_usd
3684
+ volume
3685
+ volume_usd
3686
+ market_cap
3687
+ base_token {
3688
+ contract_name
3689
+ contract_address
3690
+ contract_decimals
3691
+ contract_ticker_symbol
3692
+ }
3693
+ quote_token {
3694
+ contract_name
3695
+ contract_address
3696
+ contract_decimals
3697
+ contract_ticker_symbol
3698
+ }
3699
+ }
3700
+ }
3701
+ `;
3702
+ const client = StreamingWebSocketClient.getClient();
3703
+ return new Promise((resolve, reject) => {
3704
+ let result = [];
3705
+ client.subscribe({
3706
+ query,
3707
+ variables: { query: params.query },
3708
+ }, {
3709
+ next: (data) => {
3710
+ if (data.data) {
3711
+ result = data.data.searchToken ?? [];
3712
+ }
3713
+ else if (data.errors) {
3714
+ reject(data.errors);
3715
+ }
3716
+ },
3717
+ error: (err) => reject(err),
3718
+ complete: () => resolve(result),
3719
+ });
3720
+ });
3721
+ }
3722
+ /**
3723
+ * Get top trader wallets and their PnL for a specific token
3724
+ *
3725
+ * @param params - Parameters for the UPnL token query
3726
+ * @returns Promise resolving to an array of top trader wallet data
3727
+ *
3728
+ * @example
3729
+ * ```typescript
3730
+ * const traders = await streamingService.getUPnLForToken({
3731
+ * chain_name: StreamingChain.ETH_MAINNET,
3732
+ * token_address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
3733
+ * });
3734
+ * console.log("Top Traders:", traders);
3735
+ * ```
3736
+ */
3737
+ getUPnLForToken(params) {
3738
+ const query = `
3739
+ query {
3740
+ upnlForToken(
3741
+ chain_name: ${params.chain_name}
3742
+ token_address: "${params.token_address}"
3743
+ ) {
3744
+ token_address
3745
+ wallet_address
3746
+ volume
3747
+ transactions_count
3748
+ pnl_realized_usd
3749
+ balance
3750
+ balance_pretty
3751
+ pnl_unrealized_usd
3752
+ contract_metadata {
3753
+ contract_name
3754
+ contract_address
3755
+ contract_decimals
3756
+ contract_ticker_symbol
3757
+ }
3758
+ }
3759
+ }
3760
+ `;
3761
+ const client = StreamingWebSocketClient.getClient();
3762
+ return new Promise((resolve, reject) => {
3763
+ let result = [];
3764
+ client.subscribe({
3765
+ query,
3766
+ }, {
3767
+ next: (data) => {
3768
+ if (data.data) {
3769
+ result = data.data.upnlForToken ?? [];
3770
+ }
3771
+ else if (data.errors) {
3772
+ reject(data.errors);
3773
+ }
3774
+ },
3775
+ error: (err) => reject(err),
3776
+ complete: () => resolve(result),
3777
+ });
3778
+ });
3779
+ }
3780
+ /**
3781
+ * Get unrealized and realized PnL for all tokens held by a wallet
3782
+ *
3783
+ * @param params - Parameters for the UPnL wallet query
3784
+ * @returns Promise resolving to an array of token PnL data for the wallet
3785
+ *
3786
+ * @example
3787
+ * ```typescript
3788
+ * const pnl = await streamingService.getUPnLForWallet({
3789
+ * chain_name: StreamingChain.ETH_MAINNET,
3790
+ * wallet_address: "0xfe97b0C517a84F98fc6eDe3CD26B43012d31992a"
3791
+ * });
3792
+ * console.log("Wallet PnL:", pnl);
3793
+ * ```
3794
+ */
3795
+ getUPnLForWallet(params) {
3796
+ const query = `
3797
+ query {
3798
+ upnlForWallet(
3799
+ chain_name: ${params.chain_name}
3800
+ wallet_address: "${params.wallet_address}"
3801
+ ) {
3802
+ token_address
3803
+ cost_basis
3804
+ current_price
3805
+ pnl_realized_usd
3806
+ pnl_unrealized_usd
3807
+ net_balance_change
3808
+ marketcap_usd
3809
+ contract_metadata {
3810
+ contract_name
3811
+ contract_address
3812
+ contract_decimals
3813
+ contract_ticker_symbol
3814
+ }
3815
+ }
3816
+ }
3817
+ `;
3818
+ const client = StreamingWebSocketClient.getClient();
3819
+ return new Promise((resolve, reject) => {
3820
+ let result = [];
3821
+ client.subscribe({
3822
+ query,
3823
+ }, {
3824
+ next: (data) => {
3825
+ if (data.data) {
3826
+ result = data.data.upnlForWallet ?? [];
3827
+ }
3828
+ else if (data.errors) {
3829
+ reject(data.errors);
3830
+ }
3831
+ },
3832
+ error: (err) => reject(err),
3833
+ complete: () => resolve(result),
3834
+ });
3835
+ });
3836
+ }
3555
3837
  }
3556
3838
  /**
3557
3839
  * Singleton WebSocket Client for GoldRush Streaming
@@ -3581,6 +3863,7 @@ class StreamingWebSocketClient {
3581
3863
  return;
3582
3864
  StreamingWebSocketClient.client = createClient({
3583
3865
  url: "wss://gr-staging-v2.streaming.covalenthq.com/graphql",
3866
+ lazyCloseTimeout: 3000,
3584
3867
  connectionParams: {
3585
3868
  GOLDRUSH_API_KEY: StreamingWebSocketClient.apiKey,
3586
3869
  },
@@ -3636,7 +3919,9 @@ class TransactionService {
3636
3919
  }
3637
3920
  /**
3638
3921
  *
3639
- * Commonly used to fetch and render a single transaction including its decoded log events.
3922
+ * Used to fetch and render a single transaction including its decoded event logs. For foundational chains, can also retrieve internal transactions, state changes and method ID where available.
3923
+ *
3924
+ * **Credit Cost**: 0.1 per call
3640
3925
  *
3641
3926
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
3642
3927
  * @param {string} txHash - The transaction hash.
@@ -3701,7 +3986,9 @@ class TransactionService {
3701
3986
  }
3702
3987
  /**
3703
3988
  *
3704
- * Commonly used to fetch the earliest and latest transactions, and the transaction count for a wallet. Calculate the age of the wallet and the time it has been idle and quickly gain insights into their engagement with web3.
3989
+ * Used to fetch the earliest and latest transactions, and the transaction count for a wallet. Also enriched with gas expenditure details and total ERC20 token transfers count.
3990
+ *
3991
+ * **Credit Cost**: 1 per call
3705
3992
  *
3706
3993
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
3707
3994
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
@@ -3816,6 +4103,8 @@ class TransactionService {
3816
4103
  *
3817
4104
  * Commonly used to fetch and render the most recent transactions involving an address. Frequently seen in wallet applications.
3818
4105
  *
4106
+ * **Credit Cost**: 0.1 per item
4107
+ *
3819
4108
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
3820
4109
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
3821
4110
  * @param {GetAllTransactionsForAddressQueryParamOpts} queryParamOpts
@@ -3888,6 +4177,8 @@ class TransactionService {
3888
4177
  *
3889
4178
  * Commonly used to fetch and render the most recent transactions involving an address. Frequently seen in wallet applications.
3890
4179
  *
4180
+ * **Credit Cost**: 0.1 per item
4181
+ *
3891
4182
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
3892
4183
  * @param {string} walletAddress - The requested address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
3893
4184
  * @param {GetAllTransactionsForAddressQueryParamOpts} queryParamOpts
@@ -4082,6 +4373,8 @@ class TransactionService {
4082
4373
  *
4083
4374
  * Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
4084
4375
  *
4376
+ * **Credit Cost**: 0.1 per item
4377
+ *
4085
4378
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
4086
4379
  * @param {number} blockHeight - The requested block height.
4087
4380
  * @param {number} page - The requested page, 0-indexed.
@@ -4140,6 +4433,8 @@ class TransactionService {
4140
4433
  *
4141
4434
  * Commonly used to fetch all transactions including their decoded log events in a block and further flag interesting wallets or transactions.
4142
4435
  *
4436
+ * **Credit Cost**: 0.1 per item
4437
+ *
4143
4438
  * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
4144
4439
  * @param {string} blockHash - The requested block hash.
4145
4440
  * @param {getTransactionsForBlockByPageQueryParamOpts} queryParamOpts
@@ -4385,9 +4680,10 @@ class Execution {
4385
4680
  };
4386
4681
  }
4387
4682
  catch (error) {
4683
+ const err = error;
4388
4684
  debugOutput(this.settings, `Request URL: ${endpoint} | Retry Enabled: ${this.enableRetry} | Retry Count: ${retryCount} | Max Retries: ${this.maxRetries} | Retry Delay: ${this.retryDelay}ms`, error);
4389
4685
  if (this.enableRetry &&
4390
- (error?.error_code === 429 || error?.cause?.code === 429)) {
4686
+ (err?.error_code === 429 || err?.cause?.code === 429)) {
4391
4687
  if (retryCount >= this.maxRetries) {
4392
4688
  completed = true;
4393
4689
  return {
@@ -4408,9 +4704,9 @@ class Execution {
4408
4704
  return {
4409
4705
  data: null,
4410
4706
  error: true,
4411
- error_code: error?.cause?.code || error?.error_code || 500,
4412
- error_message: error?.cause?.message ||
4413
- error?.error_message ||
4707
+ error_code: err?.cause?.code || err?.error_code || 500,
4708
+ error_message: err?.cause?.message ||
4709
+ err?.error_message ||
4414
4710
  "Internal server error",
4415
4711
  };
4416
4712
  }
@@ -5650,7 +5946,10 @@ exports.StreamingChain = void 0;
5650
5946
  StreamingChain["ETH_MAINNET"] = "ETH_MAINNET";
5651
5947
  StreamingChain["BSC_MAINNET"] = "BSC_MAINNET";
5652
5948
  StreamingChain["HYPERCORE_MAINNET"] = "HYPERCORE_MAINNET";
5949
+ StreamingChain["HYPEREVM_MAINNET"] = "HYPEREVM_MAINNET";
5653
5950
  StreamingChain["MONAD_MAINNET"] = "MONAD_MAINNET";
5951
+ StreamingChain["POLYGON_MAINNET"] = "POLYGON_MAINNET";
5952
+ StreamingChain["MEGAETH_MAINNET"] = "MEGAETH_MAINNET";
5654
5953
  })(exports.StreamingChain || (exports.StreamingChain = {}));
5655
5954
  exports.StreamingInterval = void 0;
5656
5955
  (function (StreamingInterval) {
@@ -5678,9 +5977,8 @@ exports.StreamingProtocol = void 0;
5678
5977
  (function (StreamingProtocol) {
5679
5978
  StreamingProtocol["UNISWAP_V2"] = "UNISWAP_V2";
5680
5979
  StreamingProtocol["UNISWAP_V3"] = "UNISWAP_V3";
5681
- // UNISWAP_V4 = "UNISWAP_V4",
5682
5980
  StreamingProtocol["VIRTUALS_V2"] = "VIRTUALS_V2";
5683
- StreamingProtocol["CLANKER_V3"] = "CLANKER_V3";
5981
+ StreamingProtocol["CLANKER_V3"] = "CLANKER";
5684
5982
  StreamingProtocol["RAYDIUM_AMM"] = "RAYDIUM_AMM";
5685
5983
  StreamingProtocol["RAYDIUM_CLMM"] = "RAYDIUM_CLMM";
5686
5984
  StreamingProtocol["RAYDIUM_CPMM"] = "RAYDIUM_CPMM";
@@ -5697,7 +5995,12 @@ exports.StreamingProtocol = void 0;
5697
5995
  StreamingProtocol["SHADOW_V3"] = "SHADOW_V3";
5698
5996
  StreamingProtocol["OCTOSWAP_V2"] = "OCTOSWAP_V2";
5699
5997
  StreamingProtocol["OCTOSWAP_V3"] = "OCTOSWAP_V3";
5700
- // CROCSWAP = "CROCSWAP",
5998
+ StreamingProtocol["QUICKSWAP_V2"] = "QUICKSWAP_V2";
5999
+ StreamingProtocol["QUICKSWAP_V3"] = "QUICKSWAP_V3";
6000
+ StreamingProtocol["SUSHISWAP_V2"] = "SUSHISWAP_V2";
6001
+ StreamingProtocol["PROJECT_X"] = "PROJECT_X";
6002
+ StreamingProtocol["KUMBAYA_V1"] = "KUMBAYA_V1";
6003
+ StreamingProtocol["JOE_V2"] = "JOE_V2";
5701
6004
  })(exports.StreamingProtocol || (exports.StreamingProtocol = {}));
5702
6005
 
5703
6006
  exports.GoldRushClient = GoldRushClient;