@across-protocol/sdk 3.0.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/LICENSE +661 -0
- package/README.md +116 -0
- package/dist/cjs/apiClient/abstractClient.d.ts +13 -0
- package/dist/cjs/apiClient/abstractClient.js +17 -0
- package/dist/cjs/apiClient/abstractClient.js.map +1 -0
- package/dist/cjs/apiClient/index.d.ts +2 -0
- package/dist/cjs/apiClient/index.js +11 -0
- package/dist/cjs/apiClient/index.js.map +1 -0
- package/dist/cjs/apiClient/mockedClient.d.ts +11 -0
- package/dist/cjs/apiClient/mockedClient.js +60 -0
- package/dist/cjs/apiClient/mockedClient.js.map +1 -0
- package/dist/cjs/apiClient/productionClient.d.ts +10 -0
- package/dist/cjs/apiClient/productionClient.js +110 -0
- package/dist/cjs/apiClient/productionClient.js.map +1 -0
- package/dist/cjs/apiClient/types.d.ts +44 -0
- package/dist/cjs/apiClient/types.js +3 -0
- package/dist/cjs/apiClient/types.js.map +1 -0
- package/dist/cjs/caching/Arweave/ArweaveClient.d.ts +20 -0
- package/dist/cjs/caching/Arweave/ArweaveClient.js +218 -0
- package/dist/cjs/caching/Arweave/ArweaveClient.js.map +1 -0
- package/dist/cjs/caching/Arweave/index.d.ts +1 -0
- package/dist/cjs/caching/Arweave/index.js +5 -0
- package/dist/cjs/caching/Arweave/index.js.map +1 -0
- package/dist/cjs/caching/IPFS/PinataIPFSClient.d.ts +11 -0
- package/dist/cjs/caching/IPFS/PinataIPFSClient.js +67 -0
- package/dist/cjs/caching/IPFS/PinataIPFSClient.js.map +1 -0
- package/dist/cjs/caching/IPFS/index.d.ts +1 -0
- package/dist/cjs/caching/IPFS/index.js +5 -0
- package/dist/cjs/caching/IPFS/index.js.map +1 -0
- package/dist/cjs/caching/index.d.ts +2 -0
- package/dist/cjs/caching/index.js +6 -0
- package/dist/cjs/caching/index.js.map +1 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +66 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +377 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/index.d.ts +1 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/index.js +5 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/index.js.map +1 -0
- package/dist/cjs/clients/BaseAbstractClient.d.ts +22 -0
- package/dist/cjs/clients/BaseAbstractClient.js +76 -0
- package/dist/cjs/clients/BaseAbstractClient.js.map +1 -0
- package/dist/cjs/clients/HubPoolClient.d.ts +111 -0
- package/dist/cjs/clients/HubPoolClient.js +758 -0
- package/dist/cjs/clients/HubPoolClient.js.map +1 -0
- package/dist/cjs/clients/SpokePoolClient.d.ts +117 -0
- package/dist/cjs/clients/SpokePoolClient.js +553 -0
- package/dist/cjs/clients/SpokePoolClient.js.map +1 -0
- package/dist/cjs/clients/index.d.ts +4 -0
- package/dist/cjs/clients/index.js +14 -0
- package/dist/cjs/clients/index.js.map +1 -0
- package/dist/cjs/clients/mocks/MockConfigStoreClient.d.ts +20 -0
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js +121 -0
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -0
- package/dist/cjs/clients/mocks/MockEvents.d.ts +27 -0
- package/dist/cjs/clients/mocks/MockEvents.js +117 -0
- package/dist/cjs/clients/mocks/MockEvents.js.map +1 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +35 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +222 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -0
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +38 -0
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +319 -0
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -0
- package/dist/cjs/clients/mocks/index.d.ts +3 -0
- package/dist/cjs/clients/mocks/index.js +7 -0
- package/dist/cjs/clients/mocks/index.js.map +1 -0
- package/dist/cjs/coingecko/Coingecko.d.ts +40 -0
- package/dist/cjs/coingecko/Coingecko.js +277 -0
- package/dist/cjs/coingecko/Coingecko.js.map +1 -0
- package/dist/cjs/coingecko/index.d.ts +1 -0
- package/dist/cjs/coingecko/index.js +5 -0
- package/dist/cjs/coingecko/index.js.map +1 -0
- package/dist/cjs/constants.d.ts +18 -0
- package/dist/cjs/constants.js +27 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/contracts/acrossConfigStore.d.ts +57 -0
- package/dist/cjs/contracts/acrossConfigStore.js +65 -0
- package/dist/cjs/contracts/acrossConfigStore.js.map +1 -0
- package/dist/cjs/contracts/hubPool.d.ts +17 -0
- package/dist/cjs/contracts/hubPool.js +61 -0
- package/dist/cjs/contracts/hubPool.js.map +1 -0
- package/dist/cjs/contracts/index.d.ts +2 -0
- package/dist/cjs/contracts/index.js +7 -0
- package/dist/cjs/contracts/index.js.map +1 -0
- package/dist/cjs/contracts/utils.d.ts +15 -0
- package/dist/cjs/contracts/utils.js +40 -0
- package/dist/cjs/contracts/utils.js.map +1 -0
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.d.ts +3 -0
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +25 -0
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -0
- package/dist/cjs/gasPriceOracle/adapters/ethereum.d.ts +4 -0
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js +46 -0
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -0
- package/dist/cjs/gasPriceOracle/adapters/index.d.ts +3 -0
- package/dist/cjs/gasPriceOracle/adapters/index.js +7 -0
- package/dist/cjs/gasPriceOracle/adapters/index.js.map +1 -0
- package/dist/cjs/gasPriceOracle/adapters/polygon.d.ts +3 -0
- package/dist/cjs/gasPriceOracle/adapters/polygon.js +77 -0
- package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -0
- package/dist/cjs/gasPriceOracle/index.d.ts +2 -0
- package/dist/cjs/gasPriceOracle/index.js +6 -0
- package/dist/cjs/gasPriceOracle/index.js.map +1 -0
- package/dist/cjs/gasPriceOracle/oracle.d.ts +3 -0
- package/dist/cjs/gasPriceOracle/oracle.js +45 -0
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -0
- package/dist/cjs/gasPriceOracle/types.d.ts +8 -0
- package/dist/cjs/gasPriceOracle/types.js +3 -0
- package/dist/cjs/gasPriceOracle/types.js.map +1 -0
- package/dist/cjs/gasPriceOracle/util.d.ts +2 -0
- package/dist/cjs/gasPriceOracle/util.js +8 -0
- package/dist/cjs/gasPriceOracle/util.js.map +1 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces/Bridge.d.ts +9 -0
- package/dist/cjs/interfaces/Bridge.js +3 -0
- package/dist/cjs/interfaces/Bridge.js.map +1 -0
- package/dist/cjs/interfaces/CachingMechanism.d.ts +5 -0
- package/dist/cjs/interfaces/CachingMechanism.js +3 -0
- package/dist/cjs/interfaces/CachingMechanism.js.map +1 -0
- package/dist/cjs/interfaces/Common.d.ts +10 -0
- package/dist/cjs/interfaces/Common.js +3 -0
- package/dist/cjs/interfaces/Common.js.map +1 -0
- package/dist/cjs/interfaces/ConfigStore.d.ts +81 -0
- package/dist/cjs/interfaces/ConfigStore.js +3 -0
- package/dist/cjs/interfaces/ConfigStore.js.map +1 -0
- package/dist/cjs/interfaces/Error.d.ts +5 -0
- package/dist/cjs/interfaces/Error.js +3 -0
- package/dist/cjs/interfaces/Error.js.map +1 -0
- package/dist/cjs/interfaces/HubPool.d.ts +98 -0
- package/dist/cjs/interfaces/HubPool.js +3 -0
- package/dist/cjs/interfaces/HubPool.js.map +1 -0
- package/dist/cjs/interfaces/SpokePool.d.ts +103 -0
- package/dist/cjs/interfaces/SpokePool.js +16 -0
- package/dist/cjs/interfaces/SpokePool.js.map +1 -0
- package/dist/cjs/interfaces/TypedData.d.ts +19 -0
- package/dist/cjs/interfaces/TypedData.js +3 -0
- package/dist/cjs/interfaces/TypedData.js.map +1 -0
- package/dist/cjs/interfaces/index.d.ts +8 -0
- package/dist/cjs/interfaces/index.js +12 -0
- package/dist/cjs/interfaces/index.js.map +1 -0
- package/dist/cjs/lpFeeCalculator/index.d.ts +1 -0
- package/dist/cjs/lpFeeCalculator/index.js +5 -0
- package/dist/cjs/lpFeeCalculator/index.js.map +1 -0
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.d.ts +19 -0
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js +79 -0
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js.map +1 -0
- package/dist/cjs/lpFeeCalculator/rateModel.d.ts +28 -0
- package/dist/cjs/lpFeeCalculator/rateModel.js +103 -0
- package/dist/cjs/lpFeeCalculator/rateModel.js.map +1 -0
- package/dist/cjs/merkleDistributor/MerkleDistributor.d.ts +8 -0
- package/dist/cjs/merkleDistributor/MerkleDistributor.js +25 -0
- package/dist/cjs/merkleDistributor/MerkleDistributor.js.map +1 -0
- package/dist/cjs/merkleDistributor/index.d.ts +2 -0
- package/dist/cjs/merkleDistributor/index.js +6 -0
- package/dist/cjs/merkleDistributor/index.js.map +1 -0
- package/dist/cjs/merkleDistributor/model/Distribution.d.ts +17 -0
- package/dist/cjs/merkleDistributor/model/Distribution.js +3 -0
- package/dist/cjs/merkleDistributor/model/Distribution.js.map +1 -0
- package/dist/cjs/merkleDistributor/model/index.d.ts +1 -0
- package/dist/cjs/merkleDistributor/model/index.js +5 -0
- package/dist/cjs/merkleDistributor/model/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/pool/TransactionManager.d.ts +12 -0
- package/dist/cjs/pool/TransactionManager.js +121 -0
- package/dist/cjs/pool/TransactionManager.js.map +1 -0
- package/dist/cjs/pool/index.d.ts +1 -0
- package/dist/cjs/pool/index.js +5 -0
- package/dist/cjs/pool/index.js.map +1 -0
- package/dist/cjs/pool/poolClient.d.ts +232 -0
- package/dist/cjs/pool/poolClient.js +869 -0
- package/dist/cjs/pool/poolClient.js.map +1 -0
- package/dist/cjs/priceClient/adapters/acrossApi.d.ts +13 -0
- package/dist/cjs/priceClient/adapters/acrossApi.js +48 -0
- package/dist/cjs/priceClient/adapters/acrossApi.js.map +1 -0
- package/dist/cjs/priceClient/adapters/baseAdapter.d.ts +17 -0
- package/dist/cjs/priceClient/adapters/baseAdapter.js +81 -0
- package/dist/cjs/priceClient/adapters/baseAdapter.js.map +1 -0
- package/dist/cjs/priceClient/adapters/coingecko.d.ts +14 -0
- package/dist/cjs/priceClient/adapters/coingecko.js +75 -0
- package/dist/cjs/priceClient/adapters/coingecko.js.map +1 -0
- package/dist/cjs/priceClient/adapters/defiLlama.d.ts +17 -0
- package/dist/cjs/priceClient/adapters/defiLlama.js +95 -0
- package/dist/cjs/priceClient/adapters/defiLlama.js.map +1 -0
- package/dist/cjs/priceClient/adapters/index.d.ts +3 -0
- package/dist/cjs/priceClient/adapters/index.js +8 -0
- package/dist/cjs/priceClient/adapters/index.js.map +1 -0
- package/dist/cjs/priceClient/index.d.ts +2 -0
- package/dist/cjs/priceClient/index.js +7 -0
- package/dist/cjs/priceClient/index.js.map +1 -0
- package/dist/cjs/priceClient/priceClient.d.ts +32 -0
- package/dist/cjs/priceClient/priceClient.js +197 -0
- package/dist/cjs/priceClient/priceClient.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +29 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +62 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +151 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +35 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/index.d.ts +3 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js +7 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/polygon.d.ts +152 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/polygon.js +43 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/polygon.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/index.d.ts +2 -0
- package/dist/cjs/relayFeeCalculator/index.js +6 -0
- package/dist/cjs/relayFeeCalculator/index.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +231 -0
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +224 -0
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -0
- package/dist/cjs/typechain.d.ts +17 -0
- package/dist/cjs/typechain.js +20 -0
- package/dist/cjs/typechain.js.map +1 -0
- package/dist/cjs/typeguards/error.d.ts +3 -0
- package/dist/cjs/typeguards/error.js +11 -0
- package/dist/cjs/typeguards/error.js.map +1 -0
- package/dist/cjs/typeguards/index.d.ts +1 -0
- package/dist/cjs/typeguards/index.js +5 -0
- package/dist/cjs/typeguards/index.js.map +1 -0
- package/dist/cjs/utils/AddressUtils.d.ts +2 -0
- package/dist/cjs/utils/AddressUtils.js +24 -0
- package/dist/cjs/utils/AddressUtils.js.map +1 -0
- package/dist/cjs/utils/ArrayUtils.d.ts +12 -0
- package/dist/cjs/utils/ArrayUtils.js +125 -0
- package/dist/cjs/utils/ArrayUtils.js.map +1 -0
- package/dist/cjs/utils/BigNumberUtils.d.ts +8 -0
- package/dist/cjs/utils/BigNumberUtils.js +26 -0
- package/dist/cjs/utils/BigNumberUtils.js.map +1 -0
- package/dist/cjs/utils/BlockExplorerUtils.d.ts +3 -0
- package/dist/cjs/utils/BlockExplorerUtils.js +52 -0
- package/dist/cjs/utils/BlockExplorerUtils.js.map +1 -0
- package/dist/cjs/utils/BlockUtils.d.ts +28 -0
- package/dist/cjs/utils/BlockUtils.js +251 -0
- package/dist/cjs/utils/BlockUtils.js.map +1 -0
- package/dist/cjs/utils/BundleUtils.d.ts +5 -0
- package/dist/cjs/utils/BundleUtils.js +62 -0
- package/dist/cjs/utils/BundleUtils.js.map +1 -0
- package/dist/cjs/utils/CachingUtils.d.ts +5 -0
- package/dist/cjs/utils/CachingUtils.js +59 -0
- package/dist/cjs/utils/CachingUtils.js.map +1 -0
- package/dist/cjs/utils/DeploymentUtils.d.ts +1 -0
- package/dist/cjs/utils/DeploymentUtils.js +8 -0
- package/dist/cjs/utils/DeploymentUtils.js.map +1 -0
- package/dist/cjs/utils/DepositUtils.d.ts +19 -0
- package/dist/cjs/utils/DepositUtils.js +107 -0
- package/dist/cjs/utils/DepositUtils.js.map +1 -0
- package/dist/cjs/utils/EventUtils.d.ts +18 -0
- package/dist/cjs/utils/EventUtils.js +169 -0
- package/dist/cjs/utils/EventUtils.js.map +1 -0
- package/dist/cjs/utils/FlowUtils.d.ts +7 -0
- package/dist/cjs/utils/FlowUtils.js +42 -0
- package/dist/cjs/utils/FlowUtils.js.map +1 -0
- package/dist/cjs/utils/FormattingUtils.d.ts +15 -0
- package/dist/cjs/utils/FormattingUtils.js +107 -0
- package/dist/cjs/utils/FormattingUtils.js.map +1 -0
- package/dist/cjs/utils/IPFSUtils.d.ts +4 -0
- package/dist/cjs/utils/IPFSUtils.js +48 -0
- package/dist/cjs/utils/IPFSUtils.js.map +1 -0
- package/dist/cjs/utils/JSONUtils.d.ts +4 -0
- package/dist/cjs/utils/JSONUtils.js +53 -0
- package/dist/cjs/utils/JSONUtils.js.map +1 -0
- package/dist/cjs/utils/LogUtils.d.ts +14 -0
- package/dist/cjs/utils/LogUtils.js +18 -0
- package/dist/cjs/utils/LogUtils.js.map +1 -0
- package/dist/cjs/utils/Multicall.d.ts +13 -0
- package/dist/cjs/utils/Multicall.js +73 -0
- package/dist/cjs/utils/Multicall.js.map +1 -0
- package/dist/cjs/utils/NetworkUtils.d.ts +10 -0
- package/dist/cjs/utils/NetworkUtils.js +70 -0
- package/dist/cjs/utils/NetworkUtils.js.map +1 -0
- package/dist/cjs/utils/NumberUtils.d.ts +2 -0
- package/dist/cjs/utils/NumberUtils.js +12 -0
- package/dist/cjs/utils/NumberUtils.js.map +1 -0
- package/dist/cjs/utils/ObjectUtils.d.ts +5 -0
- package/dist/cjs/utils/ObjectUtils.js +65 -0
- package/dist/cjs/utils/ObjectUtils.js.map +1 -0
- package/dist/cjs/utils/ReviverUtils.d.ts +3 -0
- package/dist/cjs/utils/ReviverUtils.js +23 -0
- package/dist/cjs/utils/ReviverUtils.js.map +1 -0
- package/dist/cjs/utils/SpokeUtils.d.ts +16 -0
- package/dist/cjs/utils/SpokeUtils.js +299 -0
- package/dist/cjs/utils/SpokeUtils.js.map +1 -0
- package/dist/cjs/utils/TimeUtils.d.ts +1 -0
- package/dist/cjs/utils/TimeUtils.js +8 -0
- package/dist/cjs/utils/TimeUtils.js.map +1 -0
- package/dist/cjs/utils/TokenUtils.d.ts +303 -0
- package/dist/cjs/utils/TokenUtils.js +74 -0
- package/dist/cjs/utils/TokenUtils.js.map +1 -0
- package/dist/cjs/utils/TypeGuards.d.ts +3 -0
- package/dist/cjs/utils/TypeGuards.js +16 -0
- package/dist/cjs/utils/TypeGuards.js.map +1 -0
- package/dist/cjs/utils/TypeUtils.d.ts +5 -0
- package/dist/cjs/utils/TypeUtils.js +3 -0
- package/dist/cjs/utils/TypeUtils.js.map +1 -0
- package/dist/cjs/utils/V3Utils.d.ts +4 -0
- package/dist/cjs/utils/V3Utils.js +15 -0
- package/dist/cjs/utils/V3Utils.js.map +1 -0
- package/dist/cjs/utils/ValidatorUtils.d.ts +2 -0
- package/dist/cjs/utils/ValidatorUtils.js +39 -0
- package/dist/cjs/utils/ValidatorUtils.js.map +1 -0
- package/dist/cjs/utils/abi/contracts/Multicall3.json +440 -0
- package/dist/cjs/utils/abi/index.d.ts +3 -0
- package/dist/cjs/utils/abi/index.js +31 -0
- package/dist/cjs/utils/abi/index.js.map +1 -0
- package/dist/cjs/utils/common.d.ts +79 -0
- package/dist/cjs/utils/common.js +220 -0
- package/dist/cjs/utils/common.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +29 -0
- package/dist/cjs/utils/index.js +33 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/esm/apiClient/abstractClient.d.ts +66 -0
- package/dist/esm/apiClient/abstractClient.js +31 -0
- package/dist/esm/apiClient/abstractClient.js.map +1 -0
- package/dist/esm/apiClient/index.d.ts +2 -0
- package/dist/esm/apiClient/index.js +3 -0
- package/dist/esm/apiClient/index.js.map +1 -0
- package/dist/esm/apiClient/mockedClient.d.ts +24 -0
- package/dist/esm/apiClient/mockedClient.js +69 -0
- package/dist/esm/apiClient/mockedClient.js.map +1 -0
- package/dist/esm/apiClient/productionClient.d.ts +16 -0
- package/dist/esm/apiClient/productionClient.js +114 -0
- package/dist/esm/apiClient/productionClient.js.map +1 -0
- package/dist/esm/apiClient/types.d.ts +44 -0
- package/dist/esm/apiClient/types.js +2 -0
- package/dist/esm/apiClient/types.js.map +1 -0
- package/dist/esm/caching/Arweave/ArweaveClient.d.ts +61 -0
- package/dist/esm/caching/Arweave/ArweaveClient.js +265 -0
- package/dist/esm/caching/Arweave/ArweaveClient.js.map +1 -0
- package/dist/esm/caching/Arweave/index.d.ts +1 -0
- package/dist/esm/caching/Arweave/index.js +2 -0
- package/dist/esm/caching/Arweave/index.js.map +1 -0
- package/dist/esm/caching/IPFS/PinataIPFSClient.d.ts +37 -0
- package/dist/esm/caching/IPFS/PinataIPFSClient.js +81 -0
- package/dist/esm/caching/IPFS/PinataIPFSClient.js.map +1 -0
- package/dist/esm/caching/IPFS/index.d.ts +1 -0
- package/dist/esm/caching/IPFS/index.js +2 -0
- package/dist/esm/caching/IPFS/index.js.map +1 -0
- package/dist/esm/caching/index.d.ts +2 -0
- package/dist/esm/caching/index.js +3 -0
- package/dist/esm/caching/index.js.map +1 -0
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +108 -0
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +467 -0
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -0
- package/dist/esm/clients/AcrossConfigStoreClient/index.d.ts +1 -0
- package/dist/esm/clients/AcrossConfigStoreClient/index.js +2 -0
- package/dist/esm/clients/AcrossConfigStoreClient/index.js.map +1 -0
- package/dist/esm/clients/BaseAbstractClient.d.ts +51 -0
- package/dist/esm/clients/BaseAbstractClient.js +101 -0
- package/dist/esm/clients/BaseAbstractClient.js.map +1 -0
- package/dist/esm/clients/HubPoolClient.d.ts +134 -0
- package/dist/esm/clients/HubPoolClient.js +862 -0
- package/dist/esm/clients/HubPoolClient.js.map +1 -0
- package/dist/esm/clients/SpokePoolClient.d.ts +318 -0
- package/dist/esm/clients/SpokePoolClient.js +780 -0
- package/dist/esm/clients/SpokePoolClient.js.map +1 -0
- package/dist/esm/clients/index.d.ts +4 -0
- package/dist/esm/clients/index.js +6 -0
- package/dist/esm/clients/index.js.map +1 -0
- package/dist/esm/clients/mocks/MockConfigStoreClient.d.ts +20 -0
- package/dist/esm/clients/mocks/MockConfigStoreClient.js +122 -0
- package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -0
- package/dist/esm/clients/mocks/MockEvents.d.ts +34 -0
- package/dist/esm/clients/mocks/MockEvents.js +126 -0
- package/dist/esm/clients/mocks/MockEvents.js.map +1 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +35 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.js +223 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -0
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +38 -0
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +322 -0
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -0
- package/dist/esm/clients/mocks/index.d.ts +3 -0
- package/dist/esm/clients/mocks/index.js +4 -0
- package/dist/esm/clients/mocks/index.js.map +1 -0
- package/dist/esm/coingecko/Coingecko.d.ts +40 -0
- package/dist/esm/coingecko/Coingecko.js +283 -0
- package/dist/esm/coingecko/Coingecko.js.map +1 -0
- package/dist/esm/coingecko/index.d.ts +1 -0
- package/dist/esm/coingecko/index.js +2 -0
- package/dist/esm/coingecko/index.js.map +1 -0
- package/dist/esm/constants.d.ts +29 -0
- package/dist/esm/constants.js +34 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/contracts/acrossConfigStore.d.ts +57 -0
- package/dist/esm/contracts/acrossConfigStore.js +62 -0
- package/dist/esm/contracts/acrossConfigStore.js.map +1 -0
- package/dist/esm/contracts/hubPool.d.ts +17 -0
- package/dist/esm/contracts/hubPool.js +55 -0
- package/dist/esm/contracts/hubPool.js.map +1 -0
- package/dist/esm/contracts/index.d.ts +2 -0
- package/dist/esm/contracts/index.js +5 -0
- package/dist/esm/contracts/index.js.map +1 -0
- package/dist/esm/contracts/utils.d.ts +23 -0
- package/dist/esm/contracts/utils.js +38 -0
- package/dist/esm/contracts/utils.js.map +1 -0
- package/dist/esm/gasPriceOracle/adapters/arbitrum.d.ts +3 -0
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js +25 -0
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -0
- package/dist/esm/gasPriceOracle/adapters/ethereum.d.ts +4 -0
- package/dist/esm/gasPriceOracle/adapters/ethereum.js +41 -0
- package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -0
- package/dist/esm/gasPriceOracle/adapters/index.d.ts +3 -0
- package/dist/esm/gasPriceOracle/adapters/index.js +4 -0
- package/dist/esm/gasPriceOracle/adapters/index.js.map +1 -0
- package/dist/esm/gasPriceOracle/adapters/polygon.d.ts +3 -0
- package/dist/esm/gasPriceOracle/adapters/polygon.js +78 -0
- package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -0
- package/dist/esm/gasPriceOracle/index.d.ts +2 -0
- package/dist/esm/gasPriceOracle/index.js +2 -0
- package/dist/esm/gasPriceOracle/index.js.map +1 -0
- package/dist/esm/gasPriceOracle/oracle.d.ts +10 -0
- package/dist/esm/gasPriceOracle/oracle.js +48 -0
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -0
- package/dist/esm/gasPriceOracle/types.d.ts +8 -0
- package/dist/esm/gasPriceOracle/types.js +2 -0
- package/dist/esm/gasPriceOracle/types.js.map +1 -0
- package/dist/esm/gasPriceOracle/util.d.ts +2 -0
- package/dist/esm/gasPriceOracle/util.js +4 -0
- package/dist/esm/gasPriceOracle/util.js.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +31 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interfaces/Bridge.d.ts +9 -0
- package/dist/esm/interfaces/Bridge.js +2 -0
- package/dist/esm/interfaces/Bridge.js.map +1 -0
- package/dist/esm/interfaces/CachingMechanism.d.ts +26 -0
- package/dist/esm/interfaces/CachingMechanism.js +2 -0
- package/dist/esm/interfaces/CachingMechanism.js.map +1 -0
- package/dist/esm/interfaces/Common.d.ts +10 -0
- package/dist/esm/interfaces/Common.js +2 -0
- package/dist/esm/interfaces/Common.js.map +1 -0
- package/dist/esm/interfaces/ConfigStore.d.ts +157 -0
- package/dist/esm/interfaces/ConfigStore.js +2 -0
- package/dist/esm/interfaces/ConfigStore.js.map +1 -0
- package/dist/esm/interfaces/Error.d.ts +5 -0
- package/dist/esm/interfaces/Error.js +2 -0
- package/dist/esm/interfaces/Error.js.map +1 -0
- package/dist/esm/interfaces/HubPool.d.ts +98 -0
- package/dist/esm/interfaces/HubPool.js +2 -0
- package/dist/esm/interfaces/HubPool.js.map +1 -0
- package/dist/esm/interfaces/SpokePool.d.ts +103 -0
- package/dist/esm/interfaces/SpokePool.js +13 -0
- package/dist/esm/interfaces/SpokePool.js.map +1 -0
- package/dist/esm/interfaces/TypedData.d.ts +19 -0
- package/dist/esm/interfaces/TypedData.js +2 -0
- package/dist/esm/interfaces/TypedData.js.map +1 -0
- package/dist/esm/interfaces/index.d.ts +8 -0
- package/dist/esm/interfaces/index.js +9 -0
- package/dist/esm/interfaces/index.js.map +1 -0
- package/dist/esm/lpFeeCalculator/index.d.ts +1 -0
- package/dist/esm/lpFeeCalculator/index.js +2 -0
- package/dist/esm/lpFeeCalculator/index.js.map +1 -0
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.d.ts +66 -0
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.js +129 -0
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.js.map +1 -0
- package/dist/esm/lpFeeCalculator/rateModel.d.ts +45 -0
- package/dist/esm/lpFeeCalculator/rateModel.js +138 -0
- package/dist/esm/lpFeeCalculator/rateModel.js.map +1 -0
- package/dist/esm/merkleDistributor/MerkleDistributor.d.ts +20 -0
- package/dist/esm/merkleDistributor/MerkleDistributor.js +34 -0
- package/dist/esm/merkleDistributor/MerkleDistributor.js.map +1 -0
- package/dist/esm/merkleDistributor/index.d.ts +2 -0
- package/dist/esm/merkleDistributor/index.js +3 -0
- package/dist/esm/merkleDistributor/index.js.map +1 -0
- package/dist/esm/merkleDistributor/model/Distribution.d.ts +17 -0
- package/dist/esm/merkleDistributor/model/Distribution.js +2 -0
- package/dist/esm/merkleDistributor/model/Distribution.js.map +1 -0
- package/dist/esm/merkleDistributor/model/index.d.ts +1 -0
- package/dist/esm/merkleDistributor/model/index.js +2 -0
- package/dist/esm/merkleDistributor/model/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/pool/TransactionManager.d.ts +12 -0
- package/dist/esm/pool/TransactionManager.js +122 -0
- package/dist/esm/pool/TransactionManager.js.map +1 -0
- package/dist/esm/pool/index.d.ts +1 -0
- package/dist/esm/pool/index.js +2 -0
- package/dist/esm/pool/index.js.map +1 -0
- package/dist/esm/pool/poolClient.d.ts +242 -0
- package/dist/esm/pool/poolClient.js +899 -0
- package/dist/esm/pool/poolClient.js.map +1 -0
- package/dist/esm/priceClient/adapters/acrossApi.d.ts +14 -0
- package/dist/esm/priceClient/adapters/acrossApi.js +49 -0
- package/dist/esm/priceClient/adapters/acrossApi.js.map +1 -0
- package/dist/esm/priceClient/adapters/baseAdapter.d.ts +17 -0
- package/dist/esm/priceClient/adapters/baseAdapter.js +78 -0
- package/dist/esm/priceClient/adapters/baseAdapter.js.map +1 -0
- package/dist/esm/priceClient/adapters/coingecko.d.ts +14 -0
- package/dist/esm/priceClient/adapters/coingecko.js +73 -0
- package/dist/esm/priceClient/adapters/coingecko.js.map +1 -0
- package/dist/esm/priceClient/adapters/defiLlama.d.ts +17 -0
- package/dist/esm/priceClient/adapters/defiLlama.js +93 -0
- package/dist/esm/priceClient/adapters/defiLlama.js.map +1 -0
- package/dist/esm/priceClient/adapters/index.d.ts +3 -0
- package/dist/esm/priceClient/adapters/index.js +7 -0
- package/dist/esm/priceClient/adapters/index.js.map +1 -0
- package/dist/esm/priceClient/index.d.ts +2 -0
- package/dist/esm/priceClient/index.js +4 -0
- package/dist/esm/priceClient/index.js.map +1 -0
- package/dist/esm/priceClient/priceClient.d.ts +32 -0
- package/dist/esm/priceClient/priceClient.js +206 -0
- package/dist/esm/priceClient/priceClient.js.map +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +61 -0
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +91 -0
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +151 -0
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +38 -0
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/index.d.ts +3 -0
- package/dist/esm/relayFeeCalculator/chain-queries/index.js +4 -0
- package/dist/esm/relayFeeCalculator/chain-queries/index.js.map +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/polygon.d.ts +152 -0
- package/dist/esm/relayFeeCalculator/chain-queries/polygon.js +40 -0
- package/dist/esm/relayFeeCalculator/chain-queries/polygon.js.map +1 -0
- package/dist/esm/relayFeeCalculator/index.d.ts +2 -0
- package/dist/esm/relayFeeCalculator/index.js +3 -0
- package/dist/esm/relayFeeCalculator/index.js.map +1 -0
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +282 -0
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +298 -0
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -0
- package/dist/esm/typechain.d.ts +22 -0
- package/dist/esm/typechain.js +9 -0
- package/dist/esm/typechain.js.map +1 -0
- package/dist/esm/typeguards/error.d.ts +3 -0
- package/dist/esm/typeguards/error.js +6 -0
- package/dist/esm/typeguards/error.js.map +1 -0
- package/dist/esm/typeguards/index.d.ts +1 -0
- package/dist/esm/typeguards/index.js +2 -0
- package/dist/esm/typeguards/index.js.map +1 -0
- package/dist/esm/utils/AddressUtils.d.ts +8 -0
- package/dist/esm/utils/AddressUtils.js +28 -0
- package/dist/esm/utils/AddressUtils.js.map +1 -0
- package/dist/esm/utils/ArrayUtils.d.ts +98 -0
- package/dist/esm/utils/ArrayUtils.js +196 -0
- package/dist/esm/utils/ArrayUtils.js.map +1 -0
- package/dist/esm/utils/BigNumberUtils.d.ts +31 -0
- package/dist/esm/utils/BigNumberUtils.js +52 -0
- package/dist/esm/utils/BigNumberUtils.js.map +1 -0
- package/dist/esm/utils/BlockExplorerUtils.d.ts +21 -0
- package/dist/esm/utils/BlockExplorerUtils.js +91 -0
- package/dist/esm/utils/BlockExplorerUtils.js.map +1 -0
- package/dist/esm/utils/BlockUtils.d.ts +46 -0
- package/dist/esm/utils/BlockUtils.js +294 -0
- package/dist/esm/utils/BlockUtils.js.map +1 -0
- package/dist/esm/utils/BundleUtils.d.ts +29 -0
- package/dist/esm/utils/BundleUtils.js +89 -0
- package/dist/esm/utils/BundleUtils.js.map +1 -0
- package/dist/esm/utils/CachingUtils.d.ts +17 -0
- package/dist/esm/utils/CachingUtils.js +66 -0
- package/dist/esm/utils/CachingUtils.js.map +1 -0
- package/dist/esm/utils/DeploymentUtils.d.ts +1 -0
- package/dist/esm/utils/DeploymentUtils.js +2 -0
- package/dist/esm/utils/DeploymentUtils.js.map +1 -0
- package/dist/esm/utils/DepositUtils.d.ts +46 -0
- package/dist/esm/utils/DepositUtils.js +138 -0
- package/dist/esm/utils/DepositUtils.js.map +1 -0
- package/dist/esm/utils/EventUtils.d.ts +32 -0
- package/dist/esm/utils/EventUtils.js +194 -0
- package/dist/esm/utils/EventUtils.js.map +1 -0
- package/dist/esm/utils/FlowUtils.d.ts +8 -0
- package/dist/esm/utils/FlowUtils.js +39 -0
- package/dist/esm/utils/FlowUtils.js.map +1 -0
- package/dist/esm/utils/FormattingUtils.d.ts +61 -0
- package/dist/esm/utils/FormattingUtils.js +167 -0
- package/dist/esm/utils/FormattingUtils.js.map +1 -0
- package/dist/esm/utils/IPFSUtils.d.ts +24 -0
- package/dist/esm/utils/IPFSUtils.js +65 -0
- package/dist/esm/utils/IPFSUtils.js.map +1 -0
- package/dist/esm/utils/JSONUtils.d.ts +31 -0
- package/dist/esm/utils/JSONUtils.js +82 -0
- package/dist/esm/utils/JSONUtils.js.map +1 -0
- package/dist/esm/utils/LogUtils.d.ts +20 -0
- package/dist/esm/utils/LogUtils.js +19 -0
- package/dist/esm/utils/LogUtils.js.map +1 -0
- package/dist/esm/utils/Multicall.d.ts +13 -0
- package/dist/esm/utils/Multicall.js +70 -0
- package/dist/esm/utils/Multicall.js.map +1 -0
- package/dist/esm/utils/NetworkUtils.d.ts +60 -0
- package/dist/esm/utils/NetworkUtils.js +109 -0
- package/dist/esm/utils/NetworkUtils.js.map +1 -0
- package/dist/esm/utils/NumberUtils.d.ts +12 -0
- package/dist/esm/utils/NumberUtils.js +17 -0
- package/dist/esm/utils/NumberUtils.js.map +1 -0
- package/dist/esm/utils/ObjectUtils.d.ts +10 -0
- package/dist/esm/utils/ObjectUtils.js +72 -0
- package/dist/esm/utils/ObjectUtils.js.map +1 -0
- package/dist/esm/utils/ReviverUtils.d.ts +15 -0
- package/dist/esm/utils/ReviverUtils.js +33 -0
- package/dist/esm/utils/ReviverUtils.js.map +1 -0
- package/dist/esm/utils/SpokeUtils.d.ts +64 -0
- package/dist/esm/utils/SpokeUtils.js +370 -0
- package/dist/esm/utils/SpokeUtils.js.map +1 -0
- package/dist/esm/utils/TimeUtils.d.ts +5 -0
- package/dist/esm/utils/TimeUtils.js +8 -0
- package/dist/esm/utils/TimeUtils.js.map +1 -0
- package/dist/esm/utils/TokenUtils.d.ts +325 -0
- package/dist/esm/utils/TokenUtils.js +88 -0
- package/dist/esm/utils/TokenUtils.js.map +1 -0
- package/dist/esm/utils/TypeGuards.d.ts +3 -0
- package/dist/esm/utils/TypeGuards.js +10 -0
- package/dist/esm/utils/TypeGuards.js.map +1 -0
- package/dist/esm/utils/TypeUtils.d.ts +5 -0
- package/dist/esm/utils/TypeUtils.js +2 -0
- package/dist/esm/utils/TypeUtils.js.map +1 -0
- package/dist/esm/utils/V3Utils.d.ts +4 -0
- package/dist/esm/utils/V3Utils.js +10 -0
- package/dist/esm/utils/V3Utils.js.map +1 -0
- package/dist/esm/utils/ValidatorUtils.d.ts +2 -0
- package/dist/esm/utils/ValidatorUtils.js +35 -0
- package/dist/esm/utils/ValidatorUtils.js.map +1 -0
- package/dist/esm/utils/abi/contracts/Multicall3.json +440 -0
- package/dist/esm/utils/abi/index.d.ts +18 -0
- package/dist/esm/utils/abi/index.js +41 -0
- package/dist/esm/utils/abi/index.js.map +1 -0
- package/dist/esm/utils/common.d.ts +204 -0
- package/dist/esm/utils/common.js +325 -0
- package/dist/esm/utils/common.js.map +1 -0
- package/dist/esm/utils/index.d.ts +29 -0
- package/dist/esm/utils/index.js +30 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/types/apiClient/abstractClient.d.ts +67 -0
- package/dist/types/apiClient/abstractClient.d.ts.map +1 -0
- package/dist/types/apiClient/index.d.ts +3 -0
- package/dist/types/apiClient/index.d.ts.map +1 -0
- package/dist/types/apiClient/mockedClient.d.ts +25 -0
- package/dist/types/apiClient/mockedClient.d.ts.map +1 -0
- package/dist/types/apiClient/productionClient.d.ts +17 -0
- package/dist/types/apiClient/productionClient.d.ts.map +1 -0
- package/dist/types/apiClient/types.d.ts +45 -0
- package/dist/types/apiClient/types.d.ts.map +1 -0
- package/dist/types/caching/Arweave/ArweaveClient.d.ts +62 -0
- package/dist/types/caching/Arweave/ArweaveClient.d.ts.map +1 -0
- package/dist/types/caching/Arweave/index.d.ts +2 -0
- package/dist/types/caching/Arweave/index.d.ts.map +1 -0
- package/dist/types/caching/IPFS/PinataIPFSClient.d.ts +38 -0
- package/dist/types/caching/IPFS/PinataIPFSClient.d.ts.map +1 -0
- package/dist/types/caching/IPFS/index.d.ts +2 -0
- package/dist/types/caching/IPFS/index.d.ts.map +1 -0
- package/dist/types/caching/index.d.ts +3 -0
- package/dist/types/caching/index.d.ts.map +1 -0
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +109 -0
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -0
- package/dist/types/clients/AcrossConfigStoreClient/index.d.ts +2 -0
- package/dist/types/clients/AcrossConfigStoreClient/index.d.ts.map +1 -0
- package/dist/types/clients/BaseAbstractClient.d.ts +52 -0
- package/dist/types/clients/BaseAbstractClient.d.ts.map +1 -0
- package/dist/types/clients/HubPoolClient.d.ts +135 -0
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -0
- package/dist/types/clients/SpokePoolClient.d.ts +319 -0
- package/dist/types/clients/SpokePoolClient.d.ts.map +1 -0
- package/dist/types/clients/index.d.ts +5 -0
- package/dist/types/clients/index.d.ts.map +1 -0
- package/dist/types/clients/mocks/MockConfigStoreClient.d.ts +21 -0
- package/dist/types/clients/mocks/MockConfigStoreClient.d.ts.map +1 -0
- package/dist/types/clients/mocks/MockEvents.d.ts +35 -0
- package/dist/types/clients/mocks/MockEvents.d.ts.map +1 -0
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +36 -0
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -0
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +39 -0
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -0
- package/dist/types/clients/mocks/index.d.ts +4 -0
- package/dist/types/clients/mocks/index.d.ts.map +1 -0
- package/dist/types/coingecko/Coingecko.d.ts +41 -0
- package/dist/types/coingecko/Coingecko.d.ts.map +1 -0
- package/dist/types/coingecko/index.d.ts +2 -0
- package/dist/types/coingecko/index.d.ts.map +1 -0
- package/dist/types/constants.d.ts +30 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/contracts/acrossConfigStore.d.ts +58 -0
- package/dist/types/contracts/acrossConfigStore.d.ts.map +1 -0
- package/dist/types/contracts/hubPool.d.ts +18 -0
- package/dist/types/contracts/hubPool.d.ts.map +1 -0
- package/dist/types/contracts/index.d.ts +3 -0
- package/dist/types/contracts/index.d.ts.map +1 -0
- package/dist/types/contracts/utils.d.ts +24 -0
- package/dist/types/contracts/utils.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts +4 -0
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts +5 -0
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/adapters/index.d.ts +4 -0
- package/dist/types/gasPriceOracle/adapters/index.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/adapters/polygon.d.ts +4 -0
- package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/index.d.ts +3 -0
- package/dist/types/gasPriceOracle/index.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/oracle.d.ts +11 -0
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/types.d.ts +9 -0
- package/dist/types/gasPriceOracle/types.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/util.d.ts +3 -0
- package/dist/types/gasPriceOracle/util.d.ts.map +1 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/interfaces/Bridge.d.ts +10 -0
- package/dist/types/interfaces/Bridge.d.ts.map +1 -0
- package/dist/types/interfaces/CachingMechanism.d.ts +27 -0
- package/dist/types/interfaces/CachingMechanism.d.ts.map +1 -0
- package/dist/types/interfaces/Common.d.ts +11 -0
- package/dist/types/interfaces/Common.d.ts.map +1 -0
- package/dist/types/interfaces/ConfigStore.d.ts +158 -0
- package/dist/types/interfaces/ConfigStore.d.ts.map +1 -0
- package/dist/types/interfaces/Error.d.ts +6 -0
- package/dist/types/interfaces/Error.d.ts.map +1 -0
- package/dist/types/interfaces/HubPool.d.ts +99 -0
- package/dist/types/interfaces/HubPool.d.ts.map +1 -0
- package/dist/types/interfaces/SpokePool.d.ts +104 -0
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -0
- package/dist/types/interfaces/TypedData.d.ts +20 -0
- package/dist/types/interfaces/TypedData.d.ts.map +1 -0
- package/dist/types/interfaces/index.d.ts +9 -0
- package/dist/types/interfaces/index.d.ts.map +1 -0
- package/dist/types/lpFeeCalculator/index.d.ts +2 -0
- package/dist/types/lpFeeCalculator/index.d.ts.map +1 -0
- package/dist/types/lpFeeCalculator/lpFeeCalculator.d.ts +67 -0
- package/dist/types/lpFeeCalculator/lpFeeCalculator.d.ts.map +1 -0
- package/dist/types/lpFeeCalculator/rateModel.d.ts +46 -0
- package/dist/types/lpFeeCalculator/rateModel.d.ts.map +1 -0
- package/dist/types/merkleDistributor/MerkleDistributor.d.ts +21 -0
- package/dist/types/merkleDistributor/MerkleDistributor.d.ts.map +1 -0
- package/dist/types/merkleDistributor/index.d.ts +3 -0
- package/dist/types/merkleDistributor/index.d.ts.map +1 -0
- package/dist/types/merkleDistributor/model/Distribution.d.ts +18 -0
- package/dist/types/merkleDistributor/model/Distribution.d.ts.map +1 -0
- package/dist/types/merkleDistributor/model/index.d.ts +2 -0
- package/dist/types/merkleDistributor/model/index.d.ts.map +1 -0
- package/dist/types/pool/TransactionManager.d.ts +13 -0
- package/dist/types/pool/TransactionManager.d.ts.map +1 -0
- package/dist/types/pool/index.d.ts +2 -0
- package/dist/types/pool/index.d.ts.map +1 -0
- package/dist/types/pool/poolClient.d.ts +243 -0
- package/dist/types/pool/poolClient.d.ts.map +1 -0
- package/dist/types/priceClient/adapters/acrossApi.d.ts +15 -0
- package/dist/types/priceClient/adapters/acrossApi.d.ts.map +1 -0
- package/dist/types/priceClient/adapters/baseAdapter.d.ts +18 -0
- package/dist/types/priceClient/adapters/baseAdapter.d.ts.map +1 -0
- package/dist/types/priceClient/adapters/coingecko.d.ts +15 -0
- package/dist/types/priceClient/adapters/coingecko.d.ts.map +1 -0
- package/dist/types/priceClient/adapters/defiLlama.d.ts +18 -0
- package/dist/types/priceClient/adapters/defiLlama.d.ts.map +1 -0
- package/dist/types/priceClient/adapters/index.d.ts +4 -0
- package/dist/types/priceClient/adapters/index.d.ts.map +1 -0
- package/dist/types/priceClient/index.d.ts +3 -0
- package/dist/types/priceClient/index.d.ts.map +1 -0
- package/dist/types/priceClient/priceClient.d.ts +33 -0
- package/dist/types/priceClient/priceClient.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +62 -0
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +152 -0
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/chain-queries/index.d.ts +4 -0
- package/dist/types/relayFeeCalculator/chain-queries/index.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts +153 -0
- package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/index.d.ts +3 -0
- package/dist/types/relayFeeCalculator/index.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +283 -0
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -0
- package/dist/types/typechain.d.ts +23 -0
- package/dist/types/typechain.d.ts.map +1 -0
- package/dist/types/typeguards/error.d.ts +4 -0
- package/dist/types/typeguards/error.d.ts.map +1 -0
- package/dist/types/typeguards/index.d.ts +2 -0
- package/dist/types/typeguards/index.d.ts.map +1 -0
- package/dist/types/utils/AddressUtils.d.ts +9 -0
- package/dist/types/utils/AddressUtils.d.ts.map +1 -0
- package/dist/types/utils/ArrayUtils.d.ts +99 -0
- package/dist/types/utils/ArrayUtils.d.ts.map +1 -0
- package/dist/types/utils/BigNumberUtils.d.ts +32 -0
- package/dist/types/utils/BigNumberUtils.d.ts.map +1 -0
- package/dist/types/utils/BlockExplorerUtils.d.ts +22 -0
- package/dist/types/utils/BlockExplorerUtils.d.ts.map +1 -0
- package/dist/types/utils/BlockUtils.d.ts +47 -0
- package/dist/types/utils/BlockUtils.d.ts.map +1 -0
- package/dist/types/utils/BundleUtils.d.ts +30 -0
- package/dist/types/utils/BundleUtils.d.ts.map +1 -0
- package/dist/types/utils/CachingUtils.d.ts +18 -0
- package/dist/types/utils/CachingUtils.d.ts.map +1 -0
- package/dist/types/utils/DeploymentUtils.d.ts +2 -0
- package/dist/types/utils/DeploymentUtils.d.ts.map +1 -0
- package/dist/types/utils/DepositUtils.d.ts +47 -0
- package/dist/types/utils/DepositUtils.d.ts.map +1 -0
- package/dist/types/utils/EventUtils.d.ts +33 -0
- package/dist/types/utils/EventUtils.d.ts.map +1 -0
- package/dist/types/utils/FlowUtils.d.ts +9 -0
- package/dist/types/utils/FlowUtils.d.ts.map +1 -0
- package/dist/types/utils/FormattingUtils.d.ts +62 -0
- package/dist/types/utils/FormattingUtils.d.ts.map +1 -0
- package/dist/types/utils/IPFSUtils.d.ts +25 -0
- package/dist/types/utils/IPFSUtils.d.ts.map +1 -0
- package/dist/types/utils/JSONUtils.d.ts +32 -0
- package/dist/types/utils/JSONUtils.d.ts.map +1 -0
- package/dist/types/utils/LogUtils.d.ts +21 -0
- package/dist/types/utils/LogUtils.d.ts.map +1 -0
- package/dist/types/utils/Multicall.d.ts +14 -0
- package/dist/types/utils/Multicall.d.ts.map +1 -0
- package/dist/types/utils/NetworkUtils.d.ts +61 -0
- package/dist/types/utils/NetworkUtils.d.ts.map +1 -0
- package/dist/types/utils/NumberUtils.d.ts +13 -0
- package/dist/types/utils/NumberUtils.d.ts.map +1 -0
- package/dist/types/utils/ObjectUtils.d.ts +11 -0
- package/dist/types/utils/ObjectUtils.d.ts.map +1 -0
- package/dist/types/utils/ReviverUtils.d.ts +16 -0
- package/dist/types/utils/ReviverUtils.d.ts.map +1 -0
- package/dist/types/utils/SpokeUtils.d.ts +65 -0
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -0
- package/dist/types/utils/TimeUtils.d.ts +6 -0
- package/dist/types/utils/TimeUtils.d.ts.map +1 -0
- package/dist/types/utils/TokenUtils.d.ts +326 -0
- package/dist/types/utils/TokenUtils.d.ts.map +1 -0
- package/dist/types/utils/TypeGuards.d.ts +4 -0
- package/dist/types/utils/TypeGuards.d.ts.map +1 -0
- package/dist/types/utils/TypeUtils.d.ts +6 -0
- package/dist/types/utils/TypeUtils.d.ts.map +1 -0
- package/dist/types/utils/V3Utils.d.ts +5 -0
- package/dist/types/utils/V3Utils.d.ts.map +1 -0
- package/dist/types/utils/ValidatorUtils.d.ts +3 -0
- package/dist/types/utils/ValidatorUtils.d.ts.map +1 -0
- package/dist/types/utils/abi/index.d.ts +19 -0
- package/dist/types/utils/abi/index.d.ts.map +1 -0
- package/dist/types/utils/common.d.ts +205 -0
- package/dist/types/utils/common.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +30 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +144 -0
- package/src/apiClient/abstractClient.ts +95 -0
- package/src/apiClient/index.ts +2 -0
- package/src/apiClient/mockedClient.ts +90 -0
- package/src/apiClient/productionClient.ts +98 -0
- package/src/apiClient/types.ts +49 -0
- package/src/caching/Arweave/ArweaveClient.ts +238 -0
- package/src/caching/Arweave/index.ts +1 -0
- package/src/caching/IPFS/PinataIPFSClient.ts +92 -0
- package/src/caching/IPFS/index.ts +1 -0
- package/src/caching/index.ts +2 -0
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +526 -0
- package/src/clients/AcrossConfigStoreClient/index.ts +1 -0
- package/src/clients/BaseAbstractClient.ts +94 -0
- package/src/clients/HubPoolClient.ts +1010 -0
- package/src/clients/SpokePoolClient.ts +894 -0
- package/src/clients/index.ts +9 -0
- package/src/clients/mocks/MockConfigStoreClient.ts +129 -0
- package/src/clients/mocks/MockEvents.ts +156 -0
- package/src/clients/mocks/MockHubPoolClient.ts +257 -0
- package/src/clients/mocks/MockSpokePoolClient.ts +341 -0
- package/src/clients/mocks/index.ts +3 -0
- package/src/coingecko/Coingecko.ts +277 -0
- package/src/coingecko/index.ts +1 -0
- package/src/constants.ts +53 -0
- package/src/contracts/acrossConfigStore.ts +49 -0
- package/src/contracts/hubPool.ts +90 -0
- package/src/contracts/index.ts +2 -0
- package/src/contracts/utils.ts +56 -0
- package/src/gasPriceOracle/adapters/arbitrum.ts +21 -0
- package/src/gasPriceOracle/adapters/ethereum.ts +27 -0
- package/src/gasPriceOracle/adapters/index.ts +3 -0
- package/src/gasPriceOracle/adapters/polygon.ts +77 -0
- package/src/gasPriceOracle/index.ts +2 -0
- package/src/gasPriceOracle/oracle.ts +42 -0
- package/src/gasPriceOracle/types.ts +10 -0
- package/src/gasPriceOracle/util.ts +5 -0
- package/src/index.ts +15 -0
- package/src/interfaces/Bridge.ts +10 -0
- package/src/interfaces/CachingMechanism.ts +37 -0
- package/src/interfaces/Common.ts +12 -0
- package/src/interfaces/ConfigStore.ts +173 -0
- package/src/interfaces/Error.ts +5 -0
- package/src/interfaces/HubPool.ts +118 -0
- package/src/interfaces/SpokePool.ts +119 -0
- package/src/interfaces/TypedData.ts +21 -0
- package/src/interfaces/index.ts +8 -0
- package/src/lpFeeCalculator/README.md +27 -0
- package/src/lpFeeCalculator/index.ts +1 -0
- package/src/lpFeeCalculator/lpFeeCalculator.ts +169 -0
- package/src/lpFeeCalculator/rateModel.ts +183 -0
- package/src/merkleDistributor/MerkleDistributor.ts +37 -0
- package/src/merkleDistributor/README.md +30 -0
- package/src/merkleDistributor/index.ts +2 -0
- package/src/merkleDistributor/model/Distribution.ts +17 -0
- package/src/merkleDistributor/model/index.ts +1 -0
- package/src/pool/TransactionManager.ts +73 -0
- package/src/pool/index.ts +1 -0
- package/src/pool/poolClient.ts +840 -0
- package/src/priceClient/README.md +36 -0
- package/src/priceClient/adapters/acrossApi.ts +44 -0
- package/src/priceClient/adapters/baseAdapter.ts +65 -0
- package/src/priceClient/adapters/coingecko.ts +67 -0
- package/src/priceClient/adapters/defiLlama.ts +96 -0
- package/src/priceClient/adapters/index.ts +3 -0
- package/src/priceClient/index.ts +2 -0
- package/src/priceClient/priceClient.ts +192 -0
- package/src/relayFeeCalculator/README.md +34 -0
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +98 -0
- package/src/relayFeeCalculator/chain-queries/factory.ts +58 -0
- package/src/relayFeeCalculator/chain-queries/index.ts +3 -0
- package/src/relayFeeCalculator/chain-queries/polygon.ts +45 -0
- package/src/relayFeeCalculator/index.ts +2 -0
- package/src/relayFeeCalculator/relayFeeCalculator.ts +410 -0
- package/src/typechain.ts +46 -0
- package/src/typeguards/error.ts +7 -0
- package/src/typeguards/index.ts +1 -0
- package/src/utils/AddressUtils.ts +18 -0
- package/src/utils/ArrayUtils.ts +170 -0
- package/src/utils/BigNumberUtils.ts +58 -0
- package/src/utils/BlockExplorerUtils.ts +91 -0
- package/src/utils/BlockUtils.ts +265 -0
- package/src/utils/BundleUtils.ts +109 -0
- package/src/utils/CachingUtils.ts +56 -0
- package/src/utils/DeploymentUtils.ts +5 -0
- package/src/utils/DepositUtils.ts +144 -0
- package/src/utils/EventUtils.ts +227 -0
- package/src/utils/FlowUtils.ts +48 -0
- package/src/utils/FormattingUtils.ts +186 -0
- package/src/utils/IPFSUtils.ts +48 -0
- package/src/utils/JSONUtils.ts +85 -0
- package/src/utils/LogUtils.ts +38 -0
- package/src/utils/Multicall.ts +64 -0
- package/src/utils/NetworkUtils.ts +117 -0
- package/src/utils/NumberUtils.ts +17 -0
- package/src/utils/ObjectUtils.ts +77 -0
- package/src/utils/ReviverUtils.ts +31 -0
- package/src/utils/SpokeUtils.ts +372 -0
- package/src/utils/TimeUtils.ts +7 -0
- package/src/utils/TokenUtils.ts +94 -0
- package/src/utils/TypeGuards.ts +15 -0
- package/src/utils/TypeUtils.ts +9 -0
- package/src/utils/V3Utils.ts +12 -0
- package/src/utils/ValidatorUtils.ts +38 -0
- package/src/utils/abi/contracts/Multicall3.json +440 -0
- package/src/utils/abi/index.ts +33 -0
- package/src/utils/common.ts +392 -0
- package/src/utils/index.ts +29 -0
|
@@ -0,0 +1,1010 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import { BigNumber, Contract, Event, EventFilter } from "ethers";
|
|
3
|
+
import _ from "lodash";
|
|
4
|
+
import winston from "winston";
|
|
5
|
+
import { DEFAULT_CACHING_SAFE_LAG, DEFAULT_CACHING_TTL } from "../constants";
|
|
6
|
+
import {
|
|
7
|
+
CachingMechanismInterface,
|
|
8
|
+
CancelledRootBundle,
|
|
9
|
+
CrossChainContractsSet,
|
|
10
|
+
Deposit,
|
|
11
|
+
DepositWithBlock,
|
|
12
|
+
DestinationTokenWithBlock,
|
|
13
|
+
DisputedRootBundle,
|
|
14
|
+
ExecutedRootBundle,
|
|
15
|
+
L1Token,
|
|
16
|
+
LpToken,
|
|
17
|
+
PendingRootBundle,
|
|
18
|
+
ProposedRootBundle,
|
|
19
|
+
RealizedLpFee,
|
|
20
|
+
SetPoolRebalanceRoot,
|
|
21
|
+
TokenRunningBalance,
|
|
22
|
+
} from "../interfaces";
|
|
23
|
+
import * as lpFeeCalculator from "../lpFeeCalculator";
|
|
24
|
+
import {
|
|
25
|
+
BlockFinder,
|
|
26
|
+
bnZero,
|
|
27
|
+
dedupArray,
|
|
28
|
+
EventSearchConfig,
|
|
29
|
+
MakeOptional,
|
|
30
|
+
assign,
|
|
31
|
+
fetchTokenInfo,
|
|
32
|
+
getCachedBlockForTimestamp,
|
|
33
|
+
getCurrentTime,
|
|
34
|
+
getNetworkName,
|
|
35
|
+
isDefined,
|
|
36
|
+
mapAsync,
|
|
37
|
+
paginatedEventQuery,
|
|
38
|
+
shouldCache,
|
|
39
|
+
sortEventsDescending,
|
|
40
|
+
spreadEvent,
|
|
41
|
+
spreadEventWithBlockNumber,
|
|
42
|
+
toBN,
|
|
43
|
+
} from "../utils";
|
|
44
|
+
import { AcrossConfigStoreClient as ConfigStoreClient } from "./AcrossConfigStoreClient/AcrossConfigStoreClient";
|
|
45
|
+
import { BaseAbstractClient, isUpdateFailureReason, UpdateFailureReason } from "./BaseAbstractClient";
|
|
46
|
+
|
|
47
|
+
type HubPoolUpdateSuccess = {
|
|
48
|
+
success: true;
|
|
49
|
+
currentTime: number;
|
|
50
|
+
pendingRootBundleProposal: PendingRootBundle;
|
|
51
|
+
events: Record<string, Event[]>;
|
|
52
|
+
searchEndBlock: number;
|
|
53
|
+
};
|
|
54
|
+
type HubPoolUpdateFailure = {
|
|
55
|
+
success: false;
|
|
56
|
+
reason: UpdateFailureReason;
|
|
57
|
+
};
|
|
58
|
+
export type HubPoolUpdate = HubPoolUpdateSuccess | HubPoolUpdateFailure;
|
|
59
|
+
|
|
60
|
+
type HubPoolEvent =
|
|
61
|
+
| "SetPoolRebalanceRoute"
|
|
62
|
+
| "L1TokenEnabledForLiquidityProvision"
|
|
63
|
+
| "ProposeRootBundle"
|
|
64
|
+
| "RootBundleCanceled"
|
|
65
|
+
| "RootBundleDisputed"
|
|
66
|
+
| "RootBundleExecuted"
|
|
67
|
+
| "CrossChainContractsSet";
|
|
68
|
+
|
|
69
|
+
type L1TokensToDestinationTokens = {
|
|
70
|
+
[l1Token: string]: { [destinationChainId: number]: string };
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type LpFeeRequest = Pick<Deposit, "originChainId" | "inputToken" | "inputAmount" | "quoteTimestamp"> & {
|
|
74
|
+
paymentChainId?: number;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export class HubPoolClient extends BaseAbstractClient {
|
|
78
|
+
// L1Token -> destinationChainId -> destinationToken
|
|
79
|
+
protected l1TokensToDestinationTokens: L1TokensToDestinationTokens = {};
|
|
80
|
+
protected l1Tokens: L1Token[] = []; // L1Tokens and their associated info.
|
|
81
|
+
protected lpTokens: { [token: string]: LpToken } = {};
|
|
82
|
+
protected proposedRootBundles: ProposedRootBundle[] = [];
|
|
83
|
+
protected canceledRootBundles: CancelledRootBundle[] = [];
|
|
84
|
+
protected disputedRootBundles: DisputedRootBundle[] = [];
|
|
85
|
+
protected executedRootBundles: ExecutedRootBundle[] = [];
|
|
86
|
+
protected crossChainContracts: { [l2ChainId: number]: CrossChainContractsSet[] } = {};
|
|
87
|
+
protected l1TokensToDestinationTokensWithBlock: {
|
|
88
|
+
[l1Token: string]: { [destinationChainId: number]: DestinationTokenWithBlock[] };
|
|
89
|
+
} = {};
|
|
90
|
+
protected pendingRootBundle: PendingRootBundle | undefined;
|
|
91
|
+
|
|
92
|
+
public currentTime: number | undefined;
|
|
93
|
+
public readonly blockFinder: BlockFinder;
|
|
94
|
+
|
|
95
|
+
constructor(
|
|
96
|
+
readonly logger: winston.Logger,
|
|
97
|
+
readonly hubPool: Contract,
|
|
98
|
+
public configStoreClient: ConfigStoreClient,
|
|
99
|
+
public deploymentBlock = 0,
|
|
100
|
+
readonly chainId: number = 1,
|
|
101
|
+
eventSearchConfig: MakeOptional<EventSearchConfig, "toBlock"> = { fromBlock: 0, maxBlockLookBack: 0 },
|
|
102
|
+
protected readonly configOverride: {
|
|
103
|
+
ignoredHubExecutedBundles: number[];
|
|
104
|
+
ignoredHubProposedBundles: number[];
|
|
105
|
+
timeToCache?: number;
|
|
106
|
+
} = {
|
|
107
|
+
ignoredHubExecutedBundles: [],
|
|
108
|
+
ignoredHubProposedBundles: [],
|
|
109
|
+
},
|
|
110
|
+
cachingMechanism?: CachingMechanismInterface
|
|
111
|
+
) {
|
|
112
|
+
super(eventSearchConfig, cachingMechanism);
|
|
113
|
+
this.latestBlockSearched = Math.min(deploymentBlock - 1, 0);
|
|
114
|
+
this.firstBlockToSearch = eventSearchConfig.fromBlock;
|
|
115
|
+
|
|
116
|
+
const provider = this.hubPool.provider;
|
|
117
|
+
this.blockFinder = new BlockFinder(provider);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
protected hubPoolEventFilters(): Record<HubPoolEvent, EventFilter> {
|
|
121
|
+
return {
|
|
122
|
+
SetPoolRebalanceRoute: this.hubPool.filters.SetPoolRebalanceRoute(),
|
|
123
|
+
L1TokenEnabledForLiquidityProvision: this.hubPool.filters.L1TokenEnabledForLiquidityProvision(),
|
|
124
|
+
ProposeRootBundle: this.hubPool.filters.ProposeRootBundle(),
|
|
125
|
+
RootBundleCanceled: this.hubPool.filters.RootBundleCanceled(),
|
|
126
|
+
RootBundleDisputed: this.hubPool.filters.RootBundleDisputed(),
|
|
127
|
+
RootBundleExecuted: this.hubPool.filters.RootBundleExecuted(),
|
|
128
|
+
CrossChainContractsSet: this.hubPool.filters.CrossChainContractsSet(),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
hasPendingProposal(): boolean {
|
|
133
|
+
return this.pendingRootBundle !== undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
getPendingRootBundle(): PendingRootBundle | undefined {
|
|
137
|
+
return this.pendingRootBundle;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
getProposedRootBundles(): ProposedRootBundle[] {
|
|
141
|
+
return this.proposedRootBundles;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
getCancelledRootBundles(): CancelledRootBundle[] {
|
|
145
|
+
return this.canceledRootBundles;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
getDisputedRootBundles(): DisputedRootBundle[] {
|
|
149
|
+
return this.disputedRootBundles;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
getExecutedRootBundles(): ExecutedRootBundle[] {
|
|
153
|
+
return this.executedRootBundles;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
getSpokePoolForBlock(chain: number, block: number = Number.MAX_SAFE_INTEGER): string {
|
|
157
|
+
if (!this.crossChainContracts[chain]) {
|
|
158
|
+
throw new Error(`No cross chain contracts set for ${chain}`);
|
|
159
|
+
}
|
|
160
|
+
const mostRecentSpokePoolUpdateBeforeBlock = (
|
|
161
|
+
sortEventsDescending(this.crossChainContracts[chain]) as CrossChainContractsSet[]
|
|
162
|
+
).find((crossChainContract) => crossChainContract.blockNumber <= block);
|
|
163
|
+
if (!mostRecentSpokePoolUpdateBeforeBlock) {
|
|
164
|
+
throw new Error(`No cross chain contract found before block ${block} for chain ${chain}`);
|
|
165
|
+
} else {
|
|
166
|
+
return mostRecentSpokePoolUpdateBeforeBlock.spokePool;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
getSpokePoolActivationBlock(chain: number, spokePool: string): number | undefined {
|
|
171
|
+
// Return first time that this spoke pool was registered in the HubPool as a cross chain contract. We can use
|
|
172
|
+
// this block as the oldest block that we should query for SpokePoolClient purposes.
|
|
173
|
+
const mostRecentSpokePoolUpdateBeforeBlock = this.crossChainContracts[chain].find(
|
|
174
|
+
(crossChainContract) => crossChainContract.spokePool === spokePool
|
|
175
|
+
);
|
|
176
|
+
return mostRecentSpokePoolUpdateBeforeBlock?.blockNumber;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Returns the latest L2 token to use for an L1 token as of the input hub block.
|
|
180
|
+
getL2TokenForL1TokenAtBlock(
|
|
181
|
+
l1Token: string,
|
|
182
|
+
destinationChainId: number,
|
|
183
|
+
latestHubBlock = Number.MAX_SAFE_INTEGER
|
|
184
|
+
): string {
|
|
185
|
+
if (!this.l1TokensToDestinationTokensWithBlock?.[l1Token]?.[destinationChainId]) {
|
|
186
|
+
const chain = getNetworkName(destinationChainId);
|
|
187
|
+
const { symbol } = this.l1Tokens.find(({ address }) => address === l1Token) ?? { symbol: l1Token };
|
|
188
|
+
throw new Error(`Could not find SpokePool mapping for ${symbol} on ${chain} and L1 token ${l1Token}`);
|
|
189
|
+
}
|
|
190
|
+
// Find the last mapping published before the target block.
|
|
191
|
+
const l2Token: DestinationTokenWithBlock | undefined = sortEventsDescending(
|
|
192
|
+
this.l1TokensToDestinationTokensWithBlock[l1Token][destinationChainId]
|
|
193
|
+
).find((mapping: DestinationTokenWithBlock) => mapping.blockNumber <= latestHubBlock);
|
|
194
|
+
if (!l2Token) {
|
|
195
|
+
const chain = getNetworkName(destinationChainId);
|
|
196
|
+
const { symbol } = this.l1Tokens.find(({ address }) => address === l1Token) ?? { symbol: l1Token };
|
|
197
|
+
throw new Error(
|
|
198
|
+
`Could not find SpokePool mapping for ${symbol} on ${chain} at or before HubPool block ${latestHubBlock}!`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
return l2Token.l2Token;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Returns the latest L1 token to use for an L2 token as of the input hub block.
|
|
205
|
+
getL1TokenForL2TokenAtBlock(
|
|
206
|
+
l2Token: string,
|
|
207
|
+
destinationChainId: number,
|
|
208
|
+
latestHubBlock = Number.MAX_SAFE_INTEGER
|
|
209
|
+
): string {
|
|
210
|
+
const l2Tokens = Object.keys(this.l1TokensToDestinationTokensWithBlock)
|
|
211
|
+
.filter((l1Token) => this.l2TokenEnabledForL1Token(l1Token, destinationChainId))
|
|
212
|
+
.map((l1Token) => {
|
|
213
|
+
// Return all matching L2 token mappings that are equal to or earlier than the target block.
|
|
214
|
+
return this.l1TokensToDestinationTokensWithBlock[l1Token][destinationChainId].filter(
|
|
215
|
+
(mapping) => mapping.l2Token === l2Token && mapping.blockNumber <= latestHubBlock
|
|
216
|
+
);
|
|
217
|
+
})
|
|
218
|
+
.flat();
|
|
219
|
+
if (l2Tokens.length === 0) {
|
|
220
|
+
const chain = getNetworkName(destinationChainId);
|
|
221
|
+
throw new Error(
|
|
222
|
+
`Could not find HubPool mapping for ${l2Token} on ${chain} at or before HubPool block ${latestHubBlock}!`
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
// Find the last mapping published before the target block.
|
|
226
|
+
return sortEventsDescending(l2Tokens)[0].l1Token;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Returns the L1 token that should be used for an L2 Bridge event. This function is
|
|
231
|
+
* designed to be used by the caller to associate the L2 token with its mapped L1 token
|
|
232
|
+
* at the HubPool equivalent block number of the L2 event.
|
|
233
|
+
* @param deposit Deposit event
|
|
234
|
+
* @param returns string L1 token counterpart for Deposit
|
|
235
|
+
*/
|
|
236
|
+
getL1TokenForDeposit(deposit: Pick<DepositWithBlock, "originChainId" | "inputToken" | "quoteBlockNumber">): string {
|
|
237
|
+
// L1-->L2 token mappings are set via PoolRebalanceRoutes which occur on mainnet,
|
|
238
|
+
// so we use the latest token mapping. This way if a very old deposit is filled, the relayer can use the
|
|
239
|
+
// latest L2 token mapping to find the L1 token counterpart.
|
|
240
|
+
return this.getL1TokenForL2TokenAtBlock(deposit.inputToken, deposit.originChainId, deposit.quoteBlockNumber);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Returns the L2 token that should be used as a counterpart to a deposit event. For example, the caller
|
|
245
|
+
* might want to know what the refund token will be on l2ChainId for the deposit event.
|
|
246
|
+
* @param l2ChainId Chain where caller wants to get L2 token counterpart for
|
|
247
|
+
* @param event Deposit event
|
|
248
|
+
* @returns string L2 token counterpart on l2ChainId
|
|
249
|
+
*/
|
|
250
|
+
getL2TokenForDeposit(
|
|
251
|
+
deposit: Pick<DepositWithBlock, "originChainId" | "destinationChainId" | "inputToken" | "quoteBlockNumber">,
|
|
252
|
+
l2ChainId = deposit.destinationChainId
|
|
253
|
+
): string {
|
|
254
|
+
const l1Token = this.getL1TokenForDeposit(deposit);
|
|
255
|
+
// Use the latest hub block number to find the L2 token counterpart.
|
|
256
|
+
return this.getL2TokenForL1TokenAtBlock(l1Token, l2ChainId, deposit.quoteBlockNumber);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
l2TokenEnabledForL1Token(l1Token: string, destinationChainId: number): boolean {
|
|
260
|
+
return this.l1TokensToDestinationTokens?.[l1Token]?.[destinationChainId] != undefined;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
getBlockNumber(timestamp: number): Promise<number | undefined> {
|
|
264
|
+
const hints = { lowBlock: this.deploymentBlock };
|
|
265
|
+
return getCachedBlockForTimestamp(this.chainId, timestamp, this.blockFinder, this.cachingMechanism, hints);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
async getCurrentPoolUtilization(l1Token: string): Promise<BigNumber> {
|
|
269
|
+
const blockNumber = this.latestBlockSearched ?? (await this.hubPool.provider.getBlockNumber());
|
|
270
|
+
return await this.getUtilization(l1Token, blockNumber, bnZero, getCurrentTime(), 0);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* For a HubPool token at a specific block number, compute the relevant utilization.
|
|
275
|
+
* @param hubPoolToken HubPool token to query utilization for.
|
|
276
|
+
* @param blocknumber Block number to query utilization at.
|
|
277
|
+
* @param amount Amount to query. If set to 0, the closing utilization at blockNumber is returned.
|
|
278
|
+
* @param amount timestamp Associated quoteTimestamp for query, used for caching evaluation.
|
|
279
|
+
* @param timeToCache Age at which the response is able to be cached.
|
|
280
|
+
* @returns HubPool utilization at `blockNumber` after optional `amount` increase in utilization.
|
|
281
|
+
*/
|
|
282
|
+
protected async getUtilization(
|
|
283
|
+
hubPoolToken: string,
|
|
284
|
+
blockNumber: number,
|
|
285
|
+
depositAmount: BigNumber,
|
|
286
|
+
timestamp: number,
|
|
287
|
+
timeToCache: number
|
|
288
|
+
): Promise<BigNumber> {
|
|
289
|
+
// Resolve this function call as an async anonymous function
|
|
290
|
+
const resolver = async () => {
|
|
291
|
+
const overrides = { blockTag: blockNumber };
|
|
292
|
+
if (depositAmount.eq(0)) {
|
|
293
|
+
// For zero amount, just get the utilisation at `blockNumber`.
|
|
294
|
+
return await this.hubPool.callStatic.liquidityUtilizationCurrent(hubPoolToken, overrides);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return await this.hubPool.callStatic.liquidityUtilizationPostRelay(hubPoolToken, depositAmount, overrides);
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// Resolve the cache locally so that we can appease typescript
|
|
301
|
+
const cache = this.cachingMechanism;
|
|
302
|
+
|
|
303
|
+
// If there is no cache or the timestamp is not old enough to be cached, just resolve the function.
|
|
304
|
+
if (!cache || !shouldCache(getCurrentTime(), timestamp, timeToCache)) {
|
|
305
|
+
return resolver();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Otherwise, let's resolve the key
|
|
309
|
+
// @note Avoid collisions with pre-existing cache keys by appending an underscore (_) for post-relay utilization.
|
|
310
|
+
// @fixme This can be removed once the existing keys have been ejected from the cache (i.e. 7 days).
|
|
311
|
+
const key = depositAmount.eq(0)
|
|
312
|
+
? `utilization_${hubPoolToken}_${blockNumber}`
|
|
313
|
+
: `utilization_${hubPoolToken}_${blockNumber}_${depositAmount.toString()}_`;
|
|
314
|
+
const result = await cache.get<string>(key);
|
|
315
|
+
if (isDefined(result)) {
|
|
316
|
+
return BigNumber.from(result);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// We were not able to find a valid result, so let's resolve the function.
|
|
320
|
+
const utilization = await resolver();
|
|
321
|
+
if (cache && shouldCache(getCurrentTime(), timestamp, timeToCache)) {
|
|
322
|
+
// If we should cache the result, store it for up to DEFAULT_CACHING_TTL.
|
|
323
|
+
await cache.set(key, `${utilization.toString()}`, DEFAULT_CACHING_TTL);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return utilization;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
async computeRealizedLpFeePct(deposit: LpFeeRequest): Promise<RealizedLpFee> {
|
|
330
|
+
const [lpFee] = await this.batchComputeRealizedLpFeePct([deposit]);
|
|
331
|
+
return lpFee;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
async batchComputeRealizedLpFeePct(deposits: LpFeeRequest[]): Promise<RealizedLpFee[]> {
|
|
335
|
+
assert(deposits.length > 0, "No deposits supplied to batchComputeRealizedLpFeePct");
|
|
336
|
+
if (!isDefined(this.currentTime)) {
|
|
337
|
+
throw new Error("HubPoolClient has not set a currentTime");
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Map each HubPool token to an array of unqiue quoteTimestamps.
|
|
341
|
+
const utilizationTimestamps: { [hubPoolToken: string]: number[] } = {};
|
|
342
|
+
|
|
343
|
+
// Map each HubPool token to utilization at a particular block number.
|
|
344
|
+
let utilization: { [hubPoolToken: string]: { [blockNumber: number]: BigNumber } } = {};
|
|
345
|
+
|
|
346
|
+
let quoteBlocks: { [quoteTimestamp: number]: number } = {};
|
|
347
|
+
|
|
348
|
+
// Map SpokePool token addresses to HubPool token addresses.
|
|
349
|
+
// Note: Should only be accessed via `getHubPoolToken()` or `getHubPoolTokens()`.
|
|
350
|
+
const hubPoolTokens: { [k: string]: string } = {};
|
|
351
|
+
const getHubPoolToken = (deposit: LpFeeRequest, quoteBlockNumber: number): string => {
|
|
352
|
+
const tokenKey = `${deposit.originChainId}-${deposit.inputToken}`;
|
|
353
|
+
return (hubPoolTokens[tokenKey] ??= this.getL1TokenForDeposit({ ...deposit, quoteBlockNumber }));
|
|
354
|
+
};
|
|
355
|
+
const getHubPoolTokens = (): string[] => dedupArray(Object.values(hubPoolTokens));
|
|
356
|
+
|
|
357
|
+
// Helper to resolve the unqiue hubPoolToken & quoteTimestamp mappings.
|
|
358
|
+
const resolveUniqueQuoteTimestamps = (deposit: LpFeeRequest): void => {
|
|
359
|
+
const { quoteTimestamp } = deposit;
|
|
360
|
+
|
|
361
|
+
// Resolve the HubPool token address for this origin chainId/token pair, if it isn't already known.
|
|
362
|
+
const quoteBlockNumber = quoteBlocks[quoteTimestamp];
|
|
363
|
+
const hubPoolToken = getHubPoolToken(deposit, quoteBlockNumber);
|
|
364
|
+
|
|
365
|
+
// Append the quoteTimestamp for this HubPool token, if it isn't already enqueued.
|
|
366
|
+
utilizationTimestamps[hubPoolToken] ??= [];
|
|
367
|
+
if (!utilizationTimestamps[hubPoolToken].includes(quoteTimestamp)) {
|
|
368
|
+
utilizationTimestamps[hubPoolToken].push(quoteTimestamp);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
// Helper to resolve a quoteTimestamp to a HubPool block number.
|
|
373
|
+
const resolveTimestampsToBlocks = async (quoteTimestamp: number): Promise<[number, number]> => {
|
|
374
|
+
const quoteBlock = await this.getBlockNumber(quoteTimestamp);
|
|
375
|
+
if (!isDefined(quoteBlock)) {
|
|
376
|
+
throw new Error(`Could not find block for timestamp ${quoteTimestamp}`);
|
|
377
|
+
}
|
|
378
|
+
return [quoteTimestamp, quoteBlock];
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
// Helper to resolve existing HubPool token utilisation for an array of unique block numbers.
|
|
382
|
+
// Produces a mapping of blockNumber -> utilization for a specific token.
|
|
383
|
+
const resolveUtilization = async (hubPoolToken: string): Promise<Record<number, BigNumber>> => {
|
|
384
|
+
return Object.fromEntries(
|
|
385
|
+
await mapAsync(utilizationTimestamps[hubPoolToken], async (quoteTimestamp) => {
|
|
386
|
+
const blockNumber = quoteBlocks[quoteTimestamp];
|
|
387
|
+
const utilization = await this.getUtilization(
|
|
388
|
+
hubPoolToken,
|
|
389
|
+
blockNumber,
|
|
390
|
+
bnZero, // amount
|
|
391
|
+
quoteTimestamp,
|
|
392
|
+
timeToCache
|
|
393
|
+
);
|
|
394
|
+
return [blockNumber, utilization];
|
|
395
|
+
})
|
|
396
|
+
);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
// Helper compute the realizedLpFeePct of an individual deposit based on pre-retrieved batch data.
|
|
400
|
+
const computeRealizedLpFeePct = async (deposit: LpFeeRequest) => {
|
|
401
|
+
const { originChainId, paymentChainId, inputAmount, quoteTimestamp } = deposit;
|
|
402
|
+
const quoteBlock = quoteBlocks[quoteTimestamp];
|
|
403
|
+
|
|
404
|
+
if (paymentChainId === undefined) {
|
|
405
|
+
return { quoteBlock, realizedLpFeePct: bnZero };
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
const hubPoolToken = getHubPoolToken(deposit, quoteBlock);
|
|
409
|
+
const rateModel = this.configStoreClient.getRateModelForBlockNumber(
|
|
410
|
+
hubPoolToken,
|
|
411
|
+
originChainId,
|
|
412
|
+
paymentChainId,
|
|
413
|
+
quoteBlock
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
const preUtilization = utilization[hubPoolToken][quoteBlock];
|
|
417
|
+
const postUtilization = await this.getUtilization(
|
|
418
|
+
hubPoolToken,
|
|
419
|
+
quoteBlock,
|
|
420
|
+
inputAmount,
|
|
421
|
+
quoteTimestamp,
|
|
422
|
+
timeToCache
|
|
423
|
+
);
|
|
424
|
+
const realizedLpFeePct = lpFeeCalculator.calculateRealizedLpFeePct(rateModel, preUtilization, postUtilization);
|
|
425
|
+
|
|
426
|
+
return { quoteBlock, realizedLpFeePct };
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Execution flow starts here.
|
|
431
|
+
*/
|
|
432
|
+
const timeToCache = this.configOverride.timeToCache ?? DEFAULT_CACHING_SAFE_LAG;
|
|
433
|
+
|
|
434
|
+
// Identify the unique hubPoolToken & quoteTimestamp mappings. This is used to optimise subsequent HubPool queries.
|
|
435
|
+
deposits.forEach((deposit) => resolveUniqueQuoteTimestamps(deposit));
|
|
436
|
+
|
|
437
|
+
// Filter all deposits for unique quoteTimestamps, to be resolved to a blockNumber in parallel.
|
|
438
|
+
const quoteTimestamps = dedupArray(deposits.map(({ quoteTimestamp }) => quoteTimestamp));
|
|
439
|
+
quoteBlocks = Object.fromEntries(
|
|
440
|
+
await mapAsync(quoteTimestamps, (quoteTimestamp) => resolveTimestampsToBlocks(quoteTimestamp))
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
// For each token / quoteBlock pair, resolve the utilisation for each quoted block.
|
|
444
|
+
// This can be reused for each deposit with the same HubPool token and quoteTimestamp pair.
|
|
445
|
+
utilization = Object.fromEntries(
|
|
446
|
+
await mapAsync(getHubPoolTokens(), async (hubPoolToken) => [hubPoolToken, await resolveUtilization(hubPoolToken)])
|
|
447
|
+
);
|
|
448
|
+
|
|
449
|
+
// For each deposit, compute the post-relay HubPool utilisation independently.
|
|
450
|
+
// @dev The caller expects to receive an array in the same length and ordering as the input `deposits`.
|
|
451
|
+
return await mapAsync(deposits, (deposit) => computeRealizedLpFeePct(deposit));
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
getL1Tokens(): L1Token[] {
|
|
455
|
+
return this.l1Tokens;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
getTokenInfoForL1Token(l1Token: string): L1Token | undefined {
|
|
459
|
+
return this.l1Tokens.find((token) => token.address === l1Token);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
getLpTokenInfoForL1Token(l1Token: string): LpToken | undefined {
|
|
463
|
+
return this.lpTokens[l1Token];
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
getL1TokenInfoForL2Token(l2Token: string, chainId: number): L1Token | undefined {
|
|
467
|
+
const l1TokenCounterpart = this.getL1TokenForL2TokenAtBlock(l2Token, chainId, this.latestBlockSearched);
|
|
468
|
+
return this.getTokenInfoForL1Token(l1TokenCounterpart);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
getTokenInfoForDeposit(deposit: Deposit): L1Token | undefined {
|
|
472
|
+
return this.getTokenInfoForL1Token(
|
|
473
|
+
this.getL1TokenForL2TokenAtBlock(deposit.inputToken, deposit.originChainId, this.latestBlockSearched)
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
getTokenInfo(chainId: number | string, tokenAddress: string): L1Token | undefined {
|
|
478
|
+
const deposit = { originChainId: parseInt(chainId.toString()), inputToken: tokenAddress } as Deposit;
|
|
479
|
+
return this.getTokenInfoForDeposit(deposit);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
areTokensEquivalent(
|
|
483
|
+
tokenA: string,
|
|
484
|
+
chainIdA: number,
|
|
485
|
+
tokenB: string,
|
|
486
|
+
chainIdB: number,
|
|
487
|
+
hubPoolBlock = this.latestBlockSearched
|
|
488
|
+
): boolean {
|
|
489
|
+
try {
|
|
490
|
+
// Resolve both SpokePool tokens back to their respective HubPool tokens and verify that they match.
|
|
491
|
+
const l1TokenA = this.getL1TokenForL2TokenAtBlock(tokenA, chainIdA, hubPoolBlock);
|
|
492
|
+
const l1TokenB = this.getL1TokenForL2TokenAtBlock(tokenB, chainIdB, hubPoolBlock);
|
|
493
|
+
if (l1TokenA !== l1TokenB) {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// Resolve both HubPool tokens back to a current SpokePool token and verify that they match.
|
|
498
|
+
const _tokenA = this.getL2TokenForL1TokenAtBlock(l1TokenA, chainIdA, hubPoolBlock);
|
|
499
|
+
const _tokenB = this.getL2TokenForL1TokenAtBlock(l1TokenB, chainIdB, hubPoolBlock);
|
|
500
|
+
return tokenA === _tokenA && tokenB === _tokenB;
|
|
501
|
+
} catch {
|
|
502
|
+
return false; // One or both input tokens were not recognised.
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
getSpokeActivationBlockForChain(chainId: number): number {
|
|
507
|
+
return this.getSpokePoolActivationBlock(chainId, this.getSpokePoolForBlock(chainId)) ?? 0;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Root bundles are valid if all of their pool rebalance leaves have been executed before the next bundle, or the
|
|
511
|
+
// latest mainnet block to search. Whichever comes first.
|
|
512
|
+
isRootBundleValid(rootBundle: ProposedRootBundle, latestMainnetBlock: number): boolean {
|
|
513
|
+
const nextRootBundle = this.getFollowingRootBundle(rootBundle);
|
|
514
|
+
const executedLeafCount = this.getExecutedLeavesForRootBundle(
|
|
515
|
+
rootBundle,
|
|
516
|
+
nextRootBundle ? Math.min(nextRootBundle.blockNumber, latestMainnetBlock) : latestMainnetBlock
|
|
517
|
+
);
|
|
518
|
+
return executedLeafCount.length === rootBundle.poolRebalanceLeafCount;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// This should find the ProposeRootBundle event whose bundle block number for `chain` is closest to the `block`
|
|
522
|
+
// without being smaller. It returns the bundle block number for the chain or undefined if not matched.
|
|
523
|
+
getRootBundleEvalBlockNumberContainingBlock(
|
|
524
|
+
latestMainnetBlock: number,
|
|
525
|
+
block: number,
|
|
526
|
+
chain: number,
|
|
527
|
+
chainIdListOverride?: number[]
|
|
528
|
+
): number | undefined {
|
|
529
|
+
const chainIdList = chainIdListOverride ?? this.configStoreClient.getChainIdIndicesForBlock(latestMainnetBlock);
|
|
530
|
+
let endingBlockNumber: number | undefined;
|
|
531
|
+
// Search proposed root bundles in reverse chronological order.
|
|
532
|
+
for (let i = this.proposedRootBundles.length - 1; i >= 0; i--) {
|
|
533
|
+
const rootBundle = this.proposedRootBundles[i];
|
|
534
|
+
const nextRootBundle = this.getFollowingRootBundle(rootBundle);
|
|
535
|
+
if (!this.isRootBundleValid(rootBundle, nextRootBundle ? nextRootBundle.blockNumber : latestMainnetBlock)) {
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// 0 is the default value bundleEvalBlockNumber.
|
|
540
|
+
const bundleEvalBlockNumber = this.getBundleEndBlockForChain(
|
|
541
|
+
rootBundle as ProposedRootBundle,
|
|
542
|
+
chain,
|
|
543
|
+
chainIdList
|
|
544
|
+
);
|
|
545
|
+
|
|
546
|
+
// Since we're iterating from newest to oldest, bundleEvalBlockNumber is only decreasing, and if the
|
|
547
|
+
// bundleEvalBlockNumber is smaller than the target block, then we should return the last set `endingBlockNumber`.
|
|
548
|
+
if (bundleEvalBlockNumber <= block) {
|
|
549
|
+
if (bundleEvalBlockNumber === block) {
|
|
550
|
+
endingBlockNumber = bundleEvalBlockNumber;
|
|
551
|
+
}
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
endingBlockNumber = bundleEvalBlockNumber;
|
|
555
|
+
}
|
|
556
|
+
return endingBlockNumber;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// TODO: This might not be necessary since the cumulative root bundle count doesn't grow fast enough, but consider
|
|
560
|
+
// using _.findLast/_.find instead of resorting the arrays if these functions begin to take a lot time.
|
|
561
|
+
getProposedRootBundlesInBlockRange(startingBlock: number, endingBlock: number): ProposedRootBundle[] {
|
|
562
|
+
return this.proposedRootBundles.filter(
|
|
563
|
+
(bundle: ProposedRootBundle) => bundle.blockNumber >= startingBlock && bundle.blockNumber <= endingBlock
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
getCancelledRootBundlesInBlockRange(startingBlock: number, endingBlock: number): CancelledRootBundle[] {
|
|
568
|
+
return sortEventsDescending(this.canceledRootBundles).filter(
|
|
569
|
+
(bundle: CancelledRootBundle) => bundle.blockNumber >= startingBlock && bundle.blockNumber <= endingBlock
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
getDisputedRootBundlesInBlockRange(startingBlock: number, endingBlock: number): DisputedRootBundle[] {
|
|
574
|
+
return sortEventsDescending(this.disputedRootBundles).filter(
|
|
575
|
+
(bundle: DisputedRootBundle) => bundle.blockNumber >= startingBlock && bundle.blockNumber <= endingBlock
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
getLatestProposedRootBundle(): ProposedRootBundle {
|
|
580
|
+
return this.proposedRootBundles[this.proposedRootBundles.length - 1] as ProposedRootBundle;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
getFollowingRootBundle(currentRootBundle: ProposedRootBundle): ProposedRootBundle | undefined {
|
|
584
|
+
const index = _.findLastIndex(
|
|
585
|
+
this.proposedRootBundles,
|
|
586
|
+
(bundle) => bundle.blockNumber === currentRootBundle.blockNumber
|
|
587
|
+
);
|
|
588
|
+
// If index of current root bundle is not found or is the last bundle, return undefined.
|
|
589
|
+
if (index === -1 || index === this.proposedRootBundles.length - 1) {
|
|
590
|
+
return undefined;
|
|
591
|
+
}
|
|
592
|
+
return this.proposedRootBundles[index + 1];
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
getExecutedLeavesForRootBundle(
|
|
596
|
+
rootBundle: ProposedRootBundle,
|
|
597
|
+
latestMainnetBlockToSearch: number
|
|
598
|
+
): ExecutedRootBundle[] {
|
|
599
|
+
return this.executedRootBundles.filter(
|
|
600
|
+
(executedLeaf: ExecutedRootBundle) =>
|
|
601
|
+
executedLeaf.blockNumber <= latestMainnetBlockToSearch &&
|
|
602
|
+
// Note: We can use > instead of >= here because a leaf can never be executed in same block as its root
|
|
603
|
+
// proposal due to bundle liveness enforced by HubPool. This importantly avoids the edge case
|
|
604
|
+
// where the execution all leaves occurs in the same block as the next proposal, leading us to think
|
|
605
|
+
// that the next proposal is fully executed when its not.
|
|
606
|
+
executedLeaf.blockNumber > rootBundle.blockNumber
|
|
607
|
+
) as ExecutedRootBundle[];
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
getValidatedRootBundles(latestMainnetBlock: number = Number.MAX_SAFE_INTEGER): ProposedRootBundle[] {
|
|
611
|
+
return this.proposedRootBundles.filter((rootBundle: ProposedRootBundle) => {
|
|
612
|
+
if (rootBundle.blockNumber > latestMainnetBlock) {
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
return this.isRootBundleValid(rootBundle, latestMainnetBlock);
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
getLatestFullyExecutedRootBundle(latestMainnetBlock: number): ProposedRootBundle | undefined {
|
|
620
|
+
// Search for latest ProposeRootBundleExecuted event followed by all of its RootBundleExecuted event suggesting
|
|
621
|
+
// that all pool rebalance leaves were executed. This ignores any proposed bundles that were partially executed.
|
|
622
|
+
return _.findLast(this.proposedRootBundles, (rootBundle: ProposedRootBundle) => {
|
|
623
|
+
if (rootBundle.blockNumber > latestMainnetBlock) {
|
|
624
|
+
return false;
|
|
625
|
+
}
|
|
626
|
+
return this.isRootBundleValid(rootBundle, latestMainnetBlock);
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
getEarliestFullyExecutedRootBundle(latestMainnetBlock: number, startBlock = 0): ProposedRootBundle | undefined {
|
|
631
|
+
return this.proposedRootBundles.find((rootBundle: ProposedRootBundle) => {
|
|
632
|
+
if (rootBundle.blockNumber > latestMainnetBlock) {
|
|
633
|
+
return false;
|
|
634
|
+
}
|
|
635
|
+
if (rootBundle.blockNumber < startBlock) {
|
|
636
|
+
return false;
|
|
637
|
+
}
|
|
638
|
+
return this.isRootBundleValid(rootBundle, latestMainnetBlock);
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// If n is negative, then return the Nth latest executed bundle, otherwise return the Nth earliest
|
|
643
|
+
// executed bundle. Latest means most recent, earliest means oldest. N cannot be 0.
|
|
644
|
+
// `startBlock` can be used to set the starting point from which we look forwards or backwards, depending
|
|
645
|
+
// on whether n is positive or negative.
|
|
646
|
+
getNthFullyExecutedRootBundle(n: number, startBlock?: number): ProposedRootBundle | undefined {
|
|
647
|
+
if (n === 0) {
|
|
648
|
+
throw new Error("n cannot be 0");
|
|
649
|
+
}
|
|
650
|
+
if (!this.latestBlockSearched) {
|
|
651
|
+
throw new Error("HubPoolClient::getNthFullyExecutedRootBundle client not updated");
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
let bundleToReturn: ProposedRootBundle | undefined;
|
|
655
|
+
|
|
656
|
+
// If n is negative, then return the Nth latest executed bundle, otherwise return the Nth earliest
|
|
657
|
+
// executed bundle.
|
|
658
|
+
if (n < 0) {
|
|
659
|
+
let nextLatestMainnetBlock = startBlock ?? this.latestBlockSearched;
|
|
660
|
+
for (let i = 0; i < Math.abs(n); i++) {
|
|
661
|
+
bundleToReturn = this.getLatestFullyExecutedRootBundle(nextLatestMainnetBlock);
|
|
662
|
+
const bundleBlockNumber = bundleToReturn ? bundleToReturn.blockNumber : 0;
|
|
663
|
+
|
|
664
|
+
// Subtract 1 so that next `getLatestFullyExecutedRootBundle` call filters out the root bundle we just found
|
|
665
|
+
// because its block number is > nextLatestMainnetBlock.
|
|
666
|
+
nextLatestMainnetBlock = Math.max(0, bundleBlockNumber - 1);
|
|
667
|
+
}
|
|
668
|
+
} else {
|
|
669
|
+
let nextStartBlock = startBlock ?? 0;
|
|
670
|
+
for (let i = 0; i < n; i++) {
|
|
671
|
+
bundleToReturn = this.getEarliestFullyExecutedRootBundle(this.latestBlockSearched, nextStartBlock);
|
|
672
|
+
const bundleBlockNumber = bundleToReturn ? bundleToReturn.blockNumber : 0;
|
|
673
|
+
|
|
674
|
+
// Add 1 so that next `getEarliestFullyExecutedRootBundle` call filters out the root bundle we just found
|
|
675
|
+
// because its block number is < nextStartBlock.
|
|
676
|
+
nextStartBlock = Math.min(bundleBlockNumber + 1, this.latestBlockSearched);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
return bundleToReturn;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
getLatestBundleEndBlockForChain(chainIdList: number[], latestMainnetBlock: number, chainId: number): number {
|
|
684
|
+
const latestFullyExecutedPoolRebalanceRoot = this.getLatestFullyExecutedRootBundle(latestMainnetBlock);
|
|
685
|
+
|
|
686
|
+
// If no event, then we can return a conservative default starting block like 0,
|
|
687
|
+
// or we could throw an Error.
|
|
688
|
+
if (!latestFullyExecutedPoolRebalanceRoot) {
|
|
689
|
+
return 0;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// Once this proposal event is found, determine its mapping of indices to chainId in its
|
|
693
|
+
// bundleEvaluationBlockNumbers array using CHAIN_ID_LIST. For each chainId, their starting block number is that
|
|
694
|
+
// chain's bundleEvaluationBlockNumber + 1 in this past proposal event.
|
|
695
|
+
return this.getBundleEndBlockForChain(latestFullyExecutedPoolRebalanceRoot, chainId, chainIdList);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
getNextBundleStartBlockNumber(chainIdList: number[], latestMainnetBlock: number, chainId: number): number {
|
|
699
|
+
const endBlock = this.getLatestBundleEndBlockForChain(chainIdList, latestMainnetBlock, chainId);
|
|
700
|
+
|
|
701
|
+
// This assumes that chain ID's are only added to the chain ID list over time, and that chains are never
|
|
702
|
+
// deleted.
|
|
703
|
+
return endBlock > 0 ? endBlock + 1 : 0;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token: string): TokenRunningBalance {
|
|
707
|
+
// Search ExecutedRootBundles in descending block order to find the most recent event before the target block.
|
|
708
|
+
const executedRootBundle = sortEventsDescending(this.executedRootBundles).find(
|
|
709
|
+
(executedLeaf: ExecutedRootBundle) => {
|
|
710
|
+
return (
|
|
711
|
+
executedLeaf.blockNumber <= block &&
|
|
712
|
+
executedLeaf.chainId === chain &&
|
|
713
|
+
executedLeaf.l1Tokens.map((l1Token) => l1Token.toLowerCase()).includes(l1Token.toLowerCase())
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
) as ExecutedRootBundle;
|
|
717
|
+
|
|
718
|
+
return this.getRunningBalanceForToken(l1Token, executedRootBundle);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
public getRunningBalanceForToken(l1Token: string, executedRootBundle: ExecutedRootBundle): TokenRunningBalance {
|
|
722
|
+
let runningBalance = toBN(0);
|
|
723
|
+
let incentiveBalance = toBN(0);
|
|
724
|
+
if (executedRootBundle) {
|
|
725
|
+
const indexOfL1Token = executedRootBundle.l1Tokens
|
|
726
|
+
.map((l1Token) => l1Token.toLowerCase())
|
|
727
|
+
.indexOf(l1Token.toLowerCase());
|
|
728
|
+
runningBalance = executedRootBundle.runningBalances[indexOfL1Token];
|
|
729
|
+
incentiveBalance = executedRootBundle.incentiveBalances[indexOfL1Token];
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
return { runningBalance, incentiveBalance };
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
async _update(eventNames: HubPoolEvent[]): Promise<HubPoolUpdate> {
|
|
736
|
+
const hubPoolEvents = this.hubPoolEventFilters();
|
|
737
|
+
const searchConfig = await this.updateSearchConfig(this.hubPool.provider);
|
|
738
|
+
|
|
739
|
+
if (isUpdateFailureReason(searchConfig)) {
|
|
740
|
+
return { success: false, reason: searchConfig };
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
const supportedEvents = Object.keys(hubPoolEvents);
|
|
744
|
+
if (eventNames.some((eventName) => !supportedEvents.includes(eventName))) {
|
|
745
|
+
return { success: false, reason: UpdateFailureReason.BadRequest };
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
const eventSearchConfigs = eventNames.map((eventName) => {
|
|
749
|
+
const _searchConfig = { ...searchConfig }; // shallow copy
|
|
750
|
+
|
|
751
|
+
// By default, an event's query range is controlled by the `searchConfig` passed in during
|
|
752
|
+
// instantiation. However, certain events generally must be queried back to HubPool genesis.
|
|
753
|
+
const overrideEvents = ["CrossChainContractsSet", "L1TokenEnabledForLiquidityProvision", "SetPoolRebalanceRoute"];
|
|
754
|
+
if (overrideEvents.includes(eventName) && !this.isUpdated) {
|
|
755
|
+
_searchConfig.fromBlock = this.deploymentBlock;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
return {
|
|
759
|
+
eventName,
|
|
760
|
+
filter: hubPoolEvents[eventName],
|
|
761
|
+
searchConfig: _searchConfig,
|
|
762
|
+
};
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
this.logger.debug({
|
|
766
|
+
at: "HubPoolClient",
|
|
767
|
+
message: "Updating HubPool client",
|
|
768
|
+
searchConfig: eventSearchConfigs.map(({ eventName, searchConfig }) => ({ eventName, searchConfig })),
|
|
769
|
+
});
|
|
770
|
+
const timerStart = Date.now();
|
|
771
|
+
|
|
772
|
+
const { hubPool } = this;
|
|
773
|
+
const multicallFunctions = ["getCurrentTime", "rootBundleProposal"];
|
|
774
|
+
const [multicallOutput, ...events] = await Promise.all([
|
|
775
|
+
hubPool.callStatic.multicall(
|
|
776
|
+
multicallFunctions.map((f) => hubPool.interface.encodeFunctionData(f)),
|
|
777
|
+
{ blockTag: searchConfig.toBlock }
|
|
778
|
+
),
|
|
779
|
+
...eventSearchConfigs.map((config) => paginatedEventQuery(hubPool, config.filter, config.searchConfig)),
|
|
780
|
+
]);
|
|
781
|
+
|
|
782
|
+
const [currentTime, pendingRootBundleProposal] = multicallFunctions.map((fn, idx) => {
|
|
783
|
+
const output = hubPool.interface.decodeFunctionResult(fn, multicallOutput[idx]);
|
|
784
|
+
return output.length > 1 ? output : output[0];
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
this.logger.debug({
|
|
788
|
+
at: "HubPoolClient#_update",
|
|
789
|
+
message: `Time to query new events from RPC for ${this.chainId}: ${Date.now() - timerStart} ms`,
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
const _events = Object.fromEntries(eventNames.map((eventName, idx) => [eventName, events[idx]]));
|
|
793
|
+
|
|
794
|
+
return {
|
|
795
|
+
success: true,
|
|
796
|
+
currentTime,
|
|
797
|
+
pendingRootBundleProposal,
|
|
798
|
+
searchEndBlock: searchConfig.toBlock,
|
|
799
|
+
events: _events,
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
async update(
|
|
804
|
+
eventsToQuery: HubPoolEvent[] = Object.keys(this.hubPoolEventFilters()) as HubPoolEvent[]
|
|
805
|
+
): Promise<void> {
|
|
806
|
+
if (!this.configStoreClient.isUpdated) {
|
|
807
|
+
throw new Error("ConfigStoreClient not updated");
|
|
808
|
+
}
|
|
809
|
+
const update = await this._update(eventsToQuery);
|
|
810
|
+
if (!update.success) {
|
|
811
|
+
if (update.reason !== UpdateFailureReason.AlreadyUpdated) {
|
|
812
|
+
throw new Error(`Unable to update HubPoolClient: ${update.reason}`);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// No need to touch `this.isUpdated` because it should already be set from a previous update.
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
const { events, currentTime, pendingRootBundleProposal, searchEndBlock } = update;
|
|
819
|
+
|
|
820
|
+
if (eventsToQuery.includes("CrossChainContractsSet")) {
|
|
821
|
+
for (const event of events["CrossChainContractsSet"]) {
|
|
822
|
+
const args = spreadEventWithBlockNumber(event) as CrossChainContractsSet;
|
|
823
|
+
assign(
|
|
824
|
+
this.crossChainContracts,
|
|
825
|
+
[args.l2ChainId],
|
|
826
|
+
[
|
|
827
|
+
{
|
|
828
|
+
spokePool: args.spokePool,
|
|
829
|
+
blockNumber: args.blockNumber,
|
|
830
|
+
transactionIndex: args.transactionIndex,
|
|
831
|
+
logIndex: args.logIndex,
|
|
832
|
+
},
|
|
833
|
+
]
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
if (eventsToQuery.includes("SetPoolRebalanceRoute")) {
|
|
839
|
+
for (const event of events["SetPoolRebalanceRoute"]) {
|
|
840
|
+
const args = spreadEventWithBlockNumber(event) as SetPoolRebalanceRoot;
|
|
841
|
+
assign(this.l1TokensToDestinationTokens, [args.l1Token, args.destinationChainId], args.destinationToken);
|
|
842
|
+
assign(
|
|
843
|
+
this.l1TokensToDestinationTokensWithBlock,
|
|
844
|
+
[args.l1Token, args.destinationChainId],
|
|
845
|
+
[
|
|
846
|
+
{
|
|
847
|
+
l1Token: args.l1Token,
|
|
848
|
+
l2Token: args.destinationToken,
|
|
849
|
+
blockNumber: args.blockNumber,
|
|
850
|
+
transactionIndex: args.transactionIndex,
|
|
851
|
+
logIndex: args.logIndex,
|
|
852
|
+
},
|
|
853
|
+
]
|
|
854
|
+
);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// For each enabled Lp token fetch the token symbol and decimals from the token contract. Note this logic will
|
|
859
|
+
// only run iff a new token has been enabled. Will only append iff the info is not there already.
|
|
860
|
+
// Filter out any duplicate addresses. This might happen due to enabling, disabling and re-enabling a token.
|
|
861
|
+
if (eventsToQuery.includes("L1TokenEnabledForLiquidityProvision")) {
|
|
862
|
+
const uniqueL1Tokens = [
|
|
863
|
+
...Array.from(
|
|
864
|
+
new Set(events["L1TokenEnabledForLiquidityProvision"].map((event) => spreadEvent(event.args).l1Token))
|
|
865
|
+
),
|
|
866
|
+
];
|
|
867
|
+
const [tokenInfo, lpTokenInfo] = await Promise.all([
|
|
868
|
+
Promise.all(uniqueL1Tokens.map((l1Token: string) => fetchTokenInfo(l1Token, this.hubPool.provider))),
|
|
869
|
+
Promise.all(
|
|
870
|
+
uniqueL1Tokens.map(
|
|
871
|
+
async (l1Token: string) => await this.hubPool.pooledTokens(l1Token, { blockTag: update.searchEndBlock })
|
|
872
|
+
)
|
|
873
|
+
),
|
|
874
|
+
]);
|
|
875
|
+
for (const info of tokenInfo) {
|
|
876
|
+
if (!this.l1Tokens.find((token) => token.symbol === info.symbol)) {
|
|
877
|
+
if (info.decimals > 0 && info.decimals <= 18) {
|
|
878
|
+
this.l1Tokens.push(info);
|
|
879
|
+
} else {
|
|
880
|
+
throw new Error(`Unsupported HubPool token: ${JSON.stringify(info)}`);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
uniqueL1Tokens.forEach((token: string, i) => {
|
|
886
|
+
this.lpTokens[token] = {
|
|
887
|
+
lastLpFeeUpdate: lpTokenInfo[i].lastLpFeeUpdate,
|
|
888
|
+
liquidReserves: lpTokenInfo[i].liquidReserves,
|
|
889
|
+
};
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
if (eventsToQuery.includes("ProposeRootBundle")) {
|
|
894
|
+
this.proposedRootBundles.push(
|
|
895
|
+
...events["ProposeRootBundle"]
|
|
896
|
+
.filter((event) => !this.configOverride.ignoredHubProposedBundles.includes(event.blockNumber))
|
|
897
|
+
.map((event) => {
|
|
898
|
+
return {
|
|
899
|
+
...spreadEventWithBlockNumber(event),
|
|
900
|
+
transactionHash: event.transactionHash,
|
|
901
|
+
} as ProposedRootBundle;
|
|
902
|
+
})
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
if (eventsToQuery.includes("RootBundleCanceled")) {
|
|
907
|
+
this.canceledRootBundles.push(
|
|
908
|
+
...events["RootBundleCanceled"].map((event) => spreadEventWithBlockNumber(event) as CancelledRootBundle)
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
if (eventsToQuery.includes("RootBundleDisputed")) {
|
|
913
|
+
this.disputedRootBundles.push(
|
|
914
|
+
...events["RootBundleDisputed"].map((event) => spreadEventWithBlockNumber(event) as DisputedRootBundle)
|
|
915
|
+
);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
if (eventsToQuery.includes("RootBundleExecuted")) {
|
|
919
|
+
for (const event of events["RootBundleExecuted"]) {
|
|
920
|
+
if (this.configOverride.ignoredHubExecutedBundles.includes(event.blockNumber)) {
|
|
921
|
+
continue;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// Set running balances and incentive balances for this bundle.
|
|
925
|
+
const executedRootBundle = spreadEventWithBlockNumber(event) as ExecutedRootBundle;
|
|
926
|
+
const { l1Tokens, runningBalances } = executedRootBundle;
|
|
927
|
+
const nTokens = l1Tokens.length;
|
|
928
|
+
|
|
929
|
+
// Safeguard
|
|
930
|
+
if (![nTokens, nTokens * 2].includes(runningBalances.length)) {
|
|
931
|
+
throw new Error(
|
|
932
|
+
`Invalid runningBalances length: ${runningBalances.length}.` +
|
|
933
|
+
` Expected ${nTokens} or ${nTokens * 2} for chain ${this.chainId} transaction ${event.transactionHash}`
|
|
934
|
+
);
|
|
935
|
+
}
|
|
936
|
+
executedRootBundle.runningBalances = runningBalances.slice(0, nTokens);
|
|
937
|
+
executedRootBundle.incentiveBalances =
|
|
938
|
+
runningBalances.length > nTokens ? runningBalances.slice(nTokens) : runningBalances.map(() => toBN(0));
|
|
939
|
+
this.executedRootBundles.push(executedRootBundle);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
// If the contract's current rootBundleProposal() value has an unclaimedPoolRebalanceLeafCount > 0, then
|
|
944
|
+
// it means that either the root bundle proposal is in the challenge period and can be disputed, or it has
|
|
945
|
+
// passed the challenge period and pool rebalance leaves can be executed. Once all leaves are executed, the
|
|
946
|
+
// unclaimed count will drop to 0 and at that point there is nothing more that we can do with this root bundle
|
|
947
|
+
// besides proposing another one.
|
|
948
|
+
if (eventsToQuery.includes("ProposeRootBundle")) {
|
|
949
|
+
if (pendingRootBundleProposal.unclaimedPoolRebalanceLeafCount > 0) {
|
|
950
|
+
const mostRecentProposedRootBundle = this.proposedRootBundles[this.proposedRootBundles.length - 1];
|
|
951
|
+
this.pendingRootBundle = {
|
|
952
|
+
poolRebalanceRoot: pendingRootBundleProposal.poolRebalanceRoot,
|
|
953
|
+
relayerRefundRoot: pendingRootBundleProposal.relayerRefundRoot,
|
|
954
|
+
slowRelayRoot: pendingRootBundleProposal.slowRelayRoot,
|
|
955
|
+
proposer: pendingRootBundleProposal.proposer,
|
|
956
|
+
unclaimedPoolRebalanceLeafCount: pendingRootBundleProposal.unclaimedPoolRebalanceLeafCount,
|
|
957
|
+
challengePeriodEndTimestamp: pendingRootBundleProposal.challengePeriodEndTimestamp,
|
|
958
|
+
bundleEvaluationBlockNumbers: mostRecentProposedRootBundle.bundleEvaluationBlockNumbers.map(
|
|
959
|
+
(block: BigNumber) => {
|
|
960
|
+
// Ideally, the HubPool.sol contract should limit the size of the elements within the
|
|
961
|
+
// bundleEvaluationBlockNumbers array. But because it doesn't, we wrap the cast of BN --> Number
|
|
962
|
+
// in a try/catch statement and return some value that would always be disputable.
|
|
963
|
+
// This catches the denial of service attack vector where a malicious proposer proposes with bundle block
|
|
964
|
+
// evaluation block numbers larger than what BigNumber::toNumber() can handle.
|
|
965
|
+
try {
|
|
966
|
+
return block.toNumber();
|
|
967
|
+
} catch {
|
|
968
|
+
return 0;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
),
|
|
972
|
+
proposalBlockNumber: mostRecentProposedRootBundle.blockNumber,
|
|
973
|
+
};
|
|
974
|
+
} else {
|
|
975
|
+
this.pendingRootBundle = undefined;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
this.currentTime = currentTime;
|
|
980
|
+
this.latestBlockSearched = searchEndBlock;
|
|
981
|
+
this.firstBlockToSearch = update.searchEndBlock + 1; // Next iteration should start off from where this one ended.
|
|
982
|
+
this.eventSearchConfig.toBlock = undefined; // Caller can re-set on subsequent updates if necessary.
|
|
983
|
+
|
|
984
|
+
this.isUpdated = true;
|
|
985
|
+
this.logger.debug({ at: "HubPoolClient::update", message: "HubPool client updated!", searchEndBlock });
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// Returns end block for `chainId` in ProposedRootBundle.bundleBlockEvalNumbers. Looks up chainId
|
|
989
|
+
// in chainId list, gets the index where its located, and returns the value of the index in
|
|
990
|
+
// bundleBlockEvalNumbers. Returns 0 if `chainId` can't be found in `chainIdList` and if index doesn't
|
|
991
|
+
// exist in bundleBlockEvalNumbers.
|
|
992
|
+
protected getBundleEndBlockForChain(
|
|
993
|
+
proposeRootBundleEvent: ProposedRootBundle,
|
|
994
|
+
chainId: number,
|
|
995
|
+
chainIdList: number[]
|
|
996
|
+
): number {
|
|
997
|
+
const bundleEvaluationBlockNumbers: BigNumber[] = proposeRootBundleEvent.bundleEvaluationBlockNumbers;
|
|
998
|
+
const chainIdIndex = chainIdList.indexOf(chainId);
|
|
999
|
+
if (chainIdIndex === -1) {
|
|
1000
|
+
return 0;
|
|
1001
|
+
}
|
|
1002
|
+
// Sometimes, the root bundle event's chain ID list will update from bundle to bundle, so we need to check that
|
|
1003
|
+
// the bundle evaluation block number list is long enough to contain this index. We assume that chain ID's
|
|
1004
|
+
// are only added to the bundle block list, never deleted.
|
|
1005
|
+
if (chainIdIndex >= bundleEvaluationBlockNumbers.length) {
|
|
1006
|
+
return 0;
|
|
1007
|
+
}
|
|
1008
|
+
return bundleEvaluationBlockNumbers[chainIdIndex].toNumber();
|
|
1009
|
+
}
|
|
1010
|
+
}
|