@across-protocol/sdk 3.2.13 → 3.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.
Files changed (93) hide show
  1. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +30 -30
  2. package/dist/cjs/coingecko/Coingecko.d.ts +9 -1
  3. package/dist/cjs/coingecko/Coingecko.js +94 -46
  4. package/dist/cjs/coingecko/Coingecko.js.map +1 -1
  5. package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.d.ts +3 -0
  6. package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.js +21 -0
  7. package/dist/cjs/gasPriceOracle/adapters/arbitrum-viem.js.map +1 -0
  8. package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.d.ts +4 -0
  9. package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.js +26 -0
  10. package/dist/cjs/gasPriceOracle/adapters/ethereum-viem.js.map +1 -0
  11. package/dist/cjs/gasPriceOracle/adapters/polygon-viem.d.ts +3 -0
  12. package/dist/cjs/gasPriceOracle/adapters/polygon-viem.js +84 -0
  13. package/dist/cjs/gasPriceOracle/adapters/polygon-viem.js.map +1 -0
  14. package/dist/cjs/gasPriceOracle/oracle.d.ts +3 -1
  15. package/dist/cjs/gasPriceOracle/oracle.js +71 -4
  16. package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
  17. package/dist/cjs/gasPriceOracle/types.d.ts +3 -2
  18. package/dist/cjs/gasPriceOracle/util.d.ts +3 -3
  19. package/dist/cjs/gasPriceOracle/util.js +12 -1
  20. package/dist/cjs/gasPriceOracle/util.js.map +1 -1
  21. package/dist/cjs/providers/types.d.ts +3 -3
  22. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +7 -1
  23. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +13 -8
  24. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  25. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +8 -2
  26. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +4 -2
  27. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  28. package/dist/cjs/utils/common.d.ts +6 -1
  29. package/dist/cjs/utils/common.js +21 -17
  30. package/dist/cjs/utils/common.js.map +1 -1
  31. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +30 -30
  32. package/dist/esm/coingecko/Coingecko.d.ts +9 -1
  33. package/dist/esm/coingecko/Coingecko.js +96 -46
  34. package/dist/esm/coingecko/Coingecko.js.map +1 -1
  35. package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.d.ts +3 -0
  36. package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.js +20 -0
  37. package/dist/esm/gasPriceOracle/adapters/arbitrum-viem.js.map +1 -0
  38. package/dist/esm/gasPriceOracle/adapters/ethereum-viem.d.ts +4 -0
  39. package/dist/esm/gasPriceOracle/adapters/ethereum-viem.js +21 -0
  40. package/dist/esm/gasPriceOracle/adapters/ethereum-viem.js.map +1 -0
  41. package/dist/esm/gasPriceOracle/adapters/polygon-viem.d.ts +3 -0
  42. package/dist/esm/gasPriceOracle/adapters/polygon-viem.js +82 -0
  43. package/dist/esm/gasPriceOracle/adapters/polygon-viem.js.map +1 -0
  44. package/dist/esm/gasPriceOracle/oracle.d.ts +9 -1
  45. package/dist/esm/gasPriceOracle/oracle.js +82 -3
  46. package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
  47. package/dist/esm/gasPriceOracle/types.d.ts +3 -2
  48. package/dist/esm/gasPriceOracle/util.d.ts +3 -3
  49. package/dist/esm/gasPriceOracle/util.js +9 -0
  50. package/dist/esm/gasPriceOracle/util.js.map +1 -1
  51. package/dist/esm/providers/types.d.ts +3 -3
  52. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +12 -3
  53. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +18 -10
  54. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  55. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +8 -2
  56. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +4 -2
  57. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  58. package/dist/esm/utils/common.d.ts +10 -3
  59. package/dist/esm/utils/common.js +25 -19
  60. package/dist/esm/utils/common.js.map +1 -1
  61. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +30 -30
  62. package/dist/types/coingecko/Coingecko.d.ts +9 -1
  63. package/dist/types/coingecko/Coingecko.d.ts.map +1 -1
  64. package/dist/types/gasPriceOracle/adapters/arbitrum-viem.d.ts +4 -0
  65. package/dist/types/gasPriceOracle/adapters/arbitrum-viem.d.ts.map +1 -0
  66. package/dist/types/gasPriceOracle/adapters/ethereum-viem.d.ts +5 -0
  67. package/dist/types/gasPriceOracle/adapters/ethereum-viem.d.ts.map +1 -0
  68. package/dist/types/gasPriceOracle/adapters/polygon-viem.d.ts +4 -0
  69. package/dist/types/gasPriceOracle/adapters/polygon-viem.d.ts.map +1 -0
  70. package/dist/types/gasPriceOracle/oracle.d.ts +9 -1
  71. package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
  72. package/dist/types/gasPriceOracle/types.d.ts +3 -2
  73. package/dist/types/gasPriceOracle/types.d.ts.map +1 -1
  74. package/dist/types/gasPriceOracle/util.d.ts +3 -3
  75. package/dist/types/gasPriceOracle/util.d.ts.map +1 -1
  76. package/dist/types/providers/types.d.ts +3 -3
  77. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +12 -3
  78. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  79. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +8 -2
  80. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  81. package/dist/types/utils/common.d.ts +10 -3
  82. package/dist/types/utils/common.d.ts.map +1 -1
  83. package/package.json +3 -2
  84. package/src/coingecko/Coingecko.ts +94 -47
  85. package/src/gasPriceOracle/adapters/arbitrum-viem.ts +13 -0
  86. package/src/gasPriceOracle/adapters/ethereum-viem.ts +19 -0
  87. package/src/gasPriceOracle/adapters/polygon-viem.ts +86 -0
  88. package/src/gasPriceOracle/oracle.ts +69 -5
  89. package/src/gasPriceOracle/types.ts +4 -2
  90. package/src/gasPriceOracle/util.ts +12 -3
  91. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +19 -7
  92. package/src/relayFeeCalculator/relayFeeCalculator.ts +15 -12
  93. package/src/utils/common.ts +15 -6
