@across-protocol/sdk 4.1.63 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/arch/evm/BlockUtils.d.ts +15 -0
- package/dist/cjs/arch/evm/BlockUtils.js +218 -0
- package/dist/cjs/arch/evm/BlockUtils.js.map +1 -0
- package/dist/cjs/arch/evm/SpokeUtils.d.ts +1 -1
- package/dist/cjs/arch/evm/SpokeUtils.js +6 -5
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/evm/index.d.ts +1 -0
- package/dist/cjs/arch/evm/index.js +1 -0
- package/dist/cjs/arch/evm/index.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +20 -0
- package/dist/cjs/arch/svm/SpokeUtils.js +449 -0
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -0
- package/dist/cjs/arch/svm/constants.d.ts +2 -0
- package/dist/cjs/arch/svm/constants.js +7 -0
- package/dist/cjs/arch/svm/constants.js.map +1 -0
- package/dist/cjs/arch/svm/eventsClient.d.ts +26 -0
- package/dist/cjs/arch/svm/eventsClient.js +253 -0
- package/dist/cjs/arch/svm/eventsClient.js.map +1 -0
- package/dist/cjs/arch/svm/index.d.ts +5 -1
- package/dist/cjs/arch/svm/index.js +6 -2
- package/dist/cjs/arch/svm/index.js.map +1 -1
- package/dist/cjs/{svm → arch/svm}/types.d.ts +9 -4
- package/dist/cjs/arch/svm/types.js.map +1 -0
- package/dist/cjs/arch/svm/utils.d.ts +18 -0
- package/dist/cjs/arch/svm/utils.js +212 -0
- package/dist/cjs/arch/svm/utils.js.map +1 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +7 -7
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/BaseAbstractClient.d.ts +6 -5
- package/dist/cjs/clients/BaseAbstractClient.js +30 -19
- package/dist/cjs/clients/BaseAbstractClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +15 -11
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +114 -114
- package/dist/cjs/clients/HubPoolClient.d.ts +4 -3
- package/dist/cjs/clients/HubPoolClient.js +18 -17
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -3
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +23 -20
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +23 -0
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +172 -0
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -0
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -5
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +54 -57
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/index.d.ts +3 -0
- package/dist/cjs/clients/SpokePoolClient/index.js +8 -1
- package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/cjs/clients/index.d.ts +1 -1
- package/dist/cjs/clients/index.js +2 -1
- package/dist/cjs/clients/index.js.map +1 -1
- package/dist/cjs/clients/mocks/MockConfigStoreClient.d.ts +1 -1
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js +2 -2
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +2 -2
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +7 -4
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +33 -0
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +184 -0
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -0
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +30 -0
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +90 -0
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -0
- package/dist/cjs/clients/mocks/index.d.ts +2 -0
- package/dist/cjs/clients/mocks/index.js +2 -0
- package/dist/cjs/clients/mocks/index.js.map +1 -1
- package/dist/cjs/coingecko/Coingecko.d.ts +3 -2
- package/dist/cjs/coingecko/Coingecko.js +11 -3
- package/dist/cjs/coingecko/Coingecko.js.map +1 -1
- package/dist/cjs/constants.d.ts +1 -0
- package/dist/cjs/constants.js +2 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.d.ts +2 -2
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/ethereum.d.ts +4 -4
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js +3 -2
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/polygon.d.ts +3 -3
- package/dist/cjs/gasPriceOracle/adapters/solana.d.ts +4 -0
- package/dist/cjs/gasPriceOracle/adapters/solana.js +43 -0
- package/dist/cjs/gasPriceOracle/adapters/solana.js.map +1 -0
- package/dist/cjs/gasPriceOracle/index.d.ts +1 -1
- package/dist/cjs/gasPriceOracle/oracle.d.ts +4 -3
- package/dist/cjs/gasPriceOracle/oracle.js +16 -9
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/gasPriceOracle/types.d.ts +6 -1
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +1 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/SpokePool.d.ts +13 -0
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/providers/index.d.ts +1 -1
- package/dist/cjs/providers/index.js +1 -2
- package/dist/cjs/providers/index.js.map +1 -1
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.d.ts +5 -0
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js +21 -0
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -0
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts +5 -0
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js +20 -0
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -0
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.d.ts +13 -0
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js +76 -0
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js.map +1 -0
- package/dist/cjs/providers/mocks/index.d.ts +4 -0
- package/dist/cjs/providers/mocks/index.js +8 -0
- package/dist/cjs/providers/mocks/index.js.map +1 -0
- package/dist/cjs/providers/{mockProvider.js → mocks/mockEthersProvider.js} +2 -2
- package/dist/cjs/providers/mocks/mockEthersProvider.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +10 -8
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +4 -2
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +8 -2
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/index.d.ts +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +37 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +171 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +2 -0
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +9 -3
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +9 -3
- package/dist/cjs/utils/AddressUtils.js +36 -6
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/ArrayUtils.d.ts +1 -0
- package/dist/cjs/utils/ArrayUtils.js +6 -1
- package/dist/cjs/utils/ArrayUtils.js.map +1 -1
- package/dist/cjs/utils/BlockFinder.d.ts +22 -0
- package/dist/cjs/utils/BlockFinder.js +10 -0
- package/dist/cjs/utils/BlockFinder.js.map +1 -0
- package/dist/cjs/utils/BlockUtils.d.ts +2 -27
- package/dist/cjs/utils/BlockUtils.js +2 -208
- package/dist/cjs/utils/BlockUtils.js.map +1 -1
- package/dist/cjs/utils/EventUtils.d.ts +4 -4
- package/dist/cjs/utils/EventUtils.js +7 -4
- package/dist/cjs/utils/EventUtils.js.map +1 -1
- package/dist/cjs/utils/JSONUtils.js +3 -0
- package/dist/cjs/utils/JSONUtils.js.map +1 -1
- package/dist/cjs/utils/NumberUtils.d.ts +1 -0
- package/dist/cjs/utils/NumberUtils.js +7 -1
- package/dist/cjs/utils/NumberUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.js +5 -0
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.js +4 -1
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/esm/arch/evm/BlockUtils.d.ts +24 -0
- package/dist/esm/arch/evm/BlockUtils.js +250 -0
- package/dist/esm/arch/evm/BlockUtils.js.map +1 -0
- package/dist/esm/arch/evm/SpokeUtils.d.ts +1 -1
- package/dist/esm/arch/evm/SpokeUtils.js +6 -5
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/evm/index.d.ts +1 -0
- package/dist/esm/arch/evm/index.js +1 -0
- package/dist/esm/arch/evm/index.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +122 -0
- package/dist/esm/arch/svm/SpokeUtils.js +566 -0
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -0
- package/dist/esm/arch/svm/constants.d.ts +2 -0
- package/dist/esm/arch/svm/constants.js +3 -0
- package/dist/esm/arch/svm/constants.js.map +1 -0
- package/dist/esm/arch/svm/eventsClient.d.ts +87 -0
- package/dist/esm/arch/svm/eventsClient.js +316 -0
- package/dist/esm/arch/svm/eventsClient.js.map +1 -0
- package/dist/esm/arch/svm/index.d.ts +5 -1
- package/dist/esm/arch/svm/index.js +5 -1
- package/dist/esm/arch/svm/index.js.map +1 -1
- package/dist/esm/{svm → arch/svm}/types.d.ts +9 -4
- package/dist/esm/arch/svm/types.js.map +1 -0
- package/dist/esm/arch/svm/utils.d.ts +63 -0
- package/dist/esm/arch/svm/utils.js +258 -0
- package/dist/esm/arch/svm/utils.js.map +1 -0
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +7 -7
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BaseAbstractClient.d.ts +6 -5
- package/dist/esm/clients/BaseAbstractClient.js +30 -19
- package/dist/esm/clients/BaseAbstractClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +17 -14
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +114 -114
- package/dist/esm/clients/HubPoolClient.d.ts +4 -3
- package/dist/esm/clients/HubPoolClient.js +19 -18
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -3
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +23 -20
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +66 -0
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +225 -0
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -0
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +7 -7
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +57 -59
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.d.ts +8 -0
- package/dist/esm/clients/SpokePoolClient/index.js +10 -0
- package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/esm/clients/index.d.ts +1 -1
- package/dist/esm/clients/index.js +1 -1
- package/dist/esm/clients/index.js.map +1 -1
- package/dist/esm/clients/mocks/MockConfigStoreClient.d.ts +1 -1
- package/dist/esm/clients/mocks/MockConfigStoreClient.js +2 -2
- package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.js +2 -2
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +8 -5
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +33 -0
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +183 -0
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -0
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +30 -0
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +89 -0
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -0
- package/dist/esm/clients/mocks/index.d.ts +2 -0
- package/dist/esm/clients/mocks/index.js +2 -0
- package/dist/esm/clients/mocks/index.js.map +1 -1
- package/dist/esm/coingecko/Coingecko.d.ts +3 -2
- package/dist/esm/coingecko/Coingecko.js +12 -3
- package/dist/esm/coingecko/Coingecko.js.map +1 -1
- package/dist/esm/constants.d.ts +1 -0
- package/dist/esm/constants.js +1 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/arbitrum.d.ts +2 -2
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/ethereum.d.ts +4 -4
- package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js +3 -2
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/polygon.d.ts +4 -4
- package/dist/esm/gasPriceOracle/adapters/polygon.js +1 -1
- package/dist/esm/gasPriceOracle/adapters/solana.d.ts +8 -0
- package/dist/esm/gasPriceOracle/adapters/solana.js +43 -0
- package/dist/esm/gasPriceOracle/adapters/solana.js.map +1 -0
- package/dist/esm/gasPriceOracle/index.d.ts +1 -1
- package/dist/esm/gasPriceOracle/oracle.d.ts +4 -3
- package/dist/esm/gasPriceOracle/oracle.js +18 -9
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/gasPriceOracle/types.d.ts +6 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/SpokePool.d.ts +13 -0
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/providers/index.d.ts +1 -1
- package/dist/esm/providers/index.js +1 -2
- package/dist/esm/providers/index.js.map +1 -1
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.d.ts +5 -0
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js +19 -0
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -0
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts +5 -0
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js +18 -0
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -0
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.d.ts +13 -0
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.js +74 -0
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.js.map +1 -0
- package/dist/esm/providers/mocks/index.d.ts +4 -0
- package/dist/esm/providers/mocks/index.js +5 -0
- package/dist/esm/providers/mocks/index.js.map +1 -0
- package/dist/esm/providers/{mockProvider.js → mocks/mockEthersProvider.js} +2 -2
- package/dist/esm/providers/mocks/mockEthersProvider.js.map +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +10 -8
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +4 -2
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +11 -5
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/index.d.ts +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/index.js +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/index.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +84 -0
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +216 -0
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -0
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +12 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +9 -4
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +9 -3
- package/dist/esm/utils/AddressUtils.js +41 -6
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/ArrayUtils.d.ts +6 -0
- package/dist/esm/utils/ArrayUtils.js +9 -0
- package/dist/esm/utils/ArrayUtils.js.map +1 -1
- package/dist/esm/utils/BlockFinder.d.ts +22 -0
- package/dist/esm/utils/BlockFinder.js +7 -0
- package/dist/esm/utils/BlockFinder.js.map +1 -0
- package/dist/esm/utils/BlockUtils.d.ts +2 -36
- package/dist/esm/utils/BlockUtils.js +2 -243
- package/dist/esm/utils/BlockUtils.js.map +1 -1
- package/dist/esm/utils/EventUtils.d.ts +4 -4
- package/dist/esm/utils/EventUtils.js +7 -4
- package/dist/esm/utils/EventUtils.js.map +1 -1
- package/dist/esm/utils/JSONUtils.js +3 -0
- package/dist/esm/utils/JSONUtils.js.map +1 -1
- package/dist/esm/utils/NumberUtils.d.ts +7 -0
- package/dist/esm/utils/NumberUtils.js +11 -0
- package/dist/esm/utils/NumberUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.js +5 -0
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +12 -0
- package/dist/esm/utils/TokenUtils.js +6 -3
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/types/arch/evm/BlockUtils.d.ts +25 -0
- package/dist/types/arch/evm/BlockUtils.d.ts.map +1 -0
- package/dist/types/arch/evm/SpokeUtils.d.ts +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/evm/index.d.ts +1 -0
- package/dist/types/arch/evm/index.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +123 -0
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -0
- package/dist/types/arch/svm/constants.d.ts +3 -0
- package/dist/types/arch/svm/constants.d.ts.map +1 -0
- package/dist/types/arch/svm/eventsClient.d.ts +88 -0
- package/dist/types/arch/svm/eventsClient.d.ts.map +1 -0
- package/dist/types/arch/svm/index.d.ts +5 -1
- package/dist/types/arch/svm/index.d.ts.map +1 -1
- package/dist/types/{svm → arch/svm}/types.d.ts +9 -4
- package/dist/types/arch/svm/types.d.ts.map +1 -0
- package/dist/types/arch/svm/utils.d.ts +64 -0
- package/dist/types/arch/svm/utils.d.ts.map +1 -0
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +1 -1
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/BaseAbstractClient.d.ts +6 -5
- package/dist/types/clients/BaseAbstractClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +114 -114
- package/dist/types/clients/HubPoolClient.d.ts +4 -3
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -3
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +67 -0
- package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +1 -0
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +7 -7
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/index.d.ts +8 -0
- package/dist/types/clients/SpokePoolClient/index.d.ts.map +1 -1
- package/dist/types/clients/index.d.ts +1 -1
- package/dist/types/clients/index.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockConfigStoreClient.d.ts +1 -1
- package/dist/types/clients/mocks/MockConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +34 -0
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts.map +1 -0
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +31 -0
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -0
- package/dist/types/clients/mocks/index.d.ts +2 -0
- package/dist/types/clients/mocks/index.d.ts.map +1 -1
- package/dist/types/coingecko/Coingecko.d.ts +3 -2
- package/dist/types/coingecko/Coingecko.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts +2 -2
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts +4 -4
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/linea-viem.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/polygon.d.ts +4 -4
- package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/solana.d.ts +9 -0
- package/dist/types/gasPriceOracle/adapters/solana.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/index.d.ts +1 -1
- package/dist/types/gasPriceOracle/index.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/oracle.d.ts +4 -3
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/types.d.ts +6 -1
- package/dist/types/gasPriceOracle/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +13 -0
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/providers/index.d.ts +1 -1
- package/dist/types/providers/index.d.ts.map +1 -1
- package/dist/types/providers/mocks/MockCachedSolanaRpcFactory.d.ts +6 -0
- package/dist/types/providers/mocks/MockCachedSolanaRpcFactory.d.ts.map +1 -0
- package/dist/types/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts +6 -0
- package/dist/types/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts.map +1 -0
- package/dist/types/providers/mocks/MockSolanaRpcFactory.d.ts +14 -0
- package/dist/types/providers/mocks/MockSolanaRpcFactory.d.ts.map +1 -0
- package/dist/types/providers/mocks/index.d.ts +5 -0
- package/dist/types/providers/mocks/index.d.ts.map +1 -0
- package/dist/types/providers/{mockProvider.d.ts → mocks/mockEthersProvider.d.ts} +1 -1
- package/dist/types/providers/mocks/mockEthersProvider.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +4 -2
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/index.d.ts +1 -0
- package/dist/types/relayFeeCalculator/chain-queries/index.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +85 -0
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +12 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +9 -3
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/ArrayUtils.d.ts +6 -0
- package/dist/types/utils/ArrayUtils.d.ts.map +1 -1
- package/dist/types/utils/BlockFinder.d.ts +23 -0
- package/dist/types/utils/BlockFinder.d.ts.map +1 -0
- package/dist/types/utils/BlockUtils.d.ts +2 -36
- package/dist/types/utils/BlockUtils.d.ts.map +1 -1
- package/dist/types/utils/EventUtils.d.ts +4 -4
- package/dist/types/utils/EventUtils.d.ts.map +1 -1
- package/dist/types/utils/JSONUtils.d.ts.map +1 -1
- package/dist/types/utils/NumberUtils.d.ts +7 -0
- package/dist/types/utils/NumberUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +12 -0
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/arch/evm/BlockUtils.ts +209 -0
- package/src/arch/evm/SpokeUtils.ts +5 -5
- package/src/arch/evm/index.ts +1 -0
- package/src/arch/svm/SpokeUtils.ts +581 -0
- package/src/arch/svm/constants.ts +2 -0
- package/src/arch/svm/eventsClient.ts +342 -0
- package/src/arch/svm/index.ts +5 -1
- package/src/{svm → arch/svm}/types.ts +21 -4
- package/src/arch/svm/utils.ts +233 -0
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -7
- package/src/clients/BaseAbstractClient.ts +20 -13
- package/src/clients/BundleDataClient/BundleDataClient.ts +28 -19
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +1 -1
- package/src/clients/HubPoolClient.ts +19 -19
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +23 -21
- package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +268 -0
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +50 -59
- package/src/clients/SpokePoolClient/index.ts +11 -0
- package/src/clients/index.ts +1 -1
- package/src/clients/mocks/MockConfigStoreClient.ts +2 -2
- package/src/clients/mocks/MockHubPoolClient.ts +2 -2
- package/src/clients/mocks/MockSpokePoolClient.ts +9 -4
- package/src/clients/mocks/MockSvmCpiEventsClient.ts +226 -0
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +119 -0
- package/src/clients/mocks/index.ts +2 -0
- package/src/coingecko/Coingecko.ts +12 -3
- package/src/constants.ts +1 -0
- package/src/gasPriceOracle/adapters/arbitrum.ts +5 -2
- package/src/gasPriceOracle/adapters/ethereum.ts +7 -4
- package/src/gasPriceOracle/adapters/linea-viem.ts +3 -1
- package/src/gasPriceOracle/adapters/polygon.ts +6 -6
- package/src/gasPriceOracle/adapters/solana.ts +47 -0
- package/src/gasPriceOracle/index.ts +1 -1
- package/src/gasPriceOracle/oracle.ts +20 -4
- package/src/gasPriceOracle/types.ts +7 -1
- package/src/index.ts +0 -1
- package/src/interfaces/SpokePool.ts +14 -0
- package/src/providers/index.ts +1 -1
- package/src/providers/mocks/MockCachedSolanaRpcFactory.ts +15 -0
- package/src/providers/mocks/MockRateLimitedSolanaRpcFactory.ts +14 -0
- package/src/providers/mocks/MockSolanaRpcFactory.ts +55 -0
- package/src/providers/mocks/index.ts +4 -0
- package/src/providers/{mockProvider.ts → mocks/mockEthersProvider.ts} +1 -1
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +11 -9
- package/src/relayFeeCalculator/chain-queries/factory.ts +24 -8
- package/src/relayFeeCalculator/chain-queries/index.ts +1 -0
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +225 -0
- package/src/relayFeeCalculator/relayFeeCalculator.ts +15 -3
- package/src/utils/AddressUtils.ts +49 -6
- package/src/utils/ArrayUtils.ts +12 -0
- package/src/utils/BlockFinder.ts +26 -0
- package/src/utils/BlockUtils.ts +5 -215
- package/src/utils/EventUtils.ts +11 -11
- package/src/utils/JSONUtils.ts +2 -0
- package/src/utils/NumberUtils.ts +10 -0
- package/src/utils/SpokeUtils.ts +7 -3
- package/src/utils/TokenUtils.ts +6 -3
- package/src/utils/index.ts +1 -0
- package/dist/cjs/providers/mockProvider.js.map +0 -1
- package/dist/cjs/svm/eventsClient.d.ts +0 -15
- package/dist/cjs/svm/eventsClient.js +0 -157
- package/dist/cjs/svm/eventsClient.js.map +0 -1
- package/dist/cjs/svm/index.d.ts +0 -3
- package/dist/cjs/svm/index.js +0 -8
- package/dist/cjs/svm/index.js.map +0 -1
- package/dist/cjs/svm/types.js.map +0 -1
- package/dist/cjs/svm/utils/events.d.ts +0 -8
- package/dist/cjs/svm/utils/events.js +0 -47
- package/dist/cjs/svm/utils/events.js.map +0 -1
- package/dist/cjs/svm/utils/helpers.d.ts +0 -2
- package/dist/cjs/svm/utils/helpers.js +0 -19
- package/dist/cjs/svm/utils/helpers.js.map +0 -1
- package/dist/cjs/svm/utils/index.d.ts +0 -1
- package/dist/cjs/svm/utils/index.js +0 -5
- package/dist/cjs/svm/utils/index.js.map +0 -1
- package/dist/esm/providers/mockProvider.js.map +0 -1
- package/dist/esm/svm/eventsClient.d.ts +0 -51
- package/dist/esm/svm/eventsClient.js +0 -195
- package/dist/esm/svm/eventsClient.js.map +0 -1
- package/dist/esm/svm/index.d.ts +0 -3
- package/dist/esm/svm/index.js +0 -5
- package/dist/esm/svm/index.js.map +0 -1
- package/dist/esm/svm/types.js.map +0 -1
- package/dist/esm/svm/utils/events.d.ts +0 -17
- package/dist/esm/svm/utils/events.js +0 -55
- package/dist/esm/svm/utils/events.js.map +0 -1
- package/dist/esm/svm/utils/helpers.d.ts +0 -5
- package/dist/esm/svm/utils/helpers.js +0 -18
- package/dist/esm/svm/utils/helpers.js.map +0 -1
- package/dist/esm/svm/utils/index.d.ts +0 -1
- package/dist/esm/svm/utils/index.js +0 -2
- package/dist/esm/svm/utils/index.js.map +0 -1
- package/dist/types/providers/mockProvider.d.ts.map +0 -1
- package/dist/types/svm/eventsClient.d.ts +0 -52
- package/dist/types/svm/eventsClient.d.ts.map +0 -1
- package/dist/types/svm/index.d.ts +0 -4
- package/dist/types/svm/index.d.ts.map +0 -1
- package/dist/types/svm/types.d.ts.map +0 -1
- package/dist/types/svm/utils/events.d.ts +0 -18
- package/dist/types/svm/utils/events.d.ts.map +0 -1
- package/dist/types/svm/utils/helpers.d.ts +0 -6
- package/dist/types/svm/utils/helpers.d.ts.map +0 -1
- package/dist/types/svm/utils/index.d.ts +0 -2
- package/dist/types/svm/utils/index.d.ts.map +0 -1
- package/src/svm/eventsClient.ts +0 -199
- package/src/svm/index.ts +0 -3
- package/src/svm/utils/events.ts +0 -58
- package/src/svm/utils/helpers.ts +0 -9
- package/src/svm/utils/index.ts +0 -1
- /package/dist/cjs/{svm → arch/svm}/types.js +0 -0
- /package/dist/cjs/providers/{mockProvider.d.ts → mocks/mockEthersProvider.d.ts} +0 -0
- /package/dist/esm/{svm → arch/svm}/types.js +0 -0
- /package/dist/esm/providers/{mockProvider.d.ts → mocks/mockEthersProvider.d.ts} +0 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import { createHash } from "crypto";
|
|
3
|
+
import { hexlify, arrayify, hexZeroPad } from "ethers/lib/utils";
|
|
4
|
+
import { random } from "lodash";
|
|
5
|
+
import { Address, UnixTimestamp, signature } from "@solana/kit";
|
|
6
|
+
import { Idl } from "@coral-xyz/anchor";
|
|
7
|
+
import { SvmSpokeClient } from "@across-protocol/contracts";
|
|
8
|
+
import { CHAIN_IDs } from "@across-protocol/constants";
|
|
9
|
+
|
|
10
|
+
import { MockSolanaRpcFactory } from "../../providers/mocks";
|
|
11
|
+
import {
|
|
12
|
+
SVM_DEFAULT_ADDRESS,
|
|
13
|
+
EventName,
|
|
14
|
+
EventWithData,
|
|
15
|
+
SvmCpiEventsClient,
|
|
16
|
+
SVMEventNames,
|
|
17
|
+
SVMProvider,
|
|
18
|
+
getRandomSvmAddress,
|
|
19
|
+
} from "../../arch/svm";
|
|
20
|
+
import { bnZero, bnOne, bs58, getCurrentTime, randomAddress, EvmAddress } from "../../utils";
|
|
21
|
+
import { FillType } from "../../interfaces";
|
|
22
|
+
|
|
23
|
+
export class MockSvmCpiEventsClient extends SvmCpiEventsClient {
|
|
24
|
+
private events: Record<EventName, EventWithData[]> = {} as Record<EventName, EventWithData[]>;
|
|
25
|
+
private slotHeight: bigint = BigInt(0);
|
|
26
|
+
public chainId: number;
|
|
27
|
+
public minBlockRange = 10;
|
|
28
|
+
public numberOfDeposits = bnZero;
|
|
29
|
+
|
|
30
|
+
constructor(programId = SvmSpokeClient.SVM_SPOKE_PROGRAM_ADDRESS, chainId = CHAIN_IDs.SOLANA) {
|
|
31
|
+
super(null as unknown as SVMProvider, programId as Address, null as unknown as Address, null as unknown as Idl);
|
|
32
|
+
this.chainId = chainId;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public setSlotHeight(slotHeight: bigint) {
|
|
36
|
+
this.slotHeight = slotHeight;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public setEvents(events: EventWithData[]) {
|
|
40
|
+
for (const event of events) {
|
|
41
|
+
this.events[event.name as EventName] ??= [];
|
|
42
|
+
this.events[event.name as EventName].push(event);
|
|
43
|
+
}
|
|
44
|
+
const maxSlot = Math.max(...events.map((event) => Number(event.slot)));
|
|
45
|
+
this.setSlotHeight(BigInt(maxSlot) + BigInt(1));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public clearEvents(name?: EventName) {
|
|
49
|
+
if (name) {
|
|
50
|
+
this.events[name] = [];
|
|
51
|
+
} else {
|
|
52
|
+
this.events = {} as Record<EventName, EventWithData[]>;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public override queryEvents(eventName: EventName, fromSlot?: bigint, toSlot?: bigint): Promise<EventWithData[]> {
|
|
57
|
+
return Promise.resolve(
|
|
58
|
+
this.events[eventName]?.filter(
|
|
59
|
+
(event) => (!fromSlot || event.slot >= fromSlot) && (!toSlot || event.slot <= toSlot)
|
|
60
|
+
) ?? []
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public override getRpc(): SVMProvider {
|
|
65
|
+
const client = new MockSolanaRpcFactory("https://test.com", 1234567890);
|
|
66
|
+
client.setResult("getSlot", [], this.slotHeight);
|
|
67
|
+
return client.createRpcClient();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public deposit(deposit: SvmSpokeClient.FundsDeposited & Partial<EventWithData>): EventWithData {
|
|
71
|
+
const { slot } = deposit;
|
|
72
|
+
let { depositId, destinationChainId, inputAmount, outputAmount } = deposit;
|
|
73
|
+
depositId ??= arrayify(hexZeroPad(hexlify(random(1, 100_000, false)), 32));
|
|
74
|
+
this.numberOfDeposits = this.numberOfDeposits.add(bnOne);
|
|
75
|
+
|
|
76
|
+
destinationChainId ??= BigInt(random(1, 42161, false));
|
|
77
|
+
const depositor = deposit.depositor ?? getRandomSvmAddress();
|
|
78
|
+
const recipient = deposit.recipient ?? EvmAddress.from(randomAddress()).toBase58();
|
|
79
|
+
const inputToken = deposit.inputToken ?? getRandomSvmAddress();
|
|
80
|
+
const outputToken = deposit.outputToken ?? EvmAddress.from(randomAddress()).toBase58();
|
|
81
|
+
inputAmount ??= BigInt(random(1, 1000, false));
|
|
82
|
+
outputAmount ??= (inputAmount * BigInt(95)) / BigInt(100);
|
|
83
|
+
const message = deposit.message ?? new Uint8Array(32);
|
|
84
|
+
const quoteTimestamp = deposit.quoteTimestamp ?? getCurrentTime();
|
|
85
|
+
|
|
86
|
+
const args = {
|
|
87
|
+
depositId,
|
|
88
|
+
destinationChainId,
|
|
89
|
+
depositor,
|
|
90
|
+
recipient,
|
|
91
|
+
inputToken,
|
|
92
|
+
inputAmount,
|
|
93
|
+
outputToken,
|
|
94
|
+
outputAmount,
|
|
95
|
+
quoteTimestamp,
|
|
96
|
+
fillDeadline: deposit.fillDeadline ?? quoteTimestamp + 3600,
|
|
97
|
+
exclusiveRelayer: deposit.exclusiveRelayer ?? SVM_DEFAULT_ADDRESS,
|
|
98
|
+
exclusivityDeadline: deposit.exclusivityDeadline ?? quoteTimestamp + 600,
|
|
99
|
+
message,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return this.generateEvent({
|
|
103
|
+
event: SVMEventNames.FundsDeposited,
|
|
104
|
+
address: this.getProgramAddress(),
|
|
105
|
+
args,
|
|
106
|
+
slot,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public fillRelay(fill: SvmSpokeClient.FilledRelay & Partial<EventWithData>): EventWithData {
|
|
111
|
+
const { slot } = fill;
|
|
112
|
+
let { depositId, inputAmount, outputAmount, fillDeadline } = fill;
|
|
113
|
+
depositId ??= arrayify(hexZeroPad(hexlify(random(1, 100_000, false)), 32));
|
|
114
|
+
inputAmount ??= BigInt(random(1, 1000, false));
|
|
115
|
+
outputAmount ??= (inputAmount * BigInt(95)) / BigInt(100);
|
|
116
|
+
fillDeadline ??= getCurrentTime() + 60;
|
|
117
|
+
|
|
118
|
+
const depositor = fill.depositor ?? EvmAddress.from(randomAddress()).toBase58();
|
|
119
|
+
const recipient = fill.recipient ?? getRandomSvmAddress();
|
|
120
|
+
const inputToken = fill.inputToken ?? EvmAddress.from(randomAddress()).toBase58();
|
|
121
|
+
const outputToken = fill.outputToken ?? getRandomSvmAddress();
|
|
122
|
+
const messageHash = fill.messageHash ?? new Uint8Array(32);
|
|
123
|
+
|
|
124
|
+
const relayExecutionInfo = {
|
|
125
|
+
updatedRecipient: fill.relayExecutionInfo?.updatedRecipient ?? recipient,
|
|
126
|
+
updatedOutputAmount: fill.relayExecutionInfo?.updatedOutputAmount ?? outputAmount,
|
|
127
|
+
fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill,
|
|
128
|
+
updatedMessageHash: fill.relayExecutionInfo?.updatedMessageHash ?? messageHash,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const args = {
|
|
132
|
+
depositId,
|
|
133
|
+
originChainId: fill.originChainId ?? BigInt(random(1, 42161, false)),
|
|
134
|
+
depositor,
|
|
135
|
+
recipient,
|
|
136
|
+
inputToken,
|
|
137
|
+
inputAmount,
|
|
138
|
+
outputToken,
|
|
139
|
+
outputAmount,
|
|
140
|
+
fillDeadline,
|
|
141
|
+
exclusiveRelayer: fill.exclusiveRelayer ?? SVM_DEFAULT_ADDRESS,
|
|
142
|
+
exclusivityDeadline: fill.exclusivityDeadline ?? fillDeadline,
|
|
143
|
+
relayer: fill.relayer ?? getRandomSvmAddress(),
|
|
144
|
+
messageHash,
|
|
145
|
+
relayExecutionInfo,
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
return this.generateEvent({
|
|
149
|
+
event: SVMEventNames.FilledRelay,
|
|
150
|
+
address: this.getProgramAddress(),
|
|
151
|
+
args,
|
|
152
|
+
slot,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public requestSlowFill(slowFillRequest: SvmSpokeClient.RequestedSlowFill & Partial<EventWithData>): EventWithData {
|
|
157
|
+
const { slot } = slowFillRequest;
|
|
158
|
+
let { depositId, originChainId } = slowFillRequest;
|
|
159
|
+
depositId ??= Uint8Array.from([random(1, 100_000, false)]);
|
|
160
|
+
originChainId ??= BigInt(random(1, 42161, false));
|
|
161
|
+
const depositor = slowFillRequest.depositor ?? EvmAddress.from(randomAddress()).toBase58();
|
|
162
|
+
const recipient = slowFillRequest.recipient ?? getRandomSvmAddress();
|
|
163
|
+
const inputToken = slowFillRequest.inputToken ?? EvmAddress.from(randomAddress()).toBase58();
|
|
164
|
+
const outputToken = slowFillRequest.outputToken ?? getRandomSvmAddress();
|
|
165
|
+
|
|
166
|
+
const args = {
|
|
167
|
+
...slowFillRequest,
|
|
168
|
+
depositId,
|
|
169
|
+
originChainId,
|
|
170
|
+
depositor,
|
|
171
|
+
recipient,
|
|
172
|
+
inputToken,
|
|
173
|
+
outputToken,
|
|
174
|
+
inputAmount: slowFillRequest.inputAmount ?? BigInt(random(1, 1000, false)),
|
|
175
|
+
outputAmount: slowFillRequest.outputAmount ?? slowFillRequest.inputAmount ?? BigInt(random(1, 1000, false)),
|
|
176
|
+
exclusiveRelayer: slowFillRequest.exclusiveRelayer ?? SVM_DEFAULT_ADDRESS,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
return this.generateEvent({
|
|
180
|
+
event: SVMEventNames.RequestedSlowFill,
|
|
181
|
+
address: this.getProgramAddress(),
|
|
182
|
+
args,
|
|
183
|
+
slot,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
protected generateEvent(inputs: {
|
|
188
|
+
address: Address;
|
|
189
|
+
event: EventName;
|
|
190
|
+
args: Record<string, unknown>;
|
|
191
|
+
slot?: bigint;
|
|
192
|
+
}) {
|
|
193
|
+
const { address, event, args } = inputs;
|
|
194
|
+
let { slot } = inputs;
|
|
195
|
+
|
|
196
|
+
const randomSlotWithinRange = () =>
|
|
197
|
+
random(Number(this.slotHeight) + 1, Number(this.slotHeight) + this.minBlockRange, false);
|
|
198
|
+
|
|
199
|
+
// Increment the slot number by at least 1, by default. The caller may override
|
|
200
|
+
// to force the same slot number to be used, but never a previous slot number.
|
|
201
|
+
slot ??= BigInt(randomSlotWithinRange());
|
|
202
|
+
assert(slot >= this.slotHeight, `${slot} < ${this.slotHeight}`);
|
|
203
|
+
this.slotHeight = slot;
|
|
204
|
+
|
|
205
|
+
const generatedEvent = {
|
|
206
|
+
name: event,
|
|
207
|
+
slot,
|
|
208
|
+
signature: signature(
|
|
209
|
+
bs58.encode(
|
|
210
|
+
Uint8Array.from(
|
|
211
|
+
createHash("sha512")
|
|
212
|
+
.update(`Across-${event}-${slot}-${random(1, 100_000)}`)
|
|
213
|
+
.digest()
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
),
|
|
217
|
+
program: address,
|
|
218
|
+
data: args,
|
|
219
|
+
confirmationStatus: "finalized",
|
|
220
|
+
blockTime: BigInt(new Date().getTime()) as UnixTimestamp,
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
this.setEvents([generatedEvent]);
|
|
224
|
+
return generatedEvent;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import winston from "winston";
|
|
2
|
+
import { SvmSpokeClient } from "@across-protocol/contracts";
|
|
3
|
+
import { Address } from "@solana/kit";
|
|
4
|
+
import { DepositWithBlock, RelayerRefundExecution, SortableEvent, SlowFillLeaf, Log } from "../../interfaces";
|
|
5
|
+
import { getCurrentTime, bnZero, MakeOptional, EventSearchConfig } from "../../utils";
|
|
6
|
+
import { SpokePoolUpdate, SvmSpokePoolClient } from "../SpokePoolClient";
|
|
7
|
+
import { HubPoolClient } from "../HubPoolClient";
|
|
8
|
+
import { EventOverrides } from "./MockEvents";
|
|
9
|
+
import { AcrossConfigStoreClient } from "../AcrossConfigStoreClient";
|
|
10
|
+
import { MockSvmCpiEventsClient } from "./MockSvmCpiEventsClient";
|
|
11
|
+
import { EventWithData, SvmCpiEventsClient, SVMEventNames, unwrapEventData } from "../../arch/svm";
|
|
12
|
+
|
|
13
|
+
// This class replaces internal SpokePoolClient functionality, enabling
|
|
14
|
+
// the user to bypass on-chain queries and inject events directly.
|
|
15
|
+
export class MockSvmSpokePoolClient extends SvmSpokePoolClient {
|
|
16
|
+
public mockEventsClient: MockSvmCpiEventsClient;
|
|
17
|
+
private destinationTokenForChainOverride: Record<number, string> = {};
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
logger: winston.Logger,
|
|
21
|
+
chainId: number,
|
|
22
|
+
programId = SvmSpokeClient.SVM_SPOKE_PROGRAM_ADDRESS,
|
|
23
|
+
deploymentBlock: number = 1,
|
|
24
|
+
eventSearchConfig: MakeOptional<EventSearchConfig, "to"> = { from: 0, maxLookBack: 0 },
|
|
25
|
+
opts: { hubPoolClient: HubPoolClient | null } = { hubPoolClient: null }
|
|
26
|
+
) {
|
|
27
|
+
super(
|
|
28
|
+
logger,
|
|
29
|
+
opts.hubPoolClient,
|
|
30
|
+
chainId,
|
|
31
|
+
BigInt(deploymentBlock),
|
|
32
|
+
eventSearchConfig,
|
|
33
|
+
null as unknown as SvmCpiEventsClient,
|
|
34
|
+
programId,
|
|
35
|
+
null as unknown as Address
|
|
36
|
+
);
|
|
37
|
+
this.mockEventsClient = new MockSvmCpiEventsClient();
|
|
38
|
+
this.latestHeightSearched = deploymentBlock;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setConfigStoreClient(configStore?: AcrossConfigStoreClient): void {
|
|
42
|
+
this.configStoreClient = configStore;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setDestinationTokenForChain(chainId: number, token: string): void {
|
|
46
|
+
this.destinationTokenForChainOverride[chainId] = token;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getDestinationTokenForDeposit(deposit: DepositWithBlock): string {
|
|
50
|
+
return this.destinationTokenForChainOverride[deposit.originChainId] ?? super.getDestinationTokenForDeposit(deposit);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
setLatestBlockNumber(blockNumber: number): void {
|
|
54
|
+
this.latestHeightSearched = blockNumber;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async _update(eventsToQuery: string[]): Promise<SpokePoolUpdate> {
|
|
58
|
+
const from = this.eventSearchConfig.from ?? this.deploymentBlock;
|
|
59
|
+
const to = this.eventSearchConfig.to ? BigInt(this.eventSearchConfig.to) : undefined;
|
|
60
|
+
|
|
61
|
+
// Get events from the mock event client.
|
|
62
|
+
const events: EventWithData[][] = await Promise.all(
|
|
63
|
+
eventsToQuery.map((eventName) => this.mockEventsClient.queryEvents(eventName as SVMEventNames, BigInt(from), to))
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const eventsWithBlockNumber = events.map((eventList) =>
|
|
67
|
+
eventList.map((event) => {
|
|
68
|
+
return {
|
|
69
|
+
txnRef: event.signature,
|
|
70
|
+
blockNumber: Number(event.slot),
|
|
71
|
+
txnIndex: 0,
|
|
72
|
+
logIndex: 0,
|
|
73
|
+
...(unwrapEventData(event.data) as Record<string, unknown>),
|
|
74
|
+
};
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return Promise.resolve({
|
|
79
|
+
success: true,
|
|
80
|
+
firstDepositId: bnZero,
|
|
81
|
+
currentTime: getCurrentTime(),
|
|
82
|
+
events: eventsWithBlockNumber,
|
|
83
|
+
searchEndBlock: this.eventSearchConfig.to || this.latestHeightSearched,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
deposit(deposit: SvmSpokeClient.FundsDeposited & Partial<EventWithData>): EventWithData {
|
|
88
|
+
return this.mockEventsClient.deposit(deposit);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
fillRelay(fill: SvmSpokeClient.FilledRelay & Partial<EventWithData>): EventWithData {
|
|
92
|
+
return this.mockEventsClient.fillRelay(fill);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
requestSlowFill(request: SvmSpokeClient.RequestedSlowFill & Partial<EventWithData>): EventWithData {
|
|
96
|
+
return this.mockEventsClient.requestSlowFill(request);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setTokensBridged(_tokensBridged: SvmSpokeClient.TokensBridged & Partial<EventWithData>): EventWithData {
|
|
100
|
+
throw new Error("MockSvmSpokePoolClient#setTokensBridged not implemented");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
executeSlowRelayLeaf(_leaf: Omit<SlowFillLeaf, "messageHash">): Log {
|
|
104
|
+
throw new Error("MockSvmSpokePoolClient#executeV3SlowRelayLeaf not implemented");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
executeRelayerRefundLeaf(_refund: RelayerRefundExecution & Partial<SortableEvent>): Log {
|
|
108
|
+
throw new Error("MockSvmSpokePoolClient#executeRelayerRefundLeaf not implemented");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
setEnableRoute(
|
|
112
|
+
_originToken: string,
|
|
113
|
+
_destinationChainId: number,
|
|
114
|
+
_enabled: boolean,
|
|
115
|
+
_overrides: EventOverrides = {}
|
|
116
|
+
): Log {
|
|
117
|
+
throw new Error("MockSvmSpokePoolClient#setEnableRoute not implemented");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -70,13 +70,14 @@ export class Coingecko {
|
|
|
70
70
|
private platformIdMap = new Map<number, string>(); // chainId => platform_id (137 => "polygon-pos")
|
|
71
71
|
private tokenIdMap: Record<string, Record<string, string>> = {}; // coinGeckoId => { platform_id : "tokenAddress":}
|
|
72
72
|
|
|
73
|
-
public static get(logger: Logger, apiKey?: string) {
|
|
73
|
+
public static get(logger: Logger, apiKey?: string, customPlatformIdMap?: Record<number, string>) {
|
|
74
74
|
if (!this.instance)
|
|
75
75
|
this.instance = new Coingecko(
|
|
76
76
|
"https://api.coingecko.com/api/v3",
|
|
77
77
|
"https://pro-api.coingecko.com/api/v3",
|
|
78
78
|
logger,
|
|
79
|
-
apiKey
|
|
79
|
+
apiKey,
|
|
80
|
+
customPlatformIdMap
|
|
80
81
|
);
|
|
81
82
|
return this.instance;
|
|
82
83
|
}
|
|
@@ -98,7 +99,8 @@ export class Coingecko {
|
|
|
98
99
|
private readonly host: string,
|
|
99
100
|
private readonly proHost: string,
|
|
100
101
|
private readonly logger: Logger,
|
|
101
|
-
private readonly apiKey?: string
|
|
102
|
+
private readonly apiKey?: string,
|
|
103
|
+
private readonly customPlatformIdMap?: Record<number, string>
|
|
102
104
|
) {
|
|
103
105
|
this.prices = {};
|
|
104
106
|
}
|
|
@@ -115,6 +117,13 @@ export class Coingecko {
|
|
|
115
117
|
platforms.filter((chain) => Boolean(chain.chain_identifier)).map((chain) => [chain.chain_identifier, chain.id])
|
|
116
118
|
);
|
|
117
119
|
|
|
120
|
+
// Extend the platformIdMap with any custom platform ids
|
|
121
|
+
if (this.customPlatformIdMap) {
|
|
122
|
+
Object.entries(this.customPlatformIdMap).forEach(([chainId, platformId]) => {
|
|
123
|
+
this.platformIdMap.set(Number(chainId), platformId);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
118
127
|
id = this.platformIdMap.get(chainId);
|
|
119
128
|
if (!id) {
|
|
120
129
|
this.logger.error({
|
package/src/constants.ts
CHANGED
|
@@ -54,6 +54,7 @@ export const DEFAULT_CACHING_TTL = 60 * 60 * 24 * 7 * 2; // 2 Weeks
|
|
|
54
54
|
export const DEFAULT_CACHING_SAFE_LAG = 60 * 60; // 1 hour
|
|
55
55
|
|
|
56
56
|
export const DEFAULT_SIMULATED_RELAYER_ADDRESS = "0x07aE8551Be970cB1cCa11Dd7a11F47Ae82e70E67";
|
|
57
|
+
export const DEFAULT_SIMULATED_RELAYER_ADDRESS_SVM = "FmMK62wrtWVb5SVoTZftSCGw3nEDA79hDbZNTRnC1R6t";
|
|
57
58
|
export const DEFAULT_SIMULATED_RELAYER_ADDRESS_TEST = "0x9A8f92a830A5cB89a3816e3D267CB7791c16b04D"; // Görli, ...
|
|
58
59
|
|
|
59
60
|
export const DEFAULT_ARWEAVE_STORAGE_ADDRESS = "Z6hjBM8FHu90lYWB8o5jR1dfX92FlV2WBaND9xgp8Lg";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { providers } from "ethers";
|
|
2
2
|
import { bnOne } from "../../utils";
|
|
3
|
-
import {
|
|
3
|
+
import { EvmGasPriceEstimate } from "../types";
|
|
4
4
|
import * as ethereum from "./ethereum";
|
|
5
5
|
import { GasPriceEstimateOptions } from "../oracle";
|
|
6
6
|
|
|
@@ -16,7 +16,10 @@ import { GasPriceEstimateOptions } from "../oracle";
|
|
|
16
16
|
* function.
|
|
17
17
|
* @returns GasPriceEstimate
|
|
18
18
|
*/
|
|
19
|
-
export async function eip1559(
|
|
19
|
+
export async function eip1559(
|
|
20
|
+
provider: providers.Provider,
|
|
21
|
+
opts: GasPriceEstimateOptions
|
|
22
|
+
): Promise<EvmGasPriceEstimate> {
|
|
20
23
|
const { maxFeePerGas: _maxFeePerGas, maxPriorityFeePerGas } = await ethereum.eip1559(provider, opts);
|
|
21
24
|
|
|
22
25
|
// eip1559() sets maxFeePerGas = lastBaseFeePerGas + maxPriorityFeePerGas, so back out priority fee.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
import { providers } from "ethers";
|
|
3
3
|
import { BigNumber, bnZero, fixedPointAdjustment, getNetworkName, parseUnits } from "../../utils";
|
|
4
|
-
import {
|
|
4
|
+
import { EvmGasPriceEstimate } from "../types";
|
|
5
5
|
import { gasPriceError } from "../util";
|
|
6
6
|
import { GasPriceEstimateOptions } from "../oracle";
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ import { GasPriceEstimateOptions } from "../oracle";
|
|
|
13
13
|
* @param priorityFeeMultiplier Amount to multiply priority fee or unused for legacy gas pricing.
|
|
14
14
|
* @returns Promise of gas price estimate object.
|
|
15
15
|
*/
|
|
16
|
-
export function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<
|
|
16
|
+
export function eip1559(provider: providers.Provider, opts: GasPriceEstimateOptions): Promise<EvmGasPriceEstimate> {
|
|
17
17
|
return eip1559Raw(provider, opts.chainId, opts.baseFeeMultiplier, opts.priorityFeeMultiplier);
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -29,7 +29,7 @@ export async function eip1559Raw(
|
|
|
29
29
|
chainId: number,
|
|
30
30
|
baseFeeMultiplier: BigNumber,
|
|
31
31
|
priorityFeeMultiplier: BigNumber
|
|
32
|
-
): Promise<
|
|
32
|
+
): Promise<EvmGasPriceEstimate> {
|
|
33
33
|
const [{ baseFeePerGas }, _maxPriorityFeePerGas] = await Promise.all([
|
|
34
34
|
provider.getBlock("pending"),
|
|
35
35
|
(provider as providers.JsonRpcProvider).send("eth_maxPriorityFeePerGas", []),
|
|
@@ -54,7 +54,10 @@ export async function eip1559Raw(
|
|
|
54
54
|
* @dev Its recommended to use the eip1559Raw method over this one where possible as it will be more accurate.
|
|
55
55
|
* @returns GasPriceEstimate
|
|
56
56
|
*/
|
|
57
|
-
export async function legacy(
|
|
57
|
+
export async function legacy(
|
|
58
|
+
provider: providers.Provider,
|
|
59
|
+
opts: GasPriceEstimateOptions
|
|
60
|
+
): Promise<EvmGasPriceEstimate> {
|
|
58
61
|
const { chainId, baseFeeMultiplier } = opts;
|
|
59
62
|
const gasPrice = await provider.getGasPrice();
|
|
60
63
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PopulatedTransaction } from "ethers";
|
|
1
2
|
import { Address, Hex, PublicClient } from "viem";
|
|
2
3
|
import { estimateGas } from "viem/linea";
|
|
3
4
|
import { DEFAULT_SIMULATED_RELAYER_ADDRESS as account } from "../../constants";
|
|
@@ -26,7 +27,8 @@ export async function eip1559(
|
|
|
26
27
|
provider: PublicClient,
|
|
27
28
|
opts: GasPriceEstimateOptions
|
|
28
29
|
): Promise<InternalGasPriceEstimate> {
|
|
29
|
-
const { unsignedTx, priorityFeeMultiplier } = opts;
|
|
30
|
+
const { unsignedTx: _unsignedTx, priorityFeeMultiplier } = opts;
|
|
31
|
+
const unsignedTx = _unsignedTx as PopulatedTransaction; // Cast the opaque unsignedTx type to an ethers PopulatedTransaction.
|
|
30
32
|
const { baseFeePerGas, priorityFeePerGas: _priorityFeePerGas } = await estimateGas(provider, {
|
|
31
33
|
account: (unsignedTx?.from as Address) ?? account,
|
|
32
34
|
to: (unsignedTx?.to as Address) ?? account,
|
|
@@ -2,7 +2,7 @@ import { providers } from "ethers";
|
|
|
2
2
|
import { BaseHTTPAdapter, BaseHTTPAdapterArgs } from "../../priceClient/adapters/baseAdapter";
|
|
3
3
|
import { BigNumber, bnZero, fixedPointAdjustment, isDefined, parseUnits } from "../../utils";
|
|
4
4
|
import { CHAIN_IDs } from "../../constants";
|
|
5
|
-
import {
|
|
5
|
+
import { EvmGasPriceEstimate } from "../types";
|
|
6
6
|
import { gasPriceError } from "../util";
|
|
7
7
|
import { eip1559 } from "./ethereum";
|
|
8
8
|
import { GasPriceEstimateOptions } from "../oracle";
|
|
@@ -38,7 +38,7 @@ export class PolygonGasStation extends BaseHTTPAdapter {
|
|
|
38
38
|
this.chainId = chainId;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
async getFeeData(strategy: "safeLow" | "standard" | "fast" = "fast"): Promise<
|
|
41
|
+
async getFeeData(strategy: "safeLow" | "standard" | "fast" = "fast"): Promise<EvmGasPriceEstimate> {
|
|
42
42
|
const gas = await this.query("v2", {});
|
|
43
43
|
|
|
44
44
|
const gasPrice = (gas as GasStationV2Response)?.[strategy];
|
|
@@ -69,7 +69,7 @@ export class PolygonGasStation extends BaseHTTPAdapter {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
class MockRevertingPolygonGasStation extends PolygonGasStation {
|
|
72
|
-
getFeeData(): Promise<
|
|
72
|
+
getFeeData(): Promise<EvmGasPriceEstimate> {
|
|
73
73
|
throw new Error();
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -78,7 +78,7 @@ export const MockPolygonGasStationBaseFee = () => parseUnits("12", 9);
|
|
|
78
78
|
export const MockPolygonGasStationPriorityFee = () => parseUnits("1", 9);
|
|
79
79
|
|
|
80
80
|
class MockPolygonGasStation extends PolygonGasStation {
|
|
81
|
-
getFeeData(): Promise<
|
|
81
|
+
getFeeData(): Promise<EvmGasPriceEstimate> {
|
|
82
82
|
return Promise.resolve({
|
|
83
83
|
maxPriorityFeePerGas: MockPolygonGasStationPriorityFee(),
|
|
84
84
|
maxFeePerGas: MockPolygonGasStationBaseFee().add(MockPolygonGasStationPriorityFee()),
|
|
@@ -90,12 +90,12 @@ class MockPolygonGasStation extends PolygonGasStation {
|
|
|
90
90
|
* @notice Returns the gas price suggested by the Polygon GasStation API or reconstructs it using
|
|
91
91
|
* the eip1559() method as a fallback.
|
|
92
92
|
* @param provider Ethers Provider.
|
|
93
|
-
* @returns
|
|
93
|
+
* @returns EvmGasPriceEstimate
|
|
94
94
|
*/
|
|
95
95
|
export async function gasStation(
|
|
96
96
|
provider: providers.Provider,
|
|
97
97
|
opts: GasPriceEstimateOptions
|
|
98
|
-
): Promise<
|
|
98
|
+
): Promise<EvmGasPriceEstimate> {
|
|
99
99
|
const { chainId, baseFeeMultiplier, priorityFeeMultiplier } = opts;
|
|
100
100
|
let gasStation: PolygonGasStation;
|
|
101
101
|
if (process.env.TEST_POLYGON_GAS_STATION === "true") {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SVMProvider } from "../../arch/svm";
|
|
2
|
+
import { toBN, dedupArray, parseUnits } from "../../utils";
|
|
3
|
+
import { GasPriceEstimate } from "../types";
|
|
4
|
+
import { GasPriceEstimateOptions } from "../oracle";
|
|
5
|
+
import { CompilableTransactionMessage, TransactionMessageBytesBase64, compileTransaction } from "@solana/kit";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @notice Returns result of getFeeForMessage and getRecentPrioritizationFees RPC calls.
|
|
9
|
+
* @returns GasPriceEstimate
|
|
10
|
+
*/
|
|
11
|
+
export async function messageFee(provider: SVMProvider, opts: GasPriceEstimateOptions): Promise<GasPriceEstimate> {
|
|
12
|
+
const { unsignedTx: _unsignedTx } = opts;
|
|
13
|
+
|
|
14
|
+
// Cast the opaque unsignedTx type to a solana-kit CompilableTransactionMessage.
|
|
15
|
+
const unsignedTx = _unsignedTx as CompilableTransactionMessage;
|
|
16
|
+
const compiledTransaction = compileTransaction(unsignedTx);
|
|
17
|
+
|
|
18
|
+
// Get this base fee. This should result in LAMPORTS_PER_SIGNATURE * nSignatures.
|
|
19
|
+
const encodedTransactionMessage = Buffer.from(compiledTransaction.messageBytes).toString(
|
|
20
|
+
"base64"
|
|
21
|
+
) as TransactionMessageBytesBase64;
|
|
22
|
+
const baseFeeResponse = await provider.getFeeForMessage(encodedTransactionMessage).send();
|
|
23
|
+
|
|
24
|
+
// Get the priority fee by calling `getRecentPrioritzationFees` on all the addresses in the transaction's instruction array.
|
|
25
|
+
const instructionAddresses = dedupArray(unsignedTx.instructions.map((instruction) => instruction.programAddress));
|
|
26
|
+
const recentPriorityFees = await provider.getRecentPrioritizationFees(instructionAddresses).send();
|
|
27
|
+
|
|
28
|
+
// Take the most recent 25 slots and find the average of the nonzero priority fees.
|
|
29
|
+
const nonzeroPrioritizationFees = recentPriorityFees
|
|
30
|
+
.slice(125)
|
|
31
|
+
.map((value) => value.prioritizationFee)
|
|
32
|
+
.filter((fee) => fee > 0);
|
|
33
|
+
const totalPrioritizationFees = nonzeroPrioritizationFees.reduce((acc, fee) => acc + fee, BigInt(0));
|
|
34
|
+
|
|
35
|
+
// Optionally impose a minimum priority fee, denoted in microLamports/computeUnit.
|
|
36
|
+
const flooredPriorityFeePerGas = parseUnits(process.env[`MIN_PRIORITY_FEE_PER_GAS_${opts.chainId}`] || "0", 6);
|
|
37
|
+
let microLamportsPerComputeUnit = toBN(
|
|
38
|
+
totalPrioritizationFees / BigInt(Math.max(nonzeroPrioritizationFees.length, 1))
|
|
39
|
+
);
|
|
40
|
+
if (microLamportsPerComputeUnit.lt(flooredPriorityFeePerGas)) {
|
|
41
|
+
microLamportsPerComputeUnit = flooredPriorityFeePerGas;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
baseFee: toBN(baseFeeResponse!.value!),
|
|
45
|
+
microLamportsPerComputeUnit,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { getGasPriceEstimate } from "./oracle";
|
|
2
|
-
export { GasPriceEstimate } from "./types";
|
|
2
|
+
export { GasPriceEstimate, EvmGasPriceEstimate, SvmGasPriceEstimate } from "./types";
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
import { Transport } from "viem";
|
|
3
|
-
import {
|
|
3
|
+
import { providers } from "ethers";
|
|
4
4
|
import { CHAIN_IDs } from "../constants";
|
|
5
5
|
import { BigNumber, chainIsOPStack, fixedPointAdjustment, toBNWei } from "../utils";
|
|
6
|
+
import { SVMProvider as SolanaProvider } from "../arch/svm";
|
|
6
7
|
import { GasPriceEstimate } from "./types";
|
|
7
8
|
import { getPublicClient } from "./util";
|
|
8
9
|
import * as arbitrum from "./adapters/arbitrum";
|
|
9
10
|
import * as ethereum from "./adapters/ethereum";
|
|
10
11
|
import * as polygon from "./adapters/polygon";
|
|
11
12
|
import * as lineaViem from "./adapters/linea-viem";
|
|
13
|
+
import * as solana from "./adapters/solana";
|
|
12
14
|
|
|
13
15
|
export interface GasPriceEstimateOptions {
|
|
14
16
|
// baseFeeMultiplier Multiplier applied to base fee for EIP1559 gas prices (or total fee for legacy).
|
|
@@ -19,8 +21,8 @@ export interface GasPriceEstimateOptions {
|
|
|
19
21
|
legacyFallback: boolean;
|
|
20
22
|
// chainId The chain ID to query for gas prices. If omitted can be inferred by provider.
|
|
21
23
|
chainId: number;
|
|
22
|
-
// unsignedTx The unsigned transaction used for simulation by Linea's Viem provider to produce the priority gas fee.
|
|
23
|
-
unsignedTx?:
|
|
24
|
+
// unsignedTx The unsigned transaction used for simulation by Linea's Viem provider to produce the priority gas fee, or alternatively, by Solana's provider to determine the base/priority fee.
|
|
25
|
+
unsignedTx?: unknown;
|
|
24
26
|
// transport Viem Transport object to use for querying gas fees used for testing.
|
|
25
27
|
transport?: Transport;
|
|
26
28
|
}
|
|
@@ -39,7 +41,7 @@ const VIEM_CHAINS = [CHAIN_IDs.LINEA];
|
|
|
39
41
|
* @returns An object of type GasPriceEstimate.
|
|
40
42
|
*/
|
|
41
43
|
export async function getGasPriceEstimate(
|
|
42
|
-
provider: providers.Provider,
|
|
44
|
+
provider: providers.Provider | SolanaProvider,
|
|
43
45
|
opts: Partial<GasPriceEstimateOptions> = {}
|
|
44
46
|
): Promise<GasPriceEstimate> {
|
|
45
47
|
const baseFeeMultiplier = opts.baseFeeMultiplier ?? toBNWei("1");
|
|
@@ -53,6 +55,20 @@ export async function getGasPriceEstimate(
|
|
|
53
55
|
`Require 1.0 < priority fee multiplier (${priorityFeeMultiplier}) <= 5.0 for a total gas multiplier within [+1.0, +5.0]`
|
|
54
56
|
);
|
|
55
57
|
|
|
58
|
+
// Exit here if we need to estimate on Solana.
|
|
59
|
+
if (!(provider instanceof providers.Provider)) {
|
|
60
|
+
const optsWithDefaults: GasPriceEstimateOptions = {
|
|
61
|
+
...GAS_PRICE_ESTIMATE_DEFAULTS,
|
|
62
|
+
baseFeeMultiplier,
|
|
63
|
+
priorityFeeMultiplier,
|
|
64
|
+
...opts,
|
|
65
|
+
chainId: opts.chainId ?? CHAIN_IDs.SOLANA,
|
|
66
|
+
};
|
|
67
|
+
return solana.messageFee(provider, optsWithDefaults);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Cast the provider to an ethers provider, which should be given to the oracle when querying an EVM network.
|
|
71
|
+
provider = provider as providers.Provider;
|
|
56
72
|
const chainId = opts.chainId ?? (await provider.getNetwork()).chainId;
|
|
57
73
|
const optsWithDefaults: GasPriceEstimateOptions = {
|
|
58
74
|
...GAS_PRICE_ESTIMATE_DEFAULTS,
|
|
@@ -2,12 +2,18 @@ import { type Chain, type Transport, PublicClient, FeeValuesEIP1559 } from "viem
|
|
|
2
2
|
import { BigNumber } from "../utils";
|
|
3
3
|
|
|
4
4
|
export type InternalGasPriceEstimate = FeeValuesEIP1559;
|
|
5
|
+
export type GasPriceEstimate = EvmGasPriceEstimate | SvmGasPriceEstimate;
|
|
5
6
|
|
|
6
|
-
export type
|
|
7
|
+
export type EvmGasPriceEstimate = {
|
|
7
8
|
maxFeePerGas: BigNumber;
|
|
8
9
|
maxPriorityFeePerGas: BigNumber;
|
|
9
10
|
};
|
|
10
11
|
|
|
12
|
+
export type SvmGasPriceEstimate = {
|
|
13
|
+
baseFee: BigNumber;
|
|
14
|
+
microLamportsPerComputeUnit: BigNumber;
|
|
15
|
+
};
|
|
16
|
+
|
|
11
17
|
export interface GasPriceFeed {
|
|
12
18
|
(provider: PublicClient<Transport, Chain>, chainId: number): Promise<InternalGasPriceEstimate>;
|
|
13
19
|
}
|
package/src/index.ts
CHANGED