@across-protocol/sdk 3.1.11 → 3.1.13

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.
Files changed (70) hide show
  1. package/dist/cjs/clients/SpokePoolClient.d.ts +1 -0
  2. package/dist/cjs/clients/SpokePoolClient.js +4 -0
  3. package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
  4. package/dist/cjs/coingecko/Coingecko.d.ts +1 -0
  5. package/dist/cjs/coingecko/Coingecko.js +25 -0
  6. package/dist/cjs/coingecko/Coingecko.js.map +1 -1
  7. package/dist/cjs/constants.d.ts +2 -1
  8. package/dist/cjs/constants.js +3 -1
  9. package/dist/cjs/constants.js.map +1 -1
  10. package/dist/cjs/gasPriceOracle/oracle.js +1 -0
  11. package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
  12. package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +21 -0
  13. package/dist/cjs/relayFeeCalculator/chain-queries/polygon.d.ts +21 -0
  14. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +21 -0
  15. package/dist/cjs/utils/BlockUtils.js +12 -13
  16. package/dist/cjs/utils/BlockUtils.js.map +1 -1
  17. package/dist/cjs/utils/NetworkUtils.d.ts +1 -0
  18. package/dist/cjs/utils/NetworkUtils.js +7 -13
  19. package/dist/cjs/utils/NetworkUtils.js.map +1 -1
  20. package/dist/cjs/utils/TokenUtils.d.ts +44 -0
  21. package/dist/cjs/utils/TokenUtils.js +13 -1
  22. package/dist/cjs/utils/TokenUtils.js.map +1 -1
  23. package/dist/esm/clients/SpokePoolClient.d.ts +6 -0
  24. package/dist/esm/clients/SpokePoolClient.js +9 -0
  25. package/dist/esm/clients/SpokePoolClient.js.map +1 -1
  26. package/dist/esm/coingecko/Coingecko.d.ts +9 -0
  27. package/dist/esm/coingecko/Coingecko.js +34 -1
  28. package/dist/esm/coingecko/Coingecko.js.map +1 -1
  29. package/dist/esm/constants.d.ts +2 -1
  30. package/dist/esm/constants.js +2 -1
  31. package/dist/esm/constants.js.map +1 -1
  32. package/dist/esm/gasPriceOracle/oracle.js +1 -0
  33. package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
  34. package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +21 -0
  35. package/dist/esm/relayFeeCalculator/chain-queries/polygon.d.ts +21 -0
  36. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +21 -0
  37. package/dist/esm/utils/BlockUtils.js +13 -14
  38. package/dist/esm/utils/BlockUtils.js.map +1 -1
  39. package/dist/esm/utils/NetworkUtils.d.ts +6 -0
  40. package/dist/esm/utils/NetworkUtils.js +11 -13
  41. package/dist/esm/utils/NetworkUtils.js.map +1 -1
  42. package/dist/esm/utils/TokenUtils.d.ts +58 -0
  43. package/dist/esm/utils/TokenUtils.js +10 -0
  44. package/dist/esm/utils/TokenUtils.js.map +1 -1
  45. package/dist/types/clients/SpokePoolClient.d.ts +6 -0
  46. package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
  47. package/dist/types/coingecko/Coingecko.d.ts +9 -0
  48. package/dist/types/coingecko/Coingecko.d.ts.map +1 -1
  49. package/dist/types/constants.d.ts +2 -1
  50. package/dist/types/constants.d.ts.map +1 -1
  51. package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
  52. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +21 -0
  53. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
  54. package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts +21 -0
  55. package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts.map +1 -1
  56. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +21 -0
  57. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  58. package/dist/types/utils/BlockUtils.d.ts.map +1 -1
  59. package/dist/types/utils/NetworkUtils.d.ts +6 -0
  60. package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
  61. package/dist/types/utils/TokenUtils.d.ts +58 -0
  62. package/dist/types/utils/TokenUtils.d.ts.map +1 -1
  63. package/package.json +3 -3
  64. package/src/clients/SpokePoolClient.ts +10 -0
  65. package/src/coingecko/Coingecko.ts +27 -1
  66. package/src/constants.ts +3 -1
  67. package/src/gasPriceOracle/oracle.ts +1 -0
  68. package/src/utils/BlockUtils.ts +9 -7
  69. package/src/utils/NetworkUtils.ts +11 -13
  70. package/src/utils/TokenUtils.ts +14 -0
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/NetworkUtils.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAGjE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAErE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAavD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAa3D;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAExE"}
1
+ {"version":3,"file":"NetworkUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/NetworkUtils.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAGjE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAErE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAa3D;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAExE"}
@@ -29,6 +29,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
29
29
  addresses: {
30
30
  [x: number]: string;
31
31
  };