@@ -1,13 +1,13 @@
1
1
  import { BigNumber } from "../../../utils";
2
2
  export declare const BundleDataSS: import("superstruct").Struct<{
3
3
  bundleDepositsV3: Record<string, Record<string, {
4
- depositId: number;
5
- originChainId: number;
6
4
  blockNumber: number;
7
5
  transactionIndex: number;
8
- logIndex: number;
9
6
  transactionHash: string;
7
+ logIndex: number;
10
8
  message: string;
9
+ depositId: number;
10
+ originChainId: number;
11
11
  inputToken: string;
12
12
  inputAmount: BigNumber;
13
13
  quoteTimestamp: number;
@@ -30,13 +30,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
30
30
  }[]>>;
31
31
  bundleFillsV3: Record<string, Record<string, {
32
32
  fills: {
33
- depositId: number;
34
- originChainId: number;
35
33
  blockNumber: number;
36
34
  transactionIndex: number;
37
- logIndex: number;
38
35
  transactionHash: string;
36
+ logIndex: number;
39
37
  message: string;
38
+ depositId: number;
39
+ originChainId: number;
40
40
  inputToken: string;
41
41
  inputAmount: BigNumber;
42
42
  quoteTimestamp: number;
@@ -63,13 +63,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
63
63
  totalRefundAmount: BigNumber;
64
64
  }>>;
65
65
  bundleSlowFillsV3: Record<string, Record<string, {
66
- depositId: number;
67
- originChainId: number;
68
66
  blockNumber: number;
69
67
  transactionIndex: number;
70
- logIndex: number;
71
68
  transactionHash: string;
69
+ logIndex: number;
72
70
  message: string;
71
+ depositId: number;
72
+ originChainId: number;
73
73
  inputToken: string;
74
74
  inputAmount: BigNumber;
75
75
  quoteTimestamp: number;
@@ -92,13 +92,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
92
92
  relayerFeePct?: BigNumber | undefined;
93
93
  }[]>>;
94
94
  expiredDepositsToRefundV3: Record<string, Record<string, {
95
- depositId: number;
96
- originChainId: number;
97
95
  blockNumber: number;
98
96
  transactionIndex: number;
99
- logIndex: number;
100
97
  transactionHash: string;
98
+ logIndex: number;
101
99
  message: string;
100
+ depositId: number;
101
+ originChainId: number;
102
102
  inputToken: string;
103
103
  inputAmount: BigNumber;
104
104
  quoteTimestamp: number;
@@ -120,13 +120,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
120
120
  relayerFeePct?: BigNumber | undefined;
121
121
  }[]>>;
122
122
  unexecutableSlowFills: Record<string, Record<string, {
123
- depositId: number;
124
- originChainId: number;
125
123
  blockNumber: number;
126
124
  transactionIndex: number;
127
- logIndex: number;
128
125
  transactionHash: string;
126
+ logIndex: number;
129
127
  message: string;
128
+ depositId: number;
129
+ originChainId: number;
130
130
  inputToken: string;
131
131
  inputAmount: BigNumber;
132
132
  quoteTimestamp: number;
@@ -152,13 +152,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
152
152
  }, {
153
153
  bundleBlockRanges: import("superstruct").Struct<number[][], import("superstruct").Struct<number[], import("superstruct").Struct<number, null>>>;
154
154
  bundleDepositsV3: import("superstruct").Struct<Record<string, Record<string, {
155
- depositId: number;
156
- originChainId: number;
157
155
  blockNumber: number;
158
156
  transactionIndex: number;
159
- logIndex: number;
160
157
  transactionHash: string;
158
+ logIndex: number;
161
159
  message: string;
160
+ depositId: number;
161
+ originChainId: number;
162
162
  inputToken: string;
163
163
  inputAmount: BigNumber;
164
164
  quoteTimestamp: number;
@@ -180,13 +180,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
180
180
  relayerFeePct?: BigNumber | undefined;
181
181
  }[]>>, null>;
182
182
  expiredDepositsToRefundV3: import("superstruct").Struct<Record<string, Record<string, {
183
- depositId: number;
184
- originChainId: number;
185
183
  blockNumber: number;
186
184
  transactionIndex: number;
187
- logIndex: number;
188
185
  transactionHash: string;
186
+ logIndex: number;
189
187
  message: string;
188
+ depositId: number;
189
+ originChainId: number;
190
190
  inputToken: string;
191
191
  inputAmount: BigNumber;
192
192
  quoteTimestamp: number;
@@ -208,13 +208,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
208
208
  relayerFeePct?: BigNumber | undefined;
209
209
  }[]>>, null>;
210
210
  unexecutableSlowFills: import("superstruct").Struct<Record<string, Record<string, {
211
- depositId: number;
212
- originChainId: number;
213
211
  blockNumber: number;
214
212
  transactionIndex: number;
215
- logIndex: number;
216
213
  transactionHash: string;
214
+ logIndex: number;
217
215
  message: string;
216
+ depositId: number;
217
+ originChainId: number;
218
218
  inputToken: string;
219
219
  inputAmount: BigNumber;
220
220
  quoteTimestamp: number;
@@ -237,13 +237,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
237
237
  relayerFeePct?: BigNumber | undefined;
238
238
  }[]>>, null>;
239
239
  bundleSlowFillsV3: import("superstruct").Struct<Record<string, Record<string, {
240
- depositId: number;
241
- originChainId: number;
242
240
  blockNumber: number;
243
241
  transactionIndex: number;
244
- logIndex: number;
245
242
  transactionHash: string;
243
+ logIndex: number;
246
244
  message: string;
245
+ depositId: number;
246
+ originChainId: number;
247
247
  inputToken: string;
248
248
  inputAmount: BigNumber;
249
249
  quoteTimestamp: number;
@@ -267,13 +267,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
267
267
  }[]>>, null>;
268
268
  bundleFillsV3: import("superstruct").Struct<Record<string, Record<string, {
269
269
  fills: {
270
- depositId: number;
271
- originChainId: number;
272
270
  blockNumber: number;
273
271
  transactionIndex: number;
274
- logIndex: number;
275
272
  transactionHash: string;
273
+ logIndex: number;
276
274
  message: string;
275
+ depositId: number;
276
+ originChainId: number;
277
277
  inputToken: string;
278
278
  inputAmount: BigNumber;
279
279
  quoteTimestamp: number;
@@ -11,6 +11,10 @@ export type CoinGeckoPrice = {
11
11
  timestamp: number;
12
12
  price: number;
13
13
  };
14
+ type CGTokenPrice = {
15
+ [currency: string]: number;
16
+ last_updated_at: number;
17
+ };
14
18
  export declare class Coingecko {
15
19
  private readonly host;
16
20
  private readonly proHost;
@@ -37,13 +41,17 @@ export declare class Coingecko {
37
41
  */
38
42
  getContractHistoricDayPrice(contractAddress: string, date: string, currency?: string): Promise<number>;
39
43
  getContractDetails(contract_address: string, platform_id?: string): Promise<any>;
40
- getCurrentPriceByContract(contract_address: string, currency?: string, platform_id?: string): Promise<[string, number]>;
44
+ getCurrentPriceByContract(contractAddress: string, currency?: string, platform_id?: string): Promise<[string, number]>;
45
+ getCurrentPriceById(contractAddress: string, currency?: string, platform_id?: string): Promise<[string, number]>;
41
46
  getContractPrices(addresses: Array<string>, currency?: string, platform_id?: string): Promise<CoinGeckoPrice[]>;
42
47
  getPlatforms(): Promise<CoinGeckoAssetPlatform[]>;
43
48
  call(path: string): Promise<any>;
44
49
  protected getPriceCache(currency: string, platform_id: string): {
45
50
  [addr: string]: CoinGeckoPrice;
46
51
  };
52
+ protected getCachedAddressPrice(contractAddress: string, currency: string, platform_id: string): CoinGeckoPrice | undefined;
53
+ protected updatePriceCache(cgPrice: CGTokenPrice, contractAddress: string, currency: string, platform_id: string): void;
47
54
  private _callBasic;
48
55
  private _callPro;
49
56
  }
57
+ export {};
@@ -103,39 +103,59 @@ var Coingecko = /** @class */ (function () {
103
103
  if (platform_id === void 0) { platform_id = "ethereum"; }
104
104
  return this.call("coins/".concat(platform_id, "/contract/").concat(contract_address.toLowerCase()));
105
105
  };
106
- Coingecko.prototype.getCurrentPriceByContract = function (contract_address, currency, platform_id) {
106
+ Coingecko.prototype.getCurrentPriceByContract = function (contractAddress, currency, platform_id) {
107
107
  if (currency === void 0) { currency = "usd"; }
108
108
  if (platform_id === void 0) { platform_id = "ethereum"; }
109
109
  return __awaiter(this, void 0, void 0, function () {
110
- var priceCache, now, tokenPrice;
110
+ var priceCache, tokenPrice;
111
111
  return __generator(this, function (_a) {
112
112
  switch (_a.label) {
113
113
  case 0:
114
114
  priceCache = this.getPriceCache(currency, platform_id);
115
- now = msToS(Date.now());
116
- tokenPrice = priceCache[contract_address];
117
- if (!(tokenPrice === undefined || tokenPrice.timestamp + this.maxPriceAge <= now)) return [3 /*break*/, 2];
118
- if (this.maxPriceAge > 0) {
115
+ tokenPrice = this.getCachedAddressPrice(contractAddress, currency, platform_id);
116
+ if (!(tokenPrice === undefined)) return [3 /*break*/, 2];
117
+ return [4 /*yield*/, this.getContractPrices([contractAddress], currency, platform_id)];
118
+ case 1:
119
+ _a.sent();
120
+ tokenPrice = priceCache[contractAddress];
121
+ _a.label = 2;
122
+ case 2:
123
+ assert(tokenPrice !== undefined);
124
+ return [2 /*return*/, [tokenPrice.timestamp.toString(), tokenPrice.price]];
125
+ }
126
+ });
127
+ });
128
+ };
129
+ Coingecko.prototype.getCurrentPriceById = function (contractAddress, currency, platform_id) {
130
+ if (currency === void 0) { currency = "usd"; }
131
+ if (platform_id === void 0) { platform_id = "ethereum"; }
132
+ return __awaiter(this, void 0, void 0, function () {
133
+ var priceCache, tokenPrice, coingeckoId, result, cgPrice, errMsg;
134
+ return __generator(this, function (_a) {
135
+ switch (_a.label) {
136
+ case 0:
137
+ priceCache = this.getPriceCache(currency, platform_id);
138
+ tokenPrice = this.getCachedAddressPrice(contractAddress, currency, platform_id);
139
+ if (!(tokenPrice === undefined)) return [3 /*break*/, 2];
140
+ coingeckoId = getCoingeckoTokenIdByAddress(contractAddress);
141
+ return [4 /*yield*/, this.call("simple/price?ids=".concat(coingeckoId, "&vs_currencies=").concat(currency, "&include_last_updated_at=true"))];
142
+ case 1:
143
+ result = _a.sent();
144
+ cgPrice = result === null || result === void 0 ? void 0 : result[coingeckoId];
145
+ if (cgPrice === undefined || !(cgPrice === null || cgPrice === void 0 ? void 0 : cgPrice[currency])) {
146
+ errMsg = "No price found for ".concat(coingeckoId);
119
147
  this.logger.debug({
120
- at: "Coingecko#getCurrentPriceByContract",
121
- message: "Cache miss on ".concat(platform_id, "/").concat(currency, " for ").concat(contract_address),
122
- maxPriceAge: this.maxPriceAge,
123
- tokenPrice: tokenPrice,
148
+ at: "Coingecko#getCurrentPriceById",
149
+ message: errMsg,
124
150
  });
151
+ throw new Error(errMsg);
125
152
  }
126
- return [4 /*yield*/, this.getContractPrices([contract_address], currency, platform_id)];
127
- case 1:
128
- _a.sent();
129
- tokenPrice = priceCache[contract_address];
130
- return [3 /*break*/, 3];
153
+ else {
154
+ this.updatePriceCache(cgPrice, contractAddress, currency, platform_id);
155
+ }
156
+ _a.label = 2;
131
157
  case 2:
132
- this.logger.debug({
133
- at: "Coingecko#getCurrentPriceByContract",
134
- message: "Cache hit on token ".concat(contract_address, " (age ").concat(now - tokenPrice.timestamp, " S)."),
135
- price: tokenPrice,
136
- });
137
- _a.label = 3;
138
- case 3:
158
+ tokenPrice = priceCache[contractAddress];
139
159
  assert(tokenPrice !== undefined);
140
160
  return [2 /*return*/, [tokenPrice.timestamp.toString(), tokenPrice.price]];
141
161
  }
@@ -148,7 +168,7 @@ var Coingecko = /** @class */ (function () {
148
168
  if (currency === void 0) { currency = "usd"; }
149
169
  if (platform_id === void 0) { platform_id = "ethereum"; }
150
170
  return __awaiter(this, void 0, void 0, function () {
151
- var priceCache, contract_addresses, result, err_1, errMsg, updated;
171
+ var priceCache, contract_addresses, result, err_1, errMsg;
152
172
  var _this = this;
153
173
  return __generator(this, function (_a) {
154
174
  switch (_a.label) {
@@ -180,13 +200,14 @@ var Coingecko = /** @class */ (function () {
180
200
  err_1 = _a.sent();
181
201
  errMsg = "Failed to retrieve ".concat(platform_id, "/").concat(currency, " prices (").concat(err_1, ")");
182
202
  this.logger.debug({
183
- at: "Coingecko#getCurrentPriceByContract",
203
+ at: "Coingecko#getContractPrices",
184
204
  message: errMsg,
185
205
  tokens: contract_addresses,
186
206
  });
187
207
  throw new Error(errMsg);
188
208
  case 4:
189
- updated = [];
209
+ // Note: contract_addresses is a reliable reference for the price lookup.
210
+ // priceCache might have been updated subsequently by concurrent price requests.
190
211
  contract_addresses.forEach(function (addr) {
191
212
  var cgPrice = result[addr.toLowerCase()];
192
213
  if (cgPrice === undefined) {
@@ -195,29 +216,10 @@ var Coingecko = /** @class */ (function () {
195
216
  message: "Token ".concat(addr, " not included in CoinGecko response."),
196
217
  });
197
218
  }
198
- else if (cgPrice.last_updated_at > priceCache[addr].timestamp) {
199
- priceCache[addr] = {
200
- address: addr,
201
- price: cgPrice[currency],
202
- timestamp: cgPrice.last_updated_at,
203
- };
204
- updated.push(addr);
205
- }
206
- else if (cgPrice.last_updated_at === priceCache[addr].timestamp) {
207
- _this.logger.debug({
208
- at: "Coingecko#getContractPrices",
209
- message: "No new price available for token ".concat(addr, "."),
210
- token: cgPrice,
211
- });
219
+ else {
220
+ _this.updatePriceCache(cgPrice, addr, currency, platform_id);
212
221
  }
213
222
  });
214
- if (updated.length > 0) {
215
- this.logger.debug({
216
- at: "Coingecko#updatePriceCache",
217
- message: "Updated ".concat(platform_id, "/").concat(currency, " token price cache."),
218
- tokens: updated,
219
- });
220
- }
221
223
  return [2 /*return*/, addresses.map(function (addr) { return priceCache[addr]; })];
222
224
  }
223
225
  });
@@ -264,6 +266,54 @@ var Coingecko = /** @class */ (function () {
264
266
  this.prices[platform_id][currency] = {};
265
267
  return this.prices[platform_id][currency];
266
268
  };
269
+ Coingecko.prototype.getCachedAddressPrice = function (contractAddress, currency, platform_id) {
270
+ var priceCache = this.getPriceCache(currency, platform_id);
271
+ var now = msToS(Date.now());
272
+ var tokenPrice = priceCache[contractAddress];
273
+ if (tokenPrice === undefined || tokenPrice.timestamp + this.maxPriceAge <= now) {
274
+ if (this.maxPriceAge > 0) {
275
+ this.logger.debug({
276
+ at: "Coingecko#getCachedAddressPrice",
277
+ message: "Cache miss on ".concat(platform_id, "/").concat(currency, " for ").concat(contractAddress),
278
+ maxPriceAge: this.maxPriceAge,
279
+ tokenPrice: tokenPrice,
280
+ });
281
+ }
282
+ return undefined;
283
+ }
284
+ else {
285
+ this.logger.debug({
286
+ at: "Coingecko#getCachedAddressPrice",
287
+ message: "Cache hit on token ".concat(contractAddress, " (age ").concat(now - tokenPrice.timestamp, " S)."),
288
+ price: tokenPrice,
289
+ });
290
+ return tokenPrice;
291
+ }
292
+ };
293
+ Coingecko.prototype.updatePriceCache = function (cgPrice, contractAddress, currency, platform_id) {
294
+ var priceCache = this.getPriceCache(currency, platform_id);
295
+ if (priceCache[contractAddress] === undefined) {
296
+ priceCache[contractAddress] = { address: contractAddress, price: 0, timestamp: 0 };
297
+ }
298
+ if (cgPrice.last_updated_at > priceCache[contractAddress].timestamp) {
299
+ priceCache[contractAddress] = {
300
+ address: contractAddress,
301
+ price: cgPrice[currency],
302
+ timestamp: cgPrice.last_updated_at,
303
+ };
304
+ this.logger.debug({
305
+ at: "Coingecko#updatePriceCache",
306
+ message: "Updated ".concat(platform_id, "/").concat(currency, "/").concat(contractAddress, " token price cache."),
307
+ });
308
+ }
309
+ else {
310
+ this.logger.debug({
311
+ at: "Coingecko#updatePriceCache",
312
+ message: "No new price available for token ".concat(contractAddress, "."),
313
+ token: cgPrice,
314
+ });
315
+ }
316
+ };
267
317
  Coingecko.prototype._callBasic = function (path, timeout) {
268
318
  return __awaiter(this, void 0, void 0, function () {
269
319
  var url, result, err_3, msg;
@@ -1 +1 @@
1
- {"version":3,"file":"Coingecko.js","sourceRoot":"","sources":["../../../src/coingecko/Coingecko.ts"],"names":[],"mappings":";AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,EAAE,4BAA4B,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAG/D,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI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KAAG,EAAE,qBAAqB,EAAE,GAAG,CAAC,KAAG,EAAE,qBAAqB,EAAG,KAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;wBAC1G,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;;;;;KAExB;IACH,gBAAC;AAAD,CAAC,AAxTD,IAwTC"}
@@ -0,0 +1,3 @@
1
+ import { PublicClient } from "viem";
2
+ import { InternalGasPriceEstimate } from "../types";
3
+ export declare function eip1559(provider: PublicClient, _chainId: number): Promise<InternalGasPriceEstimate>;
@@ -0,0 +1,20 @@
1
+ import { __awaiter, __generator } from "tslib";
2
+ var MAX_PRIORITY_FEE_PER_GAS = BigInt(1);
3
+ // Arbitrum Nitro implements EIP-1559 pricing, but the priority fee is always refunded to the caller.
4
+ // Swap it for 1 Wei to avoid inaccurate transaction cost estimates.
5
+ // Reference: https://developer.arbitrum.io/faqs/gas-faqs#q-priority
6
+ export function eip1559(provider, _chainId) {
7
+ return __awaiter(this, void 0, void 0, function () {
8
+ var _a, _maxFeePerGas, maxPriorityFeePerGas, maxFeePerGas;
9
+ return __generator(this, function (_b) {
10
+ switch (_b.label) {
11
+ case 0: return [4 /*yield*/, provider.estimateFeesPerGas()];
12
+ case 1:
13
+ _a = _b.sent(), _maxFeePerGas = _a.maxFeePerGas, maxPriorityFeePerGas = _a.maxPriorityFeePerGas;
14
+ maxFeePerGas = BigInt(_maxFeePerGas) - maxPriorityFeePerGas + MAX_PRIORITY_FEE_PER_GAS;
15
+ return [2 /*return*/, { maxFeePerGas: maxFeePerGas, maxPriorityFeePerGas: MAX_PRIORITY_FEE_PER_GAS }];
16
+ }
17
+ });
18
+ });
19
+ }
20
+ //# sourceMappingURL=arbitrum-viem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arbitrum-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/arbitrum-viem.ts"],"names":[],"mappings":";AAGA,IAAM,wBAAwB,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAE3C,qGAAqG;AACrG,oEAAoE;AACpE,oEAAoE;AACpE,MAAM,UAAgB,OAAO,CAAC,QAAsB,EAAE,QAAgB;;;;;wBACN,qBAAM,QAAQ,CAAC,kBAAkB,EAAE,EAAA;;oBAA3F,KAAwD,SAAmC,EAA3E,aAAa,kBAAA,EAAE,oBAAoB,0BAAA;oBACnD,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,oBAAoB,GAAG,wBAAwB,CAAC;oBAC7F,sBAAO,EAAE,YAAY,cAAA,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,EAAC;;;;CACzE"}
@@ -0,0 +1,4 @@
1
+ import { PublicClient } from "viem";
2
+ import { InternalGasPriceEstimate } from "../types";
3
+ export declare function eip1559(provider: PublicClient, _chainId: number): Promise<InternalGasPriceEstimate>;
4
+ export declare function legacy(provider: PublicClient, _chainId: number, _test?: number): Promise<InternalGasPriceEstimate>;
@@ -0,0 +1,21 @@
1
+ import { __awaiter, __generator } from "tslib";
2
+ export function eip1559(provider, _chainId) {
3
+ return provider.estimateFeesPerGas();
4
+ }
5
+ export function legacy(provider, _chainId, _test) {
6
+ return __awaiter(this, void 0, void 0, function () {
7
+ var gasPrice;
8
+ return __generator(this, function (_a) {
9
+ switch (_a.label) {
10
+ case 0: return [4 /*yield*/, provider.getGasPrice()];
11
+ case 1:
12
+ gasPrice = _a.sent();
13
+ return [2 /*return*/, {
14
+ maxFeePerGas: gasPrice,
15
+ maxPriorityFeePerGas: BigInt(0),
16
+ }];
17
+ }
18
+ });
19
+ });
20
+ }
21
+ //# sourceMappingURL=ethereum-viem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ethereum-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/ethereum-viem.ts"],"names":[],"mappings":";AAGA,MAAM,UAAU,OAAO,CAAC,QAAsB,EAAE,QAAgB;IAC9D,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,UAAgB,MAAM,CAC1B,QAAsB,EACtB,QAAgB,EAChB,KAAc;;;;;wBAEG,qBAAM,QAAQ,CAAC,WAAW,EAAE,EAAA;;oBAAvC,QAAQ,GAAG,SAA4B;oBAE7C,sBAAO;4BACL,YAAY,EAAE,QAAQ;4BACtB,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC;yBAChC,EAAC;;;;CACH"}
@@ -0,0 +1,3 @@
1
+ import { PublicClient } from "viem";
2
+ import { InternalGasPriceEstimate } from "../types";
3
+ export declare function gasStation(provider: PublicClient, chainId: number): Promise<InternalGasPriceEstimate>;
@@ -0,0 +1,82 @@
1
+ import { __awaiter, __extends, __generator } from "tslib";
2
+ import { BaseHTTPAdapter } from "../../priceClient/adapters/baseAdapter";
3
+ import { isDefined } from "../../utils";
4
+ import { CHAIN_IDs } from "../../constants";
5
+ import { gasPriceError } from "../util";
6
+ import { eip1559 } from "./ethereum-viem";
7
+ var POLYGON = CHAIN_IDs.POLYGON;
8
+ var GWEI = BigInt(1000000000);
9
+ var PolygonGasStation = /** @class */ (function (_super) {
10
+ __extends(PolygonGasStation, _super);
11
+ function PolygonGasStation(_a) {
12
+ var _this = this;
13
+ var _b = _a === void 0 ? {} : _a, _c = _b.chainId, chainId = _c === void 0 ? POLYGON : _c, host = _b.host, _d = _b.timeout, timeout = _d === void 0 ? 1500 : _d, _e = _b.retries, retries = _e === void 0 ? 1 : _e;
14
+ host = (host !== null && host !== void 0 ? host : chainId === POLYGON) ? "gasstation.polygon.technology" : "gasstation-testnet.polygon.technology";
15
+ _this = _super.call(this, "Polygon Gas Station", host, { timeout: timeout, retries: retries }) || this;
16
+ _this.chainId = chainId;
17
+ return _this;
18
+ }
19
+ PolygonGasStation.prototype.getFeeData = function (strategy) {
20
+ if (strategy === void 0) { strategy = "fast"; }
21
+ return __awaiter(this, void 0, void 0, function () {
22
+ var gas, gasPrice, maxPriorityFeePerGas, maxFeePerGas;
23
+ return __generator(this, function (_a) {
24
+ switch (_a.label) {
25
+ case 0: return [4 /*yield*/, this.query("v2", {})];
26
+ case 1:
27
+ gas = _a.sent();
28
+ gasPrice = gas === null || gas === void 0 ? void 0 : gas[strategy];
29
+ if (!this.isPolygon1559GasPrice(gasPrice)) {
30
+ // @todo: generalise gasPriceError() to accept a reason/cause?
31
+ gasPriceError("getFeeData()", this.chainId, gasPrice);
32
+ }
33
+ maxPriorityFeePerGas = BigInt(gasPrice.maxPriorityFee) * GWEI;
34
+ maxFeePerGas = BigInt(gasPrice.maxFee) * GWEI;
35
+ return [2 /*return*/, { maxPriorityFeePerGas: maxPriorityFeePerGas, maxFeePerGas: maxFeePerGas }];
36
+ }
37
+ });
38
+ });
39
+ };
40
+ PolygonGasStation.prototype.isPolygon1559GasPrice = function (gasPrice) {
41
+ if (!isDefined(gasPrice)) {
42
+ return false;
43
+ }
44
+ var _gasPrice = gasPrice;
45
+ return [_gasPrice.maxPriorityFee, _gasPrice.maxFee].every(function (field) { return ["number", "string"].includes(typeof field); });
46
+ };
47
+ return PolygonGasStation;
48
+ }(BaseHTTPAdapter));
49
+ export function gasStation(provider, chainId) {
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ var gasStation, maxPriorityFeePerGas, maxFeePerGas, err_1, minPriorityFee, priorityDelta;
52
+ var _a, _b;
53
+ return __generator(this, function (_c) {
54
+ switch (_c.label) {
55
+ case 0:
56
+ gasStation = new PolygonGasStation({ chainId: chainId, timeout: 2000, retries: 0 });
57
+ _c.label = 1;
58
+ case 1:
59
+ _c.trys.push([1, 3, , 5]);
60
+ return [4 /*yield*/, gasStation.getFeeData()];
61
+ case 2:
62
+ (_a = _c.sent(), maxPriorityFeePerGas = _a.maxPriorityFeePerGas, maxFeePerGas = _a.maxFeePerGas);
63
+ return [3 /*break*/, 5];
64
+ case 3:
65
+ err_1 = _c.sent();
66
+ return [4 /*yield*/, eip1559(provider, chainId)];
67
+ case 4:
68
+ // Fall back to the RPC provider. May be less accurate.
69
+ (_b = _c.sent(), maxPriorityFeePerGas = _b.maxPriorityFeePerGas, maxFeePerGas = _b.maxFeePerGas);
70
+ minPriorityFee = BigInt(30) * GWEI;
71
+ if (minPriorityFee > maxPriorityFeePerGas) {
72
+ priorityDelta = minPriorityFee - maxPriorityFeePerGas;
73
+ maxPriorityFeePerGas = minPriorityFee;
74
+ maxFeePerGas = maxFeePerGas + priorityDelta;
75
+ }
76
+ return [3 /*break*/, 5];
77
+ case 5: return [2 /*return*/, { maxPriorityFeePerGas: maxPriorityFeePerGas, maxFeePerGas: maxFeePerGas }];
78
+ }
79
+ });
80
+ });
81
+ }
82
+ //# sourceMappingURL=polygon-viem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polygon-viem.js","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/polygon-viem.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAuB,MAAM,wCAAwC,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAqBlC,IAAA,OAAO,GAAK,SAAS,QAAd,CAAe;AAE9B,IAAM,IAAI,GAAG,MAAM,CAAC,UAAa,CAAC,CAAC;AACnC;IAAgC,qCAAe;IAG7C,2BAAY,EAA6E;QAAzF,iBAKC;YALW,qBAA2E,EAAE,KAAA,EAA3E,eAAiB,EAAjB,OAAO,mBAAG,OAAO,KAAA,EAAE,IAAI,UAAA,EAAE,eAAc,EAAd,OAAO,mBAAG,IAAI,KAAA,EAAE,eAAW,EAAX,OAAO,mBAAG,CAAC,KAAA;QAChE,IAAI,GAAG,CAAA,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,OAAO,KAAK,OAAO,EAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,uCAAuC,CAAC;gBAE/G,kBAAM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EAAE,OAAe;;;;;;;oBAChE,UAAU,GAAG,IAAI,iBAAiB,CAAC,EAAE,OAAO,SAAA,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;;;;oBAIrC,qBAAM,UAAU,CAAC,UAAU,EAAE,EAAA;;oBAAvE,CAAC,KAAyC,SAA6B,EAApE,oBAAoB,0BAAA,EAAE,YAAY,kBAAA,CAAmC,CAAC;;;;oBAG/B,qBAAM,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAA;;oBAD1E,uDAAuD;oBACvD,CAAC,KAAyC,SAAgC,EAAvE,oBAAoB,0BAAA,EAAE,YAAY,kBAAA,CAAsC,CAAC;oBAItE,cAAc,GAAG,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;oBACzC,IAAI,cAAc,GAAG,oBAAoB,EAAE;wBACnC,aAAa,GAAG,cAAc,GAAG,oBAAoB,CAAC;wBAC5D,oBAAoB,GAAG,cAAc,CAAC;wBACtC,YAAY,GAAG,YAAY,GAAG,aAAa,CAAC;qBAC7C;;wBAGH,sBAAO,EAAE,oBAAoB,sBAAA,EAAE,YAAY,cAAA,EAAE,EAAC;;;;CAC/C"}
@@ -1,3 +1,4 @@
1
+ import { Transport } from "viem";
1
2
  import { providers } from "ethers";
2
3
  import { GasPriceEstimate } from "./types";
3
4
  /**
@@ -7,4 +8,11 @@ import { GasPriceEstimate } from "./types";
7
8
  * @param legacyFallback In the case of an unrecognised chain, fall back to type 0 gas estimation.
8
9
  * @returns Am object of type GasPriceEstimate.
9
10
  */
10
- export declare function getGasPriceEstimate(provider: providers.Provider, chainId?: number, legacyFallback?: boolean): Promise<GasPriceEstimate>;
11
+ export declare function getGasPriceEstimate(provider: providers.Provider, chainId?: number, transport?: Transport, legacyFallback?: boolean): Promise<GasPriceEstimate>;
12
+ /**
13
+ * Provide an estimate for the current gas price for a particular chain.
14
+ * @param providerOrChainId A valid ethers provider or a chain ID.
15
+ * @param transport An optional transport object for custom gas price retrieval.
16
+ * @returns Am object of type GasPriceEstimate.
17
+ */
18
+ export declare function getViemGasPriceEstimate(providerOrChainId: providers.Provider | number, transport?: Transport): Promise<GasPriceEstimate>;