@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,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deduplicates an array by filtering it via a Set.
|
|
3
|
+
* @notice Should not be used for deduplicating arrays of complex types.
|
|
4
|
+
* @param array The array to deduplicate.
|
|
5
|
+
* @returns A new array, filtered for uniqueness.
|
|
6
|
+
*/
|
|
7
|
+
export function dedupArray<T>(array: T[]): T[] {
|
|
8
|
+
return Array.from(new Set(array));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Splits an arbitrary array into a series of chunks.
|
|
13
|
+
* @param array The array to chunk.
|
|
14
|
+
* @param chunkSize The maximum size of any chunk within the array.
|
|
15
|
+
* @returns A new array of chunked members.
|
|
16
|
+
*/
|
|
17
|
+
export function chunk<T>(array: T[], chunkSize: number): T[][] {
|
|
18
|
+
const chunks: T[][] = [];
|
|
19
|
+
|
|
20
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
21
|
+
chunks.push(array.slice(i, i + chunkSize));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return chunks;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns the last index of an array that matches the given predicate.
|
|
29
|
+
* @note Emulates Array.prototype.findLastIndex
|
|
30
|
+
* @param array The array to search.
|
|
31
|
+
* @param predicate The predicate function to apply to each element.
|
|
32
|
+
* @returns The last index of the array that matches the predicate, or -1 if no element matches.
|
|
33
|
+
*/
|
|
34
|
+
export function findLastIndex<T>(array: T[], predicate: (value: T, index: number, obj: T[]) => boolean): number {
|
|
35
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
36
|
+
if (predicate(array[i], i, array)) {
|
|
37
|
+
return i;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Returns the last element of an array that matches the given predicate.
|
|
45
|
+
* @note Emulates Array.prototype.findLast
|
|
46
|
+
* @param array The array to search.
|
|
47
|
+
* @param predicate The predicate function to apply to each element.
|
|
48
|
+
* @returns The last element of the array that matches the predicate, or undefined if no element matches.
|
|
49
|
+
*/
|
|
50
|
+
export function findLast<T>(array: T[], predicate: (value: T, index: number, obj: T[]) => boolean): T | undefined {
|
|
51
|
+
const index = findLastIndex(array, predicate);
|
|
52
|
+
return index >= 0 ? array[index] : undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Performs an asynchronous filter operation on an array. This function behaves like Array.prototype.filter, but
|
|
57
|
+
* accepts an asynchronous predicate function.
|
|
58
|
+
* @param array The array to filter.
|
|
59
|
+
* @param predicate The asynchronous predicate function to apply to each element.
|
|
60
|
+
* @returns A promise that resolves to an array of elements that match the predicate.
|
|
61
|
+
*/
|
|
62
|
+
export async function filterAsync<T>(
|
|
63
|
+
array: T[],
|
|
64
|
+
predicate: (value: T, index: number, obj: T[]) => Promise<boolean>
|
|
65
|
+
): Promise<T[]> {
|
|
66
|
+
const results = await Promise.all(array.map(predicate));
|
|
67
|
+
return array.filter((_, index) => results[index]);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Performs an asynchronous map operation on an array. This function behaves like Array.prototype.map, but accepts an
|
|
72
|
+
* asynchronous mapper function.
|
|
73
|
+
* @param array The array to map.
|
|
74
|
+
* @param mapper The asynchronous mapper function to apply to each element.
|
|
75
|
+
* @returns A promise that resolves to an array of mapped elements.
|
|
76
|
+
*/
|
|
77
|
+
export function mapAsync<T, U>(array: T[], mapper: (value: T, index: number, obj: T[]) => Promise<U>): Promise<U[]> {
|
|
78
|
+
return Promise.all(array.map(mapper));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Performs an asynchronous reduce operation on an array. This function behaves like Array.prototype.reduce, but
|
|
83
|
+
* accepts an asynchronous reducer function.
|
|
84
|
+
* @param array The array to reduce.
|
|
85
|
+
* @param reducer The asynchronous reducer function to apply to each element.
|
|
86
|
+
* @param initialValue The initial value of the accumulator.
|
|
87
|
+
* @returns A promise that resolves to the final value of the accumulator.
|
|
88
|
+
*/
|
|
89
|
+
export async function reduceAsync<T, U>(
|
|
90
|
+
array: T[],
|
|
91
|
+
reducer: (accumulator: U, currentValue: T, currentIndex: number, obj: T[]) => Promise<U>,
|
|
92
|
+
initialValue: U
|
|
93
|
+
): Promise<U> {
|
|
94
|
+
let accumulator = initialValue;
|
|
95
|
+
for (let i = 0; i < array.length; i++) {
|
|
96
|
+
accumulator = await reducer(accumulator, array[i], i, array);
|
|
97
|
+
}
|
|
98
|
+
return accumulator;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Performs an asynchronous forEach operation on an array. This function behaves like Array.prototype.forEach, but
|
|
103
|
+
* accepts an asynchronous callback function.
|
|
104
|
+
* @param array The array to iterate over.
|
|
105
|
+
* @param callback The asynchronous callback function to apply to each element.
|
|
106
|
+
* @returns A promise that resolves to void.
|
|
107
|
+
*/
|
|
108
|
+
export async function forEachAsync<T>(
|
|
109
|
+
array: T[],
|
|
110
|
+
callback: (value: T, index: number, obj: T[]) => Promise<void>
|
|
111
|
+
): Promise<void> {
|
|
112
|
+
await mapAsync(array, callback);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Performs an asynchronous some operation on an array. This function behaves like Array.prototype.some, but accepts
|
|
117
|
+
* an asynchronous predicate function.
|
|
118
|
+
* @param array The array to search.
|
|
119
|
+
* @param predicate The asynchronous predicate function to apply to each element.
|
|
120
|
+
* @returns A promise that resolves to true if any element matches the predicate, or false if no element matches.
|
|
121
|
+
*/
|
|
122
|
+
export async function someAsync<T>(
|
|
123
|
+
array: T[],
|
|
124
|
+
predicate: (value: T, index: number, obj: T[]) => Promise<boolean>
|
|
125
|
+
): Promise<boolean> {
|
|
126
|
+
const results = await mapAsync(array, predicate);
|
|
127
|
+
return results.some((value) => value);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Performs an asynchronous every operation on an array. This function behaves like Array.prototype.every, but accepts
|
|
132
|
+
* an asynchronous predicate function.
|
|
133
|
+
* @param array The array to test.
|
|
134
|
+
* @param predicate The asynchronous predicate function to apply to each element.
|
|
135
|
+
* @returns A promise that resolves to true if all elements match the predicate, or false if any element does not match.
|
|
136
|
+
* @note This function uses De Morgan's law to convert the predicate to a negated predicate, and then uses someAsync.
|
|
137
|
+
* This is done because it is more efficient to short-circuit on the first false value than the first true value.
|
|
138
|
+
*/
|
|
139
|
+
export async function everyAsync<T>(
|
|
140
|
+
array: T[],
|
|
141
|
+
predicate: (value: T, index: number, obj: T[]) => Promise<boolean>
|
|
142
|
+
): Promise<boolean> {
|
|
143
|
+
return !(await someAsync(array, async (value, index, obj) => !(await predicate(value, index, obj))));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Performs an asynchronous includes operation on an array. This function behaves like Array.prototype.includes, but
|
|
148
|
+
* accepts an asynchronous predicate function.
|
|
149
|
+
* @param array The array to search.
|
|
150
|
+
* @param predicate The asynchronous predicate function to apply to each element.
|
|
151
|
+
* @returns A promise that resolves to true if any element matches the predicate, or false if no element matches.
|
|
152
|
+
* @note This function uses someAsync.
|
|
153
|
+
*/
|
|
154
|
+
export function includesAsync<T>(
|
|
155
|
+
array: T[],
|
|
156
|
+
predicate: (value: T, index: number, obj: T[]) => Promise<boolean>
|
|
157
|
+
): Promise<boolean> {
|
|
158
|
+
return someAsync(array, predicate);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* A generic type guard for arrays of a specific type.
|
|
163
|
+
* @param array The array to test.
|
|
164
|
+
* @param predicate The type guard predicate function to apply to each element.
|
|
165
|
+
* @returns True if the array is an array of the specified type, or false otherwise.
|
|
166
|
+
* @note This function uses Array.prototype.every.
|
|
167
|
+
*/
|
|
168
|
+
export function isArrayOf<T>(array: unknown, predicate: (value: unknown) => value is T): array is T[] {
|
|
169
|
+
return Array.isArray(array) && array.every(predicate);
|
|
170
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Responsible for providing utility functions for working with BigNumbers.
|
|
3
|
+
* @module utils/BigNumberUtils
|
|
4
|
+
* @author Across Protocol
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ethers, BigNumber } from "ethers";
|
|
8
|
+
|
|
9
|
+
export type BigNumberish = ethers.BigNumberish;
|
|
10
|
+
export type BN = ethers.BigNumber;
|
|
11
|
+
|
|
12
|
+
export const { Zero: bnZero, One: bnOne, MaxUint256: bnUint256Max } = ethers.constants;
|
|
13
|
+
|
|
14
|
+
export const bnUint32Max = BigNumber.from("0xffffffff");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Converts a stringified number into a BigNumber with 18 decimal places.
|
|
18
|
+
* @param num The number to parse.
|
|
19
|
+
* @returns The parsed BigNumber.
|
|
20
|
+
*/
|
|
21
|
+
export function toWei(num: BigNumberish): BN {
|
|
22
|
+
return ethers.utils.parseEther(num.toString());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Converts a stringified number into a BigNumber with 9 decimal places.
|
|
27
|
+
* @param num The number to parse.
|
|
28
|
+
* @returns The parsed BigNumber.
|
|
29
|
+
*/
|
|
30
|
+
export function toGWei(num: BigNumberish): BN {
|
|
31
|
+
return ethers.utils.parseUnits(num.toString(), 9);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Converts a stringified number into a BigNumber.
|
|
36
|
+
* If the string version of the num contains a `.` then it is a number which needs to be parsed to a string int.
|
|
37
|
+
* @param num The number to parse.
|
|
38
|
+
* @param rounding The rounding method to use if the number has a decimal point. Defaults to "floor" or rounding down. Valid values are "floor", "round", and "ceil".
|
|
39
|
+
* @returns The parsed BigNumber.
|
|
40
|
+
* @note This is a temporary function until we can backport support for decimal points to @across-protocol/sdk.
|
|
41
|
+
*/
|
|
42
|
+
export const toBN = (num: BigNumberish, rounding: "floor" | "round" | "ceil" = "floor"): BN => {
|
|
43
|
+
// If the string version of the num contains a `.` then it is a number which needs to be parsed to a string int.
|
|
44
|
+
if (num.toString().includes(".")) {
|
|
45
|
+
// Destructure the integer and decimal parts of the number.
|
|
46
|
+
const [integer, decimal] = num.toString().split(".");
|
|
47
|
+
// We can determine if we need to round in a losseless way. First we need to check
|
|
48
|
+
// if the number just has a decimal point with no decimal places. If it does, we
|
|
49
|
+
// can just return the integer. However, if it has a decimal point with decimal
|
|
50
|
+
// places, then we can automatically round up if ceil is specified or if round is
|
|
51
|
+
// specified and the first decimal is greater than or equal to 5.
|
|
52
|
+
const roundUp = decimal.length > 0 && (rounding === "ceil" || (rounding === "round" && parseInt(decimal[0]) >= 5));
|
|
53
|
+
// If we need to round up, we can just add 1 to the integer.
|
|
54
|
+
return BigNumber.from(integer).add(roundUp ? 1 : 0);
|
|
55
|
+
}
|
|
56
|
+
// Otherwise, it is a string int and we can parse it directly.
|
|
57
|
+
return BigNumber.from(num.toString());
|
|
58
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { PUBLIC_NETWORKS } from "../constants";
|
|
3
|
+
import { createShortHexString } from "./FormattingUtils";
|
|
4
|
+
import { isDefined } from "./TypeGuards";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a block explorer link for a transaction or address on a given network.
|
|
8
|
+
* @param txHashOrAddress The transaction hash or address to link to.
|
|
9
|
+
* @param chainId The chainId to link to.
|
|
10
|
+
* @returns The block explorer link. This link will be formatted in markdown.
|
|
11
|
+
*/
|
|
12
|
+
export function blockExplorerLink(txHashOrAddress: string, chainId: number | string): string {
|
|
13
|
+
return _createBlockExplorerLinkMarkdown(txHashOrAddress, Number(chainId)) ?? "<>";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolves a domain to an block explorer link for a given network.
|
|
18
|
+
* @param networkId The network to link to.
|
|
19
|
+
* @returns The block explorer link. If the networkId is not supported, undefined will be returned.
|
|
20
|
+
*/
|
|
21
|
+
export function resolveBlockExplorerDomain(networkId: number): string | undefined {
|
|
22
|
+
return PUBLIC_NETWORKS[networkId]?.blockExplorer;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Constructs a URL for a given list of domain parts.
|
|
27
|
+
* @param domain The domain to construct a URL for.
|
|
28
|
+
* @param parts The relative path of parts to append to the domain. These parts will be joined with a "/".
|
|
29
|
+
* @returns The constructed URL.
|
|
30
|
+
* @see resolveBlockExplorerDomain
|
|
31
|
+
* @example constructURL("https://example.com", ["path", "to", "resource"]) => "https://example.com/path/to/resource"
|
|
32
|
+
* @example constructURL("https://example.com", ["path", "to", "resource", ""]) => "https://example.com/path/to/resource"
|
|
33
|
+
* @example constructURL("https://example.com", ["path", "to//", "resource",]) => "https://example.com/path/to/resource"
|
|
34
|
+
*/
|
|
35
|
+
function constructURL(domain: string, parts: string[]): string {
|
|
36
|
+
// Further split the parts by "/" to handle any parts that contain multiple "/".
|
|
37
|
+
parts = parts.flatMap((p) => p.split("/"));
|
|
38
|
+
// Remove any empty parts.
|
|
39
|
+
parts = parts.filter((p) => p !== "");
|
|
40
|
+
// Join the parts with a "/".
|
|
41
|
+
const path = parts.join("/");
|
|
42
|
+
// Remove any trailing "/".
|
|
43
|
+
return `${domain}/${path}`.replace(/\/+$/, "");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Generates a valid block explorer link for a given transaction hash or address.
|
|
48
|
+
* @param hex The transaction hash or address to link to.
|
|
49
|
+
* @param chainId The chainId to link to.
|
|
50
|
+
* @returns A formatted markdown block explorer link to the given transaction hash or address on the given chainId.
|
|
51
|
+
*/
|
|
52
|
+
function _createBlockExplorerLinkMarkdown(hex: string, chainId = 1): string | null {
|
|
53
|
+
// Attempt to resolve the block explorer domain for the given chainId.
|
|
54
|
+
const explorerDomain = resolveBlockExplorerDomain(chainId);
|
|
55
|
+
// If the chainId is not supported, return an unsupported link.
|
|
56
|
+
if (!isDefined(explorerDomain)) {
|
|
57
|
+
return `<unsupported chain/hash ${chainId}:${hex}>}`;
|
|
58
|
+
}
|
|
59
|
+
// Ensure that the first two characters are "0x". If they are not, append them.
|
|
60
|
+
if (hex.substring(0, 2) !== "0x") {
|
|
61
|
+
hex = `0x${hex}`;
|
|
62
|
+
}
|
|
63
|
+
// Ensure that the hex string is a valid hexadecimal string.
|
|
64
|
+
if (!ethers.utils.isHexString(hex)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
// Resolve the short URL string.
|
|
68
|
+
const shortURLString = createShortHexString(hex);
|
|
69
|
+
// Iterate over the two possible hex lengths.
|
|
70
|
+
for (const [length, route] of [
|
|
71
|
+
[66, "tx"],
|
|
72
|
+
[42, "address"],
|
|
73
|
+
] as [number, string][]) {
|
|
74
|
+
// If the hex string is the correct length, return the link.
|
|
75
|
+
if (hex.length === length) {
|
|
76
|
+
return `<${constructURL(explorerDomain, [route, hex])}|${shortURLString}>`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Generates a list of blockExplorer links for a given list of transaction hashes or addresses.
|
|
84
|
+
* @param txHashesOrAddresses The list of transaction hashes or addresses to link to.
|
|
85
|
+
* @param chainId The chainId to link to.
|
|
86
|
+
* @returns A list of formatted markdown block explorer links to the given transaction hashes or addresses on the given chainId.
|
|
87
|
+
* @see blockExplorerLink
|
|
88
|
+
*/
|
|
89
|
+
export function blockExplorerLinks(txHashesOrAddresses: string[], chainId: number | string): string {
|
|
90
|
+
return txHashesOrAddresses.map((hash) => `${blockExplorerLink(hash, chainId)}\n`).join("");
|
|
91
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import type { Block, Provider } from "@ethersproject/abstract-provider";
|
|
3
|
+
import { clamp, sortedIndexBy } from "lodash";
|
|
4
|
+
import { getNetworkName } from "./NetworkUtils";
|
|
5
|
+
import { isDefined } from "./TypeGuards";
|
|
6
|
+
import { getCurrentTime } from "./TimeUtils";
|
|
7
|
+
import { CachingMechanismInterface } from "../interfaces";
|
|
8
|
+
import { shouldCache } from "./CachingUtils";
|
|
9
|
+
import { DEFAULT_CACHING_SAFE_LAG } from "../constants";
|
|
10
|
+
|
|
11
|
+
type Opts = {
|
|
12
|
+
highBlock?: number;
|
|
13
|
+
highBlockOffset?: number;
|
|
14
|
+
blockRange?: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type BlockTimeAverage = {
|
|
18
|
+
average: number;
|
|
19
|
+
blockRange: number;
|
|
20
|
+
timestamp: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Archive requests typically commence at 128 blocks past the head of the chain.
|
|
24
|
+
// Round down to 120 blocks to avoid slipping into archive territory.
|
|
25
|
+
const defaultBlockRange = 120;
|
|
26
|
+
|
|
27
|
+
// Default offset to the high block number. This is subtracted from the block number of the high block
|
|
28
|
+
// when it is queried from the network, rather than having been specified by the caller. This is useful
|
|
29
|
+
// since the supplied Provider instance may be backed by multiple RPC providers, which can lead to some
|
|
30
|
+
// providers running slower than others and taking time to synchronise on the latest block.
|
|
31
|
+
const defaultHighBlockOffset = 10;
|
|
32
|
+
|
|
33
|
+
// Retain computations for 15 minutes.
|
|
34
|
+
const cacheTTL = 60 * 15;
|
|
35
|
+
const now = getCurrentTime(); // Seed the cache with initial values.
|
|
36
|
+
const blockTimes: { [chainId: number]: BlockTimeAverage } = {
|
|
37
|
+
1: { average: 12.5, timestamp: now, blockRange: 1 },
|
|
38
|
+
10: { average: 2, timestamp: now, blockRange: 1 },
|
|
39
|
+
8453: { average: 2, timestamp: now, blockRange: 1 },
|
|
40
|
+
34443: { average: 2, timestamp: now, blockRange: 1 },
|
|
41
|
+
59144: { average: 3, timestamp: now, blockRange: 1 },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @description Compute the average block time over a block range.
|
|
46
|
+
* @returns Average number of seconds per block.
|
|
47
|
+
*/
|
|
48
|
+
export async function averageBlockTime(
|
|
49
|
+
provider: Provider,
|
|
50
|
+
{ highBlock, highBlockOffset, blockRange }: Opts = {}
|
|
51
|
+
): Promise<Pick<BlockTimeAverage, "average" | "blockRange">> {
|
|
52
|
+
// Does not block for StaticJsonRpcProvider.
|
|
53
|
+
const chainId = (await provider.getNetwork()).chainId;
|
|
54
|
+
|
|
55
|
+
const cache = blockTimes[chainId];
|
|
56
|
+
const now = getCurrentTime();
|
|
57
|
+
if (isDefined(cache) && now < cache.timestamp + cacheTTL) {
|
|
58
|
+
return { average: cache.average, blockRange: cache.blockRange };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// If the caller was not specific about highBlock, resolve it via the RPC provider. Subtract an offset
|
|
62
|
+
// to account for various RPC provider sync issues that might occur when querting the latest block.
|
|
63
|
+
if (!isDefined(highBlock)) {
|
|
64
|
+
highBlock = await provider.getBlockNumber();
|
|
65
|
+
highBlock -= highBlockOffset ?? defaultHighBlockOffset;
|
|
66
|
+
}
|
|
67
|
+
blockRange ??= defaultBlockRange;
|
|
68
|
+
|
|
69
|
+
const earliestBlockNumber = highBlock - blockRange;
|
|
70
|
+
const [firstBlock, lastBlock] = await Promise.all([
|
|
71
|
+
provider.getBlock(earliestBlockNumber),
|
|
72
|
+
provider.getBlock(highBlock),
|
|
73
|
+
]);
|
|
74
|
+
[firstBlock, lastBlock].forEach((block: Block | undefined) => {
|
|
75
|
+
if (!isDefined(block?.timestamp)) {
|
|
76
|
+
const network = getNetworkName(chainId);
|
|
77
|
+
const blockNumber = block === firstBlock ? earliestBlockNumber : highBlock;
|
|
78
|
+
throw new Error(`BlockFinder: Failed to fetch block ${blockNumber} on ${network}`);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const average = (lastBlock.timestamp - firstBlock.timestamp) / blockRange;
|
|
83
|
+
blockTimes[chainId] = { timestamp: now, average, blockRange };
|
|
84
|
+
|
|
85
|
+
return { average, blockRange };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function estimateBlocksElapsed(seconds: number, cushionPercentage = 0.0, provider: Provider): Promise<number> {
|
|
89
|
+
const cushionMultiplier = cushionPercentage + 1.0;
|
|
90
|
+
const { average } = await averageBlockTime(provider);
|
|
91
|
+
return Math.floor((seconds * cushionMultiplier) / average);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type BlockFinderHints = {
|
|
95
|
+
lowBlock?: number;
|
|
96
|
+
highBlock?: number;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export class BlockFinder {
|
|
100
|
+
constructor(
|
|
101
|
+
private readonly provider: Provider,
|
|
102
|
+
private readonly blocks: Block[] = []
|
|
103
|
+
) {}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @notice Gets the latest block whose timestamp is <= the provided timestamp.
|
|
107
|
+
* @param number Timestamp timestamp to search.
|
|
108
|
+
* @param hints Optional low and high block to bound the search space.
|
|
109
|
+
*/
|
|
110
|
+
public async getBlockForTimestamp(timestamp: number | string, hints: BlockFinderHints = {}): Promise<Block> {
|
|
111
|
+
timestamp = Number(timestamp);
|
|
112
|
+
assert(timestamp !== undefined && timestamp !== null, "timestamp must be provided");
|
|
113
|
+
// If the last block we have stored is too early, grab the latest block.
|
|
114
|
+
if (this.blocks.length === 0 || this.blocks[this.blocks.length - 1].timestamp < timestamp) {
|
|
115
|
+
const block = await this.getLatestBlock();
|
|
116
|
+
if (timestamp >= block.timestamp) return block;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Prime the BlockFinder cache with any supplied hints.
|
|
120
|
+
// If the hint is accurate, then this will bypass the subsequent estimation.
|
|
121
|
+
await Promise.all(
|
|
122
|
+
Object.values(hints)
|
|
123
|
+
.filter((blockNumber) => isDefined(blockNumber))
|
|
124
|
+
.map((blockNumber) => this.getBlock(blockNumber))
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
// Check the first block. If it's greater than our timestamp, we need to find an earlier block.
|
|
128
|
+
if (this.blocks[0].timestamp > timestamp) {
|
|
129
|
+
const initialBlock = this.blocks[0];
|
|
130
|
+
// We use a 2x cushion to reduce the number of iterations in the following loop and increase the chance
|
|
131
|
+
// that the first block we find sets a floor for the target timestamp. The loop converges on the correct block
|
|
132
|
+
// slower than the following incremental search performed by `findBlock`, so we want to minimize the number of
|
|
133
|
+
// loop iterations in favor of searching more blocks over the `findBlock` search.
|
|
134
|
+
const cushion = 1;
|
|
135
|
+
const incrementDistance = Math.max(
|
|
136
|
+
// Ensure the increment block distance is _at least_ a single block to prevent an infinite loop.
|
|
137
|
+
await estimateBlocksElapsed(initialBlock.timestamp - timestamp, cushion, this.provider),
|
|
138
|
+
1
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// Search backwards by a constant increment until we find a block before the timestamp or hit block 0.
|
|
142
|
+
for (let multiplier = 1; ; multiplier++) {
|
|
143
|
+
const distance = multiplier * incrementDistance;
|
|
144
|
+
const blockNumber = Math.max(0, initialBlock.number - distance);
|
|
145
|
+
const block = await this.getBlock(blockNumber);
|
|
146
|
+
if (block.timestamp <= timestamp) break; // Found an earlier block.
|
|
147
|
+
assert(blockNumber > 0, "timestamp is before block 0"); // Block 0 was not earlier than this timestamp. The row.
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Find the index where the block would be inserted and use that as the end block (since it is >= the timestamp).
|
|
152
|
+
const index = sortedIndexBy(this.blocks, { timestamp } as Block, "timestamp");
|
|
153
|
+
return this.findBlock(this.blocks[index - 1], this.blocks[index], timestamp);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Grabs the most recent block and caches it.
|
|
157
|
+
private async getLatestBlock() {
|
|
158
|
+
const block = await this.provider.getBlock("latest");
|
|
159
|
+
const index = sortedIndexBy(this.blocks, block, "number");
|
|
160
|
+
if (this.blocks[index]?.number !== block.number) this.blocks.splice(index, 0, block);
|
|
161
|
+
return this.blocks[index];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Grabs the block for a particular number and caches it.
|
|
165
|
+
private async getBlock(number: number) {
|
|
166
|
+
let index = sortedIndexBy(this.blocks, { number } as Block, "number");
|
|
167
|
+
if (this.blocks[index]?.number === number) return this.blocks[index]; // Return early if block already exists.
|
|
168
|
+
const block = await this.provider.getBlock(number);
|
|
169
|
+
|
|
170
|
+
// Recompute the index after the async call since the state of this.blocks could have changed!
|
|
171
|
+
index = sortedIndexBy(this.blocks, { number } as Block, "number");
|
|
172
|
+
|
|
173
|
+
// Rerun this check to avoid duplicate insertion.
|
|
174
|
+
if (this.blocks[index]?.number === number) return this.blocks[index];
|
|
175
|
+
this.blocks.splice(index, 0, block); // A simple insert at index.
|
|
176
|
+
return block;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Return the latest block, between startBlock and endBlock, whose timestamp is <= timestamp.
|
|
180
|
+
// Effectively, this is an interpolation search algorithm to minimize block requests.
|
|
181
|
+
// Note: startBlock and endBlock _must_ be different blocks.
|
|
182
|
+
private async findBlock(_startBlock: Block, _endBlock: Block, timestamp: number): Promise<Block> {
|
|
183
|
+
const [startBlock, endBlock] = [_startBlock, _endBlock];
|
|
184
|
+
// In the case of equality, the endBlock is expected to be passed as the one whose timestamp === the requested
|
|
185
|
+
// timestamp.
|
|
186
|
+
if (endBlock.timestamp === timestamp) return endBlock;
|
|
187
|
+
|
|
188
|
+
// If there's no equality, but the blocks are adjacent, return the startBlock, since we want the returned block's
|
|
189
|
+
// timestamp to be <= the requested timestamp.
|
|
190
|
+
if (endBlock.number === startBlock.number + 1) return startBlock;
|
|
191
|
+
|
|
192
|
+
assert(endBlock.number !== startBlock.number, "startBlock cannot equal endBlock");
|
|
193
|
+
assert(
|
|
194
|
+
timestamp < endBlock.timestamp && timestamp > startBlock.timestamp,
|
|
195
|
+
"timestamp not in between start and end blocks"
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
// Interpolating the timestamp we're searching for to block numbers.
|
|
199
|
+
const totalTimeDifference = endBlock.timestamp - startBlock.timestamp;
|
|
200
|
+
const totalBlockDistance = endBlock.number - startBlock.number;
|
|
201
|
+
const blockPercentile = (timestamp - startBlock.timestamp) / totalTimeDifference;
|
|
202
|
+
const estimatedBlock = startBlock.number + Math.round(blockPercentile * totalBlockDistance);
|
|
203
|
+
|
|
204
|
+
// Clamp ensures the estimated block is strictly greater than the start block and strictly less than the end block.
|
|
205
|
+
const newBlock = await this.getBlock(clamp(estimatedBlock, startBlock.number + 1, endBlock.number - 1));
|
|
206
|
+
|
|
207
|
+
// Depending on whether the new block is below or above the timestamp, narrow the search space accordingly.
|
|
208
|
+
if (newBlock.timestamp < timestamp) {
|
|
209
|
+
return this.findBlock(newBlock, endBlock, timestamp);
|
|
210
|
+
} else {
|
|
211
|
+
return this.findBlock(startBlock, newBlock, timestamp);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @notice Get the block number for a given timestamp fresh from on-chain data if not found in redis cache.
|
|
218
|
+
* If redis cache is not available, then requests block from blockFinder.
|
|
219
|
+
* @param chainId Chain to load block finder for.
|
|
220
|
+
* @param timestamp Approximate timestamp of the to requested block number.
|
|
221
|
+
* @param blockFinder Caller can optionally pass in a block finder object to use instead of creating a new one
|
|
222
|
+
* or loading from cache. This is useful for testing primarily.
|
|
223
|
+
* @returns Block number for the requested timestamp.
|
|
224
|
+
*/
|
|
225
|
+
export async function getCachedBlockForTimestamp(
|
|
226
|
+
chainId: number,
|
|
227
|
+
timestamp: number,
|
|
228
|
+
blockFinder: BlockFinder,
|
|
229
|
+
cache?: CachingMechanismInterface,
|
|
230
|
+
hints?: BlockFinderHints
|
|
231
|
+
): Promise<number> {
|
|
232
|
+
// Resolve a convenience function to directly compute what we're
|
|
233
|
+
// looking for.
|
|
234
|
+
const resolver = async () => (await blockFinder.getBlockForTimestamp(timestamp, hints)).number;
|
|
235
|
+
|
|
236
|
+
// If no redis client, then request block from blockFinder.
|
|
237
|
+
if (!isDefined(cache)) {
|
|
238
|
+
return resolver();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Cache exists. We should first check if it's possible to retrieve the block number from cache.
|
|
242
|
+
|
|
243
|
+
// Resolve the key for the block number.
|
|
244
|
+
const key = `${chainId}_block_number_${timestamp}`;
|
|
245
|
+
// See if it's even possible to retrieve the block number from cache.
|
|
246
|
+
if (shouldCache(timestamp, getCurrentTime(), DEFAULT_CACHING_SAFE_LAG)) {
|
|
247
|
+
// Attempt to retrieve the block number from cache.
|
|
248
|
+
const result = await cache.get<string>(key);
|
|
249
|
+
// If the block number is in cache, then return it.
|
|
250
|
+
if (result !== null) {
|
|
251
|
+
return parseInt(result);
|
|
252
|
+
}
|
|
253
|
+
// Otherwise, we need to resolve the block number and cache it.
|
|
254
|
+
else {
|
|
255
|
+
const blockNumber = await resolver();
|
|
256
|
+
// Expire key after 90 days.
|
|
257
|
+
await cache.set(key, blockNumber.toString(), 60 * 60 * 24 * 90); // 90 days
|
|
258
|
+
return blockNumber;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// It's too early to cache this key. Resolve the block number and return it.
|
|
262
|
+
else {
|
|
263
|
+
return resolver();
|
|
264
|
+
}
|
|
265
|
+
}
|