32
+ coingeckoId: string;
32
33
  };
33
34
  ARB: {
34
35
  name: string;
@@ -37,6 +38,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
37
38
  addresses: {
38
39
  [x: number]: string;
39
40
  };
41
+ coingeckoId: string;
40
42
  };
41
43
  BAL: {
42
44
  name: string;
@@ -45,6 +47,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
45
47
  addresses: {
46
48
  [x: number]: string;
47
49
  };
50
+ coingeckoId: string;
48
51
  };
49
52
  BADGER: {
50
53
  name: string;
@@ -53,6 +56,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
53
56
  addresses: {
54
57
  [x: number]: string;
55
58
  };
59
+ coingeckoId: string;
56
60
  };
57
61
  BOBA: {
58
62
  name: string;
@@ -61,6 +65,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
61
65
  addresses: {
62
66
  [x: number]: string;
63
67
  };
68
+ coingeckoId: string;
64
69
  };
65
70
  DAI: {
66
71
  name: string;
@@ -69,6 +74,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
69
74
  addresses: {
70
75
  [x: number]: string;
71
76
  };
77
+ coingeckoId: string;
72
78
  };
73
79
  ETH: {
74
80
  name: string;
@@ -77,6 +83,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
77
83
  addresses: {
78
84
  [x: number]: string;
79
85
  };
86
+ coingeckoId: string;
80
87
  };
81
88
  LSK: {
82
89
  name: string;
@@ -85,6 +92,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
85
92
  addresses: {
86
93
  [x: number]: string;
87
94
  };
95
+ coingeckoId: string;
88
96
  };
89
97
  MATIC: {
90
98
  name: string;
@@ -93,6 +101,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
93
101
  addresses: {
94
102
  [x: number]: string;
95
103
  };
104
+ coingeckoId: string;
96
105
  };
97
106
  OP: {
98
107
  name: string;
@@ -101,14 +110,23 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
101
110
  addresses: {
102
111
  [x: number]: string;
103
112
  };
113
+ coingeckoId: string;
104
114
  };
105
115
  POOL: {
106
116
  name: string;
107
117
  symbol: string;
108
118
  decimals: number;
119
+ /**
120
+ * Returns the contract address for a given token symbol and chainId.
121
+ * @param symbol A case-insensitive token symbol.
122
+ * @param chainId The chainId to resolve the contract address for.
123
+ * @param tokenMapping A parameter to determine where to source token information. Defaults to the constants variant.
124
+ * @returns The contract address for the given token symbol and chainId, or undefined if the token symbol is not supported.
125
+ */
109
126
  addresses: {
110
127
  [x: number]: string;
111
128
  };
129
+ coingeckoId: string;
112
130
  };
113
131
  SNX: {
114
132
  name: string;
@@ -117,6 +135,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
117
135
  addresses: {
118
136
  [x: number]: string;
119
137
  };
138
+ coingeckoId: string;
120
139
  };
121
140
  UMA: {
122
141
  name: string;
@@ -125,6 +144,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
125
144
  addresses: {
126
145
  [x: number]: string;
127
146
  };
147
+ coingeckoId: string;
128
148
  };
129
149
  USDB: {
130
150
  name: string;
@@ -133,6 +153,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
133
153
  addresses: {
134
154
  [x: number]: string;
135
155
  };
156
+ coingeckoId: string;
136
157
  };
137
158
  USDC: {
138
159
  name: string;
@@ -141,6 +162,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
141
162
  addresses: {
142
163
  [x: number]: string;
143
164
  };
165
+ coingeckoId: string;
144
166
  };
