@metamask/assets-controllers 94.0.0 → 94.1.0

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/dist/AccountTrackerController.cjs +71 -57
  3. package/dist/AccountTrackerController.cjs.map +1 -1
  4. package/dist/AccountTrackerController.d.cts +3 -2
  5. package/dist/AccountTrackerController.d.cts.map +1 -1
  6. package/dist/AccountTrackerController.d.mts +3 -2
  7. package/dist/AccountTrackerController.d.mts.map +1 -1
  8. package/dist/AccountTrackerController.mjs +71 -57
  9. package/dist/AccountTrackerController.mjs.map +1 -1
  10. package/dist/TokenBalancesController.cjs +351 -382
  11. package/dist/TokenBalancesController.cjs.map +1 -1
  12. package/dist/TokenBalancesController.d.cts +20 -39
  13. package/dist/TokenBalancesController.d.cts.map +1 -1
  14. package/dist/TokenBalancesController.d.mts +20 -39
  15. package/dist/TokenBalancesController.d.mts.map +1 -1
  16. package/dist/TokenBalancesController.mjs +351 -382
  17. package/dist/TokenBalancesController.mjs.map +1 -1
  18. package/dist/TokenDetectionController.cjs +139 -207
  19. package/dist/TokenDetectionController.cjs.map +1 -1
  20. package/dist/TokenDetectionController.d.cts +38 -12
  21. package/dist/TokenDetectionController.d.cts.map +1 -1
  22. package/dist/TokenDetectionController.d.mts +38 -12
  23. package/dist/TokenDetectionController.d.mts.map +1 -1
  24. package/dist/TokenDetectionController.mjs +140 -208
  25. package/dist/TokenDetectionController.mjs.map +1 -1
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +1 -1
  28. package/dist/index.d.cts.map +1 -1
  29. package/dist/index.d.mts +1 -1
  30. package/dist/index.d.mts.map +1 -1
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/multi-chain-accounts-service/api-balance-fetcher.cjs +13 -2
  33. package/dist/multi-chain-accounts-service/api-balance-fetcher.cjs.map +1 -1
  34. package/dist/multi-chain-accounts-service/api-balance-fetcher.d.cts.map +1 -1
  35. package/dist/multi-chain-accounts-service/api-balance-fetcher.d.mts.map +1 -1
  36. package/dist/multi-chain-accounts-service/api-balance-fetcher.mjs +13 -2
  37. package/dist/multi-chain-accounts-service/api-balance-fetcher.mjs.map +1 -1
  38. package/dist/multi-chain-accounts-service/types.cjs.map +1 -1
  39. package/dist/multi-chain-accounts-service/types.d.cts +2 -1
  40. package/dist/multi-chain-accounts-service/types.d.cts.map +1 -1
  41. package/dist/multi-chain-accounts-service/types.d.mts +2 -1
  42. package/dist/multi-chain-accounts-service/types.d.mts.map +1 -1
  43. package/dist/multi-chain-accounts-service/types.mjs.map +1 -1
  44. package/dist/token-prices-service/codefi-v2.cjs +12 -0
  45. package/dist/token-prices-service/codefi-v2.cjs.map +1 -1
  46. package/dist/token-prices-service/codefi-v2.d.cts +12 -2
  47. package/dist/token-prices-service/codefi-v2.d.cts.map +1 -1
  48. package/dist/token-prices-service/codefi-v2.d.mts +12 -2
  49. package/dist/token-prices-service/codefi-v2.d.mts.map +1 -1
  50. package/dist/token-prices-service/codefi-v2.mjs +12 -0
  51. package/dist/token-prices-service/codefi-v2.mjs.map +1 -1
  52. package/dist/token-service.cjs +11 -3
  53. package/dist/token-service.cjs.map +1 -1
  54. package/dist/token-service.d.cts +3 -1
  55. package/dist/token-service.d.cts.map +1 -1
  56. package/dist/token-service.d.mts +3 -1
  57. package/dist/token-service.d.mts.map +1 -1
  58. package/dist/token-service.mjs +11 -3
  59. package/dist/token-service.mjs.map +1 -1
  60. package/package.json +1 -1
@@ -18,6 +18,7 @@ function $importDefault(module) {
18
18
  }
19
19
  import { Contract } from "@ethersproject/contracts";
20
20
  import { safelyExecute, safelyExecuteWithTimeout, toHex, toChecksumHexAddress } from "@metamask/controller-utils";
21
+ import { parseCaipChainId } from "@metamask/utils";
21
22
  import $BN from "bn.js";
22
23
  const BN = $importDefault($BN);
23
24
  import { fetchMultiChainBalancesV4 } from "./multi-chain-accounts.mjs";
@@ -63,8 +64,18 @@ export class AccountsApiBalanceFetcher {
63
64
  throw new Error('Accounts API request timed out or failed');
64
65
  }
65
66
  // Extract unprocessed networks and convert to hex chain IDs
66
- const unprocessedChainIds = apiResponse.unprocessedNetworks
67
- ? apiResponse.unprocessedNetworks.map((chainId) => toHex(chainId))
67
+ // V4 API returns CAIP chain IDs like 'eip155:1329', need to parse them
68
+ // V2 API returns decimal numbers, handle both cases
69
+ const unprocessedChainIds = apiResponse
70
+ .unprocessedNetworks?.length
71
+ ? apiResponse.unprocessedNetworks.map((network) => {
72
+ if (typeof network === 'string') {
73
+ // CAIP chain ID format: 'eip155:1329'
74
+ return toHex(parseCaipChainId(network).reference);
75
+ }
76
+ // Decimal number format
77
+ return toHex(network);
78
+ })
68
79
  : undefined;
69
80
  const stakedBalances = await __classPrivateFieldGet(this, _AccountsApiBalanceFetcher_instances, "m", _AccountsApiBalanceFetcher_fetchStakedBalances).call(this, caipAddrs);
70
81
  const results = [];
