@across-protocol/sdk 4.2.16 → 4.3.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/SpokeUtils.d.ts +8 -3
- package/dist/cjs/arch/evm/SpokeUtils.js +26 -11
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +8 -2
- package/dist/cjs/arch/svm/SpokeUtils.js +41 -50
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/eventsClient.js +4 -2
- package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +3 -3
- package/dist/cjs/arch/svm/utils.js +16 -14
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +59 -59
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +16 -13
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +3 -2
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +13 -8
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +21 -21
- package/dist/cjs/clients/HubPoolClient.js +85 -58
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +1 -3
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +66 -46
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/index.d.ts +1 -0
- package/dist/cjs/clients/SpokePoolClient/index.js +3 -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/MockHubPoolClient.d.ts +9 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +15 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -36
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +6 -4
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/cjs/interfaces/HubPool.d.ts +19 -14
- package/dist/cjs/interfaces/SpokePool.d.ts +18 -19
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +17 -9
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +24 -15
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +8 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +13 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +61 -58
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +15 -7
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +13 -13
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +12 -8
- package/dist/cjs/utils/AddressUtils.js +33 -36
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.d.ts +2 -2
- package/dist/cjs/utils/DepositUtils.js +1 -1
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +1 -3
- package/dist/cjs/utils/SpokeUtils.js +3 -25
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +4 -4
- package/dist/cjs/utils/TokenUtils.js +5 -3
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +9 -4
- package/dist/esm/arch/evm/SpokeUtils.js +29 -14
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +9 -3
- package/dist/esm/arch/svm/SpokeUtils.js +42 -55
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/eventsClient.js +5 -3
- package/dist/esm/arch/svm/eventsClient.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +3 -3
- package/dist/esm/arch/svm/utils.js +17 -15
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +60 -60
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +18 -15
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +7 -7
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +20 -10
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +22 -22
- package/dist/esm/clients/HubPoolClient.js +93 -66
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +3 -3
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +2 -4
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +69 -48
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.d.ts +1 -0
- package/dist/esm/clients/SpokePoolClient/index.js +1 -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/MockHubPoolClient.d.ts +9 -9
- package/dist/esm/clients/mocks/MockHubPoolClient.js +16 -10
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +42 -38
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +7 -5
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +3 -3
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/esm/interfaces/HubPool.d.ts +19 -14
- package/dist/esm/interfaces/SpokePool.d.ts +18 -19
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +28 -19
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +9 -6
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +67 -63
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +12 -12
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +12 -8
- package/dist/esm/utils/AddressUtils.js +36 -38
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.d.ts +2 -2
- package/dist/esm/utils/DepositUtils.js +2 -2
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +1 -8
- package/dist/esm/utils/SpokeUtils.js +3 -29
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +6 -18
- package/dist/esm/utils/TokenUtils.js +6 -4
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +9 -4
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +9 -3
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/eventsClient.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +3 -3
- package/dist/types/arch/svm/utils.d.ts.map +1 -1
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +22 -22
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/index.d.ts +1 -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/MockHubPoolClient.d.ts +9 -9
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
- package/dist/types/interfaces/HubPool.d.ts +19 -14
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +18 -19
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +12 -8
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/DepositUtils.d.ts +2 -2
- package/dist/types/utils/DepositUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +1 -8
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +6 -18
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/arch/evm/SpokeUtils.ts +72 -22
- package/src/arch/svm/SpokeUtils.ts +67 -53
- package/src/arch/svm/eventsClient.ts +40 -8
- package/src/arch/svm/utils.ts +6 -6
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +56 -56
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +32 -15
- package/src/clients/BundleDataClient/utils/FillUtils.ts +12 -8
- package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +7 -1
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +22 -10
- package/src/clients/HubPoolClient.ts +125 -86
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +7 -2
- package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +1 -4
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +122 -37
- package/src/clients/SpokePoolClient/index.ts +1 -0
- package/src/clients/index.ts +1 -0
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +39 -27
- package/src/clients/mocks/MockSvmCpiEventsClient.ts +8 -5
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
- package/src/interfaces/HubPool.ts +20 -14
- package/src/interfaces/SpokePool.ts +19 -19
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +39 -21
- package/src/relayFeeCalculator/chain-queries/factory.ts +8 -5
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +73 -58
- package/src/relayFeeCalculator/relayFeeCalculator.ts +23 -21
- package/src/utils/AddressUtils.ts +39 -51
- package/src/utils/DepositUtils.ts +4 -4
- package/src/utils/SpokeUtils.ts +8 -36
- package/src/utils/TokenUtils.ts +10 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BigNumber } from "../utils";
|
|
1
|
+
import { Address, BigNumber, EvmAddress } from "../utils";
|
|
2
2
|
import { SortableEvent } from "./Common";
|
|
3
3
|
|
|
4
4
|
export interface PoolRebalanceLeaf {
|
|
@@ -8,7 +8,7 @@ export interface PoolRebalanceLeaf {
|
|
|
8
8
|
netSendAmounts: BigNumber[];
|
|
9
9
|
runningBalances: BigNumber[];
|
|
10
10
|
leafId: number;
|
|
11
|
-
l1Tokens:
|
|
11
|
+
l1Tokens: EvmAddress[];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface RelayerRefundLeaf {
|
|
@@ -16,8 +16,8 @@ export interface RelayerRefundLeaf {
|
|
|
16
16
|
chainId: number;
|
|
17
17
|
refundAmounts: BigNumber[];
|
|
18
18
|
leafId: number;
|
|
19
|
-
l2TokenAddress:
|
|
20
|
-
refundAddresses:
|
|
19
|
+
l2TokenAddress: Address;
|
|
20
|
+
refundAddresses: Address[];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface ProposedRootBundle extends SortableEvent {
|
|
@@ -27,7 +27,7 @@ export interface ProposedRootBundle extends SortableEvent {
|
|
|
27
27
|
poolRebalanceRoot: string;
|
|
28
28
|
relayerRefundRoot: string;
|
|
29
29
|
slowRelayRoot: string;
|
|
30
|
-
proposer:
|
|
30
|
+
proposer: EvmAddress;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export type RealizedLpFee = {
|
|
@@ -55,7 +55,7 @@ export interface ExecutedRootBundle extends SortableEvent {
|
|
|
55
55
|
netSendAmounts: BigNumber[];
|
|
56
56
|
runningBalances: BigNumber[];
|
|
57
57
|
leafId: number;
|
|
58
|
-
l1Tokens:
|
|
58
|
+
l1Tokens: EvmAddress[];
|
|
59
59
|
proof: string[];
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -76,8 +76,14 @@ export interface RelayerRefundLeafWithGroup extends RelayerRefundLeaf {
|
|
|
76
76
|
groupIndex: number;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export interface
|
|
80
|
-
address:
|
|
79
|
+
export interface L1TokenInfo {
|
|
80
|
+
address: EvmAddress;
|
|
81
|
+
symbol: string;
|
|
82
|
+
decimals: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface TokenInfo {
|
|
86
|
+
address: Address;
|
|
81
87
|
symbol: string;
|
|
82
88
|
decimals: number;
|
|
83
89
|
}
|
|
@@ -89,25 +95,25 @@ export interface LpToken {
|
|
|
89
95
|
|
|
90
96
|
export interface CrossChainContractsSet extends SortableEvent {
|
|
91
97
|
l2ChainId: number;
|
|
92
|
-
spokePool:
|
|
98
|
+
spokePool: Address;
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
export interface DestinationTokenWithBlock extends SortableEvent {
|
|
96
|
-
l2Token:
|
|
97
|
-
l1Token:
|
|
102
|
+
l2Token: Address;
|
|
103
|
+
l1Token: EvmAddress;
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
export interface SetPoolRebalanceRoot extends SortableEvent {
|
|
101
107
|
destinationChainId: number;
|
|
102
|
-
l1Token:
|
|
103
|
-
destinationToken:
|
|
108
|
+
l1Token: EvmAddress;
|
|
109
|
+
destinationToken: Address;
|
|
104
110
|
}
|
|
105
111
|
|
|
106
112
|
export interface PendingRootBundle {
|
|
107
113
|
poolRebalanceRoot: string;
|
|
108
114
|
relayerRefundRoot: string;
|
|
109
115
|
slowRelayRoot: string;
|
|
110
|
-
proposer:
|
|
116
|
+
proposer: EvmAddress;
|
|
111
117
|
unclaimedPoolRebalanceLeafCount: number;
|
|
112
118
|
challengePeriodEndTimestamp: number;
|
|
113
119
|
bundleEvaluationBlockNumbers: number[];
|
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
import { SortableEvent } from "./Common";
|
|
2
2
|
import { SpokePoolClient } from "../clients";
|
|
3
|
-
import { BigNumber } from "../utils";
|
|
3
|
+
import { BigNumber, Address, EvmAddress } from "../utils";
|
|
4
4
|
import { RelayerRefundLeaf } from "./HubPool";
|
|
5
5
|
|
|
6
6
|
export interface RelayData {
|
|
7
7
|
originChainId: number;
|
|
8
|
-
depositor:
|
|
9
|
-
recipient:
|
|
8
|
+
depositor: Address;
|
|
9
|
+
recipient: Address;
|
|
10
10
|
depositId: BigNumber;
|
|
11
|
-
inputToken:
|
|
11
|
+
inputToken: Address;
|
|
12
12
|
inputAmount: BigNumber;
|
|
13
|
-
outputToken:
|
|
13
|
+
outputToken: Address;
|
|
14
14
|
outputAmount: BigNumber;
|
|
15
15
|
message: string;
|
|
16
16
|
fillDeadline: number;
|
|
17
|
-
exclusiveRelayer:
|
|
17
|
+
exclusiveRelayer: Address;
|
|
18
18
|
exclusivityDeadline: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export interface
|
|
21
|
+
export interface SpeedUpCommon {
|
|
22
|
+
updatedRecipient: Address;
|
|
23
|
+
updatedOutputAmount: BigNumber;
|
|
24
|
+
updatedMessage: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Deposit extends RelayData, Partial<SpeedUpCommon> {
|
|
22
28
|
messageHash: string;
|
|
23
29
|
destinationChainId: number;
|
|
24
30
|
quoteTimestamp: number;
|
|
25
31
|
speedUpSignature?: string;
|
|
26
|
-
updatedRecipient?: string;
|
|
27
|
-
updatedOutputAmount?: BigNumber;
|
|
28
|
-
updatedMessage?: string;
|
|
29
32
|
fromLiteChain: boolean;
|
|
30
33
|
toLiteChain: boolean;
|
|
31
34
|
}
|
|
@@ -51,7 +54,7 @@ export enum FillType {
|
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
export interface RelayExecutionEventInfo {
|
|
54
|
-
updatedRecipient:
|
|
57
|
+
updatedRecipient: Address;
|
|
55
58
|
updatedOutputAmount: BigNumber;
|
|
56
59
|
updatedMessage?: string;
|
|
57
60
|
updatedMessageHash: string;
|
|
@@ -61,7 +64,7 @@ export interface RelayExecutionEventInfo {
|
|
|
61
64
|
export interface Fill extends Omit<RelayData, "message"> {
|
|
62
65
|
messageHash: string;
|
|
63
66
|
destinationChainId: number;
|
|
64
|
-
relayer:
|
|
67
|
+
relayer: Address;
|
|
65
68
|
repaymentChainId: number;
|
|
66
69
|
relayExecutionInfo: RelayExecutionEventInfo;
|
|
67
70
|
}
|
|
@@ -72,20 +75,17 @@ export interface FillWithTime extends Fill, SortableEvent {
|
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
export interface EnabledDepositRoute {
|
|
75
|
-
originToken:
|
|
78
|
+
originToken: Address;
|
|
76
79
|
destinationChainId: number;
|
|
77
80
|
enabled: boolean;
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
export interface EnabledDepositRouteWithBlock extends EnabledDepositRoute, SortableEvent {}
|
|
81
|
-
export interface SpeedUp {
|
|
82
|
-
depositor:
|
|
84
|
+
export interface SpeedUp extends SpeedUpCommon {
|
|
85
|
+
depositor: EvmAddress;
|
|
83
86
|
depositorSignature: string;
|
|
84
87
|
depositId: BigNumber;
|
|
85
88
|
originChainId: number;
|
|
86
|
-
updatedRecipient: string;
|
|
87
|
-
updatedOutputAmount: BigNumber;
|
|
88
|
-
updatedMessage: string;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export interface SpeedUpWithBlock extends SpeedUp, SortableEvent {}
|
|
@@ -130,7 +130,7 @@ export interface TokensBridged extends SortableEvent {
|
|
|
130
130
|
amountToReturn: BigNumber;
|
|
131
131
|
chainId: number;
|
|
132
132
|
leafId: number;
|
|
133
|
-
l2TokenAddress:
|
|
133
|
+
l2TokenAddress: Address;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
export interface ClaimedRelayerRefundWithBlock extends SortableEvent {
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { L2Provider } from "@eth-optimism/sdk/dist/interfaces/l2-provider";
|
|
2
2
|
import { isL2Provider as isOptimismL2Provider } from "@eth-optimism/sdk/dist/l2-provider";
|
|
3
|
-
|
|
4
3
|
import { PopulatedTransaction, providers, VoidSigner } from "ethers";
|
|
5
4
|
import { Coingecko } from "../../coingecko";
|
|
6
5
|
import { CHAIN_IDs } from "../../constants";
|
|
7
|
-
import {
|
|
6
|
+
import { RelayData } from "../../interfaces";
|
|
8
7
|
import { SpokePool, SpokePool__factory } from "../../typechain";
|
|
9
8
|
import { populateV3Relay } from "../../arch/evm";
|
|
10
9
|
import {
|
|
11
10
|
BigNumberish,
|
|
11
|
+
EvmAddress,
|
|
12
12
|
TransactionCostEstimate,
|
|
13
13
|
BigNumber,
|
|
14
14
|
toBNWei,
|
|
15
15
|
bnZero,
|
|
16
16
|
chainIsOPStack,
|
|
17
17
|
fixedPointAdjustment,
|
|
18
|
+
Address,
|
|
18
19
|
} from "../../utils";
|
|
19
20
|
import assert from "assert";
|
|
20
|
-
import { Logger, QueryInterface,
|
|
21
|
+
import { Logger, QueryInterface, getDefaultRelayer } from "../relayFeeCalculator";
|
|
21
22
|
import { Transport } from "viem";
|
|
22
23
|
import { getGasPriceEstimate } from "../../gasPriceOracle";
|
|
23
24
|
import { EvmProvider } from "../../arch/evm/types";
|
|
@@ -51,7 +52,7 @@ export class QueryBase implements QueryInterface {
|
|
|
51
52
|
readonly provider: EvmProvider,
|
|
52
53
|
readonly symbolMapping: SymbolMappingType,
|
|
53
54
|
readonly spokePoolAddress: string,
|
|
54
|
-
readonly simulatedRelayerAddress:
|
|
55
|
+
readonly simulatedRelayerAddress: EvmAddress,
|
|
55
56
|
readonly logger: Logger,
|
|
56
57
|
readonly coingeckoProApiKey?: string,
|
|
57
58
|
readonly fixedGasPrice?: BigNumberish,
|
|
@@ -62,7 +63,7 @@ export class QueryBase implements QueryInterface {
|
|
|
62
63
|
|
|
63
64
|
/**
|
|
64
65
|
* Retrieves the current gas costs of performing a fillRelay contract at the referenced SpokePool.
|
|
65
|
-
* @param
|
|
66
|
+
* @param relayData RelayData instance, supplemented with destinationChainId
|
|
66
67
|
* @param relayerAddress Relayer address to simulate with.
|
|
67
68
|
* @param options
|
|
68
69
|
* @param options.gasPrice Optional gas price to use for the simulation.
|
|
@@ -71,8 +72,8 @@ export class QueryBase implements QueryInterface {
|
|
|
71
72
|
* @returns The gas estimate for this function call (multiplied with the optional buffer).
|
|
72
73
|
*/
|
|
73
74
|
async getGasCosts(
|
|
74
|
-
|
|
75
|
-
relayer =
|
|
75
|
+
relayData: RelayData & { destinationChainId: number },
|
|
76
|
+
relayer = getDefaultRelayer(relayData.destinationChainId),
|
|
76
77
|
options: Partial<{
|
|
77
78
|
gasPrice: BigNumberish;
|
|
78
79
|
gasUnits: BigNumberish;
|
|
@@ -91,7 +92,12 @@ export class QueryBase implements QueryInterface {
|
|
|
91
92
|
transport,
|
|
92
93
|
} = options;
|
|
93
94
|
|
|
94
|
-
const
|
|
95
|
+
const { recipient, outputToken, exclusiveRelayer } = relayData;
|
|
96
|
+
assert(recipient.isEVM(), `getGasCosts: recipient not an EVM address (${recipient})`);
|
|
97
|
+
assert(outputToken.isEVM(), `getGasCosts: outputToken not an EVM address (${outputToken})`);
|
|
98
|
+
assert(exclusiveRelayer.isEVM(), `getGasCosts: exclusiveRelayer not an EVM address (${exclusiveRelayer})`);
|
|
99
|
+
|
|
100
|
+
const tx = await this.getUnsignedTxFromDeposit({ ...relayData, recipient, outputToken, exclusiveRelayer }, relayer);
|
|
95
101
|
const {
|
|
96
102
|
nativeGasCost,
|
|
97
103
|
tokenGasCost,
|
|
@@ -116,29 +122,41 @@ export class QueryBase implements QueryInterface {
|
|
|
116
122
|
|
|
117
123
|
/**
|
|
118
124
|
* @notice Return ethers.PopulatedTransaction for a fill based on input deposit args
|
|
119
|
-
* @param
|
|
125
|
+
* @param relayData RelayData instance, supplemented with destinationChainId
|
|
120
126
|
* @param relayer Sender of PopulatedTransaction
|
|
121
127
|
* @returns PopulatedTransaction
|
|
122
128
|
*/
|
|
123
129
|
getUnsignedTxFromDeposit(
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
relayData: Omit<RelayData, "recipient" | "outputToken"> & {
|
|
131
|
+
destinationChainId: number;
|
|
132
|
+
recipient: EvmAddress;
|
|
133
|
+
outputToken: EvmAddress;
|
|
134
|
+
},
|
|
135
|
+
relayer = getDefaultRelayer(relayData.destinationChainId)
|
|
126
136
|
): Promise<PopulatedTransaction> {
|
|
127
|
-
return populateV3Relay(this.spokePool,
|
|
137
|
+
return populateV3Relay(this.spokePool, relayData, relayer);
|
|
128
138
|
}
|
|
129
139
|
|
|
130
140
|
/**
|
|
131
141
|
* @notice Return the gas cost of a simulated transaction
|
|
132
|
-
* @param
|
|
142
|
+
* @param relayData RelayData instance, supplemented with destinationChainId
|
|
133
143
|
* @param relayer Sender of PopulatedTransaction
|
|
134
144
|
* @returns Estimated gas cost based on ethers.VoidSigner's gas estimation
|
|
135
145
|
*/
|
|
136
146
|
async getNativeGasCost(
|
|
137
|
-
|
|
138
|
-
relayer =
|
|
147
|
+
relayData: RelayData & { destinationChainId: number },
|
|
148
|
+
relayer = getDefaultRelayer(relayData.destinationChainId)
|
|
139
149
|
): Promise<BigNumber> {
|
|
140
|
-
const
|
|
141
|
-
|
|
150
|
+
const { recipient, outputToken, exclusiveRelayer } = relayData;
|
|
151
|
+
assert(recipient.isEVM(), `getNativeGasCost: recipient not an EVM address (${recipient})`);
|
|
152
|
+
assert(outputToken.isEVM(), `getNativeGasCost: outputToken not an EVM address (${outputToken})`);
|
|
153
|
+
assert(exclusiveRelayer.isEVM(), `getNativeGasCost: exclusiveRelayer not an EVM address (${exclusiveRelayer})`);
|
|
154
|
+
|
|
155
|
+
const unsignedTx = await this.getUnsignedTxFromDeposit(
|
|
156
|
+
{ ...relayData, recipient, outputToken, exclusiveRelayer },
|
|
157
|
+
relayer
|
|
158
|
+
);
|
|
159
|
+
const voidSigner = new VoidSigner(relayer.toEvmAddress(), this.provider);
|
|
142
160
|
return voidSigner.estimateGas(unsignedTx);
|
|
143
161
|
}
|
|
144
162
|
|
|
@@ -152,7 +170,7 @@ export class QueryBase implements QueryInterface {
|
|
|
152
170
|
*/
|
|
153
171
|
async getOpStackL1DataFee(
|
|
154
172
|
unsignedTx: PopulatedTransaction,
|
|
155
|
-
relayer =
|
|
173
|
+
relayer = getDefaultRelayer(unsignedTx.chainId),
|
|
156
174
|
options: Partial<{
|
|
157
175
|
opStackL2GasUnits: BigNumberish;
|
|
158
176
|
opStackL1DataFeeMultiplier: BigNumber;
|
|
@@ -161,7 +179,7 @@ export class QueryBase implements QueryInterface {
|
|
|
161
179
|
const { opStackL2GasUnits, opStackL1DataFeeMultiplier = toBNWei("1") } = options || {};
|
|
162
180
|
const { chainId } = await this.provider.getNetwork();
|
|
163
181
|
assert(isOptimismL2Provider(this.provider), `Unexpected provider for chain ID ${chainId}.`);
|
|
164
|
-
const voidSigner = new VoidSigner(relayer, this.provider);
|
|
182
|
+
const voidSigner = new VoidSigner(relayer.toEvmAddress(), this.provider);
|
|
165
183
|
const populatedTransaction = await voidSigner.populateTransaction({
|
|
166
184
|
...unsignedTx,
|
|
167
185
|
gasLimit: opStackL2GasUnits, // prevents additional gas estimation call
|
|
@@ -183,7 +201,7 @@ export class QueryBase implements QueryInterface {
|
|
|
183
201
|
*/
|
|
184
202
|
async estimateGas(
|
|
185
203
|
unsignedTx: PopulatedTransaction,
|
|
186
|
-
senderAddress:
|
|
204
|
+
senderAddress: Address,
|
|
187
205
|
provider: providers.Provider | L2Provider<providers.Provider>,
|
|
188
206
|
options: Partial<{
|
|
189
207
|
gasPrice: BigNumberish;
|
|
@@ -204,7 +222,7 @@ export class QueryBase implements QueryInterface {
|
|
|
204
222
|
} = options || {};
|
|
205
223
|
|
|
206
224
|
const { chainId } = await provider.getNetwork();
|
|
207
|
-
const voidSigner = new VoidSigner(senderAddress, provider);
|
|
225
|
+
const voidSigner = new VoidSigner(senderAddress.toEvmAddress(), provider);
|
|
208
226
|
|
|
209
227
|
// Estimate the Gas units required to submit this transaction.
|
|
210
228
|
const queries = [
|
|
@@ -7,7 +7,7 @@ import { CUSTOM_GAS_TOKENS } from "../../constants";
|
|
|
7
7
|
import { chainIsOPStack, isDefined, chainIsSvm, SvmAddress } from "../../utils";
|
|
8
8
|
import { QueryBase } from "./baseQuery";
|
|
9
9
|
import { SVMProvider as svmProvider } from "../../arch/svm";
|
|
10
|
-
import { DEFAULT_LOGGER,
|
|
10
|
+
import { DEFAULT_LOGGER, getDefaultRelayer, Logger } from "../relayFeeCalculator";
|
|
11
11
|
import { CustomGasTokenQueries } from "./customGasToken";
|
|
12
12
|
import { SvmQuery } from "./svmQuery";
|
|
13
13
|
|
|
@@ -25,7 +25,7 @@ export class QueryBase__factory {
|
|
|
25
25
|
provider: providers.Provider | svmProvider,
|
|
26
26
|
symbolMapping = TOKEN_SYMBOLS_MAP,
|
|
27
27
|
spokePoolAddress = getDeployedAddress("SpokePool", chainId),
|
|
28
|
-
|
|
28
|
+
relayerAddress = getDefaultRelayer(chainId),
|
|
29
29
|
coingeckoProApiKey?: string,
|
|
30
30
|
logger: Logger = DEFAULT_LOGGER,
|
|
31
31
|
coingeckoBaseCurrency = "eth"
|
|
@@ -34,12 +34,13 @@ export class QueryBase__factory {
|
|
|
34
34
|
|
|
35
35
|
const customGasTokenSymbol = CUSTOM_GAS_TOKENS[chainId];
|
|
36
36
|
if (customGasTokenSymbol) {
|
|
37
|
+
assert(relayerAddress.isEVM());
|
|
37
38
|
return new CustomGasTokenQueries({
|
|
38
39
|
queryBaseArgs: [
|
|
39
40
|
provider as providers.Provider,
|
|
40
41
|
symbolMapping,
|
|
41
42
|
spokePoolAddress,
|
|
42
|
-
|
|
43
|
+
relayerAddress,
|
|
43
44
|
logger,
|
|
44
45
|
coingeckoProApiKey,
|
|
45
46
|
fixedGasPrice[chainId],
|
|
@@ -49,11 +50,12 @@ export class QueryBase__factory {
|
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
if (chainIsSvm(chainId)) {
|
|
53
|
+
assert(relayerAddress.isSVM());
|
|
52
54
|
return new SvmQuery(
|
|
53
55
|
provider as svmProvider,
|
|
54
56
|
symbolMapping,
|
|
55
57
|
SvmAddress.from(spokePoolAddress),
|
|
56
|
-
|
|
58
|
+
relayerAddress,
|
|
57
59
|
logger,
|
|
58
60
|
coingeckoProApiKey,
|
|
59
61
|
fixedGasPrice[chainId],
|
|
@@ -66,11 +68,12 @@ export class QueryBase__factory {
|
|
|
66
68
|
? asL2Provider(provider as providers.Provider)
|
|
67
69
|
: (provider as providers.Provider);
|
|
68
70
|
|
|
71
|
+
assert(relayerAddress.isEVM());
|
|
69
72
|
return new QueryBase(
|
|
70
73
|
provider,
|
|
71
74
|
symbolMapping,
|
|
72
75
|
spokePoolAddress,
|
|
73
|
-
|
|
76
|
+
relayerAddress,
|
|
74
77
|
logger,
|
|
75
78
|
coingeckoProApiKey,
|
|
76
79
|
fixedGasPrice[chainId],
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import assert from "assert";
|
|
1
2
|
import { SvmSpokeClient } from "@across-protocol/contracts";
|
|
2
3
|
import { intToU8Array32 } from "@across-protocol/contracts/dist/src/svm/web3-v1/conversionUtils";
|
|
3
4
|
import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system";
|
|
@@ -17,17 +18,17 @@ import {
|
|
|
17
18
|
import { Coingecko } from "../../coingecko";
|
|
18
19
|
import { CHAIN_IDs } from "../../constants";
|
|
19
20
|
import { getGasPriceEstimate } from "../../gasPriceOracle";
|
|
20
|
-
import {
|
|
21
|
+
import { RelayData } from "../../interfaces";
|
|
21
22
|
import {
|
|
23
|
+
Address,
|
|
22
24
|
BigNumber,
|
|
23
25
|
BigNumberish,
|
|
24
26
|
SvmAddress,
|
|
25
27
|
TransactionCostEstimate,
|
|
26
28
|
getRelayDataHash,
|
|
27
|
-
toAddressType,
|
|
28
29
|
toBN,
|
|
29
30
|
} from "../../utils";
|
|
30
|
-
import { Logger, QueryInterface,
|
|
31
|
+
import { Logger, QueryInterface, getDefaultRelayer } from "../relayFeeCalculator";
|
|
31
32
|
import { SymbolMappingType } from "./";
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -65,7 +66,7 @@ export class SvmQuery implements QueryInterface {
|
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
68
|
* Retrieves the current gas costs of performing a fillRelay contract at the referenced SpokePool.
|
|
68
|
-
* @param
|
|
69
|
+
* @param relayData RelayData instance, supplemented with destinationChainId
|
|
69
70
|
* @param _relayer Relayer address to simulate with.
|
|
70
71
|
* @param options
|
|
71
72
|
* @param options.gasPrice Optional gas price to use for the simulation.
|
|
@@ -74,8 +75,8 @@ export class SvmQuery implements QueryInterface {
|
|
|
74
75
|
* @returns The gas estimate for this function call (multiplied with the optional buffer).
|
|
75
76
|
*/
|
|
76
77
|
async getGasCosts(
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
relayData: RelayData & { destinationChainId: number },
|
|
79
|
+
relayer = getDefaultRelayer(relayData.destinationChainId),
|
|
79
80
|
options: Partial<{
|
|
80
81
|
gasPrice: BigNumberish;
|
|
81
82
|
gasUnits: BigNumberish;
|
|
@@ -83,10 +84,19 @@ export class SvmQuery implements QueryInterface {
|
|
|
83
84
|
priorityFeeMultiplier: BigNumber;
|
|
84
85
|
}> = {}
|
|
85
86
|
): Promise<TransactionCostEstimate> {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
const { destinationChainId, recipient, outputToken, exclusiveRelayer } = relayData;
|
|
88
|
+
assert(recipient.isSVM(), `getGasCosts: recipient not an SVM address (${recipient})`);
|
|
89
|
+
assert(outputToken.isSVM(), `getGasCosts: outputToken not an SVM address (${outputToken})`);
|
|
90
|
+
assert(exclusiveRelayer.isSVM(), `getGasCosts: exclusiveRelayer not an SVM address (${exclusiveRelayer})`);
|
|
91
|
+
assert(relayer.isSVM());
|
|
92
|
+
|
|
93
|
+
const [repaymentChainId, repaymentAddress] = [destinationChainId, relayer]; // These are not important for gas cost simulation.
|
|
94
|
+
const fillRelayTx = await this.getFillRelayTx(
|
|
95
|
+
{ ...relayData, recipient, outputToken, exclusiveRelayer },
|
|
96
|
+
relayer,
|
|
97
|
+
repaymentChainId,
|
|
98
|
+
repaymentAddress
|
|
99
|
+
);
|
|
90
100
|
|
|
91
101
|
const [computeUnitsConsumed, gasPriceEstimate] = await Promise.all([
|
|
92
102
|
toBN(await this.computeUnitEstimator(fillRelayTx)),
|
|
@@ -117,77 +127,82 @@ export class SvmQuery implements QueryInterface {
|
|
|
117
127
|
* @returns Estimated gas cost in compute units
|
|
118
128
|
*/
|
|
119
129
|
async getNativeGasCost(
|
|
120
|
-
deposit:
|
|
121
|
-
|
|
130
|
+
deposit: RelayData & { destinationChainId: number },
|
|
131
|
+
relayer = getDefaultRelayer(deposit.destinationChainId)
|
|
122
132
|
): Promise<BigNumber> {
|
|
123
|
-
const
|
|
133
|
+
const { destinationChainId, recipient, outputToken, exclusiveRelayer } = deposit;
|
|
134
|
+
assert(recipient.isSVM(), `getNativeGasCost: recipient not an SVM address (${recipient})`);
|
|
135
|
+
assert(outputToken.isSVM(), `getNativeGasCost: outputToken not an SVM address (${outputToken})`);
|
|
136
|
+
assert(exclusiveRelayer.isSVM(), `getNativeGasCost: exclusiveRelayer not an SVM address (${exclusiveRelayer})`);
|
|
137
|
+
assert(relayer.isSVM());
|
|
138
|
+
|
|
139
|
+
const [repaymentChainId, repaymentAddress] = [destinationChainId, relayer]; // These are not important for gas cost simulation.
|
|
140
|
+
const fillRelayTx = await this.getFillRelayTx(
|
|
141
|
+
{ ...deposit, recipient, outputToken, exclusiveRelayer },
|
|
142
|
+
relayer,
|
|
143
|
+
repaymentChainId,
|
|
144
|
+
repaymentAddress
|
|
145
|
+
);
|
|
124
146
|
return toBN(await this.computeUnitEstimator(fillRelayTx));
|
|
125
147
|
}
|
|
126
148
|
|
|
127
149
|
/**
|
|
128
150
|
* @notice Return the fillRelay transaction for a given deposit
|
|
129
|
-
* @param
|
|
151
|
+
* @param relayData RelayData instance, supplemented with destinationChainId
|
|
130
152
|
* @param relayer SVM address of the relayer
|
|
131
153
|
* @returns FillRelay transaction
|
|
132
154
|
*/
|
|
133
|
-
async getFillRelayTx(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
155
|
+
protected async getFillRelayTx(
|
|
156
|
+
relayData: Omit<RelayData, "recipent" | "outputToken"> & {
|
|
157
|
+
destinationChainId: number;
|
|
158
|
+
recipient: SvmAddress;
|
|
159
|
+
outputToken: SvmAddress;
|
|
160
|
+
},
|
|
161
|
+
relayer: SvmAddress,
|
|
162
|
+
repaymentChainId: number,
|
|
163
|
+
repaymentAddress: Address
|
|
138
164
|
) {
|
|
139
|
-
const
|
|
140
|
-
toAddress(toAddressType(address, chainId).forceSvmAddress());
|
|
165
|
+
const { depositor, recipient, inputToken, outputToken, exclusiveRelayer, destinationChainId } = relayData;
|
|
141
166
|
|
|
142
|
-
|
|
143
|
-
|
|
167
|
+
// tsc appeasement...should be unnecessary, but isn't. @todo Identify why.
|
|
168
|
+
assert(recipient.isSVM(), `getFillRelayTx: recipient not an SVM address (${recipient})`);
|
|
169
|
+
assert(
|
|
170
|
+
repaymentAddress.isValidOn(repaymentChainId),
|
|
171
|
+
`getFillRelayTx: repayment address ${repaymentAddress} not valid on chain ${repaymentChainId})`
|
|
172
|
+
);
|
|
144
173
|
|
|
145
174
|
const program = toAddress(this.spokePool);
|
|
146
|
-
const
|
|
147
|
-
? toAddressType(_relayer, deposit.destinationChainId).forceSvmAddress()
|
|
148
|
-
: this.simulatedRelayerAddress;
|
|
149
|
-
|
|
150
|
-
const _relayDataHash = getRelayDataHash(deposit, destinationChainId);
|
|
175
|
+
const _relayDataHash = getRelayDataHash(relayData, destinationChainId);
|
|
151
176
|
const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
|
|
152
177
|
|
|
153
178
|
const [state, delegate] = await Promise.all([
|
|
154
179
|
getStatePda(program),
|
|
155
|
-
getFillRelayDelegatePda(
|
|
156
|
-
relayDataHash,
|
|
157
|
-
BigInt(repaymentChainId),
|
|
158
|
-
toSvmAddress(repaymentAddress, repaymentChainId),
|
|
159
|
-
program
|
|
160
|
-
),
|
|
180
|
+
getFillRelayDelegatePda(relayDataHash, BigInt(repaymentChainId), toAddress(repaymentAddress), program),
|
|
161
181
|
]);
|
|
162
182
|
|
|
163
|
-
const
|
|
164
|
-
const mint = toAddress(_mint);
|
|
183
|
+
const mint = toAddress(outputToken);
|
|
165
184
|
const mintInfo = await fetchMint(this.provider, mint);
|
|
166
185
|
|
|
167
186
|
const [recipientAta, relayerAta, fillStatus, eventAuthority] = await Promise.all([
|
|
168
|
-
getAssociatedTokenAddress(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
),
|
|
173
|
-
getAssociatedTokenAddress(SvmAddress.from(relayer.toBase58()), _mint, mintInfo.programAddress),
|
|
174
|
-
getFillStatusPda(program, deposit, destinationChainId),
|
|
175
|
-
getEventAuthority(),
|
|
187
|
+
getAssociatedTokenAddress(recipient, outputToken, mintInfo.programAddress),
|
|
188
|
+
getAssociatedTokenAddress(SvmAddress.from(relayer.toBase58()), outputToken, mintInfo.programAddress),
|
|
189
|
+
getFillStatusPda(program, relayData, destinationChainId),
|
|
190
|
+
getEventAuthority(program),
|
|
176
191
|
]);
|
|
177
192
|
|
|
178
|
-
const
|
|
179
|
-
depositor:
|
|
180
|
-
recipient:
|
|
181
|
-
exclusiveRelayer:
|
|
182
|
-
inputToken:
|
|
193
|
+
const svmRelayData: SvmSpokeClient.FillRelayInput["relayData"] = {
|
|
194
|
+
depositor: toAddress(depositor),
|
|
195
|
+
recipient: toAddress(recipient),
|
|
196
|
+
exclusiveRelayer: toAddress(exclusiveRelayer),
|
|
197
|
+
inputToken: toAddress(inputToken),
|
|
183
198
|
outputToken: mint,
|
|
184
|
-
inputAmount:
|
|
185
|
-
outputAmount:
|
|
186
|
-
originChainId:
|
|
187
|
-
depositId: new Uint8Array(intToU8Array32(
|
|
188
|
-
fillDeadline:
|
|
189
|
-
exclusivityDeadline:
|
|
190
|
-
message: new Uint8Array(Buffer.from(
|
|
199
|
+
inputAmount: relayData.inputAmount.toBigInt(),
|
|
200
|
+
outputAmount: relayData.outputAmount.toBigInt(),
|
|
201
|
+
originChainId: relayData.originChainId,
|
|
202
|
+
depositId: new Uint8Array(intToU8Array32(relayData.depositId.toNumber())),
|
|
203
|
+
fillDeadline: relayData.fillDeadline,
|
|
204
|
+
exclusivityDeadline: relayData.exclusivityDeadline,
|
|
205
|
+
message: new Uint8Array(Buffer.from(relayData.message, "hex")),
|
|
191
206
|
};
|
|
192
207
|
|
|
193
208
|
const simulatedSigner = SolanaVoidSigner(relayer.toBase58());
|
|
@@ -205,9 +220,9 @@ export class SvmQuery implements QueryInterface {
|
|
|
205
220
|
eventAuthority,
|
|
206
221
|
program,
|
|
207
222
|
relayHash: relayDataHash,
|
|
208
|
-
relayData,
|
|
223
|
+
relayData: svmRelayData,
|
|
209
224
|
repaymentChainId: BigInt(repaymentChainId),
|
|
210
|
-
repaymentAddress:
|
|
225
|
+
repaymentAddress: toAddress(repaymentAddress),
|
|
211
226
|
};
|
|
212
227
|
// Pass createRecipientAtaIfNeeded =true to the createFillInstruction function to create the recipient token account
|
|
213
228
|
// if it doesn't exist.
|