145
167
  "USDC.e": {
146
168
  name: string;
@@ -149,6 +171,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
149
171
  addresses: {
150
172
  [x: number]: string;
151
173
  };
174
+ coingeckoId: string;
152
175
  };
153
176
  USDbC: {
154
177
  name: string;
@@ -157,6 +180,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
157
180
  addresses: {
158
181
  [x: number]: string;
159
182
  };
183
+ coingeckoId: string;
160
184
  };
161
185
  USDT: {
162
186
  name: string;
@@ -165,6 +189,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
165
189
  addresses: {
166
190
  [x: number]: string;
167
191
  };
192
+ coingeckoId: string;
168
193
  };
169
194
  WBTC: {
170
195
  name: string;
@@ -173,6 +198,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
173
198
  addresses: {
174
199
  [x: number]: string;
175
200
  };
201
+ coingeckoId: string;
176
202
  };
177
203
  WETH: {
178
204
  name: string;
@@ -181,6 +207,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
181
207
  addresses: {
182
208
  [x: number]: string;
183
209
  };
210
+ coingeckoId: string;
184
211
  };
185
212
  WMATIC: {
186
213
  name: string;
@@ -189,6 +216,7 @@ export declare const resolveContractFromSymbol: (symbol: string, chainId: string
189
216
  addresses: {
190
217
  [x: number]: string;
191
218
  };
219
+ coingeckoId: string;
192
220
  };
193
221
  }) => string | undefined;
194
222
  export declare function getTokenInformationFromAddress(address: string, tokenMapping?: {
@@ -199,6 +227,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
199
227
  addresses: {
200
228
  [x: number]: string;
201
229
  };
230
+ coingeckoId: string;
202
231
  };
203
232
  ARB: {
204
233
  name: string;
@@ -207,6 +236,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
207
236
  addresses: {
208
237
  [x: number]: string;
209
238
  };
239
+ coingeckoId: string;
210
240
  };
211
241
  BAL: {
212
242
  name: string;
@@ -215,6 +245,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
215
245
  addresses: {
216
246
  [x: number]: string;
217
247
  };
248
+ coingeckoId: string;
218
249
  };
219
250
  BADGER: {
220
251
  name: string;
@@ -223,6 +254,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
223
254
  addresses: {
224
255
  [x: number]: string;
225
256
  };
257
+ coingeckoId: string;
226
258
  };
227
259
  BOBA: {
228
260
  name: string;
@@ -231,6 +263,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
231
263
  addresses: {
232
264
  [x: number]: string;
233
265
  };
266
+ coingeckoId: string;
234
267
  };
235
268
  DAI: {
236
269
  name: string;
@@ -239,6 +272,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
239
272
  addresses: {
240
273
  [x: number]: string;
241
274
  };
275
+ coingeckoId: string;
242
276
  };
243
277
  ETH: {
244
278
  name: string;
@@ -247,6 +281,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
247
281
  addresses: {
248
282
  [x: number]: string;
249
283
  };
284
+ coingeckoId: string;
250
285
  };
251
286
  LSK: {
252
287
  name: string;
@@ -255,6 +290,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
255
290
  addresses: {
256
291
  [x: number]: string;
257
292
  };
293
+ coingeckoId: string;
258
294
  };
259
295
  MATIC: {
260
296
  name: string;
@@ -263,6 +299,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
263
299
  addresses: {
264
300
  [x: number]: string;
265
301
  };
302
+ coingeckoId: string;
266
303
  };
267
304
  OP: {
268
305
  name: string;
@@ -271,14 +308,23 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
271
308
  addresses: {
272
309
  [x: number]: string;
273
310
  };
311
+ coingeckoId: string;
274
312
  };
275
313
  POOL: {
276
314
  name: string;
277
315
  symbol: string;
278
316
  decimals: number;
317
+ /**
318
+ * Returns the contract address for a given token symbol and chainId.
319
+ * @param symbol A case-insensitive token symbol.
320
+ * @param chainId The chainId to resolve the contract address for.
321
+ * @param tokenMapping A parameter to determine where to source token information. Defaults to the constants variant.
322
+ * @returns The contract address for the given token symbol and chainId, or undefined if the token symbol is not supported.
323
+ */
279
324
  addresses: {
280
325
  [x: number]: string;
281
326
  };
327
+ coingeckoId: string;
282
328
  };
283
329
  SNX: {
284
330
  name: string;
@@ -287,6 +333,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
287
333
  addresses: {
288
334
  [x: number]: string;
289
335
  };
336
+ coingeckoId: string;
290
337
  };
291
338
  UMA: {
292
339
  name: string;
@@ -295,6 +342,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
295
342
  addresses: {
296
343
  [x: number]: string;
297
344
  };
345
+ coingeckoId: string;
298
346
  };
299
347
  USDB: {
300
348
  name: string;
@@ -303,6 +351,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
303
351
  addresses: {
304
352
  [x: number]: string;
305
353
  };
354
+ coingeckoId: string;
306
355
  };
307
356
  USDC: {
308
357
  name: string;
@@ -311,6 +360,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
311
360
  addresses: {
312
361
  [x: number]: string;
313
362
  };
363
+ coingeckoId: string;
314
364
  };
315
365
  "USDC.e": {
316
366
  name: string;
@@ -319,6 +369,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
319
369
  addresses: {
320
370
  [x: number]: string;
321
371
  };
372
+ coingeckoId: string;
322
373
  };
323
374
  USDbC: {
324
375
  name: string;
@@ -327,6 +378,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
327
378
  addresses: {
328
379
  [x: number]: string;
329
380
  };
381
+ coingeckoId: string;
330
382
  };
331
383
  USDT: {
332
384
  name: string;
@@ -335,6 +387,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
335
387
  addresses: {
336
388
  [x: number]: string;
337
389
  };
390
+ coingeckoId: string;
338
391
  };
339
392
  WBTC: {
340
393
  name: string;
@@ -343,6 +396,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
343
396
  addresses: {
344
397
  [x: number]: string;
345
398
  };
399
+ coingeckoId: string;
346
400
  };
347
401
  WETH: {
348
402
  name: string;
@@ -351,6 +405,7 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
351
405
  addresses: {
352
406
  [x: number]: string;
353
407
  };
408
+ coingeckoId: string;
354
409
  };
355
410
  WMATIC: {
356
411
  name: string;
@@ -359,8 +414,10 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
359
414
  addresses: {
360
415
  [x: number]: string;
361
416
  };
417
+ coingeckoId: string;
362
418
  };
363
419
  }): L1Token | undefined;
