@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,840 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import * as uma from "@uma/sdk";
|
|
3
|
+
import { toBNWei, fixedPointAdjustment, calcPeriodicCompoundInterest, calcApr, BigNumberish, fromWei } from "../utils";
|
|
4
|
+
import { ethers, Signer, BigNumber } from "ethers";
|
|
5
|
+
import type { Overrides } from "@ethersproject/contracts";
|
|
6
|
+
import { TransactionRequest, TransactionReceipt, Log } from "@ethersproject/abstract-provider";
|
|
7
|
+
import { Provider, Block } from "@ethersproject/providers";
|
|
8
|
+
import set from "lodash/set";
|
|
9
|
+
import get from "lodash/get";
|
|
10
|
+
import has from "lodash/has";
|
|
11
|
+
import { calculateInstantaneousRate } from "../lpFeeCalculator";
|
|
12
|
+
import { hubPool, acrossConfigStore } from "../contracts";
|
|
13
|
+
import {
|
|
14
|
+
AcceleratingDistributor,
|
|
15
|
+
AcceleratingDistributor__factory,
|
|
16
|
+
MerkleDistributor,
|
|
17
|
+
MerkleDistributor__factory,
|
|
18
|
+
TypedEvent,
|
|
19
|
+
} from "../typechain";
|
|
20
|
+
|
|
21
|
+
const { erc20 } = uma.clients;
|
|
22
|
+
const { loop } = uma.utils;
|
|
23
|
+
const { TransactionManager } = uma.across;
|
|
24
|
+
const { SECONDS_PER_YEAR, DEFAULT_BLOCK_DELTA } = uma.across.constants;
|
|
25
|
+
const { AddressZero } = ethers.constants;
|
|
26
|
+
|
|
27
|
+
export type { Provider };
|
|
28
|
+
|
|
29
|
+
export type Awaited<T> = T extends PromiseLike<infer U> ? U : T;
|
|
30
|
+
|
|
31
|
+
export type Config = {
|
|
32
|
+
chainId?: number;
|
|
33
|
+
hubPoolAddress: string;
|
|
34
|
+
acceleratingDistributorAddress: string;
|
|
35
|
+
merkleDistributorAddress: string;
|
|
36
|
+
wethAddress: string;
|
|
37
|
+
configStoreAddress: string;
|
|
38
|
+
confirmations?: number;
|
|
39
|
+
blockDelta?: number;
|
|
40
|
+
hasArchive?: boolean;
|
|
41
|
+
hubPoolStartBlock?: number;
|
|
42
|
+
};
|
|
43
|
+
export type Dependencies = {
|
|
44
|
+
provider: Provider;
|
|
45
|
+
};
|
|
46
|
+
export type StakeData = {
|
|
47
|
+
cumulativeBalance: BigNumber;
|
|
48
|
+
amountAirdropped: BigNumber;
|
|
49
|
+
};
|
|
50
|
+
export type Pool = {
|
|
51
|
+
address: string;
|
|
52
|
+
totalPoolSize: string;
|
|
53
|
+
l1Token: string;
|
|
54
|
+
lpToken: string;
|
|
55
|
+
liquidReserves: string;
|
|
56
|
+
exchangeRateCurrent: string;
|
|
57
|
+
exchangeRatePrevious: string;
|
|
58
|
+
estimatedApy: string;
|
|
59
|
+
estimatedApr: string;
|
|
60
|
+
blocksElapsed: number;
|
|
61
|
+
secondsElapsed: number;
|
|
62
|
+
utilizedReserves: string;
|
|
63
|
+
projectedApr: string;
|
|
64
|
+
liquidityUtilizationCurrent: string;
|
|
65
|
+
};
|
|
66
|
+
export type User = {
|
|
67
|
+
address: string;
|
|
68
|
+
poolAddress: string;
|
|
69
|
+
lpTokens: string;
|
|
70
|
+
positionValue: string;
|
|
71
|
+
totalDeposited: string;
|
|
72
|
+
feesEarned: string;
|
|
73
|
+
};
|
|
74
|
+
export type Transaction = {
|
|
75
|
+
id: string;
|
|
76
|
+
state: "requested" | "submitted" | "mined" | "error";
|
|
77
|
+
toAddress: string;
|
|
78
|
+
fromAddress: string;
|
|
79
|
+
type: "Add Liquidity" | "Remove Liquidity";
|
|
80
|
+
description: string;
|
|
81
|
+
request?: TransactionRequest;
|
|
82
|
+
hash?: string;
|
|
83
|
+
receipt?: TransactionReceipt;
|
|
84
|
+
error?: Error;
|
|
85
|
+
};
|
|
86
|
+
export type Token = {
|
|
87
|
+
decimals: string;
|
|
88
|
+
symbol: string;
|
|
89
|
+
name: string;
|
|
90
|
+
};
|
|
91
|
+
export type State = {
|
|
92
|
+
pools: Record<string, Pool>;
|
|
93
|
+
users: Record<string, Record<string, User>>;
|
|
94
|
+
transactions: Record<string, Transaction>;
|
|
95
|
+
error?: Error;
|
|
96
|
+
};
|
|
97
|
+
export type EmitState = (path: string[], data: Pool | User | Transaction | Error) => void;
|
|
98
|
+
export type PooledToken = {
|
|
99
|
+
// LP token given to LPs of a specific L1 token.
|
|
100
|
+
lpToken: string;
|
|
101
|
+
// True if accepting new LP's.
|
|
102
|
+
isEnabled: boolean;
|
|
103
|
+
// Timestamp of last LP fee update.
|
|
104
|
+
lastLpFeeUpdate: number;
|
|
105
|
+
// Number of LP funds sent via pool rebalances to SpokePools and are expected to be sent
|
|
106
|
+
// back later.
|
|
107
|
+
utilizedReserves: BigNumber;
|
|
108
|
+
// Number of LP funds held in contract less utilized reserves.
|
|
109
|
+
liquidReserves: BigNumber;
|
|
110
|
+
// Number of LP funds reserved to pay out to LPs as fees.
|
|
111
|
+
undistributedLpFees: BigNumber;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
class PoolState {
|
|
115
|
+
constructor(
|
|
116
|
+
private contract: hubPool.Instance,
|
|
117
|
+
private address: string
|
|
118
|
+
) {}
|
|
119
|
+
public async read(l1Token: string, latestBlock: number, previousBlock?: number) {
|
|
120
|
+
// typechain does not have complete types for call options, so we have to cast blockTag to any
|
|
121
|
+
const exchangeRatePrevious = await this.exchangeRateAtBlock(l1Token, previousBlock || latestBlock - 1);
|
|
122
|
+
|
|
123
|
+
const exchangeRateCurrent = await this.contract.callStatic.exchangeRateCurrent(l1Token);
|
|
124
|
+
|
|
125
|
+
const pooledToken: PooledToken = await this.contract.pooledTokens(l1Token);
|
|
126
|
+
const liquidityUtilizationCurrent: BigNumber = await this.contract.callStatic.liquidityUtilizationCurrent(l1Token);
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
address: this.address,
|
|
130
|
+
l1Token,
|
|
131
|
+
latestBlock,
|
|
132
|
+
previousBlock,
|
|
133
|
+
exchangeRatePrevious,
|
|
134
|
+
exchangeRateCurrent,
|
|
135
|
+
liquidityUtilizationCurrent,
|
|
136
|
+
...pooledToken,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
public exchangeRateAtBlock(l1Token: string, blockTag: number) {
|
|
140
|
+
return this.contract.callStatic.exchangeRateCurrent(l1Token, { blockTag });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
type EventIdParams = { blockNumber: number; transactionIndex: number; logIndex: number };
|
|
145
|
+
export class PoolEventState {
|
|
146
|
+
private seen = new Set<string>();
|
|
147
|
+
private iface: ethers.utils.Interface;
|
|
148
|
+
// maintain ordered unique list of events so we can calculate state
|
|
149
|
+
private events: uma.SerializableEvent[] = [];
|
|
150
|
+
constructor(
|
|
151
|
+
private contract: hubPool.Instance,
|
|
152
|
+
private startBlock = 0
|
|
153
|
+
) {
|
|
154
|
+
this.iface = new ethers.utils.Interface(hubPool.Factory.abi);
|
|
155
|
+
}
|
|
156
|
+
private makeId = (params: EventIdParams): string => {
|
|
157
|
+
return uma.oracle.utils.eventKey(params);
|
|
158
|
+
};
|
|
159
|
+
hasEvent(params: EventIdParams): boolean {
|
|
160
|
+
return this.seen.has(this.makeId(params));
|
|
161
|
+
}
|
|
162
|
+
private addEvent(params: EventIdParams): void {
|
|
163
|
+
this.seen.add(this.makeId(params));
|
|
164
|
+
}
|
|
165
|
+
private filterSeen = (params: EventIdParams): boolean => {
|
|
166
|
+
const seen = this.hasEvent(params);
|
|
167
|
+
if (!seen) this.addEvent(params);
|
|
168
|
+
return !seen;
|
|
169
|
+
};
|
|
170
|
+
private processEvent = (event: uma.SerializableEvent): void => {
|
|
171
|
+
if (!this.filterSeen(event)) return;
|
|
172
|
+
this.events = uma.oracle.utils.insertOrderedAscending(this.events, event, this.makeId);
|
|
173
|
+
};
|
|
174
|
+
private processEvents = (events: Array<uma.SerializableEvent>): void => {
|
|
175
|
+
events.forEach(this.processEvent);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
public async read(endBlock: number, l1TokenAddress?: string, userAddress?: string): Promise<hubPool.EventState> {
|
|
179
|
+
const events = await Promise.all([
|
|
180
|
+
...(await this.contract.queryFilter(
|
|
181
|
+
this.contract.filters.LiquidityAdded(l1TokenAddress, undefined, undefined, userAddress),
|
|
182
|
+
this.startBlock,
|
|
183
|
+
endBlock
|
|
184
|
+
)),
|
|
185
|
+
...(await this.contract.queryFilter(
|
|
186
|
+
this.contract.filters.LiquidityRemoved(l1TokenAddress, undefined, undefined, userAddress),
|
|
187
|
+
this.startBlock,
|
|
188
|
+
endBlock
|
|
189
|
+
)),
|
|
190
|
+
]);
|
|
191
|
+
this.processEvents(events);
|
|
192
|
+
return hubPool.getEventState(this.events);
|
|
193
|
+
}
|
|
194
|
+
makeEventFromLog = (log: Log): uma.SerializableEvent => {
|
|
195
|
+
const description = this.iface.parseLog(log);
|
|
196
|
+
return {
|
|
197
|
+
...log,
|
|
198
|
+
...description,
|
|
199
|
+
event: description.name,
|
|
200
|
+
eventSignature: description.signature,
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
getL1TokenFromReceipt(receipt: TransactionReceipt): string {
|
|
204
|
+
const events = receipt.logs
|
|
205
|
+
.filter((log) => ethers.utils.getAddress(log.address) === ethers.utils.getAddress(this.contract.address))
|
|
206
|
+
.map(this.makeEventFromLog);
|
|
207
|
+
|
|
208
|
+
// save these events
|
|
209
|
+
this.processEvents(events);
|
|
210
|
+
// only process token receipt events, becasue we just want the l1 token involved with this transfer
|
|
211
|
+
const eventState = hubPool.getEventState(events);
|
|
212
|
+
// event state is keyed by l1token address
|
|
213
|
+
const l1Tokens = Object.keys(eventState);
|
|
214
|
+
assert(l1Tokens.length, "Token not found from events");
|
|
215
|
+
assert(l1Tokens.length === 1, "Multiple tokens found from events");
|
|
216
|
+
return l1Tokens[0];
|
|
217
|
+
}
|
|
218
|
+
readTxReceipt(receipt: TransactionReceipt): hubPool.EventState {
|
|
219
|
+
const events = receipt.logs
|
|
220
|
+
.filter((log) => ethers.utils.getAddress(log.address) === ethers.utils.getAddress(this.contract.address))
|
|
221
|
+
.map(this.makeEventFromLog);
|
|
222
|
+
this.processEvents(events);
|
|
223
|
+
return hubPool.getEventState(this.events);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
class UserState {
|
|
228
|
+
private seen = new Set<string>();
|
|
229
|
+
private events: uma.clients.erc20.Transfer[] = [];
|
|
230
|
+
constructor(
|
|
231
|
+
private contract: uma.clients.erc20.Instance,
|
|
232
|
+
private userAddress: string,
|
|
233
|
+
private startBlock = 0,
|
|
234
|
+
private acceleratingDistributorContractAddress = ""
|
|
235
|
+
) {}
|
|
236
|
+
private makeId(params: EventIdParams): string {
|
|
237
|
+
return uma.oracle.utils.eventKey(params);
|
|
238
|
+
}
|
|
239
|
+
hasEvent(params: EventIdParams): boolean {
|
|
240
|
+
return this.seen.has(this.makeId(params));
|
|
241
|
+
}
|
|
242
|
+
private addEvent(params: EventIdParams): void {
|
|
243
|
+
this.seen.add(this.makeId(params));
|
|
244
|
+
}
|
|
245
|
+
private filterSeen = (params: EventIdParams): boolean => {
|
|
246
|
+
const seen = this.hasEvent(params);
|
|
247
|
+
if (!seen) this.addEvent(params);
|
|
248
|
+
return !seen;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* readEvents. Fetch and cache events for the user.
|
|
252
|
+
*
|
|
253
|
+
* @param {number} endBlock
|
|
254
|
+
*/
|
|
255
|
+
public async readEvents(endBlock: number): Promise<uma.clients.erc20.Transfer[]> {
|
|
256
|
+
if (endBlock <= this.startBlock) return [];
|
|
257
|
+
const { userAddress } = this;
|
|
258
|
+
const events: TypedEvent<
|
|
259
|
+
[string, string, uma.oracle.types.ethers.BigNumber] & {
|
|
260
|
+
from: string;
|
|
261
|
+
to: string;
|
|
262
|
+
value: uma.oracle.types.ethers.BigNumber;
|
|
263
|
+
}
|
|
264
|
+
>[] = (
|
|
265
|
+
await Promise.all([
|
|
266
|
+
...(await this.contract.queryFilter(
|
|
267
|
+
this.contract.filters.Transfer(userAddress, undefined),
|
|
268
|
+
this.startBlock,
|
|
269
|
+
endBlock
|
|
270
|
+
)),
|
|
271
|
+
...(await this.contract.queryFilter(
|
|
272
|
+
this.contract.filters.Transfer(undefined, userAddress),
|
|
273
|
+
this.startBlock,
|
|
274
|
+
endBlock
|
|
275
|
+
)),
|
|
276
|
+
])
|
|
277
|
+
)
|
|
278
|
+
// filter out events we have seen
|
|
279
|
+
.filter(this.filterSeen)
|
|
280
|
+
// filter out mint/burn transfers
|
|
281
|
+
.filter(
|
|
282
|
+
(event: uma.clients.erc20.Transfer) =>
|
|
283
|
+
// ignore mint events
|
|
284
|
+
event.args.from !== AddressZero &&
|
|
285
|
+
// ignore burn events
|
|
286
|
+
event.args.to !== AddressZero &&
|
|
287
|
+
// ignore AD transfer events in
|
|
288
|
+
event.args.to !== this.acceleratingDistributorContractAddress &&
|
|
289
|
+
// ignore AD transfer events out
|
|
290
|
+
event.args.from !== this.acceleratingDistributorContractAddress &&
|
|
291
|
+
// ignore self transfer events
|
|
292
|
+
event.args.from !== event.args.to
|
|
293
|
+
)
|
|
294
|
+
.flat();
|
|
295
|
+
|
|
296
|
+
this.events = this.events.concat(events).sort((a, b) => {
|
|
297
|
+
if (a.blockNumber !== b.blockNumber) return a.blockNumber - b.blockNumber;
|
|
298
|
+
if (a.transactionIndex !== b.transactionIndex) return a.transactionIndex - b.transactionIndex;
|
|
299
|
+
if (a.logIndex !== b.logIndex) return a.logIndex - b.logIndex;
|
|
300
|
+
throw new Error("Duplicate events at tx hash: " + a.transactionHash);
|
|
301
|
+
});
|
|
302
|
+
// ethers queries are inclusive [start,end] unless start === end, then exclusive (start,end). we increment to make sure we dont see same event twice
|
|
303
|
+
this.startBlock = endBlock + 1;
|
|
304
|
+
return this.events;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* read. Reads the state for the user, building state from events as well as contract calls.
|
|
308
|
+
*
|
|
309
|
+
* @param {number} endBlock
|
|
310
|
+
*/
|
|
311
|
+
public async read(endBlock: number) {
|
|
312
|
+
const { userAddress } = this;
|
|
313
|
+
const transferEvents = await this.readEvents(endBlock);
|
|
314
|
+
const state = uma.clients.erc20.getEventState(transferEvents);
|
|
315
|
+
const balanceTransferred = state?.balances?.[userAddress] || "0";
|
|
316
|
+
return {
|
|
317
|
+
transferEvents,
|
|
318
|
+
balanceTransferred,
|
|
319
|
+
address: userAddress,
|
|
320
|
+
balanceOf: await this.contract.balanceOf(userAddress),
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export function calculateRemoval(amountWei: BigNumber, percentWei: BigNumber) {
|
|
326
|
+
const receive = amountWei.mul(percentWei).div(fixedPointAdjustment);
|
|
327
|
+
const remain = amountWei.sub(receive);
|
|
328
|
+
return {
|
|
329
|
+
recieve: receive.toString(),
|
|
330
|
+
remain: remain.toString(),
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
// params here mimic the user object type
|
|
334
|
+
export function previewRemoval(
|
|
335
|
+
values: { positionValue: BigNumberish; feesEarned: BigNumberish; totalDeposited: BigNumberish },
|
|
336
|
+
percentFloat: number
|
|
337
|
+
) {
|
|
338
|
+
const percentWei = toBNWei(percentFloat);
|
|
339
|
+
return {
|
|
340
|
+
position: {
|
|
341
|
+
...calculateRemoval(BigNumber.from(values.totalDeposited), percentWei),
|
|
342
|
+
},
|
|
343
|
+
fees: {
|
|
344
|
+
...calculateRemoval(BigNumber.from(values.feesEarned), percentWei),
|
|
345
|
+
},
|
|
346
|
+
total: {
|
|
347
|
+
...calculateRemoval(BigNumber.from(values.positionValue), percentWei),
|
|
348
|
+
},
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
function joinUserState(
|
|
352
|
+
poolState: Pool,
|
|
353
|
+
tokenEventState: hubPool.TokenEventState,
|
|
354
|
+
userState: Awaited<ReturnType<UserState["read"]>>,
|
|
355
|
+
transferValue: BigNumber = ethers.constants.Zero,
|
|
356
|
+
cumulativeStakeBalance: BigNumber = ethers.constants.Zero,
|
|
357
|
+
cumulativeStakeClaimBalance: BigNumber = ethers.constants.Zero
|
|
358
|
+
): User {
|
|
359
|
+
const positionValue = BigNumber.from(poolState.exchangeRateCurrent)
|
|
360
|
+
.mul(userState.balanceOf.add(cumulativeStakeBalance))
|
|
361
|
+
.div(fixedPointAdjustment);
|
|
362
|
+
const totalDeposited = BigNumber.from(tokenEventState?.tokenBalances[userState.address] || "0").add(
|
|
363
|
+
cumulativeStakeClaimBalance
|
|
364
|
+
);
|
|
365
|
+
const feesEarned = positionValue.sub(totalDeposited.add(transferValue));
|
|
366
|
+
return {
|
|
367
|
+
address: userState.address,
|
|
368
|
+
poolAddress: poolState.address,
|
|
369
|
+
lpTokens: userState.balanceOf.toString(),
|
|
370
|
+
positionValue: positionValue.toString(),
|
|
371
|
+
totalDeposited: totalDeposited.toString(),
|
|
372
|
+
feesEarned: feesEarned.toString(),
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function joinPoolState(
|
|
376
|
+
poolState: Awaited<ReturnType<PoolState["read"]>>,
|
|
377
|
+
latestBlock: Block,
|
|
378
|
+
previousBlock: Block,
|
|
379
|
+
rateModel?: acrossConfigStore.RateModel
|
|
380
|
+
): Pool {
|
|
381
|
+
const totalPoolSize = poolState.liquidReserves.add(poolState.utilizedReserves);
|
|
382
|
+
const secondsElapsed = latestBlock.timestamp - previousBlock.timestamp;
|
|
383
|
+
const blocksElapsed = latestBlock.number - previousBlock.number;
|
|
384
|
+
const exchangeRatePrevious = poolState.exchangeRatePrevious.toString();
|
|
385
|
+
const exchangeRateCurrent = poolState.exchangeRateCurrent.toString();
|
|
386
|
+
const liquidityUtilizationCurrent = poolState.liquidityUtilizationCurrent.toString();
|
|
387
|
+
|
|
388
|
+
const estimatedApy = calcPeriodicCompoundInterest(
|
|
389
|
+
exchangeRatePrevious,
|
|
390
|
+
exchangeRateCurrent,
|
|
391
|
+
secondsElapsed,
|
|
392
|
+
SECONDS_PER_YEAR
|
|
393
|
+
);
|
|
394
|
+
const estimatedApr = calcApr(exchangeRatePrevious, exchangeRateCurrent, secondsElapsed, SECONDS_PER_YEAR);
|
|
395
|
+
let projectedApr = "";
|
|
396
|
+
|
|
397
|
+
if (rateModel) {
|
|
398
|
+
projectedApr = fromWei(
|
|
399
|
+
calculateInstantaneousRate(rateModel, liquidityUtilizationCurrent)
|
|
400
|
+
.mul(liquidityUtilizationCurrent)
|
|
401
|
+
.div(fixedPointAdjustment)
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return {
|
|
406
|
+
address: poolState.address,
|
|
407
|
+
totalPoolSize: totalPoolSize.toString(),
|
|
408
|
+
l1Token: poolState.l1Token,
|
|
409
|
+
lpToken: poolState.lpToken,
|
|
410
|
+
liquidReserves: poolState.liquidReserves.toString(),
|
|
411
|
+
exchangeRateCurrent: poolState.exchangeRateCurrent.toString(),
|
|
412
|
+
exchangeRatePrevious: poolState.exchangeRatePrevious.toString(),
|
|
413
|
+
estimatedApy,
|
|
414
|
+
estimatedApr,
|
|
415
|
+
blocksElapsed,
|
|
416
|
+
secondsElapsed,
|
|
417
|
+
projectedApr,
|
|
418
|
+
utilizedReserves: poolState.utilizedReserves.toString(),
|
|
419
|
+
liquidityUtilizationCurrent,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
export class ReadPoolClient {
|
|
423
|
+
private poolState: PoolState;
|
|
424
|
+
private contract: hubPool.Instance;
|
|
425
|
+
constructor(
|
|
426
|
+
private address: string,
|
|
427
|
+
private provider: Provider
|
|
428
|
+
) {
|
|
429
|
+
this.contract = hubPool.connect(address, this.provider);
|
|
430
|
+
this.poolState = new PoolState(this.contract, this.address);
|
|
431
|
+
}
|
|
432
|
+
public read(tokenAddress: string, latestBlock: number) {
|
|
433
|
+
return this.poolState.read(tokenAddress, latestBlock);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
export function validateWithdraw(pool: Pool, user: User, lpTokenAmount: BigNumberish) {
|
|
437
|
+
const l1TokensToReturn = BigNumber.from(lpTokenAmount).mul(pool.exchangeRateCurrent).div(fixedPointAdjustment);
|
|
438
|
+
assert(BigNumber.from(l1TokensToReturn).gt("0"), "Must withdraw amount greater than 0");
|
|
439
|
+
assert(BigNumber.from(lpTokenAmount).lte(user.lpTokens), "You cannot withdraw more than you have");
|
|
440
|
+
return { lpTokenAmount, l1TokensToReturn: l1TokensToReturn.toString() };
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export class Client {
|
|
444
|
+
private transactionManagers: Record<string, ReturnType<typeof TransactionManager>> = {};
|
|
445
|
+
private hubPool: hubPool.Instance;
|
|
446
|
+
private acceleratingDistributor: AcceleratingDistributor;
|
|
447
|
+
private merkleDistributor: MerkleDistributor;
|
|
448
|
+
public readonly state: State = { pools: {}, users: {}, transactions: {} };
|
|
449
|
+
private poolEvents: PoolEventState;
|
|
450
|
+
private erc20s: Record<string, uma.clients.erc20.Instance> = {};
|
|
451
|
+
private intervalStarted = false;
|
|
452
|
+
private configStoreClient: acrossConfigStore.Client;
|
|
453
|
+
private exchangeRateTable: Record<string, Record<number, BigNumberish>> = {};
|
|
454
|
+
private userServices: Record<string, Record<string, UserState>> = {};
|
|
455
|
+
constructor(
|
|
456
|
+
public readonly config: Config,
|
|
457
|
+
public readonly deps: Dependencies,
|
|
458
|
+
private emit: EmitState
|
|
459
|
+
) {
|
|
460
|
+
config.chainId = config.chainId || 1;
|
|
461
|
+
this.hubPool = this.createHubPoolContract(deps.provider);
|
|
462
|
+
this.acceleratingDistributor = this.createAcceleratingDistributorContract(deps.provider);
|
|
463
|
+
this.merkleDistributor = this.createMerkleDistributorContract(deps.provider);
|
|
464
|
+
this.poolEvents = new PoolEventState(this.hubPool, this.config.hubPoolStartBlock);
|
|
465
|
+
this.configStoreClient = new acrossConfigStore.Client(config.configStoreAddress, deps.provider);
|
|
466
|
+
}
|
|
467
|
+
public getOrCreateErc20Contract(address: string): uma.clients.erc20.Instance {
|
|
468
|
+
if (this.erc20s[address]) return this.erc20s[address];
|
|
469
|
+
this.erc20s[address] = erc20.connect(address, this.deps.provider);
|
|
470
|
+
return this.erc20s[address];
|
|
471
|
+
}
|
|
472
|
+
public getOrCreatePoolContract(): hubPool.Instance {
|
|
473
|
+
return this.hubPool;
|
|
474
|
+
}
|
|
475
|
+
public createHubPoolContract(signerOrProvider: Signer | Provider): hubPool.Instance {
|
|
476
|
+
return hubPool.connect(this.config.hubPoolAddress, signerOrProvider);
|
|
477
|
+
}
|
|
478
|
+
private getOrCreatePoolEvents() {
|
|
479
|
+
return this.poolEvents;
|
|
480
|
+
}
|
|
481
|
+
public createAcceleratingDistributorContract(signerOrProvider: Signer | Provider): AcceleratingDistributor {
|
|
482
|
+
return AcceleratingDistributor__factory.connect(this.config.acceleratingDistributorAddress, signerOrProvider);
|
|
483
|
+
}
|
|
484
|
+
public createMerkleDistributorContract(signerOrProvider: Signer | Provider): MerkleDistributor {
|
|
485
|
+
return MerkleDistributor__factory.connect(this.config.merkleDistributorAddress, signerOrProvider);
|
|
486
|
+
}
|
|
487
|
+
public getOrCreateAcceleratingDistributorContract(): AcceleratingDistributor {
|
|
488
|
+
return this.acceleratingDistributor;
|
|
489
|
+
}
|
|
490
|
+
public getOrCreateMerkleDistributorContract(): MerkleDistributor {
|
|
491
|
+
return this.merkleDistributor;
|
|
492
|
+
}
|
|
493
|
+
private getOrCreateUserService(userAddress: string, tokenAddress: string) {
|
|
494
|
+
if (has(this.userServices, [tokenAddress, userAddress])) return get(this.userServices, [tokenAddress, userAddress]);
|
|
495
|
+
const erc20Contract = this.getOrCreateErc20Contract(tokenAddress);
|
|
496
|
+
const userService = new UserState(erc20Contract, userAddress);
|
|
497
|
+
// this service is stateful now, so needs to be cached
|
|
498
|
+
set(this.userServices, [tokenAddress, userAddress], userService);
|
|
499
|
+
return userService;
|
|
500
|
+
}
|
|
501
|
+
private updateExchangeRateTable(
|
|
502
|
+
l1TokenAddress: string,
|
|
503
|
+
exchangeRateTable: Record<number, BigNumberish>
|
|
504
|
+
): Record<number, BigNumberish> {
|
|
505
|
+
if (!this.exchangeRateTable[l1TokenAddress]) this.exchangeRateTable[l1TokenAddress] = {};
|
|
506
|
+
this.exchangeRateTable[l1TokenAddress] = { ...this.exchangeRateTable[l1TokenAddress], ...exchangeRateTable };
|
|
507
|
+
return this.exchangeRateTable[l1TokenAddress];
|
|
508
|
+
}
|
|
509
|
+
async resolveStakingData(
|
|
510
|
+
lpToken: string,
|
|
511
|
+
l1TokenAddress: string,
|
|
512
|
+
userState: Awaited<ReturnType<UserState["read"]>>
|
|
513
|
+
): Promise<StakeData> {
|
|
514
|
+
assert(this.config.acceleratingDistributorAddress, "Must have the accelerating distributor address");
|
|
515
|
+
assert(this.config.merkleDistributorAddress, "Must have the merkle distributor address");
|
|
516
|
+
|
|
517
|
+
// Define the contracts we need to interact with.
|
|
518
|
+
const acceleratingDistributorContract = this.getOrCreateAcceleratingDistributorContract();
|
|
519
|
+
const merkleDistributorContract = this.getOrCreateMerkleDistributorContract();
|
|
520
|
+
const poolContract = this.getOrCreatePoolContract();
|
|
521
|
+
|
|
522
|
+
// Get the list of all claims made by the user.
|
|
523
|
+
const claimList = await merkleDistributorContract.queryFilter(
|
|
524
|
+
merkleDistributorContract.filters.Claimed(undefined, undefined, userState.address, undefined, undefined, lpToken)
|
|
525
|
+
);
|
|
526
|
+
|
|
527
|
+
// Calculate the total amount of LP tokens claimed by the user from the merkle
|
|
528
|
+
// distributor contract with the exchange rate at the time of the claim.
|
|
529
|
+
const amountOfLPClaimed = (
|
|
530
|
+
await Promise.all(
|
|
531
|
+
claimList.map(async (claim) =>
|
|
532
|
+
claim.args.amount.mul(
|
|
533
|
+
await poolContract.callStatic.exchangeRateCurrent(l1TokenAddress, { blockTag: claim.blockNumber })
|
|
534
|
+
)
|
|
535
|
+
)
|
|
536
|
+
)
|
|
537
|
+
).reduce((prev, acc) => acc.add(prev), ethers.constants.Zero);
|
|
538
|
+
|
|
539
|
+
// Get the cumulative balance of the user from the accelerating distributor contract.
|
|
540
|
+
const { cumulativeBalance } = await acceleratingDistributorContract.getUserStake(lpToken, userState.address);
|
|
541
|
+
|
|
542
|
+
return {
|
|
543
|
+
cumulativeBalance,
|
|
544
|
+
amountAirdropped: amountOfLPClaimed,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// calculates the value of each LP token transfer at the block it was sent. this only works if we have archive node
|
|
549
|
+
async calculateLpTransferValue(l1TokenAddress: string, userState: Awaited<ReturnType<UserState["read"]>>) {
|
|
550
|
+
assert(this.config.hasArchive, "Can only calculate historical lp values with archive node");
|
|
551
|
+
const contract = this.getOrCreatePoolContract();
|
|
552
|
+
const pool = new PoolState(contract, this.config.hubPoolAddress);
|
|
553
|
+
const blockNumbers = userState.transferEvents
|
|
554
|
+
.map((x) => x.blockNumber)
|
|
555
|
+
// we are going to lookup exchange rates for block numbers only if we dont already have it
|
|
556
|
+
// its possible these values do not exist, so to prevent crashing do optional chaining
|
|
557
|
+
.filter((blockNumber) => !this.exchangeRateTable?.[l1TokenAddress]?.[blockNumber]);
|
|
558
|
+
|
|
559
|
+
// new exchange rate lookups
|
|
560
|
+
const exchangeRateTable = this.updateExchangeRateTable(
|
|
561
|
+
l1TokenAddress,
|
|
562
|
+
Object.fromEntries(
|
|
563
|
+
await Promise.all(
|
|
564
|
+
blockNumbers.map(async (blockNumber) => {
|
|
565
|
+
return [blockNumber, await pool.exchangeRateAtBlock(l1TokenAddress, blockNumber)];
|
|
566
|
+
})
|
|
567
|
+
)
|
|
568
|
+
)
|
|
569
|
+
);
|
|
570
|
+
|
|
571
|
+
return userState.transferEvents.reduce((result, transfer) => {
|
|
572
|
+
const exchangeRate = exchangeRateTable[transfer.blockNumber];
|
|
573
|
+
if (transfer.args.to === userState.address) {
|
|
574
|
+
return result.add(transfer.args.value.mul(exchangeRate).div(fixedPointAdjustment));
|
|
575
|
+
}
|
|
576
|
+
if (transfer.args.from === userState.address) {
|
|
577
|
+
return result.sub(transfer.args.value.mul(exchangeRate).div(fixedPointAdjustment));
|
|
578
|
+
}
|
|
579
|
+
// we make sure to filter out any transfers where to/from is the same user
|
|
580
|
+
return result;
|
|
581
|
+
}, ethers.constants.Zero);
|
|
582
|
+
}
|
|
583
|
+
private getOrCreateTransactionManager(signer: Signer, address: string) {
|
|
584
|
+
if (this.transactionManagers[address]) return this.transactionManagers[address];
|
|
585
|
+
const txman = TransactionManager({ confirmations: this.config.confirmations }, signer, (event, id, data) => {
|
|
586
|
+
if (event === "submitted") {
|
|
587
|
+
this.state.transactions[id].state = event;
|
|
588
|
+
this.state.transactions[id].hash = data as string;
|
|
589
|
+
this.emit(["transactions", id], { ...this.state.transactions[id] });
|
|
590
|
+
}
|
|
591
|
+
if (event === "mined") {
|
|
592
|
+
const txReceipt = data as TransactionReceipt;
|
|
593
|
+
this.state.transactions[id].state = event;
|
|
594
|
+
this.state.transactions[id].receipt = txReceipt;
|
|
595
|
+
this.emit(["transactions", id], { ...this.state.transactions[id] });
|
|
596
|
+
// trigger pool and user update for a known mined transaction
|
|
597
|
+
const tx = this.state.transactions[id];
|
|
598
|
+
this.updateUserWithTransaction(tx.fromAddress, txReceipt).catch((err) => {
|
|
599
|
+
this.emit(["error"], err);
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
if (event === "error") {
|
|
603
|
+
this.state.transactions[id].state = event;
|
|
604
|
+
this.state.transactions[id].error = data as Error;
|
|
605
|
+
this.emit(["transactions", id], { ...this.state.transactions[id] });
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
this.transactionManagers[address] = txman;
|
|
609
|
+
return txman;
|
|
610
|
+
}
|
|
611
|
+
async addEthLiquidity(signer: Signer, l1TokenAmount: BigNumberish, overrides: Overrides = {}) {
|
|
612
|
+
const { hubPoolAddress, wethAddress: l1Token } = this.config;
|
|
613
|
+
const userAddress = await signer.getAddress();
|
|
614
|
+
const contract = this.getOrCreatePoolContract();
|
|
615
|
+
const txman = this.getOrCreateTransactionManager(signer, userAddress);
|
|
616
|
+
|
|
617
|
+
// dont allow override value here
|
|
618
|
+
const request = await contract.populateTransaction.addLiquidity(l1Token, l1TokenAmount, {
|
|
619
|
+
...overrides,
|
|
620
|
+
value: l1TokenAmount,
|
|
621
|
+
});
|
|
622
|
+
const id = txman.request(request);
|
|
623
|
+
|
|
624
|
+
this.state.transactions[id] = {
|
|
625
|
+
id,
|
|
626
|
+
state: "requested",
|
|
627
|
+
toAddress: hubPoolAddress,
|
|
628
|
+
fromAddress: userAddress,
|
|
629
|
+
type: "Add Liquidity",
|
|
630
|
+
description: "Adding ETH to pool",
|
|
631
|
+
request,
|
|
632
|
+
};
|
|
633
|
+
this.emit(["transactions", id], { ...this.state.transactions[id] });
|
|
634
|
+
await txman.update();
|
|
635
|
+
return id;
|
|
636
|
+
}
|
|
637
|
+
async addTokenLiquidity(signer: Signer, l1Token: string, l1TokenAmount: BigNumberish, overrides: Overrides = {}) {
|
|
638
|
+
const { hubPoolAddress } = this.config;
|
|
639
|
+
const userAddress = await signer.getAddress();
|
|
640
|
+
const contract = this.getOrCreatePoolContract();
|
|
641
|
+
const txman = this.getOrCreateTransactionManager(signer, userAddress);
|
|
642
|
+
|
|
643
|
+
const request = await contract.populateTransaction.addLiquidity(l1Token, l1TokenAmount, overrides);
|
|
644
|
+
const id = await txman.request(request);
|
|
645
|
+
|
|
646
|
+
this.state.transactions[id] = {
|
|
647
|
+
id,
|
|
648
|
+
state: "requested",
|
|
649
|
+
toAddress: hubPoolAddress,
|
|
650
|
+
fromAddress: userAddress,
|
|
651
|
+
type: "Add Liquidity",
|
|
652
|
+
description: "Adding Tokens to pool",
|
|
653
|
+
request,
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
this.emit(["transactions", id], { ...this.state.transactions[id] });
|
|
657
|
+
await txman.update();
|
|
658
|
+
return id;
|
|
659
|
+
}
|
|
660
|
+
async validateWithdraw(l1Token: string, userAddress: string, lpAmount: BigNumberish) {
|
|
661
|
+
await this.updatePool(l1Token);
|
|
662
|
+
const poolState = this.getPoolState(l1Token);
|
|
663
|
+
if (!this.hasUserState(l1Token, userAddress)) {
|
|
664
|
+
await this.updateUser(l1Token, userAddress);
|
|
665
|
+
}
|
|
666
|
+
const userState = this.getUserState(poolState.l1Token, userAddress);
|
|
667
|
+
return validateWithdraw(poolState, userState, lpAmount);
|
|
668
|
+
}
|
|
669
|
+
async removeTokenLiquidity(signer: Signer, l1Token: string, lpTokenAmount: BigNumberish, overrides: Overrides = {}) {
|
|
670
|
+
const { hubPoolAddress } = this.config;
|
|
671
|
+
const userAddress = await signer.getAddress();
|
|
672
|
+
await this.validateWithdraw(l1Token, userAddress, lpTokenAmount);
|
|
673
|
+
const contract = this.getOrCreatePoolContract();
|
|
674
|
+
const txman = this.getOrCreateTransactionManager(signer, userAddress);
|
|
675
|
+
|
|
676
|
+
const request = await contract.populateTransaction.removeLiquidity(l1Token, lpTokenAmount, false, overrides);
|
|
677
|
+
const id = await txman.request(request);
|
|
678
|
+
|
|
679
|
+
this.state.transactions[id] = {
|
|
680
|
+
id,
|
|
681
|
+
state: "requested",
|
|
682
|
+
toAddress: hubPoolAddress,
|
|
683
|
+
fromAddress: userAddress,
|
|
684
|
+
type: "Remove Liquidity",
|
|
685
|
+
description: "Withdrawing Tokens from pool",
|
|
686
|
+
request,
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
this.emit(["transactions", id], { ...this.state.transactions[id] });
|
|
690
|
+
await txman.update();
|
|
691
|
+
return id;
|
|
692
|
+
}
|
|
693
|
+
async removeEthliquidity(signer: Signer, lpTokenAmount: BigNumberish, overrides: Overrides = {}) {
|
|
694
|
+
const { hubPoolAddress, wethAddress: l1Token } = this.config;
|
|
695
|
+
const userAddress = await signer.getAddress();
|
|
696
|
+
await this.validateWithdraw(l1Token, userAddress, lpTokenAmount);
|
|
697
|
+
const contract = this.getOrCreatePoolContract();
|
|
698
|
+
const txman = this.getOrCreateTransactionManager(signer, userAddress);
|
|
699
|
+
|
|
700
|
+
const request = await contract.populateTransaction.removeLiquidity(l1Token, lpTokenAmount, true, overrides);
|
|
701
|
+
const id = await txman.request(request);
|
|
702
|
+
|
|
703
|
+
this.state.transactions[id] = {
|
|
704
|
+
id,
|
|
705
|
+
state: "requested",
|
|
706
|
+
toAddress: hubPoolAddress,
|
|
707
|
+
fromAddress: userAddress,
|
|
708
|
+
type: "Remove Liquidity",
|
|
709
|
+
description: "Withdrawing Eth from pool",
|
|
710
|
+
request,
|
|
711
|
+
};
|
|
712
|
+
this.emit(["transactions", id], { ...this.state.transactions[id] });
|
|
713
|
+
await txman.update();
|
|
714
|
+
return id;
|
|
715
|
+
}
|
|
716
|
+
getPoolState(l1TokenAddress: string): Pool {
|
|
717
|
+
return this.state.pools[l1TokenAddress];
|
|
718
|
+
}
|
|
719
|
+
hasPoolState(l1TokenAddress: string): boolean {
|
|
720
|
+
return Boolean(this.state.pools[l1TokenAddress]);
|
|
721
|
+
}
|
|
722
|
+
setUserState(l1TokenAddress: string, userAddress: string, state: User): User {
|
|
723
|
+
set(this.state, ["users", userAddress, l1TokenAddress], state);
|
|
724
|
+
return state;
|
|
725
|
+
}
|
|
726
|
+
getUserState(l1TokenAddress: string, userAddress: string): User {
|
|
727
|
+
return get(this.state, ["users", userAddress, l1TokenAddress]);
|
|
728
|
+
}
|
|
729
|
+
hasUserState(l1TokenAddress: string, userAddress: string): boolean {
|
|
730
|
+
return has(this.state, ["users", userAddress, l1TokenAddress]);
|
|
731
|
+
}
|
|
732
|
+
hasTxState(id: string): boolean {
|
|
733
|
+
return has(this.state, ["transactions", id]);
|
|
734
|
+
}
|
|
735
|
+
getTxState(id: string): Transaction {
|
|
736
|
+
return get(this.state, ["transactions", id]);
|
|
737
|
+
}
|
|
738
|
+
private async updateAndEmitUser(
|
|
739
|
+
userState: Awaited<ReturnType<UserState["read"]>>,
|
|
740
|
+
poolState: Pool,
|
|
741
|
+
poolEventState: hubPool.EventState
|
|
742
|
+
): Promise<void> {
|
|
743
|
+
const { l1Token: l1TokenAddress, lpToken } = poolState;
|
|
744
|
+
const { address: userAddress } = userState;
|
|
745
|
+
const transferValue = this.config.hasArchive
|
|
746
|
+
? await this.calculateLpTransferValue(l1TokenAddress, userState)
|
|
747
|
+
: ethers.constants.Zero;
|
|
748
|
+
const stakeData = await this.resolveStakingData(lpToken, l1TokenAddress, userState);
|
|
749
|
+
const tokenEventState = poolEventState[l1TokenAddress];
|
|
750
|
+
const newUserState = this.setUserState(
|
|
751
|
+
l1TokenAddress,
|
|
752
|
+
userAddress,
|
|
753
|
+
joinUserState(
|
|
754
|
+
poolState,
|
|
755
|
+
tokenEventState,
|
|
756
|
+
userState,
|
|
757
|
+
transferValue,
|
|
758
|
+
stakeData.cumulativeBalance,
|
|
759
|
+
stakeData.amountAirdropped
|
|
760
|
+
)
|
|
761
|
+
);
|
|
762
|
+
this.emit(["users", userAddress, l1TokenAddress], newUserState);
|
|
763
|
+
}
|
|
764
|
+
private async updateUserWithTransaction(userAddress: string, txReceipt: TransactionReceipt): Promise<void> {
|
|
765
|
+
const latestBlock = await this.deps.provider.getBlock("latest");
|
|
766
|
+
const getPoolEventState = this.getOrCreatePoolEvents();
|
|
767
|
+
const l1TokenAddress = getPoolEventState.getL1TokenFromReceipt(txReceipt);
|
|
768
|
+
await this.updatePool(l1TokenAddress, latestBlock);
|
|
769
|
+
const poolState = this.getPoolState(l1TokenAddress);
|
|
770
|
+
const poolEventState = getPoolEventState.readTxReceipt(txReceipt);
|
|
771
|
+
|
|
772
|
+
const lpToken = poolState.lpToken;
|
|
773
|
+
const getUserState = this.getOrCreateUserService(userAddress, lpToken);
|
|
774
|
+
const userState = await getUserState.read(latestBlock.number);
|
|
775
|
+
|
|
776
|
+
await this.updateAndEmitUser(userState, poolState, poolEventState);
|
|
777
|
+
}
|
|
778
|
+
async updateUser(userAddress: string, l1TokenAddress: string): Promise<void> {
|
|
779
|
+
const latestBlock = await this.deps.provider.getBlock("latest");
|
|
780
|
+
await this.updatePool(l1TokenAddress, latestBlock);
|
|
781
|
+
|
|
782
|
+
const poolState = this.getPoolState(l1TokenAddress);
|
|
783
|
+
const lpToken = poolState.lpToken;
|
|
784
|
+
const getPoolEventState = this.getOrCreatePoolEvents();
|
|
785
|
+
const poolEventState = await getPoolEventState.read(latestBlock.number, l1TokenAddress, userAddress);
|
|
786
|
+
|
|
787
|
+
const getUserState = this.getOrCreateUserService(userAddress, lpToken);
|
|
788
|
+
const userState = await getUserState.read(latestBlock.number);
|
|
789
|
+
|
|
790
|
+
await this.updateAndEmitUser(userState, poolState, poolEventState);
|
|
791
|
+
}
|
|
792
|
+
async updatePool(l1TokenAddress: string, overrideLatestBlock?: Block): Promise<void> {
|
|
793
|
+
// default to 100 block delta unless specified otherwise in config
|
|
794
|
+
const { blockDelta = DEFAULT_BLOCK_DELTA } = this.config;
|
|
795
|
+
const contract = this.getOrCreatePoolContract();
|
|
796
|
+
const pool = new PoolState(contract, this.config.hubPoolAddress);
|
|
797
|
+
const latestBlock = overrideLatestBlock || (await this.deps.provider.getBlock("latest"));
|
|
798
|
+
const previousBlock = await this.deps.provider.getBlock(latestBlock.number - blockDelta);
|
|
799
|
+
const state = await pool.read(l1TokenAddress, latestBlock.number, previousBlock.number);
|
|
800
|
+
|
|
801
|
+
let rateModel: acrossConfigStore.RateModel | undefined = undefined;
|
|
802
|
+
try {
|
|
803
|
+
// Use the default rate model (i.e. not any of the routeRateModels to project the Pool's APR). This assumes
|
|
804
|
+
// that the default rate model is the most often used, but this may change in future if many different
|
|
805
|
+
// route rate models are set.
|
|
806
|
+
rateModel = await this.configStoreClient.getRateModel(l1TokenAddress);
|
|
807
|
+
} catch (err) {
|
|
808
|
+
// we could swallow this error or just log it since getting the rate model is optional,
|
|
809
|
+
// but we will just emit it to the caller and let them decide what to do with it.
|
|
810
|
+
this.emit(["error"], err as unknown as Error);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
this.state.pools[l1TokenAddress] = joinPoolState(state, latestBlock, previousBlock, rateModel);
|
|
814
|
+
this.emit(["pools", l1TokenAddress], this.state.pools[l1TokenAddress]);
|
|
815
|
+
}
|
|
816
|
+
async updateTransactions(): Promise<void> {
|
|
817
|
+
for (const txMan of Object.values(this.transactionManagers)) {
|
|
818
|
+
try {
|
|
819
|
+
await txMan.update();
|
|
820
|
+
} catch (err) {
|
|
821
|
+
this.emit(["error"], err as unknown as Error);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
// starts transaction checking intervals, defaults to 30 seconds
|
|
826
|
+
startInterval(delayMs = 30000) {
|
|
827
|
+
assert(!this.intervalStarted, "Interval already started, try stopping first");
|
|
828
|
+
this.intervalStarted = true;
|
|
829
|
+
loop(async () => {
|
|
830
|
+
assert(this.intervalStarted, "HubPool Interval Stopped");
|
|
831
|
+
await this.updateTransactions();
|
|
832
|
+
}, delayMs).catch((err) => {
|
|
833
|
+
this.emit(["error"], err);
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
// starts transaction checking intervals
|
|
837
|
+
stopInterval() {
|
|
838
|
+
this.intervalStarted = false;
|
|
839
|
+
}
|
|
840
|
+
}
|