@@ -1 +1 @@
1
- {"version":3,"file":"api-balance-fetcher.mjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/api-balance-fetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,QAAQ,EAAE,iCAAiC;AAEpD,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,KAAK,EACL,oBAAoB,EACrB,mCAAmC;AAGpC,OAAO,GAAE,cAAc;;AAEvB,OAAO,EAAE,yBAAyB,EAAE,mCAA+B;AACnE,OAAO,EAAE,mCAAmC,EAAE,wCAAoC;AAClF,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,8BAA8B,EAC/B,0BAAsB;AACvB,OAAO,EAAE,kCAAkC,EAAE,yBAAqB;AAElE,+FAA+F;AAC/F,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,iDAAiD;AACjD,MAAM,uBAAuB,GAAG,KAAM,CAAC;AA6BvC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAmB,EAAE,CACjD,oBAAoB,CAAC,IAA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Q,CACT,CAAC;IACJ,CAAC;IASD,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAU,CAAC;IACjD,MAAM,WAAW,GAAG,MAAM,uBAAuB,CAG/C;QACA,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,uBAAuB;QAClC,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE;YACxC,MAAM,QAAQ,GAAG,MAAM,yBAAyB,CAC9C,EAAE,gBAAgB,EAAE,KAAK,EAAE,EAC3B,uBAAA,IAAI,2CAAU,EACd,QAAQ,CACT,CAAC;YACF,+CAA+C;YAC/C,IAAI,QAAQ,CAAC,mBAAmB,EAAE,CAAC;gBACjC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC/C,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC,CACpC,CAAC;YACJ,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC1D,CAAC;QACD,aAAa,EAAE,EAAE;KAClB,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,WAAW;QACrB,mBAAmB,EAAE,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC;KACxC,CAAC;AACpB,CAAC","sourcesContent":["import type { BigNumber } from '@ethersproject/bignumber';\nimport { Contract } from '@ethersproject/contracts';\nimport type { Web3Provider } from '@ethersproject/providers';\nimport {\n safelyExecute,\n safelyExecuteWithTimeout,\n toHex,\n toChecksumHexAddress,\n} from '@metamask/controller-utils';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { CaipAccountAddress, Hex } from '@metamask/utils';\nimport BN from 'bn.js';\n\nimport { fetchMultiChainBalancesV4 } from './multi-chain-accounts';\nimport { STAKING_CONTRACT_ADDRESS_BY_CHAINID } from '../AssetsContractController';\nimport {\n accountAddressToCaipReference,\n reduceInBatchesSerially,\n SupportedStakedBalanceNetworks,\n} from '../assetsUtil';\nimport { SUPPORTED_NETWORKS_ACCOUNTS_API_V4 } from '../constants';\n\n// Maximum number of account addresses that can be sent to the accounts API in a single request\nconst ACCOUNTS_API_BATCH_SIZE = 20;\n\n// Timeout for accounts API requests (10 seconds)\nconst ACCOUNTS_API_TIMEOUT_MS = 10_000;\n\nexport type ChainIdHex = Hex;\nexport type ChecksumAddress = Hex;\n\nexport type ProcessedBalance = {\n success: boolean;\n value?: BN;\n account: ChecksumAddress | string;\n token: ChecksumAddress;\n chainId: ChainIdHex;\n};\n\nexport type BalanceFetchResult = {\n balances: ProcessedBalance[];\n unprocessedChainIds?: ChainIdHex[];\n};\n\nexport type BalanceFetcher = {\n supports(chainId: ChainIdHex): boolean;\n fetch(input: {\n chainIds: ChainIdHex[];\n queryAllAccounts: boolean;\n selectedAccount: ChecksumAddress;\n allAccounts: InternalAccount[];\n jwtToken?: string;\n }): Promise<BalanceFetchResult>;\n};\n\nconst checksum = (addr: string): ChecksumAddress =>\n toChecksumHexAddress(addr) as ChecksumAddress;\n\nconst toCaipAccount = (\n chainId: ChainIdHex,\n account: ChecksumAddress,\n): CaipAccountAddress => accountAddressToCaipReference(chainId, account);\n\nexport type GetProviderFunction = (chainId: ChainIdHex) => Web3Provider;\n\nexport class AccountsApiBalanceFetcher implements BalanceFetcher {\n readonly #platform: 'extension' | 'mobile' = 'extension';\n\n readonly #getProvider?: GetProviderFunction;\n\n constructor(\n platform: 'extension' | 'mobile' = 'extension',\n getProvider?: GetProviderFunction,\n ) {\n this.#platform = platform;\n this.#getProvider = getProvider;\n }\n\n supports(chainId: ChainIdHex): boolean {\n return SUPPORTED_NETWORKS_ACCOUNTS_API_V4.includes(chainId);\n }\n\n async #fetchStakedBalances(\n addrs: CaipAccountAddress[],\n ): Promise<ProcessedBalance[]> {\n // Return empty array if no provider is available for blockchain calls\n if (!this.#getProvider) {\n return [];\n }\n\n const results: ProcessedBalance[] = [];\n\n // Group addresses by chain ID\n const addressesByChain: Record<ChainIdHex, ChecksumAddress[]> = {};\n\n for (const caipAddr of addrs) {\n const [, chainRef, address] = caipAddr.split(':');\n const chainId = toHex(parseInt(chainRef, 10));\n const checksumAddress = checksum(address);\n\n if (!addressesByChain[chainId]) {\n addressesByChain[chainId] = [];\n }\n addressesByChain[chainId].push(checksumAddress);\n }\n\n // Process each supported chain\n for (const [chainId, addresses] of Object.entries(addressesByChain)) {\n const chainIdHex = chainId as ChainIdHex;\n\n // Only fetch staked balance on supported networks (mainnet and hoodi)\n if (\n ![\n SupportedStakedBalanceNetworks.mainnet,\n SupportedStakedBalanceNetworks.hoodi,\n ].includes(chainIdHex as SupportedStakedBalanceNetworks)\n ) {\n continue;\n }\n\n // Only fetch staked balance if contract address exists\n if (!(chainIdHex in STAKING_CONTRACT_ADDRESS_BY_CHAINID)) {\n continue;\n }\n\n const contractAddress = STAKING_CONTRACT_ADDRESS_BY_CHAINID[chainIdHex];\n const provider = this.#getProvider(chainIdHex);\n\n const abi = [\n {\n inputs: [\n { internalType: 'address', name: 'account', type: 'address' },\n ],\n name: 'getShares',\n outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [\n { internalType: 'uint256', name: 'shares', type: 'uint256' },\n ],\n name: 'convertToAssets',\n outputs: [\n { internalType: 'uint256', name: 'assets', type: 'uint256' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n ];\n\n try {\n const contract = new Contract(contractAddress, abi, provider);\n\n // Get shares for each address\n for (const address of addresses) {\n try {\n const shares = await safelyExecute(() =>\n contract.getShares(address),\n );\n\n if (shares && (shares as BigNumber).gt(0)) {\n // Convert shares to assets (actual staked ETH amount)\n const assets = await safelyExecute(() =>\n contract.convertToAssets(shares),\n );\n\n if (assets) {\n results.push({\n success: true,\n value: new BN((assets as BigNumber).toString()),\n account: address,\n token: checksum(contractAddress),\n chainId: chainIdHex,\n });\n }\n } else {\n // Return zero balance for accounts with no staked assets\n results.push({\n success: true,\n value: new BN('0'),\n account: address,\n token: checksum(contractAddress),\n chainId: chainIdHex,\n });\n }\n } catch (error) {\n // Log error and continue with next address\n console.error(\n `Error fetching staked balance for ${address}:`,\n error,\n );\n results.push({\n success: false,\n account: address,\n token: checksum(contractAddress),\n chainId: chainIdHex,\n });\n }\n }\n } catch (error) {\n console.error(\n `Error setting up staking contract for chain ${chainId}:`,\n error,\n );\n }\n }\n\n return results;\n }\n\n async #fetchBalances(addrs: CaipAccountAddress[], jwtToken?: string) {\n // If we have fewer than or equal to the batch size, make a single request\n if (addrs.length <= ACCOUNTS_API_BATCH_SIZE) {\n return await fetchMultiChainBalancesV4(\n { accountAddresses: addrs },\n this.#platform,\n jwtToken,\n );\n }\n\n // Otherwise, batch the requests to respect the 50-element limit\n type BalanceData = Awaited<\n ReturnType<typeof fetchMultiChainBalancesV4>\n >['balances'][number];\n\n type ResponseData = Awaited<ReturnType<typeof fetchMultiChainBalancesV4>>;\n\n const allUnprocessedNetworks = new Set<number>();\n const allBalances = await reduceInBatchesSerially<\n CaipAccountAddress,\n BalanceData[]\n >({\n values: addrs,\n batchSize: ACCOUNTS_API_BATCH_SIZE,\n eachBatch: async (workingResult, batch) => {\n const response = await fetchMultiChainBalancesV4(\n { accountAddresses: batch },\n this.#platform,\n jwtToken,\n );\n // Collect unprocessed networks from each batch\n if (response.unprocessedNetworks) {\n response.unprocessedNetworks.forEach((network) =>\n allUnprocessedNetworks.add(network),\n );\n }\n return [...(workingResult || []), ...response.balances];\n },\n initialResult: [],\n });\n\n return {\n balances: allBalances,\n unprocessedNetworks: Array.from(allUnprocessedNetworks),\n } as ResponseData;\n }\n\n async fetch({\n chainIds,\n queryAllAccounts,\n selectedAccount,\n allAccounts,\n jwtToken,\n }: Parameters<BalanceFetcher['fetch']>[0]): Promise<BalanceFetchResult> {\n const caipAddrs: CaipAccountAddress[] = [];\n\n for (const chainId of chainIds.filter((c) => this.supports(c))) {\n if (queryAllAccounts) {\n allAccounts.forEach((a) =>\n caipAddrs.push(toCaipAccount(chainId, a.address as ChecksumAddress)),\n );\n } else {\n caipAddrs.push(toCaipAccount(chainId, selectedAccount));\n }\n }\n\n if (!caipAddrs.length) {\n return { balances: [] };\n }\n\n // Let errors propagate to TokenBalancesController for RPC fallback\n // Use timeout to prevent hanging API calls (30 seconds)\n const apiResponse = await safelyExecuteWithTimeout(\n () => this.#fetchBalances(caipAddrs, jwtToken),\n false, // don't log error here, let it propagate\n ACCOUNTS_API_TIMEOUT_MS,\n );\n\n // If API call timed out or failed, throw error to trigger RPC fallback\n if (!apiResponse) {\n throw new Error('Accounts API request timed out or failed');\n }\n\n // Extract unprocessed networks and convert to hex chain IDs\n const unprocessedChainIds: ChainIdHex[] | undefined =\n apiResponse.unprocessedNetworks\n ? apiResponse.unprocessedNetworks.map((chainId) => toHex(chainId))\n : undefined;\n\n const stakedBalances = await this.#fetchStakedBalances(caipAddrs);\n\n const results: ProcessedBalance[] = [];\n\n // Collect all unique addresses and chains from the CAIP addresses\n const addressChainMap = new Map<string, Set<ChainIdHex>>();\n caipAddrs.forEach((caipAddr) => {\n const [, chainRef, address] = caipAddr.split(':');\n const chainId = toHex(parseInt(chainRef, 10));\n const checksumAddress = checksum(address);\n\n if (!addressChainMap.has(checksumAddress)) {\n addressChainMap.set(checksumAddress, new Set());\n }\n addressChainMap.get(checksumAddress)?.add(chainId);\n });\n\n // Ensure native token entries exist for all addresses on all requested chains\n const ZERO_ADDRESS =\n '0x0000000000000000000000000000000000000000' as ChecksumAddress;\n const nativeBalancesFromAPI = new Map<string, BN>(); // key: `${address}-${chainId}`\n\n // Process regular API balances\n if (apiResponse.balances) {\n const apiBalances = apiResponse.balances.flatMap((b) => {\n const addressPart = b.accountAddress?.split(':')[2];\n if (!addressPart) {\n return [];\n }\n const account = checksum(addressPart);\n const token = checksum(b.address);\n // Use original address for zero address tokens, checksummed for others\n // TODO: this is a hack to get the correct account address type but needs to be fixed\n // by mgrating tokenBalancesController to checksum addresses\n const finalAccount: ChecksumAddress | string =\n token === ZERO_ADDRESS ? account : addressPart;\n const chainId = toHex(b.chainId);\n\n let value: BN | undefined;\n try {\n // Convert string balance to BN avoiding floating point precision issues\n const { balance: balanceStr, decimals } = b;\n\n // Split the balance string into integer and decimal parts\n const [integerPart = '0', decimalPart = ''] = balanceStr.split('.');\n\n // Pad or truncate decimal part to match token decimals\n const paddedDecimalPart = decimalPart\n .padEnd(decimals, '0')\n .slice(0, decimals);\n\n // Combine and create BN\n const fullIntegerStr = integerPart + paddedDecimalPart;\n value = new BN(fullIntegerStr);\n } catch {\n value = undefined;\n }\n\n // Track native balances for later\n if (token === ZERO_ADDRESS && value !== undefined) {\n nativeBalancesFromAPI.set(`${finalAccount}-${chainId}`, value);\n }\n\n return [\n {\n success: value !== undefined,\n value,\n account: finalAccount,\n token,\n chainId,\n },\n ];\n });\n results.push(...apiBalances);\n }\n\n // Add zero native balance entries for addresses that API didn't return\n addressChainMap.forEach((chains, address) => {\n chains.forEach((chainId) => {\n const key = `${address}-${chainId}`;\n const existingBalance = nativeBalancesFromAPI.get(key);\n\n if (!existingBalance) {\n // Add zero native balance entry if API succeeded but didn't return one\n results.push({\n success: true,\n value: new BN('0'),\n account: address as ChecksumAddress,\n token: ZERO_ADDRESS,\n chainId,\n });\n }\n });\n });\n\n // Add staked balances\n results.push(...stakedBalances);\n\n return {\n balances: results,\n unprocessedChainIds,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"api-balance-fetcher.mjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/api-balance-fetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,QAAQ,EAAE,iCAAiC;AAEpD,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,KAAK,EACL,oBAAoB,EACrB,mCAAmC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,wBAAwB;AACnD,OAAO,GAAE,cAAc;;AAEvB,OAAO,EAAE,yBAAyB,EAAE,mCAA+B;AAEnE,OAAO,EAA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CAAC;QACD,aAAa,EAAE,EAAE;KAClB,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,WAAW;QACrB,mBAAmB,EAAE,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC;KACxC,CAAC;AACpB,CAAC","sourcesContent":["import type { BigNumber } from '@ethersproject/bignumber';\nimport { Contract } from '@ethersproject/contracts';\nimport type { Web3Provider } from '@ethersproject/providers';\nimport {\n safelyExecute,\n safelyExecuteWithTimeout,\n toHex,\n toChecksumHexAddress,\n} from '@metamask/controller-utils';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { CaipAccountAddress, CaipChainId, Hex } from '@metamask/utils';\nimport { parseCaipChainId } from '@metamask/utils';\nimport BN from 'bn.js';\n\nimport { fetchMultiChainBalancesV4 } from './multi-chain-accounts';\nimport type { GetBalancesResponse } from './types';\nimport { STAKING_CONTRACT_ADDRESS_BY_CHAINID } from '../AssetsContractController';\nimport {\n accountAddressToCaipReference,\n reduceInBatchesSerially,\n SupportedStakedBalanceNetworks,\n} from '../assetsUtil';\nimport { SUPPORTED_NETWORKS_ACCOUNTS_API_V4 } from '../constants';\n\n// Maximum number of account addresses that can be sent to the accounts API in a single request\nconst ACCOUNTS_API_BATCH_SIZE = 20;\n\n// Timeout for accounts API requests (10 seconds)\nconst ACCOUNTS_API_TIMEOUT_MS = 10_000;\n\nexport type ChainIdHex = Hex;\nexport type ChecksumAddress = Hex;\n\nexport type ProcessedBalance = {\n success: boolean;\n value?: BN;\n account: ChecksumAddress | string;\n token: ChecksumAddress;\n chainId: ChainIdHex;\n};\n\nexport type BalanceFetchResult = {\n balances: ProcessedBalance[];\n unprocessedChainIds?: ChainIdHex[];\n};\n\nexport type BalanceFetcher = {\n supports(chainId: ChainIdHex): boolean;\n fetch(input: {\n chainIds: ChainIdHex[];\n queryAllAccounts: boolean;\n selectedAccount: ChecksumAddress;\n allAccounts: InternalAccount[];\n jwtToken?: string;\n }): Promise<BalanceFetchResult>;\n};\n\nconst checksum = (addr: string): ChecksumAddress =>\n toChecksumHexAddress(addr) as ChecksumAddress;\n\nconst toCaipAccount = (\n chainId: ChainIdHex,\n account: ChecksumAddress,\n): CaipAccountAddress => accountAddressToCaipReference(chainId, account);\n\nexport type GetProviderFunction = (chainId: ChainIdHex) => Web3Provider;\n\nexport class AccountsApiBalanceFetcher implements BalanceFetcher {\n readonly #platform: 'extension' | 'mobile' = 'extension';\n\n readonly #getProvider?: GetProviderFunction;\n\n constructor(\n platform: 'extension' | 'mobile' = 'extension',\n getProvider?: GetProviderFunction,\n ) {\n this.#platform = platform;\n this.#getProvider = getProvider;\n }\n\n supports(chainId: ChainIdHex): boolean {\n return SUPPORTED_NETWORKS_ACCOUNTS_API_V4.includes(chainId);\n }\n\n async #fetchStakedBalances(\n addrs: CaipAccountAddress[],\n ): Promise<ProcessedBalance[]> {\n // Return empty array if no provider is available for blockchain calls\n if (!this.#getProvider) {\n return [];\n }\n\n const results: ProcessedBalance[] = [];\n\n // Group addresses by chain ID\n const addressesByChain: Record<ChainIdHex, ChecksumAddress[]> = {};\n\n for (const caipAddr of addrs) {\n const [, chainRef, address] = caipAddr.split(':');\n const chainId = toHex(parseInt(chainRef, 10));\n const checksumAddress = checksum(address);\n\n if (!addressesByChain[chainId]) {\n addressesByChain[chainId] = [];\n }\n addressesByChain[chainId].push(checksumAddress);\n }\n\n // Process each supported chain\n for (const [chainId, addresses] of Object.entries(addressesByChain)) {\n const chainIdHex = chainId as ChainIdHex;\n\n // Only fetch staked balance on supported networks (mainnet and hoodi)\n if (\n ![\n SupportedStakedBalanceNetworks.mainnet,\n SupportedStakedBalanceNetworks.hoodi,\n ].includes(chainIdHex as SupportedStakedBalanceNetworks)\n ) {\n continue;\n }\n\n // Only fetch staked balance if contract address exists\n if (!(chainIdHex in STAKING_CONTRACT_ADDRESS_BY_CHAINID)) {\n continue;\n }\n\n const contractAddress = STAKING_CONTRACT_ADDRESS_BY_CHAINID[chainIdHex];\n const provider = this.#getProvider(chainIdHex);\n\n const abi = [\n {\n inputs: [\n { internalType: 'address', name: 'account', type: 'address' },\n ],\n name: 'getShares',\n outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [\n { internalType: 'uint256', name: 'shares', type: 'uint256' },\n ],\n name: 'convertToAssets',\n outputs: [\n { internalType: 'uint256', name: 'assets', type: 'uint256' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n ];\n\n try {\n const contract = new Contract(contractAddress, abi, provider);\n\n // Get shares for each address\n for (const address of addresses) {\n try {\n const shares = await safelyExecute(() =>\n contract.getShares(address),\n );\n\n if (shares && (shares as BigNumber).gt(0)) {\n // Convert shares to assets (actual staked ETH amount)\n const assets = await safelyExecute(() =>\n contract.convertToAssets(shares),\n );\n\n if (assets) {\n results.push({\n success: true,\n value: new BN((assets as BigNumber).toString()),\n account: address,\n token: checksum(contractAddress),\n chainId: chainIdHex,\n });\n }\n } else {\n // Return zero balance for accounts with no staked assets\n results.push({\n success: true,\n value: new BN('0'),\n account: address,\n token: checksum(contractAddress),\n chainId: chainIdHex,\n });\n }\n } catch (error) {\n // Log error and continue with next address\n console.error(\n `Error fetching staked balance for ${address}:`,\n error,\n );\n results.push({\n success: false,\n account: address,\n token: checksum(contractAddress),\n chainId: chainIdHex,\n });\n }\n }\n } catch (error) {\n console.error(\n `Error setting up staking contract for chain ${chainId}:`,\n error,\n );\n }\n }\n\n return results;\n }\n\n async #fetchBalances(addrs: CaipAccountAddress[], jwtToken?: string) {\n // If we have fewer than or equal to the batch size, make a single request\n if (addrs.length <= ACCOUNTS_API_BATCH_SIZE) {\n return await fetchMultiChainBalancesV4(\n { accountAddresses: addrs },\n this.#platform,\n jwtToken,\n );\n }\n\n // Otherwise, batch the requests to respect the 50-element limit\n type BalanceData = Awaited<\n ReturnType<typeof fetchMultiChainBalancesV4>\n >['balances'][number];\n\n type ResponseData = Awaited<ReturnType<typeof fetchMultiChainBalancesV4>>;\n\n const allUnprocessedNetworks = new Set<number | string>();\n const allBalances = await reduceInBatchesSerially<\n CaipAccountAddress,\n BalanceData[]\n >({\n values: addrs,\n batchSize: ACCOUNTS_API_BATCH_SIZE,\n eachBatch: async (workingResult, batch) => {\n const response = await fetchMultiChainBalancesV4(\n { accountAddresses: batch },\n this.#platform,\n jwtToken,\n );\n // Collect unprocessed networks from each batch\n if (response.unprocessedNetworks) {\n response.unprocessedNetworks.forEach((network) =>\n allUnprocessedNetworks.add(network),\n );\n }\n return [...(workingResult || []), ...response.balances];\n },\n initialResult: [],\n });\n\n return {\n balances: allBalances,\n unprocessedNetworks: Array.from(allUnprocessedNetworks),\n } as ResponseData;\n }\n\n async fetch({\n chainIds,\n queryAllAccounts,\n selectedAccount,\n allAccounts,\n jwtToken,\n }: Parameters<BalanceFetcher['fetch']>[0]): Promise<BalanceFetchResult> {\n const caipAddrs: CaipAccountAddress[] = [];\n\n for (const chainId of chainIds.filter((c) => this.supports(c))) {\n if (queryAllAccounts) {\n allAccounts.forEach((a) =>\n caipAddrs.push(toCaipAccount(chainId, a.address as ChecksumAddress)),\n );\n } else {\n caipAddrs.push(toCaipAccount(chainId, selectedAccount));\n }\n }\n\n if (!caipAddrs.length) {\n return { balances: [] };\n }\n\n // Let errors propagate to TokenBalancesController for RPC fallback\n // Use timeout to prevent hanging API calls (30 seconds)\n const apiResponse = await safelyExecuteWithTimeout(\n () => this.#fetchBalances(caipAddrs, jwtToken),\n false, // don't log error here, let it propagate\n ACCOUNTS_API_TIMEOUT_MS,\n );\n\n // If API call timed out or failed, throw error to trigger RPC fallback\n if (!apiResponse) {\n throw new Error('Accounts API request timed out or failed');\n }\n\n // Extract unprocessed networks and convert to hex chain IDs\n // V4 API returns CAIP chain IDs like 'eip155:1329', need to parse them\n // V2 API returns decimal numbers, handle both cases\n const unprocessedChainIds: ChainIdHex[] | undefined = apiResponse\n .unprocessedNetworks?.length\n ? apiResponse.unprocessedNetworks.map((network) => {\n if (typeof network === 'string') {\n // CAIP chain ID format: 'eip155:1329'\n return toHex(parseCaipChainId(network as CaipChainId).reference);\n }\n // Decimal number format\n return toHex(network);\n })\n : undefined;\n\n const stakedBalances = await this.#fetchStakedBalances(caipAddrs);\n\n const results: ProcessedBalance[] = [];\n\n // Collect all unique addresses and chains from the CAIP addresses\n const addressChainMap = new Map<string, Set<ChainIdHex>>();\n caipAddrs.forEach((caipAddr) => {\n const [, chainRef, address] = caipAddr.split(':');\n const chainId = toHex(parseInt(chainRef, 10));\n const checksumAddress = checksum(address);\n\n if (!addressChainMap.has(checksumAddress)) {\n addressChainMap.set(checksumAddress, new Set());\n }\n addressChainMap.get(checksumAddress)?.add(chainId);\n });\n\n // Ensure native token entries exist for all addresses on all requested chains\n const ZERO_ADDRESS =\n '0x0000000000000000000000000000000000000000' as ChecksumAddress;\n const nativeBalancesFromAPI = new Map<string, BN>(); // key: `${address}-${chainId}`\n\n // Process regular API balances\n if (apiResponse.balances) {\n const apiBalances = apiResponse.balances.flatMap(\n (b: GetBalancesResponse['balances'][number]) => {\n const addressPart = b.accountAddress?.split(':')[2];\n if (!addressPart) {\n return [];\n }\n const account = checksum(addressPart);\n const token = checksum(b.address);\n // Use original address for zero address tokens, checksummed for others\n // TODO: this is a hack to get the correct account address type but needs to be fixed\n // by mgrating tokenBalancesController to checksum addresses\n const finalAccount: ChecksumAddress | string =\n token === ZERO_ADDRESS ? account : addressPart;\n const chainId = toHex(b.chainId);\n\n let value: BN | undefined;\n try {\n // Convert string balance to BN avoiding floating point precision issues\n const { balance: balanceStr, decimals } = b;\n\n // Split the balance string into integer and decimal parts\n const [integerPart = '0', decimalPart = ''] = balanceStr.split('.');\n\n // Pad or truncate decimal part to match token decimals\n const paddedDecimalPart = decimalPart\n .padEnd(decimals, '0')\n .slice(0, decimals);\n\n // Combine and create BN\n const fullIntegerStr = integerPart + paddedDecimalPart;\n value = new BN(fullIntegerStr);\n } catch {\n value = undefined;\n }\n\n // Track native balances for later\n if (token === ZERO_ADDRESS && value !== undefined) {\n nativeBalancesFromAPI.set(`${finalAccount}-${chainId}`, value);\n }\n\n return [\n {\n success: value !== undefined,\n value,\n account: finalAccount,\n token,\n chainId,\n },\n ];\n },\n );\n results.push(...apiBalances);\n }\n\n // Add zero native balance entries for addresses that API didn't return\n addressChainMap.forEach((chains, address) => {\n chains.forEach((chainId) => {\n const key = `${address}-${chainId}`;\n const existingBalance = nativeBalancesFromAPI.get(key);\n\n if (!existingBalance) {\n // Add zero native balance entry if API succeeded but didn't return one\n results.push({\n success: true,\n value: new BN('0'),\n account: address as ChecksumAddress,\n token: ZERO_ADDRESS,\n chainId,\n });\n }\n });\n });\n\n // Add staked balances\n results.push(...stakedBalances);\n\n return {\n balances: results,\n unprocessedChainIds,\n };\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"names":[],"mappings":"","sourcesContent":["export type GetSupportedNetworksResponse = {\n fullSupport: number[];\n partialSupport: {\n balances: number[];\n };\n};\n\nexport type GetBalancesQueryParams = {\n /** Comma-separated network/chain IDs */\n networks?: string;\n /** Whether or not to filter the assets to contain only the tokens existing in the Token API */\n filterSupportedTokens?: boolean;\n /** Specific token addresses to fetch balances for across specified network(s) */\n includeTokenAddresses?: string;\n /** Whether to include balances of the account's staked asset balances */\n includeStakedAssets?: boolean;\n};\n\nexport type GetBalancesQueryParamsV4 = {\n /** Comma-separated network/chain IDs */\n networks?: string;\n\n /** Comma-separated account addresses */\n accountAddresses?: string;\n};\n\nexport type GetBalancesResponse = {\n count: number;\n balances: {\n /** Underlying object type. Seems to be always `token` */\n object: string;\n /** Token Type: This is only supplied as `native` to native chain tokens (e.g. - ETH, POL) */\n type?: string;\n /** Timestamp is only provided for `native` chain tokens */\n timestamp?: string;\n address: string;\n symbol: string;\n name: string;\n decimals: number;\n chainId: number;\n /** string representation of the balance in decimal format (decimals adjusted). e.g. - 123.456789 */\n balance: string;\n /** Account address for V4 API responses */\n accountAddress?: string;\n }[];\n /** networks that failed to process, if no network is processed, returns HTTP 422 */\n unprocessedNetworks: number[];\n};\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"names":[],"mappings":"","sourcesContent":["export type GetSupportedNetworksResponse = {\n fullSupport: number[];\n partialSupport: {\n balances: number[];\n };\n};\n\nexport type GetBalancesQueryParams = {\n /** Comma-separated network/chain IDs */\n networks?: string;\n /** Whether or not to filter the assets to contain only the tokens existing in the Token API */\n filterSupportedTokens?: boolean;\n /** Specific token addresses to fetch balances for across specified network(s) */\n includeTokenAddresses?: string;\n /** Whether to include balances of the account's staked asset balances */\n includeStakedAssets?: boolean;\n};\n\nexport type GetBalancesQueryParamsV4 = {\n /** Comma-separated network/chain IDs */\n networks?: string;\n\n /** Comma-separated account addresses */\n accountAddresses?: string;\n};\n\nexport type GetBalancesResponse = {\n count: number;\n balances: {\n /** Underlying object type. Seems to be always `token` */\n object: string;\n /** Token Type: This is only supplied as `native` to native chain tokens (e.g. - ETH, POL) */\n type?: string;\n /** Timestamp is only provided for `native` chain tokens */\n timestamp?: string;\n address: string;\n symbol: string;\n name: string;\n decimals: number;\n chainId: number;\n /** string representation of the balance in decimal format (decimals adjusted). e.g. - 123.456789 */\n balance: string;\n /** Account address for V4 API responses */\n accountAddress?: string;\n }[];\n /** networks that failed to process, if no network is processed, returns HTTP 422 */\n /** V4 API returns CAIP chain IDs like 'eip155:1329', V2 API returns decimal numbers */\n unprocessedNetworks: (number | string)[];\n};\n"]}
@@ -40,6 +40,7 @@ export type GetBalancesResponse = {
40
40
  accountAddress?: string;
41
41
  }[];
42
42
  /** networks that failed to process, if no network is processed, returns HTTP 422 */
43
- unprocessedNetworks: number[];
43
+ /** V4 API returns CAIP chain IDs like 'eip155:1329', V2 API returns decimal numbers */
44
+ unprocessedNetworks: (number | string)[];
44
45
  };
45
46
  //# sourceMappingURL=types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE;QACd,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+FAA+F;IAC/F,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iFAAiF;IACjF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,yDAAyD;QACzD,MAAM,EAAE,MAAM,CAAC;QACf,6FAA6F;QAC7F,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,2DAA2D;QAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,oGAAoG;QACpG,OAAO,EAAE,MAAM,CAAC;QAChB,2CAA2C;QAC3C,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,EAAE,CAAC;IACJ,qFAAqF;IACrF,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B,CAAC"}
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"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  /** networks that failed to process, if no network is processed, returns HTTP 422 */
43
- unprocessedNetworks: number[];
43
+ /** V4 API returns CAIP chain IDs like 'eip155:1329', V2 API returns decimal numbers */
44
+ unprocessedNetworks: (number | string)[];
44
45
  };