420
+ export declare function getCoingeckoTokenIdByAddress(contractAddress: string): string;
364
421
  /**
365
422
  * Retrieves the ERC20 balance for a given address and token address.
366
423
  * @param address The address to retrieve the balance for.
@@ -370,5 +427,6 @@ export declare function getTokenInformationFromAddress(address: string, tokenMap
370
427
  * @returns The balance of the given address for the given token address.
371
428
  */
372
429
  export declare function getTokenBalance(address: string, tokenAddress: string, signerOrProvider: SignerOrProvider, blockTag?: BlockTag): Promise<BigNumber>;
430
+ export declare function isBridgedUsdc(tokenSymbol: string): boolean;
373
431
  export {};
374
432
  //# sourceMappingURL=TokenUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TokenUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/TokenUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAY,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAMxC,KAAK,gBAAgB,GAAG,SAAS,CAAC,QAAQ,GAAG,MAAM,CAAC;AAEpD,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAI1G;AAED,eAAO,MAAM,mBAAmB,mBACd,MAAM;;aAMvB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAY7E;AAED;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,WAC5B,MAAM,WACL,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAEd,MAAM,GAAG,SAIX,CAAC;AAEF,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAoB,GAAG,OAAO,GAAG,SAAS,CAWrH;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,GAAE,QAAmB,GAC5B,OAAO,CAAC,SAAS,CAAC,CAGpB"}
