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