@across-protocol/sdk 4.3.111-alpha.4 → 4.3.112-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/addressAggregator/adapters/abstract.js +64 -50
- package/dist/cjs/addressAggregator/adapters/abstract.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/bybit.js +29 -16
- package/dist/cjs/addressAggregator/adapters/bybit.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/env.js +15 -11
- package/dist/cjs/addressAggregator/adapters/env.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/file.js +45 -32
- package/dist/cjs/addressAggregator/adapters/file.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/index.js +1 -1
- package/dist/cjs/addressAggregator/adapters/risklabs.js +36 -22
- package/dist/cjs/addressAggregator/adapters/risklabs.js.map +1 -1
- package/dist/cjs/addressAggregator/index.js +87 -57
- package/dist/cjs/addressAggregator/index.js.map +1 -1
- package/dist/cjs/apiClient/abstractClient.js +8 -9
- package/dist/cjs/apiClient/abstractClient.js.map +1 -1
- package/dist/cjs/apiClient/index.js +1 -1
- package/dist/cjs/apiClient/mockedClient.js +29 -23
- package/dist/cjs/apiClient/mockedClient.js.map +1 -1
- package/dist/cjs/apiClient/productionClient.js +103 -65
- package/dist/cjs/apiClient/productionClient.js.map +1 -1
- package/dist/cjs/arch/evm/BlockUtils.js +208 -122
- package/dist/cjs/arch/evm/BlockUtils.js.map +1 -1
- package/dist/cjs/arch/evm/MessageUtils.js +1 -1
- package/dist/cjs/arch/evm/MessageUtils.js.map +1 -1
- package/dist/cjs/arch/evm/SpokeUtils.js +288 -134
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/evm/index.js +1 -1
- package/dist/cjs/arch/evm/utils/index.js +1 -1
- package/dist/cjs/arch/evm/utils/wait.js +49 -38
- package/dist/cjs/arch/evm/utils/wait.js.map +1 -1
- package/dist/cjs/arch/index.js +1 -1
- package/dist/cjs/arch/svm/BlockUtils.js +158 -102
- package/dist/cjs/arch/svm/BlockUtils.js.map +1 -1
- package/dist/cjs/arch/svm/MessageUtils.js +2 -2
- package/dist/cjs/arch/svm/MessageUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +1147 -708
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/encoders.js +1 -1
- package/dist/cjs/arch/svm/encoders.js.map +1 -1
- package/dist/cjs/arch/svm/eventsClient.js +236 -174
- package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
- package/dist/cjs/arch/svm/index.js +1 -1
- package/dist/cjs/arch/svm/provider.js +3 -3
- package/dist/cjs/arch/svm/provider.js.map +1 -1
- package/dist/cjs/arch/svm/utils.js +355 -166
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/caching/Arweave/ArweaveClient.js +246 -168
- package/dist/cjs/caching/Arweave/ArweaveClient.js.map +1 -1
- package/dist/cjs/caching/Arweave/index.js +1 -1
- package/dist/cjs/caching/IPFS/PinataIPFSClient.js +49 -40
- package/dist/cjs/caching/IPFS/PinataIPFSClient.js.map +1 -1
- package/dist/cjs/caching/IPFS/index.js +1 -1
- package/dist/cjs/caching/Memory/MemoryCacheClient.js +18 -13
- package/dist/cjs/caching/Memory/MemoryCacheClient.js.map +1 -1
- package/dist/cjs/caching/Memory/index.js +1 -1
- package/dist/cjs/caching/index.js +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +381 -302
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/index.js +1 -1
- package/dist/cjs/clients/BaseAbstractClient.js +83 -58
- package/dist/cjs/clients/BaseAbstractClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +900 -709
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/index.js +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +128 -95
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +53 -48
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +8 -10
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +90 -67
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +24 -46
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/index.js +1 -1
- package/dist/cjs/clients/HubPoolClient.js +708 -526
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +179 -133
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +183 -124
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +389 -357
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js +8 -9
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/index.js +3 -3
- package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/cjs/clients/index.js +1 -1
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js +67 -58
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockEvents.js +52 -47
- package/dist/cjs/clients/mocks/MockEvents.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +185 -142
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +192 -208
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +143 -140
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +73 -57
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/index.js +1 -1
- package/dist/cjs/coingecko/Coingecko.js +437 -285
- package/dist/cjs/coingecko/Coingecko.js.map +1 -1
- package/dist/cjs/coingecko/index.js +1 -1
- package/dist/cjs/constants.js +30 -23
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/contracts/acrossConfigStore.js +48 -27
- package/dist/cjs/contracts/acrossConfigStore.js.map +1 -1
- package/dist/cjs/contracts/hubPool.js +20 -36
- package/dist/cjs/contracts/hubPool.js.map +1 -1
- package/dist/cjs/contracts/index.js +1 -1
- package/dist/cjs/contracts/utils.js +8 -6
- package/dist/cjs/contracts/utils.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +16 -7
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js +45 -26
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js +28 -16
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/polygon.js +112 -73
- package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/solana.js +33 -20
- package/dist/cjs/gasPriceOracle/adapters/solana.js.map +1 -1
- package/dist/cjs/gasPriceOracle/oracle.js +104 -77
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/gasPriceOracle/types.js +3 -3
- package/dist/cjs/gasPriceOracle/types.js.map +1 -1
- package/dist/cjs/gasPriceOracle/util.js +8 -8
- package/dist/cjs/gasPriceOracle/util.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/interfaces/index.js +1 -1
- package/dist/cjs/lpFeeCalculator/index.js +1 -1
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js +35 -33
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js.map +1 -1
- package/dist/cjs/lpFeeCalculator/rateModel.js +9 -7
- package/dist/cjs/lpFeeCalculator/rateModel.js.map +1 -1
- package/dist/cjs/merkleDistributor/MerkleDistributor.js +18 -20
- package/dist/cjs/merkleDistributor/MerkleDistributor.js.map +1 -1
- package/dist/cjs/merkleDistributor/index.js +1 -1
- package/dist/cjs/merkleDistributor/model/index.js +1 -1
- package/dist/cjs/pool/TransactionManager.js +100 -45
- package/dist/cjs/pool/TransactionManager.js.map +1 -1
- package/dist/cjs/pool/index.js +1 -1
- package/dist/cjs/pool/poolClient.js +731 -464
- package/dist/cjs/pool/poolClient.js.map +1 -1
- package/dist/cjs/pool/uma/across/index.js +1 -1
- package/dist/cjs/pool/uma/across/transactionManager.js +100 -45
- package/dist/cjs/pool/uma/across/transactionManager.js.map +1 -1
- package/dist/cjs/pool/uma/clients/erc20/client.js +16 -18
- package/dist/cjs/pool/uma/clients/erc20/client.js.map +1 -1
- package/dist/cjs/pool/uma/clients/erc20/index.js +1 -1
- package/dist/cjs/pool/uma/clients/index.js +1 -1
- package/dist/cjs/pool/uma/index.js +1 -1
- package/dist/cjs/pool/uma/oracle/index.js +1 -1
- package/dist/cjs/pool/uma/oracle/utils.js +5 -4
- package/dist/cjs/pool/uma/oracle/utils.js.map +1 -1
- package/dist/cjs/pool/uma/utils.js +30 -11
- package/dist/cjs/pool/uma/utils.js.map +1 -1
- package/dist/cjs/priceClient/adapters/acrossApi.js +39 -22
- package/dist/cjs/priceClient/adapters/acrossApi.js.map +1 -1
- package/dist/cjs/priceClient/adapters/baseAdapter.js +73 -49
- package/dist/cjs/priceClient/adapters/baseAdapter.js.map +1 -1
- package/dist/cjs/priceClient/adapters/coingecko.js +61 -34
- package/dist/cjs/priceClient/adapters/coingecko.js.map +1 -1
- package/dist/cjs/priceClient/adapters/default.js +31 -16
- package/dist/cjs/priceClient/adapters/default.js.map +1 -1
- package/dist/cjs/priceClient/adapters/defiLlama.js +74 -40
- package/dist/cjs/priceClient/adapters/defiLlama.js.map +1 -1
- package/dist/cjs/priceClient/adapters/index.js +1 -1
- package/dist/cjs/priceClient/index.js +1 -1
- package/dist/cjs/priceClient/priceClient.js +159 -110
- package/dist/cjs/priceClient/priceClient.js.map +1 -1
- package/dist/cjs/providers/alchemy.js +19 -17
- package/dist/cjs/providers/alchemy.js.map +1 -1
- package/dist/cjs/providers/cachedProvider.js +129 -88
- package/dist/cjs/providers/cachedProvider.js.map +1 -1
- package/dist/cjs/providers/drpc.js +11 -9
- package/dist/cjs/providers/drpc.js.map +1 -1
- package/dist/cjs/providers/index.js +1 -1
- package/dist/cjs/providers/infura.js +12 -10
- package/dist/cjs/providers/infura.js.map +1 -1
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js +15 -7
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js +14 -6
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/MockRetrySolanaRpcFactory.js +15 -7
- package/dist/cjs/providers/mocks/MockRetrySolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js +66 -42
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/index.js +1 -1
- package/dist/cjs/providers/mocks/mockEthersProvider.js +31 -29
- package/dist/cjs/providers/mocks/mockEthersProvider.js.map +1 -1
- package/dist/cjs/providers/quicknode.js +21 -19
- package/dist/cjs/providers/quicknode.js.map +1 -1
- package/dist/cjs/providers/rateLimitedProvider.js +79 -64
- package/dist/cjs/providers/rateLimitedProvider.js.map +1 -1
- package/dist/cjs/providers/retryProvider.js +246 -163
- package/dist/cjs/providers/retryProvider.js.map +1 -1
- package/dist/cjs/providers/solana/baseRpcFactories.js +18 -14
- package/dist/cjs/providers/solana/baseRpcFactories.js.map +1 -1
- package/dist/cjs/providers/solana/cachedRpcFactory.js +112 -70
- package/dist/cjs/providers/solana/cachedRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/defaultRpcFactory.js +15 -8
- package/dist/cjs/providers/solana/defaultRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/index.js +1 -1
- package/dist/cjs/providers/solana/quorumFallbackRpcFactory.js +191 -135
- package/dist/cjs/providers/solana/quorumFallbackRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/rateLimitedRpcFactory.js +90 -67
- package/dist/cjs/providers/solana/rateLimitedRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/retryRpcFactory.js +79 -52
- package/dist/cjs/providers/solana/retryRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/utils.js +2 -2
- package/dist/cjs/providers/solana/utils.js.map +1 -1
- package/dist/cjs/providers/speedProvider.js +53 -31
- package/dist/cjs/providers/speedProvider.js.map +1 -1
- package/dist/cjs/providers/types.js +1 -1
- package/dist/cjs/providers/types.js.map +1 -1
- package/dist/cjs/providers/utils.js +28 -26
- package/dist/cjs/providers/utils.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +162 -108
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/customGasToken.js +26 -14
- package/dist/cjs/relayFeeCalculator/chain-queries/customGasToken.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +29 -20
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +137 -88
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/index.js +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +297 -199
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/typeguards/error.js +7 -5
- package/dist/cjs/typeguards/error.js.map +1 -1
- package/dist/cjs/typeguards/index.js +1 -1
- package/dist/cjs/utils/AddressUtils.js +144 -117
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/ArrayUtils.js +78 -21
- package/dist/cjs/utils/ArrayUtils.js.map +1 -1
- package/dist/cjs/utils/BigNumberUtils.js +10 -9
- package/dist/cjs/utils/BigNumberUtils.js.map +1 -1
- package/dist/cjs/utils/BlockExplorerUtils.js +30 -26
- package/dist/cjs/utils/BlockExplorerUtils.js.map +1 -1
- package/dist/cjs/utils/BlockFinder.js +5 -2
- package/dist/cjs/utils/BlockFinder.js.map +1 -1
- package/dist/cjs/utils/BlockUtils.js +41 -24
- package/dist/cjs/utils/BlockUtils.js.map +1 -1
- package/dist/cjs/utils/BundleUtils.js +24 -21
- package/dist/cjs/utils/BundleUtils.js.map +1 -1
- package/dist/cjs/utils/CCTPUtils.js +126 -62
- package/dist/cjs/utils/CCTPUtils.js.map +1 -1
- package/dist/cjs/utils/CachingUtils.js +42 -20
- package/dist/cjs/utils/CachingUtils.js.map +1 -1
- package/dist/cjs/utils/ContractUtils.js +5 -5
- package/dist/cjs/utils/ContractUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.js +99 -122
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/EventUtils.js +70 -49
- package/dist/cjs/utils/EventUtils.js.map +1 -1
- package/dist/cjs/utils/FormattingUtils.js +32 -26
- package/dist/cjs/utils/FormattingUtils.js.map +1 -1
- package/dist/cjs/utils/HyperLiquidUtils.js +23 -10
- package/dist/cjs/utils/HyperLiquidUtils.js.map +1 -1
- package/dist/cjs/utils/IPFSUtils.js +34 -16
- package/dist/cjs/utils/IPFSUtils.js.map +1 -1
- package/dist/cjs/utils/JSONUtils.js +6 -6
- package/dist/cjs/utils/JSONUtils.js.map +1 -1
- package/dist/cjs/utils/LogUtils.js +12 -10
- package/dist/cjs/utils/LogUtils.js.map +1 -1
- package/dist/cjs/utils/Multicall.js +115 -56
- package/dist/cjs/utils/Multicall.js.map +1 -1
- package/dist/cjs/utils/NetworkUtils.js +28 -12
- package/dist/cjs/utils/NetworkUtils.js.map +1 -1
- package/dist/cjs/utils/NumberUtils.js +3 -1
- package/dist/cjs/utils/NumberUtils.js.map +1 -1
- package/dist/cjs/utils/ObjectUtils.js +41 -27
- package/dist/cjs/utils/ObjectUtils.js.map +1 -1
- package/dist/cjs/utils/Profiler.js +83 -80
- package/dist/cjs/utils/Profiler.js.map +1 -1
- package/dist/cjs/utils/ReviverUtils.js +9 -5
- package/dist/cjs/utils/ReviverUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.js +84 -84
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.js +64 -41
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/cjs/utils/TypeGuards.js +1 -1
- package/dist/cjs/utils/TypeGuards.js.map +1 -1
- package/dist/cjs/utils/ValidatorUtils.js +7 -7
- package/dist/cjs/utils/ValidatorUtils.js.map +1 -1
- package/dist/cjs/utils/abi/contracts/index.js +1 -1
- package/dist/cjs/utils/abi/index.js +22 -12
- package/dist/cjs/utils/abi/index.js.map +1 -1
- package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js +12 -9
- package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
- package/dist/cjs/utils/abi/typechain/index.js +1 -1
- package/dist/cjs/utils/common.js +53 -40
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/cjs/utils/index.js +1 -1
- package/dist/esm/addressAggregator/adapters/abstract.js +64 -48
- package/dist/esm/addressAggregator/adapters/abstract.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/bybit.js +29 -15
- package/dist/esm/addressAggregator/adapters/bybit.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/env.js +14 -9
- package/dist/esm/addressAggregator/adapters/env.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/file.js +43 -29
- package/dist/esm/addressAggregator/adapters/file.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/risklabs.js +35 -20
- package/dist/esm/addressAggregator/adapters/risklabs.js.map +1 -1
- package/dist/esm/addressAggregator/index.js +83 -52
- package/dist/esm/addressAggregator/index.js.map +1 -1
- package/dist/esm/addressAggregator/types.js +1 -1
- package/dist/esm/addressAggregator/types.js.map +1 -1
- package/dist/esm/apiClient/abstractClient.js +9 -15
- package/dist/esm/apiClient/abstractClient.js.map +1 -1
- package/dist/esm/apiClient/mockedClient.js +26 -21
- package/dist/esm/apiClient/mockedClient.js.map +1 -1
- package/dist/esm/apiClient/productionClient.js +101 -61
- package/dist/esm/apiClient/productionClient.js.map +1 -1
- package/dist/esm/arch/evm/BlockUtils.js +217 -139
- package/dist/esm/arch/evm/BlockUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.js +289 -146
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/evm/utils/wait.js +46 -34
- package/dist/esm/arch/evm/utils/wait.js.map +1 -1
- package/dist/esm/arch/svm/BlockUtils.js +166 -118
- package/dist/esm/arch/svm/BlockUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js +1150 -738
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/constants.js +1 -1
- package/dist/esm/arch/svm/constants.js.map +1 -1
- package/dist/esm/arch/svm/eventsClient.js +232 -172
- package/dist/esm/arch/svm/eventsClient.js.map +1 -1
- package/dist/esm/arch/svm/provider.js +1 -1
- package/dist/esm/arch/svm/provider.js.map +1 -1
- package/dist/esm/arch/svm/utils.js +345 -155
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/caching/Arweave/ArweaveClient.js +256 -182
- package/dist/esm/caching/Arweave/ArweaveClient.js.map +1 -1
- package/dist/esm/caching/IPFS/PinataIPFSClient.js +48 -47
- package/dist/esm/caching/IPFS/PinataIPFSClient.js.map +1 -1
- package/dist/esm/caching/Memory/MemoryCacheClient.js +19 -13
- package/dist/esm/caching/Memory/MemoryCacheClient.js.map +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +408 -333
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BaseAbstractClient.js +92 -66
- package/dist/esm/clients/BaseAbstractClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +1054 -927
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +131 -102
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +59 -57
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -7
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +94 -75
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +23 -45
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.js +740 -581
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +178 -133
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +183 -126
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +399 -372
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js +9 -9
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.js +2 -2
- package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/types.js +2 -2
- package/dist/esm/clients/SpokePoolClient/types.js.map +1 -1
- package/dist/esm/clients/mocks/MockConfigStoreClient.js +64 -53
- package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockEvents.js +49 -42
- package/dist/esm/clients/mocks/MockEvents.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.js +182 -138
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +188 -202
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +132 -127
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +69 -53
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/esm/coingecko/Coingecko.js +443 -298
- package/dist/esm/coingecko/Coingecko.js.map +1 -1
- package/dist/esm/constants.js +47 -40
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/contracts/acrossConfigStore.js +46 -24
- package/dist/esm/contracts/acrossConfigStore.js.map +1 -1
- package/dist/esm/contracts/hubPool.js +18 -34
- package/dist/esm/contracts/hubPool.js.map +1 -1
- package/dist/esm/contracts/utils.js +5 -3
- package/dist/esm/contracts/utils.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js +14 -6
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/ethereum.js +42 -22
- package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js +25 -13
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/polygon.js +108 -72
- package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/solana.js +31 -22
- package/dist/esm/gasPriceOracle/adapters/solana.js.map +1 -1
- package/dist/esm/gasPriceOracle/oracle.js +96 -70
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/gasPriceOracle/types.js +2 -2
- package/dist/esm/gasPriceOracle/types.js.map +1 -1
- package/dist/esm/gasPriceOracle/util.js +4 -4
- package/dist/esm/gasPriceOracle/util.js.map +1 -1
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.js +33 -30
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.js.map +1 -1
- package/dist/esm/lpFeeCalculator/rateModel.js +9 -7
- package/dist/esm/lpFeeCalculator/rateModel.js.map +1 -1
- package/dist/esm/merkleDistributor/MerkleDistributor.js +17 -18
- package/dist/esm/merkleDistributor/MerkleDistributor.js.map +1 -1
- package/dist/esm/pool/TransactionManager.js +100 -45
- package/dist/esm/pool/TransactionManager.js.map +1 -1
- package/dist/esm/pool/poolClient.js +740 -479
- package/dist/esm/pool/poolClient.js.map +1 -1
- package/dist/esm/pool/uma/across/constants.js +2 -2
- package/dist/esm/pool/uma/across/constants.js.map +1 -1
- package/dist/esm/pool/uma/across/transactionManager.js +100 -45
- package/dist/esm/pool/uma/across/transactionManager.js.map +1 -1
- package/dist/esm/pool/uma/clients/erc20/client.js +13 -15
- package/dist/esm/pool/uma/clients/erc20/client.js.map +1 -1
- package/dist/esm/pool/uma/oracle/utils.js +3 -2
- package/dist/esm/pool/uma/oracle/utils.js.map +1 -1
- package/dist/esm/pool/uma/utils.js +28 -9
- package/dist/esm/pool/uma/utils.js.map +1 -1
- package/dist/esm/priceClient/adapters/acrossApi.js +40 -21
- package/dist/esm/priceClient/adapters/acrossApi.js.map +1 -1
- package/dist/esm/priceClient/adapters/baseAdapter.js +72 -46
- package/dist/esm/priceClient/adapters/baseAdapter.js.map +1 -1
- package/dist/esm/priceClient/adapters/coingecko.js +61 -33
- package/dist/esm/priceClient/adapters/coingecko.js.map +1 -1
- package/dist/esm/priceClient/adapters/default.js +31 -15
- package/dist/esm/priceClient/adapters/default.js.map +1 -1
- package/dist/esm/priceClient/adapters/defiLlama.js +73 -38
- package/dist/esm/priceClient/adapters/defiLlama.js.map +1 -1
- package/dist/esm/priceClient/priceClient.js +158 -109
- package/dist/esm/priceClient/priceClient.js.map +1 -1
- package/dist/esm/providers/alchemy.js +18 -16
- package/dist/esm/providers/alchemy.js.map +1 -1
- package/dist/esm/providers/cachedProvider.js +134 -99
- package/dist/esm/providers/cachedProvider.js.map +1 -1
- package/dist/esm/providers/constants.js +3 -3
- package/dist/esm/providers/constants.js.map +1 -1
- package/dist/esm/providers/drpc.js +10 -8
- package/dist/esm/providers/drpc.js.map +1 -1
- package/dist/esm/providers/infura.js +11 -9
- package/dist/esm/providers/infura.js.map +1 -1
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js +15 -6
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js +14 -5
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/MockRetrySolanaRpcFactory.js +15 -6
- package/dist/esm/providers/mocks/MockRetrySolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.js +66 -41
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/mockEthersProvider.js +30 -27
- package/dist/esm/providers/mocks/mockEthersProvider.js.map +1 -1
- package/dist/esm/providers/quicknode.js +20 -18
- package/dist/esm/providers/quicknode.js.map +1 -1
- package/dist/esm/providers/rateLimitedProvider.js +80 -68
- package/dist/esm/providers/rateLimitedProvider.js.map +1 -1
- package/dist/esm/providers/retryProvider.js +259 -186
- package/dist/esm/providers/retryProvider.js.map +1 -1
- package/dist/esm/providers/solana/baseRpcFactories.js +19 -13
- package/dist/esm/providers/solana/baseRpcFactories.js.map +1 -1
- package/dist/esm/providers/solana/cachedRpcFactory.js +112 -75
- package/dist/esm/providers/solana/cachedRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/defaultRpcFactory.js +14 -6
- package/dist/esm/providers/solana/defaultRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/quorumFallbackRpcFactory.js +202 -149
- package/dist/esm/providers/solana/quorumFallbackRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/rateLimitedRpcFactory.js +90 -70
- package/dist/esm/providers/solana/rateLimitedRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/retryRpcFactory.js +74 -50
- package/dist/esm/providers/solana/retryRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/utils.js +1 -1
- package/dist/esm/providers/solana/utils.js.map +1 -1
- package/dist/esm/providers/speedProvider.js +51 -28
- package/dist/esm/providers/speedProvider.js.map +1 -1
- package/dist/esm/providers/types.js +2 -2
- package/dist/esm/providers/types.js.map +1 -1
- package/dist/esm/providers/utils.js +20 -17
- package/dist/esm/providers/utils.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +152 -98
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/customGasToken.js +26 -13
- package/dist/esm/relayFeeCalculator/chain-queries/customGasToken.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +19 -9
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +128 -83
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +299 -211
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/typeguards/error.js +5 -3
- package/dist/esm/typeguards/error.js.map +1 -1
- package/dist/esm/utils/AddressUtils.js +147 -115
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/ArrayUtils.js +78 -21
- package/dist/esm/utils/ArrayUtils.js.map +1 -1
- package/dist/esm/utils/BigNumberUtils.js +12 -11
- package/dist/esm/utils/BigNumberUtils.js.map +1 -1
- package/dist/esm/utils/BlockExplorerUtils.js +23 -19
- package/dist/esm/utils/BlockExplorerUtils.js.map +1 -1
- package/dist/esm/utils/BlockFinder.js +6 -2
- package/dist/esm/utils/BlockFinder.js.map +1 -1
- package/dist/esm/utils/BlockUtils.js +40 -31
- package/dist/esm/utils/BlockUtils.js.map +1 -1
- package/dist/esm/utils/BundleUtils.js +24 -21
- package/dist/esm/utils/BundleUtils.js.map +1 -1
- package/dist/esm/utils/CCTPUtils.js +123 -62
- package/dist/esm/utils/CCTPUtils.js.map +1 -1
- package/dist/esm/utils/CachingUtils.js +38 -17
- package/dist/esm/utils/CachingUtils.js.map +1 -1
- package/dist/esm/utils/ContractUtils.js +3 -3
- package/dist/esm/utils/ContractUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.js +98 -121
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/EventUtils.js +69 -52
- package/dist/esm/utils/EventUtils.js.map +1 -1
- package/dist/esm/utils/FormattingUtils.js +26 -20
- package/dist/esm/utils/FormattingUtils.js.map +1 -1
- package/dist/esm/utils/HyperLiquidUtils.js +22 -8
- package/dist/esm/utils/HyperLiquidUtils.js.map +1 -1
- package/dist/esm/utils/IPFSUtils.js +35 -16
- package/dist/esm/utils/IPFSUtils.js.map +1 -1
- package/dist/esm/utils/JSONUtils.js +4 -4
- package/dist/esm/utils/JSONUtils.js.map +1 -1
- package/dist/esm/utils/LogUtils.js +12 -8
- package/dist/esm/utils/LogUtils.js.map +1 -1
- package/dist/esm/utils/Multicall.js +110 -50
- package/dist/esm/utils/Multicall.js.map +1 -1
- package/dist/esm/utils/NetworkUtils.js +28 -12
- package/dist/esm/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/utils/NumberUtils.js +3 -1
- package/dist/esm/utils/NumberUtils.js.map +1 -1
- package/dist/esm/utils/ObjectUtils.js +41 -27
- package/dist/esm/utils/ObjectUtils.js.map +1 -1
- package/dist/esm/utils/Profiler.js +82 -77
- package/dist/esm/utils/Profiler.js.map +1 -1
- package/dist/esm/utils/ReviverUtils.js +7 -3
- package/dist/esm/utils/ReviverUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.js +78 -83
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.js +57 -33
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/esm/utils/ValidatorUtils.js +4 -4
- package/dist/esm/utils/ValidatorUtils.js.map +1 -1
- package/dist/esm/utils/abi/index.js +20 -10
- package/dist/esm/utils/abi/index.js.map +1 -1
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js +12 -8
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
- package/dist/esm/utils/common.js +52 -38
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/utils/Multicall.d.ts.map +1 -1
- package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/constants.ts +1 -0
- package/src/gasPriceOracle/oracle.ts +1 -0
- package/src/utils/Multicall.ts +1 -0
- package/src/utils/NetworkUtils.ts +8 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign, __awaiter, __extends, __generator, __rest, __spreadArray } from "tslib";
|
|
1
2
|
import assert from "assert";
|
|
2
3
|
import { isError } from "../../typeguards";
|
|
3
4
|
import { averageBlockTime } from "../../arch/evm";
|
|
@@ -8,7 +9,7 @@ import { BaseAbstractClient, isUpdateFailureReason, UpdateFailureReason } from "
|
|
|
8
9
|
import { parseAndReturnRateModelFromString } from "../../lpFeeCalculator/rateModel";
|
|
9
10
|
// Version 0 is the implicit ConfigStore version from before the version attribute was introduced.
|
|
10
11
|
// @dev Do not change this value.
|
|
11
|
-
export
|
|
12
|
+
export var DEFAULT_CONFIG_STORE_VERSION = 0;
|
|
12
13
|
export var GLOBAL_CONFIG_STORE_KEYS;
|
|
13
14
|
(function (GLOBAL_CONFIG_STORE_KEYS) {
|
|
14
15
|
GLOBAL_CONFIG_STORE_KEYS["MAX_RELAYER_REPAYMENT_LEAF_SIZE"] = "MAX_RELAYER_REPAYMENT_LEAF_SIZE";
|
|
@@ -19,7 +20,7 @@ export var GLOBAL_CONFIG_STORE_KEYS;
|
|
|
19
20
|
GLOBAL_CONFIG_STORE_KEYS["LITE_CHAIN_ID_INDICES"] = "LITE_CHAIN_ID_INDICES";
|
|
20
21
|
})(GLOBAL_CONFIG_STORE_KEYS || (GLOBAL_CONFIG_STORE_KEYS = {}));
|
|
21
22
|
// Conveniently store known invalid token config update hashes to avoid spamming debug logs.
|
|
22
|
-
|
|
23
|
+
var KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES = [
|
|
23
24
|
"0x422abc617c6598e4b91859f99c392939d2034c1a839a342a963a34a2f0390195",
|
|
24
25
|
"0x36c85e388279714b2c98d46e3377dc37a1575665b2cac5e52fe97d8d77efcd2b",
|
|
25
26
|
"0x6f0a93119e538dd84e02adfce821fb4e6dd9baddcceb041977e8ba3c39185ab8",
|
|
@@ -34,52 +35,55 @@ const KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES = [
|
|
|
34
35
|
"0x89830f5e81b9e8b44ac2f8966b2fa4bf8e71d7f546e2bc0e773d8ee8df4bdb36",
|
|
35
36
|
"0xb0ad6270124c925a234d9c4f87b60396f2b52fdc250cd2fc9cac792d0d62e467",
|
|
36
37
|
"0x779bc3bf2dba1128d5dda6be8ae99b503cae23343a7265a86bca3d5572ed4268",
|
|
37
|
-
].map((hash)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
configStore
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.latestHeightSearched = 0;
|
|
38
|
+
].map(function (hash) { return hash.toLowerCase(); });
|
|
39
|
+
var AcrossConfigStoreClient = /** @class */ (function (_super) {
|
|
40
|
+
__extends(AcrossConfigStoreClient, _super);
|
|
41
|
+
function AcrossConfigStoreClient(logger, configStore, eventSearchConfig, configStoreVersion) {
|
|
42
|
+
if (eventSearchConfig === void 0) { eventSearchConfig = { from: 0, maxLookBack: 0 }; }
|
|
43
|
+
var _this = _super.call(this, eventSearchConfig) || this;
|
|
44
|
+
_this.logger = logger;
|
|
45
|
+
_this.configStore = configStore;
|
|
46
|
+
_this.configStoreVersion = configStoreVersion;
|
|
47
|
+
_this.cumulativeRateModelUpdates = [];
|
|
48
|
+
_this.cumulativeRouteRateModelUpdates = [];
|
|
49
|
+
_this.cumulativeMaxRefundCountUpdates = [];
|
|
50
|
+
_this.cumulativeMaxL1TokenCountUpdates = [];
|
|
51
|
+
_this.chainIdIndicesUpdates = [];
|
|
52
|
+
_this.liteChainIndicesUpdates = [];
|
|
53
|
+
_this.cumulativeSpokeTargetBalanceUpdates = [];
|
|
54
|
+
_this.cumulativeConfigStoreVersionUpdates = [];
|
|
55
|
+
_this.cumulativeDisabledChainUpdates = [];
|
|
56
|
+
_this.hasLatestConfigStoreVersion = false;
|
|
57
|
+
_this.firstHeightToSearch = eventSearchConfig.from;
|
|
58
|
+
_this.latestHeightSearched = 0;
|
|
59
|
+
return _this;
|
|
60
60
|
}
|
|
61
|
-
getRateModelForBlockNumber(l1Token, originChainId, destinationChainId, blockNumber
|
|
61
|
+
AcrossConfigStoreClient.prototype.getRateModelForBlockNumber = function (l1Token, originChainId, destinationChainId, blockNumber) {
|
|
62
|
+
if (blockNumber === void 0) { blockNumber = undefined; }
|
|
62
63
|
// Use route-rate model if available, otherwise use default rate model for l1Token.
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
var route = "".concat(originChainId, "-").concat(destinationChainId);
|
|
65
|
+
var routeRateModel = this.getRouteRateModelForBlockNumber(l1Token, route, blockNumber);
|
|
65
66
|
if (routeRateModel) {
|
|
66
67
|
return routeRateModel;
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
-
config.
|
|
70
|
-
|
|
69
|
+
var defaultRateModelUpdate = sortEventsDescending(this.cumulativeRateModelUpdates).find(function (config) {
|
|
70
|
+
return config.blockNumber <= (blockNumber !== null && blockNumber !== void 0 ? blockNumber : 0) &&
|
|
71
|
+
config.l1Token === l1Token.toEvmAddress() &&
|
|
72
|
+
config.rateModel !== undefined;
|
|
73
|
+
});
|
|
71
74
|
if (!defaultRateModelUpdate) {
|
|
72
|
-
throw new Error(
|
|
75
|
+
throw new Error("Could not find TokenConfig update for ".concat(l1Token, " at block ").concat(blockNumber));
|
|
73
76
|
}
|
|
74
77
|
return parseAndReturnRateModelFromString(defaultRateModelUpdate.rateModel);
|
|
75
|
-
}
|
|
76
|
-
getRouteRateModelForBlockNumber(l1Token, route, blockNumber
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
};
|
|
79
|
+
AcrossConfigStoreClient.prototype.getRouteRateModelForBlockNumber = function (l1Token, route, blockNumber) {
|
|
80
|
+
if (blockNumber === void 0) { blockNumber = undefined; }
|
|
81
|
+
var config = sortEventsDescending(this.cumulativeRouteRateModelUpdates).find(function (config) { return config.blockNumber <= (blockNumber !== null && blockNumber !== void 0 ? blockNumber : 0) && config.l1Token === l1Token.toEvmAddress(); });
|
|
82
|
+
if ((config === null || config === void 0 ? void 0 : config.routeRateModel[route]) === undefined) {
|
|
79
83
|
return undefined;
|
|
80
84
|
}
|
|
81
85
|
return parseAndReturnRateModelFromString(config.routeRateModel[route]);
|
|
82
|
-
}
|
|
86
|
+
};
|
|
83
87
|
/**
|
|
84
88
|
* Resolve the implied set of chain ID indices based on the chain ID of the ConfigStore.
|
|
85
89
|
* @param chainId Chain ID of the ConfigStore.
|
|
@@ -88,10 +92,10 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
88
92
|
* @dev The protocol defaults are [1, 10, 137, 288, 42161] (outlined in UMIP-157).
|
|
89
93
|
* @dev chainId is marked optional to appease tsc. It must always be passed in.
|
|
90
94
|
*/
|
|
91
|
-
implicitChainIdIndices(chainId) {
|
|
95
|
+
AcrossConfigStoreClient.prototype.implicitChainIdIndices = function (chainId) {
|
|
92
96
|
assert(isDefined(chainId), "ConfigStoreClient used before update");
|
|
93
97
|
return PROTOCOL_DEFAULT_CHAIN_ID_INDICES[0] === chainId ? PROTOCOL_DEFAULT_CHAIN_ID_INDICES : [chainId];
|
|
94
|
-
}
|
|
98
|
+
};
|
|
95
99
|
/**
|
|
96
100
|
* Resolves the chain ids that were available to the protocol at a given block range.
|
|
97
101
|
* @param blockNumber Block number to search for. Defaults to latest block.
|
|
@@ -103,64 +107,75 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
103
107
|
* this key/value entry, the function will return the default list of chain IDs as
|
|
104
108
|
* outlined per the UMIP (https://github.com/UMAprotocol/UMIPs/pull/590).
|
|
105
109
|
*/
|
|
106
|
-
getChainIdIndicesForBlock
|
|
110
|
+
AcrossConfigStoreClient.prototype.getChainIdIndicesForBlock = function (blockNumber) {
|
|
111
|
+
var _a;
|
|
112
|
+
if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
|
|
107
113
|
// Resolve the chain ID indices for the block number requested.
|
|
108
|
-
|
|
114
|
+
var chainIdUpdates = sortEventsDescending(this.chainIdIndicesUpdates);
|
|
109
115
|
// Iterate through each of the chain ID updates and resolve the first update that is
|
|
110
116
|
// less than or equal to the block number requested.
|
|
111
|
-
|
|
117
|
+
var chainIdIndices = (_a = chainIdUpdates.find(function (update) { return update.blockNumber <= blockNumber; })) === null || _a === void 0 ? void 0 : _a.value;
|
|
112
118
|
// Return either the found value or the protocol default.
|
|
113
|
-
return chainIdIndices
|
|
114
|
-
}
|
|
119
|
+
return chainIdIndices !== null && chainIdIndices !== void 0 ? chainIdIndices : this.implicitChainIdIndices(this.chainId);
|
|
120
|
+
};
|
|
115
121
|
/**
|
|
116
122
|
* Resolves the lite chain ids that were available to the protocol at a given block range.
|
|
117
123
|
* @param blockNumber Block number to search for. Defaults to latest block.
|
|
118
124
|
* @returns List of lite chain IDs that were available to the protocol at the given block number.
|
|
119
125
|
* @note This dynamic functionality has been added after the launch of Across.
|
|
120
126
|
*/
|
|
121
|
-
getLiteChainIdIndicesForBlock
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
AcrossConfigStoreClient.prototype.getLiteChainIdIndicesForBlock = function (blockNumber) {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
|
|
130
|
+
var liteChainIdList = sortEventsDescending(this.liteChainIndicesUpdates);
|
|
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
|
+
};
|
|
125
133
|
/**
|
|
126
134
|
* Resolves the lite chain ids that were available to the protocol at a given timestamp.
|
|
127
135
|
* @param timestamp Timestamp to search for. Defaults to latest time - in seconds.
|
|
128
136
|
* @returns List of lite chain IDs that were available to the protocol at the given timestamp.
|
|
129
137
|
* @note This dynamic functionality has been added after the launch of Across.
|
|
130
138
|
*/
|
|
131
|
-
getLiteChainIdIndicesForTimestamp
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
AcrossConfigStoreClient.prototype.getLiteChainIdIndicesForTimestamp = function (timestamp) {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
if (timestamp === void 0) { timestamp = Number.MAX_SAFE_INTEGER; }
|
|
142
|
+
var liteChainIdList = sortEventsDescending(this.liteChainIndicesUpdates);
|
|
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
|
+
};
|
|
135
145
|
/**
|
|
136
146
|
* Checks if a chain ID was a lite chain at a given timestamp.
|
|
137
147
|
* @param chainId The chain ID to check.
|
|
138
148
|
* @param timestamp The timestamp to check. Defaults to latest time - in seconds.
|
|
139
149
|
* @returns True if the chain ID was a lite chain at the given timestamp. False otherwise.
|
|
140
150
|
*/
|
|
141
|
-
isChainLiteChainAtTimestamp(chainId, timestamp
|
|
151
|
+
AcrossConfigStoreClient.prototype.isChainLiteChainAtTimestamp = function (chainId, timestamp) {
|
|
152
|
+
if (timestamp === void 0) { timestamp = Number.MAX_SAFE_INTEGER; }
|
|
142
153
|
return this.getLiteChainIdIndicesForTimestamp(timestamp).includes(chainId);
|
|
143
|
-
}
|
|
144
|
-
getSpokeTargetBalancesForBlock(l1Token, chainId, blockNumber
|
|
145
|
-
|
|
146
|
-
|
|
154
|
+
};
|
|
155
|
+
AcrossConfigStoreClient.prototype.getSpokeTargetBalancesForBlock = function (l1Token, chainId, blockNumber) {
|
|
156
|
+
var _a;
|
|
157
|
+
if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
|
|
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];
|
|
147
160
|
return targetBalance || { target: toBN(0), threshold: toBN(0) };
|
|
148
|
-
}
|
|
161
|
+
};
|
|
149
162
|
// <-- END LEGACY CONFIGURATION OBJECTS -->
|
|
150
|
-
getMaxRefundCountForRelayerRefundLeafForBlock
|
|
151
|
-
|
|
163
|
+
AcrossConfigStoreClient.prototype.getMaxRefundCountForRelayerRefundLeafForBlock = function (blockNumber) {
|
|
164
|
+
if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
|
|
165
|
+
var config = sortEventsDescending(this.cumulativeMaxRefundCountUpdates).find(function (config) { return config.blockNumber <= blockNumber; });
|
|
152
166
|
if (!config) {
|
|
153
|
-
throw new Error(
|
|
167
|
+
throw new Error("Could not find MaxRefundCount before block ".concat(blockNumber));
|
|
154
168
|
}
|
|
155
169
|
return Number(config.value);
|
|
156
|
-
}
|
|
157
|
-
getMaxL1TokenCountForPoolRebalanceLeafForBlock
|
|
158
|
-
|
|
170
|
+
};
|
|
171
|
+
AcrossConfigStoreClient.prototype.getMaxL1TokenCountForPoolRebalanceLeafForBlock = function (blockNumber) {
|
|
172
|
+
if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
|
|
173
|
+
var config = sortEventsDescending(this.cumulativeMaxL1TokenCountUpdates).find(function (config) { return config.blockNumber <= blockNumber; });
|
|
159
174
|
if (!config) {
|
|
160
|
-
throw new Error(
|
|
175
|
+
throw new Error("Could not find MaxL1TokenCount before block ".concat(blockNumber));
|
|
161
176
|
}
|
|
162
177
|
return Number(config.value);
|
|
163
|
-
}
|
|
178
|
+
};
|
|
164
179
|
/**
|
|
165
180
|
* Returns list of chains that have been enabled at least once in the block range.
|
|
166
181
|
* If a chain was disabled in the block range, it will be included in the list provided it was enabled
|
|
@@ -171,25 +186,26 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
171
186
|
* up until `latest`.
|
|
172
187
|
* @returns List of chain IDs that have been enabled at least once in the block range. Sorted from lowest to highest.
|
|
173
188
|
*/
|
|
174
|
-
getEnabledChainsInBlockRange(fromBlock, toBlock
|
|
189
|
+
AcrossConfigStoreClient.prototype.getEnabledChainsInBlockRange = function (fromBlock, toBlock) {
|
|
190
|
+
if (toBlock === void 0) { toBlock = Number.MAX_SAFE_INTEGER; }
|
|
175
191
|
// If our fromBlock is greater than our toBlock, then we have an invalid range.
|
|
176
192
|
if (fromBlock > toBlock) {
|
|
177
|
-
throw new Error(
|
|
193
|
+
throw new Error("Invalid block range: fromBlock ".concat(fromBlock, " > toBlock ").concat(toBlock));
|
|
178
194
|
}
|
|
179
195
|
// Initiate list with all possible chains enabled at the toBlock while removing any chains
|
|
180
196
|
// that were disabled at the from block.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
197
|
+
var disabledChainsAtFromBlock = this.getDisabledChainsForBlock(fromBlock);
|
|
198
|
+
var allPossibleChains = this.getChainIdIndicesForBlock(toBlock);
|
|
199
|
+
var enabledChainsInBlockRange = allPossibleChains.filter(function (chainId) { return !disabledChainsAtFromBlock.includes(chainId); });
|
|
184
200
|
// If there are any disabled chain updates in the block range, then we might need to update the list of enabled
|
|
185
201
|
// chains in the block range.
|
|
186
202
|
this.cumulativeDisabledChainUpdates
|
|
187
|
-
.filter((e)
|
|
188
|
-
.forEach((e)
|
|
203
|
+
.filter(function (e) { return e.blockNumber <= toBlock && e.blockNumber >= fromBlock; })
|
|
204
|
+
.forEach(function (e) {
|
|
189
205
|
// If disabled chain update no longer includes a previously disabled chain, then add it back to the enabled chains
|
|
190
206
|
// list.
|
|
191
|
-
|
|
192
|
-
disabledChainsAtFromBlock.forEach((disabledChain)
|
|
207
|
+
var newDisabledSet = e.chainIds;
|
|
208
|
+
disabledChainsAtFromBlock.forEach(function (disabledChain) {
|
|
193
209
|
// New disabled set doesn't include this chain that was previously disabled so it was re-enabled at this point
|
|
194
210
|
// in the block range.
|
|
195
211
|
if (!newDisabledSet.includes(disabledChain)) {
|
|
@@ -198,297 +214,356 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
198
214
|
});
|
|
199
215
|
});
|
|
200
216
|
// Return the enabled chains in the block range sorted in the same order as the chain indices.
|
|
201
|
-
return allPossibleChains.filter((chainId)
|
|
202
|
-
}
|
|
203
|
-
getEnabledChains
|
|
217
|
+
return allPossibleChains.filter(function (chainId) { return enabledChainsInBlockRange.includes(chainId); });
|
|
218
|
+
};
|
|
219
|
+
AcrossConfigStoreClient.prototype.getEnabledChains = function (block) {
|
|
220
|
+
if (block === void 0) { block = Number.MAX_SAFE_INTEGER; }
|
|
204
221
|
// Get most recent disabled chain list before the block specified.
|
|
205
|
-
|
|
206
|
-
return this.getChainIdIndicesForBlock(block).filter((chainId)
|
|
207
|
-
}
|
|
208
|
-
getDisabledChainsForBlock
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
222
|
+
var currentlyDisabledChains = this.getDisabledChainsForBlock(block);
|
|
223
|
+
return this.getChainIdIndicesForBlock(block).filter(function (chainId) { return !currentlyDisabledChains.includes(chainId); });
|
|
224
|
+
};
|
|
225
|
+
AcrossConfigStoreClient.prototype.getDisabledChainsForBlock = function (blockNumber) {
|
|
226
|
+
var _a, _b;
|
|
227
|
+
if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
|
|
228
|
+
return ((_b = (_a = sortEventsDescending(this.cumulativeDisabledChainUpdates).find(function (config) { return config.blockNumber <= blockNumber; })) === null || _a === void 0 ? void 0 : _a.chainIds) !== null && _b !== void 0 ? _b : []);
|
|
229
|
+
};
|
|
230
|
+
AcrossConfigStoreClient.prototype.getConfigStoreVersionForTimestamp = function (timestamp) {
|
|
231
|
+
if (timestamp === void 0) { timestamp = Number.MAX_SAFE_INTEGER; }
|
|
232
|
+
var config = this.cumulativeConfigStoreVersionUpdates.find(function (config) { return config.timestamp <= timestamp; });
|
|
214
233
|
return isDefined(config) ? Number(config.value) : DEFAULT_CONFIG_STORE_VERSION;
|
|
215
|
-
}
|
|
216
|
-
getConfigStoreVersionForBlock
|
|
217
|
-
|
|
234
|
+
};
|
|
235
|
+
AcrossConfigStoreClient.prototype.getConfigStoreVersionForBlock = function (blockNumber) {
|
|
236
|
+
if (blockNumber === void 0) { blockNumber = Number.MAX_SAFE_INTEGER; }
|
|
237
|
+
var config = this.cumulativeConfigStoreVersionUpdates.find(function (config) { return config.blockNumber <= blockNumber; });
|
|
218
238
|
return isDefined(config) ? Number(config.value) : DEFAULT_CONFIG_STORE_VERSION;
|
|
219
|
-
}
|
|
220
|
-
hasValidConfigStoreVersionForTimestamp
|
|
221
|
-
|
|
239
|
+
};
|
|
240
|
+
AcrossConfigStoreClient.prototype.hasValidConfigStoreVersionForTimestamp = function (timestamp) {
|
|
241
|
+
if (timestamp === void 0) { timestamp = Number.MAX_SAFE_INTEGER; }
|
|
242
|
+
var version = this.getConfigStoreVersionForTimestamp(timestamp);
|
|
222
243
|
return this.configStoreVersion >= version;
|
|
223
|
-
}
|
|
244
|
+
};
|
|
224
245
|
/**
|
|
225
246
|
* Resolve the chain ID for the ConfigStore Provider instance.
|
|
226
247
|
* @dev When the provider is a StatisJsonRpcProvider instance, the getNetwork() is non-blocking.
|
|
227
248
|
* @returns Chain ID for the ConfigStore deployment.
|
|
228
249
|
*/
|
|
229
|
-
|
|
230
|
-
return this
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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 });
|
|
290
|
-
}
|
|
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
|
-
});
|
|
250
|
+
AcrossConfigStoreClient.prototype.resolveChainId = function () {
|
|
251
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
252
|
+
var _a;
|
|
253
|
+
var _b;
|
|
254
|
+
return __generator(this, function (_c) {
|
|
255
|
+
switch (_c.label) {
|
|
256
|
+
case 0:
|
|
257
|
+
if (!((_b = this.chainId) !== null && _b !== void 0)) return [3 /*break*/, 1];
|
|
258
|
+
_a = _b;
|
|
259
|
+
return [3 /*break*/, 3];
|
|
260
|
+
case 1: return [4 /*yield*/, this.configStore.provider.getNetwork()];
|
|
261
|
+
case 2:
|
|
262
|
+
_a = (_c.sent()).chainId;
|
|
263
|
+
_c.label = 3;
|
|
264
|
+
case 3: return [2 /*return*/, _a];
|
|
305
265
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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.`,
|
|
374
|
-
});
|
|
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}`,
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
AcrossConfigStoreClient.prototype._update = function () {
|
|
270
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
271
|
+
var chainId, searchConfig, reason, _a, updatedTokenConfigEvents, updatedGlobalConfigEvents, updatedTokenConfigSortableEvents, updatedGlobalConfigSortableEvents, globalConfigUpdateTimes;
|
|
272
|
+
var _this = this;
|
|
273
|
+
return __generator(this, function (_b) {
|
|
274
|
+
switch (_b.label) {
|
|
275
|
+
case 0: return [4 /*yield*/, this.resolveChainId()];
|
|
276
|
+
case 1:
|
|
277
|
+
chainId = _b.sent();
|
|
278
|
+
return [4 /*yield*/, this.updateSearchConfig(this.configStore.provider)];
|
|
279
|
+
case 2:
|
|
280
|
+
searchConfig = _b.sent();
|
|
281
|
+
if (isUpdateFailureReason(searchConfig)) {
|
|
282
|
+
reason = searchConfig;
|
|
283
|
+
return [2 /*return*/, { success: false, reason: reason }];
|
|
284
|
+
}
|
|
285
|
+
this.logger.debug({ at: "AcrossConfigStore", message: "Updating ConfigStore client", searchConfig: searchConfig });
|
|
286
|
+
return [4 /*yield*/, Promise.all([
|
|
287
|
+
paginatedEventQuery(this.configStore, this.configStore.filters.UpdatedTokenConfig(), searchConfig),
|
|
288
|
+
paginatedEventQuery(this.configStore, this.configStore.filters.UpdatedGlobalConfig(), searchConfig),
|
|
289
|
+
])];
|
|
290
|
+
case 3:
|
|
291
|
+
_a = _b.sent(), updatedTokenConfigEvents = _a[0], updatedGlobalConfigEvents = _a[1];
|
|
292
|
+
updatedTokenConfigSortableEvents = updatedTokenConfigEvents.map(spreadEventWithBlockNumber);
|
|
293
|
+
updatedGlobalConfigSortableEvents = updatedGlobalConfigEvents.map(spreadEventWithBlockNumber);
|
|
294
|
+
// Events *should* normally be received in ascending order, but explicitly enforce the ordering.
|
|
295
|
+
[updatedTokenConfigSortableEvents, updatedGlobalConfigSortableEvents].forEach(function (events) {
|
|
296
|
+
return sortEventsAscendingInPlace(events);
|
|
387
297
|
});
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
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;
|
|
298
|
+
return [4 /*yield*/, Promise.all(updatedGlobalConfigEvents.map(function (event) { return _this.configStore.provider.getBlock(event.blockNumber); }))];
|
|
299
|
+
case 4:
|
|
300
|
+
globalConfigUpdateTimes = (_b.sent()).map(function (block) { return block.timestamp; });
|
|
301
|
+
return [2 /*return*/, {
|
|
302
|
+
success: true,
|
|
303
|
+
chainId: chainId,
|
|
304
|
+
searchEndBlock: searchConfig.to,
|
|
305
|
+
events: {
|
|
306
|
+
updatedTokenConfigEvents: updatedTokenConfigSortableEvents,
|
|
307
|
+
updatedGlobalConfigEvents: updatedGlobalConfigSortableEvents,
|
|
308
|
+
globalConfigUpdateTimes: globalConfigUpdateTimes,
|
|
309
|
+
},
|
|
310
|
+
}];
|
|
411
311
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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*/];
|
|
430
510
|
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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;
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
};
|
|
514
|
+
AcrossConfigStoreClient.prototype.validateTokenConfigUpdate = function (args) {
|
|
515
|
+
var _this = this;
|
|
516
|
+
var value = args.value, key = args.key, txnRef = args.txnRef;
|
|
517
|
+
var parsedValue = parseJSONWithNumericString(value);
|
|
518
|
+
var l1Token = key;
|
|
448
519
|
// Return the following parameters if the TokenConfig update is valid, otherwise throw an error.
|
|
449
520
|
// Remove any config updates with invalid rate models by throwing an error if any part of the TokenConfig
|
|
450
521
|
// is wrong before we push any events into this client's state.
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
522
|
+
var rateModelForToken = undefined;
|
|
523
|
+
var spokeTargetBalances = {};
|
|
524
|
+
var routeRateModel = {};
|
|
454
525
|
// Drop value and key before passing args.
|
|
455
|
-
if (parsedValue
|
|
456
|
-
|
|
457
|
-
assert(this.isValidRateModel(rateModel),
|
|
526
|
+
if ((parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.rateModel) !== undefined) {
|
|
527
|
+
var rateModel = parsedValue.rateModel;
|
|
528
|
+
assert(this.isValidRateModel(rateModel), "Invalid rateModel UBar for ".concat(l1Token, " at transaction ").concat(txnRef, ", ").concat(JSON.stringify(rateModel)));
|
|
458
529
|
rateModelForToken = JSON.stringify(rateModel);
|
|
459
530
|
// Store spokeTargetBalances
|
|
460
|
-
if (parsedValue
|
|
531
|
+
if (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.spokeTargetBalances) {
|
|
461
532
|
// Note: cast is required because fromEntries always produces string keys, despite the function returning a
|
|
462
533
|
// numerical key.
|
|
463
|
-
spokeTargetBalances = Object.fromEntries(Object.entries(parsedValue.spokeTargetBalances).map((
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
534
|
+
spokeTargetBalances = Object.fromEntries(Object.entries(parsedValue.spokeTargetBalances).map(function (_a) {
|
|
535
|
+
var chainId = _a[0], targetBalance = _a[1];
|
|
536
|
+
var target = max(toBN(targetBalance.target), toBN(0));
|
|
537
|
+
var threshold = max(toBN(targetBalance.threshold), toBN(0));
|
|
538
|
+
return [chainId, { target: target, threshold: threshold }];
|
|
467
539
|
}));
|
|
468
540
|
}
|
|
469
541
|
// Store route-specific rate models
|
|
470
|
-
if (parsedValue
|
|
471
|
-
routeRateModel = Object.fromEntries(Object.entries(parsedValue.routeRateModel).map((
|
|
472
|
-
|
|
473
|
-
|
|
542
|
+
if (parsedValue === null || parsedValue === void 0 ? void 0 : parsedValue.routeRateModel) {
|
|
543
|
+
routeRateModel = Object.fromEntries(Object.entries(parsedValue.routeRateModel).map(function (_a) {
|
|
544
|
+
var path = _a[0], routeRateModel = _a[1];
|
|
545
|
+
assert(_this.isValidRateModel(routeRateModel) &&
|
|
546
|
+
"Invalid routeRateModel UBar for ".concat(path, " for ").concat(l1Token, " at transaction ").concat(txnRef, ", ").concat(JSON.stringify(routeRateModel)));
|
|
474
547
|
return [path, JSON.stringify(routeRateModel)];
|
|
475
548
|
}));
|
|
476
549
|
}
|
|
477
550
|
}
|
|
478
551
|
return {
|
|
479
|
-
spokeTargetBalances,
|
|
552
|
+
spokeTargetBalances: spokeTargetBalances,
|
|
480
553
|
rateModel: rateModelForToken,
|
|
481
|
-
routeRateModel,
|
|
554
|
+
routeRateModel: routeRateModel,
|
|
482
555
|
};
|
|
483
|
-
}
|
|
484
|
-
isValidRateModel(rateModel) {
|
|
556
|
+
};
|
|
557
|
+
AcrossConfigStoreClient.prototype.isValidRateModel = function (rateModel) {
|
|
485
558
|
// UBar should be between 0% and 100%.
|
|
486
559
|
return toBN(rateModel.UBar).gt(0) && toBN(rateModel.UBar).lt(toWei("1"));
|
|
487
|
-
}
|
|
488
|
-
filterDisabledChains(disabledChains) {
|
|
560
|
+
};
|
|
561
|
+
AcrossConfigStoreClient.prototype.filterDisabledChains = function (disabledChains) {
|
|
489
562
|
// If any chain ID's are not integers then ignore. UMIP-157 requires that this key cannot include
|
|
490
563
|
// the chain ID 1.
|
|
491
|
-
return disabledChains.filter((chainId)
|
|
492
|
-
}
|
|
493
|
-
|
|
564
|
+
return disabledChains.filter(function (chainId) { return !isNaN(chainId) && Number.isInteger(chainId) && chainId !== 1; });
|
|
565
|
+
};
|
|
566
|
+
return AcrossConfigStoreClient;
|
|
567
|
+
}(BaseAbstractClient));
|
|
568
|
+
export { AcrossConfigStoreClient };
|
|
494
569
|
//# sourceMappingURL=AcrossConfigStoreClient.js.map
|