1
+ {"version":3,"file":"TokenUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/TokenUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAY,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAMxC,KAAK,gBAAgB,GAAG,SAAS,CAAC,QAAQ,GAAG,MAAM,CAAC;AAEpD,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAI1G;AAED,eAAO,MAAM,mBAAmB,mBACd,MAAM;;aAMvB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAY7E;AAED;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,WAC5B,MAAM,WACL,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QATjB;;;;;;WAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAKA,MAAM,GAAG,SAIX,CAAC;AAEF,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAjB5E;;;;;;WAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAW6F,GAAG,OAAO,GAAG,SAAS,CAWrH;AAED,wBAAgB,4BAA4B,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAM5E;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,GAAE,QAAmB,GAC5B,OAAO,CAAC,SAAS,CAAC,CAGpB;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAI1D"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@across-protocol/sdk",
3
3
  "author": "UMA Team",
4
- "version": "3.1.11",
4
+ "version": "3.1.13",
5
5
  "license": "AGPL-3.0",
6
6
  "homepage": "https://docs.across.to/reference/sdk",
7
7
  "files": [
@@ -99,8 +99,8 @@
99
99
  },
100
100
  "dependencies": {
101
101
  "@across-protocol/across-token": "^1.0.0",
102
- "@across-protocol/constants": "^3.1.5",
103
- "@across-protocol/contracts": "^3.0.5",
102
+ "@across-protocol/constants": "^3.1.10",
103
+ "@across-protocol/contracts": "^3.0.6",
104
104
  "@eth-optimism/sdk": "^3.3.1",
105
105
  "@pinata/sdk": "^2.1.0",
106
106
  "@types/mocha": "^10.0.1",
@@ -302,6 +302,16 @@ export class SpokePoolClient extends BaseAbstractClient {
302
302
  return validateFillForDeposit(fill, depositWithMatchingDepositId) ? depositWithMatchingDepositId : undefined;
303
303
  }
304
304
 
305
+ /**
306
+ * Find a valid fill for a given deposit.
307
+ * @param deposit A deposit event.
308
+ * @returns A valid fill for the deposit, or undefined.
309
+ */
310
+ public getFillForDeposit(deposit: Deposit): FillWithBlock | undefined {
311
+ const fills = this.depositHashesToFills[this.getDepositHash(deposit)];
312
+ return fills?.find((fill) => validateFillForDeposit(fill, deposit));
313
+ }
314
+
305
315
  /**
306
316
  * Find the unfilled amount for a given deposit. This is the full deposit amount minus the total filled amount.
307
317
  * @param deposit The deposit to find the unfilled amount for.
@@ -1,7 +1,7 @@
1
1
  import axios, { AxiosError } from "axios";
2
2
  import assert from "assert";
3
3
  import get from "lodash.get";
4
- import { retry } from "../utils";
4
+ import { getCoingeckoTokenIdByAddress, retry } from "../utils";
5
5
  import { Logger } from "../relayFeeCalculator";
6
6
 
7
7
  export function msToS(ms: number) {
@@ -89,6 +89,32 @@ export class Coingecko {
89
89
  if (result.prices) return result.prices;
90
90
  throw new Error("Something went wrong fetching coingecko prices!");
91
91
  }
92
+
93
+ /**
94
+ * Get the current price of a token denominated in `currency`.
95
+ * @param contractAddress The L1 token address to fetch the price for.
96
+ * @param date A datestring in the format "dd-mm-yyyy" to fetch the price for.
97
+ * @param currency The currency to fetch the price in. Defaults to "usd".
98
+ * @returns The price of the token at the given date.
99
+ * @throws If today is selected and it is before 3am UTC or if the price is not found.
100
+ */
101
+ async getContractHistoricDayPrice(contractAddress: string, date: string, currency = "usd"): Promise<number> {
102
+ const coingeckoTokenIdentifier = getCoingeckoTokenIdByAddress(contractAddress);
103
+ assert(date, "Requires date string");
104
+ // Build the path for the Coingecko API request
105
+ const url = `coins/${coingeckoTokenIdentifier}/history`;
106
+ // Build the query parameters for the Coingecko API request
107
+ const queryParams = {
108
+ date,
109
+ localization: "false",
110
+ };
111
+ // Grab the result - parse out price, market cap, total volume, and timestamp
112
+ const result = await this.call(`${url}?${new URLSearchParams(queryParams).toString()}`);
113
+ const price = result?.market_data?.current_price?.[currency];
114
+ assert(price, `No price found for ${contractAddress} on ${date}`);
115
+ return price;
116
+ }
117
+
92
118
  getContractDetails(contract_address: string, platform_id = "ethereum") {
93
119
  return this.call(`coins/${platform_id}/contract/${contract_address.toLowerCase()}`);
94
120
  }
package/src/constants.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { constants as ethersConstants, BigNumber, utils } from "ethers";
2
-
3
2
  export {
3
+ ChainFamily,
4
4
  CHAIN_IDs,
5
5
  MAINNET_CHAIN_IDs,
6
6
  PUBLIC_NETWORKS,
@@ -51,3 +51,5 @@ export const DEFAULT_SIMULATED_RELAYER_ADDRESS_TEST = "0x9A8f92a830A5cB89a3816e3
51
51
  export const DEFAULT_ARWEAVE_STORAGE_ADDRESS = "Z6hjBM8FHu90lYWB8o5jR1dfX92FlV2WBaND9xgp8Lg";
52
52
 
53
53
  export const EMPTY_MESSAGE = "0x";
54
+
55
+ export const BRIDGED_USDC_SYMBOLS = ["USDC.e", "USDbC"];
@@ -33,6 +33,7 @@ export async function getGasPriceEstimate(
33
33
  [CHAIN_IDs.OPTIMISM]: ethereum.eip1559,
34
34
  [CHAIN_IDs.POLYGON]: polygon.gasStation,
35
35
  [CHAIN_IDs.ZK_SYNC]: ethereum.legacy,
36
+ [CHAIN_IDs.SCROLL]: ethereum.legacy,
36
37
  };
37
38
 
38
39
  let gasPriceFeed = gasPriceFeeds[chainId];
@@ -1,7 +1,7 @@
1
1
  import assert from "assert";
2
2
  import type { Block, Provider } from "@ethersproject/abstract-provider";
3
3
  import { clamp, sortedIndexBy } from "lodash";
4
- import { getNetworkName } from "./NetworkUtils";
4
+ import { chainIsOPStack, getNetworkName } from "./NetworkUtils";
5
5
  import { isDefined } from "./TypeGuards";
6
6
  import { getCurrentTime } from "./TimeUtils";
7
7
  import { CachingMechanismInterface } from "../interfaces";
@@ -34,12 +34,8 @@ const defaultHighBlockOffset = 10;
34
34
  const cacheTTL = 60 * 15;
35
35
  const now = getCurrentTime(); // Seed the cache with initial values.
36
36
  const blockTimes: { [chainId: number]: BlockTimeAverage } = {
37
- [CHAIN_IDs.BASE]: { average: 2, timestamp: now, blockRange: 1 },
38
- [CHAIN_IDs.BLAST]: { average: 2, timestamp: now, blockRange: 1 },
39
37
  [CHAIN_IDs.LINEA]: { average: 3, timestamp: now, blockRange: 1 },
40
- [CHAIN_IDs.LISK]: { average: 2, timestamp: now, blockRange: 1 },
41
38
  [CHAIN_IDs.MAINNET]: { average: 12.5, timestamp: now, blockRange: 1 },
42
- [CHAIN_IDs.MODE]: { average: 2, timestamp: now, blockRange: 1 },
43
39
  [CHAIN_IDs.OPTIMISM]: { average: 2, timestamp: now, blockRange: 1 },
44
40
  };
45
41
 
@@ -52,9 +48,15 @@ export async function averageBlockTime(
52
48
  { highBlock, highBlockOffset, blockRange }: Opts = {}
53
49
  ): Promise<Pick<BlockTimeAverage, "average" | "blockRange">> {
54
50
  // Does not block for StaticJsonRpcProvider.
55
- const chainId = (await provider.getNetwork()).chainId;
51
+ const { chainId } = await provider.getNetwork();
52
+
53
+ // OP stack chains inherit Optimism block times, but can be overridden.
54
+ // prettier-ignore
55
+ const cache = blockTimes[chainId]
56
+ ?? chainIsOPStack(chainId)
57
+ ? blockTimes[CHAIN_IDs.OPTIMISM]
58
+ : undefined;
56
59
 
57
- const cache = blockTimes[chainId];
58
60
  const now = getCurrentTime();
59
61
  if (isDefined(cache) && now < cache.timestamp + cacheTTL) {
60
62
  return { average: cache.average, blockRange: cache.blockRange };
@@ -1,4 +1,4 @@
1
- import { CHAIN_IDs, MAINNET_CHAIN_IDs, PUBLIC_NETWORKS, TESTNET_CHAIN_IDs } from "../constants";
1
+ import { ChainFamily, CHAIN_IDs, MAINNET_CHAIN_IDs, PUBLIC_NETWORKS, TESTNET_CHAIN_IDs } from "../constants";
2
2
 
3
3
  const hreNetworks: Record<number, string> = {
4
4
  666: "Hardhat1",
@@ -57,18 +57,7 @@ export function chainIsMatic(chainId: number): boolean {
57
57
  * @returns True if chainId is an OP stack, otherwise false.
58
58
  */
59
59
  export function chainIsOPStack(chainId: number): boolean {
60
- return [
61
- CHAIN_IDs.OPTIMISM,
62
- CHAIN_IDs.BASE,
63
- CHAIN_IDs.BLAST,
64
- CHAIN_IDs.LISK,
65
- CHAIN_IDs.MODE,
66
- CHAIN_IDs.OPTIMISM_SEPOLIA,
67
- CHAIN_IDs.BASE_SEPOLIA,
68
- CHAIN_IDs.BLAST_SEPOLIA,
69
- CHAIN_IDs.LISK_SEPOLIA,
70
- CHAIN_IDs.MODE_SEPOLIA,
71
- ].includes(chainId);
60
+ return PUBLIC_NETWORKS[chainId]?.family === ChainFamily.OP_STACK ?? false;
72
61
  }
73
62
 
74
63
  /**
@@ -89,6 +78,15 @@ export function chainIsLinea(chainId: number): boolean {
89
78
  return [CHAIN_IDs.LINEA].includes(chainId);
90
79
  }
91
80
 
81
+ /**
82
+ * Determines whether a chain ID has a corresponding hub pool contract.
83
+ * @param chainId Chain ID to evaluate.
84
+ * @returns True if chain corresponding to chainId has a hub pool implementation.
85
+ */
86
+ export function chainIsL1(chainId: number): boolean {
87
+ return [CHAIN_IDs.MAINNET, CHAIN_IDs.SEPOLIA].includes(chainId);
88
+ }
89
+
92
90
  /**
93
91
  * Determines whether a chain ID has the capacity for having its USDC bridged via CCTP.
94
92
  * @param chainId Chain ID to evaluate.
@@ -75,6 +75,14 @@ export function getTokenInformationFromAddress(address: string, tokenMapping = T
75
75
  : undefined;
76
76
  }
77
77
 
78
+ export function getCoingeckoTokenIdByAddress(contractAddress: string): string {
79
+ const token = getTokenInformationFromAddress(contractAddress);
80
+ if (!token) {
81
+ throw new Error(`Token with address ${contractAddress} not found in token mapping`);
82
+ }
83
+ return TOKEN_SYMBOLS_MAP[token.symbol as keyof typeof TOKEN_SYMBOLS_MAP].coingeckoId;
84
+ }
85
+
78
86
  /**
79
87
  * Retrieves the ERC20 balance for a given address and token address.
80
88
  * @param address The address to retrieve the balance for.
@@ -92,3 +100,9 @@ export function getTokenBalance(
92
100
  const token = ERC20__factory.connect(tokenAddress, signerOrProvider);
93
101
  return token.balanceOf(address, { blockTag });
94
102
  }
103
+
104
+ export function isBridgedUsdc(tokenSymbol: string): boolean {
105
+ return !!constants.BRIDGED_USDC_SYMBOLS.find(
106
+ (bridgedUsdcSymbol) => bridgedUsdcSymbol.toLowerCase() === tokenSymbol.toLowerCase()
107
+ );
108
+ }