@across-protocol/sdk 4.2.14-alpha.0 → 4.2.14
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 +2 -5
- package/dist/cjs/arch/evm/SpokeUtils.js +5 -22
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +11 -14
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +1 -1
- package/dist/cjs/arch/svm/utils.js +13 -15
- 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 +2 -4
- 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 +56 -60
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +13 -13
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +1 -2
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +2 -3
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +1 -5
- 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 +63 -63
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +8 -11
- 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 +59 -83
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +7 -3
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +77 -69
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +9 -15
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +3 -5
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +36 -39
- package/dist/cjs/clients/mocks/MockSpokePoolClient.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 +14 -19
- package/dist/cjs/interfaces/SpokePool.d.ts +23 -13
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +7 -7
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +15 -14
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +7 -7
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +3 -6
- package/dist/cjs/utils/AddressUtils.js +14 -42
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +3 -3
- package/dist/cjs/utils/SpokeUtils.js +22 -4
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +4 -4
- package/dist/cjs/utils/TokenUtils.js +3 -3
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +2 -5
- package/dist/esm/arch/evm/SpokeUtils.js +6 -23
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js +12 -15
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +1 -1
- package/dist/esm/arch/svm/utils.js +13 -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 +2 -4
- 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 +57 -61
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +14 -14
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +1 -2
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +3 -4
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +1 -5
- 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 +63 -63
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +9 -12
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +22 -23
- package/dist/esm/clients/HubPoolClient.js +63 -96
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +15 -3
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +86 -71
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/esm/clients/mocks/MockHubPoolClient.js +10 -16
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +3 -5
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +38 -41
- package/dist/esm/clients/mocks/MockSpokePoolClient.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 +14 -19
- package/dist/esm/interfaces/SpokePool.d.ts +23 -13
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +8 -8
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +16 -15
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +8 -8
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +3 -7
- package/dist/esm/utils/AddressUtils.js +19 -52
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +8 -3
- package/dist/esm/utils/SpokeUtils.js +26 -4
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +16 -18
- package/dist/esm/utils/TokenUtils.js +3 -3
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +2 -5
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +1 -1
- 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 +1 -2
- 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 +63 -63
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +22 -23
- 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/SpokePoolClient.d.ts +15 -3
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.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 +3 -5
- package/dist/types/clients/mocks/MockSpokePoolClient.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 +14 -19
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +23 -13
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +3 -7
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +8 -3
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +16 -18
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/arch/evm/SpokeUtils.ts +11 -53
- package/src/arch/svm/SpokeUtils.ts +11 -44
- package/src/arch/svm/utils.ts +3 -3
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +4 -7
- package/src/clients/BundleDataClient/BundleDataClient.ts +52 -54
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +13 -28
- package/src/clients/BundleDataClient/utils/FillUtils.ts +4 -6
- package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +1 -7
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +9 -13
- package/src/clients/HubPoolClient.ts +82 -122
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +0 -6
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +66 -107
- package/src/clients/mocks/MockHubPoolClient.ts +19 -24
- package/src/clients/mocks/MockSpokePoolClient.ts +26 -37
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +3 -12
- package/src/interfaces/HubPool.ts +14 -23
- package/src/interfaces/SpokePool.ts +25 -13
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +8 -10
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +21 -16
- package/src/relayFeeCalculator/relayFeeCalculator.ts +12 -20
- package/src/utils/AddressUtils.ts +21 -56
- package/src/utils/SpokeUtils.ts +33 -11
- package/src/utils/TokenUtils.ts +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BigNumber } 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: string[];
|
|
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: string;
|
|
20
|
+
refundAddresses: string[];
|
|
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: string;
|
|
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: string[];
|
|
59
59
|
proof: string[];
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -76,14 +76,8 @@ export interface RelayerRefundLeafWithGroup extends RelayerRefundLeaf {
|
|
|
76
76
|
groupIndex: number;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export interface
|
|
80
|
-
address:
|
|
81
|
-
symbol: string;
|
|
82
|
-
decimals: number;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface TokenInfo {
|
|
86
|
-
address: Address;
|
|
79
|
+
export interface L1Token {
|
|
80
|
+
address: string;
|
|
87
81
|
symbol: string;
|
|
88
82
|
decimals: number;
|
|
89
83
|
}
|
|
@@ -93,30 +87,27 @@ export interface LpToken {
|
|
|
93
87
|
liquidReserves: BigNumber;
|
|
94
88
|
}
|
|
95
89
|
|
|
96
|
-
// TODO: I think I don't change string -> Address in the Events. I change right after the event is read
|
|
97
90
|
export interface CrossChainContractsSet extends SortableEvent {
|
|
98
91
|
l2ChainId: number;
|
|
99
|
-
spokePool:
|
|
92
|
+
spokePool: string;
|
|
100
93
|
}
|
|
101
94
|
|
|
102
|
-
// TODO: I think I don't change string -> Address in the Events. I change right after the event is read
|
|
103
95
|
export interface DestinationTokenWithBlock extends SortableEvent {
|
|
104
|
-
l2Token:
|
|
105
|
-
l1Token:
|
|
96
|
+
l2Token: string;
|
|
97
|
+
l1Token: string;
|
|
106
98
|
}
|
|
107
99
|
|
|
108
|
-
// TODO: I think I don't change string -> Address in the Events. I change right after the event is read
|
|
109
100
|
export interface SetPoolRebalanceRoot extends SortableEvent {
|
|
110
101
|
destinationChainId: number;
|
|
111
|
-
l1Token:
|
|
112
|
-
destinationToken:
|
|
102
|
+
l1Token: string;
|
|
103
|
+
destinationToken: string;
|
|
113
104
|
}
|
|
114
105
|
|
|
115
106
|
export interface PendingRootBundle {
|
|
116
107
|
poolRebalanceRoot: string;
|
|
117
108
|
relayerRefundRoot: string;
|
|
118
109
|
slowRelayRoot: string;
|
|
119
|
-
proposer:
|
|
110
|
+
proposer: string;
|
|
120
111
|
unclaimedPoolRebalanceLeafCount: number;
|
|
121
112
|
challengePeriodEndTimestamp: number;
|
|
122
113
|
bundleEvaluationBlockNumbers: number[];
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { SortableEvent } from "./Common";
|
|
2
2
|
import { SpokePoolClient } from "../clients";
|
|
3
|
-
import { BigNumber
|
|
3
|
+
import { BigNumber } 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: string;
|
|
9
|
+
recipient: string;
|
|
10
10
|
depositId: BigNumber;
|
|
11
|
-
inputToken:
|
|
11
|
+
inputToken: string;
|
|
12
12
|
inputAmount: BigNumber;
|
|
13
|
-
outputToken:
|
|
13
|
+
outputToken: string;
|
|
14
14
|
outputAmount: BigNumber;
|
|
15
15
|
message: string;
|
|
16
16
|
fillDeadline: number;
|
|
17
|
-
exclusiveRelayer:
|
|
17
|
+
exclusiveRelayer: string;
|
|
18
18
|
exclusivityDeadline: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -23,7 +23,7 @@ export interface Deposit extends RelayData {
|
|
|
23
23
|
destinationChainId: number;
|
|
24
24
|
quoteTimestamp: number;
|
|
25
25
|
speedUpSignature?: string;
|
|
26
|
-
updatedRecipient?:
|
|
26
|
+
updatedRecipient?: string;
|
|
27
27
|
updatedOutputAmount?: BigNumber;
|
|
28
28
|
updatedMessage?: string;
|
|
29
29
|
fromLiteChain: boolean;
|
|
@@ -51,7 +51,7 @@ export enum FillType {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export interface RelayExecutionEventInfo {
|
|
54
|
-
updatedRecipient:
|
|
54
|
+
updatedRecipient: string;
|
|
55
55
|
updatedOutputAmount: BigNumber;
|
|
56
56
|
updatedMessage?: string;
|
|
57
57
|
updatedMessageHash: string;
|
|
@@ -61,7 +61,7 @@ export interface RelayExecutionEventInfo {
|
|
|
61
61
|
export interface Fill extends Omit<RelayData, "message"> {
|
|
62
62
|
messageHash: string;
|
|
63
63
|
destinationChainId: number;
|
|
64
|
-
relayer:
|
|
64
|
+
relayer: string;
|
|
65
65
|
repaymentChainId: number;
|
|
66
66
|
relayExecutionInfo: RelayExecutionEventInfo;
|
|
67
67
|
}
|
|
@@ -72,18 +72,18 @@ export interface FillWithTime extends Fill, SortableEvent {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export interface EnabledDepositRoute {
|
|
75
|
-
originToken:
|
|
75
|
+
originToken: string;
|
|
76
76
|
destinationChainId: number;
|
|
77
77
|
enabled: boolean;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export interface EnabledDepositRouteWithBlock extends EnabledDepositRoute, SortableEvent {}
|
|
81
81
|
export interface SpeedUp {
|
|
82
|
-
depositor:
|
|
82
|
+
depositor: string;
|
|
83
83
|
depositorSignature: string;
|
|
84
84
|
depositId: BigNumber;
|
|
85
85
|
originChainId: number;
|
|
86
|
-
updatedRecipient:
|
|
86
|
+
updatedRecipient: string;
|
|
87
87
|
updatedOutputAmount: BigNumber;
|
|
88
88
|
updatedMessage: string;
|
|
89
89
|
}
|
|
@@ -130,7 +130,19 @@ export interface TokensBridged extends SortableEvent {
|
|
|
130
130
|
amountToReturn: BigNumber;
|
|
131
131
|
chainId: number;
|
|
132
132
|
leafId: number;
|
|
133
|
-
l2TokenAddress:
|
|
133
|
+
l2TokenAddress: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface ClaimedRelayerRefundWithBlock extends SortableEvent {
|
|
137
|
+
l2TokenAddress: string;
|
|
138
|
+
refundAddress: string;
|
|
139
|
+
amount: BigNumber;
|
|
140
|
+
caller?: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface BridgedToHubPoolWithBlock extends SortableEvent {
|
|
144
|
+
amount: BigNumber;
|
|
145
|
+
mint: string;
|
|
134
146
|
}
|
|
135
147
|
|
|
136
148
|
export interface SpokePoolClientsByChain {
|
|
@@ -15,8 +15,6 @@ import {
|
|
|
15
15
|
bnZero,
|
|
16
16
|
chainIsOPStack,
|
|
17
17
|
fixedPointAdjustment,
|
|
18
|
-
toAddressType,
|
|
19
|
-
Address,
|
|
20
18
|
} from "../../utils";
|
|
21
19
|
import assert from "assert";
|
|
22
20
|
import { Logger, QueryInterface, getDefaultSimulatedRelayerAddress } from "../relayFeeCalculator";
|
|
@@ -74,7 +72,7 @@ export class QueryBase implements QueryInterface {
|
|
|
74
72
|
*/
|
|
75
73
|
async getGasCosts(
|
|
76
74
|
deposit: Omit<Deposit, "messageHash">,
|
|
77
|
-
relayer =
|
|
75
|
+
relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
78
76
|
options: Partial<{
|
|
79
77
|
gasPrice: BigNumberish;
|
|
80
78
|
gasUnits: BigNumberish;
|
|
@@ -124,7 +122,7 @@ export class QueryBase implements QueryInterface {
|
|
|
124
122
|
*/
|
|
125
123
|
getUnsignedTxFromDeposit(
|
|
126
124
|
deposit: Omit<Deposit, "messageHash">,
|
|
127
|
-
relayer =
|
|
125
|
+
relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
|
|
128
126
|
): Promise<PopulatedTransaction> {
|
|
129
127
|
return populateV3Relay(this.spokePool, deposit, relayer);
|
|
130
128
|
}
|
|
@@ -137,10 +135,10 @@ export class QueryBase implements QueryInterface {
|
|
|
137
135
|
*/
|
|
138
136
|
async getNativeGasCost(
|
|
139
137
|
deposit: Omit<Deposit, "messageHash">,
|
|
140
|
-
relayer =
|
|
138
|
+
relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
|
|
141
139
|
): Promise<BigNumber> {
|
|
142
140
|
const unsignedTx = await this.getUnsignedTxFromDeposit(deposit, relayer);
|
|
143
|
-
const voidSigner = new VoidSigner(relayer
|
|
141
|
+
const voidSigner = new VoidSigner(relayer, this.provider);
|
|
144
142
|
return voidSigner.estimateGas(unsignedTx);
|
|
145
143
|
}
|
|
146
144
|
|
|
@@ -154,7 +152,7 @@ export class QueryBase implements QueryInterface {
|
|
|
154
152
|
*/
|
|
155
153
|
async getOpStackL1DataFee(
|
|
156
154
|
unsignedTx: PopulatedTransaction,
|
|
157
|
-
relayer =
|
|
155
|
+
relayer = getDefaultSimulatedRelayerAddress(unsignedTx.chainId),
|
|
158
156
|
options: Partial<{
|
|
159
157
|
opStackL2GasUnits: BigNumberish;
|
|
160
158
|
opStackL1DataFeeMultiplier: BigNumber;
|
|
@@ -163,7 +161,7 @@ export class QueryBase implements QueryInterface {
|
|
|
163
161
|
const { opStackL2GasUnits, opStackL1DataFeeMultiplier = toBNWei("1") } = options || {};
|
|
164
162
|
const { chainId } = await this.provider.getNetwork();
|
|
165
163
|
assert(isOptimismL2Provider(this.provider), `Unexpected provider for chain ID ${chainId}.`);
|
|
166
|
-
const voidSigner = new VoidSigner(relayer
|
|
164
|
+
const voidSigner = new VoidSigner(relayer, this.provider);
|
|
167
165
|
const populatedTransaction = await voidSigner.populateTransaction({
|
|
168
166
|
...unsignedTx,
|
|
169
167
|
gasLimit: opStackL2GasUnits, // prevents additional gas estimation call
|
|
@@ -185,7 +183,7 @@ export class QueryBase implements QueryInterface {
|
|
|
185
183
|
*/
|
|
186
184
|
async estimateGas(
|
|
187
185
|
unsignedTx: PopulatedTransaction,
|
|
188
|
-
senderAddress:
|
|
186
|
+
senderAddress: string,
|
|
189
187
|
provider: providers.Provider | L2Provider<providers.Provider>,
|
|
190
188
|
options: Partial<{
|
|
191
189
|
gasPrice: BigNumberish;
|
|
@@ -206,7 +204,7 @@ export class QueryBase implements QueryInterface {
|
|
|
206
204
|
} = options || {};
|
|
207
205
|
|
|
208
206
|
const { chainId } = await provider.getNetwork();
|
|
209
|
-
const voidSigner = new VoidSigner(senderAddress
|
|
207
|
+
const voidSigner = new VoidSigner(senderAddress, provider);
|
|
210
208
|
|
|
211
209
|
// Estimate the Gas units required to submit this transaction.
|
|
212
210
|
const queries = [
|
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
getRelayDataHash,
|
|
26
26
|
toAddressType,
|
|
27
27
|
toBN,
|
|
28
|
-
Address,
|
|
29
28
|
} from "../../utils";
|
|
30
29
|
import { Logger, QueryInterface, getDefaultSimulatedRelayerAddress } from "../relayFeeCalculator";
|
|
31
30
|
import { SymbolMappingType } from "./";
|
|
@@ -75,7 +74,7 @@ export class SvmQuery implements QueryInterface {
|
|
|
75
74
|
*/
|
|
76
75
|
async getGasCosts(
|
|
77
76
|
deposit: Omit<Deposit, "messageHash">,
|
|
78
|
-
_relayer =
|
|
77
|
+
_relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
79
78
|
options: Partial<{
|
|
80
79
|
gasPrice: BigNumberish;
|
|
81
80
|
gasUnits: BigNumberish;
|
|
@@ -83,8 +82,8 @@ export class SvmQuery implements QueryInterface {
|
|
|
83
82
|
priorityFeeMultiplier: BigNumber;
|
|
84
83
|
}> = {}
|
|
85
84
|
): Promise<TransactionCostEstimate> {
|
|
86
|
-
const relayer = _relayer ? _relayer.forceSvmAddress() : this.simulatedRelayerAddress;
|
|
87
|
-
const fillRelayTx = await this.getFillRelayTx(deposit, relayer);
|
|
85
|
+
const relayer = _relayer ? toAddressType(_relayer).forceSvmAddress() : this.simulatedRelayerAddress;
|
|
86
|
+
const fillRelayTx = await this.getFillRelayTx(deposit, relayer.toBase58());
|
|
88
87
|
|
|
89
88
|
const [computeUnitsConsumed, _gasPriceEstimate] = await Promise.all([
|
|
90
89
|
toBN(await this.computeUnitEstimator(fillRelayTx)),
|
|
@@ -117,7 +116,7 @@ export class SvmQuery implements QueryInterface {
|
|
|
117
116
|
*/
|
|
118
117
|
async getNativeGasCost(
|
|
119
118
|
deposit: Omit<Deposit, "messageHash">,
|
|
120
|
-
_relayer =
|
|
119
|
+
_relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
|
|
121
120
|
): Promise<BigNumber> {
|
|
122
121
|
const fillRelayTx = await this.getFillRelayTx(deposit, _relayer);
|
|
123
122
|
return toBN(await this.computeUnitEstimator(fillRelayTx));
|
|
@@ -131,29 +130,35 @@ export class SvmQuery implements QueryInterface {
|
|
|
131
130
|
*/
|
|
132
131
|
async getFillRelayTx(
|
|
133
132
|
deposit: Omit<Deposit, "messageHash">,
|
|
134
|
-
|
|
133
|
+
_relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
135
134
|
repaymentChainId = deposit.destinationChainId,
|
|
136
|
-
repaymentAddress =
|
|
137
|
-
getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
138
|
-
deposit.destinationChainId
|
|
139
|
-
)
|
|
135
|
+
repaymentAddress = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
|
|
140
136
|
) {
|
|
141
|
-
const toSvmAddress = (address:
|
|
137
|
+
const toSvmAddress = (address: string) => toAddressType(address).forceSvmAddress().toV2Address();
|
|
138
|
+
const relayer = _relayer ? toAddressType(_relayer).forceSvmAddress() : this.simulatedRelayerAddress;
|
|
142
139
|
const state = await getStatePda(this.spokePoolAddress.toV2Address());
|
|
143
140
|
const _relayDataHash = getRelayDataHash(deposit, deposit.destinationChainId);
|
|
144
141
|
const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
|
|
145
142
|
const delegate = await getFillRelayDelegatePda(
|
|
146
143
|
relayDataHash,
|
|
147
144
|
BigInt(repaymentChainId),
|
|
148
|
-
repaymentAddress
|
|
145
|
+
toSvmAddress(repaymentAddress),
|
|
149
146
|
this.spokePoolAddress.toV2Address()
|
|
150
147
|
);
|
|
151
|
-
const mint = deposit.outputToken;
|
|
148
|
+
const mint = toAddressType(deposit.outputToken).forceSvmAddress();
|
|
152
149
|
const mintInfo = await fetchMint(this.provider, mint.toV2Address());
|
|
153
|
-
const recipientAta = await getAssociatedTokenAddress(
|
|
154
|
-
|
|
150
|
+
const recipientAta = await getAssociatedTokenAddress(
|
|
151
|
+
toAddressType(deposit.recipient).forceSvmAddress(),
|
|
152
|
+
mint,
|
|
153
|
+
mintInfo.programAddress
|
|
154
|
+
);
|
|
155
|
+
const relayerAta = await getAssociatedTokenAddress(
|
|
156
|
+
SvmAddress.from(relayer.toBase58()),
|
|
157
|
+
mint,
|
|
158
|
+
mintInfo.programAddress
|
|
159
|
+
);
|
|
155
160
|
const fillStatus = await getFillStatusPda(this.spokePoolAddress.toV2Address(), deposit, deposit.destinationChainId);
|
|
156
|
-
const eventAuthority = await getEventAuthority(
|
|
161
|
+
const eventAuthority = await getEventAuthority();
|
|
157
162
|
|
|
158
163
|
const relayData: SvmSpokeClient.FillRelayInput["relayData"] = {
|
|
159
164
|
depositor: toSvmAddress(deposit.depositor),
|
|
@@ -9,9 +9,12 @@ import { Deposit } from "../interfaces";
|
|
|
9
9
|
import {
|
|
10
10
|
BigNumber,
|
|
11
11
|
BigNumberish,
|
|
12
|
+
ConvertDecimals,
|
|
12
13
|
MAX_BIG_INT,
|
|
13
14
|
TransactionCostEstimate,
|
|
14
15
|
bnZero,
|
|
16
|
+
chainIsSvm,
|
|
17
|
+
compareAddressesSimple,
|
|
15
18
|
fixedPointAdjustment,
|
|
16
19
|
getTokenInfo,
|
|
17
20
|
isDefined,
|
|
@@ -22,18 +25,13 @@ import {
|
|
|
22
25
|
percent,
|
|
23
26
|
toBN,
|
|
24
27
|
toBNWei,
|
|
25
|
-
compareAddressesSimple,
|
|
26
|
-
ConvertDecimals,
|
|
27
|
-
chainIsSvm,
|
|
28
|
-
toAddressType,
|
|
29
|
-
Address,
|
|
30
28
|
} from "../utils";
|
|
31
29
|
|
|
32
30
|
// This needs to be implemented for every chain and passed into RelayFeeCalculator
|
|
33
31
|
export interface QueryInterface {
|
|
34
32
|
getGasCosts: (
|
|
35
33
|
deposit: Omit<Deposit, "messageHash">,
|
|
36
|
-
relayer:
|
|
34
|
+
relayer: string,
|
|
37
35
|
options?: Partial<{
|
|
38
36
|
gasPrice: BigNumberish;
|
|
39
37
|
gasUnits: BigNumberish;
|
|
@@ -44,7 +42,7 @@ export interface QueryInterface {
|
|
|
44
42
|
}>
|
|
45
43
|
) => Promise<TransactionCostEstimate>;
|
|
46
44
|
getTokenPrice: (tokenSymbol: string) => Promise<number>;
|
|
47
|
-
getNativeGasCost: (deposit: Omit<Deposit, "messageHash">, relayer:
|
|
45
|
+
getNativeGasCost: (deposit: Omit<Deposit, "messageHash">, relayer: string) => Promise<BigNumber>;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
export const expectedCapitalCostsKeys = ["lowerBound", "upperBound", "cutoff", "decimals"];
|
|
@@ -256,10 +254,7 @@ export class RelayFeeCalculator {
|
|
|
256
254
|
deposit: Deposit,
|
|
257
255
|
outputAmount: BigNumberish,
|
|
258
256
|
simulateZeroFill = false,
|
|
259
|
-
relayerAddress =
|
|
260
|
-
getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
261
|
-
deposit.destinationChainId
|
|
262
|
-
),
|
|
257
|
+
relayerAddress = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
263
258
|
_tokenPrice?: number,
|
|
264
259
|
tokenMapping = TOKEN_SYMBOLS_MAP,
|
|
265
260
|
gasPrice?: BigNumberish,
|
|
@@ -276,14 +271,14 @@ export class RelayFeeCalculator {
|
|
|
276
271
|
// undefined address on destination.
|
|
277
272
|
const destinationChainTokenDetails = Object.values(tokenMapping).find(
|
|
278
273
|
(details) =>
|
|
279
|
-
compareAddressesSimple(details.addresses[originChainId], inputToken
|
|
274
|
+
compareAddressesSimple(details.addresses[originChainId], inputToken) &&
|
|
280
275
|
isDefined(details.addresses[destinationChainId])
|
|
281
276
|
);
|
|
282
277
|
const outputToken = isZeroAddress(deposit.outputToken)
|
|
283
278
|
? destinationChainTokenDetails!.addresses[destinationChainId]
|
|
284
|
-
: deposit.outputToken
|
|
279
|
+
: deposit.outputToken;
|
|
285
280
|
const outputTokenInfo = getTokenInfo(outputToken, destinationChainId, tokenMapping);
|
|
286
|
-
const inputTokenInfo = getTokenInfo(inputToken
|
|
281
|
+
const inputTokenInfo = getTokenInfo(inputToken, originChainId, tokenMapping);
|
|
287
282
|
if (!isDefined(outputTokenInfo) || !isDefined(inputTokenInfo)) {
|
|
288
283
|
throw new Error(`Could not find token information for ${inputToken} or ${outputToken}`);
|
|
289
284
|
}
|
|
@@ -498,10 +493,7 @@ export class RelayFeeCalculator {
|
|
|
498
493
|
deposit: Deposit,
|
|
499
494
|
outputAmount?: BigNumberish,
|
|
500
495
|
simulateZeroFill = false,
|
|
501
|
-
relayerAddress =
|
|
502
|
-
getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
503
|
-
deposit.destinationChainId
|
|
504
|
-
),
|
|
496
|
+
relayerAddress = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
505
497
|
_tokenPrice?: number,
|
|
506
498
|
gasPrice?: BigNumberish,
|
|
507
499
|
gasUnits?: BigNumberish,
|
|
@@ -513,8 +505,8 @@ export class RelayFeeCalculator {
|
|
|
513
505
|
const { inputToken, originChainId, outputToken, destinationChainId } = deposit;
|
|
514
506
|
// We can perform a simple lookup with `getTokenInfo` here without resolving the exact token to resolve since we only need to
|
|
515
507
|
// resolve the L1 token symbol and not the L2 token decimals.
|
|
516
|
-
const inputTokenInfo = getTokenInfo(inputToken
|
|
517
|
-
const outputTokenInfo = getTokenInfo(outputToken
|
|
508
|
+
const inputTokenInfo = getTokenInfo(inputToken, originChainId);
|
|
509
|
+
const outputTokenInfo = getTokenInfo(outputToken, destinationChainId);
|
|
518
510
|
if (!isDefined(inputTokenInfo) || !isDefined(outputTokenInfo)) {
|
|
519
511
|
throw new Error(`Could not find token information for ${inputToken} or ${outputToken}`);
|
|
520
512
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { providers, utils } from "ethers";
|
|
2
|
-
import assert from "assert";
|
|
3
2
|
import bs58 from "bs58";
|
|
4
3
|
import { Address as V2Address } from "@solana/kit";
|
|
5
|
-
import { BigNumber, chainIsEvm
|
|
4
|
+
import { BigNumber, chainIsEvm } from "./";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Checks if a contract is deployed at the given address
|
|
@@ -76,39 +75,20 @@ export function isValidEvmAddress(address: string): boolean {
|
|
|
76
75
|
* Creates the proper address type given the input chain ID corresponding to the address's origin network.
|
|
77
76
|
* @param address Stringified address type to convert. Can be either hex encoded or base58 encoded.
|
|
78
77
|
* @param chainId Network ID corresponding to the input address, used to determine which address type to output.
|
|
79
|
-
* If no chain ID is specified, then fallback to inference via the structure of the address string.
|
|
80
78
|
* @returns a child `Address` type most fitting for the chain ID.
|
|
81
79
|
* @todo: Change this to `toAddress` once we remove the other `toAddress` function.
|
|
82
80
|
*/
|
|
83
|
-
export function toAddressType(address: string
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return EvmAddress.from(address);
|
|
88
|
-
}
|
|
89
|
-
return SvmAddress.from(address);
|
|
90
|
-
} catch (e) {
|
|
91
|
-
// If we hit this block, then the validation for one of the child address classes failed. We still may want to keep this address in our state, so
|
|
92
|
-
// return an unchecked address type.
|
|
93
|
-
assert(utils.isHexString(address));
|
|
94
|
-
assert(utils.hexDataLength(address) === 32);
|
|
95
|
-
return Address.__unsafeConstruct(utils.arrayify(address));
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
// If there is no network ID, then infer the address by the string format.
|
|
99
|
-
const addressType = parseAddress(address);
|
|
100
|
-
if (!isDefined(chainId)) {
|
|
101
|
-
return addressType;
|
|
102
|
-
}
|
|
103
|
-
// Wrap this in a try/catch in case we are trying to force an invalid EVM address to an EvmAddress type.
|
|
104
|
-
if (chainIsEvm(chainId)) {
|
|
105
|
-
try {
|
|
106
|
-
return addressType.forceEvmAddress();
|
|
107
|
-
} catch {
|
|
108
|
-
return addressType;
|
|
81
|
+
export function toAddressType(address: string): Address | EvmAddress | SvmAddress {
|
|
82
|
+
try {
|
|
83
|
+
if (utils.isHexString(address)) {
|
|
84
|
+
return EvmAddress.from(address);
|
|
109
85
|
}
|
|
86
|
+
return SvmAddress.from(address);
|
|
87
|
+
} catch (e) {
|
|
88
|
+
// If we hit this block, then the validation for one of the child address classes failed. We still may want to keep this address in our state, so
|
|
89
|
+
// return an unchecked address type.
|
|
90
|
+
return new Address(utils.arrayify(address));
|
|
110
91
|
}
|
|
111
|
-
return addressType.forceSvmAddress();
|
|
112
92
|
}
|
|
113
93
|
|
|
114
94
|
// The Address class can contain any address type. It is up to the subclasses to determine how to format the address's internal representation,
|
|
@@ -133,24 +113,12 @@ export class Address {
|
|
|
133
113
|
this.rawAddress = utils.zeroPad(_rawAddress, 32);
|
|
134
114
|
}
|
|
135
115
|
|
|
136
|
-
static __unsafeConstruct(_rawAddress: Uint8Array): Address {
|
|
137
|
-
return new this(_rawAddress);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
116
|
// Converts the address into a bytes32 string. Note that the output bytes will be lowercase so that it matches ethers event data. This function will never
|
|
141
117
|
// throw since address length validation was done at construction time.
|
|
142
118
|
toBytes32(): string {
|
|
143
119
|
return (this.bytes32Address ??= utils.hexZeroPad(utils.hexlify(this.rawAddress), 32).toLowerCase());
|
|
144
120
|
}
|
|
145
121
|
|
|
146
|
-
// Returns last 20 bytes of Address as a hex string. Truncates if necessary. This function is useful for comparing some longer addresses(e.g. Solana) to Solidity events
|
|
147
|
-
// that contain truncated `address` type as one of the fields
|
|
148
|
-
truncateToBytes20(): string {
|
|
149
|
-
// Take the last 20 bytes
|
|
150
|
-
const bytes20 = this.rawAddress.slice(-20);
|
|
151
|
-
return toAddress(utils.hexlify(bytes20));
|
|
152
|
-
}
|
|
153
|
-
|
|
154
122
|
// Converts the address (can be bytes32 or bytes20) to its base58 counterpart. This conversion will always succeed, even if the input address is not valid on Solana,
|
|
155
123
|
// as this address may be needed to represent an EVM address on Solana.
|
|
156
124
|
toBase58(): string {
|
|
@@ -192,7 +160,7 @@ export class Address {
|
|
|
192
160
|
// Checks if this address can be coerced into a bytes20 evm address. Returns true if it is possible and false otherwise.
|
|
193
161
|
isValidEvmAddress(): boolean {
|
|
194
162
|
try {
|
|
195
|
-
this.
|
|
163
|
+
this.toAddress();
|
|
196
164
|
return true;
|
|
197
165
|
} catch {
|
|
198
166
|
return false;
|
|
@@ -223,11 +191,6 @@ export class Address {
|
|
|
223
191
|
return utils.stripZeros(this.rawAddress).length === 0;
|
|
224
192
|
}
|
|
225
193
|
|
|
226
|
-
// Small utility to convert an Address to a Solana Kit branded type.
|
|
227
|
-
toV2Address(): V2Address<string> {
|
|
228
|
-
return this.toBase58() as V2Address<string>;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
194
|
// Forces `rawAddress` to become an SvmAddress type. This will only throw if `rawAddress.length > 32`.
|
|
232
195
|
forceSvmAddress(): SvmAddress {
|
|
233
196
|
return SvmAddress.from(this.toBase58());
|
|
@@ -257,14 +220,6 @@ export class Address {
|
|
|
257
220
|
return 0;
|
|
258
221
|
}
|
|
259
222
|
}
|
|
260
|
-
|
|
261
|
-
static isEvmAddress(address: Address): boolean {
|
|
262
|
-
return address instanceof EvmAddress;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
static isSvmAddress(address: Address): boolean {
|
|
266
|
-
return address instanceof SvmAddress;
|
|
267
|
-
}
|
|
268
223
|
}
|
|
269
224
|
|
|
270
225
|
// Subclass of address which strictly deals with 20-byte addresses. These addresses are guaranteed to be valid EVM addresses, so `toAddress` will always succeed.
|
|
@@ -314,6 +269,16 @@ export class SvmAddress extends Address {
|
|
|
314
269
|
return this.toBase58();
|
|
315
270
|
}
|
|
316
271
|
|
|
272
|
+
// Small utility to convert an SvmAddress to a Solana Kit branded type.
|
|
273
|
+
toV2Address(): V2Address<string> {
|
|
274
|
+
return this.toBase58() as V2Address<string>;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Forces an SvmAddress to an EVM address string by truncating the leading 12 bytes.
|
|
278
|
+
override toEvmAddress(): string {
|
|
279
|
+
return toAddress(`0x${this.toBytes32().slice(-40)}`);
|
|
280
|
+
}
|
|
281
|
+
|
|
317
282
|
// Constructs a new SvmAddress type.
|
|
318
283
|
static from(address: string, encoding: "base58" | "base16" = "base58"): SvmAddress {
|
|
319
284
|
if (encoding === "base58") {
|
package/src/utils/SpokeUtils.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { encodeAbiParameters, Hex, keccak256 } from "viem";
|
|
2
2
|
import { fixedPointAdjustment as fixedPoint } from "./common";
|
|
3
|
-
import { MAX_SAFE_DEPOSIT_ID, ZERO_BYTES } from "../constants";
|
|
4
|
-
import { Fill, FillType, RelayData, SlowFillLeaf } from "../interfaces";
|
|
3
|
+
import { MAX_SAFE_DEPOSIT_ID, ZERO_ADDRESS, ZERO_BYTES } from "../constants";
|
|
4
|
+
import { Deposit, Fill, FillType, RelayData, SlowFillLeaf } from "../interfaces";
|
|
5
|
+
import { toBytes32 } from "./AddressUtils";
|
|
5
6
|
import { BigNumber } from "./BigNumberUtils";
|
|
6
|
-
import { Address } from "./AddressUtils";
|
|
7
7
|
import { isMessageEmpty } from "./DepositUtils";
|
|
8
8
|
import { chainIsSvm } from "./NetworkUtils";
|
|
9
9
|
import { svm } from "../arch";
|
|
@@ -16,6 +16,28 @@ export function getSlowFillLeafLpFeePct(leaf: SlowFillLeaf): BigNumber {
|
|
|
16
16
|
const { relayData, updatedOutputAmount } = leaf;
|
|
17
17
|
return relayData.inputAmount.sub(updatedOutputAmount).mul(fixedPoint).div(relayData.inputAmount);
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Produce the RelayData for a Deposit.
|
|
21
|
+
* @param deposit Deposit instance.
|
|
22
|
+
* @returns The corresponding RelayData object.
|
|
23
|
+
*/
|
|
24
|
+
export function getDepositRelayData(deposit: Omit<Deposit, "messageHash">): RelayData {
|
|
25
|
+
return {
|
|
26
|
+
depositor: toBytes32(deposit.depositor),
|
|
27
|
+
recipient: toBytes32(deposit.recipient),
|
|
28
|
+
exclusiveRelayer: toBytes32(deposit.exclusiveRelayer),
|
|
29
|
+
inputToken: toBytes32(deposit.inputToken),
|
|
30
|
+
outputToken: toBytes32(deposit.outputToken),
|
|
31
|
+
inputAmount: deposit.inputAmount,
|
|
32
|
+
outputAmount: deposit.outputAmount,
|
|
33
|
+
originChainId: deposit.originChainId,
|
|
34
|
+
depositId: deposit.depositId,
|
|
35
|
+
fillDeadline: deposit.fillDeadline,
|
|
36
|
+
exclusivityDeadline: deposit.exclusivityDeadline,
|
|
37
|
+
message: deposit.message,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
19
41
|
/**
|
|
20
42
|
* Compute the RelayData hash for a fill. This can be used to determine the fill status.
|
|
21
43
|
* @param relayData RelayData information that is used to complete a fill.
|
|
@@ -46,14 +68,14 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe
|
|
|
46
68
|
|
|
47
69
|
const _relayData = {
|
|
48
70
|
...relayData,
|
|
49
|
-
depositor: relayData.depositor
|
|
50
|
-
recipient: relayData.recipient
|
|
51
|
-
inputToken: relayData.inputToken
|
|
52
|
-
outputToken: relayData.outputToken
|
|
53
|
-
exclusiveRelayer: relayData.exclusiveRelayer
|
|
71
|
+
depositor: toBytes32(relayData.depositor),
|
|
72
|
+
recipient: toBytes32(relayData.recipient),
|
|
73
|
+
inputToken: toBytes32(relayData.inputToken),
|
|
74
|
+
outputToken: toBytes32(relayData.outputToken),
|
|
75
|
+
exclusiveRelayer: toBytes32(relayData.exclusiveRelayer),
|
|
54
76
|
};
|
|
55
77
|
if (chainIsSvm(destinationChainId)) {
|
|
56
|
-
return svm.getRelayDataHash(
|
|
78
|
+
return svm.getRelayDataHash(_relayData, destinationChainId);
|
|
57
79
|
}
|
|
58
80
|
return keccak256(encodeAbiParameters(abi, [_relayData, destinationChainId]));
|
|
59
81
|
}
|
|
@@ -73,8 +95,8 @@ export function isUnsafeDepositId(depositId: BigNumber): boolean {
|
|
|
73
95
|
}
|
|
74
96
|
|
|
75
97
|
// Determines if the input address (either a bytes32 or bytes20) is the zero address.
|
|
76
|
-
export function isZeroAddress(address:
|
|
77
|
-
return address
|
|
98
|
+
export function isZeroAddress(address: string): boolean {
|
|
99
|
+
return address === ZERO_ADDRESS || address === ZERO_BYTES;
|
|
78
100
|
}
|
|
79
101
|
|
|
80
102
|
export function getMessageHash(message: string): string {
|