45
46
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE;QACd,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+FAA+F;IAC/F,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iFAAiF;IACjF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,yDAAyD;QACzD,MAAM,EAAE,MAAM,CAAC;QACf,6FAA6F;QAC7F,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,2DAA2D;QAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,oGAAoG;QACpG,OAAO,EAAE,MA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AC,EAAE,MAAM,CAAC;KACzB,EAAE,CAAC;IACJ,qFAAqF;IACrF,uFAAuF;IACvF,mBAAmB,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAC1C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"names":[],"mappings":"","sourcesContent":["export type GetSupportedNetworksResponse = {\n fullSupport: number[];\n partialSupport: {\n balances: number[];\n };\n};\n\nexport type GetBalancesQueryParams = {\n /** Comma-separated network/chain IDs */\n networks?: string;\n /** Whether or not to filter the assets to contain only the tokens existing in the Token API */\n filterSupportedTokens?: boolean;\n /** Specific token addresses to fetch balances for across specified network(s) */\n includeTokenAddresses?: string;\n /** Whether to include balances of the account's staked asset balances */\n includeStakedAssets?: boolean;\n};\n\nexport type GetBalancesQueryParamsV4 = {\n /** Comma-separated network/chain IDs */\n networks?: string;\n\n /** Comma-separated account addresses */\n accountAddresses?: string;\n};\n\nexport type GetBalancesResponse = {\n count: number;\n balances: {\n /** Underlying object type. Seems to be always `token` */\n object: string;\n /** Token Type: This is only supplied as `native` to native chain tokens (e.g. - ETH, POL) */\n type?: string;\n /** Timestamp is only provided for `native` chain tokens */\n timestamp?: string;\n address: string;\n symbol: string;\n name: string;\n decimals: number;\n chainId: number;\n /** string representation of the balance in decimal format (decimals adjusted). e.g. - 123.456789 */\n balance: string;\n /** Account address for V4 API responses */\n accountAddress?: string;\n }[];\n /** networks that failed to process, if no network is processed, returns HTTP 422 */\n unprocessedNetworks: number[];\n};\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"names":[],"mappings":"","sourcesContent":["export type GetSupportedNetworksResponse = {\n fullSupport: number[];\n partialSupport: {\n balances: number[];\n };\n};\n\nexport type GetBalancesQueryParams = {\n /** Comma-separated network/chain IDs */\n networks?: string;\n /** Whether or not to filter the assets to contain only the tokens existing in the Token API */\n filterSupportedTokens?: boolean;\n /** Specific token addresses to fetch balances for across specified network(s) */\n includeTokenAddresses?: string;\n /** Whether to include balances of the account's staked asset balances */\n includeStakedAssets?: boolean;\n};\n\nexport type GetBalancesQueryParamsV4 = {\n /** Comma-separated network/chain IDs */\n networks?: string;\n\n /** Comma-separated account addresses */\n accountAddresses?: string;\n};\n\nexport type GetBalancesResponse = {\n count: number;\n balances: {\n /** Underlying object type. Seems to be always `token` */\n object: string;\n /** Token Type: This is only supplied as `native` to native chain tokens (e.g. - ETH, POL) */\n type?: string;\n /** Timestamp is only provided for `native` chain tokens */\n timestamp?: string;\n address: string;\n symbol: string;\n name: string;\n decimals: number;\n chainId: number;\n /** string representation of the balance in decimal format (decimals adjusted). e.g. - 123.456789 */\n balance: string;\n /** Account address for V4 API responses */\n accountAddress?: string;\n }[];\n /** networks that failed to process, if no network is processed, returns HTTP 422 */\n /** V4 API returns CAIP chain IDs like 'eip155:1329', V2 API returns decimal numbers */\n unprocessedNetworks: (number | string)[];\n};\n"]}
@@ -192,6 +192,8 @@ exports.SUPPORTED_CURRENCIES = [
192
192
  'nom',
193
193
  // Avalanche
194
194
  'avax',
195
+ // Apechain
196
+ 'ape',
195
197
  ];
196
198
  /**
197
199
  * Represents the zero address, commonly used as a placeholder in blockchain transactions.
@@ -259,6 +261,16 @@ exports.SPOT_PRICES_SUPPORT_INFO = {
259
261
  '0x82750': 'eip155:534352/slip44:60', // Scroll Mainnet - Native symbol: ETH
260
262
  '0x4e454152': 'eip155:60/slip44:60', // Aurora Mainnet (Ethereum L2 on NEAR) - Native symbol: ETH
261
263
  '0x63564c40': 'eip155:1666600000/slip44:1023', // Harmony Mainnet Shard 0 - Native symbol: ONE
264
+ '0x8173': 'eip155:33139/erc20:0x0000000000000000000000000000000000000000', // Apechain Mainnet - Native symbol: APE
265
+ '0xe8': 'eip155:232/erc20:0x0000000000000000000000000000000000000000', // Lens Mainnet - Native symbol: GHO
266
+ '0x18232': 'eip155:98866/erc20:0x0000000000000000000000000000000000000000', // Plume Mainnet - Narive symbol: Plume
267
+ '0x2eb': 'eip155:747/erc20:0x0000000000000000000000000000000000000000', // Flow evm - Native symbol: Flow
268
+ '0x138de': 'eip155:80094/erc20:0x0000000000000000000000000000000000000000', // Berachain - Native symbol: Bera',
269
+ '0x15f900': 'eip155:1440000/erc20:0x0000000000000000000000000000000000000000', // xrpl-evm - native symbol: XRP
270
+ '0xfc': 'eip155:252/erc20:0x0000000000000000000000000000000000000000', // Fraxtal - native symbol: FRAX
271
+ '0x2a': 'eip155:42/erc20:0x0000000000000000000000000000000000000000', // Lukso - native symbol: LYX
272
+ '0x32': 'eip155:50/erc20:0x0000000000000000000000000000000000000000', // xdc-network - native symbol: XDC
273
+ '0x2611': 'eip155:9745/erc20:0x0000000000000000000000000000000000000000', // Plasma mainnet - native symbol: XPL
262
274
  };
263
275
  /**
264
276
  * The list of chain IDs that can be supplied in the URL for the `/spot-prices`
@@ -1 +1 @@
1
- {"version":3,"file":"codefi-v2.cjs","sourceRoot":"","sources":["../../src/token-prices-service/codefi-v2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iEAOoC;AAGpC,2CAIyB;AAWzB;;;GAGG;AACU,QAAA,oBAAoB,GAAG;IAClC,UAAU;IACV,KAAK;IACL,QAAQ;IACR,KAAK;IACL,WAAW;IACX,KAAK;IACL,eAAe;IACf,KAAK;IACL,eAAe;IACf,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,SAAS;IACT,KAAK;IACL,YAAY;IACZ,MAAM;IACN,WAAW;IACX,KAAK;IACL,gBAAgB;IAChB,KAAK;IACL,YAAY;IACZ,KAAK;IACL,8BAA8B;IAC9B,KAAK;IACL,iBAAiB;IACjB,KAAK;IACL,oBAAoB;IACpB,KAAK;IACL,mBAAmB;IACnB,KAAK;IACL,iBAAiB;IACjB,KAAK;IACL,mBAAmB;IACnB,KAAK;IACL,cAAc;IACd,KAAK;IACL,kBAAkB;IAClB,KAAK;IAC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OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CACzB,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAClD,CACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n createServicePolicy,\n DEFAULT_CIRCUIT_BREAK_DURATION,\n DEFAULT_DEGRADED_THRESHOLD,\n DEFAULT_MAX_CONSECUTIVE_FAILURES,\n DEFAULT_MAX_RETRIES,\n handleFetch,\n} from '@metamask/controller-utils';\nimport type { ServicePolicy } from '@metamask/controller-utils';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\nimport {\n hexToNumber,\n KnownCaipNamespace,\n toCaipChainId,\n} from '@metamask/utils';\n\nimport type {\n AbstractTokenPricesService,\n EvmAssetAddressWithChain,\n EvmAssetWithId,\n EvmAssetWithMarketData,\n ExchangeRatesByCurrency,\n} from './abstract-token-prices-service';\nimport type { MarketDataDetails } from '../TokenRatesController';\n\n/**\n * The list of currencies that can be supplied as the `vsCurrency` parameter to\n * the `/spot-prices` endpoint, in lowercase form.\n */\nexport const SUPPORTED_CURRENCIES = [\n // Bitcoin\n 'btc',\n // Ether\n 'eth',\n // Litecoin\n 'ltc',\n // Bitcoin Cash\n 'bch',\n // Binance Coin\n 'bnb',\n // EOS\n 'eos',\n // XRP\n 'xrp',\n // Lumens\n 'xlm',\n // Chainlink\n 'link',\n // Polkadot\n 'dot',\n // Yearn.finance\n 'yfi',\n // US Dollar\n 'usd',\n // United Arab Emirates Dirham\n 'aed',\n // Argentine Peso\n 'ars',\n // Australian Dollar\n 'aud',\n // Bangladeshi Taka\n 'bdt',\n // Bahraini Dinar\n 'bhd',\n // Bermudian Dollar\n 'bmd',\n // Brazil Real\n 'brl',\n // Canadian Dollar\n 'cad',\n // Swiss Franc\n 'chf',\n // Chilean Peso\n 'clp',\n // Chinese Yuan\n 'cny',\n // Czech Koruna\n 'czk',\n // Danish Krone\n 'dkk',\n // Euro\n 'eur',\n // British Pound Sterling\n 'gbp',\n // Georgian Lari\n 'gel',\n // Hong Kong Dollar\n 'hkd',\n // Hungarian Forint\n 'huf',\n // Indonesian Rupiah\n 'idr',\n // Israeli New Shekel\n 'ils',\n // Indian Rupee\n 'inr',\n // Japanese Yen\n 'jpy',\n // South Korean Won\n 'krw',\n // Kuwaiti Dinar\n 'kwd',\n // Sri Lankan Rupee\n 'lkr',\n // Burmese Kyat\n 'mmk',\n // Mexican Peso\n 'mxn',\n // Malaysian Ringgit\n 'myr',\n // Monad\n 'mon',\n // Nigerian Naira\n 'ngn',\n // Norwegian Krone\n 'nok',\n // New Zealand Dollar\n 'nzd',\n // Philippine Peso\n 'php',\n // Pakistani Rupee\n 'pkr',\n // Polish Zloty\n 'pln',\n // Russian Ruble\n 'rub',\n // Saudi Riyal\n 'sar',\n // Swedish Krona\n 'sek',\n // Singapore Dollar\n 'sgd',\n // Thai Baht\n 'thb',\n // Turkish Lira\n 'try',\n // New Taiwan Dollar\n 'twd',\n // Ukrainian hryvnia\n 'uah',\n // Venezuelan bolívar fuerte\n 'vef',\n // Vietnamese đồng\n 'vnd',\n // South African Rand\n 'zar',\n // IMF Special Drawing Rights\n 'xdr',\n // Silver - Troy Ounce\n 'xag',\n // Gold - Troy Ounce\n 'xau',\n // Bits\n 'bits',\n // Satoshi\n 'sats',\n // Colombian Peso\n 'cop',\n // Kenyan Shilling\n 'kes',\n // Romanian Leu\n 'ron',\n // Dominican Peso\n 'dop',\n // Costa Rican Colón\n 'crc',\n // Honduran Lempira\n 'hnl',\n // Zambian Kwacha\n 'zmw',\n // Salvadoran Colón\n 'svc',\n // Bosnia-Herzegovina Convertible Mark\n 'bam',\n // Peruvian Sol\n 'pen',\n // Guatemalan Quetzal\n 'gtq',\n // Lebanese Pound\n 'lbp',\n // Armenian Dram\n 'amd',\n // Solana\n 'sol',\n // Sei\n 'sei',\n // Sonic\n 'sonic',\n // Tron\n 'trx',\n // Taiko\n 'taiko',\n // Pepu\n 'pepu',\n // Polygon\n 'pol',\n // Mantle\n 'mnt',\n // Onomy\n 'nom',\n // Avalanche\n 'avax',\n] as const;\n\n/**\n * Represents the zero address, commonly used as a placeholder in blockchain transactions.\n * In the context of fetching market data, the zero address is utilized to retrieve information\n * specifically for native currencies. This allows for a standardized approach to query market\n * data for blockchain-native assets without a specific contract address.\n */\nexport const ZERO_ADDRESS: Hex =\n '0x0000000000000000000000000000000000000000' as const;\n\n/**\n * A mapping from chain id to the address of the chain's native token.\n * Only for chains whose native tokens have a specific address.\n */\nconst chainIdToNativeTokenAddress: Record<Hex, Hex> = {\n '0x89': '0x0000000000000000000000000000000000001010', // Polygon\n '0x440': '0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000', // Metis Andromeda\n '0x1388': '0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000', // Mantle\n};\n\n/**\n * Returns the address that should be used to query the price api for the\n * chain's native token. On most chains, this is signified by the zero address.\n * But on some chains, the native token has a specific address.\n *\n * @param chainId - The hexadecimal chain id.\n * @returns The address of the chain's native token.\n */\nexport const getNativeTokenAddress = (chainId: Hex): Hex =>\n chainIdToNativeTokenAddress[chainId] ?? ZERO_ADDRESS;\n\n// Source: https://github.com/consensys-vertical-apps/va-mmcx-price-api/blob/main/src/constants/slip44.ts\n// We can only support PricesAPI V3 for EVM chains that have a CAIP-19 native asset mapping.\nexport const SPOT_PRICES_SUPPORT_INFO = {\n '0x1': 'eip155:1/slip44:60', // Ethereum Mainnet - Native symbol: ETH\n '0xa': 'eip155:10/slip44:60', // OP Mainnet - Native symbol: ETH\n '0x19': 'eip155:25/slip44:394', // Cronos Mainnet - Native symbol: CRO\n '0x38': 'eip155:56/slip44:714', // BNB Smart Chain Mainnet - Native symbol: BNB\n '0x39': 'eip155:57/erc20:0x0000000000000000000000000000000000000000', // 'eip155:57/slip44:57', // Syscoin Mainnet - Native symbol: SYS\n '0x52': null, // 'eip155:82/slip44:18000', // Meter Mainnet - Native symbol: MTR\n '0x58': 'eip155:88/erc20:0x0000000000000000000000000000000000000000', // 'eip155:88/slip44:889', // TomoChain - Native symbol: TOMO\n '0x64': 'eip155:100/slip44:700', // Gnosis (formerly xDAI Chain) - Native symbol: xDAI\n '0x6a': 'eip155:106/erc20:0x0000000000000000000000000000000000000000', // 'eip155:106/slip44:5655640', // Velas EVM Mainnet - Native symbol: VLX\n '0x80': 'eip155:128/erc20:0x0000000000000000000000000000000000000000', // 'eip155:128/slip44:1010', // Huobi ECO Chain Mainnet - Native symbol: HT\n '0x89': 'eip155:137/slip44:966', // Polygon Mainnet - Native symbol: POL\n '0x8f': null, // 'eip155:143/slip44:268435779', // Monad Mainnet - Native symbol: MON\n '0x92': 'eip155:146/slip44:10007', // Sonic Mainnet - Native symbol: S\n '0xfa': 'eip155:250/slip44:1007', // Fantom Opera - Native symbol: FTM\n '0x141': 'eip155:321/erc20:0x0000000000000000000000000000000000000000', // 'eip155:321/slip44:641', // KCC Mainnet - Native symbol: KCS\n '0x144': 'eip155:324/slip44:60', // zkSync Era Mainnet (Ethereum L2) - Native symbol: ETH\n '0x169': 'eip155:361/erc20:0x0000000000000000000000000000000000000000', // 'eip155:361/slip44:589', // Theta Mainnet - Native symbol: TFUEL\n '0x3e7': 'eip155:999/slip44:2457', // HyperEVM - Native symbol: ETH\n '0x440': 'eip155:1088/erc20:0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000', // 'eip155:1088/slip44:XXX', // Metis Andromeda Mainnet (Ethereum L2) - Native symbol: METIS\n '0x44d': 'eip155:1101/slip44:60', // Polygon zkEVM mainnet - Native symbol: ETH\n '0x504': 'eip155:1284/slip44:1284', // Moonbeam - Native symbol: GLMR\n '0x505': 'eip155:1285/slip44:1285', // Moonriver - Native symbol: MOVR\n '0x531': 'eip155:1329/slip44:19000118', // Sei Mainnet - Native symbol: SEI\n '0x1388': 'eip155:5000/erc20:0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000', // 'eip155:5000/slip44:XXX', // Mantle - Native symbol: MNT\n '0x2105': 'eip155:8453/slip44:60', // Base - Native symbol: ETH\n '0x2710': 'eip155:10000/erc20:0x0000000000000000000000000000000000000000', // 'eip155:10000/slip44:145', // Smart Bitcoin Cash - Native symbol: BCH\n '0xa4b1': 'eip155:42161/slip44:60', // Arbitrum One - Native symbol: ETH\n '0xa4ec': 'eip155:42220/slip44:52752', // Celo Mainnet - Native symbol: CELO\n '0xa516': 'eip155:42262/erc20:0x0000000000000000000000000000000000000000', // 'eip155:42262/slip44:474', // Oasis Emerald - Native symbol: ROSE\n '0xa86a': 'eip155:43114/slip44:9005', // Avalanche C-Chain - Native symbol: AVAX\n '0xe708': 'eip155:59144/slip44:60', // Linea Mainnet - Native symbol: ETH\n '0x13c31': 'eip155:81457/erc20:0x0000000000000000000000000000000000000000', // 'eip155:81457/slip44:60', // Blast Mainnet - Native symbol: ETH\n '0x17dcd': 'eip155:97741/erc20:0x0000000000000000000000000000000000000000', // 'eip155:97741/slip44:XXX', // Pepe Unchained Mainnet - Native symbol: PEPU\n '0x518af': null, // 'eip155:333999/slip44:1997', // Polis Mainnet - Native symbol: POLIS\n '0x82750': 'eip155:534352/slip44:60', // Scroll Mainnet - Native symbol: ETH\n '0x4e454152': 'eip155:60/slip44:60', // Aurora Mainnet (Ethereum L2 on NEAR) - Native symbol: ETH\n '0x63564c40': 'eip155:1666600000/slip44:1023', // Harmony Mainnet Shard 0 - Native symbol: ONE\n} as const;\n\n// MISSING CHAINS WITH NO NATIVE ASSET PRICES IN V2\n// '0x42': 'eip155:66/slip44:996', // OKXChain Mainnet - Native symbol: OKT\n// '0x46': 'eip155:70/slip44:1170', // Hoo Smart Chain - Native symbol: HOO\n// '0x7a': 'eip155:122/slip44:XXX', // Fuse Mainnet - Native symbol: FUSE\n// '0x120': 'eip155:288/slip44:60', // Boba Network (Ethereum L2) - Native symbol: ETH\n// '0x150': 'eip155:336/slip44:809', // Shiden - Native symbol: SDN\n// '0x28c58': 'eip155:167000/slip44:60', // Taiko Mainnet - Native symbol: ETH\n\n/**\n * A currency that can be supplied as the `vsCurrency` parameter to\n * the `/spot-prices` endpoint. Covers both uppercase and lowercase versions.\n */\ntype SupportedCurrency =\n | (typeof SUPPORTED_CURRENCIES)[number]\n | Uppercase<(typeof SUPPORTED_CURRENCIES)[number]>;\n\n/**\n * The list of chain IDs that can be supplied in the URL for the `/spot-prices`\n * endpoint, but in hexadecimal form (for consistency with how we represent\n * chain IDs in other places).\n *\n * @see Used by {@link CodefiTokenPricesServiceV2} to validate that a given chain ID is supported by V2 of the Codefi Price API.\n */\nexport const SUPPORTED_CHAIN_IDS = Object.keys(\n SPOT_PRICES_SUPPORT_INFO,\n) as (keyof typeof SPOT_PRICES_SUPPORT_INFO)[];\n\n/**\n * A chain ID that can be supplied in the URL for the `/spot-prices` endpoint,\n * but in hexadecimal form (for consistency with how we represent chain IDs in\n * other places).\n */\ntype SupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];\n\n/**\n * The list of chain IDs that are supported by V3 of the Codefi Price API.\n * Only includes chain IDs from SPOT_PRICES_SUPPORT_INFO that have a non-null CAIP-19 value.\n */\nconst SUPPORTED_CHAIN_IDS_V3 = Object.keys(SPOT_PRICES_SUPPORT_INFO).filter(\n (chainId) =>\n SPOT_PRICES_SUPPORT_INFO[\n chainId as keyof typeof SPOT_PRICES_SUPPORT_INFO\n ] !== null,\n);\n\nconst BASE_URL_V1 = 'https://price.api.cx.metamask.io/v1';\n\nconst BASE_URL_V2 = 'https://price.api.cx.metamask.io/v2';\n\nconst BASE_URL_V3 = 'https://price.api.cx.metamask.io/v3';\n\n/**\n * This version of the token prices service uses V2 of the Codefi Price API to\n * fetch token prices.\n */\nexport class CodefiTokenPricesServiceV2\n implements AbstractTokenPricesService<SupportedChainId, SupportedCurrency>\n{\n readonly #policy: ServicePolicy;\n\n /**\n * Construct a Codefi Token Price Service.\n *\n * @param args - The arguments.\n * @param args.degradedThreshold - The length of time (in milliseconds)\n * that governs when the service is regarded as degraded (affecting when\n * `onDegraded` is called). Defaults to 5 seconds.\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further updates.\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n */\n constructor(args?: {\n degradedThreshold?: number;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n });\n\n /**\n * Construct a Codefi Token Price Service.\n *\n * @deprecated This signature is deprecated; please use the `onBreak` and\n * `onDegraded` methods instead.\n * @param args - The arguments.\n * @param args.degradedThreshold - The length of time (in milliseconds)\n * that governs when the service is regarded as degraded (affecting when\n * `onDegraded` is called). Defaults to 5 seconds.\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further updates.\n * @param args.onBreak - Callback for when the circuit breaks, useful\n * for capturing metrics about network failures.\n * @param args.onDegraded - Callback for when the API responds successfully\n * but takes too long to respond (5 seconds or more).\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n constructor(args?: {\n degradedThreshold?: number;\n retries?: number;\n maximumConsecutiveFailures?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n circuitBreakDuration?: number;\n });\n\n constructor({\n degradedThreshold = DEFAULT_DEGRADED_THRESHOLD,\n retries = DEFAULT_MAX_RETRIES,\n maximumConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n onBreak,\n onDegraded,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n }: {\n degradedThreshold?: number;\n retries?: number;\n maximumConsecutiveFailures?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n circuitBreakDuration?: number;\n } = {}) {\n this.#policy = createServicePolicy({\n maxRetries: retries,\n maxConsecutiveFailures: maximumConsecutiveFailures,\n circuitBreakDuration,\n degradedThreshold,\n });\n if (onBreak) {\n this.#policy.onBreak(onBreak);\n }\n if (onDegraded) {\n this.#policy.onDegraded(onDegraded);\n }\n }\n\n /**\n * Listens for when the request to the API fails too many times in a row.\n *\n * @param args - The same arguments that {@link ServicePolicy.onBreak}\n * takes.\n * @returns What {@link ServicePolicy.onBreak} returns.\n */\n onBreak(...args: Parameters<ServicePolicy['onBreak']>) {\n return this.#policy.onBreak(...args);\n }\n\n /**\n * Listens for when the API is degraded.\n *\n * @param args - The same arguments that {@link ServicePolicy.onDegraded}\n * takes.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n */\n onDegraded(...args: Parameters<ServicePolicy['onDegraded']>) {\n return this.#policy.onDegraded(...args);\n }\n\n /**\n * Retrieves prices in the given currency for the tokens identified by the\n * given addresses which are expected to live on the given chain.\n *\n * @param args - The arguments to function.\n * @param args.assets - The assets to get prices for.\n * @param args.currency - The desired currency of the token prices.\n * @returns The prices for the requested tokens.\n */\n async fetchTokenPrices({\n assets,\n currency,\n }: {\n assets: EvmAssetAddressWithChain<SupportedChainId>[];\n currency: SupportedCurrency;\n }): Promise<EvmAssetWithMarketData<SupportedChainId, SupportedCurrency>[]> {\n const v3Assets = await this.#fetchTokenPricesV3(assets, currency);\n const v2Assets = await this.#fetchTokenPricesV2(assets, currency);\n\n return [...v3Assets, ...v2Assets];\n }\n\n async #fetchTokenPricesV3(\n assets: EvmAssetAddressWithChain<SupportedChainId>[],\n currency: SupportedCurrency,\n ): Promise<EvmAssetWithMarketData<SupportedChainId, SupportedCurrency>[]> {\n const assetsWithIds: EvmAssetWithId<SupportedChainId>[] = assets\n // Filter out assets that are not supported by V3 of the Price API.\n .filter((asset) => SUPPORTED_CHAIN_IDS_V3.includes(asset.chainId))\n .map((asset) => {\n const caipChainId = toCaipChainId(\n KnownCaipNamespace.Eip155,\n hexToNumber(asset.chainId).toString(),\n );\n\n const nativeAddress = getNativeTokenAddress(asset.chainId);\n\n return {\n ...asset,\n assetId: (nativeAddress.toLowerCase() ===\n asset.tokenAddress.toLowerCase()\n ? SPOT_PRICES_SUPPORT_INFO[asset.chainId]\n : `${caipChainId}/erc20:${asset.tokenAddress.toLowerCase()}`) as CaipAssetType,\n };\n })\n .filter((asset) => asset.assetId);\n\n if (assetsWithIds.length === 0) {\n return [];\n }\n\n const url = new URL(`${BASE_URL_V3}/spot-prices`);\n url.searchParams.append(\n 'assetIds',\n assetsWithIds.map((asset) => asset.assetId).join(','),\n );\n url.searchParams.append('vsCurrency', currency);\n url.searchParams.append('includeMarketData', 'true');\n\n const addressCryptoDataMap: {\n [assetId: CaipAssetType]: Omit<\n MarketDataDetails,\n 'currency' | 'tokenAddress'\n >;\n } = await this.#policy.execute(() =>\n handleFetch(url, { headers: { 'Cache-Control': 'no-cache' } }),\n );\n\n return assetsWithIds\n .map((assetWithId) => {\n const marketData = addressCryptoDataMap[assetWithId.assetId];\n\n if (!marketData) {\n return undefined;\n }\n\n return {\n ...marketData,\n ...assetWithId,\n currency,\n };\n })\n .filter((entry): entry is NonNullable<typeof entry> => Boolean(entry));\n }\n\n async #fetchTokenPricesV2(\n assets: EvmAssetAddressWithChain<SupportedChainId>[],\n currency: SupportedCurrency,\n ): Promise<EvmAssetWithMarketData<SupportedChainId, SupportedCurrency>[]> {\n const v2SupportedAssets = assets.filter(\n (asset) => !SUPPORTED_CHAIN_IDS_V3.includes(asset.chainId),\n );\n\n const assetsByChainId: Record<SupportedChainId, Hex[]> =\n v2SupportedAssets.reduce(\n (acc, { chainId, tokenAddress }) => {\n (acc[chainId] ??= []).push(tokenAddress);\n return acc;\n },\n {} as Record<SupportedChainId, Hex[]>,\n );\n\n const promises = Object.entries(assetsByChainId).map(\n async ([chainId, tokenAddresses]) => {\n if (tokenAddresses.length === 0) {\n return [];\n }\n\n const url = new URL(`${BASE_URL_V2}/chains/${chainId}/spot-prices`);\n url.searchParams.append('tokenAddresses', tokenAddresses.join(','));\n url.searchParams.append('vsCurrency', currency);\n url.searchParams.append('includeMarketData', 'true');\n\n const addressCryptoDataMap: {\n [tokenAddress: string]: Omit<\n MarketDataDetails,\n 'currency' | 'tokenAddress'\n >;\n } = await this.#policy.execute(() =>\n handleFetch(url, { headers: { 'Cache-Control': 'no-cache' } }),\n );\n\n return tokenAddresses\n .map((tokenAddress) => {\n const marketData = addressCryptoDataMap[tokenAddress.toLowerCase()];\n\n if (!marketData) {\n return undefined;\n }\n\n return {\n ...marketData,\n tokenAddress,\n chainId: chainId as SupportedChainId,\n currency,\n };\n })\n .filter((entry): entry is NonNullable<typeof entry> =>\n Boolean(entry),\n );\n },\n );\n\n return await Promise.allSettled(promises).then((results) =>\n results.flatMap((result) =>\n result.status === 'fulfilled' ? result.value : [],\n ),\n );\n }\n\n /**\n * Retrieves exchange rates in the given base currency.\n *\n * @param args - The arguments to this function.\n * @param args.baseCurrency - The desired base currency of the exchange rates.\n * @param args.includeUsdRate - Whether to include the USD rate in the response.\n * @param args.cryptocurrencies - The cryptocurrencies to get exchange rates for.\n * @returns The exchange rates for the requested base currency.\n */\n async fetchExchangeRates({\n baseCurrency,\n includeUsdRate,\n cryptocurrencies,\n }: {\n baseCurrency: SupportedCurrency;\n includeUsdRate: boolean;\n cryptocurrencies: string[];\n }): Promise<ExchangeRatesByCurrency<SupportedCurrency>> {\n const url = new URL(`${BASE_URL_V1}/exchange-rates`);\n url.searchParams.append('baseCurrency', baseCurrency);\n\n const urlUsd = new URL(`${BASE_URL_V1}/exchange-rates`);\n urlUsd.searchParams.append('baseCurrency', 'usd');\n\n const [exchangeRatesResult, exchangeRatesResultUsd] =\n await Promise.allSettled([\n this.#policy.execute(() =>\n handleFetch(url, { headers: { 'Cache-Control': 'no-cache' } }),\n ),\n ...(includeUsdRate && baseCurrency.toLowerCase() !== 'usd'\n ? [\n this.#policy.execute(() =>\n handleFetch(urlUsd, {\n headers: { 'Cache-Control': 'no-cache' },\n }),\n ),\n ]\n : []),\n ]);\n\n // Handle resolved/rejected\n const exchangeRates =\n exchangeRatesResult.status === 'fulfilled'\n ? exchangeRatesResult.value\n : {};\n const exchangeRatesUsd =\n exchangeRatesResultUsd?.status === 'fulfilled'\n ? exchangeRatesResultUsd.value\n : {};\n\n if (exchangeRatesResult.status === 'rejected') {\n throw new Error('Failed to fetch');\n }\n\n const filteredExchangeRates = cryptocurrencies.reduce((acc, key) => {\n if (exchangeRates[key.toLowerCase() as SupportedCurrency]) {\n acc[key.toLowerCase() as SupportedCurrency] =\n exchangeRates[key.toLowerCase() as SupportedCurrency];\n }\n return acc;\n }, {} as ExchangeRatesByCurrency<SupportedCurrency>);\n\n if (Object.keys(filteredExchangeRates).length === 0) {\n throw new Error(\n 'None of the cryptocurrencies are supported by price api',\n );\n }\n\n const filteredUsdExchangeRates = cryptocurrencies.reduce((acc, key) => {\n if (exchangeRatesUsd[key.toLowerCase() as SupportedCurrency]) {\n acc[key.toLowerCase() as SupportedCurrency] =\n exchangeRatesUsd[key.toLowerCase() as SupportedCurrency];\n }\n return acc;\n }, {} as ExchangeRatesByCurrency<SupportedCurrency>);\n\n if (baseCurrency.toLowerCase() === 'usd') {\n Object.keys(filteredExchangeRates).forEach((key) => {\n filteredExchangeRates[key as SupportedCurrency] = {\n ...filteredExchangeRates[key as SupportedCurrency],\n usd: filteredExchangeRates[key as SupportedCurrency]?.value,\n };\n });\n return filteredExchangeRates;\n }\n if (!includeUsdRate) {\n return filteredExchangeRates;\n }\n\n const merged = Object.keys(filteredExchangeRates).reduce((acc, key) => {\n acc[key as SupportedCurrency] = {\n ...filteredExchangeRates[key as SupportedCurrency],\n ...(filteredUsdExchangeRates[key as SupportedCurrency]?.value\n ? { usd: filteredUsdExchangeRates[key as SupportedCurrency]?.value }\n : {}),\n };\n return acc;\n }, {} as ExchangeRatesByCurrency<SupportedCurrency>);\n\n return merged;\n }\n\n /**\n * Type guard for whether the API can return token prices for the given chain\n * ID.\n *\n * @param chainId - The chain ID to check.\n * @returns True if the API supports the chain ID, false otherwise.\n */\n validateChainIdSupported(chainId: unknown): chainId is SupportedChainId {\n const supportedChainIds: readonly string[] = SUPPORTED_CHAIN_IDS;\n return typeof chainId === 'string' && supportedChainIds.includes(chainId);\n }\n\n /**\n * Type guard for whether the API can return token prices in the given\n * currency.\n *\n * @param currency - The currency to check. If a string, can be either\n * lowercase or uppercase.\n * @returns True if the API supports the currency, false otherwise.\n */\n validateCurrencySupported(currency: unknown): currency is SupportedCurrency {\n const supportedCurrencies: readonly string[] = SUPPORTED_CURRENCIES;\n return (\n typeof currency === 'string' &&\n supportedCurrencies.includes(currency.toLowerCase())\n );\n }\n}\n"]}
1
+ {"version":3,"file":"codefi-v2.cjs","sourceRoot":"","sources":["../../src/token-prices-service/codefi-v2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iEAOoC;AAGpC,2CAIyB;AAWzB;;;GAGG;AACU,QAAA,oBAAoB,GAAG;IAClC,UAAU;IACV,KAAK;IACL,QAAQ;IACR,KAAK;IACL,WAAW;IACX,KAAK;IACL,eAAe;IACf,KAAK;IACL,eAAe;IACf,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,SAAS;IACT,KAAK;IACL,YAAY;IACZ,MAAM;IACN,WAAW;IACX,KAAK;IACL,gBAAgB;IAChB,KAAK;IACL,YAAY;IACZ,KAAK;IACL,8BAA8B;IAC9B,KAAK;IACL,iBAAiB;IACjB,KAAK;IACL,oBAAoB;IACpB,KAAK;IACL,mBAAmB;IACnB,KAAK;IACL,iBAAiB;IACjB,KAAK;IACL,mBAAmB;IACnB,KAAK;IACL,cAAc;IACd,KAAK;IACL,kBAAkB;IAClB,KAAK;IACL,cAAc;IACd,KAAK;IACL,eAAe;IACf,KAAK;IACL,eAAe;IACf,KAAK;IACL,eAAe;IACf,KAAK;IACL,eAAe;IACf,KAAK;IACL,OAAO;IACP,KAAK;IACL,yBAAyB;IACzB,KAAK;IACL,gBAAgB;IAChB,KAAK;IACL,mBAAmB;IACnB,KAAK;IACL,mBAAmB;IACnB,KAAK;IACL,oBAAoB;IACpB,KAAK;IACL,qBAAqB;IACrB,KA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,KAAK,CAAC,CACf,CAAC;IACN,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACzD,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CACzB,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAClD,CACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n createServicePolicy,\n DEFAULT_CIRCUIT_BREAK_DURATION,\n DEFAULT_DEGRADED_THRESHOLD,\n DEFAULT_MAX_CONSECUTIVE_FAILURES,\n DEFAULT_MAX_RETRIES,\n handleFetch,\n} from '@metamask/controller-utils';\nimport type { ServicePolicy } from '@metamask/controller-utils';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\nimport {\n hexToNumber,\n KnownCaipNamespace,\n toCaipChainId,\n} from '@metamask/utils';\n\nimport type {\n AbstractTokenPricesService,\n EvmAssetAddressWithChain,\n EvmAssetWithId,\n EvmAssetWithMarketData,\n ExchangeRatesByCurrency,\n} from './abstract-token-prices-service';\nimport type { MarketDataDetails } from '../TokenRatesController';\n\n/**\n * The list of currencies that can be supplied as the `vsCurrency` parameter to\n * the `/spot-prices` endpoint, in lowercase form.\n */\nexport const SUPPORTED_CURRENCIES = [\n // Bitcoin\n 'btc',\n // Ether\n 'eth',\n // Litecoin\n 'ltc',\n // Bitcoin Cash\n 'bch',\n // Binance Coin\n 'bnb',\n // EOS\n 'eos',\n // XRP\n 'xrp',\n // Lumens\n 'xlm',\n // Chainlink\n 'link',\n // Polkadot\n 'dot',\n // Yearn.finance\n 'yfi',\n // US Dollar\n 'usd',\n // United Arab Emirates Dirham\n 'aed',\n // Argentine Peso\n 'ars',\n // Australian Dollar\n 'aud',\n // Bangladeshi Taka\n 'bdt',\n // Bahraini Dinar\n 'bhd',\n // Bermudian Dollar\n 'bmd',\n // Brazil Real\n 'brl',\n // Canadian Dollar\n 'cad',\n // Swiss Franc\n 'chf',\n // Chilean Peso\n 'clp',\n // Chinese Yuan\n 'cny',\n // Czech Koruna\n 'czk',\n // Danish Krone\n 'dkk',\n // Euro\n 'eur',\n // British Pound Sterling\n 'gbp',\n // Georgian Lari\n 'gel',\n // Hong Kong Dollar\n 'hkd',\n // Hungarian Forint\n 'huf',\n // Indonesian Rupiah\n 'idr',\n // Israeli New Shekel\n 'ils',\n // Indian Rupee\n 'inr',\n // Japanese Yen\n 'jpy',\n // South Korean Won\n 'krw',\n // Kuwaiti Dinar\n 'kwd',\n // Sri Lankan Rupee\n 'lkr',\n // Burmese Kyat\n 'mmk',\n // Mexican Peso\n 'mxn',\n // Malaysian Ringgit\n 'myr',\n // Monad\n 'mon',\n // Nigerian Naira\n 'ngn',\n // Norwegian Krone\n 'nok',\n // New Zealand Dollar\n 'nzd',\n // Philippine Peso\n 'php',\n // Pakistani Rupee\n 'pkr',\n // Polish Zloty\n 'pln',\n // Russian Ruble\n 'rub',\n // Saudi Riyal\n 'sar',\n // Swedish Krona\n 'sek',\n // Singapore Dollar\n 'sgd',\n // Thai Baht\n 'thb',\n // Turkish Lira\n 'try',\n // New Taiwan Dollar\n 'twd',\n // Ukrainian hryvnia\n 'uah',\n // Venezuelan bolívar fuerte\n 'vef',\n // Vietnamese đồng\n 'vnd',\n // South African Rand\n 'zar',\n // IMF Special Drawing Rights\n 'xdr',\n // Silver - Troy Ounce\n 'xag',\n // Gold - Troy Ounce\n 'xau',\n // Bits\n 'bits',\n // Satoshi\n 'sats',\n // Colombian Peso\n 'cop',\n // Kenyan Shilling\n 'kes',\n // Romanian Leu\n 'ron',\n // Dominican Peso\n 'dop',\n // Costa Rican Colón\n 'crc',\n // Honduran Lempira\n 'hnl',\n // Zambian Kwacha\n 'zmw',\n // Salvadoran Colón\n 'svc',\n // Bosnia-Herzegovina Convertible Mark\n 'bam',\n // Peruvian Sol\n 'pen',\n // Guatemalan Quetzal\n 'gtq',\n // Lebanese Pound\n 'lbp',\n // Armenian Dram\n 'amd',\n // Solana\n 'sol',\n // Sei\n 'sei',\n // Sonic\n 'sonic',\n // Tron\n 'trx',\n // Taiko\n 'taiko',\n // Pepu\n 'pepu',\n // Polygon\n 'pol',\n // Mantle\n 'mnt',\n // Onomy\n 'nom',\n // Avalanche\n 'avax',\n // Apechain\n 'ape',\n] as const;\n\n/**\n * Represents the zero address, commonly used as a placeholder in blockchain transactions.\n * In the context of fetching market data, the zero address is utilized to retrieve information\n * specifically for native currencies. This allows for a standardized approach to query market\n * data for blockchain-native assets without a specific contract address.\n */\nexport const ZERO_ADDRESS: Hex =\n '0x0000000000000000000000000000000000000000' as const;\n\n/**\n * A mapping from chain id to the address of the chain's native token.\n * Only for chains whose native tokens have a specific address.\n */\nconst chainIdToNativeTokenAddress: Record<Hex, Hex> = {\n '0x89': '0x0000000000000000000000000000000000001010', // Polygon\n '0x440': '0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000', // Metis Andromeda\n '0x1388': '0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000', // Mantle\n};\n\n/**\n * Returns the address that should be used to query the price api for the\n * chain's native token. On most chains, this is signified by the zero address.\n * But on some chains, the native token has a specific address.\n *\n * @param chainId - The hexadecimal chain id.\n * @returns The address of the chain's native token.\n */\nexport const getNativeTokenAddress = (chainId: Hex): Hex =>\n chainIdToNativeTokenAddress[chainId] ?? ZERO_ADDRESS;\n\n// Source: https://github.com/consensys-vertical-apps/va-mmcx-price-api/blob/main/src/constants/slip44.ts\n// We can only support PricesAPI V3 for EVM chains that have a CAIP-19 native asset mapping.\nexport const SPOT_PRICES_SUPPORT_INFO = {\n '0x1': 'eip155:1/slip44:60', // Ethereum Mainnet - Native symbol: ETH\n '0xa': 'eip155:10/slip44:60', // OP Mainnet - Native symbol: ETH\n '0x19': 'eip155:25/slip44:394', // Cronos Mainnet - Native symbol: CRO\n '0x38': 'eip155:56/slip44:714', // BNB Smart Chain Mainnet - Native symbol: BNB\n '0x39': 'eip155:57/erc20:0x0000000000000000000000000000000000000000', // 'eip155:57/slip44:57', // Syscoin Mainnet - Native symbol: SYS\n '0x52': null, // 'eip155:82/slip44:18000', // Meter Mainnet - Native symbol: MTR\n '0x58': 'eip155:88/erc20:0x0000000000000000000000000000000000000000', // 'eip155:88/slip44:889', // TomoChain - Native symbol: TOMO\n '0x64': 'eip155:100/slip44:700', // Gnosis (formerly xDAI Chain) - Native symbol: xDAI\n '0x6a': 'eip155:106/erc20:0x0000000000000000000000000000000000000000', // 'eip155:106/slip44:5655640', // Velas EVM Mainnet - Native symbol: VLX\n '0x80': 'eip155:128/erc20:0x0000000000000000000000000000000000000000', // 'eip155:128/slip44:1010', // Huobi ECO Chain Mainnet - Native symbol: HT\n '0x89': 'eip155:137/slip44:966', // Polygon Mainnet - Native symbol: POL\n '0x8f': null, // 'eip155:143/slip44:268435779', // Monad Mainnet - Native symbol: MON\n '0x92': 'eip155:146/slip44:10007', // Sonic Mainnet - Native symbol: S\n '0xfa': 'eip155:250/slip44:1007', // Fantom Opera - Native symbol: FTM\n '0x141': 'eip155:321/erc20:0x0000000000000000000000000000000000000000', // 'eip155:321/slip44:641', // KCC Mainnet - Native symbol: KCS\n '0x144': 'eip155:324/slip44:60', // zkSync Era Mainnet (Ethereum L2) - Native symbol: ETH\n '0x169': 'eip155:361/erc20:0x0000000000000000000000000000000000000000', // 'eip155:361/slip44:589', // Theta Mainnet - Native symbol: TFUEL\n '0x3e7': 'eip155:999/slip44:2457', // HyperEVM - Native symbol: ETH\n '0x440': 'eip155:1088/erc20:0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000', // 'eip155:1088/slip44:XXX', // Metis Andromeda Mainnet (Ethereum L2) - Native symbol: METIS\n '0x44d': 'eip155:1101/slip44:60', // Polygon zkEVM mainnet - Native symbol: ETH\n '0x504': 'eip155:1284/slip44:1284', // Moonbeam - Native symbol: GLMR\n '0x505': 'eip155:1285/slip44:1285', // Moonriver - Native symbol: MOVR\n '0x531': 'eip155:1329/slip44:19000118', // Sei Mainnet - Native symbol: SEI\n '0x1388': 'eip155:5000/erc20:0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000', // 'eip155:5000/slip44:XXX', // Mantle - Native symbol: MNT\n '0x2105': 'eip155:8453/slip44:60', // Base - Native symbol: ETH\n '0x2710': 'eip155:10000/erc20:0x0000000000000000000000000000000000000000', // 'eip155:10000/slip44:145', // Smart Bitcoin Cash - Native symbol: BCH\n '0xa4b1': 'eip155:42161/slip44:60', // Arbitrum One - Native symbol: ETH\n '0xa4ec': 'eip155:42220/slip44:52752', // Celo Mainnet - Native symbol: CELO\n '0xa516': 'eip155:42262/erc20:0x0000000000000000000000000000000000000000', // 'eip155:42262/slip44:474', // Oasis Emerald - Native symbol: ROSE\n '0xa86a': 'eip155:43114/slip44:9005', // Avalanche C-Chain - Native symbol: AVAX\n '0xe708': 'eip155:59144/slip44:60', // Linea Mainnet - Native symbol: ETH\n '0x13c31': 'eip155:81457/erc20:0x0000000000000000000000000000000000000000', // 'eip155:81457/slip44:60', // Blast Mainnet - Native symbol: ETH\n '0x17dcd': 'eip155:97741/erc20:0x0000000000000000000000000000000000000000', // 'eip155:97741/slip44:XXX', // Pepe Unchained Mainnet - Native symbol: PEPU\n '0x518af': null, // 'eip155:333999/slip44:1997', // Polis Mainnet - Native symbol: POLIS\n '0x82750': 'eip155:534352/slip44:60', // Scroll Mainnet - Native symbol: ETH\n '0x4e454152': 'eip155:60/slip44:60', // Aurora Mainnet (Ethereum L2 on NEAR) - Native symbol: ETH\n '0x63564c40': 'eip155:1666600000/slip44:1023', // Harmony Mainnet Shard 0 - Native symbol: ONE\n '0x8173': 'eip155:33139/erc20:0x0000000000000000000000000000000000000000', // Apechain Mainnet - Native symbol: APE\n '0xe8': 'eip155:232/erc20:0x0000000000000000000000000000000000000000', // Lens Mainnet - Native symbol: GHO\n '0x18232': 'eip155:98866/erc20:0x0000000000000000000000000000000000000000', // Plume Mainnet - Narive symbol: Plume\n '0x2eb': 'eip155:747/erc20:0x0000000000000000000000000000000000000000', // Flow evm - Native symbol: Flow\n '0x138de': 'eip155:80094/erc20:0x0000000000000000000000000000000000000000', // Berachain - Native symbol: Bera',\n '0x15f900': 'eip155:1440000/erc20:0x0000000000000000000000000000000000000000', // xrpl-evm - native symbol: XRP\n '0xfc': 'eip155:252/erc20:0x0000000000000000000000000000000000000000', // Fraxtal - native symbol: FRAX\n '0x2a': 'eip155:42/erc20:0x0000000000000000000000000000000000000000', // Lukso - native symbol: LYX\n '0x32': 'eip155:50/erc20:0x0000000000000000000000000000000000000000', // xdc-network - native symbol: XDC\n '0x2611': 'eip155:9745/erc20:0x0000000000000000000000000000000000000000', // Plasma mainnet - native symbol: XPL\n} as const;\n\n// MISSING CHAINS WITH NO NATIVE ASSET PRICES IN V2\n// '0x42': 'eip155:66/slip44:996', // OKXChain Mainnet - Native symbol: OKT\n// '0x46': 'eip155:70/slip44:1170', // Hoo Smart Chain - Native symbol: HOO\n// '0x7a': 'eip155:122/slip44:XXX', // Fuse Mainnet - Native symbol: FUSE\n// '0x120': 'eip155:288/slip44:60', // Boba Network (Ethereum L2) - Native symbol: ETH\n// '0x150': 'eip155:336/slip44:809', // Shiden - Native symbol: SDN\n// '0x28c58': 'eip155:167000/slip44:60', // Taiko Mainnet - Native symbol: ETH\n\n/**\n * A currency that can be supplied as the `vsCurrency` parameter to\n * the `/spot-prices` endpoint. Covers both uppercase and lowercase versions.\n */\ntype SupportedCurrency =\n | (typeof SUPPORTED_CURRENCIES)[number]\n | Uppercase<(typeof SUPPORTED_CURRENCIES)[number]>;\n\n/**\n * The list of chain IDs that can be supplied in the URL for the `/spot-prices`\n * endpoint, but in hexadecimal form (for consistency with how we represent\n * chain IDs in other places).\n *\n * @see Used by {@link CodefiTokenPricesServiceV2} to validate that a given chain ID is supported by V2 of the Codefi Price API.\n */\nexport const SUPPORTED_CHAIN_IDS = Object.keys(\n SPOT_PRICES_SUPPORT_INFO,\n) as (keyof typeof SPOT_PRICES_SUPPORT_INFO)[];\n\n/**\n * A chain ID that can be supplied in the URL for the `/spot-prices` endpoint,\n * but in hexadecimal form (for consistency with how we represent chain IDs in\n * other places).\n */\ntype SupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];\n\n/**\n * The list of chain IDs that are supported by V3 of the Codefi Price API.\n * Only includes chain IDs from SPOT_PRICES_SUPPORT_INFO that have a non-null CAIP-19 value.\n */\nconst SUPPORTED_CHAIN_IDS_V3 = Object.keys(SPOT_PRICES_SUPPORT_INFO).filter(\n (chainId) =>\n SPOT_PRICES_SUPPORT_INFO[\n chainId as keyof typeof SPOT_PRICES_SUPPORT_INFO\n ] !== null,\n);\n\nconst BASE_URL_V1 = 'https://price.api.cx.metamask.io/v1';\n\nconst BASE_URL_V2 = 'https://price.api.cx.metamask.io/v2';\n\nconst BASE_URL_V3 = 'https://price.api.cx.metamask.io/v3';\n\n/**\n * This version of the token prices service uses V2 of the Codefi Price API to\n * fetch token prices.\n */\nexport class CodefiTokenPricesServiceV2\n implements AbstractTokenPricesService<SupportedChainId, SupportedCurrency>\n{\n readonly #policy: ServicePolicy;\n\n /**\n * Construct a Codefi Token Price Service.\n *\n * @param args - The arguments.\n * @param args.degradedThreshold - The length of time (in milliseconds)\n * that governs when the service is regarded as degraded (affecting when\n * `onDegraded` is called). Defaults to 5 seconds.\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further updates.\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n */\n constructor(args?: {\n degradedThreshold?: number;\n retries?: number;\n maximumConsecutiveFailures?: number;\n circuitBreakDuration?: number;\n });\n\n /**\n * Construct a Codefi Token Price Service.\n *\n * @deprecated This signature is deprecated; please use the `onBreak` and\n * `onDegraded` methods instead.\n * @param args - The arguments.\n * @param args.degradedThreshold - The length of time (in milliseconds)\n * that governs when the service is regarded as degraded (affecting when\n * `onDegraded` is called). Defaults to 5 seconds.\n * @param args.retries - Number of retry attempts for each fetch request.\n * @param args.maximumConsecutiveFailures - The maximum number of consecutive\n * failures allowed before breaking the circuit and pausing further updates.\n * @param args.onBreak - Callback for when the circuit breaks, useful\n * for capturing metrics about network failures.\n * @param args.onDegraded - Callback for when the API responds successfully\n * but takes too long to respond (5 seconds or more).\n * @param args.circuitBreakDuration - The amount of time to wait when the\n * circuit breaks from too many consecutive failures.\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n constructor(args?: {\n degradedThreshold?: number;\n retries?: number;\n maximumConsecutiveFailures?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n circuitBreakDuration?: number;\n });\n\n constructor({\n degradedThreshold = DEFAULT_DEGRADED_THRESHOLD,\n retries = DEFAULT_MAX_RETRIES,\n maximumConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n onBreak,\n onDegraded,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n }: {\n degradedThreshold?: number;\n retries?: number;\n maximumConsecutiveFailures?: number;\n onBreak?: () => void;\n onDegraded?: () => void;\n circuitBreakDuration?: number;\n } = {}) {\n this.#policy = createServicePolicy({\n maxRetries: retries,\n maxConsecutiveFailures: maximumConsecutiveFailures,\n circuitBreakDuration,\n degradedThreshold,\n });\n if (onBreak) {\n this.#policy.onBreak(onBreak);\n }\n if (onDegraded) {\n this.#policy.onDegraded(onDegraded);\n }\n }\n\n /**\n * Listens for when the request to the API fails too many times in a row.\n *\n * @param args - The same arguments that {@link ServicePolicy.onBreak}\n * takes.\n * @returns What {@link ServicePolicy.onBreak} returns.\n */\n onBreak(...args: Parameters<ServicePolicy['onBreak']>) {\n return this.#policy.onBreak(...args);\n }\n\n /**\n * Listens for when the API is degraded.\n *\n * @param args - The same arguments that {@link ServicePolicy.onDegraded}\n * takes.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n */\n onDegraded(...args: Parameters<ServicePolicy['onDegraded']>) {\n return this.#policy.onDegraded(...args);\n }\n\n /**\n * Retrieves prices in the given currency for the tokens identified by the\n * given addresses which are expected to live on the given chain.\n *\n * @param args - The arguments to function.\n * @param args.assets - The assets to get prices for.\n * @param args.currency - The desired currency of the token prices.\n * @returns The prices for the requested tokens.\n */\n async fetchTokenPrices({\n assets,\n currency,\n }: {\n assets: EvmAssetAddressWithChain<SupportedChainId>[];\n currency: SupportedCurrency;\n }): Promise<EvmAssetWithMarketData<SupportedChainId, SupportedCurrency>[]> {\n const v3Assets = await this.#fetchTokenPricesV3(assets, currency);\n const v2Assets = await this.#fetchTokenPricesV2(assets, currency);\n\n return [...v3Assets, ...v2Assets];\n }\n\n async #fetchTokenPricesV3(\n assets: EvmAssetAddressWithChain<SupportedChainId>[],\n currency: SupportedCurrency,\n ): Promise<EvmAssetWithMarketData<SupportedChainId, SupportedCurrency>[]> {\n const assetsWithIds: EvmAssetWithId<SupportedChainId>[] = assets\n // Filter out assets that are not supported by V3 of the Price API.\n .filter((asset) => SUPPORTED_CHAIN_IDS_V3.includes(asset.chainId))\n .map((asset) => {\n const caipChainId = toCaipChainId(\n KnownCaipNamespace.Eip155,\n hexToNumber(asset.chainId).toString(),\n );\n\n const nativeAddress = getNativeTokenAddress(asset.chainId);\n\n return {\n ...asset,\n assetId: (nativeAddress.toLowerCase() ===\n asset.tokenAddress.toLowerCase()\n ? SPOT_PRICES_SUPPORT_INFO[asset.chainId]\n : `${caipChainId}/erc20:${asset.tokenAddress.toLowerCase()}`) as CaipAssetType,\n };\n })\n .filter((asset) => asset.assetId);\n\n if (assetsWithIds.length === 0) {\n return [];\n }\n\n const url = new URL(`${BASE_URL_V3}/spot-prices`);\n url.searchParams.append(\n 'assetIds',\n assetsWithIds.map((asset) => asset.assetId).join(','),\n );\n url.searchParams.append('vsCurrency', currency);\n url.searchParams.append('includeMarketData', 'true');\n\n const addressCryptoDataMap: {\n [assetId: CaipAssetType]: Omit<\n MarketDataDetails,\n 'currency' | 'tokenAddress'\n >;\n } = await this.#policy.execute(() =>\n handleFetch(url, { headers: { 'Cache-Control': 'no-cache' } }),\n );\n\n return assetsWithIds\n .map((assetWithId) => {\n const marketData = addressCryptoDataMap[assetWithId.assetId];\n\n if (!marketData) {\n return undefined;\n }\n\n return {\n ...marketData,\n ...assetWithId,\n currency,\n };\n })\n .filter((entry): entry is NonNullable<typeof entry> => Boolean(entry));\n }\n\n async #fetchTokenPricesV2(\n assets: EvmAssetAddressWithChain<SupportedChainId>[],\n currency: SupportedCurrency,\n ): Promise<EvmAssetWithMarketData<SupportedChainId, SupportedCurrency>[]> {\n const v2SupportedAssets = assets.filter(\n (asset) => !SUPPORTED_CHAIN_IDS_V3.includes(asset.chainId),\n );\n\n const assetsByChainId: Record<SupportedChainId, Hex[]> =\n v2SupportedAssets.reduce(\n (acc, { chainId, tokenAddress }) => {\n (acc[chainId] ??= []).push(tokenAddress);\n return acc;\n },\n {} as Record<SupportedChainId, Hex[]>,\n );\n\n const promises = Object.entries(assetsByChainId).map(\n async ([chainId, tokenAddresses]) => {\n if (tokenAddresses.length === 0) {\n return [];\n }\n\n const url = new URL(`${BASE_URL_V2}/chains/${chainId}/spot-prices`);\n url.searchParams.append('tokenAddresses', tokenAddresses.join(','));\n url.searchParams.append('vsCurrency', currency);\n url.searchParams.append('includeMarketData', 'true');\n\n const addressCryptoDataMap: {\n [tokenAddress: string]: Omit<\n MarketDataDetails,\n 'currency' | 'tokenAddress'\n >;\n } = await this.#policy.execute(() =>\n handleFetch(url, { headers: { 'Cache-Control': 'no-cache' } }),\n );\n\n return tokenAddresses\n .map((tokenAddress) => {\n const marketData = addressCryptoDataMap[tokenAddress.toLowerCase()];\n\n if (!marketData) {\n return undefined;\n }\n\n return {\n ...marketData,\n tokenAddress,\n chainId: chainId as SupportedChainId,\n currency,\n };\n })\n .filter((entry): entry is NonNullable<typeof entry> =>\n Boolean(entry),\n );\n },\n );\n\n return await Promise.allSettled(promises).then((results) =>\n results.flatMap((result) =>\n result.status === 'fulfilled' ? result.value : [],\n ),\n );\n }\n\n /**\n * Retrieves exchange rates in the given base currency.\n *\n * @param args - The arguments to this function.\n * @param args.baseCurrency - The desired base currency of the exchange rates.\n * @param args.includeUsdRate - Whether to include the USD rate in the response.\n * @param args.cryptocurrencies - The cryptocurrencies to get exchange rates for.\n * @returns The exchange rates for the requested base currency.\n */\n async fetchExchangeRates({\n baseCurrency,\n includeUsdRate,\n cryptocurrencies,\n }: {\n baseCurrency: SupportedCurrency;\n includeUsdRate: boolean;\n cryptocurrencies: string[];\n }): Promise<ExchangeRatesByCurrency<SupportedCurrency>> {\n const url = new URL(`${BASE_URL_V1}/exchange-rates`);\n url.searchParams.append('baseCurrency', baseCurrency);\n\n const urlUsd = new URL(`${BASE_URL_V1}/exchange-rates`);\n urlUsd.searchParams.append('baseCurrency', 'usd');\n\n const [exchangeRatesResult, exchangeRatesResultUsd] =\n await Promise.allSettled([\n this.#policy.execute(() =>\n handleFetch(url, { headers: { 'Cache-Control': 'no-cache' } }),\n ),\n ...(includeUsdRate && baseCurrency.toLowerCase() !== 'usd'\n ? [\n this.#policy.execute(() =>\n handleFetch(urlUsd, {\n headers: { 'Cache-Control': 'no-cache' },\n }),\n ),\n ]\n : []),\n ]);\n\n // Handle resolved/rejected\n const exchangeRates =\n exchangeRatesResult.status === 'fulfilled'\n ? exchangeRatesResult.value\n : {};\n const exchangeRatesUsd =\n exchangeRatesResultUsd?.status === 'fulfilled'\n ? exchangeRatesResultUsd.value\n : {};\n\n if (exchangeRatesResult.status === 'rejected') {\n throw new Error('Failed to fetch');\n }\n\n const filteredExchangeRates = cryptocurrencies.reduce((acc, key) => {\n if (exchangeRates[key.toLowerCase() as SupportedCurrency]) {\n acc[key.toLowerCase() as SupportedCurrency] =\n exchangeRates[key.toLowerCase() as SupportedCurrency];\n }\n return acc;\n }, {} as ExchangeRatesByCurrency<SupportedCurrency>);\n\n if (Object.keys(filteredExchangeRates).length === 0) {\n throw new Error(\n 'None of the cryptocurrencies are supported by price api',\n );\n }\n\n const filteredUsdExchangeRates = cryptocurrencies.reduce((acc, key) => {\n if (exchangeRatesUsd[key.toLowerCase() as SupportedCurrency]) {\n acc[key.toLowerCase() as SupportedCurrency] =\n exchangeRatesUsd[key.toLowerCase() as SupportedCurrency];\n }\n return acc;\n }, {} as ExchangeRatesByCurrency<SupportedCurrency>);\n\n if (baseCurrency.toLowerCase() === 'usd') {\n Object.keys(filteredExchangeRates).forEach((key) => {\n filteredExchangeRates[key as SupportedCurrency] = {\n ...filteredExchangeRates[key as SupportedCurrency],\n usd: filteredExchangeRates[key as SupportedCurrency]?.value,\n };\n });\n return filteredExchangeRates;\n }\n if (!includeUsdRate) {\n return filteredExchangeRates;\n }\n\n const merged = Object.keys(filteredExchangeRates).reduce((acc, key) => {\n acc[key as SupportedCurrency] = {\n ...filteredExchangeRates[key as SupportedCurrency],\n ...(filteredUsdExchangeRates[key as SupportedCurrency]?.value\n ? { usd: filteredUsdExchangeRates[key as SupportedCurrency]?.value }\n : {}),\n };\n return acc;\n }, {} as ExchangeRatesByCurrency<SupportedCurrency>);\n\n return merged;\n }\n\n /**\n * Type guard for whether the API can return token prices for the given chain\n * ID.\n *\n * @param chainId - The chain ID to check.\n * @returns True if the API supports the chain ID, false otherwise.\n */\n validateChainIdSupported(chainId: unknown): chainId is SupportedChainId {\n const supportedChainIds: readonly string[] = SUPPORTED_CHAIN_IDS;\n return typeof chainId === 'string' && supportedChainIds.includes(chainId);\n }\n\n /**\n * Type guard for whether the API can return token prices in the given\n * currency.\n *\n * @param currency - The currency to check. If a string, can be either\n * lowercase or uppercase.\n * @returns True if the API supports the currency, false otherwise.\n */\n validateCurrencySupported(currency: unknown): currency is SupportedCurrency {\n const supportedCurrencies: readonly string[] = SUPPORTED_CURRENCIES;\n return (\n typeof currency === 'string' &&\n supportedCurrencies.includes(currency.toLowerCase())\n );\n }\n}\n"]}
@@ -5,7 +5,7 @@ import type { AbstractTokenPricesService, EvmAssetAddressWithChain, EvmAssetWith
5
5
  * The list of currencies that can be supplied as the `vsCurrency` parameter to
6
6
  * the `/spot-prices` endpoint, in lowercase form.
7
7
  */
8
- export declare const SUPPORTED_CURRENCIES: readonly ["btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "gel", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "mon", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar", "xdr", "xag", "xau", "bits", "sats", "cop", "kes", "ron", "dop", "crc", "hnl", "zmw", "svc", "bam", "pen", "gtq", "lbp", "amd", "sol", "sei", "sonic", "trx", "taiko", "pepu", "pol", "mnt", "nom", "avax"];
8
+ export declare const SUPPORTED_CURRENCIES: readonly ["btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "gel", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "mon", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar", "xdr", "xag", "xau", "bits", "sats", "cop", "kes", "ron", "dop", "crc", "hnl", "zmw", "svc", "bam", "pen", "gtq", "lbp", "amd", "sol", "sei", "sonic", "trx", "taiko", "pepu", "pol", "mnt", "nom", "avax", "ape"];
9
9
  /**
10
10
  * Represents the zero address, commonly used as a placeholder in blockchain transactions.
11
11
  * In the context of fetching market data, the zero address is utilized to retrieve information
@@ -60,6 +60,16 @@ export declare const SPOT_PRICES_SUPPORT_INFO: {
60
60
  readonly '0x82750': "eip155:534352/slip44:60";
61
61
  readonly '0x4e454152': "eip155:60/slip44:60";
62
62
  readonly '0x63564c40': "eip155:1666600000/slip44:1023";
63
+ readonly '0x8173': "eip155:33139/erc20:0x0000000000000000000000000000000000000000";
64
+ readonly '0xe8': "eip155:232/erc20:0x0000000000000000000000000000000000000000";
65
+ readonly '0x18232': "eip155:98866/erc20:0x0000000000000000000000000000000000000000";
66
+ readonly '0x2eb': "eip155:747/erc20:0x0000000000000000000000000000000000000000";
67
+ readonly '0x138de': "eip155:80094/erc20:0x0000000000000000000000000000000000000000";
68
+ readonly '0x15f900': "eip155:1440000/erc20:0x0000000000000000000000000000000000000000";
69
+ readonly '0xfc': "eip155:252/erc20:0x0000000000000000000000000000000000000000";
70
+ readonly '0x2a': "eip155:42/erc20:0x0000000000000000000000000000000000000000";
71
+ readonly '0x32': "eip155:50/erc20:0x0000000000000000000000000000000000000000";
72
+ readonly '0x2611': "eip155:9745/erc20:0x0000000000000000000000000000000000000000";
63
73
  };
64
74
  /**
65
75
  * A currency that can be supplied as the `vsCurrency` parameter to
@@ -73,7 +83,7 @@ type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number] | Uppercase<(type
73
83
  *
74
84
  * @see Used by {@link CodefiTokenPricesServiceV2} to validate that a given chain ID is supported by V2 of the Codefi Price API.
75
85
  */
76
- export declare const SUPPORTED_CHAIN_IDS: ("0x1" | "0x89" | "0x38" | "0x2105" | "0xa" | "0xa4b1" | "0x82750" | "0x531" | "0x8f" | "0xe708" | "0x440" | "0x1388" | "0x19" | "0x39" | "0x52" | "0x58" | "0x64" | "0x6a" | "0x80" | "0x92" | "0xfa" | "0x141" | "0x144" | "0x169" | "0x3e7" | "0x44d" | "0x504" | "0x505" | "0x2710" | "0xa4ec" | "0xa516" | "0xa86a" | "0x13c31" | "0x17dcd" | "0x518af" | "0x4e454152" | "0x63564c40")[];
86
+ export declare const SUPPORTED_CHAIN_IDS: ("0x1" | "0x89" | "0x38" | "0x2105" | "0xa" | "0xa4b1" | "0x82750" | "0x531" | "0x8f" | "0xe708" | "0x440" | "0x1388" | "0x19" | "0x39" | "0x52" | "0x58" | "0x64" | "0x6a" | "0x80" | "0x92" | "0xfa" | "0x141" | "0x144" | "0x169" | "0x3e7" | "0x44d" | "0x504" | "0x505" | "0x2710" | "0xa4ec" | "0xa516" | "0xa86a" | "0x13c31" | "0x17dcd" | "0x518af" | "0x4e454152" | "0x63564c40" | "0x8173" | "0xe8" | "0x18232" | "0x2eb" | "0x138de" | "0x15f900" | "0xfc" | "0x2a" | "0x32" | "0x2611")[];
77
87
  /**
78
88
  * A chain ID that can be supplied in the URL for the `/spot-prices` endpoint,
79
89
  * but in hexadecimal form (for consistency with how we represent chain IDs in
@@ -1 +1 @@
1
- {"version":3,"file":"codefi-v2.d.cts","sourceRoot":"","sources":["../../src/token-prices-service/codefi-v2.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAiB,GAAG,EAAE,wBAAwB;AAO1D,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EAExB,sBAAsB,EACtB,uBAAuB,EACxB,4CAAwC;AAGzC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,8mBA6KvB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,GAC4B,CAAC;AAYxD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,YAAa,GAAG,KAAG,GACC,CAAC;AAIvD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsC3B,CAAC;AAUX;;;GAGG;AACH,KAAK,iBAAiB,GAClB,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,GACrC,SAAS,CAAC,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,+XAEc,CAAC;AAE/C;;;;GAIG;AACH,KAAK,gBAAgB,GAAG,CAAC,OAAO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CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,gBAAgB;IAKvE;;;;;;;OAOG;IACH,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,iBAAiB;CAO5E"}
@@ -5,7 +5,7 @@ import type { AbstractTokenPricesService, EvmAssetAddressWithChain, EvmAssetWith
5
5
  * The list of currencies that can be supplied as the `vsCurrency` parameter to
6
6
  * the `/spot-prices` endpoint, in lowercase form.
7
7
  */
8
- export declare const SUPPORTED_CURRENCIES: readonly ["btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "gel", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "mon", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar", "xdr", "xag", "xau", "bits", "sats", "cop", "kes", "ron", "dop", "crc", "hnl", "zmw", "svc", "bam", "pen", "gtq", "lbp", "amd", "sol", "sei", "sonic", "trx", "taiko", "pepu", "pol", "mnt", "nom", "avax"];
8
+ export declare const SUPPORTED_CURRENCIES: readonly ["btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "gel", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "mon", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar", "xdr", "xag", "xau", "bits", "sats", "cop", "kes", "ron", "dop", "crc", "hnl", "zmw", "svc", "bam", "pen", "gtq", "lbp", "amd", "sol", "sei", "sonic", "trx", "taiko", "pepu", "pol", "mnt", "nom", "avax", "ape"];
9
9
  /**
10
10
  * Represents the zero address, commonly used as a placeholder in blockchain transactions.
11
11
  * In the context of fetching market data, the zero address is utilized to retrieve information
@@ -60,6 +60,16 @@ export declare const SPOT_PRICES_SUPPORT_INFO: {
60
60
  readonly '0x82750': "eip155:534352/slip44:60";
61
61
  readonly '0x4e454152': "eip155:60/slip44:60";
62
62
  readonly '0x63564c40': "eip155:1666600000/slip44:1023";
63
+ readonly '0x8173': "eip155:33139/erc20:0x0000000000000000000000000000000000000000";
64
+ readonly '0xe8': "eip155:232/erc20:0x0000000000000000000000000000000000000000";
65
+ readonly '0x18232': "eip155:98866/erc20:0x0000000000000000000000000000000000000000";
66
+ readonly '0x2eb': "eip155:747/erc20:0x0000000000000000000000000000000000000000";
67
+ readonly '0x138de': "eip155:80094/erc20:0x0000000000000000000000000000000000000000";
68
+ readonly '0x15f900': "eip155:1440000/erc20:0x0000000000000000000000000000000000000000";
69
+ readonly '0xfc': "eip155:252/erc20:0x0000000000000000000000000000000000000000";
70
+ readonly '0x2a': "eip155:42/erc20:0x0000000000000000000000000000000000000000";
71
+ readonly '0x32': "eip155:50/erc20:0x0000000000000000000000000000000000000000";
72
+ readonly '0x2611': "eip155:9745/erc20:0x0000000000000000000000000000000000000000";
63
73
  };
64
74
  /**
65
75
  * A currency that can be supplied as the `vsCurrency` parameter to
@@ -73,7 +83,7 @@ type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number] | Uppercase<(type
73
83
  *
74
84
  * @see Used by {@link CodefiTokenPricesServiceV2} to validate that a given chain ID is supported by V2 of the Codefi Price API.
75
85
  */
76
- export declare const SUPPORTED_CHAIN_IDS: ("0x1" | "0x89" | "0x38" | "0x2105" | "0xa" | "0xa4b1" | "0x82750" | "0x531" | "0x8f" | "0xe708" | "0x440" | "0x1388" | "0x19" | "0x39" | "0x52" | "0x58" | "0x64" | "0x6a" | "0x80" | "0x92" | "0xfa" | "0x141" | "0x144" | "0x169" | "0x3e7" | "0x44d" | "0x504" | "0x505" | "0x2710" | "0xa4ec" | "0xa516" | "0xa86a" | "0x13c31" | "0x17dcd" | "0x518af" | "0x4e454152" | "0x63564c40")[];
86
+ export declare const SUPPORTED_CHAIN_IDS: ("0x1" | "0x89" | "0x38" | "0x2105" | "0xa" | "0xa4b1" | "0x82750" | "0x531" | "0x8f" | "0xe708" | "0x440" | "0x1388" | "0x19" | "0x39" | "0x52" | "0x58" | "0x64" | "0x6a" | "0x80" | "0x92" | "0xfa" | "0x141" | "0x144" | "0x169" | "0x3e7" | "0x44d" | "0x504" | "0x505" | "0x2710" | "0xa4ec" | "0xa516" | "0xa86a" | "0x13c31" | "0x17dcd" | "0x518af" | "0x4e454152" | "0x63564c40" | "0x8173" | "0xe8" | "0x18232" | "0x2eb" | "0x138de" | "0x15f900" | "0xfc" | "0x2a" | "0x32" | "0x2611")[];
77
87
  /**
78
88
  * A chain ID that can be supplied in the URL for the `/spot-prices` endpoint,
79
89
  * but in hexadecimal form (for consistency with how we represent chain IDs in
@@ -1 +1 @@
1
- {"version":3,"file":"codefi-v2.d.mts","sourceRoot":"","sources":["../../src/token-prices-service/codefi-v2.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAiB,GAAG,EAAE,wBAAwB;AAO1D,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EAExB,sBAAsB,EACtB,uBAAuB,EACxB,4CAAwC;AAGzC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,8mBA6KvB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,GAC4B,CAAC;AAYxD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,YAAa,GAAG,KAAG,GACC,CAAC;AAIvD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsC3B,CAAC;AAUX;;;GAGG;AACH,KAAK,iBAAiB,GAClB,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Z,cAAc,EACd,gBAAgB,GACjB,EAAE;QACD,YAAY,EAAE,iBAAiB,CAAC;QAChC,cAAc,EAAE,OAAO,CAAC;QACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;KAC5B,GAAG,OAAO,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;IAqFvD;;;;;;OAMG;IACH,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,gBAAgB;IAKvE;;;;;;;OAOG;IACH,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,iBAAiB;CAO5E"}
@@ -189,6 +189,8 @@ export const SUPPORTED_CURRENCIES = [
189
189
  'nom',
190
190
  // Avalanche
191
191
  'avax',
192
+ // Apechain
193
+ 'ape',
192
194
  ];
193
195
  /**
194
196
  * Represents the zero address, commonly used as a placeholder in blockchain transactions.
@@ -255,6 +257,16 @@ export const SPOT_PRICES_SUPPORT_INFO = {
255
257
  '0x82750': 'eip155:534352/slip44:60', // Scroll Mainnet - Native symbol: ETH
256
258
  '0x4e454152': 'eip155:60/slip44:60', // Aurora Mainnet (Ethereum L2 on NEAR) - Native symbol: ETH
257
259
  '0x63564c40': 'eip155:1666600000/slip44:1023', // Harmony Mainnet Shard 0 - Native symbol: ONE
260
+ '0x8173': 'eip155:33139/erc20:0x0000000000000000000000000000000000000000', // Apechain Mainnet - Native symbol: APE
261
+ '0xe8': 'eip155:232/erc20:0x0000000000000000000000000000000000000000', // Lens Mainnet - Native symbol: GHO
262
+ '0x18232': 'eip155:98866/erc20:0x0000000000000000000000000000000000000000', // Plume Mainnet - Narive symbol: Plume
263
+ '0x2eb': 'eip155:747/erc20:0x0000000000000000000000000000000000000000', // Flow evm - Native symbol: Flow
264
+ '0x138de': 'eip155:80094/erc20:0x0000000000000000000000000000000000000000', // Berachain - Native symbol: Bera',
265
+ '0x15f900': 'eip155:1440000/erc20:0x0000000000000000000000000000000000000000', // xrpl-evm - native symbol: XRP
266
+ '0xfc': 'eip155:252/erc20:0x0000000000000000000000000000000000000000', // Fraxtal - native symbol: FRAX
267
+ '0x2a': 'eip155:42/erc20:0x0000000000000000000000000000000000000000', // Lukso - native symbol: LYX
268
+ '0x32': 'eip155:50/erc20:0x0000000000000000000000000000000000000000', // xdc-network - native symbol: XDC
269
+ '0x2611': 'eip155:9745/erc20:0x0000000000000000000000000000000000000000', // Plasma mainnet - native symbol: XPL
258
270
  };
259
271
  /**
260
272
  * The list of chain IDs that can be supplied in the URL for the `/spot-prices`