@across-protocol/sdk 4.3.110 → 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 -29
- 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 -103
- 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 -114
- package/dist/cjs/utils/Multicall.js.map +1 -1
- package/dist/cjs/utils/NetworkUtils.js +12 -21
- 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 -46
- 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 -95
- 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 -109
- package/dist/esm/utils/Multicall.js.map +1 -1
- package/dist/esm/utils/NetworkUtils.js +12 -21
- 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/package.json +2 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __assign, __awaiter, __extends, __generator, __rest, __spreadArray } from "tslib";
|
|
2
1
|
import assert from "assert";
|
|
3
2
|
import { isError } from "../../typeguards";
|
|
4
3
|
import { averageBlockTime } from "../../arch/evm";
|
|
@@ -9,7 +8,7 @@ import { BaseAbstractClient, isUpdateFailureReason, UpdateFailureReason } from "
|
|
|
9
8
|
import { parseAndReturnRateModelFromString } from "../../lpFeeCalculator/rateModel";
|
|
10
9
|
// Version 0 is the implicit ConfigStore version from before the version attribute was introduced.
|
|
11
10
|
// @dev Do not change this value.
|
|
12
|
-
export
|
|
11
|
+
export const DEFAULT_CONFIG_STORE_VERSION = 0;
|
|
13
12
|
export var GLOBAL_CONFIG_STORE_KEYS;
|
|
14
13
|
(function (GLOBAL_CONFIG_STORE_KEYS) {
|
|
15
14
|
GLOBAL_CONFIG_STORE_KEYS["MAX_RELAYER_REPAYMENT_LEAF_SIZE"] = "MAX_RELAYER_REPAYMENT_LEAF_SIZE";
|
|
@@ -20,7 +19,7 @@ export var GLOBAL_CONFIG_STORE_KEYS;
|
|
|
20
19
|
GLOBAL_CONFIG_STORE_KEYS["LITE_CHAIN_ID_INDICES"] = "LITE_CHAIN_ID_INDICES";
|
|
21
20
|
})(GLOBAL_CONFIG_STORE_KEYS || (GLOBAL_CONFIG_STORE_KEYS = {}));
|
|
22
21
|
// Conveniently store known invalid token config update hashes to avoid spamming debug logs.
|
|
23
|
-
|
|
22
|
+
const KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES = [
|
|
24
23
|
"0x422abc617c6598e4b91859f99c392939d2034c1a839a342a963a34a2f0390195",
|
|
25
24
|
"0x36c85e388279714b2c98d46e3377dc37a1575665b2cac5e52fe97d8d77efcd2b",
|
|
26
25
|
"0x6f0a93119e538dd84e02adfce821fb4e6dd9baddcceb041977e8ba3c39185ab8",
|
|
@@ -35,55 +34,52 @@ var KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES = [
|
|
|
35
34
|
"0x89830f5e81b9e8b44ac2f8966b2fa4bf8e71d7f546e2bc0e773d8ee8df4bdb36",
|
|
36
35
|
"0xb0ad6270124c925a234d9c4f87b60396f2b52fdc250cd2fc9cac792d0d62e467",
|
|
37
36
|
"0x779bc3bf2dba1128d5dda6be8ae99b503cae23343a7265a86bca3d5572ed4268",
|
|
38
|
-
].map(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
37
|
+
].map((hash) => hash.toLowerCase());
|
|
38
|
+
export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
39
|
+
logger;
|
|
40
|
+
configStore;
|
|
41
|
+
configStoreVersion;
|
|
42
|
+
cumulativeRateModelUpdates = [];
|
|
43
|
+
cumulativeRouteRateModelUpdates = [];
|
|
44
|
+
cumulativeMaxRefundCountUpdates = [];
|
|
45
|
+
cumulativeMaxL1TokenCountUpdates = [];
|
|
46
|
+
chainIdIndicesUpdates = [];
|
|
47
|
+
liteChainIndicesUpdates = [];
|
|
48
|
+
cumulativeSpokeTargetBalanceUpdates = [];
|
|
49
|
+
cumulativeConfigStoreVersionUpdates = [];
|
|
50
|
+
cumulativeDisabledChainUpdates = [];
|
|
51
|
+
hasLatestConfigStoreVersion = false;
|
|
52
|
+
chainId;
|
|
53
|
+
constructor(logger, configStore, eventSearchConfig = { from: 0, maxLookBack: 0 }, configStoreVersion) {
|
|
54
|
+
super(eventSearchConfig);
|
|
55
|
+
this.logger = logger;
|
|
56
|
+
this.configStore = configStore;
|
|
57
|
+
this.configStoreVersion = configStoreVersion;
|
|
58
|
+
this.firstHeightToSearch = eventSearchConfig.from;
|
|
59
|
+
this.latestHeightSearched = 0;
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
if (blockNumber === void 0) { blockNumber = undefined; }
|
|
61
|
+
getRateModelForBlockNumber(l1Token, originChainId, destinationChainId, blockNumber = undefined) {
|
|
63
62
|
// Use route-rate model if available, otherwise use default rate model for l1Token.
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const route = `${originChainId}-${destinationChainId}`;
|
|
64
|
+
const routeRateModel = this.getRouteRateModelForBlockNumber(l1Token, route, blockNumber);
|
|
66
65
|
if (routeRateModel) {
|
|
67
66
|
return routeRateModel;
|
|
68
67
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
config.rateModel !== undefined;
|
|
73
|
-
});
|
|
68
|
+
const defaultRateModelUpdate = sortEventsDescending(this.cumulativeRateModelUpdates).find((config) => config.blockNumber <= (blockNumber ?? 0) &&
|
|
69
|
+
config.l1Token === l1Token.toEvmAddress() &&
|
|
70
|
+
config.rateModel !== undefined);
|
|
74
71
|
if (!defaultRateModelUpdate) {
|
|
75
|
-
throw new Error(
|
|
72
|
+
throw new Error(`Could not find TokenConfig update for ${l1Token} at block ${blockNumber}`);
|
|
76
73
|
}
|
|
77
74
|
return parseAndReturnRateModelFromString(defaultRateModelUpdate.rateModel);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if ((config === null || config === void 0 ? void 0 : config.routeRateModel[route]) === undefined) {
|
|
75
|
+
}
|
|
76
|
+
getRouteRateModelForBlockNumber(l1Token, route, blockNumber = undefined) {
|
|
77
|
+
const config = sortEventsDescending(this.cumulativeRouteRateModelUpdates).find((config) => config.blockNumber <= (blockNumber ?? 0) && config.l1Token === l1Token.toEvmAddress());
|
|
78
|
+
if (config?.routeRateModel[route] === undefined) {
|
|
83
79
|
return undefined;
|
|
84
80
|
}
|
|
85
81
|
return parseAndReturnRateModelFromString(config.routeRateModel[route]);
|
|
86
|
-
}
|
|
82
|
+
}
|
|
87
83
|
/**
|
|
88
84
|
* Resolve the implied set of chain ID indices based on the chain ID of the ConfigStore.
|
|
89
85
|
* @param chainId Chain ID of the ConfigStore.
|
|
@@ -92,10 +88,10 @@ var AcrossConfigStoreClient = /** @class */ (function (_super) {
|
|
|
92
88
|
* @dev The protocol defaults are [1, 10, 137, 288, 42161] (outlined in UMIP-157).
|
|
93
89
|
* @dev chainId is marked optional to appease tsc. It must always be passed in.
|
|
94
90
|
*/
|
|
95
|
-
|
|
91
|
+
implicitChainIdIndices(chainId) {
|
|
96
92
|
assert(isDefined(chainId), "ConfigStoreClient used before update");
|
|
97
93
|
return PROTOCOL_DEFAULT_CHAIN_ID_INDICES[0] === chainId ? PROTOCOL_DEFAULT_CHAIN_ID_INDICES : [chainId];
|
|
98
|
-
}
|
|
94
|
+
}
|
|
99
95
|
/**
|
|
100
96
|
* Resolves the chain ids that were available to the protocol at a given block range.
|
|
101
97
|
* @param blockNumber Block number to search for. Defaults to latest block.
|
|
@@ -107,75 +103,64 @@ var AcrossConfigStoreClient = /** @class */ (function (_super) {
|
|
|
107
103
|
* this key/value entry, the function will return the default list of chain IDs as
|
|
108
104
|
* outlined per the UMIP (https://github.com/UMAprotocol/UMIPs/pull/590).
|
|
109
105
|
*/
|
|
110
|
-
|
|
111
|
-
var _a;
|
|
112
|
-
if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
|
|
106
|
+
getChainIdIndicesForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
|
|
113
107
|
// Resolve the chain ID indices for the block number requested.
|
|
114
|
-
|
|
108
|
+
const chainIdUpdates = sortEventsDescending(this.chainIdIndicesUpdates);
|
|
115
109
|
// Iterate through each of the chain ID updates and resolve the first update that is
|
|
116
110
|
// less than or equal to the block number requested.
|
|
117
|
-
|
|
111
|
+
const chainIdIndices = chainIdUpdates.find((update) => update.blockNumber <= blockNumber)?.value;
|
|
118
112
|
// Return either the found value or the protocol default.
|
|
119
|
-
return chainIdIndices
|
|
120
|
-
}
|
|
113
|
+
return chainIdIndices ?? this.implicitChainIdIndices(this.chainId);
|
|
114
|
+
}
|
|
121
115
|
/**
|
|
122
116
|
* Resolves the lite chain ids that were available to the protocol at a given block range.
|
|
123
117
|
* @param blockNumber Block number to search for. Defaults to latest block.
|
|
124
118
|
* @returns List of lite chain IDs that were available to the protocol at the given block number.
|
|
125
119
|
* @note This dynamic functionality has been added after the launch of Across.
|
|
126
120
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return (_b = (_a = liteChainIdList.find(function (update) { return update.blockNumber <= blockNumber; })) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : [];
|
|
132
|
-
};
|
|
121
|
+
getLiteChainIdIndicesForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
|
|
122
|
+
const liteChainIdList = sortEventsDescending(this.liteChainIndicesUpdates);
|
|
123
|
+
return liteChainIdList.find((update) => update.blockNumber <= blockNumber)?.value ?? [];
|
|
124
|
+
}
|
|
133
125
|
/**
|
|
134
126
|
* Resolves the lite chain ids that were available to the protocol at a given timestamp.
|
|
135
127
|
* @param timestamp Timestamp to search for. Defaults to latest time - in seconds.
|
|
136
128
|
* @returns List of lite chain IDs that were available to the protocol at the given timestamp.
|
|
137
129
|
* @note This dynamic functionality has been added after the launch of Across.
|
|
138
130
|
*/
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return (_b = (_a = liteChainIdList.find(function (update) { return update.timestamp <= timestamp; })) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : [];
|
|
144
|
-
};
|
|
131
|
+
getLiteChainIdIndicesForTimestamp(timestamp = Number.MAX_SAFE_INTEGER) {
|
|
132
|
+
const liteChainIdList = sortEventsDescending(this.liteChainIndicesUpdates);
|
|
133
|
+
return liteChainIdList.find((update) => update.timestamp <= timestamp)?.value ?? [];
|
|
134
|
+
}
|
|
145
135
|
/**
|
|
146
136
|
* Checks if a chain ID was a lite chain at a given timestamp.
|
|
147
137
|
* @param chainId The chain ID to check.
|
|
148
138
|
* @param timestamp The timestamp to check. Defaults to latest time - in seconds.
|
|
149
139
|
* @returns True if the chain ID was a lite chain at the given timestamp. False otherwise.
|
|
150
140
|
*/
|
|
151
|
-
|
|
152
|
-
if (timestamp === void 0) { timestamp = Number.MAX_SAFE_INTEGER; }
|
|
141
|
+
isChainLiteChainAtTimestamp(chainId, timestamp = Number.MAX_SAFE_INTEGER) {
|
|
153
142
|
return this.getLiteChainIdIndicesForTimestamp(timestamp).includes(chainId);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
var config = sortEventsDescending(this.cumulativeSpokeTargetBalanceUpdates).find(function (config) { return config.l1Token === l1Token && config.blockNumber <= blockNumber; });
|
|
159
|
-
var targetBalance = (_a = config === null || config === void 0 ? void 0 : config.spokeTargetBalances) === null || _a === void 0 ? void 0 : _a[chainId];
|
|
143
|
+
}
|
|
144
|
+
getSpokeTargetBalancesForBlock(l1Token, chainId, blockNumber = Number.MAX_SAFE_INTEGER) {
|
|
145
|
+
const config = sortEventsDescending(this.cumulativeSpokeTargetBalanceUpdates).find((config) => config.l1Token === l1Token && config.blockNumber <= blockNumber);
|
|
146
|
+
const targetBalance = config?.spokeTargetBalances?.[chainId];
|
|
160
147
|
return targetBalance || { target: toBN(0), threshold: toBN(0) };
|
|
161
|
-
}
|
|
148
|
+
}
|
|
162
149
|
// <-- END LEGACY CONFIGURATION OBJECTS -->
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
var config = sortEventsDescending(this.cumulativeMaxRefundCountUpdates).find(function (config) { return config.blockNumber <= blockNumber; });
|
|
150
|
+
getMaxRefundCountForRelayerRefundLeafForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
|
|
151
|
+
const config = sortEventsDescending(this.cumulativeMaxRefundCountUpdates).find((config) => config.blockNumber <= blockNumber);
|
|
166
152
|
if (!config) {
|
|
167
|
-
throw new Error(
|
|
153
|
+
throw new Error(`Could not find MaxRefundCount before block ${blockNumber}`);
|
|
168
154
|
}
|
|
169
155
|
return Number(config.value);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
var config = sortEventsDescending(this.cumulativeMaxL1TokenCountUpdates).find(function (config) { return config.blockNumber <= blockNumber; });
|
|
156
|
+
}
|
|
157
|
+
getMaxL1TokenCountForPoolRebalanceLeafForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
|
|
158
|
+
const config = sortEventsDescending(this.cumulativeMaxL1TokenCountUpdates).find((config) => config.blockNumber <= blockNumber);
|
|
174
159
|
if (!config) {
|
|
175
|
-
throw new Error(
|
|
160
|
+
throw new Error(`Could not find MaxL1TokenCount before block ${blockNumber}`);
|
|
176
161
|
}
|
|
177
162
|
return Number(config.value);
|
|
178
|
-
}
|
|
163
|
+
}
|
|
179
164
|
/**
|
|
180
165
|
* Returns list of chains that have been enabled at least once in the block range.
|
|
181
166
|
* If a chain was disabled in the block range, it will be included in the list provided it was enabled
|
|
@@ -186,26 +171,25 @@ var AcrossConfigStoreClient = /** @class */ (function (_super) {
|
|
|
186
171
|
* up until `latest`.
|
|
187
172
|
* @returns List of chain IDs that have been enabled at least once in the block range. Sorted from lowest to highest.
|
|
188
173
|
*/
|
|
189
|
-
|
|
190
|
-
if (toBlock === void 0) { toBlock = Number.MAX_SAFE_INTEGER; }
|
|
174
|
+
getEnabledChainsInBlockRange(fromBlock, toBlock = Number.MAX_SAFE_INTEGER) {
|
|
191
175
|
// If our fromBlock is greater than our toBlock, then we have an invalid range.
|
|
192
176
|
if (fromBlock > toBlock) {
|
|
193
|
-
throw new Error(
|
|
177
|
+
throw new Error(`Invalid block range: fromBlock ${fromBlock} > toBlock ${toBlock}`);
|
|
194
178
|
}
|
|
195
179
|
// Initiate list with all possible chains enabled at the toBlock while removing any chains
|
|
196
180
|
// that were disabled at the from block.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
181
|
+
const disabledChainsAtFromBlock = this.getDisabledChainsForBlock(fromBlock);
|
|
182
|
+
const allPossibleChains = this.getChainIdIndicesForBlock(toBlock);
|
|
183
|
+
const enabledChainsInBlockRange = allPossibleChains.filter((chainId) => !disabledChainsAtFromBlock.includes(chainId));
|
|
200
184
|
// If there are any disabled chain updates in the block range, then we might need to update the list of enabled
|
|
201
185
|
// chains in the block range.
|
|
202
186
|
this.cumulativeDisabledChainUpdates
|
|
203
|
-
.filter(
|
|
204
|
-
.forEach(
|
|
187
|
+
.filter((e) => e.blockNumber <= toBlock && e.blockNumber >= fromBlock)
|
|
188
|
+
.forEach((e) => {
|
|
205
189
|
// If disabled chain update no longer includes a previously disabled chain, then add it back to the enabled chains
|
|
206
190
|
// list.
|
|
207
|
-
|
|
208
|
-
disabledChainsAtFromBlock.forEach(
|
|
191
|
+
const newDisabledSet = e.chainIds;
|
|
192
|
+
disabledChainsAtFromBlock.forEach((disabledChain) => {
|
|
209
193
|
// New disabled set doesn't include this chain that was previously disabled so it was re-enabled at this point
|
|
210
194
|
// in the block range.
|
|
211
195
|
if (!newDisabledSet.includes(disabledChain)) {
|
|
@@ -214,356 +198,297 @@ var AcrossConfigStoreClient = /** @class */ (function (_super) {
|
|
|
214
198
|
});
|
|
215
199
|
});
|
|
216
200
|
// Return the enabled chains in the block range sorted in the same order as the chain indices.
|
|
217
|
-
return allPossibleChains.filter(
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (block === void 0) { block = Number.MAX_SAFE_INTEGER; }
|
|
201
|
+
return allPossibleChains.filter((chainId) => enabledChainsInBlockRange.includes(chainId));
|
|
202
|
+
}
|
|
203
|
+
getEnabledChains(block = Number.MAX_SAFE_INTEGER) {
|
|
221
204
|
// Get most recent disabled chain list before the block specified.
|
|
222
|
-
|
|
223
|
-
return this.getChainIdIndicesForBlock(block).filter(
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (timestamp === void 0) { timestamp = Number.MAX_SAFE_INTEGER; }
|
|
232
|
-
var config = this.cumulativeConfigStoreVersionUpdates.find(function (config) { return config.timestamp <= timestamp; });
|
|
205
|
+
const currentlyDisabledChains = this.getDisabledChainsForBlock(block);
|
|
206
|
+
return this.getChainIdIndicesForBlock(block).filter((chainId) => !currentlyDisabledChains.includes(chainId));
|
|
207
|
+
}
|
|
208
|
+
getDisabledChainsForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
|
|
209
|
+
return (sortEventsDescending(this.cumulativeDisabledChainUpdates).find((config) => config.blockNumber <= blockNumber)
|
|
210
|
+
?.chainIds ?? []);
|
|
211
|
+
}
|
|
212
|
+
getConfigStoreVersionForTimestamp(timestamp = Number.MAX_SAFE_INTEGER) {
|
|
213
|
+
const config = this.cumulativeConfigStoreVersionUpdates.find((config) => config.timestamp <= timestamp);
|
|
233
214
|
return isDefined(config) ? Number(config.value) : DEFAULT_CONFIG_STORE_VERSION;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
var config = this.cumulativeConfigStoreVersionUpdates.find(function (config) { return config.blockNumber <= blockNumber; });
|
|
215
|
+
}
|
|
216
|
+
getConfigStoreVersionForBlock(blockNumber = Number.MAX_SAFE_INTEGER) {
|
|
217
|
+
const config = this.cumulativeConfigStoreVersionUpdates.find((config) => config.blockNumber <= blockNumber);
|
|
238
218
|
return isDefined(config) ? Number(config.value) : DEFAULT_CONFIG_STORE_VERSION;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
var version = this.getConfigStoreVersionForTimestamp(timestamp);
|
|
219
|
+
}
|
|
220
|
+
hasValidConfigStoreVersionForTimestamp(timestamp = Number.MAX_SAFE_INTEGER) {
|
|
221
|
+
const version = this.getConfigStoreVersionForTimestamp(timestamp);
|
|
243
222
|
return this.configStoreVersion >= version;
|
|
244
|
-
}
|
|
223
|
+
}
|
|
245
224
|
/**
|
|
246
225
|
* Resolve the chain ID for the ConfigStore Provider instance.
|
|
247
226
|
* @dev When the provider is a StatisJsonRpcProvider instance, the getNetwork() is non-blocking.
|
|
248
227
|
* @returns Chain ID for the ConfigStore deployment.
|
|
249
228
|
*/
|
|
250
|
-
|
|
251
|
-
return
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
229
|
+
async resolveChainId() {
|
|
230
|
+
return this.chainId ?? (await this.configStore.provider.getNetwork()).chainId;
|
|
231
|
+
}
|
|
232
|
+
async _update() {
|
|
233
|
+
const chainId = await this.resolveChainId();
|
|
234
|
+
const searchConfig = await this.updateSearchConfig(this.configStore.provider);
|
|
235
|
+
if (isUpdateFailureReason(searchConfig)) {
|
|
236
|
+
const reason = searchConfig;
|
|
237
|
+
return { success: false, reason };
|
|
238
|
+
}
|
|
239
|
+
this.logger.debug({ at: "AcrossConfigStore", message: "Updating ConfigStore client", searchConfig });
|
|
240
|
+
const [updatedTokenConfigEvents, updatedGlobalConfigEvents] = await Promise.all([
|
|
241
|
+
paginatedEventQuery(this.configStore, this.configStore.filters.UpdatedTokenConfig(), searchConfig),
|
|
242
|
+
paginatedEventQuery(this.configStore, this.configStore.filters.UpdatedGlobalConfig(), searchConfig),
|
|
243
|
+
]);
|
|
244
|
+
const updatedTokenConfigSortableEvents = updatedTokenConfigEvents.map(spreadEventWithBlockNumber);
|
|
245
|
+
const updatedGlobalConfigSortableEvents = updatedGlobalConfigEvents.map(spreadEventWithBlockNumber);
|
|
246
|
+
// Events *should* normally be received in ascending order, but explicitly enforce the ordering.
|
|
247
|
+
[updatedTokenConfigSortableEvents, updatedGlobalConfigSortableEvents].forEach((events) => sortEventsAscendingInPlace(events));
|
|
248
|
+
const globalConfigUpdateTimes = (await Promise.all(updatedGlobalConfigEvents.map((event) => this.configStore.provider.getBlock(event.blockNumber)))).map((block) => block.timestamp);
|
|
249
|
+
return {
|
|
250
|
+
success: true,
|
|
251
|
+
chainId,
|
|
252
|
+
searchEndBlock: searchConfig.to,
|
|
253
|
+
events: {
|
|
254
|
+
updatedTokenConfigEvents: updatedTokenConfigSortableEvents,
|
|
255
|
+
updatedGlobalConfigEvents: updatedGlobalConfigSortableEvents,
|
|
256
|
+
globalConfigUpdateTimes,
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
async update() {
|
|
261
|
+
const result = await this._update();
|
|
262
|
+
if (!result.success) {
|
|
263
|
+
if (result.reason !== UpdateFailureReason.AlreadyUpdated) {
|
|
264
|
+
throw new Error(`Unable to update ConfigStoreClient: ${result.reason}`);
|
|
265
|
+
}
|
|
266
|
+
// No need to touch `this.isUpdated` because it should already be set from a previous update.
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const { chainId } = result;
|
|
270
|
+
const { updatedTokenConfigEvents, updatedGlobalConfigEvents, globalConfigUpdateTimes } = result.events;
|
|
271
|
+
assert(updatedGlobalConfigEvents.length === globalConfigUpdateTimes.length, `GlobalConfigUpdate events mismatch (${updatedGlobalConfigEvents.length} != ${globalConfigUpdateTimes.length})`);
|
|
272
|
+
// Save new TokenConfig updates.
|
|
273
|
+
for (const event of updatedTokenConfigEvents) {
|
|
274
|
+
// If transaction hash is known to be invalid, skip it immediately to avoid creating extra logs.
|
|
275
|
+
if (KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES.includes(event.txnRef.toLowerCase())) {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
const args = event;
|
|
279
|
+
try {
|
|
280
|
+
const { rateModel, routeRateModel, spokeTargetBalances } = this.validateTokenConfigUpdate(args);
|
|
281
|
+
const { value, key: l1Token, ...eventData } = args;
|
|
282
|
+
if (rateModel !== undefined) {
|
|
283
|
+
this.cumulativeRateModelUpdates.push({ ...eventData, rateModel, l1Token });
|
|
284
|
+
this.cumulativeSpokeTargetBalanceUpdates.push({
|
|
285
|
+
...eventData,
|
|
286
|
+
spokeTargetBalances,
|
|
287
|
+
l1Token,
|
|
288
|
+
});
|
|
289
|
+
this.cumulativeRouteRateModelUpdates.push({ ...eventData, routeRateModel, l1Token });
|
|
265
290
|
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
291
|
+
}
|
|
292
|
+
catch (err) {
|
|
293
|
+
const { average: blockTime } = await averageBlockTime(this.configStore.provider);
|
|
294
|
+
const maxWarnAge = (24 * 60 * 60) / blockTime;
|
|
295
|
+
if (result.searchEndBlock - event.blockNumber < maxWarnAge) {
|
|
296
|
+
const errMsg = isError(err) ? err.message : "unknown error";
|
|
297
|
+
// This will emit warning logs for any invalid historical updates and it will be very noisy, so
|
|
298
|
+
// developer should move over known invalid hashes to KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES to
|
|
299
|
+
// suppress these warnings.
|
|
300
|
+
this.logger.warn({
|
|
301
|
+
at: "ConfigStore::update",
|
|
302
|
+
message: `Caught error during ConfigStore update: ${errMsg}`,
|
|
303
|
+
update: args,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
this.logger.debug({
|
|
308
|
+
at: "ConfigStoreClient::update",
|
|
309
|
+
message: `Skipping invalid historical update at block ${event.blockNumber}`,
|
|
310
|
+
txnRef: event.txnRef,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// Save new Global config updates.
|
|
317
|
+
for (let i = 0; i < updatedGlobalConfigEvents.length; i++) {
|
|
318
|
+
const args = updatedGlobalConfigEvents[i];
|
|
319
|
+
if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.MAX_RELAYER_REPAYMENT_LEAF_SIZE)) {
|
|
320
|
+
if (!isNaN(args.value)) {
|
|
321
|
+
this.cumulativeMaxRefundCountUpdates.push(args);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.LITE_CHAIN_ID_INDICES)) {
|
|
325
|
+
// We need to parse the chain ID indices array from the stringified JSON. However,
|
|
326
|
+
// the on-chain string has quotes around the array, which will parse our JSON as a
|
|
327
|
+
// string instead of an array. We need to remove these quotes before parsing.
|
|
328
|
+
// To be sure, we can check for single quotes, double quotes, and spaces.
|
|
329
|
+
// Use a regular expression to check if the string is a valid array. We need to check for
|
|
330
|
+
// leading and trailing quotes, as well as leading and trailing whitespace. We also need to
|
|
331
|
+
// check for commas between the numbers. Alternatively, this can be an empty array.
|
|
332
|
+
if (!/^\s*["']?\[(\d+(,\d+)*)?\]["']?\s*$/.test(args.value)) {
|
|
333
|
+
this.logger.warn({ at: "ConfigStore", message: `The lite chain indices array ${args.value} is invalid.` });
|
|
334
|
+
// If not a valid array, skip.
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
const chainIndices = JSON.parse(args.value.replace(/['"\s]/g, ""));
|
|
338
|
+
// Check that the array is valid and that every element is a number.
|
|
339
|
+
if (!isArrayOf(chainIndices, isPositiveInteger)) {
|
|
340
|
+
this.logger.warn({ at: "ConfigStore", message: `The array ${chainIndices} is invalid.` });
|
|
341
|
+
// If not a valid array, skip.
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
// Let's also check that the array doesn't contain any duplicates.
|
|
345
|
+
if (new Set(chainIndices).size !== chainIndices.length) {
|
|
346
|
+
this.logger.warn({
|
|
347
|
+
at: "ConfigStore",
|
|
348
|
+
message: `The array ${chainIndices} contains duplicates making it invalid.`,
|
|
349
|
+
});
|
|
350
|
+
// If not a valid array, skip.
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
// If all else passes, we can add this update.
|
|
354
|
+
this.liteChainIndicesUpdates.push({ ...args, value: chainIndices, timestamp: globalConfigUpdateTimes[i] });
|
|
355
|
+
}
|
|
356
|
+
else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.CHAIN_ID_INDICES)) {
|
|
357
|
+
try {
|
|
358
|
+
// We need to parse the chain ID indices array from the stringified JSON. However,
|
|
359
|
+
// the on-chain string has quotes around the array, which will parse our JSON as a
|
|
360
|
+
// string instead of an array. We need to remove these quotes before parsing.
|
|
361
|
+
// To be sure, we can check for single quotes, double quotes, and spaces.
|
|
362
|
+
const chainIndices = JSON.parse(args.value.replace(/['"\s]/g, ""));
|
|
363
|
+
// Check that the array is valid and that every element is a number.
|
|
364
|
+
if (!isArrayOf(chainIndices, isPositiveInteger)) {
|
|
365
|
+
this.logger.warn({ at: "ConfigStore", message: `The array ${chainIndices} is invalid.` });
|
|
366
|
+
// If not a valid array, skip.
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
// Let's also check that the array doesn't contain any duplicates.
|
|
370
|
+
if (new Set(chainIndices).size !== chainIndices.length) {
|
|
371
|
+
this.logger.warn({
|
|
372
|
+
at: "ConfigStore",
|
|
373
|
+
message: `The array ${chainIndices} contains duplicates making it invalid.`,
|
|
297
374
|
});
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
375
|
+
// If not a valid array, skip.
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
// Now check that we're only appending positive integers to the chainIndices array on each
|
|
379
|
+
// update. If this isn't the case, skip the update & warn. If there is no previous update,
|
|
380
|
+
// resolve an implicit chain ID list.
|
|
381
|
+
const previousUpdate = this.chainIdIndicesUpdates.at(-1)?.value ?? this.implicitChainIdIndices(chainId);
|
|
382
|
+
// We should now check that previousUpdate is a subset of chainIndices.
|
|
383
|
+
if (!previousUpdate.every((chainId, idx) => chainIndices[idx] === chainId)) {
|
|
384
|
+
this.logger.warn({
|
|
385
|
+
at: "ConfigStoreClient#update",
|
|
386
|
+
message: `The array ${chainIndices} is invalid. It must be a superset of the previous array ${previousUpdate}`,
|
|
387
|
+
});
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
// If all else passes, we can add this update.
|
|
391
|
+
this.chainIdIndicesUpdates.push({ ...args, value: chainIndices });
|
|
311
392
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
};
|
|
315
|
-
AcrossConfigStoreClient.prototype.update = function () {
|
|
316
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
317
|
-
var result, chainId, _a, updatedTokenConfigEvents, updatedGlobalConfigEvents, globalConfigUpdateTimes, _i, updatedTokenConfigEvents_1, event_1, args, _b, rateModel, routeRateModel, spokeTargetBalances, value, l1Token, eventData, err_1, blockTime, maxWarnAge, errMsg, _loop_1, this_1, i;
|
|
318
|
-
var _c, _d, _e, _f, _g;
|
|
319
|
-
return __generator(this, function (_h) {
|
|
320
|
-
switch (_h.label) {
|
|
321
|
-
case 0: return [4 /*yield*/, this._update()];
|
|
322
|
-
case 1:
|
|
323
|
-
result = _h.sent();
|
|
324
|
-
if (!result.success) {
|
|
325
|
-
if (result.reason !== UpdateFailureReason.AlreadyUpdated) {
|
|
326
|
-
throw new Error("Unable to update ConfigStoreClient: ".concat(result.reason));
|
|
327
|
-
}
|
|
328
|
-
// No need to touch `this.isUpdated` because it should already be set from a previous update.
|
|
329
|
-
return [2 /*return*/];
|
|
330
|
-
}
|
|
331
|
-
chainId = result.chainId;
|
|
332
|
-
_a = result.events, updatedTokenConfigEvents = _a.updatedTokenConfigEvents, updatedGlobalConfigEvents = _a.updatedGlobalConfigEvents, globalConfigUpdateTimes = _a.globalConfigUpdateTimes;
|
|
333
|
-
assert(updatedGlobalConfigEvents.length === globalConfigUpdateTimes.length, "GlobalConfigUpdate events mismatch (".concat(updatedGlobalConfigEvents.length, " != ").concat(globalConfigUpdateTimes.length, ")"));
|
|
334
|
-
_i = 0, updatedTokenConfigEvents_1 = updatedTokenConfigEvents;
|
|
335
|
-
_h.label = 2;
|
|
336
|
-
case 2:
|
|
337
|
-
if (!(_i < updatedTokenConfigEvents_1.length)) return [3 /*break*/, 7];
|
|
338
|
-
event_1 = updatedTokenConfigEvents_1[_i];
|
|
339
|
-
// If transaction hash is known to be invalid, skip it immediately to avoid creating extra logs.
|
|
340
|
-
if (KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES.includes(event_1.txnRef.toLowerCase())) {
|
|
341
|
-
return [3 /*break*/, 6];
|
|
342
|
-
}
|
|
343
|
-
args = event_1;
|
|
344
|
-
_h.label = 3;
|
|
345
|
-
case 3:
|
|
346
|
-
_h.trys.push([3, 4, , 6]);
|
|
347
|
-
_b = this.validateTokenConfigUpdate(args), rateModel = _b.rateModel, routeRateModel = _b.routeRateModel, spokeTargetBalances = _b.spokeTargetBalances;
|
|
348
|
-
value = args.value, l1Token = args.key, eventData = __rest(args, ["value", "key"]);
|
|
349
|
-
if (rateModel !== undefined) {
|
|
350
|
-
this.cumulativeRateModelUpdates.push(__assign(__assign({}, eventData), { rateModel: rateModel, l1Token: l1Token }));
|
|
351
|
-
this.cumulativeSpokeTargetBalanceUpdates.push(__assign(__assign({}, eventData), { spokeTargetBalances: spokeTargetBalances, l1Token: l1Token }));
|
|
352
|
-
this.cumulativeRouteRateModelUpdates.push(__assign(__assign({}, eventData), { routeRateModel: routeRateModel, l1Token: l1Token }));
|
|
353
|
-
}
|
|
354
|
-
return [3 /*break*/, 6];
|
|
355
|
-
case 4:
|
|
356
|
-
err_1 = _h.sent();
|
|
357
|
-
return [4 /*yield*/, averageBlockTime(this.configStore.provider)];
|
|
358
|
-
case 5:
|
|
359
|
-
blockTime = (_h.sent()).average;
|
|
360
|
-
maxWarnAge = (24 * 60 * 60) / blockTime;
|
|
361
|
-
if (result.searchEndBlock - event_1.blockNumber < maxWarnAge) {
|
|
362
|
-
errMsg = isError(err_1) ? err_1.message : "unknown error";
|
|
363
|
-
// This will emit warning logs for any invalid historical updates and it will be very noisy, so
|
|
364
|
-
// developer should move over known invalid hashes to KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES to
|
|
365
|
-
// suppress these warnings.
|
|
366
|
-
this.logger.warn({
|
|
367
|
-
at: "ConfigStore::update",
|
|
368
|
-
message: "Caught error during ConfigStore update: ".concat(errMsg),
|
|
369
|
-
update: args,
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
else {
|
|
373
|
-
this.logger.debug({
|
|
374
|
-
at: "ConfigStoreClient::update",
|
|
375
|
-
message: "Skipping invalid historical update at block ".concat(event_1.blockNumber),
|
|
376
|
-
txnRef: event_1.txnRef,
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
return [3 /*break*/, 6];
|
|
380
|
-
case 6:
|
|
381
|
-
_i++;
|
|
382
|
-
return [3 /*break*/, 2];
|
|
383
|
-
case 7:
|
|
384
|
-
_loop_1 = function (i) {
|
|
385
|
-
var args = updatedGlobalConfigEvents[i];
|
|
386
|
-
if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.MAX_RELAYER_REPAYMENT_LEAF_SIZE)) {
|
|
387
|
-
if (!isNaN(args.value)) {
|
|
388
|
-
this_1.cumulativeMaxRefundCountUpdates.push(args);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.LITE_CHAIN_ID_INDICES)) {
|
|
392
|
-
// We need to parse the chain ID indices array from the stringified JSON. However,
|
|
393
|
-
// the on-chain string has quotes around the array, which will parse our JSON as a
|
|
394
|
-
// string instead of an array. We need to remove these quotes before parsing.
|
|
395
|
-
// To be sure, we can check for single quotes, double quotes, and spaces.
|
|
396
|
-
// Use a regular expression to check if the string is a valid array. We need to check for
|
|
397
|
-
// leading and trailing quotes, as well as leading and trailing whitespace. We also need to
|
|
398
|
-
// check for commas between the numbers. Alternatively, this can be an empty array.
|
|
399
|
-
if (!/^\s*["']?\[(\d+(,\d+)*)?\]["']?\s*$/.test(args.value)) {
|
|
400
|
-
this_1.logger.warn({ at: "ConfigStore", message: "The lite chain indices array ".concat(args.value, " is invalid.") });
|
|
401
|
-
return "continue";
|
|
402
|
-
}
|
|
403
|
-
var chainIndices = JSON.parse(args.value.replace(/['"\s]/g, ""));
|
|
404
|
-
// Check that the array is valid and that every element is a number.
|
|
405
|
-
if (!isArrayOf(chainIndices, isPositiveInteger)) {
|
|
406
|
-
this_1.logger.warn({ at: "ConfigStore", message: "The array ".concat(chainIndices, " is invalid.") });
|
|
407
|
-
return "continue";
|
|
408
|
-
}
|
|
409
|
-
// Let's also check that the array doesn't contain any duplicates.
|
|
410
|
-
if (new Set(chainIndices).size !== chainIndices.length) {
|
|
411
|
-
this_1.logger.warn({
|
|
412
|
-
at: "ConfigStore",
|
|
413
|
-
message: "The array ".concat(chainIndices, " contains duplicates making it invalid."),
|
|
414
|
-
});
|
|
415
|
-
return "continue";
|
|
416
|
-
}
|
|
417
|
-
// If all else passes, we can add this update.
|
|
418
|
-
this_1.liteChainIndicesUpdates.push(__assign(__assign({}, args), { value: chainIndices, timestamp: globalConfigUpdateTimes[i] }));
|
|
419
|
-
}
|
|
420
|
-
else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.CHAIN_ID_INDICES)) {
|
|
421
|
-
try {
|
|
422
|
-
// We need to parse the chain ID indices array from the stringified JSON. However,
|
|
423
|
-
// the on-chain string has quotes around the array, which will parse our JSON as a
|
|
424
|
-
// string instead of an array. We need to remove these quotes before parsing.
|
|
425
|
-
// To be sure, we can check for single quotes, double quotes, and spaces.
|
|
426
|
-
var chainIndices_1 = JSON.parse(args.value.replace(/['"\s]/g, ""));
|
|
427
|
-
// Check that the array is valid and that every element is a number.
|
|
428
|
-
if (!isArrayOf(chainIndices_1, isPositiveInteger)) {
|
|
429
|
-
this_1.logger.warn({ at: "ConfigStore", message: "The array ".concat(chainIndices_1, " is invalid.") });
|
|
430
|
-
return "continue";
|
|
431
|
-
}
|
|
432
|
-
// Let's also check that the array doesn't contain any duplicates.
|
|
433
|
-
if (new Set(chainIndices_1).size !== chainIndices_1.length) {
|
|
434
|
-
this_1.logger.warn({
|
|
435
|
-
at: "ConfigStore",
|
|
436
|
-
message: "The array ".concat(chainIndices_1, " contains duplicates making it invalid."),
|
|
437
|
-
});
|
|
438
|
-
return "continue";
|
|
439
|
-
}
|
|
440
|
-
// Now check that we're only appending positive integers to the chainIndices array on each
|
|
441
|
-
// update. If this isn't the case, skip the update & warn. If there is no previous update,
|
|
442
|
-
// resolve an implicit chain ID list.
|
|
443
|
-
var previousUpdate = (_d = (_c = this_1.chainIdIndicesUpdates.at(-1)) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : this_1.implicitChainIdIndices(chainId);
|
|
444
|
-
// We should now check that previousUpdate is a subset of chainIndices.
|
|
445
|
-
if (!previousUpdate.every(function (chainId, idx) { return chainIndices_1[idx] === chainId; })) {
|
|
446
|
-
this_1.logger.warn({
|
|
447
|
-
at: "ConfigStoreClient#update",
|
|
448
|
-
message: "The array ".concat(chainIndices_1, " is invalid. It must be a superset of the previous array ").concat(previousUpdate),
|
|
449
|
-
});
|
|
450
|
-
return "continue";
|
|
451
|
-
}
|
|
452
|
-
// If all else passes, we can add this update.
|
|
453
|
-
this_1.chainIdIndicesUpdates.push(__assign(__assign({}, args), { value: chainIndices_1 }));
|
|
454
|
-
}
|
|
455
|
-
catch (e) {
|
|
456
|
-
this_1.logger.warn({ at: "ConfigStore::update", message: "Failed to parse chain ID indices: ".concat(args.value) });
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.MAX_POOL_REBALANCE_LEAF_SIZE)) {
|
|
460
|
-
if (!isNaN(args.value)) {
|
|
461
|
-
this_1.cumulativeMaxL1TokenCountUpdates.push(args);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.VERSION)) {
|
|
465
|
-
// If not a number, skip.
|
|
466
|
-
if (isNaN(args.value)) {
|
|
467
|
-
return "continue";
|
|
468
|
-
}
|
|
469
|
-
var value = Number(args.value);
|
|
470
|
-
// If not an integer, skip.
|
|
471
|
-
if (!Number.isInteger(value)) {
|
|
472
|
-
return "continue";
|
|
473
|
-
}
|
|
474
|
-
// Extract the current highest version. Require that the version always increments, otherwise skip the update.
|
|
475
|
-
var lastValue = Number((_f = (_e = this_1.cumulativeConfigStoreVersionUpdates[0]) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : DEFAULT_CONFIG_STORE_VERSION);
|
|
476
|
-
if (value <= lastValue) {
|
|
477
|
-
return "continue";
|
|
478
|
-
}
|
|
479
|
-
// Prepend the update to impose descending ordering for version updates.
|
|
480
|
-
this_1.cumulativeConfigStoreVersionUpdates = __spreadArray([
|
|
481
|
-
__assign(__assign({}, args), { timestamp: globalConfigUpdateTimes[i] })
|
|
482
|
-
], this_1.cumulativeConfigStoreVersionUpdates, true);
|
|
483
|
-
}
|
|
484
|
-
else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.DISABLED_CHAINS)) {
|
|
485
|
-
try {
|
|
486
|
-
var chainIds = this_1.filterDisabledChains(JSON.parse(args.value));
|
|
487
|
-
this_1.cumulativeDisabledChainUpdates.push(__assign(__assign({}, args), { chainIds: chainIds }));
|
|
488
|
-
}
|
|
489
|
-
catch (err) {
|
|
490
|
-
// Can't parse list, skip.
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
else {
|
|
494
|
-
return "continue";
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
this_1 = this;
|
|
498
|
-
// Save new Global config updates.
|
|
499
|
-
for (i = 0; i < updatedGlobalConfigEvents.length; i++) {
|
|
500
|
-
_loop_1(i);
|
|
501
|
-
}
|
|
502
|
-
this.hasLatestConfigStoreVersion = this.hasValidConfigStoreVersionForTimestamp();
|
|
503
|
-
this.latestHeightSearched = result.searchEndBlock;
|
|
504
|
-
this.firstHeightToSearch = result.searchEndBlock + 1; // Next iteration should start off from where this one ended.
|
|
505
|
-
this.eventSearchConfig.to = undefined; // Caller can re-set on subsequent updates if necessary
|
|
506
|
-
this.chainId = (_g = this.chainId) !== null && _g !== void 0 ? _g : chainId; // Update on the first run only.
|
|
507
|
-
this.isUpdated = true;
|
|
508
|
-
this.logger.debug({ at: "ConfigStore", message: "ConfigStore client updated!" });
|
|
509
|
-
return [2 /*return*/];
|
|
393
|
+
catch (e) {
|
|
394
|
+
this.logger.warn({ at: "ConfigStore::update", message: `Failed to parse chain ID indices: ${args.value}` });
|
|
510
395
|
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
396
|
+
}
|
|
397
|
+
else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.MAX_POOL_REBALANCE_LEAF_SIZE)) {
|
|
398
|
+
if (!isNaN(args.value)) {
|
|
399
|
+
this.cumulativeMaxL1TokenCountUpdates.push(args);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.VERSION)) {
|
|
403
|
+
// If not a number, skip.
|
|
404
|
+
if (isNaN(args.value)) {
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
const value = Number(args.value);
|
|
408
|
+
// If not an integer, skip.
|
|
409
|
+
if (!Number.isInteger(value)) {
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
// Extract the current highest version. Require that the version always increments, otherwise skip the update.
|
|
413
|
+
const lastValue = Number(this.cumulativeConfigStoreVersionUpdates[0]?.value ?? DEFAULT_CONFIG_STORE_VERSION);
|
|
414
|
+
if (value <= lastValue) {
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
// Prepend the update to impose descending ordering for version updates.
|
|
418
|
+
this.cumulativeConfigStoreVersionUpdates = [
|
|
419
|
+
{ ...args, timestamp: globalConfigUpdateTimes[i] },
|
|
420
|
+
...this.cumulativeConfigStoreVersionUpdates,
|
|
421
|
+
];
|
|
422
|
+
}
|
|
423
|
+
else if (args.key === utf8ToHex(GLOBAL_CONFIG_STORE_KEYS.DISABLED_CHAINS)) {
|
|
424
|
+
try {
|
|
425
|
+
const chainIds = this.filterDisabledChains(JSON.parse(args.value));
|
|
426
|
+
this.cumulativeDisabledChainUpdates.push({ ...args, chainIds });
|
|
427
|
+
}
|
|
428
|
+
catch (err) {
|
|
429
|
+
// Can't parse list, skip.
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
this.hasLatestConfigStoreVersion = this.hasValidConfigStoreVersionForTimestamp();
|
|
437
|
+
this.latestHeightSearched = result.searchEndBlock;
|
|
438
|
+
this.firstHeightToSearch = result.searchEndBlock + 1; // Next iteration should start off from where this one ended.
|
|
439
|
+
this.eventSearchConfig.to = undefined; // Caller can re-set on subsequent updates if necessary
|
|
440
|
+
this.chainId = this.chainId ?? chainId; // Update on the first run only.
|
|
441
|
+
this.isUpdated = true;
|
|
442
|
+
this.logger.debug({ at: "ConfigStore", message: "ConfigStore client updated!" });
|
|
443
|
+
}
|
|
444
|
+
validateTokenConfigUpdate(args) {
|
|
445
|
+
const { value, key, txnRef } = args;
|
|
446
|
+
const parsedValue = parseJSONWithNumericString(value);
|
|
447
|
+
const l1Token = key;
|
|
519
448
|
// Return the following parameters if the TokenConfig update is valid, otherwise throw an error.
|
|
520
449
|
// Remove any config updates with invalid rate models by throwing an error if any part of the TokenConfig
|
|
521
450
|
// is wrong before we push any events into this client's state.
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
451
|
+
let rateModelForToken = undefined;
|
|
452
|
+
let spokeTargetBalances = {};
|
|
453
|
+
let routeRateModel = {};
|
|
525
454
|
// Drop value and key before passing args.
|
|
526
|
-
if (
|
|
527
|
-
|
|
528
|
-
assert(this.isValidRateModel(rateModel),
|
|
455
|
+
if (parsedValue?.rateModel !== undefined) {
|
|
456
|
+
const rateModel = parsedValue.rateModel;
|
|
457
|
+
assert(this.isValidRateModel(rateModel), `Invalid rateModel UBar for ${l1Token} at transaction ${txnRef}, ${JSON.stringify(rateModel)}`);
|
|
529
458
|
rateModelForToken = JSON.stringify(rateModel);
|
|
530
459
|
// Store spokeTargetBalances
|
|
531
|
-
if (parsedValue
|
|
460
|
+
if (parsedValue?.spokeTargetBalances) {
|
|
532
461
|
// Note: cast is required because fromEntries always produces string keys, despite the function returning a
|
|
533
462
|
// numerical key.
|
|
534
|
-
spokeTargetBalances = Object.fromEntries(Object.entries(parsedValue.spokeTargetBalances).map(
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
return [chainId, { target: target, threshold: threshold }];
|
|
463
|
+
spokeTargetBalances = Object.fromEntries(Object.entries(parsedValue.spokeTargetBalances).map(([chainId, targetBalance]) => {
|
|
464
|
+
const target = max(toBN(targetBalance.target), toBN(0));
|
|
465
|
+
const threshold = max(toBN(targetBalance.threshold), toBN(0));
|
|
466
|
+
return [chainId, { target, threshold }];
|
|
539
467
|
}));
|
|
540
468
|
}
|
|
541
469
|
// Store route-specific rate models
|
|
542
|
-
if (parsedValue
|
|
543
|
-
routeRateModel = Object.fromEntries(Object.entries(parsedValue.routeRateModel).map(
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
"Invalid routeRateModel UBar for ".concat(path, " for ").concat(l1Token, " at transaction ").concat(txnRef, ", ").concat(JSON.stringify(routeRateModel)));
|
|
470
|
+
if (parsedValue?.routeRateModel) {
|
|
471
|
+
routeRateModel = Object.fromEntries(Object.entries(parsedValue.routeRateModel).map(([path, routeRateModel]) => {
|
|
472
|
+
assert(this.isValidRateModel(routeRateModel) &&
|
|
473
|
+
`Invalid routeRateModel UBar for ${path} for ${l1Token} at transaction ${txnRef}, ${JSON.stringify(routeRateModel)}`);
|
|
547
474
|
return [path, JSON.stringify(routeRateModel)];
|
|
548
475
|
}));
|
|
549
476
|
}
|
|
550
477
|
}
|
|
551
478
|
return {
|
|
552
|
-
spokeTargetBalances
|
|
479
|
+
spokeTargetBalances,
|
|
553
480
|
rateModel: rateModelForToken,
|
|
554
|
-
routeRateModel
|
|
481
|
+
routeRateModel,
|
|
555
482
|
};
|
|
556
|
-
}
|
|
557
|
-
|
|
483
|
+
}
|
|
484
|
+
isValidRateModel(rateModel) {
|
|
558
485
|
// UBar should be between 0% and 100%.
|
|
559
486
|
return toBN(rateModel.UBar).gt(0) && toBN(rateModel.UBar).lt(toWei("1"));
|
|
560
|
-
}
|
|
561
|
-
|
|
487
|
+
}
|
|
488
|
+
filterDisabledChains(disabledChains) {
|
|
562
489
|
// If any chain ID's are not integers then ignore. UMIP-157 requires that this key cannot include
|
|
563
490
|
// the chain ID 1.
|
|
564
|
-
return disabledChains.filter(
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
}(BaseAbstractClient));
|
|
568
|
-
export { AcrossConfigStoreClient };
|
|
491
|
+
return disabledChains.filter((chainId) => !isNaN(chainId) && Number.isInteger(chainId) && chainId !== 1);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
569
494
|
//# sourceMappingURL=AcrossConfigStoreClient.js.map
|