@across-protocol/sdk 4.3.111-alpha.3 → 4.3.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/addressAggregator/adapters/abstract.js +64 -50
- package/dist/cjs/addressAggregator/adapters/abstract.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/bybit.js +29 -16
- package/dist/cjs/addressAggregator/adapters/bybit.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/env.js +15 -11
- package/dist/cjs/addressAggregator/adapters/env.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/file.js +45 -32
- package/dist/cjs/addressAggregator/adapters/file.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/index.js +1 -1
- package/dist/cjs/addressAggregator/adapters/risklabs.js +36 -22
- package/dist/cjs/addressAggregator/adapters/risklabs.js.map +1 -1
- package/dist/cjs/addressAggregator/index.js +87 -57
- package/dist/cjs/addressAggregator/index.js.map +1 -1
- package/dist/cjs/apiClient/abstractClient.js +8 -9
- package/dist/cjs/apiClient/abstractClient.js.map +1 -1
- package/dist/cjs/apiClient/index.js +1 -1
- package/dist/cjs/apiClient/mockedClient.js +29 -23
- package/dist/cjs/apiClient/mockedClient.js.map +1 -1
- package/dist/cjs/apiClient/productionClient.js +103 -65
- package/dist/cjs/apiClient/productionClient.js.map +1 -1
- package/dist/cjs/arch/evm/BlockUtils.js +208 -122
- package/dist/cjs/arch/evm/BlockUtils.js.map +1 -1
- package/dist/cjs/arch/evm/MessageUtils.js +1 -1
- package/dist/cjs/arch/evm/MessageUtils.js.map +1 -1
- package/dist/cjs/arch/evm/SpokeUtils.js +288 -134
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/evm/index.js +1 -1
- package/dist/cjs/arch/evm/utils/index.js +1 -1
- package/dist/cjs/arch/evm/utils/wait.js +49 -38
- package/dist/cjs/arch/evm/utils/wait.js.map +1 -1
- package/dist/cjs/arch/index.js +1 -1
- package/dist/cjs/arch/svm/BlockUtils.js +158 -102
- package/dist/cjs/arch/svm/BlockUtils.js.map +1 -1
- package/dist/cjs/arch/svm/MessageUtils.js +2 -2
- package/dist/cjs/arch/svm/MessageUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +1147 -708
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/encoders.js +1 -1
- package/dist/cjs/arch/svm/encoders.js.map +1 -1
- package/dist/cjs/arch/svm/eventsClient.js +236 -174
- package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
- package/dist/cjs/arch/svm/index.js +1 -1
- package/dist/cjs/arch/svm/provider.js +3 -3
- package/dist/cjs/arch/svm/provider.js.map +1 -1
- package/dist/cjs/arch/svm/utils.js +355 -166
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/caching/Arweave/ArweaveClient.js +246 -168
- package/dist/cjs/caching/Arweave/ArweaveClient.js.map +1 -1
- package/dist/cjs/caching/Arweave/index.js +1 -1
- package/dist/cjs/caching/IPFS/PinataIPFSClient.js +49 -40
- package/dist/cjs/caching/IPFS/PinataIPFSClient.js.map +1 -1
- package/dist/cjs/caching/IPFS/index.js +1 -1
- package/dist/cjs/caching/Memory/MemoryCacheClient.js +18 -13
- package/dist/cjs/caching/Memory/MemoryCacheClient.js.map +1 -1
- package/dist/cjs/caching/Memory/index.js +1 -1
- package/dist/cjs/caching/index.js +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +381 -302
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/index.js +1 -1
- package/dist/cjs/clients/BaseAbstractClient.js +83 -58
- package/dist/cjs/clients/BaseAbstractClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +900 -709
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/index.js +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +128 -95
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +53 -48
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +8 -10
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +90 -67
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +24 -46
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/index.js +1 -1
- package/dist/cjs/clients/HubPoolClient.js +708 -526
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +179 -133
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +183 -124
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +389 -357
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js +8 -9
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/index.js +3 -3
- package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/cjs/clients/index.js +1 -1
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js +67 -58
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockEvents.js +52 -47
- package/dist/cjs/clients/mocks/MockEvents.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +185 -142
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +192 -208
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +143 -140
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +73 -57
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/index.js +1 -1
- package/dist/cjs/coingecko/Coingecko.js +437 -285
- package/dist/cjs/coingecko/Coingecko.js.map +1 -1
- package/dist/cjs/coingecko/index.js +1 -1
- package/dist/cjs/constants.js +30 -23
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/contracts/acrossConfigStore.js +48 -27
- package/dist/cjs/contracts/acrossConfigStore.js.map +1 -1
- package/dist/cjs/contracts/hubPool.js +20 -36
- package/dist/cjs/contracts/hubPool.js.map +1 -1
- package/dist/cjs/contracts/index.js +1 -1
- package/dist/cjs/contracts/utils.js +8 -6
- package/dist/cjs/contracts/utils.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +16 -7
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js +45 -26
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js +28 -16
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/polygon.js +112 -73
- package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/solana.js +33 -20
- package/dist/cjs/gasPriceOracle/adapters/solana.js.map +1 -1
- package/dist/cjs/gasPriceOracle/oracle.js +104 -77
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/gasPriceOracle/types.js +3 -3
- package/dist/cjs/gasPriceOracle/types.js.map +1 -1
- package/dist/cjs/gasPriceOracle/util.js +8 -8
- package/dist/cjs/gasPriceOracle/util.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/interfaces/index.js +1 -1
- package/dist/cjs/lpFeeCalculator/index.js +1 -1
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js +35 -33
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js.map +1 -1
- package/dist/cjs/lpFeeCalculator/rateModel.js +9 -7
- package/dist/cjs/lpFeeCalculator/rateModel.js.map +1 -1
- package/dist/cjs/merkleDistributor/MerkleDistributor.js +18 -20
- package/dist/cjs/merkleDistributor/MerkleDistributor.js.map +1 -1
- package/dist/cjs/merkleDistributor/index.js +1 -1
- package/dist/cjs/merkleDistributor/model/index.js +1 -1
- package/dist/cjs/pool/TransactionManager.js +100 -45
- package/dist/cjs/pool/TransactionManager.js.map +1 -1
- package/dist/cjs/pool/index.js +1 -1
- package/dist/cjs/pool/poolClient.js +731 -464
- package/dist/cjs/pool/poolClient.js.map +1 -1
- package/dist/cjs/pool/uma/across/index.js +1 -1
- package/dist/cjs/pool/uma/across/transactionManager.js +100 -45
- package/dist/cjs/pool/uma/across/transactionManager.js.map +1 -1
- package/dist/cjs/pool/uma/clients/erc20/client.js +16 -18
- package/dist/cjs/pool/uma/clients/erc20/client.js.map +1 -1
- package/dist/cjs/pool/uma/clients/erc20/index.js +1 -1
- package/dist/cjs/pool/uma/clients/index.js +1 -1
- package/dist/cjs/pool/uma/index.js +1 -1
- package/dist/cjs/pool/uma/oracle/index.js +1 -1
- package/dist/cjs/pool/uma/oracle/utils.js +5 -4
- package/dist/cjs/pool/uma/oracle/utils.js.map +1 -1
- package/dist/cjs/pool/uma/utils.js +30 -11
- package/dist/cjs/pool/uma/utils.js.map +1 -1
- package/dist/cjs/priceClient/adapters/acrossApi.js +39 -22
- package/dist/cjs/priceClient/adapters/acrossApi.js.map +1 -1
- package/dist/cjs/priceClient/adapters/baseAdapter.js +73 -49
- package/dist/cjs/priceClient/adapters/baseAdapter.js.map +1 -1
- package/dist/cjs/priceClient/adapters/coingecko.js +61 -34
- package/dist/cjs/priceClient/adapters/coingecko.js.map +1 -1
- package/dist/cjs/priceClient/adapters/default.js +31 -16
- package/dist/cjs/priceClient/adapters/default.js.map +1 -1
- package/dist/cjs/priceClient/adapters/defiLlama.js +74 -40
- package/dist/cjs/priceClient/adapters/defiLlama.js.map +1 -1
- package/dist/cjs/priceClient/adapters/index.js +1 -1
- package/dist/cjs/priceClient/index.js +1 -1
- package/dist/cjs/priceClient/priceClient.js +159 -110
- package/dist/cjs/priceClient/priceClient.js.map +1 -1
- package/dist/cjs/providers/alchemy.js +19 -17
- package/dist/cjs/providers/alchemy.js.map +1 -1
- package/dist/cjs/providers/cachedProvider.js +129 -88
- package/dist/cjs/providers/cachedProvider.js.map +1 -1
- package/dist/cjs/providers/drpc.js +11 -9
- package/dist/cjs/providers/drpc.js.map +1 -1
- package/dist/cjs/providers/index.js +1 -1
- package/dist/cjs/providers/infura.js +12 -10
- package/dist/cjs/providers/infura.js.map +1 -1
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js +15 -7
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js +14 -6
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/MockRetrySolanaRpcFactory.js +15 -7
- package/dist/cjs/providers/mocks/MockRetrySolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js +66 -42
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/index.js +1 -1
- package/dist/cjs/providers/mocks/mockEthersProvider.js +31 -29
- package/dist/cjs/providers/mocks/mockEthersProvider.js.map +1 -1
- package/dist/cjs/providers/quicknode.js +21 -19
- package/dist/cjs/providers/quicknode.js.map +1 -1
- package/dist/cjs/providers/rateLimitedProvider.js +79 -64
- package/dist/cjs/providers/rateLimitedProvider.js.map +1 -1
- package/dist/cjs/providers/retryProvider.js +246 -163
- package/dist/cjs/providers/retryProvider.js.map +1 -1
- package/dist/cjs/providers/solana/baseRpcFactories.js +18 -14
- package/dist/cjs/providers/solana/baseRpcFactories.js.map +1 -1
- package/dist/cjs/providers/solana/cachedRpcFactory.js +112 -70
- package/dist/cjs/providers/solana/cachedRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/defaultRpcFactory.js +15 -8
- package/dist/cjs/providers/solana/defaultRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/index.js +1 -1
- package/dist/cjs/providers/solana/quorumFallbackRpcFactory.js +191 -135
- package/dist/cjs/providers/solana/quorumFallbackRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/rateLimitedRpcFactory.js +90 -67
- package/dist/cjs/providers/solana/rateLimitedRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/retryRpcFactory.js +79 -52
- package/dist/cjs/providers/solana/retryRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/utils.js +2 -2
- package/dist/cjs/providers/solana/utils.js.map +1 -1
- package/dist/cjs/providers/speedProvider.js +53 -31
- package/dist/cjs/providers/speedProvider.js.map +1 -1
- package/dist/cjs/providers/types.js +1 -1
- package/dist/cjs/providers/types.js.map +1 -1
- package/dist/cjs/providers/utils.js +28 -26
- package/dist/cjs/providers/utils.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +162 -108
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/customGasToken.js +26 -14
- package/dist/cjs/relayFeeCalculator/chain-queries/customGasToken.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +29 -20
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +137 -88
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/index.js +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +297 -199
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/typeguards/error.js +7 -5
- package/dist/cjs/typeguards/error.js.map +1 -1
- package/dist/cjs/typeguards/index.js +1 -1
- package/dist/cjs/utils/AddressUtils.js +144 -117
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/ArrayUtils.js +78 -21
- package/dist/cjs/utils/ArrayUtils.js.map +1 -1
- package/dist/cjs/utils/BigNumberUtils.js +10 -9
- package/dist/cjs/utils/BigNumberUtils.js.map +1 -1
- package/dist/cjs/utils/BlockExplorerUtils.js +30 -26
- package/dist/cjs/utils/BlockExplorerUtils.js.map +1 -1
- package/dist/cjs/utils/BlockFinder.js +5 -2
- package/dist/cjs/utils/BlockFinder.js.map +1 -1
- package/dist/cjs/utils/BlockUtils.js +41 -24
- package/dist/cjs/utils/BlockUtils.js.map +1 -1
- package/dist/cjs/utils/BundleUtils.js +24 -21
- package/dist/cjs/utils/BundleUtils.js.map +1 -1
- package/dist/cjs/utils/CCTPUtils.js +126 -62
- package/dist/cjs/utils/CCTPUtils.js.map +1 -1
- package/dist/cjs/utils/CachingUtils.js +42 -20
- package/dist/cjs/utils/CachingUtils.js.map +1 -1
- package/dist/cjs/utils/ContractUtils.js +5 -5
- package/dist/cjs/utils/ContractUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.js +99 -122
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/EventUtils.js +70 -49
- package/dist/cjs/utils/EventUtils.js.map +1 -1
- package/dist/cjs/utils/FormattingUtils.js +32 -26
- package/dist/cjs/utils/FormattingUtils.js.map +1 -1
- package/dist/cjs/utils/HyperLiquidUtils.js +23 -10
- package/dist/cjs/utils/HyperLiquidUtils.js.map +1 -1
- package/dist/cjs/utils/IPFSUtils.js +34 -16
- package/dist/cjs/utils/IPFSUtils.js.map +1 -1
- package/dist/cjs/utils/JSONUtils.js +6 -6
- package/dist/cjs/utils/JSONUtils.js.map +1 -1
- package/dist/cjs/utils/LogUtils.js +12 -10
- package/dist/cjs/utils/LogUtils.js.map +1 -1
- package/dist/cjs/utils/Multicall.js +115 -56
- package/dist/cjs/utils/Multicall.js.map +1 -1
- package/dist/cjs/utils/NetworkUtils.js +28 -12
- package/dist/cjs/utils/NetworkUtils.js.map +1 -1
- package/dist/cjs/utils/NumberUtils.js +3 -1
- package/dist/cjs/utils/NumberUtils.js.map +1 -1
- package/dist/cjs/utils/ObjectUtils.js +41 -27
- package/dist/cjs/utils/ObjectUtils.js.map +1 -1
- package/dist/cjs/utils/Profiler.js +83 -80
- package/dist/cjs/utils/Profiler.js.map +1 -1
- package/dist/cjs/utils/ReviverUtils.js +9 -5
- package/dist/cjs/utils/ReviverUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.js +84 -84
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.js +64 -41
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/cjs/utils/TypeGuards.js +1 -1
- package/dist/cjs/utils/TypeGuards.js.map +1 -1
- package/dist/cjs/utils/ValidatorUtils.js +7 -7
- package/dist/cjs/utils/ValidatorUtils.js.map +1 -1
- package/dist/cjs/utils/abi/contracts/index.js +1 -1
- package/dist/cjs/utils/abi/index.js +22 -12
- package/dist/cjs/utils/abi/index.js.map +1 -1
- package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js +12 -9
- package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
- package/dist/cjs/utils/abi/typechain/index.js +1 -1
- package/dist/cjs/utils/common.js +53 -40
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/cjs/utils/index.js +1 -1
- package/dist/esm/addressAggregator/adapters/abstract.js +64 -48
- package/dist/esm/addressAggregator/adapters/abstract.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/bybit.js +29 -15
- package/dist/esm/addressAggregator/adapters/bybit.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/env.js +14 -9
- package/dist/esm/addressAggregator/adapters/env.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/file.js +43 -29
- package/dist/esm/addressAggregator/adapters/file.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/risklabs.js +35 -20
- package/dist/esm/addressAggregator/adapters/risklabs.js.map +1 -1
- package/dist/esm/addressAggregator/index.js +83 -52
- package/dist/esm/addressAggregator/index.js.map +1 -1
- package/dist/esm/addressAggregator/types.js +1 -1
- package/dist/esm/addressAggregator/types.js.map +1 -1
- package/dist/esm/apiClient/abstractClient.js +9 -15
- package/dist/esm/apiClient/abstractClient.js.map +1 -1
- package/dist/esm/apiClient/mockedClient.js +26 -21
- package/dist/esm/apiClient/mockedClient.js.map +1 -1
- package/dist/esm/apiClient/productionClient.js +101 -61
- package/dist/esm/apiClient/productionClient.js.map +1 -1
- package/dist/esm/arch/evm/BlockUtils.js +217 -139
- package/dist/esm/arch/evm/BlockUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.js +289 -146
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/evm/utils/wait.js +46 -34
- package/dist/esm/arch/evm/utils/wait.js.map +1 -1
- package/dist/esm/arch/svm/BlockUtils.js +166 -118
- package/dist/esm/arch/svm/BlockUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js +1150 -738
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/constants.js +1 -1
- package/dist/esm/arch/svm/constants.js.map +1 -1
- package/dist/esm/arch/svm/eventsClient.js +232 -172
- package/dist/esm/arch/svm/eventsClient.js.map +1 -1
- package/dist/esm/arch/svm/provider.js +1 -1
- package/dist/esm/arch/svm/provider.js.map +1 -1
- package/dist/esm/arch/svm/utils.js +345 -155
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/caching/Arweave/ArweaveClient.js +256 -182
- package/dist/esm/caching/Arweave/ArweaveClient.js.map +1 -1
- package/dist/esm/caching/IPFS/PinataIPFSClient.js +48 -47
- package/dist/esm/caching/IPFS/PinataIPFSClient.js.map +1 -1
- package/dist/esm/caching/Memory/MemoryCacheClient.js +19 -13
- package/dist/esm/caching/Memory/MemoryCacheClient.js.map +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +408 -333
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BaseAbstractClient.js +92 -66
- package/dist/esm/clients/BaseAbstractClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +1054 -927
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +131 -102
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +59 -57
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -7
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +94 -75
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +23 -45
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.js +740 -581
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +178 -133
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +183 -126
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +399 -372
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js +9 -9
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.js +2 -2
- package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/types.js +2 -2
- package/dist/esm/clients/SpokePoolClient/types.js.map +1 -1
- package/dist/esm/clients/mocks/MockConfigStoreClient.js +64 -53
- package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockEvents.js +49 -42
- package/dist/esm/clients/mocks/MockEvents.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.js +182 -138
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +188 -202
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +132 -127
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +69 -53
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/esm/coingecko/Coingecko.js +443 -298
- package/dist/esm/coingecko/Coingecko.js.map +1 -1
- package/dist/esm/constants.js +47 -40
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/contracts/acrossConfigStore.js +46 -24
- package/dist/esm/contracts/acrossConfigStore.js.map +1 -1
- package/dist/esm/contracts/hubPool.js +18 -34
- package/dist/esm/contracts/hubPool.js.map +1 -1
- package/dist/esm/contracts/utils.js +5 -3
- package/dist/esm/contracts/utils.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js +14 -6
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/ethereum.js +42 -22
- package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js +25 -13
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/polygon.js +108 -72
- package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/solana.js +31 -22
- package/dist/esm/gasPriceOracle/adapters/solana.js.map +1 -1
- package/dist/esm/gasPriceOracle/oracle.js +96 -70
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/gasPriceOracle/types.js +2 -2
- package/dist/esm/gasPriceOracle/types.js.map +1 -1
- package/dist/esm/gasPriceOracle/util.js +4 -4
- package/dist/esm/gasPriceOracle/util.js.map +1 -1
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.js +33 -30
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.js.map +1 -1
- package/dist/esm/lpFeeCalculator/rateModel.js +9 -7
- package/dist/esm/lpFeeCalculator/rateModel.js.map +1 -1
- package/dist/esm/merkleDistributor/MerkleDistributor.js +17 -18
- package/dist/esm/merkleDistributor/MerkleDistributor.js.map +1 -1
- package/dist/esm/pool/TransactionManager.js +100 -45
- package/dist/esm/pool/TransactionManager.js.map +1 -1
- package/dist/esm/pool/poolClient.js +740 -479
- package/dist/esm/pool/poolClient.js.map +1 -1
- package/dist/esm/pool/uma/across/constants.js +2 -2
- package/dist/esm/pool/uma/across/constants.js.map +1 -1
- package/dist/esm/pool/uma/across/transactionManager.js +100 -45
- package/dist/esm/pool/uma/across/transactionManager.js.map +1 -1
- package/dist/esm/pool/uma/clients/erc20/client.js +13 -15
- package/dist/esm/pool/uma/clients/erc20/client.js.map +1 -1
- package/dist/esm/pool/uma/oracle/utils.js +3 -2
- package/dist/esm/pool/uma/oracle/utils.js.map +1 -1
- package/dist/esm/pool/uma/utils.js +28 -9
- package/dist/esm/pool/uma/utils.js.map +1 -1
- package/dist/esm/priceClient/adapters/acrossApi.js +40 -21
- package/dist/esm/priceClient/adapters/acrossApi.js.map +1 -1
- package/dist/esm/priceClient/adapters/baseAdapter.js +72 -46
- package/dist/esm/priceClient/adapters/baseAdapter.js.map +1 -1
- package/dist/esm/priceClient/adapters/coingecko.js +61 -33
- package/dist/esm/priceClient/adapters/coingecko.js.map +1 -1
- package/dist/esm/priceClient/adapters/default.js +31 -15
- package/dist/esm/priceClient/adapters/default.js.map +1 -1
- package/dist/esm/priceClient/adapters/defiLlama.js +73 -38
- package/dist/esm/priceClient/adapters/defiLlama.js.map +1 -1
- package/dist/esm/priceClient/priceClient.js +158 -109
- package/dist/esm/priceClient/priceClient.js.map +1 -1
- package/dist/esm/providers/alchemy.js +18 -16
- package/dist/esm/providers/alchemy.js.map +1 -1
- package/dist/esm/providers/cachedProvider.js +134 -99
- package/dist/esm/providers/cachedProvider.js.map +1 -1
- package/dist/esm/providers/constants.js +3 -3
- package/dist/esm/providers/constants.js.map +1 -1
- package/dist/esm/providers/drpc.js +10 -8
- package/dist/esm/providers/drpc.js.map +1 -1
- package/dist/esm/providers/infura.js +11 -9
- package/dist/esm/providers/infura.js.map +1 -1
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js +15 -6
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js +14 -5
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/MockRetrySolanaRpcFactory.js +15 -6
- package/dist/esm/providers/mocks/MockRetrySolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.js +66 -41
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/mockEthersProvider.js +30 -27
- package/dist/esm/providers/mocks/mockEthersProvider.js.map +1 -1
- package/dist/esm/providers/quicknode.js +20 -18
- package/dist/esm/providers/quicknode.js.map +1 -1
- package/dist/esm/providers/rateLimitedProvider.js +80 -68
- package/dist/esm/providers/rateLimitedProvider.js.map +1 -1
- package/dist/esm/providers/retryProvider.js +259 -186
- package/dist/esm/providers/retryProvider.js.map +1 -1
- package/dist/esm/providers/solana/baseRpcFactories.js +19 -13
- package/dist/esm/providers/solana/baseRpcFactories.js.map +1 -1
- package/dist/esm/providers/solana/cachedRpcFactory.js +112 -75
- package/dist/esm/providers/solana/cachedRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/defaultRpcFactory.js +14 -6
- package/dist/esm/providers/solana/defaultRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/quorumFallbackRpcFactory.js +202 -149
- package/dist/esm/providers/solana/quorumFallbackRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/rateLimitedRpcFactory.js +90 -70
- package/dist/esm/providers/solana/rateLimitedRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/retryRpcFactory.js +74 -50
- package/dist/esm/providers/solana/retryRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/utils.js +1 -1
- package/dist/esm/providers/solana/utils.js.map +1 -1
- package/dist/esm/providers/speedProvider.js +51 -28
- package/dist/esm/providers/speedProvider.js.map +1 -1
- package/dist/esm/providers/types.js +2 -2
- package/dist/esm/providers/types.js.map +1 -1
- package/dist/esm/providers/utils.js +20 -17
- package/dist/esm/providers/utils.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +152 -98
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/customGasToken.js +26 -13
- package/dist/esm/relayFeeCalculator/chain-queries/customGasToken.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +19 -9
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +128 -83
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +299 -211
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/typeguards/error.js +5 -3
- package/dist/esm/typeguards/error.js.map +1 -1
- package/dist/esm/utils/AddressUtils.js +147 -115
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/ArrayUtils.js +78 -21
- package/dist/esm/utils/ArrayUtils.js.map +1 -1
- package/dist/esm/utils/BigNumberUtils.js +12 -11
- package/dist/esm/utils/BigNumberUtils.js.map +1 -1
- package/dist/esm/utils/BlockExplorerUtils.js +23 -19
- package/dist/esm/utils/BlockExplorerUtils.js.map +1 -1
- package/dist/esm/utils/BlockFinder.js +6 -2
- package/dist/esm/utils/BlockFinder.js.map +1 -1
- package/dist/esm/utils/BlockUtils.js +40 -31
- package/dist/esm/utils/BlockUtils.js.map +1 -1
- package/dist/esm/utils/BundleUtils.js +24 -21
- package/dist/esm/utils/BundleUtils.js.map +1 -1
- package/dist/esm/utils/CCTPUtils.js +123 -62
- package/dist/esm/utils/CCTPUtils.js.map +1 -1
- package/dist/esm/utils/CachingUtils.js +38 -17
- package/dist/esm/utils/CachingUtils.js.map +1 -1
- package/dist/esm/utils/ContractUtils.js +3 -3
- package/dist/esm/utils/ContractUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.js +98 -121
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/EventUtils.js +69 -52
- package/dist/esm/utils/EventUtils.js.map +1 -1
- package/dist/esm/utils/FormattingUtils.js +26 -20
- package/dist/esm/utils/FormattingUtils.js.map +1 -1
- package/dist/esm/utils/HyperLiquidUtils.js +22 -8
- package/dist/esm/utils/HyperLiquidUtils.js.map +1 -1
- package/dist/esm/utils/IPFSUtils.js +35 -16
- package/dist/esm/utils/IPFSUtils.js.map +1 -1
- package/dist/esm/utils/JSONUtils.js +4 -4
- package/dist/esm/utils/JSONUtils.js.map +1 -1
- package/dist/esm/utils/LogUtils.js +12 -8
- package/dist/esm/utils/LogUtils.js.map +1 -1
- package/dist/esm/utils/Multicall.js +110 -50
- package/dist/esm/utils/Multicall.js.map +1 -1
- package/dist/esm/utils/NetworkUtils.js +28 -12
- package/dist/esm/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/utils/NumberUtils.js +3 -1
- package/dist/esm/utils/NumberUtils.js.map +1 -1
- package/dist/esm/utils/ObjectUtils.js +41 -27
- package/dist/esm/utils/ObjectUtils.js.map +1 -1
- package/dist/esm/utils/Profiler.js +82 -77
- package/dist/esm/utils/Profiler.js.map +1 -1
- package/dist/esm/utils/ReviverUtils.js +7 -3
- package/dist/esm/utils/ReviverUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.js +78 -83
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.js +57 -33
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/esm/utils/ValidatorUtils.js +4 -4
- package/dist/esm/utils/ValidatorUtils.js.map +1 -1
- package/dist/esm/utils/abi/index.js +20 -10
- package/dist/esm/utils/abi/index.js.map +1 -1
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js +12 -8
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
- package/dist/esm/utils/common.js +52 -38
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/utils/Multicall.d.ts.map +1 -1
- package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/constants.ts +1 -0
- package/src/gasPriceOracle/oracle.ts +1 -0
- package/src/utils/Multicall.ts +1 -0
- package/src/utils/NetworkUtils.ts +8 -1
|
@@ -1,12 +1,37 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator } from "tslib";
|
|
1
2
|
import assert from "assert";
|
|
2
3
|
import { DEFAULT_SIMULATED_RELAYER_ADDRESS, DEFAULT_SIMULATED_RELAYER_ADDRESS_SVM, TOKEN_SYMBOLS_MAP, } from "../constants";
|
|
3
4
|
import { BigNumber, MAX_BIG_INT, bnZero, fixedPointAdjustment, getTokenInfo, isDefined, max, min, nativeToToken, percent, toBN, toBNWei, compareAddressesSimple, ConvertDecimals, chainIsSvm, EvmAddress, SvmAddress, toAddressType, } from "../utils";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
debug: (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export var expectedCapitalCostsKeys = ["lowerBound", "upperBound", "cutoff", "decimals"];
|
|
6
|
+
export var DEFAULT_LOGGER = {
|
|
7
|
+
debug: function () {
|
|
8
|
+
var args = [];
|
|
9
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10
|
+
args[_i] = arguments[_i];
|
|
11
|
+
}
|
|
12
|
+
return console.debug(args);
|
|
13
|
+
},
|
|
14
|
+
info: function () {
|
|
15
|
+
var args = [];
|
|
16
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
17
|
+
args[_i] = arguments[_i];
|
|
18
|
+
}
|
|
19
|
+
return console.info(args);
|
|
20
|
+
},
|
|
21
|
+
warn: function () {
|
|
22
|
+
var args = [];
|
|
23
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
24
|
+
args[_i] = arguments[_i];
|
|
25
|
+
}
|
|
26
|
+
return console.warn(args);
|
|
27
|
+
},
|
|
28
|
+
error: function () {
|
|
29
|
+
var args = [];
|
|
30
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
31
|
+
args[_i] = arguments[_i];
|
|
32
|
+
}
|
|
33
|
+
return console.error(args);
|
|
34
|
+
},
|
|
10
35
|
};
|
|
11
36
|
export function getDefaultRelayer(chainId) {
|
|
12
37
|
return isDefined(chainId) && chainIsSvm(chainId)
|
|
@@ -14,18 +39,9 @@ export function getDefaultRelayer(chainId) {
|
|
|
14
39
|
: EvmAddress.from(DEFAULT_SIMULATED_RELAYER_ADDRESS);
|
|
15
40
|
}
|
|
16
41
|
// Small amount to simulate filling with. Should be low enough to guarantee a successful fill.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
gasDiscountPercent;
|
|
21
|
-
capitalDiscountPercent;
|
|
22
|
-
feeLimitPercent;
|
|
23
|
-
nativeTokenDecimals;
|
|
24
|
-
capitalCostsConfig;
|
|
25
|
-
// For logging if set. This function should accept 2 args - severity (INFO, WARN, ERROR) and the logs data, which will
|
|
26
|
-
// be an object.
|
|
27
|
-
logger;
|
|
28
|
-
constructor(config, logger, destinationChainId) {
|
|
42
|
+
var safeOutputAmount = toBN(100);
|
|
43
|
+
var RelayFeeCalculator = /** @class */ (function () {
|
|
44
|
+
function RelayFeeCalculator(config, logger, destinationChainId) {
|
|
29
45
|
assert(config, "config must be provided");
|
|
30
46
|
if ("queries" in config) {
|
|
31
47
|
this.queries = config.queries;
|
|
@@ -42,7 +58,8 @@ export class RelayFeeCalculator {
|
|
|
42
58
|
assert(this.gasDiscountPercent >= 0 && this.gasDiscountPercent <= 100, "gasDiscountPercent must be between 0 and 100 percent");
|
|
43
59
|
assert(this.capitalDiscountPercent >= 0 && this.capitalDiscountPercent <= 100, "capitalDiscountPercent must be between 0 and 100 percent");
|
|
44
60
|
assert(this.feeLimitPercent >= 0 && this.feeLimitPercent <= 100, "feeLimitPercent must be between 0 and 100 percent");
|
|
45
|
-
this.capitalCostsConfig = Object.fromEntries(Object.entries(config.capitalCostsConfig).map((
|
|
61
|
+
this.capitalCostsConfig = Object.fromEntries(Object.entries(config.capitalCostsConfig).map(function (_a) {
|
|
62
|
+
var token = _a[0], capitalCosts = _a[1];
|
|
46
63
|
return [token.toUpperCase(), RelayFeeCalculator.validateAndTransformCapitalCostsConfigOverride(capitalCosts)];
|
|
47
64
|
}));
|
|
48
65
|
assert(Object.keys(this.capitalCostsConfig).length > 0, "capitalCostsConfig must have at least one entry");
|
|
@@ -60,25 +77,26 @@ export class RelayFeeCalculator {
|
|
|
60
77
|
* CapitalCostConfig, then we need to convert it to a CapitalCostConfigOverride with the default config set with no route
|
|
61
78
|
* overrides.
|
|
62
79
|
*/
|
|
63
|
-
|
|
80
|
+
RelayFeeCalculator.capitalCostConfigIsOverride = function (config) {
|
|
64
81
|
return config.default !== undefined;
|
|
65
|
-
}
|
|
82
|
+
};
|
|
66
83
|
/**
|
|
67
84
|
* Validates a CapitalCostConfigOverride or a CapitalCostConfig.
|
|
68
85
|
* @param capitalCosts CapitalCostConfig or CapitalCostConfigOverride
|
|
69
86
|
* @returns CapitalCostConfigOverride
|
|
70
87
|
*/
|
|
71
|
-
|
|
88
|
+
RelayFeeCalculator.validateAndTransformCapitalCostsConfigOverride = function (capitalCosts) {
|
|
72
89
|
// We need to first convert the config to a baseline type. This is because the config can be either a CapitalCostConfig
|
|
73
90
|
// or a CapitalCostConfigOverride. If it's a CapitalCostConfig, then we need to convert it to a CapitalCostConfigOverride with
|
|
74
91
|
// the default config set with no route overrides.
|
|
75
|
-
|
|
92
|
+
var config = this.capitalCostConfigIsOverride(capitalCosts)
|
|
76
93
|
? capitalCosts
|
|
77
94
|
: { default: capitalCosts };
|
|
78
95
|
// Validate the default config.
|
|
79
96
|
this.validateCapitalCostsConfig(config.default);
|
|
80
97
|
// Iterate over all the route overrides and validate them.
|
|
81
|
-
for (
|
|
98
|
+
for (var _i = 0, _a = Object.values(config.routeOverrides || {}); _i < _a.length; _i++) {
|
|
99
|
+
var toChainIdRoutes = _a[_i];
|
|
82
100
|
Object.values(toChainIdRoutes).forEach(this.validateCapitalCostsConfig);
|
|
83
101
|
}
|
|
84
102
|
// Validate origin chain overrides
|
|
@@ -86,18 +104,18 @@ export class RelayFeeCalculator {
|
|
|
86
104
|
// Validate destination chain overrides
|
|
87
105
|
Object.values(config.destinationChainOverrides || {}).forEach(this.validateCapitalCostsConfig);
|
|
88
106
|
return config;
|
|
89
|
-
}
|
|
107
|
+
};
|
|
90
108
|
/**
|
|
91
109
|
* Validates a CapitalCostConfig.
|
|
92
110
|
* @param capitalCosts CapitalCostConfig
|
|
93
111
|
*/
|
|
94
|
-
|
|
112
|
+
RelayFeeCalculator.validateCapitalCostsConfig = function (capitalCosts) {
|
|
95
113
|
assert(toBN(capitalCosts.upperBound).lt(toBNWei("1")), "upper bound must be < 100%");
|
|
96
114
|
assert(capitalCosts.decimals > 0 && capitalCosts.decimals <= 18, "invalid decimals");
|
|
97
|
-
}
|
|
98
|
-
getTokenPrice(tokenSymbol) {
|
|
115
|
+
};
|
|
116
|
+
RelayFeeCalculator.prototype.getTokenPrice = function (tokenSymbol) {
|
|
99
117
|
return this.queries.getTokenPrice(tokenSymbol);
|
|
100
|
-
}
|
|
118
|
+
};
|
|
101
119
|
/**
|
|
102
120
|
* Calculate the gas fee as a % of the amount to relay.
|
|
103
121
|
* @param deposit A valid deposit object to reason about
|
|
@@ -117,73 +135,98 @@ export class RelayFeeCalculator {
|
|
|
117
135
|
* a message & recipient contract is provided as this function may not simulate with
|
|
118
136
|
* the correct parameters to see a full fill.
|
|
119
137
|
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
RelayFeeCalculator.prototype.gasFeePercent = function (deposit_1, outputAmount_1, outputTokenInfo_1) {
|
|
139
|
+
return __awaiter(this, arguments, void 0, function (deposit, outputAmount, outputTokenInfo, simulateZeroFill, relayerAddress, _tokenPrice, gasPrice, gasLimit, _tokenGasCost, transport) {
|
|
140
|
+
var simulatedAmount, getGasCosts, _a, tokenGasCost, tokenPrice, gasFeesInToken;
|
|
141
|
+
var _this = this;
|
|
142
|
+
if (simulateZeroFill === void 0) { simulateZeroFill = false; }
|
|
143
|
+
if (relayerAddress === void 0) { relayerAddress = getDefaultRelayer(deposit.destinationChainId); }
|
|
144
|
+
return __generator(this, function (_b) {
|
|
145
|
+
switch (_b.label) {
|
|
146
|
+
case 0:
|
|
147
|
+
if (toBN(outputAmount).eq(bnZero))
|
|
148
|
+
return [2 /*return*/, MAX_BIG_INT];
|
|
149
|
+
simulatedAmount = simulateZeroFill ? safeOutputAmount : toBN(outputAmount);
|
|
150
|
+
deposit = __assign(__assign({}, deposit), { outputAmount: simulatedAmount });
|
|
151
|
+
getGasCosts = this.queries
|
|
152
|
+
.getGasCosts(deposit, relayerAddress, { gasPrice: gasPrice, gasUnits: gasLimit, transport: transport })
|
|
153
|
+
.then(function (_a) {
|
|
154
|
+
var tokenGasCost = _a.tokenGasCost;
|
|
155
|
+
return tokenGasCost;
|
|
156
|
+
})
|
|
157
|
+
.catch(function (error) {
|
|
158
|
+
_this.logger.error({
|
|
159
|
+
at: "sdk/gasFeePercent",
|
|
160
|
+
message: "Error while fetching gas costs",
|
|
161
|
+
error: error,
|
|
162
|
+
simulateZeroFill: simulateZeroFill,
|
|
163
|
+
deposit: deposit,
|
|
164
|
+
});
|
|
165
|
+
throw error;
|
|
166
|
+
});
|
|
167
|
+
return [4 /*yield*/, Promise.all([
|
|
168
|
+
_tokenGasCost ? Promise.resolve(_tokenGasCost) : getGasCosts,
|
|
169
|
+
this.resolveTokenPrice(outputTokenInfo, _tokenPrice, deposit),
|
|
170
|
+
])];
|
|
171
|
+
case 1:
|
|
172
|
+
_a = _b.sent(), tokenGasCost = _a[0], tokenPrice = _a[1];
|
|
173
|
+
gasFeesInToken = nativeToToken(tokenGasCost, tokenPrice, outputTokenInfo.decimals, this.nativeTokenDecimals);
|
|
174
|
+
return [2 /*return*/, percent(gasFeesInToken, outputAmount.toString())];
|
|
175
|
+
}
|
|
137
176
|
});
|
|
138
|
-
throw error;
|
|
139
177
|
});
|
|
140
|
-
|
|
141
|
-
_tokenGasCost ? Promise.resolve(_tokenGasCost) : getGasCosts,
|
|
142
|
-
this.resolveTokenPrice(outputTokenInfo, _tokenPrice, deposit),
|
|
143
|
-
]);
|
|
144
|
-
const gasFeesInToken = nativeToToken(tokenGasCost, tokenPrice, outputTokenInfo.decimals, this.nativeTokenDecimals);
|
|
145
|
-
return percent(gasFeesInToken, outputAmount.toString());
|
|
146
|
-
}
|
|
178
|
+
};
|
|
147
179
|
/**
|
|
148
180
|
* Calculate the auxiliary native token fee as a % of the amount to relay.
|
|
149
181
|
* Treats auxiliary native outlay as value forwarded to user, reported separately.
|
|
150
182
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
183
|
+
RelayFeeCalculator.prototype.auxNativeFeePercent = function (deposit, outputAmount, outputTokenInfo, _tokenPrice) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
185
|
+
var auxNativeCost, tokenPrice, auxFeesInToken;
|
|
186
|
+
return __generator(this, function (_a) {
|
|
187
|
+
switch (_a.label) {
|
|
188
|
+
case 0:
|
|
189
|
+
if (toBN(outputAmount).eq(bnZero))
|
|
190
|
+
return [2 /*return*/, MAX_BIG_INT];
|
|
191
|
+
auxNativeCost = bnZero;
|
|
192
|
+
try {
|
|
193
|
+
auxNativeCost = this.queries.getAuxiliaryNativeTokenCost(deposit);
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
this.logger.error({
|
|
197
|
+
at: "sdk/auxNativeFeePercent",
|
|
198
|
+
message: "Error while fetching auxiliary native token cost",
|
|
199
|
+
error: error,
|
|
200
|
+
destinationChainId: deposit.destinationChainId,
|
|
201
|
+
inputToken: deposit.inputToken,
|
|
202
|
+
});
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
return [4 /*yield*/, this.resolveTokenPrice(outputTokenInfo, _tokenPrice, deposit)];
|
|
206
|
+
case 1:
|
|
207
|
+
tokenPrice = _a.sent();
|
|
208
|
+
auxFeesInToken = nativeToToken(auxNativeCost, tokenPrice, outputTokenInfo.decimals, this.nativeTokenDecimals);
|
|
209
|
+
return [2 /*return*/, percent(auxFeesInToken, outputAmount)];
|
|
210
|
+
}
|
|
165
211
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const tokenPrice = await this.resolveTokenPrice(outputTokenInfo, _tokenPrice, deposit);
|
|
169
|
-
const auxFeesInToken = nativeToToken(auxNativeCost, tokenPrice, outputTokenInfo.decimals, this.nativeTokenDecimals);
|
|
170
|
-
return percent(auxFeesInToken, outputAmount);
|
|
171
|
-
}
|
|
212
|
+
});
|
|
213
|
+
};
|
|
172
214
|
// Note: these variables are unused now, but may be needed in future versions of this function that are more complex.
|
|
173
|
-
capitalFeePercent(_outputAmount, _tokenSymbol, _originRoute, _destinationRoute) {
|
|
215
|
+
RelayFeeCalculator.prototype.capitalFeePercent = function (_outputAmount, _tokenSymbol, _originRoute, _destinationRoute) {
|
|
216
|
+
var _a, _b, _c, _d, _e, _f;
|
|
174
217
|
// If amount is 0, then the capital fee % should be the max 100%
|
|
175
218
|
if (toBN(_outputAmount).eq(toBN(0)))
|
|
176
219
|
return MAX_BIG_INT;
|
|
177
220
|
// V0: Ensure that there is a capital fee available for the token.
|
|
178
221
|
// If not, then we should throw an error because this is indicative
|
|
179
222
|
// of a misconfiguration.
|
|
180
|
-
|
|
223
|
+
var tokenCostConfig = this.capitalCostsConfig[_tokenSymbol.toUpperCase()];
|
|
181
224
|
if (!isDefined(tokenCostConfig)) {
|
|
182
225
|
this.logger.error({
|
|
183
226
|
at: "sdk/capitalFeePercent",
|
|
184
|
-
message:
|
|
227
|
+
message: "No capital fee available for token ".concat(_tokenSymbol),
|
|
185
228
|
});
|
|
186
|
-
throw new Error(
|
|
229
|
+
throw new Error("No capital cost config available for token ".concat(_tokenSymbol));
|
|
187
230
|
}
|
|
188
231
|
// V1: Charge fee that scales with size. This will charge a fee % based on a linear fee curve with a "kink" at a
|
|
189
232
|
// cutoff in the same units as _amountToRelay. Before the kink, the fee % will increase linearly from a lower
|
|
@@ -195,77 +238,85 @@ export class RelayFeeCalculator {
|
|
|
195
238
|
// 2. Destination chain overrides
|
|
196
239
|
// 3. Origin chain overrides
|
|
197
240
|
// 4. Default config
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
241
|
+
var routeOverride = (_b = (_a = tokenCostConfig === null || tokenCostConfig === void 0 ? void 0 : tokenCostConfig.routeOverrides) === null || _a === void 0 ? void 0 : _a[_originRoute || ""]) === null || _b === void 0 ? void 0 : _b[_destinationRoute || ""];
|
|
242
|
+
var destinationChainOverride = (_c = tokenCostConfig === null || tokenCostConfig === void 0 ? void 0 : tokenCostConfig.destinationChainOverrides) === null || _c === void 0 ? void 0 : _c[_destinationRoute || ""];
|
|
243
|
+
var originChainOverride = (_d = tokenCostConfig === null || tokenCostConfig === void 0 ? void 0 : tokenCostConfig.originChainOverrides) === null || _d === void 0 ? void 0 : _d[_originRoute || ""];
|
|
244
|
+
var config = (_f = (_e = routeOverride !== null && routeOverride !== void 0 ? routeOverride : destinationChainOverride) !== null && _e !== void 0 ? _e : originChainOverride) !== null && _f !== void 0 ? _f : tokenCostConfig.default;
|
|
202
245
|
// Check and log warnings for configuration conflicts
|
|
203
246
|
this.warnIfConfigConflicts(_tokenSymbol, _originRoute || "", _destinationRoute || "", routeOverride, destinationChainOverride, originChainOverride);
|
|
204
247
|
// Scale amount "y" to 18 decimals.
|
|
205
|
-
|
|
248
|
+
var y = toBN(_outputAmount).mul(toBNWei("1", 18 - config.decimals));
|
|
206
249
|
// At a minimum, the fee will be equal to lower bound fee * y
|
|
207
|
-
|
|
250
|
+
var minCharge = toBN(config.lowerBound).mul(y).div(fixedPointAdjustment);
|
|
208
251
|
// Charge an increasing marginal fee % up to min(cutoff, y). If y is very close to the cutoff, the fee %
|
|
209
252
|
// will be equal to half the sum of (upper bound + lower bound).
|
|
210
|
-
|
|
253
|
+
var yTriangle = min(config.cutoff, y);
|
|
211
254
|
// triangleSlope is slope of fee curve from lower bound to upper bound. If cutoff is 0, slope is 0.
|
|
212
255
|
// triangleCharge is interval of curve from 0 to y for curve = triangleSlope * y
|
|
213
|
-
|
|
256
|
+
var triangleSlope = toBN(config.cutoff).eq(toBN(0))
|
|
214
257
|
? toBN(0)
|
|
215
258
|
: toBN(config.upperBound).sub(config.lowerBound).mul(fixedPointAdjustment).div(config.cutoff);
|
|
216
|
-
|
|
217
|
-
|
|
259
|
+
var triangleHeight = triangleSlope.mul(yTriangle).div(fixedPointAdjustment);
|
|
260
|
+
var triangleCharge = triangleHeight.mul(yTriangle).div(toBNWei(2));
|
|
218
261
|
// For any amounts above the cutoff, the marginal fee % will not increase but will be fixed at the upper bound
|
|
219
262
|
// value.
|
|
220
|
-
|
|
221
|
-
|
|
263
|
+
var yRemainder = max(toBN(0), y.sub(config.cutoff));
|
|
264
|
+
var remainderCharge = yRemainder.mul(toBN(config.upperBound).sub(config.lowerBound)).div(fixedPointAdjustment);
|
|
222
265
|
return minCharge.add(triangleCharge).add(remainderCharge).mul(fixedPointAdjustment).div(y);
|
|
223
266
|
}
|
|
224
|
-
}
|
|
267
|
+
};
|
|
225
268
|
/**
|
|
226
269
|
* Checks for configuration conflicts across all token symbols and their associated chain configurations.
|
|
227
270
|
* This method examines the capital costs configuration for each token and identifies any overlapping
|
|
228
271
|
* or conflicting configurations between route overrides, destination chain overrides, and origin chain overrides.
|
|
229
272
|
* If conflicts are found, warnings will be logged via the warnIfConfigConflicts method.
|
|
230
273
|
*/
|
|
231
|
-
checkAllConfigConflicts() {
|
|
232
|
-
|
|
274
|
+
RelayFeeCalculator.prototype.checkAllConfigConflicts = function () {
|
|
275
|
+
var _a, _b, _c, _d;
|
|
276
|
+
var _loop_1 = function (tokenSymbol, tokenConfig) {
|
|
233
277
|
// Get all origin chains that have specific configurations
|
|
234
|
-
|
|
278
|
+
var originChains = new Set(Object.keys(tokenConfig.originChainOverrides || {}));
|
|
235
279
|
// Get all destination chains that have specific configurations
|
|
236
|
-
|
|
280
|
+
var destChains = new Set(Object.keys(tokenConfig.destinationChainOverrides || {}));
|
|
237
281
|
// Add all chains from route overrides
|
|
238
282
|
if (tokenConfig.routeOverrides) {
|
|
239
|
-
Object.keys(tokenConfig.routeOverrides).forEach((originChain)
|
|
283
|
+
Object.keys(tokenConfig.routeOverrides).forEach(function (originChain) {
|
|
240
284
|
originChains.add(originChain);
|
|
241
|
-
Object.keys(tokenConfig.routeOverrides[originChain]).forEach((destChain)
|
|
285
|
+
Object.keys(tokenConfig.routeOverrides[originChain]).forEach(function (destChain) {
|
|
242
286
|
destChains.add(destChain);
|
|
243
287
|
});
|
|
244
288
|
});
|
|
245
289
|
}
|
|
246
290
|
// If there are no specific chain configurations, just check the default case
|
|
247
291
|
if (originChains.size === 0 && destChains.size === 0) {
|
|
248
|
-
continue;
|
|
292
|
+
return "continue";
|
|
249
293
|
}
|
|
250
294
|
// Check for conflicts between all combinations of origin and destination chains
|
|
251
|
-
for (
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
295
|
+
for (var _g = 0, _h = Array.from(originChains); _g < _h.length; _g++) {
|
|
296
|
+
var originChain = _h[_g];
|
|
297
|
+
for (var _j = 0, _k = Array.from(destChains); _j < _k.length; _j++) {
|
|
298
|
+
var destChain = _k[_j];
|
|
299
|
+
var routeOverride = (_b = (_a = tokenConfig.routeOverrides) === null || _a === void 0 ? void 0 : _a[originChain]) === null || _b === void 0 ? void 0 : _b[destChain];
|
|
300
|
+
var destinationChainOverride = (_c = tokenConfig.destinationChainOverrides) === null || _c === void 0 ? void 0 : _c[destChain];
|
|
301
|
+
var originChainOverride = (_d = tokenConfig.originChainOverrides) === null || _d === void 0 ? void 0 : _d[originChain];
|
|
302
|
+
this_1.warnIfConfigConflicts(tokenSymbol, originChain, destChain, routeOverride, destinationChainOverride, originChainOverride);
|
|
257
303
|
}
|
|
258
304
|
}
|
|
305
|
+
};
|
|
306
|
+
var this_1 = this;
|
|
307
|
+
for (var _i = 0, _e = Object.entries(this.capitalCostsConfig); _i < _e.length; _i++) {
|
|
308
|
+
var _f = _e[_i], tokenSymbol = _f[0], tokenConfig = _f[1];
|
|
309
|
+
_loop_1(tokenSymbol, tokenConfig);
|
|
259
310
|
}
|
|
260
|
-
}
|
|
311
|
+
};
|
|
261
312
|
/**
|
|
262
313
|
* Log a warning if multiple configuration types apply to the same route
|
|
263
314
|
* @private
|
|
264
315
|
*/
|
|
265
|
-
warnIfConfigConflicts(tokenSymbol, originChain, destChain, routeOverride, destinationChainOverride, originChainOverride) {
|
|
266
|
-
|
|
316
|
+
RelayFeeCalculator.prototype.warnIfConfigConflicts = function (tokenSymbol, originChain, destChain, routeOverride, destinationChainOverride, originChainOverride) {
|
|
317
|
+
var overrideCount = [routeOverride, destinationChainOverride, originChainOverride].filter(Boolean).length;
|
|
267
318
|
if (overrideCount > 1) {
|
|
268
|
-
|
|
319
|
+
var configUsed = routeOverride
|
|
269
320
|
? "route override"
|
|
270
321
|
: destinationChainOverride
|
|
271
322
|
? "destination chain override"
|
|
@@ -274,14 +325,14 @@ export class RelayFeeCalculator {
|
|
|
274
325
|
: "default override";
|
|
275
326
|
this.logger.warn({
|
|
276
327
|
at: "RelayFeeCalculator",
|
|
277
|
-
message:
|
|
278
|
-
configUsed,
|
|
279
|
-
routeOverride,
|
|
280
|
-
destinationChainOverride,
|
|
281
|
-
originChainOverride,
|
|
328
|
+
message: "Multiple configurations found for token ".concat(tokenSymbol, " from chain ").concat(originChain, " to chain ").concat(destChain),
|
|
329
|
+
configUsed: configUsed,
|
|
330
|
+
routeOverride: routeOverride,
|
|
331
|
+
destinationChainOverride: destinationChainOverride,
|
|
332
|
+
originChainOverride: originChainOverride,
|
|
282
333
|
});
|
|
283
334
|
}
|
|
284
|
-
}
|
|
335
|
+
};
|
|
285
336
|
/**
|
|
286
337
|
* Retrieves the relayer fee details for a deposit.
|
|
287
338
|
* @param deposit A valid deposit object to reason about
|
|
@@ -297,110 +348,147 @@ export class RelayFeeCalculator {
|
|
|
297
348
|
* @param gasUnits Optional gas units to use for the simulation
|
|
298
349
|
* @returns A resulting `RelayerFeeDetails` object
|
|
299
350
|
*/
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
351
|
+
RelayFeeCalculator.prototype.relayerFeeDetails = function (deposit_1, outputAmount_1) {
|
|
352
|
+
return __awaiter(this, arguments, void 0, function (deposit, outputAmount, simulateZeroFill, relayerAddress, _tokenPrice, gasPrice, gasUnits, tokenGasCost) {
|
|
353
|
+
var _a, inputTokenInfo, outputTokenInfo, tokenPrice, _b, _tokenGasCost, _nativeGasCost, _c, gasFeePercent, outToInDecimals, gasFeeTotal, capitalFeePercent, capitalFeeTotal, auxNativeFeePercent, auxNativeFeeTotal, auxNativeDiscountPercent, relayFeePercent, relayFeeTotal, maxGasFeePercent, minDeposit, isAmountTooLow;
|
|
354
|
+
var _this = this;
|
|
355
|
+
if (simulateZeroFill === void 0) { simulateZeroFill = false; }
|
|
356
|
+
if (relayerAddress === void 0) { relayerAddress = getDefaultRelayer(deposit.destinationChainId); }
|
|
357
|
+
return __generator(this, function (_d) {
|
|
358
|
+
switch (_d.label) {
|
|
359
|
+
case 0:
|
|
360
|
+
// If the amount to relay is not provided, then we
|
|
361
|
+
// should use the full deposit amount.
|
|
362
|
+
outputAmount !== null && outputAmount !== void 0 ? outputAmount : (outputAmount = deposit.outputAmount);
|
|
363
|
+
_a = this.resolveInOutTokenInfos(deposit), inputTokenInfo = _a.inputTokenInfo, outputTokenInfo = _a.outputTokenInfo;
|
|
364
|
+
return [4 /*yield*/, this.resolveTokenPrice(outputTokenInfo, _tokenPrice, deposit)];
|
|
365
|
+
case 1:
|
|
366
|
+
tokenPrice = _d.sent();
|
|
367
|
+
if (!(tokenGasCost && gasUnits)) return [3 /*break*/, 2];
|
|
368
|
+
_c = { tokenGasCost: tokenGasCost, nativeGasCost: BigNumber.from(gasUnits) };
|
|
369
|
+
return [3 /*break*/, 4];
|
|
370
|
+
case 2: return [4 /*yield*/, this.queries
|
|
371
|
+
.getGasCosts(deposit, relayerAddress, { gasPrice: gasPrice, gasUnits: gasUnits })
|
|
372
|
+
.then(function (_a) {
|
|
373
|
+
var tokenGasCost = _a.tokenGasCost, nativeGasCost = _a.nativeGasCost;
|
|
374
|
+
return ({ tokenGasCost: tokenGasCost, nativeGasCost: nativeGasCost });
|
|
375
|
+
})
|
|
376
|
+
.catch(function (error) {
|
|
377
|
+
_this.logger.error({
|
|
378
|
+
at: "sdk/relayerFeeDetails",
|
|
379
|
+
message: "Error while fetching gas costs",
|
|
380
|
+
error: error,
|
|
381
|
+
simulateZeroFill: simulateZeroFill,
|
|
382
|
+
deposit: deposit,
|
|
383
|
+
});
|
|
384
|
+
throw error;
|
|
385
|
+
})];
|
|
386
|
+
case 3:
|
|
387
|
+
_c = _d.sent();
|
|
388
|
+
_d.label = 4;
|
|
389
|
+
case 4:
|
|
390
|
+
_b = _c, _tokenGasCost = _b.tokenGasCost, _nativeGasCost = _b.nativeGasCost;
|
|
391
|
+
return [4 /*yield*/, this.gasFeePercent(deposit, outputAmount, outputTokenInfo, simulateZeroFill, relayerAddress, tokenPrice, gasPrice, _nativeGasCost, _tokenGasCost)];
|
|
392
|
+
case 5:
|
|
393
|
+
gasFeePercent = _d.sent();
|
|
394
|
+
outToInDecimals = ConvertDecimals(outputTokenInfo.decimals, inputTokenInfo.decimals);
|
|
395
|
+
gasFeeTotal = gasFeePercent.mul(outToInDecimals(outputAmount.toString())).div(fixedPointAdjustment);
|
|
396
|
+
capitalFeePercent = this.capitalFeePercent(outputAmount, inputTokenInfo.symbol, deposit.originChainId.toString(), deposit.destinationChainId.toString());
|
|
397
|
+
capitalFeeTotal = capitalFeePercent.mul(outToInDecimals(outputAmount.toString())).div(fixedPointAdjustment);
|
|
398
|
+
return [4 /*yield*/, this.auxNativeFeePercent(deposit, outputAmount, outputTokenInfo, tokenPrice)];
|
|
399
|
+
case 6:
|
|
400
|
+
auxNativeFeePercent = _d.sent();
|
|
401
|
+
auxNativeFeeTotal = auxNativeFeePercent
|
|
402
|
+
.mul(outToInDecimals(outputAmount.toString()))
|
|
403
|
+
.div(fixedPointAdjustment);
|
|
404
|
+
auxNativeDiscountPercent = this.gasDiscountPercent;
|
|
405
|
+
relayFeePercent = gasFeePercent.add(capitalFeePercent).add(auxNativeFeePercent);
|
|
406
|
+
relayFeeTotal = gasFeeTotal.add(capitalFeeTotal).add(auxNativeFeeTotal);
|
|
407
|
+
maxGasFeePercent = max(toBNWei(this.feeLimitPercent / 100)
|
|
408
|
+
.sub(capitalFeePercent)
|
|
409
|
+
.sub(auxNativeFeePercent), toBN(0));
|
|
410
|
+
if (maxGasFeePercent.eq(toBN(0))) {
|
|
411
|
+
minDeposit = MAX_BIG_INT;
|
|
412
|
+
isAmountTooLow = true;
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
minDeposit = gasFeeTotal.mul(fixedPointAdjustment).div(maxGasFeePercent);
|
|
416
|
+
isAmountTooLow = toBN(outputAmount).lt(minDeposit);
|
|
417
|
+
}
|
|
418
|
+
return [2 /*return*/, {
|
|
419
|
+
amountToRelay: outputAmount.toString(),
|
|
420
|
+
tokenSymbol: inputTokenInfo.symbol,
|
|
421
|
+
gasFeePercent: gasFeePercent.toString(),
|
|
422
|
+
gasFeeTotal: gasFeeTotal.toString(),
|
|
423
|
+
gasUnits: _nativeGasCost.toString(),
|
|
424
|
+
gasDiscountPercent: this.gasDiscountPercent,
|
|
425
|
+
auxNativeFeePercent: auxNativeFeePercent.toString(),
|
|
426
|
+
auxNativeFeeTotal: auxNativeFeeTotal.toString(),
|
|
427
|
+
auxNativeDiscountPercent: auxNativeDiscountPercent,
|
|
428
|
+
capitalFeePercent: capitalFeePercent.toString(),
|
|
429
|
+
capitalFeeTotal: capitalFeeTotal.toString(),
|
|
430
|
+
capitalDiscountPercent: this.capitalDiscountPercent,
|
|
431
|
+
relayFeePercent: relayFeePercent.toString(),
|
|
432
|
+
relayFeeTotal: relayFeeTotal.toString(),
|
|
433
|
+
feeLimitPercent: this.feeLimitPercent,
|
|
434
|
+
maxGasFeePercent: maxGasFeePercent.toString(),
|
|
435
|
+
minDeposit: minDeposit.toString(),
|
|
436
|
+
isAmountTooLow: isAmountTooLow,
|
|
437
|
+
}];
|
|
438
|
+
}
|
|
320
439
|
});
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
const auxNativeFeePercent = await this.auxNativeFeePercent(deposit, outputAmount, outputTokenInfo, tokenPrice);
|
|
327
|
-
const auxNativeFeeTotal = auxNativeFeePercent
|
|
328
|
-
.mul(outToInDecimals(outputAmount.toString()))
|
|
329
|
-
.div(fixedPointAdjustment);
|
|
330
|
-
const auxNativeDiscountPercent = this.gasDiscountPercent;
|
|
331
|
-
const relayFeePercent = gasFeePercent.add(capitalFeePercent).add(auxNativeFeePercent);
|
|
332
|
-
const relayFeeTotal = gasFeeTotal.add(capitalFeeTotal).add(auxNativeFeeTotal);
|
|
333
|
-
// We don't want the relayer to incur an excessive gas fee charge as a % of the deposited total. The maximum
|
|
334
|
-
// gas fee % charged is equal to the remaining fee % leftover after subtracting the capital fee % and aux fee %
|
|
335
|
-
// from the fee limit %. We then compute the minimum deposited amount required to not exceed the maximum
|
|
336
|
-
// gas fee %: maxGasFeePercent = gasFeeTotal / minDeposit. Refactor this to figure out the minDeposit:
|
|
337
|
-
// minDeposit = gasFeeTotal / maxGasFeePercent, and subsequently determine
|
|
338
|
-
// isAmountTooLow = amountToRelay < minDeposit.
|
|
339
|
-
const maxGasFeePercent = max(toBNWei(this.feeLimitPercent / 100)
|
|
340
|
-
.sub(capitalFeePercent)
|
|
341
|
-
.sub(auxNativeFeePercent), toBN(0));
|
|
342
|
-
// If maxGasFee % is 0, then the min deposit should be infinite because there is no deposit amount that would
|
|
343
|
-
// incur a non zero gas fee % charge. In this case, isAmountTooLow should always be true.
|
|
344
|
-
let minDeposit, isAmountTooLow;
|
|
345
|
-
if (maxGasFeePercent.eq(toBN(0))) {
|
|
346
|
-
minDeposit = MAX_BIG_INT;
|
|
347
|
-
isAmountTooLow = true;
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
minDeposit = gasFeeTotal.mul(fixedPointAdjustment).div(maxGasFeePercent);
|
|
351
|
-
isAmountTooLow = toBN(outputAmount).lt(minDeposit);
|
|
352
|
-
}
|
|
353
|
-
return {
|
|
354
|
-
amountToRelay: outputAmount.toString(),
|
|
355
|
-
tokenSymbol: inputTokenInfo.symbol,
|
|
356
|
-
gasFeePercent: gasFeePercent.toString(),
|
|
357
|
-
gasFeeTotal: gasFeeTotal.toString(),
|
|
358
|
-
gasUnits: _nativeGasCost.toString(),
|
|
359
|
-
gasDiscountPercent: this.gasDiscountPercent,
|
|
360
|
-
auxNativeFeePercent: auxNativeFeePercent.toString(),
|
|
361
|
-
auxNativeFeeTotal: auxNativeFeeTotal.toString(),
|
|
362
|
-
auxNativeDiscountPercent,
|
|
363
|
-
capitalFeePercent: capitalFeePercent.toString(),
|
|
364
|
-
capitalFeeTotal: capitalFeeTotal.toString(),
|
|
365
|
-
capitalDiscountPercent: this.capitalDiscountPercent,
|
|
366
|
-
relayFeePercent: relayFeePercent.toString(),
|
|
367
|
-
relayFeeTotal: relayFeeTotal.toString(),
|
|
368
|
-
feeLimitPercent: this.feeLimitPercent,
|
|
369
|
-
maxGasFeePercent: maxGasFeePercent.toString(),
|
|
370
|
-
minDeposit: minDeposit.toString(),
|
|
371
|
-
isAmountTooLow,
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
resolveInOutTokenInfos(deposit, tokenMapping = TOKEN_SYMBOLS_MAP) {
|
|
375
|
-
const { inputToken, destinationChainId, originChainId } = deposit;
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
RelayFeeCalculator.prototype.resolveInOutTokenInfos = function (deposit, tokenMapping) {
|
|
443
|
+
if (tokenMapping === void 0) { tokenMapping = TOKEN_SYMBOLS_MAP; }
|
|
444
|
+
var inputToken = deposit.inputToken, destinationChainId = deposit.destinationChainId, originChainId = deposit.originChainId;
|
|
376
445
|
// It's fine if we resolve a destination token which is not the "canonical" L1 token (e.g. USDB for DAI or USDC.e for USDC), since `getTokenInfo` will re-map
|
|
377
446
|
// the output token to the canonical version. What matters here is that we find an entry in the token map which has defined addresses for BOTH the origin
|
|
378
447
|
// and destination chain. This prevents the call to `getTokenInfo` to mistakenly return token info for a token which has a defined address on origin and an
|
|
379
448
|
// undefined address on destination.
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
449
|
+
var destinationChainTokenDetails = Object.values(tokenMapping).find(function (details) {
|
|
450
|
+
return compareAddressesSimple(details.addresses[originChainId], inputToken.toNative()) &&
|
|
451
|
+
isDefined(details.addresses[destinationChainId]);
|
|
452
|
+
});
|
|
453
|
+
var outputToken = deposit.outputToken.isZeroAddress()
|
|
383
454
|
? toAddressType(destinationChainTokenDetails.addresses[destinationChainId], destinationChainId)
|
|
384
455
|
: deposit.outputToken;
|
|
385
|
-
|
|
386
|
-
|
|
456
|
+
var outputTokenInfo = getTokenInfo(outputToken, destinationChainId, tokenMapping);
|
|
457
|
+
var inputTokenInfo = getTokenInfo(inputToken, originChainId, tokenMapping);
|
|
387
458
|
if (!isDefined(outputTokenInfo) || !isDefined(inputTokenInfo)) {
|
|
388
|
-
throw new Error(
|
|
459
|
+
throw new Error("Could not find token information for ".concat(inputToken, " or ").concat(outputToken));
|
|
389
460
|
}
|
|
390
|
-
return { inputTokenInfo, outputTokenInfo };
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
return (
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
461
|
+
return { inputTokenInfo: inputTokenInfo, outputTokenInfo: outputTokenInfo };
|
|
462
|
+
};
|
|
463
|
+
RelayFeeCalculator.prototype.resolveTokenPrice = function (outputTokenInfo, _tokenPrice, deposit) {
|
|
464
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
465
|
+
var _a;
|
|
466
|
+
var _this = this;
|
|
467
|
+
return __generator(this, function (_b) {
|
|
468
|
+
switch (_b.label) {
|
|
469
|
+
case 0:
|
|
470
|
+
if (!(_tokenPrice !== null && _tokenPrice !== void 0)) return [3 /*break*/, 1];
|
|
471
|
+
_a = _tokenPrice;
|
|
472
|
+
return [3 /*break*/, 3];
|
|
473
|
+
case 1: return [4 /*yield*/, this.queries.getTokenPrice(outputTokenInfo.symbol).catch(function (error) {
|
|
474
|
+
_this.logger.error({
|
|
475
|
+
at: "sdk/resolveTokenPrice",
|
|
476
|
+
message: "Error while fetching token price",
|
|
477
|
+
error: error,
|
|
478
|
+
destinationChainId: deposit.destinationChainId,
|
|
479
|
+
inputToken: deposit.inputToken,
|
|
480
|
+
});
|
|
481
|
+
throw error;
|
|
482
|
+
})];
|
|
483
|
+
case 2:
|
|
484
|
+
_a = (_b.sent());
|
|
485
|
+
_b.label = 3;
|
|
486
|
+
case 3: return [2 /*return*/, (_a)];
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
return RelayFeeCalculator;
|
|
492
|
+
}());
|
|
493
|
+
export { RelayFeeCalculator };
|
|
406
494
|
//# sourceMappingURL=relayFeeCalculator.js.map
|