@across-protocol/sdk 4.3.46 → 4.3.47
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.js +30 -28
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +4 -6
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +0 -5
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +0 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +58 -58
- package/dist/cjs/clients/HubPoolClient.d.ts +9 -3
- package/dist/cjs/clients/HubPoolClient.js +81 -56
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +7 -5
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +13 -16
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +2 -2
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/constants.d.ts +3 -0
- package/dist/cjs/constants.js +10 -2
- package/dist/cjs/constants.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.js +33 -29
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +5 -7
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +1 -6
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +0 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +58 -58
- package/dist/esm/clients/HubPoolClient.d.ts +9 -3
- package/dist/esm/clients/HubPoolClient.js +87 -60
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +8 -6
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +13 -18
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +2 -2
- package/dist/esm/clients/mocks/MockHubPoolClient.js +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/constants.d.ts +3 -0
- package/dist/esm/constants.js +12 -1
- package/dist/esm/constants.js.map +1 -1
- 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/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.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 +58 -58
- package/dist/types/clients/HubPoolClient.d.ts +9 -3
- 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.map +1 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +2 -2
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/arch/evm/SpokeUtils.ts +16 -9
- package/src/arch/svm/SpokeUtils.ts +12 -7
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +20 -14
- package/src/clients/BundleDataClient/utils/FillUtils.ts +1 -7
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +0 -2
- package/src/clients/HubPoolClient.ts +79 -50
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +22 -8
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +31 -39
- package/src/clients/mocks/MockHubPoolClient.ts +3 -3
- package/src/constants.ts +12 -0
|
@@ -24,21 +24,21 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
24
24
|
exclusivityDeadline: number;
|
|
25
25
|
destinationChainId: number;
|
|
26
26
|
messageHash: string;
|
|
27
|
+
blockNumber: number;
|
|
28
|
+
logIndex: number;
|
|
27
29
|
quoteTimestamp: number;
|
|
28
30
|
fromLiteChain: boolean;
|
|
29
31
|
toLiteChain: boolean;
|
|
30
|
-
blockNumber: number;
|
|
31
|
-
logIndex: number;
|
|
32
32
|
quoteBlockNumber: number;
|
|
33
33
|
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
34
34
|
updatedOutputAmount?: BigNumber | undefined;
|
|
35
35
|
updatedMessage?: string | undefined;
|
|
36
|
-
transactionHash?: string | undefined;
|
|
37
|
-
transactionIndex?: number | undefined;
|
|
38
|
-
relayerFeePct?: BigNumber | undefined;
|
|
39
|
-
speedUpSignature?: string | undefined;
|
|
40
36
|
txnIndex?: number | undefined;
|
|
41
37
|
txnRef?: string | undefined;
|
|
38
|
+
relayerFeePct?: BigNumber | undefined;
|
|
39
|
+
speedUpSignature?: string | undefined;
|
|
40
|
+
transactionHash?: string | undefined;
|
|
41
|
+
transactionIndex?: number | undefined;
|
|
42
42
|
}[]>>;
|
|
43
43
|
bundleFillsV3: Record<string, Record<string, {
|
|
44
44
|
fills: {
|
|
@@ -54,25 +54,25 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
54
54
|
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
55
55
|
exclusivityDeadline: number;
|
|
56
56
|
destinationChainId: number;
|
|
57
|
+
relayer: SvmAddress | EvmAddress | RawAddress;
|
|
57
58
|
messageHash: string;
|
|
58
59
|
repaymentChainId: number;
|
|
59
|
-
quoteTimestamp: number;
|
|
60
|
-
relayer: SvmAddress | EvmAddress | RawAddress;
|
|
61
60
|
relayExecutionInfo: {
|
|
62
61
|
updatedRecipient: SvmAddress | EvmAddress | RawAddress;
|
|
63
62
|
updatedOutputAmount: BigNumber;
|
|
64
|
-
fillType: number;
|
|
65
63
|
updatedMessageHash: string;
|
|
64
|
+
fillType: number;
|
|
66
65
|
updatedMessage?: string | undefined;
|
|
67
66
|
};
|
|
68
67
|
blockNumber: number;
|
|
69
68
|
logIndex: number;
|
|
69
|
+
quoteTimestamp: number;
|
|
70
70
|
lpFeePct: BigNumber;
|
|
71
71
|
message?: string | undefined;
|
|
72
|
-
transactionHash?: string | undefined;
|
|
73
|
-
transactionIndex?: number | undefined;
|
|
74
72
|
txnIndex?: number | undefined;
|
|
75
73
|
txnRef?: string | undefined;
|
|
74
|
+
transactionHash?: string | undefined;
|
|
75
|
+
transactionIndex?: number | undefined;
|
|
76
76
|
}[];
|
|
77
77
|
refunds: Record<string, BigNumber>;
|
|
78
78
|
realizedLpFees: BigNumber;
|
|
@@ -93,22 +93,22 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
93
93
|
exclusivityDeadline: number;
|
|
94
94
|
destinationChainId: number;
|
|
95
95
|
messageHash: string;
|
|
96
|
+
blockNumber: number;
|
|
97
|
+
logIndex: number;
|
|
96
98
|
quoteTimestamp: number;
|
|
97
99
|
fromLiteChain: boolean;
|
|
98
100
|
toLiteChain: boolean;
|
|
99
|
-
blockNumber: number;
|
|
100
|
-
logIndex: number;
|
|
101
101
|
quoteBlockNumber: number;
|
|
102
102
|
lpFeePct: BigNumber;
|
|
103
103
|
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
104
104
|
updatedOutputAmount?: BigNumber | undefined;
|
|
105
105
|
updatedMessage?: string | undefined;
|
|
106
|
-
transactionHash?: string | undefined;
|
|
107
|
-
transactionIndex?: number | undefined;
|
|
108
|
-
relayerFeePct?: BigNumber | undefined;
|
|
109
|
-
speedUpSignature?: string | undefined;
|
|
110
106
|
txnIndex?: number | undefined;
|
|
111
107
|
txnRef?: string | undefined;
|
|
108
|
+
relayerFeePct?: BigNumber | undefined;
|
|
109
|
+
speedUpSignature?: string | undefined;
|
|
110
|
+
transactionHash?: string | undefined;
|
|
111
|
+
transactionIndex?: number | undefined;
|
|
112
112
|
}[]>>;
|
|
113
113
|
expiredDepositsToRefundV3: Record<string, Record<string, {
|
|
114
114
|
message: string;
|
|
@@ -125,21 +125,21 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
125
125
|
exclusivityDeadline: number;
|
|
126
126
|
destinationChainId: number;
|
|
127
127
|
messageHash: string;
|
|
128
|
+
blockNumber: number;
|
|
129
|
+
logIndex: number;
|
|
128
130
|
quoteTimestamp: number;
|
|
129
131
|
fromLiteChain: boolean;
|
|
130
132
|
toLiteChain: boolean;
|
|
131
|
-
blockNumber: number;
|
|
132
|
-
logIndex: number;
|
|
133
133
|
quoteBlockNumber: number;
|
|
134
134
|
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
135
135
|
updatedOutputAmount?: BigNumber | undefined;
|
|
136
136
|
updatedMessage?: string | undefined;
|
|
137
|
-
transactionHash?: string | undefined;
|
|
138
|
-
transactionIndex?: number | undefined;
|
|
139
|
-
relayerFeePct?: BigNumber | undefined;
|
|
140
|
-
speedUpSignature?: string | undefined;
|
|
141
137
|
txnIndex?: number | undefined;
|
|
142
138
|
txnRef?: string | undefined;
|
|
139
|
+
relayerFeePct?: BigNumber | undefined;
|
|
140
|
+
speedUpSignature?: string | undefined;
|
|
141
|
+
transactionHash?: string | undefined;
|
|
142
|
+
transactionIndex?: number | undefined;
|
|
143
143
|
}[]>>;
|
|
144
144
|
unexecutableSlowFills: Record<string, Record<string, {
|
|
145
145
|
message: string;
|
|
@@ -156,22 +156,22 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
156
156
|
exclusivityDeadline: number;
|
|
157
157
|
destinationChainId: number;
|
|
158
158
|
messageHash: string;
|
|
159
|
+
blockNumber: number;
|
|
160
|
+
logIndex: number;
|
|
159
161
|
quoteTimestamp: number;
|
|
160
162
|
fromLiteChain: boolean;
|
|
161
163
|
toLiteChain: boolean;
|
|
162
|
-
blockNumber: number;
|
|
163
|
-
logIndex: number;
|
|
164
164
|
quoteBlockNumber: number;
|
|
165
165
|
lpFeePct: BigNumber;
|
|
166
166
|
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
167
167
|
updatedOutputAmount?: BigNumber | undefined;
|
|
168
168
|
updatedMessage?: string | undefined;
|
|
169
|
-
transactionHash?: string | undefined;
|
|
170
|
-
transactionIndex?: number | undefined;
|
|
171
|
-
relayerFeePct?: BigNumber | undefined;
|
|
172
|
-
speedUpSignature?: string | undefined;
|
|
173
169
|
txnIndex?: number | undefined;
|
|
174
170
|
txnRef?: string | undefined;
|
|
171
|
+
relayerFeePct?: BigNumber | undefined;
|
|
172
|
+
speedUpSignature?: string | undefined;
|
|
173
|
+
transactionHash?: string | undefined;
|
|
174
|
+
transactionIndex?: number | undefined;
|
|
175
175
|
}[]>>;
|
|
176
176
|
}, {
|
|
177
177
|
bundleDepositsV3: import("superstruct").Struct<Record<string, Record<string, {
|
|
@@ -189,21 +189,21 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
189
189
|
exclusivityDeadline: number;
|
|
190
190
|
destinationChainId: number;
|
|
191
191
|
messageHash: string;
|
|
192
|
+
blockNumber: number;
|
|
193
|
+
logIndex: number;
|
|
192
194
|
quoteTimestamp: number;
|
|
193
195
|
fromLiteChain: boolean;
|
|
194
196
|
toLiteChain: boolean;
|
|
195
|
-
blockNumber: number;
|
|
196
|
-
logIndex: number;
|
|
197
197
|
quoteBlockNumber: number;
|
|
198
198
|
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
199
199
|
updatedOutputAmount?: BigNumber | undefined;
|
|
200
200
|
updatedMessage?: string | undefined;
|
|
201
|
-
transactionHash?: string | undefined;
|
|
202
|
-
transactionIndex?: number | undefined;
|
|
203
|
-
relayerFeePct?: BigNumber | undefined;
|
|
204
|
-
speedUpSignature?: string | undefined;
|
|
205
201
|
txnIndex?: number | undefined;
|
|
206
202
|
txnRef?: string | undefined;
|
|
203
|
+
relayerFeePct?: BigNumber | undefined;
|
|
204
|
+
speedUpSignature?: string | undefined;
|
|
205
|
+
transactionHash?: string | undefined;
|
|
206
|
+
transactionIndex?: number | undefined;
|
|
207
207
|
}[]>>, null>;
|
|
208
208
|
expiredDepositsToRefundV3: import("superstruct").Struct<Record<string, Record<string, {
|
|
209
209
|
message: string;
|
|
@@ -220,21 +220,21 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
220
220
|
exclusivityDeadline: number;
|
|
221
221
|
destinationChainId: number;
|
|
222
222
|
messageHash: string;
|
|
223
|
+
blockNumber: number;
|
|
224
|
+
logIndex: number;
|
|
223
225
|
quoteTimestamp: number;
|
|
224
226
|
fromLiteChain: boolean;
|
|
225
227
|
toLiteChain: boolean;
|
|
226
|
-
blockNumber: number;
|
|
227
|
-
logIndex: number;
|
|
228
228
|
quoteBlockNumber: number;
|
|
229
229
|
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
230
230
|
updatedOutputAmount?: BigNumber | undefined;
|
|
231
231
|
updatedMessage?: string | undefined;
|
|
232
|
-
transactionHash?: string | undefined;
|
|
233
|
-
transactionIndex?: number | undefined;
|
|
234
|
-
relayerFeePct?: BigNumber | undefined;
|
|
235
|
-
speedUpSignature?: string | undefined;
|
|
236
232
|
txnIndex?: number | undefined;
|
|
237
233
|
txnRef?: string | undefined;
|
|
234
|
+
relayerFeePct?: BigNumber | undefined;
|
|
235
|
+
speedUpSignature?: string | undefined;
|
|
236
|
+
transactionHash?: string | undefined;
|
|
237
|
+
transactionIndex?: number | undefined;
|
|
238
238
|
}[]>>, null>;
|
|
239
239
|
unexecutableSlowFills: import("superstruct").Struct<Record<string, Record<string, {
|
|
240
240
|
message: string;
|
|
@@ -251,22 +251,22 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
251
251
|
exclusivityDeadline: number;
|
|
252
252
|
destinationChainId: number;
|
|
253
253
|
messageHash: string;
|
|
254
|
+
blockNumber: number;
|
|
255
|
+
logIndex: number;
|
|
254
256
|
quoteTimestamp: number;
|
|
255
257
|
fromLiteChain: boolean;
|
|
256
258
|
toLiteChain: boolean;
|
|
257
|
-
blockNumber: number;
|
|
258
|
-
logIndex: number;
|
|
259
259
|
quoteBlockNumber: number;
|
|
260
260
|
lpFeePct: BigNumber;
|
|
261
261
|
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
262
262
|
updatedOutputAmount?: BigNumber | undefined;
|
|
263
263
|
updatedMessage?: string | undefined;
|
|
264
|
-
transactionHash?: string | undefined;
|
|
265
|
-
transactionIndex?: number | undefined;
|
|
266
|
-
relayerFeePct?: BigNumber | undefined;
|
|
267
|
-
speedUpSignature?: string | undefined;
|
|
268
264
|
txnIndex?: number | undefined;
|
|
269
265
|
txnRef?: string | undefined;
|
|
266
|
+
relayerFeePct?: BigNumber | undefined;
|
|
267
|
+
speedUpSignature?: string | undefined;
|
|
268
|
+
transactionHash?: string | undefined;
|
|
269
|
+
transactionIndex?: number | undefined;
|
|
270
270
|
}[]>>, null>;
|
|
271
271
|
bundleSlowFillsV3: import("superstruct").Struct<Record<string, Record<string, {
|
|
272
272
|
message: string;
|
|
@@ -283,22 +283,22 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
283
283
|
exclusivityDeadline: number;
|
|
284
284
|
destinationChainId: number;
|
|
285
285
|
messageHash: string;
|
|
286
|
+
blockNumber: number;
|
|
287
|
+
logIndex: number;
|
|
286
288
|
quoteTimestamp: number;
|
|
287
289
|
fromLiteChain: boolean;
|
|
288
290
|
toLiteChain: boolean;
|
|
289
|
-
blockNumber: number;
|
|
290
|
-
logIndex: number;
|
|
291
291
|
quoteBlockNumber: number;
|
|
292
292
|
lpFeePct: BigNumber;
|
|
293
293
|
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
294
294
|
updatedOutputAmount?: BigNumber | undefined;
|
|
295
295
|
updatedMessage?: string | undefined;
|
|
296
|
-
transactionHash?: string | undefined;
|
|
297
|
-
transactionIndex?: number | undefined;
|
|
298
|
-
relayerFeePct?: BigNumber | undefined;
|
|
299
|
-
speedUpSignature?: string | undefined;
|
|
300
296
|
txnIndex?: number | undefined;
|
|
301
297
|
txnRef?: string | undefined;
|
|
298
|
+
relayerFeePct?: BigNumber | undefined;
|
|
299
|
+
speedUpSignature?: string | undefined;
|
|
300
|
+
transactionHash?: string | undefined;
|
|
301
|
+
transactionIndex?: number | undefined;
|
|
302
302
|
}[]>>, null>;
|
|
303
303
|
bundleFillsV3: import("superstruct").Struct<Record<string, Record<string, {
|
|
304
304
|
fills: {
|
|
@@ -314,25 +314,25 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
314
314
|
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
315
315
|
exclusivityDeadline: number;
|
|
316
316
|
destinationChainId: number;
|
|
317
|
+
relayer: SvmAddress | EvmAddress | RawAddress;
|
|
317
318
|
messageHash: string;
|
|
318
319
|
repaymentChainId: number;
|
|
319
|
-
quoteTimestamp: number;
|
|
320
|
-
relayer: SvmAddress | EvmAddress | RawAddress;
|
|
321
320
|
relayExecutionInfo: {
|
|
322
321
|
updatedRecipient: SvmAddress | EvmAddress | RawAddress;
|
|
323
322
|
updatedOutputAmount: BigNumber;
|
|
324
|
-
fillType: number;
|
|
325
323
|
updatedMessageHash: string;
|
|
324
|
+
fillType: number;
|
|
326
325
|
updatedMessage?: string | undefined;
|
|
327
326
|
};
|
|
328
327
|
blockNumber: number;
|
|
329
328
|
logIndex: number;
|
|
329
|
+
quoteTimestamp: number;
|
|
330
330
|
lpFeePct: BigNumber;
|
|
331
331
|
message?: string | undefined;
|
|
332
|
-
transactionHash?: string | undefined;
|
|
333
|
-
transactionIndex?: number | undefined;
|
|
334
332
|
txnIndex?: number | undefined;
|
|
335
333
|
txnRef?: string | undefined;
|
|
334
|
+
transactionHash?: string | undefined;
|
|
335
|
+
transactionIndex?: number | undefined;
|
|
336
336
|
}[];
|
|
337
337
|
refunds: Record<string, BigNumber>;
|
|
338
338
|
realizedLpFees: BigNumber;
|
|
@@ -18,6 +18,11 @@ type HubPoolUpdateFailure = {
|
|
|
18
18
|
};
|
|
19
19
|
export type HubPoolUpdate = HubPoolUpdateSuccess | HubPoolUpdateFailure;
|
|
20
20
|
type HubPoolEvent = "SetPoolRebalanceRoute" | "L1TokenEnabledForLiquidityProvision" | "ProposeRootBundle" | "RootBundleCanceled" | "RootBundleDisputed" | "RootBundleExecuted" | "CrossChainContractsSet";
|
|
21
|
+
type L1TokensToDestinationTokens = {
|
|
22
|
+
[l1Token: string]: {
|
|
23
|
+
[destinationChainId: number]: Address;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
21
26
|
export type LpFeeRequest = Pick<Deposit, "originChainId" | "inputToken" | "inputAmount" | "quoteTimestamp"> & {
|
|
22
27
|
paymentChainId?: number;
|
|
23
28
|
};
|
|
@@ -32,6 +37,7 @@ export declare class HubPoolClient extends BaseAbstractClient {
|
|
|
32
37
|
ignoredHubProposedBundles: number[];
|
|
33
38
|
timeToCache?: number;
|
|
34
39
|
};
|
|
40
|
+
protected l1TokensToDestinationTokens: L1TokensToDestinationTokens;
|
|
35
41
|
protected l1Tokens: L1TokenInfo[];
|
|
36
42
|
protected lpTokens: {
|
|
37
43
|
[token: string]: LpToken;
|
|
@@ -65,9 +71,9 @@ export declare class HubPoolClient extends BaseAbstractClient {
|
|
|
65
71
|
getExecutedRootBundles(): ExecutedRootBundle[];
|
|
66
72
|
getSpokePoolForBlock(chain: number, block?: number): Address;
|
|
67
73
|
getSpokePoolActivationBlock(chain: number, spokePool: Address): number | undefined;
|
|
68
|
-
getL2TokenForL1TokenAtBlock(l1Token: EvmAddress, destinationChainId: number, latestHubBlock?: number): Address
|
|
69
|
-
getL1TokenForL2TokenAtBlock(l2Token: Address, destinationChainId: number, latestHubBlock?: number): EvmAddress
|
|
70
|
-
protected getL1TokenForDeposit(deposit: Pick<DepositWithBlock, "originChainId" | "inputToken" | "quoteBlockNumber">): EvmAddress
|
|
74
|
+
getL2TokenForL1TokenAtBlock(l1Token: EvmAddress, destinationChainId: number, latestHubBlock?: number): Address;
|
|
75
|
+
getL1TokenForL2TokenAtBlock(l2Token: Address, destinationChainId: number, latestHubBlock?: number): EvmAddress;
|
|
76
|
+
protected getL1TokenForDeposit(deposit: Pick<DepositWithBlock, "originChainId" | "inputToken" | "quoteBlockNumber">): EvmAddress;
|
|
71
77
|
l2TokenEnabledForL1Token(l1Token: EvmAddress, destinationChainId: number): boolean;
|
|
72
78
|
l2TokenEnabledForL1TokenAtBlock(l1Token: EvmAddress, destinationChainId: number, hubBlockNumber: number): boolean;
|
|
73
79
|
l2TokenHasPoolRebalanceRoute(l2Token: Address, l2ChainId: number, hubPoolBlock?: number): boolean;
|
|
@@ -4,7 +4,7 @@ import _ from "lodash";
|
|
|
4
4
|
import { DEFAULT_CACHING_SAFE_LAG, DEFAULT_CACHING_TTL, TOKEN_SYMBOLS_MAP } from "../constants";
|
|
5
5
|
import * as lpFeeCalculator from "../lpFeeCalculator";
|
|
6
6
|
import { EVMBlockFinder } from "../arch/evm";
|
|
7
|
-
import { BigNumber, bnZero, dedupArray, assign, fetchTokenInfo, getCachedBlockForTimestamp, getCurrentTime, isDefined, mapAsync, paginatedEventQuery, shouldCache, sortEventsDescending, spreadEventWithBlockNumber, toBN, getTokenInfo, getUsdcSymbol, chainIsSvm, getDeployedAddress, SvmAddress, EvmAddress, } from "../utils";
|
|
7
|
+
import { BigNumber, bnZero, dedupArray, assign, fetchTokenInfo, getCachedBlockForTimestamp, getCurrentTime, getNetworkName, isDefined, mapAsync, paginatedEventQuery, shouldCache, sortEventsDescending, spreadEventWithBlockNumber, toBN, getTokenInfo, getUsdcSymbol, chainIsSvm, getDeployedAddress, SvmAddress, EvmAddress, } from "../utils";
|
|
8
8
|
import { BaseAbstractClient, isUpdateFailureReason, UpdateFailureReason } from "./BaseAbstractClient";
|
|
9
9
|
var HubPoolClient = /** @class */ (function (_super) {
|
|
10
10
|
__extends(HubPoolClient, _super);
|
|
@@ -23,6 +23,8 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
23
23
|
_this.deploymentBlock = deploymentBlock;
|
|
24
24
|
_this.chainId = chainId;
|
|
25
25
|
_this.configOverride = configOverride;
|
|
26
|
+
// L1Token -> destinationChainId -> destinationToken
|
|
27
|
+
_this.l1TokensToDestinationTokens = {};
|
|
26
28
|
_this.l1Tokens = []; // L1Tokens and their associated info.
|
|
27
29
|
// @dev `token` here is a 20-byte hex sting
|
|
28
30
|
_this.lpTokens = {};
|
|
@@ -90,30 +92,49 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
90
92
|
};
|
|
91
93
|
// Returns the latest L2 token to use for an L1 token as of the input hub block.
|
|
92
94
|
HubPoolClient.prototype.getL2TokenForL1TokenAtBlock = function (l1Token, destinationChainId, latestHubBlock) {
|
|
93
|
-
var _a, _b;
|
|
95
|
+
var _a, _b, _c, _d;
|
|
94
96
|
if (latestHubBlock === void 0) { latestHubBlock = Number.MAX_SAFE_INTEGER; }
|
|
95
97
|
if (!((_b = (_a = this.l1TokensToDestinationTokensWithBlock) === null || _a === void 0 ? void 0 : _a[l1Token.toEvmAddress()]) === null || _b === void 0 ? void 0 : _b[destinationChainId])) {
|
|
96
|
-
|
|
98
|
+
var chain = getNetworkName(destinationChainId);
|
|
99
|
+
var symbol = ((_c = this.l1Tokens.find(function (_a) {
|
|
100
|
+
var address = _a.address;
|
|
101
|
+
return address.eq(l1Token);
|
|
102
|
+
})) !== null && _c !== void 0 ? _c : { symbol: l1Token.toString() }).symbol;
|
|
103
|
+
throw new Error("Could not find SpokePool mapping for ".concat(symbol, " on ").concat(chain, " and L1 token ").concat(l1Token));
|
|
97
104
|
}
|
|
98
105
|
// Find the last mapping published before the target block.
|
|
99
|
-
var l2Token = this.l1TokensToDestinationTokensWithBlock[l1Token.toEvmAddress()][destinationChainId].find(function (mapping) { return mapping.blockNumber <= latestHubBlock; });
|
|
100
|
-
|
|
106
|
+
var l2Token = sortEventsDescending(this.l1TokensToDestinationTokensWithBlock[l1Token.toEvmAddress()][destinationChainId]).find(function (mapping) { return mapping.blockNumber <= latestHubBlock; });
|
|
107
|
+
if (!l2Token) {
|
|
108
|
+
var chain = getNetworkName(destinationChainId);
|
|
109
|
+
var symbol = ((_d = this.l1Tokens.find(function (_a) {
|
|
110
|
+
var address = _a.address;
|
|
111
|
+
return address.eq(l1Token);
|
|
112
|
+
})) !== null && _d !== void 0 ? _d : { symbol: l1Token.toString() }).symbol;
|
|
113
|
+
throw new Error("Could not find SpokePool mapping for ".concat(symbol, " on ").concat(chain, " at or before HubPool block ").concat(latestHubBlock, "!"));
|
|
114
|
+
}
|
|
115
|
+
return l2Token.l2Token;
|
|
101
116
|
};
|
|
102
117
|
// Returns the latest L1 token to use for an L2 token as of the input hub block.
|
|
103
118
|
HubPoolClient.prototype.getL1TokenForL2TokenAtBlock = function (l2Token, destinationChainId, latestHubBlock) {
|
|
104
119
|
var _this = this;
|
|
105
120
|
if (latestHubBlock === void 0) { latestHubBlock = Number.MAX_SAFE_INTEGER; }
|
|
106
|
-
var l2Tokens = Object.keys(this.l1TokensToDestinationTokensWithBlock)
|
|
107
|
-
|
|
108
|
-
|
|
121
|
+
var l2Tokens = Object.keys(this.l1TokensToDestinationTokensWithBlock)
|
|
122
|
+
.filter(function (l1Token) { return _this.l2TokenEnabledForL1Token(EvmAddress.from(l1Token), destinationChainId); })
|
|
123
|
+
.map(function (l1Token) {
|
|
124
|
+
// Return all matching L2 token mappings that are equal to or earlier than the target block.
|
|
109
125
|
// @dev Since tokens on L2s (like Solana) can have 32 byte addresses, filter on the lower 20 bytes of the token only.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
126
|
+
return _this.l1TokensToDestinationTokensWithBlock[l1Token][destinationChainId].filter(function (dstTokenWithBlock) {
|
|
127
|
+
return dstTokenWithBlock.l2Token.truncateToBytes20() === l2Token.truncateToBytes20() &&
|
|
128
|
+
dstTokenWithBlock.blockNumber <= latestHubBlock;
|
|
129
|
+
});
|
|
130
|
+
})
|
|
131
|
+
.flat();
|
|
132
|
+
if (l2Tokens.length === 0) {
|
|
133
|
+
var chain = getNetworkName(destinationChainId);
|
|
134
|
+
throw new Error("Could not find HubPool mapping for ".concat(l2Token, " on ").concat(chain, " at or before HubPool block ").concat(latestHubBlock, "!"));
|
|
135
|
+
}
|
|
136
|
+
// Find the last mapping published before the target block.
|
|
137
|
+
return sortEventsDescending(l2Tokens)[0].l1Token;
|
|
117
138
|
};
|
|
118
139
|
HubPoolClient.prototype.getL1TokenForDeposit = function (deposit) {
|
|
119
140
|
// L1-->L2 token mappings are set via PoolRebalanceRoutes which occur on mainnet,
|
|
@@ -122,18 +143,27 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
122
143
|
return this.getL1TokenForL2TokenAtBlock(deposit.inputToken, deposit.originChainId, deposit.quoteBlockNumber);
|
|
123
144
|
};
|
|
124
145
|
HubPoolClient.prototype.l2TokenEnabledForL1Token = function (l1Token, destinationChainId) {
|
|
125
|
-
|
|
146
|
+
var _a, _b;
|
|
147
|
+
return ((_b = (_a = this.l1TokensToDestinationTokens) === null || _a === void 0 ? void 0 : _a[l1Token.toEvmAddress()]) === null || _b === void 0 ? void 0 : _b[destinationChainId]) != undefined;
|
|
126
148
|
};
|
|
127
149
|
HubPoolClient.prototype.l2TokenEnabledForL1TokenAtBlock = function (l1Token, destinationChainId, hubBlockNumber) {
|
|
128
150
|
var _a, _b, _c;
|
|
129
151
|
// Find the last mapping published before the target block.
|
|
130
152
|
var l2Token = sortEventsDescending((_c = (_b = (_a = this.l1TokensToDestinationTokensWithBlock) === null || _a === void 0 ? void 0 : _a[l1Token.toEvmAddress()]) === null || _b === void 0 ? void 0 : _b[destinationChainId]) !== null && _c !== void 0 ? _c : []).find(function (mapping) { return mapping.blockNumber <= hubBlockNumber; });
|
|
131
|
-
return l2Token !== undefined
|
|
153
|
+
return l2Token !== undefined;
|
|
132
154
|
};
|
|
133
155
|
HubPoolClient.prototype.l2TokenHasPoolRebalanceRoute = function (l2Token, l2ChainId, hubPoolBlock) {
|
|
134
156
|
if (hubPoolBlock === void 0) { hubPoolBlock = this.latestHeightSearched; }
|
|
135
|
-
|
|
136
|
-
|
|
157
|
+
return Object.values(this.l1TokensToDestinationTokensWithBlock).some(function (destinationTokenMapping) {
|
|
158
|
+
return Object.entries(destinationTokenMapping).some(function (_a) {
|
|
159
|
+
var _l2ChainId = _a[0], setPoolRebalanceRouteEvents = _a[1];
|
|
160
|
+
return setPoolRebalanceRouteEvents.some(function (e) {
|
|
161
|
+
return (e.blockNumber <= hubPoolBlock &&
|
|
162
|
+
e.l2Token.truncateToBytes20() === l2Token.truncateToBytes20() &&
|
|
163
|
+
Number(_l2ChainId) === l2ChainId);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
});
|
|
137
167
|
};
|
|
138
168
|
/**
|
|
139
169
|
* @dev If tokenAddress + chain do not exist in TOKEN_SYMBOLS_MAP then this will throw.
|
|
@@ -309,11 +339,11 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
309
339
|
getHubPoolToken = function (deposit, quoteBlockNumber) {
|
|
310
340
|
var _a;
|
|
311
341
|
var tokenKey = "".concat(deposit.originChainId, "-").concat(deposit.inputToken);
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
return undefined;
|
|
342
|
+
if (_this.l2TokenHasPoolRebalanceRoute(deposit.inputToken, deposit.originChainId, quoteBlockNumber)) {
|
|
343
|
+
return ((_a = hubPoolTokens[tokenKey]) !== null && _a !== void 0 ? _a : (hubPoolTokens[tokenKey] = _this.getL1TokenForDeposit(__assign(__assign({}, deposit), { quoteBlockNumber: quoteBlockNumber }))));
|
|
315
344
|
}
|
|
316
|
-
|
|
345
|
+
else
|
|
346
|
+
return undefined;
|
|
317
347
|
};
|
|
318
348
|
getHubPoolTokens = function () { return dedupArray(Object.values(hubPoolTokens).filter(isDefined)); };
|
|
319
349
|
resolveUniqueQuoteTimestamps = function (deposit) {
|
|
@@ -451,13 +481,13 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
451
481
|
// Resolve both SpokePool tokens back to their respective HubPool tokens and verify that they match.
|
|
452
482
|
var l1TokenA = this.getL1TokenForL2TokenAtBlock(tokenA, chainIdA, hubPoolBlock);
|
|
453
483
|
var l1TokenB = this.getL1TokenForL2TokenAtBlock(tokenB, chainIdB, hubPoolBlock);
|
|
454
|
-
if (!l1TokenA
|
|
484
|
+
if (!l1TokenA.eq(l1TokenB)) {
|
|
455
485
|
return false;
|
|
456
486
|
}
|
|
457
487
|
// Resolve both HubPool tokens back to a current SpokePool token and verify that they match.
|
|
458
488
|
var _tokenA = this.getL2TokenForL1TokenAtBlock(l1TokenA, chainIdA, hubPoolBlock);
|
|
459
489
|
var _tokenB = this.getL2TokenForL1TokenAtBlock(l1TokenB, chainIdB, hubPoolBlock);
|
|
460
|
-
return
|
|
490
|
+
return tokenA.eq(_tokenA) && tokenB.eq(_tokenB);
|
|
461
491
|
};
|
|
462
492
|
HubPoolClient.prototype.getSpokeActivationBlockForChain = function (chainId) {
|
|
463
493
|
var _a;
|
|
@@ -749,21 +779,20 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
749
779
|
});
|
|
750
780
|
};
|
|
751
781
|
HubPoolClient.prototype.update = function (eventsToQuery) {
|
|
752
|
-
var _a;
|
|
753
782
|
if (eventsToQuery === void 0) { eventsToQuery = Object.keys(this.hubPoolEventFilters()); }
|
|
754
783
|
return __awaiter(this, void 0, void 0, function () {
|
|
755
|
-
var update, events, currentTime, pendingRootBundleProposal, searchEndBlock, _i,
|
|
756
|
-
var _j, _k
|
|
784
|
+
var update, events, currentTime, pendingRootBundleProposal, searchEndBlock, _i, _a, event_1, args, dataToAdd, solanaSpokePool, svmSpoke, truncatedAddress, _b, _c, event_2, args, destinationToken, usdcTokenSol, svmUsdc, uniqueL1Tokens, _d, tokenInfo, lpTokenInfo_1, _loop_1, this_1, _e, tokenInfo_1, info, _f, _g, event_3, executedRootBundle, l1Tokens, runningBalances, nTokens, mostRecentProposedRootBundle;
|
|
785
|
+
var _h, _j, _k;
|
|
757
786
|
var _this = this;
|
|
758
|
-
return __generator(this, function (
|
|
759
|
-
switch (
|
|
787
|
+
return __generator(this, function (_l) {
|
|
788
|
+
switch (_l.label) {
|
|
760
789
|
case 0:
|
|
761
790
|
if (!this.configStoreClient.isUpdated) {
|
|
762
791
|
throw new Error("ConfigStoreClient not updated");
|
|
763
792
|
}
|
|
764
793
|
return [4 /*yield*/, this._update(eventsToQuery)];
|
|
765
794
|
case 1:
|
|
766
|
-
update =
|
|
795
|
+
update = _l.sent();
|
|
767
796
|
if (!update.success) {
|
|
768
797
|
if (update.reason !== UpdateFailureReason.AlreadyUpdated) {
|
|
769
798
|
throw new Error("Unable to update HubPoolClient: ".concat(update.reason));
|
|
@@ -773,8 +802,8 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
773
802
|
}
|
|
774
803
|
events = update.events, currentTime = update.currentTime, pendingRootBundleProposal = update.pendingRootBundleProposal, searchEndBlock = update.searchEndBlock;
|
|
775
804
|
if (eventsToQuery.includes("CrossChainContractsSet")) {
|
|
776
|
-
for (_i = 0,
|
|
777
|
-
event_1 =
|
|
805
|
+
for (_i = 0, _a = events["CrossChainContractsSet"]; _i < _a.length; _i++) {
|
|
806
|
+
event_1 = _a[_i];
|
|
778
807
|
args = spreadEventWithBlockNumber(event_1);
|
|
779
808
|
dataToAdd = {
|
|
780
809
|
spokePool: EvmAddress.from(args.spokePool),
|
|
@@ -804,8 +833,8 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
804
833
|
}
|
|
805
834
|
}
|
|
806
835
|
if (eventsToQuery.includes("SetPoolRebalanceRoute")) {
|
|
807
|
-
for (
|
|
808
|
-
event_2 =
|
|
836
|
+
for (_b = 0, _c = events["SetPoolRebalanceRoute"]; _b < _c.length; _b++) {
|
|
837
|
+
event_2 = _c[_b];
|
|
809
838
|
args = spreadEventWithBlockNumber(event_2);
|
|
810
839
|
destinationToken = EvmAddress.from(args.destinationToken);
|
|
811
840
|
if (chainIsSvm(args.destinationChainId)) {
|
|
@@ -817,22 +846,20 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
817
846
|
}
|
|
818
847
|
destinationToken = svmUsdc;
|
|
819
848
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
else {
|
|
835
|
-
assign(this.l1TokensToDestinationTokensWithBlock, [args.l1Token, args.destinationChainId], [newRoute]);
|
|
849
|
+
// If the destination token is set to the zero address in an event, then this means Across should no longer
|
|
850
|
+
// rebalance to this chain.
|
|
851
|
+
if (!destinationToken.isZeroAddress()) {
|
|
852
|
+
assign(this.l1TokensToDestinationTokens, [args.l1Token, args.destinationChainId], destinationToken);
|
|
853
|
+
assign(this.l1TokensToDestinationTokensWithBlock, [args.l1Token, args.destinationChainId], [
|
|
854
|
+
{
|
|
855
|
+
l1Token: EvmAddress.from(args.l1Token),
|
|
856
|
+
l2Token: destinationToken,
|
|
857
|
+
blockNumber: args.blockNumber,
|
|
858
|
+
txnIndex: args.txnIndex,
|
|
859
|
+
logIndex: args.logIndex,
|
|
860
|
+
txnRef: args.txnRef,
|
|
861
|
+
},
|
|
862
|
+
]);
|
|
836
863
|
}
|
|
837
864
|
}
|
|
838
865
|
}
|
|
@@ -858,7 +885,7 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
858
885
|
}); }); })),
|
|
859
886
|
])];
|
|
860
887
|
case 2:
|
|
861
|
-
|
|
888
|
+
_d = _l.sent(), tokenInfo = _d[0], lpTokenInfo_1 = _d[1];
|
|
862
889
|
_loop_1 = function (info) {
|
|
863
890
|
if (!this_1.l1Tokens.find(function (token) { return token.address.eq(info.address); })) {
|
|
864
891
|
if (info.decimals > 0 && info.decimals <= 18) {
|
|
@@ -870,8 +897,8 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
870
897
|
}
|
|
871
898
|
};
|
|
872
899
|
this_1 = this;
|
|
873
|
-
for (
|
|
874
|
-
info = tokenInfo_1[
|
|
900
|
+
for (_e = 0, tokenInfo_1 = tokenInfo; _e < tokenInfo_1.length; _e++) {
|
|
901
|
+
info = tokenInfo_1[_e];
|
|
875
902
|
_loop_1(info);
|
|
876
903
|
}
|
|
877
904
|
uniqueL1Tokens.forEach(function (token, i) {
|
|
@@ -880,10 +907,10 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
880
907
|
liquidReserves: lpTokenInfo_1[i].liquidReserves,
|
|
881
908
|
};
|
|
882
909
|
});
|
|
883
|
-
|
|
910
|
+
_l.label = 3;
|
|
884
911
|
case 3:
|
|
885
912
|
if (eventsToQuery.includes("ProposeRootBundle")) {
|
|
886
|
-
(
|
|
913
|
+
(_h = this.proposedRootBundles).push.apply(_h, events["ProposeRootBundle"]
|
|
887
914
|
.filter(function (event) { return !_this.configOverride.ignoredHubProposedBundles.includes(event.blockNumber); })
|
|
888
915
|
.map(function (_event) {
|
|
889
916
|
var args = spreadEventWithBlockNumber(_event);
|
|
@@ -891,14 +918,14 @@ var HubPoolClient = /** @class */ (function (_super) {
|
|
|
891
918
|
}));
|
|
892
919
|
}
|
|
893
920
|
if (eventsToQuery.includes("RootBundleCanceled")) {
|
|
894
|
-
(
|
|
921
|
+
(_j = this.canceledRootBundles).push.apply(_j, events["RootBundleCanceled"].map(function (event) { return spreadEventWithBlockNumber(event); }));
|
|
895
922
|
}
|
|
896
923
|
if (eventsToQuery.includes("RootBundleDisputed")) {
|
|
897
|
-
(
|
|
924
|
+
(_k = this.disputedRootBundles).push.apply(_k, events["RootBundleDisputed"].map(function (event) { return spreadEventWithBlockNumber(event); }));
|
|
898
925
|
}
|
|
899
926
|
if (eventsToQuery.includes("RootBundleExecuted")) {
|
|
900
|
-
for (
|
|
901
|
-
event_3 =
|
|
927
|
+
for (_f = 0, _g = events["RootBundleExecuted"]; _f < _g.length; _f++) {
|
|
928
|
+
event_3 = _g[_f];
|
|
902
929
|
if (this.configOverride.ignoredHubExecutedBundles.includes(event_3.blockNumber)) {
|
|
903
930
|
continue;
|
|
904
931
|
}
|