@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,36 @@
|
|
|
1
|
+
# Price Client
|
|
2
|
+
An interface for retrieving Ethereum ERC20 prices from various price feeds.
|
|
3
|
+
|
|
4
|
+
# Overview
|
|
5
|
+
The PriceClient aggregates user-defined preferential list of price feeds. This permits prices to be retrieved from a range of sources according to preference (i.e. failover to a lesser-preferred source in the event that a more-preferred source is unavailable).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
- Basic support for caching of prices.
|
|
9
|
+
- Support for bundling token price requests.
|
|
10
|
+
- Currently supported price feeds:
|
|
11
|
+
- CoinGecko (Free & Pro)
|
|
12
|
+
- Across API
|
|
13
|
+
- Candidates for future addition:
|
|
14
|
+
- DefiLlama
|
|
15
|
+
- On-chain lookups (i.e. Uniswap)
|
|
16
|
+
|
|
17
|
+
This code can be independently used by bots, the frontend, and the backend Across API:
|
|
18
|
+
- Bots can source their prices from the Across API, falling back to CoinGecko.
|
|
19
|
+
- The frontend can use this for greater robustness, and to abstract away the source of its price feeds.
|
|
20
|
+
- The API can add additional fallback price feeds to ensure that it is always able to resolve a price.
|
|
21
|
+
|
|
22
|
+
The interface exposed by this feature maps very closely to our existing Coingecko API.
|
|
23
|
+
|
|
24
|
+
### Preferential token price lookups
|
|
25
|
+
The PriceClient is initialised with an ordered list of Price Feeds. When performing price lookups, it will iterate through this list until it is able to successfully resolve a price for the requested tokens.
|
|
26
|
+
|
|
27
|
+
### Token price cache with configurable age
|
|
28
|
+
PriceClient.maxPriceAge controls the maximum age (in seconds) for cached prices. When a price is requested by a caller, the PriceClient will serve directly out of its internal cache if it holds a price that is younger than the maximum price age. This bypasses an external price lookup and may be used to mitigate rate-limiting. If no price is held, or if an expired price is held, then the PriceClient will perform the lookup against its ordered list of price feeds.
|
|
29
|
+
|
|
30
|
+
## Constraints
|
|
31
|
+
- There is no mapping of individual tokens to upstream PriceFeedAdapters.
|
|
32
|
+
If some tokens are only available from specific sources, then a separate
|
|
33
|
+
PriceClient instance may be used.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
Usage instructions will be added.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { msToS, PriceFeedAdapter, TokenPrice } from "../priceClient";
|
|
2
|
+
import { BaseHTTPAdapter, BaseHTTPAdapterArgs } from "./baseAdapter";
|
|
3
|
+
|
|
4
|
+
type AcrossPrice = { price: number };
|
|
5
|
+
type AcrossApiArgs = BaseHTTPAdapterArgs & {
|
|
6
|
+
name?: string;
|
|
7
|
+
host?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export class PriceFeed extends BaseHTTPAdapter implements PriceFeedAdapter {
|
|
11
|
+
constructor({
|
|
12
|
+
name = "Across API",
|
|
13
|
+
host = "across.to",
|
|
14
|
+
timeout = 5000, // ms
|
|
15
|
+
retries = 3,
|
|
16
|
+
}: AcrossApiArgs = {}) {
|
|
17
|
+
// Allow host to be overridden for test or alternative deployments.
|
|
18
|
+
super(name, host, { timeout, retries });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async getPriceByAddress(address: string, currency = "usd"): Promise<TokenPrice> {
|
|
22
|
+
const queryArgs = {
|
|
23
|
+
l1Token: address,
|
|
24
|
+
baseCurrency: currency,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const now = msToS(Date.now()) - 60; // Assume price is 60 seconds old.
|
|
28
|
+
const response: unknown = await this.query("api/coingecko", queryArgs);
|
|
29
|
+
if (!this.validateResponse(response))
|
|
30
|
+
throw new Error(`Unexpected ${this.name} response: ${JSON.stringify(response)}`);
|
|
31
|
+
|
|
32
|
+
return { address: address, price: response.price, timestamp: now };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// todo: Support bundled prices in the API endpoint.
|
|
36
|
+
getPricesByAddress(addresses: string[], currency = "usd"): Promise<TokenPrice[]> {
|
|
37
|
+
return Promise.all(addresses.map((address) => this.getPriceByAddress(address, currency)));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private validateResponse(response: unknown): response is AcrossPrice {
|
|
41
|
+
if (typeof response !== "object") return false;
|
|
42
|
+
return response !== null && typeof (response as { [key: string]: unknown }).price === "number";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
|
|
4
|
+
export type BaseHTTPAdapterArgs = {
|
|
5
|
+
timeout?: number;
|
|
6
|
+
retries?: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export class BaseHTTPAdapter {
|
|
10
|
+
private _retries = 0;
|
|
11
|
+
private _timeout = 0;
|
|
12
|
+
|
|
13
|
+
get retries(): number {
|
|
14
|
+
return this._retries;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
set retries(retries: number) {
|
|
18
|
+
assert(retries >= 0);
|
|
19
|
+
this._retries = retries;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get timeout(): number {
|
|
23
|
+
return this._timeout;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set timeout(timeout: number) {
|
|
27
|
+
assert(timeout >= 0);
|
|
28
|
+
this._timeout = timeout;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
public readonly name: string,
|
|
33
|
+
public readonly host: string,
|
|
34
|
+
{ timeout = 1000, retries = 1 }: BaseHTTPAdapterArgs
|
|
35
|
+
) {
|
|
36
|
+
this.retries = retries;
|
|
37
|
+
this.timeout = timeout; // ms
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected async query(path: string, urlArgs?: object): Promise<unknown> {
|
|
41
|
+
const url = `https://${this.host}/${path ?? ""}`;
|
|
42
|
+
const args = {
|
|
43
|
+
timeout: this.timeout,
|
|
44
|
+
params: urlArgs ?? {},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const errs: string[] = [];
|
|
48
|
+
let tries = 0;
|
|
49
|
+
do {
|
|
50
|
+
try {
|
|
51
|
+
return (await axios(url, args)).data;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
const errMsg = axios.isAxiosError(err) || err instanceof Error ? err.message : "unknown error";
|
|
54
|
+
errs.push(errMsg);
|
|
55
|
+
if (++tries <= this.retries) await this.sleep(Math.pow(1.5, tries) * 1000); // simple backoff
|
|
56
|
+
}
|
|
57
|
+
} while (tries <= this.retries);
|
|
58
|
+
|
|
59
|
+
throw new Error(`${this.name} price lookup failure (${errs.join(", ")})`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
protected sleep(ms: number): Promise<void> {
|
|
63
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { PriceFeedAdapter, TokenPrice } from "../priceClient";
|
|
2
|
+
import { BaseHTTPAdapter, BaseHTTPAdapterArgs } from "./baseAdapter";
|
|
3
|
+
|
|
4
|
+
type CoinGeckoTokenPrice = {
|
|
5
|
+
[currency: string]: number;
|
|
6
|
+
last_updated_at: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type CoinGeckoPriceResponse = {
|
|
10
|
+
[address: string]: CoinGeckoTokenPrice;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type CoinGeckoArgs = BaseHTTPAdapterArgs & {
|
|
14
|
+
name?: string;
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export class PriceFeed extends BaseHTTPAdapter implements PriceFeedAdapter {
|
|
19
|
+
private readonly apiKey: string | undefined = undefined;
|
|
20
|
+
|
|
21
|
+
constructor({ name, apiKey, timeout = 5000, retries = 3 }: CoinGeckoArgs = {}) {
|
|
22
|
+
super(name ?? apiKey ? "CoinGecko Pro" : "CoinGecko Free", apiKey ? "pro-api.coingecko.com" : "api.coingecko.com", {
|
|
23
|
+
timeout,
|
|
24
|
+
retries,
|
|
25
|
+
});
|
|
26
|
+
this.apiKey = apiKey;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async getPriceByAddress(address: string, currency = "usd"): Promise<TokenPrice> {
|
|
30
|
+
const price = await this.getPricesByAddress([address], currency);
|
|
31
|
+
return price[0];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async getPricesByAddress(addresses: string[], currency = "usd"): Promise<TokenPrice[]> {
|
|
35
|
+
const queryArgs: { [key: string]: boolean | string } = {
|
|
36
|
+
contract_addresses: addresses.map((address) => address.toLowerCase()).join(","),
|
|
37
|
+
vs_currencies: currency,
|
|
38
|
+
include_last_updated_at: true,
|
|
39
|
+
};
|
|
40
|
+
if (this.apiKey) queryArgs["x_cg_pro_api_key"] = this.apiKey;
|
|
41
|
+
|
|
42
|
+
const prices: unknown = await this.query("api/v3/simple/token_price/ethereum", queryArgs);
|
|
43
|
+
if (!this.validateResponse(prices, currency))
|
|
44
|
+
throw new Error(`Unexpected ${this.name} response: ${JSON.stringify(prices)}`);
|
|
45
|
+
|
|
46
|
+
return addresses
|
|
47
|
+
.filter((address) => prices[address.toLowerCase()] !== undefined)
|
|
48
|
+
.map((address) => {
|
|
49
|
+
const price: CoinGeckoTokenPrice = prices[address.toLowerCase()];
|
|
50
|
+
return { address, price: price[currency], timestamp: price.last_updated_at };
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private validateResponse(response: unknown, currency: string): response is CoinGeckoPriceResponse {
|
|
55
|
+
if (typeof response !== "object") return false;
|
|
56
|
+
|
|
57
|
+
return Object.entries(response as object).every(([address, tokenPrice]) => {
|
|
58
|
+
// prettier-ignore
|
|
59
|
+
return (
|
|
60
|
+
/0x[0-9a-fA-F]{40}/.exec(address) !== undefined
|
|
61
|
+
&& typeof tokenPrice === "object"
|
|
62
|
+
&& !isNaN(tokenPrice[currency])
|
|
63
|
+
&& !isNaN(tokenPrice.last_updated_at)
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import { PriceFeedAdapter, TokenPrice } from "../priceClient";
|
|
3
|
+
import { BaseHTTPAdapter, BaseHTTPAdapterArgs } from "./baseAdapter";
|
|
4
|
+
|
|
5
|
+
type DefiLlamaTokenPrice = {
|
|
6
|
+
price: number;
|
|
7
|
+
symbol: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
confidence: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type DefiLlamaPriceResponse = {
|
|
13
|
+
coins: {
|
|
14
|
+
[key: string]: DefiLlamaTokenPrice;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type DefiLlamaArgs = BaseHTTPAdapterArgs & {
|
|
19
|
+
name?: string;
|
|
20
|
+
host?: string;
|
|
21
|
+
minConfidence?: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export class PriceFeed extends BaseHTTPAdapter implements PriceFeedAdapter {
|
|
25
|
+
private _minConfidence: number;
|
|
26
|
+
|
|
27
|
+
constructor({
|
|
28
|
+
name = "DefiLlama",
|
|
29
|
+
host = "coins.llama.fi",
|
|
30
|
+
timeout = 5000,
|
|
31
|
+
retries = 2,
|
|
32
|
+
minConfidence = 0.9,
|
|
33
|
+
}: DefiLlamaArgs = {}) {
|
|
34
|
+
super(name, host, { timeout, retries });
|
|
35
|
+
assert(minConfidence >= 0.0 && minConfidence <= 1.0);
|
|
36
|
+
this._minConfidence = minConfidence;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get minConfidence(): number {
|
|
40
|
+
return this._minConfidence;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
set minConfidence(minConfidence: number) {
|
|
44
|
+
assert(minConfidence >= 0.0 && minConfidence <= 1.0);
|
|
45
|
+
this._minConfidence = minConfidence;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async getPriceByAddress(address: string, currency = "usd"): Promise<TokenPrice> {
|
|
49
|
+
const price = await this.getPricesByAddress([address], currency);
|
|
50
|
+
return price[0];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async getPricesByAddress(addresses: string[], currency = "usd"): Promise<TokenPrice[]> {
|
|
54
|
+
if (currency != "usd") throw new Error(`Currency ${currency} not supported by ${this.name}`);
|
|
55
|
+
|
|
56
|
+
const path = "prices/current/" + addresses.map((address) => `ethereum:${address.toLowerCase()}`).join();
|
|
57
|
+
const response: unknown = await this.query(path, {});
|
|
58
|
+
if (!this.validateResponse(response))
|
|
59
|
+
throw new Error(`Unexpected ${this.name} response: ${JSON.stringify(response)}`);
|
|
60
|
+
|
|
61
|
+
// Normalise the address format: "etherum:<address>" => "<address>".
|
|
62
|
+
const tokenPrices: { [address: string]: DefiLlamaTokenPrice } = Object.fromEntries(
|
|
63
|
+
Object.entries(response.coins).map(([identifier, tokenPrice]) => [identifier.split(":")[1], tokenPrice])
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return addresses
|
|
67
|
+
.filter((address) => {
|
|
68
|
+
return (tokenPrices[address.toLowerCase()]?.confidence || 0.0) >= this.minConfidence;
|
|
69
|
+
})
|
|
70
|
+
.map((address) => {
|
|
71
|
+
const { price, timestamp } = tokenPrices[address.toLowerCase()];
|
|
72
|
+
return { address, price, timestamp };
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private validateResponse(response: unknown): response is DefiLlamaPriceResponse {
|
|
77
|
+
if (response === null || typeof response !== "object") return false;
|
|
78
|
+
|
|
79
|
+
const coins: unknown = (response as Record<string, unknown>).coins;
|
|
80
|
+
if (coins === null || typeof coins !== "object") return false;
|
|
81
|
+
|
|
82
|
+
return Object.entries(coins as object).every(([address, tokenPrice]) => {
|
|
83
|
+
// prettier-ignore
|
|
84
|
+
return (
|
|
85
|
+
/[a-z]+:0[xX][0-9a-fA-F]{40}/.exec(address) !== undefined
|
|
86
|
+
&& typeof tokenPrice === "object"
|
|
87
|
+
&& typeof tokenPrice.symbol === "string"
|
|
88
|
+
&& !isNaN(tokenPrice.decimals)
|
|
89
|
+
&& (tokenPrice.decimals > 0 && tokenPrice.decimals <= 18)
|
|
90
|
+
&& !isNaN(tokenPrice.price)
|
|
91
|
+
&& !isNaN(tokenPrice.timestamp)
|
|
92
|
+
&& !isNaN(tokenPrice.confidence)
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import { CoinGeckoPrice } from "../coingecko";
|
|
3
|
+
import { Logger } from "../relayFeeCalculator"; // @todo: Relocate Logger to utils?
|
|
4
|
+
|
|
5
|
+
export { Logger }; // Permit adapters to import a common definition.
|
|
6
|
+
export type TokenPrice = CoinGeckoPrice; // Temporary inversion; CoinGecko should source from here.
|
|
7
|
+
|
|
8
|
+
// Represents valid source for spot prices (Across API, CoinGecko, ...)
|
|
9
|
+
export interface PriceFeedAdapter {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
getPriceByAddress(address: string, currency: string): Promise<TokenPrice>;
|
|
12
|
+
getPricesByAddress(addresses: string[], currency: string): Promise<TokenPrice[]>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// It's convenient to map TokenPrice objects by their address, but consumers typically want an array
|
|
16
|
+
// of TokenPrice objects, so the address must also be embedded within the TokenPrice object. To
|
|
17
|
+
// avoid storing multiple copies of the same TokenPrice, always use the lower-case variant of the
|
|
18
|
+
// address when performing a lookup into the PriceCache, and substitute the provided address into the
|
|
19
|
+
// TokenPrice object when returning to the caller.
|
|
20
|
+
export type PriceCache = {
|
|
21
|
+
[address: string]: TokenPrice;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function msToS(ms: number): number {
|
|
25
|
+
return Math.floor(ms / 1000);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// PriceClient aggregates various user-configured price feeds/sources and retains them for a
|
|
29
|
+
// configurable time period. External price lookups are performed according to an ordered list that
|
|
30
|
+
// is supplied during instantiation. The PriceClient will iterate over the list until a complete set
|
|
31
|
+
// of prices has been retrieved from a single source. External price lookups will opportunistically
|
|
32
|
+
// request new prices for _all_ previously requested tokens. Price lookups into PriceClient will be
|
|
33
|
+
// served out of its local cache if the token price is less than maxPriceAge seconds. This helps to
|
|
34
|
+
// suppress external price lookups and can help to mitigate rate-limiting by external providers.
|
|
35
|
+
// See README.md for further information and usage guidelines.
|
|
36
|
+
export class PriceClient implements PriceFeedAdapter {
|
|
37
|
+
public readonly name: string = "PriceClient";
|
|
38
|
+
private _maxPriceAge = 300; // seconds
|
|
39
|
+
protected prices: {
|
|
40
|
+
[currency: string]: PriceCache;
|
|
41
|
+
} = {};
|
|
42
|
+
|
|
43
|
+
constructor(
|
|
44
|
+
protected logger: Logger,
|
|
45
|
+
readonly priceFeeds: PriceFeedAdapter[]
|
|
46
|
+
) {
|
|
47
|
+
assert(logger, "No logging instance supplied.");
|
|
48
|
+
assert(priceFeeds.length > 0, "No price feeds supplied.");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get maxPriceAge(): number {
|
|
52
|
+
return this._maxPriceAge;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
set maxPriceAge(age: number) {
|
|
56
|
+
assert(age >= 0);
|
|
57
|
+
this.logger.debug({
|
|
58
|
+
at: "PriceClient#maxPriceAge",
|
|
59
|
+
message: `Setting maxPriceAge (S) ${this._maxPriceAge} => ${age}.`,
|
|
60
|
+
});
|
|
61
|
+
this._maxPriceAge = age;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
listPriceFeeds(): string[] {
|
|
65
|
+
return this.priceFeeds.map((priceFeed: PriceFeedAdapter) => priceFeed.name);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async getPriceByAddress(address: string, currency = "usd"): Promise<TokenPrice> {
|
|
69
|
+
const tokenPrices = await this.getPricesByAddress([address], currency);
|
|
70
|
+
return tokenPrices[0];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// note: Input addresses are *always* converted to lower case for storage as
|
|
74
|
+
// keys in the PriceClient cache. Adapters will therefore always receive
|
|
75
|
+
// addresses in lower case form.
|
|
76
|
+
async getPricesByAddress(addresses: string[], currency = "usd"): Promise<TokenPrice[]> {
|
|
77
|
+
assert(this.priceFeeds.length > 0, "No price feeds are registered.");
|
|
78
|
+
const priceCache = this.getPriceCache(currency);
|
|
79
|
+
|
|
80
|
+
// Determine whether each *requested* price is current.
|
|
81
|
+
const now = msToS(Date.now());
|
|
82
|
+
const missed: { [address: string]: number } = {};
|
|
83
|
+
addresses.forEach((address: string) => {
|
|
84
|
+
const addr = address.toLowerCase();
|
|
85
|
+
const tokenPrice = priceCache[addr] ?? ({ price: 0, timestamp: 0 } as TokenPrice);
|
|
86
|
+
priceCache[addr] = tokenPrice; // Update priceCache if necessary;
|
|
87
|
+
|
|
88
|
+
const age = now - tokenPrice.timestamp;
|
|
89
|
+
if (age > this.maxPriceAge) {
|
|
90
|
+
missed[address] = age;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
if (Object.keys(missed).length > 0) {
|
|
95
|
+
this.logger.debug({
|
|
96
|
+
at: "PriceClient#getPricesByAddress",
|
|
97
|
+
message: `${currency.toUpperCase()} cache miss (age > ${this.maxPriceAge} S).`,
|
|
98
|
+
tokens: missed,
|
|
99
|
+
});
|
|
100
|
+
await this.updatePrices(currency);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return addresses.map((address: string) => {
|
|
104
|
+
const { price, timestamp } = priceCache[address.toLowerCase()];
|
|
105
|
+
return { address, price, timestamp };
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
expireCache(currency: string): void {
|
|
110
|
+
const priceCache = this.getPriceCache(currency);
|
|
111
|
+
Object.values(priceCache).forEach((token: TokenPrice) => (token.timestamp = 0));
|
|
112
|
+
this.logger.debug({ at: "PriceClient#expireCache", message: `Expired ${currency} cache.` });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
protected getPriceCache(currency: string): PriceCache {
|
|
116
|
+
if (this.prices[currency] === undefined) this.prices[currency] = {};
|
|
117
|
+
return this.prices[currency];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
private async updatePrices(currency: string): Promise<void> {
|
|
121
|
+
const priceCache = this.getPriceCache(currency);
|
|
122
|
+
let addresses = Object.keys(priceCache);
|
|
123
|
+
|
|
124
|
+
for (const priceFeed of this.priceFeeds) {
|
|
125
|
+
this.logger.debug({
|
|
126
|
+
at: "PriceClient#updatePrices",
|
|
127
|
+
message: `Looking up prices via ${priceFeed.name}.`,
|
|
128
|
+
tokens: addresses,
|
|
129
|
+
});
|
|
130
|
+
try {
|
|
131
|
+
const prices = await priceFeed.getPricesByAddress(addresses, currency);
|
|
132
|
+
addresses = await this.updateCache(priceCache, prices, addresses);
|
|
133
|
+
if (addresses.length === 0) break; // All done
|
|
134
|
+
} catch (err) {
|
|
135
|
+
this.logger.debug({
|
|
136
|
+
at: "PriceClient#updatePrices",
|
|
137
|
+
message: `Price lookup against ${priceFeed.name} failed (${err}).`,
|
|
138
|
+
tokens: addresses,
|
|
139
|
+
});
|
|
140
|
+
// Failover to the next price feed...
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (addresses.length !== 0) {
|
|
145
|
+
this.logger.debug({
|
|
146
|
+
at: "PriceClient#updatePrices",
|
|
147
|
+
message: "Unable to resolve some token prices.",
|
|
148
|
+
priceFeeds: this.listPriceFeeds(),
|
|
149
|
+
tokens: addresses,
|
|
150
|
+
});
|
|
151
|
+
throw new Error(`Price lookup failed against all price feeds (${this.listPriceFeeds().join(", ")})`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private updateCache(priceCache: PriceCache, prices: TokenPrice[], expected: string[]): string[] {
|
|
156
|
+
const updated: TokenPrice[] = [];
|
|
157
|
+
const skipped: { [token: string]: string } = {}; // Includes reason for skipping
|
|
158
|
+
const now = msToS(Date.now());
|
|
159
|
+
|
|
160
|
+
expected.forEach((address: string) => {
|
|
161
|
+
const addr = address.toLowerCase(); // for internal priceCache lookup.
|
|
162
|
+
const tokenPrice: TokenPrice | undefined = prices.find((price) => price?.address?.toLowerCase() === addr);
|
|
163
|
+
|
|
164
|
+
if (tokenPrice === undefined) {
|
|
165
|
+
skipped[address] = "Not included in price feed response.";
|
|
166
|
+
} else if (tokenPrice.timestamp > now) {
|
|
167
|
+
skipped[address] = `Token price timestamp is too new (timestamp ${tokenPrice.timestamp}).`;
|
|
168
|
+
} else if (tokenPrice.timestamp >= priceCache[addr].timestamp) {
|
|
169
|
+
const { price, timestamp } = tokenPrice;
|
|
170
|
+
// Drop the address; we sub it in when returning to the caller.
|
|
171
|
+
// @todo: Do we care if the token price is older than maxPriceAge?
|
|
172
|
+
priceCache[addr] = { price, timestamp } as TokenPrice;
|
|
173
|
+
updated.push(tokenPrice);
|
|
174
|
+
} else if (tokenPrice.timestamp === priceCache[addr].timestamp) {
|
|
175
|
+
this.logger.debug({
|
|
176
|
+
at: "PriceClient#updateCache",
|
|
177
|
+
message: `No new price available for token ${address}.`,
|
|
178
|
+
token: tokenPrice,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
this.logger.debug({
|
|
184
|
+
at: "PriceClient#updateCache",
|
|
185
|
+
message: `Updated ${updated.length ?? 0} price(s), skipped ${Object.keys(skipped).length ?? 0}.`,
|
|
186
|
+
updated,
|
|
187
|
+
skipped,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
return Object.keys(skipped);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Relay Fee Calculator
|
|
2
|
+
|
|
3
|
+
Calculates relay fee percentages for a relay deposit.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
See tests for more documentation: [Relay Fee Calculator Test]("./relayFeeDetails.test.ts")
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import * as across from "@across/sdk"
|
|
11
|
+
import {ethers} from 'ethers'
|
|
12
|
+
|
|
13
|
+
const {RelayFeeCalculator, DefaultQueries} = across.relayFeeCalculator
|
|
14
|
+
|
|
15
|
+
const mainnetUsdcAddress = ethers.utils.getAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
|
|
16
|
+
|
|
17
|
+
// Relay fee calculator requires different queries depending on the chain, the default works with mainnet.
|
|
18
|
+
const provider = ethers.getDefaultProvider(process.env.CUSTOM_NODE_URL);
|
|
19
|
+
const queries = new DefaultQueries(provider)
|
|
20
|
+
const client = new RelayFeeCalculator({queries})
|
|
21
|
+
const result = await client.relayerFeeDetails(100000000,mainnetUsdcAddress)
|
|
22
|
+
// result =
|
|
23
|
+
// {
|
|
24
|
+
// amountToRelay: '100000000',
|
|
25
|
+
// relayFeePercent: '878173320000000000',
|
|
26
|
+
// relayFeeTotal: '87817332',
|
|
27
|
+
// discountPercent: 0,
|
|
28
|
+
// feeLimitPercent: 0,
|
|
29
|
+
// tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
30
|
+
// isAmountTooLow: false
|
|
31
|
+
// }
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { L2Provider } from "@eth-optimism/sdk/dist/interfaces/l2-provider";
|
|
2
|
+
import { providers } from "ethers";
|
|
3
|
+
import { Coingecko } from "../../coingecko";
|
|
4
|
+
import { CHAIN_IDs, DEFAULT_SIMULATED_RELAYER_ADDRESS } from "../../constants";
|
|
5
|
+
import { Deposit } from "../../interfaces";
|
|
6
|
+
import { SpokePool, SpokePool__factory } from "../../typechain";
|
|
7
|
+
import {
|
|
8
|
+
BigNumberish,
|
|
9
|
+
TransactionCostEstimate,
|
|
10
|
+
estimateTotalGasRequiredByUnsignedTransaction,
|
|
11
|
+
populateV3Relay,
|
|
12
|
+
} from "../../utils";
|
|
13
|
+
import { Logger, QueryInterface } from "../relayFeeCalculator";
|
|
14
|
+
|
|
15
|
+
type Provider = providers.Provider;
|
|
16
|
+
type OptimismProvider = L2Provider<Provider>;
|
|
17
|
+
type SymbolMappingType = Record<
|
|
18
|
+
string,
|
|
19
|
+
{
|
|
20
|
+
addresses: Record<number, string>;
|
|
21
|
+
decimals: number;
|
|
22
|
+
}
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A unified QueryBase for querying gas costs, token prices, and decimals of various tokens
|
|
27
|
+
* on a blockchain.
|
|
28
|
+
*/
|
|
29
|
+
export class QueryBase implements QueryInterface {
|
|
30
|
+
readonly spokePool: SpokePool;
|
|
31
|
+
/**
|
|
32
|
+
* Instantiates a QueryBase instance
|
|
33
|
+
* @param provider A valid Ethers.js provider
|
|
34
|
+
* @param symbolMapping A mapping to valid ERC20 tokens and their respective characteristics
|
|
35
|
+
* @param spokePoolAddress The valid address of the Spoke Pool deployment
|
|
36
|
+
* @param simulatedRelayerAddress The address that these queries will reference as the sender. Note: This address must be approved for USDC
|
|
37
|
+
* @param gasMarkup A multiplier that is applied to the total gas estimate
|
|
38
|
+
* @param logger A logging utility to report logs
|
|
39
|
+
* @param coingeckoProApiKey An optional CoinGecko API key that links to a PRO account
|
|
40
|
+
* @param fixedGasPrice Overrides the gas price with a fixed value. Note: primarily used for the Boba blockchain
|
|
41
|
+
* @param coingeckoBaseCurrency The basis currency that CoinGecko will use to resolve pricing
|
|
42
|
+
*/
|
|
43
|
+
constructor(
|
|
44
|
+
readonly provider: Provider | OptimismProvider,
|
|
45
|
+
readonly symbolMapping: SymbolMappingType,
|
|
46
|
+
readonly spokePoolAddress: string,
|
|
47
|
+
readonly simulatedRelayerAddress: string,
|
|
48
|
+
readonly gasMarkup: number,
|
|
49
|
+
readonly logger: Logger,
|
|
50
|
+
readonly coingeckoProApiKey?: string,
|
|
51
|
+
readonly fixedGasPrice?: BigNumberish,
|
|
52
|
+
readonly coingeckoBaseCurrency: string = "eth"
|
|
53
|
+
) {
|
|
54
|
+
this.spokePool = SpokePool__factory.connect(spokePoolAddress, provider);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves the current gas costs of performing a fillRelay contract at the referenced SpokePool.
|
|
59
|
+
* @param deposit V3 deposit instance.
|
|
60
|
+
* @param relayerAddress Relayer address to simulate with.
|
|
61
|
+
* @returns The gas estimate for this function call (multplied with the optional buffer).
|
|
62
|
+
*/
|
|
63
|
+
async getGasCosts(deposit: Deposit, relayer = DEFAULT_SIMULATED_RELAYER_ADDRESS): Promise<TransactionCostEstimate> {
|
|
64
|
+
const tx = await populateV3Relay(this.spokePool, deposit, relayer);
|
|
65
|
+
return estimateTotalGasRequiredByUnsignedTransaction(
|
|
66
|
+
tx,
|
|
67
|
+
relayer,
|
|
68
|
+
this.provider,
|
|
69
|
+
this.gasMarkup,
|
|
70
|
+
this.fixedGasPrice
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Retrieves the current price of a token
|
|
76
|
+
* @param tokenSymbol A valid [CoinGecko-ID](https://api.coingecko.com/api/v3/coins/list)
|
|
77
|
+
* @returns The resolved token price within the specified coingeckoBaseCurrency
|
|
78
|
+
*/
|
|
79
|
+
async getTokenPrice(tokenSymbol: string): Promise<number> {
|
|
80
|
+
if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`);
|
|
81
|
+
const coingeckoInstance = Coingecko.get(this.logger, this.coingeckoProApiKey);
|
|
82
|
+
const [, price] = await coingeckoInstance.getCurrentPriceByContract(
|
|
83
|
+
this.symbolMapping[tokenSymbol].addresses[CHAIN_IDs.MAINNET],
|
|
84
|
+
this.coingeckoBaseCurrency
|
|
85
|
+
);
|
|
86
|
+
return price;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Resolves the number of decimal places a token can have
|
|
91
|
+
* @param tokenSymbol A valid Across-Enabled Token ID
|
|
92
|
+
* @returns The number of decimals of precision for the corresponding tokenSymbol
|
|
93
|
+
*/
|
|
94
|
+
getTokenDecimals(tokenSymbol: string): number {
|
|
95
|
+
if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`);
|
|
96
|
+
return this.symbolMapping[tokenSymbol].decimals;
|
|
97
|
+
}
|
|
98
|
+
}
|