@across-protocol/sdk 3.2.11-beta.1 → 3.2.11

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 (81) hide show
  1. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +0 -2
  2. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  3. package/dist/cjs/gasPriceOracle/oracle.js +0 -1
  4. package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
  5. package/dist/cjs/providers/retryProvider.d.ts +1 -0
  6. package/dist/cjs/providers/retryProvider.js +43 -6
  7. package/dist/cjs/providers/retryProvider.js.map +1 -1
  8. package/dist/cjs/providers/types.d.ts +28 -0
  9. package/dist/cjs/providers/types.js +15 -0
  10. package/dist/cjs/providers/types.js.map +1 -1
  11. package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +0 -27
  12. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +0 -4
  13. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  14. package/dist/cjs/relayFeeCalculator/chain-queries/polygon.d.ts +0 -27
  15. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +0 -27
  16. package/dist/cjs/utils/NetworkUtils.d.ts +0 -2
  17. package/dist/cjs/utils/NetworkUtils.js +1 -10
  18. package/dist/cjs/utils/NetworkUtils.js.map +1 -1
  19. package/dist/cjs/utils/TokenUtils.d.ts +0 -54
  20. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +1 -1
  21. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  22. package/dist/esm/clients/SpokePoolClient.d.ts +1 -1
  23. package/dist/esm/clients/SpokePoolClient.js +1 -1
  24. package/dist/esm/clients/mocks/MockSpokePoolClient.js +0 -2
  25. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  26. package/dist/esm/gasPriceOracle/oracle.js +0 -1
  27. package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
  28. package/dist/esm/providers/retryProvider.d.ts +1 -0
  29. package/dist/esm/providers/retryProvider.js +49 -6
  30. package/dist/esm/providers/retryProvider.js.map +1 -1
  31. package/dist/esm/providers/types.d.ts +28 -0
  32. package/dist/esm/providers/types.js +18 -1
  33. package/dist/esm/providers/types.js.map +1 -1
  34. package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +0 -27
  35. package/dist/esm/relayFeeCalculator/chain-queries/factory.js +2 -5
  36. package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  37. package/dist/esm/relayFeeCalculator/chain-queries/polygon.d.ts +0 -27
  38. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +0 -27
  39. package/dist/esm/utils/NetworkUtils.d.ts +0 -12
  40. package/dist/esm/utils/NetworkUtils.js +0 -17
  41. package/dist/esm/utils/NetworkUtils.js.map +1 -1
  42. package/dist/esm/utils/SpokeUtils.d.ts +1 -1
  43. package/dist/esm/utils/SpokeUtils.js +1 -1
  44. package/dist/esm/utils/TokenUtils.d.ts +30 -72
  45. package/dist/types/clients/SpokePoolClient.d.ts +1 -1
  46. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
  47. package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
  48. package/dist/types/providers/retryProvider.d.ts +1 -0
  49. package/dist/types/providers/retryProvider.d.ts.map +1 -1
  50. package/dist/types/providers/types.d.ts +28 -0
  51. package/dist/types/providers/types.d.ts.map +1 -1
  52. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +0 -27
  53. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
  54. package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts +0 -27
  55. package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts.map +1 -1
  56. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +0 -27
  57. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  58. package/dist/types/utils/NetworkUtils.d.ts +0 -12
  59. package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
  60. package/dist/types/utils/SpokeUtils.d.ts +1 -1
  61. package/dist/types/utils/TokenUtils.d.ts +30 -72
  62. package/dist/types/utils/TokenUtils.d.ts.map +1 -1
  63. package/package.json +3 -3
  64. package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +1 -1
  65. package/src/clients/SpokePoolClient.ts +1 -1
  66. package/src/clients/mocks/MockSpokePoolClient.ts +0 -2
  67. package/src/gasPriceOracle/oracle.ts +0 -1
  68. package/src/providers/retryProvider.ts +46 -7
  69. package/src/providers/types.ts +21 -0
  70. package/src/relayFeeCalculator/chain-queries/factory.ts +2 -15
  71. package/src/utils/NetworkUtils.ts +0 -18
  72. package/src/utils/SpokeUtils.ts +1 -1
  73. package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -233
  74. package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.js +0 -46
  75. package/dist/cjs/relayFeeCalculator/chain-queries/alephZero.js.map +0 -1
  76. package/dist/esm/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -233
  77. package/dist/esm/relayFeeCalculator/chain-queries/alephZero.js +0 -43
  78. package/dist/esm/relayFeeCalculator/chain-queries/alephZero.js.map +0 -1
  79. package/dist/types/relayFeeCalculator/chain-queries/alephZero.d.ts +0 -234
  80. package/dist/types/relayFeeCalculator/chain-queries/alephZero.d.ts.map +0 -1
  81. package/src/relayFeeCalculator/chain-queries/alephZero.ts +0 -48
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@across-protocol/sdk",
3
3
  "author": "UMA Team",
4
- "version": "3.2.11-beta.1",
4
+ "version": "3.2.11",
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.18",
103
- "@across-protocol/contracts": "^3.0.12-beta.3",
102
+ "@across-protocol/constants": "^3.1.16",
103
+ "@across-protocol/contracts": "^3.0.11",
104
104
  "@eth-optimism/sdk": "^3.3.1",
105
105
  "@ethersproject/bignumber": "^5.7.0",
106
106
  "@pinata/sdk": "^2.1.0",
@@ -138,7 +138,7 @@ export function _buildPoolRebalanceRoot(
138
138
  // Realized LP fees are keyed the same as running balances and represent the amount of LP fees that should be paid
139
139
  // to LP's for each running balance.
140
140
 
141
- // For each FilledRelay group, identified by { repaymentChainId, L1TokenAddress }, initialize a "running balance"
141
+ // For each FilledV3Relay group, identified by { repaymentChainId, L1TokenAddress }, initialize a "running balance"
142
142
  // to the total refund amount for that group.
143
143
  const runningBalances: RunningBalances = {};
144
144
  const realizedLpFees: RunningBalances = {};
@@ -411,7 +411,7 @@ export class SpokePoolClient extends BaseAbstractClient {
411
411
  * @note // We want to find the block range that satisfies these conditions:
412
412
  * // - the low block has deposit count <= targetDepositId
413
413
  * // - the high block has a deposit count > targetDepositId.
414
- * // This way the caller can search for a FundsDeposited event between [low, high] that will always
414
+ * // This way the caller can search for a V3FundsDeposited event between [low, high] that will always
415
415
  * // contain the event emitted when deposit ID was incremented to targetDepositId + 1. This is the same transaction
416
416
  * // where the deposit with deposit ID = targetDepositId was created.
417
417
  */
@@ -114,8 +114,6 @@ export class MockSpokePoolClient extends SpokePoolClient {
114
114
  // Event signatures. Not strictly required, but they make generated events more recognisable.
115
115
  public readonly eventSignatures: Record<string, string> = {
116
116
  EnabledDepositRoute: "address,uint256,bool",
117
- FilledRelay: "uint256,uint256,uint256,int64,uint32,uint32,address,address,address,bytes",
118
- FundsDeposited: "uint256,uint256,uint256,int64,uint32,uint32,address,address,address,bytes",
119
117
  };
120
118
 
121
119
  depositV3(deposit: DepositWithBlock): Log {
@@ -24,7 +24,6 @@ export async function getGasPriceEstimate(
24
24
  }
25
25
 
26
26
  const gasPriceFeeds: { [chainId: number]: GasPriceFeed } = {
27
- [CHAIN_IDs.ALEPH_ZERO]: arbitrum.eip1559,
28
27
  [CHAIN_IDs.ARBITRUM]: arbitrum.eip1559,
29
28
  [CHAIN_IDs.BASE]: ethereum.eip1559,
30
29
  [CHAIN_IDs.BOBA]: ethereum.legacy,
@@ -5,6 +5,7 @@ import { getOriginFromURL } from "../utils/NetworkUtils";
5
5
  import { CacheProvider } from "./cachedProvider";
6
6
  import { compareRpcResults, createSendErrorWithMessage, formatProviderError } from "./utils";
7
7
  import { PROVIDER_CACHE_TTL } from "./constants";
8
+ import { JsonRpcError, RpcError } from "./types";
8
9
  import { Logger } from "winston";
9
10
 
10
11
  export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {
@@ -88,9 +89,10 @@ export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {
88
89
  ): Promise<[ethers.providers.StaticJsonRpcProvider, unknown]> => {
89
90
  return this._trySend(provider, method, params)
90
91
  .then((result): [ethers.providers.StaticJsonRpcProvider, unknown] => [provider, result])
91
- .catch((err) => {
92
+ .catch((err: unknown) => {
92
93
  // Append the provider and error to the error array.
93
- errors.push([provider, err?.stack || err?.toString()]);
94
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
+ errors.push([provider, (err as any)?.stack || err?.toString()]);
94
96
 
95
97
  // If there are no new fallback providers to use, terminate the recursion by throwing an error.
96
98
  // Otherwise, we can try to call another provider.
@@ -98,6 +100,11 @@ export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {
98
100
  throw err;
99
101
  }
100
102
 
103
+ // If one RPC provider reverted, others likely will too. Skip them.
104
+ if (quorumThreshold === 1 && this.callReverted(method, err)) {
105
+ throw err;
106
+ }
107
+
101
108
  // This line does two things:
102
109
  // 1. Removes a fallback provider from the array so it cannot be used as a fallback for another required
103
110
  // provider.
@@ -260,12 +267,44 @@ export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {
260
267
  return response;
261
268
  }
262
269
 
263
- _trySend(provider: ethers.providers.StaticJsonRpcProvider, method: string, params: Array<unknown>): Promise<unknown> {
264
- let promise = this._sendAndValidate(provider, method, params);
265
- for (let i = 0; i < this.retries; i++) {
266
- promise = promise.catch(() => delay(this.delay).then(() => this._sendAndValidate(provider, method, params)));
270
+ // For an error emitted in response to an eth_call or eth_estimateGas request, determine whether the response body
271
+ // indicates that the call reverted during execution. The exact RPC responses returned can vary, but `error.body` has
272
+ // reliably included both the code (typically 3 on revert) and the error message indicating "execution reverted".
273
+ // This is consistent with section 5.1 of the JSON-RPC spec (https://www.jsonrpc.org/specification).
274
+ protected callReverted(method: string, error: unknown): boolean {
275
+ if (!(method === "eth_call" || method === "eth_estimateGas") || !RpcError.is(error)) {
276
+ return false;
277
+ }
278
+
279
+ let response: unknown;
280
+ try {
281
+ response = JSON.parse(error.body);
282
+ } catch {
283
+ return false;
284
+ }
285
+
286
+ return JsonRpcError.is(response) && response.error.message.toLowerCase().includes("revert");
287
+ }
288
+
289
+ async _trySend(
290
+ provider: ethers.providers.StaticJsonRpcProvider,
291
+ method: string,
292
+ params: Array<unknown>
293
+ ): Promise<unknown> {
294
+ let { retries } = this;
295
+
296
+ // eslint-disable-next-line no-constant-condition
297
+ while (true) {
298
+ const [settled] = await Promise.allSettled([this._sendAndValidate(provider, method, params)]);
299
+ if (settled.status === "fulfilled") {
300
+ return settled.value;
301
+ }
302
+
303
+ if (retries-- <= 0 || this.callReverted(method, settled.reason)) {
304
+ throw settled.reason;
305
+ }
306
+ await delay(this.delay);
267
307
  }
268
- return promise;
269
308
  }
270
309
 
271
310
  _getQuorum(method: string, params: Array<unknown>): number {
@@ -1,2 +1,23 @@
1
+ import { any, literal, nullable, number, string, type, union } from "superstruct";
2
+
1
3
  export type RPCProvider = "ALCHEMY" | "DRPC" | "INFURA" | "INFURA_DIN";
2
4
  export type RPCTransport = "https" | "wss";
5
+
6
+ // JSON-RPC 2.0 Error object
7
+ // See JSON-RPC 2.0 Specification section 5 Reponse object
8
+ // https://www.jsonrpc.org/specification
9
+ export const JsonRpcError = type({
10
+ jsonrpc: literal("2.0"),
11
+ id: union([number(), string()]),
12
+ error: type({
13
+ code: number(),
14
+ message: string(),
15
+ data: nullable(any()),
16
+ }),
17
+ });
18
+
19
+ // Generic/unknown RPC error (may embed a JsonRpcError).
20
+ export const RpcError = type({
21
+ reason: string(),
22
+ body: string(),
23
+ });
@@ -4,11 +4,10 @@ import { getDeployedAddress } from "@across-protocol/contracts";
4
4
  import { asL2Provider } from "@eth-optimism/sdk";
5
5
  import { providers } from "ethers";
6
6
  import { DEFAULT_SIMULATED_RELAYER_ADDRESS } from "../../constants";
7
- import { chainIsAlephZero, chainIsMatic, chainIsOPStack, isDefined } from "../../utils";
7
+ import { chainIsMatic, chainIsOPStack, isDefined } from "../../utils";
8
8
  import { QueryBase } from "./baseQuery";
9
9
  import { PolygonQueries } from "./polygon";
10
10
  import { DEFAULT_LOGGER, Logger } from "../relayFeeCalculator";
11
- import { AlephZeroQueries } from "./alephZero";
12
11
 
13
12
  /**
14
13
  * Some chains have a fixed gas price that is applied to the gas estimates. We should override
@@ -32,6 +31,7 @@ export class QueryBase__factory {
32
31
  ): QueryBase {
33
32
  assert(isDefined(spokePoolAddress));
34
33
 
34
+ // Currently the only chain that has a custom query class is Polygon
35
35
  if (chainIsMatic(chainId)) {
36
36
  return new PolygonQueries(
37
37
  provider,
@@ -43,19 +43,6 @@ export class QueryBase__factory {
43
43
  gasMarkup
44
44
  );
45
45
  }
46
-
47
- if (chainIsAlephZero(chainId)) {
48
- return new AlephZeroQueries(
49
- provider,
50
- symbolMapping,
51
- spokePoolAddress,
52
- simulatedRelayerAddress,
53
- coingeckoProApiKey,
54
- logger,
55
- gasMarkup
56
- );
57
- }
58
-
59
46
  // For OPStack chains, we need to wrap the provider in an L2Provider
60
47
  provider = chainIsOPStack(chainId) ? asL2Provider(provider) : provider;
61
48
 
@@ -60,15 +60,6 @@ export function chainIsOPStack(chainId: number): boolean {
60
60
  return PUBLIC_NETWORKS[chainId]?.family === ChainFamily.OP_STACK;
61
61
  }
62
62
 
63
- /**
64
- * Determines whether a chain ID is an Arbitrum Orbit implementation.
65
- * @param chainId Chain ID to evaluate.
66
- * @returns True if chainId is an Orbit chain, otherwise false.
67
- */
68
- export function chainIsOrbit(chainId: number): boolean {
69
- return PUBLIC_NETWORKS[chainId]?.family === ChainFamily.ORBIT;
70
- }
71
-
72
63
  /**
73
64
  * Determines whether a chain ID is an Arbitrum implementation.
74
65
  * @param chainId Chain ID to evaluate.
@@ -78,15 +69,6 @@ export function chainIsArbitrum(chainId: number): boolean {
78
69
  return [CHAIN_IDs.ARBITRUM, CHAIN_IDs.ARBITRUM_SEPOLIA].includes(chainId);
79
70
  }
80
71
 
81
- /**
82
- * Determines whether a chain ID is an Aleph0 implementation
83
- * @param chainId Chain ID to evaluate
84
- * @returns True if chainId is an Aleph0 chain, otherwise false.
85
- */
86
- export function chainIsAlephZero(chainId: number): boolean {
87
- return [CHAIN_IDs.ALEPH_ZERO].includes(chainId);
88
- }
89
-
90
72
  /**
91
73
  * Determines whether a chain ID is a Linea implementation.
92
74
  * @param chainId Chain ID to evaluate.
@@ -65,7 +65,7 @@ export function populateV3Relay(
65
65
  * @note // We want to find the block range that satisfies these conditions:
66
66
  * // - the low block has deposit count <= targetDepositId
67
67
  * // - the high block has a deposit count > targetDepositId.
68
- * // This way the caller can search for a FundsDeposited event between [low, high] that will always
68
+ * // This way the caller can search for a V3FundsDeposited event between [low, high] that will always
69
69
  * // contain the event emitted when deposit ID was incremented to targetDepositId + 1. This is the same transaction
70
70
  * // where the deposit with deposit ID = targetDepositId was created.
71
71
  */
@@ -1,233 +0,0 @@
1
- import { Logger } from "../relayFeeCalculator";
2
- import { providers } from "ethers";
3
- import { QueryBase } from "./baseQuery";
4
- export declare class AlephZeroQueries extends QueryBase {
5
- constructor(provider: providers.Provider, symbolMapping?: {
6
- ACX: {
7
- name: string;
8
- symbol: string;
9
- decimals: number;
10
- addresses: {
11
- [x: number]: string;
12
- };
13
- coingeckoId: string;
14
- };
15
- ARB: {
16
- name: string;
17
- symbol: string;
18
- decimals: number;
19
- addresses: {
20
- [x: number]: string;
21
- };
22
- coingeckoId: string;
23
- };
24
- AZERO: {
25
- name: string;
26
- symbol: string;
27
- decimals: number;
28
- addresses: {
29
- [x: number]: string;
30
- };
31
- coingeckoId: string;
32
- };
33
- BAL: {
34
- name: string;
35
- symbol: string;
36
- decimals: number;
37
- addresses: {
38
- [x: number]: string;
39
- };
40
- coingeckoId: string;
41
- };
42
- BADGER: {
43
- name: string;
44
- symbol: string;
45
- decimals: number;
46
- addresses: {
47
- [x: number]: string;
48
- };
49
- coingeckoId: string;
50
- };
51
- BOBA: {
52
- name: string;
53
- symbol: string;
54
- decimals: number;
55
- addresses: {
56
- [x: number]: string;
57
- };
58
- coingeckoId: string;
59
- };
60
- DAI: {
61
- name: string;
62
- symbol: string;
63
- decimals: number;
64
- addresses: {
65
- [x: number]: string;
66
- };
67
- coingeckoId: string;
68
- };
69
- ETH: {
70
- name: string;
71
- symbol: string;
72
- decimals: number;
73
- addresses: {
74
- [x: number]: string;
75
- };
76
- coingeckoId: string;
77
- };
78
- GHO: {
79
- name: string;
80
- symbol: string;
81
- decimals: number;
82
- addresses: {
83
- [x: number]: string;
84
- };
85
- coingeckoId: string;
86
- };
87
- LSK: {
88
- name: string;
89
- symbol: string;
90
- decimals: number;
91
- addresses: {
92
- [x: number]: string;
93
- };
94
- coingeckoId: string;
95
- };
96
- MATIC: {
97
- name: string;
98
- symbol: string;
99
- decimals: number;
100
- addresses: {
101
- [x: number]: string;
102
- };
103
- coingeckoId: string;
104
- };
105
- OP: {
106
- name: string;
107
- symbol: string;
108
- decimals: number;
109
- addresses: {
110
- [x: number]: string;
111
- };
112
- coingeckoId: string;
113
- };
114
- POOL: {
115
- name: string;
116
- symbol: string;
117
- decimals: number;
118
- addresses: {
119
- [x: number]: string;
120
- };
121
- coingeckoId: string;
122
- };
123
- SNX: {
124
- name: string;
125
- symbol: string;
126
- decimals: number;
127
- addresses: {
128
- [x: number]: string;
129
- };
130
- coingeckoId: string;
131
- };
132
- UMA: {
133
- name: string;
134
- symbol: string;
135
- decimals: number;
136
- addresses: {
137
- [x: number]: string;
138
- };
139
- coingeckoId: string;
140
- };
141
- USDB: {
142
- name: string;
143
- symbol: string;
144
- decimals: number;
145
- addresses: {
146
- [x: number]: string;
147
- };
148
- coingeckoId: string;
149
- };
150
- USDC: {
151
- name: string;
152
- symbol: string;
153
- decimals: number;
154
- addresses: {
155
- [x: number]: string;
156
- };
157
- coingeckoId: string;
158
- };
159
- "USDC.e": {
160
- name: string;
161
- symbol: string;
162
- decimals: number;
163
- addresses: {
164
- [x: number]: string;
165
- };
166
- coingeckoId: string;
167
- };
168
- USDbC: {
169
- name: string;
170
- symbol: string;
171
- decimals: number;
172
- addresses: {
173
- [x: number]: string;
174
- };
175
- coingeckoId: string;
176
- };
177
- USDzC: {
178
- name: string;
179
- symbol: string;
180
- decimals: number;
181
- addresses: {
182
- [x: number]: string;
183
- };
184
- coingeckoId: string;
185
- };
186
- USDT: {
187
- name: string;
188
- symbol: string;
189
- decimals: number;
190
- addresses: {
191
- [x: number]: string;
192
- };
193
- coingeckoId: string;
194
- };
195
- WAZERO: {
196
- name: string;
197
- symbol: string;
198
- decimals: number;
199
- addresses: {
200
- [x: number]: string;
201
- };
202
- coingeckoId: string;
203
- };
204
- WBTC: {
205
- name: string;
206
- symbol: string;
207
- decimals: number;
208
- addresses: {
209
- [x: number]: string;
210
- };
211
- coingeckoId: string;
212
- };
213
- WETH: {
214
- name: string;
215
- symbol: string;
216
- decimals: number;
217
- addresses: {
218
- [x: number]: string;
219
- };
220
- coingeckoId: string;
221
- };
222
- WMATIC: {
223
- name: string;
224
- symbol: string;
225
- decimals: number;
226
- addresses: {
227
- [x: number]: string;
228
- };
229
- coingeckoId: string;
230
- };
231
- }, spokePoolAddress?: string | undefined, simulatedRelayerAddress?: string, coingeckoProApiKey?: string, logger?: Logger, gasMarkup?: number);
232
- getTokenPrice(tokenSymbol: string): Promise<number>;
233
- }
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AlephZeroQueries = void 0;
4
- var tslib_1 = require("tslib");
5
- var assert_1 = tslib_1.__importDefault(require("assert"));
6
- var DeploymentUtils_1 = require("../../utils/DeploymentUtils");
7
- var relayFeeCalculator_1 = require("../relayFeeCalculator");
8
- var constants_1 = require("../../constants");
9
- var Coingecko_1 = require("../../coingecko/Coingecko");
10
- var utils_1 = require("../../utils");
11
- var baseQuery_1 = require("./baseQuery");
12
- var AlephZeroQueries = (function (_super) {
13
- tslib_1.__extends(AlephZeroQueries, _super);
14
- function AlephZeroQueries(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, coingeckoProApiKey, logger, gasMarkup) {
15
- if (symbolMapping === void 0) { symbolMapping = constants_1.TOKEN_SYMBOLS_MAP; }
16
- if (spokePoolAddress === void 0) { spokePoolAddress = (0, DeploymentUtils_1.getDeployedAddress)("SpokePool", constants_1.CHAIN_IDs.ALEPH_ZERO); }
17
- if (simulatedRelayerAddress === void 0) { simulatedRelayerAddress = constants_1.DEFAULT_SIMULATED_RELAYER_ADDRESS; }
18
- if (logger === void 0) { logger = relayFeeCalculator_1.DEFAULT_LOGGER; }
19
- if (gasMarkup === void 0) { gasMarkup = 0; }
20
- (0, assert_1.default)((0, utils_1.isDefined)(spokePoolAddress));
21
- return _super.call(this, provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey, undefined, "usd") || this;
22
- }
23
- AlephZeroQueries.prototype.getTokenPrice = function (tokenSymbol) {
24
- return tslib_1.__awaiter(this, void 0, void 0, function () {
25
- var coingeckoInstance, _a, tokenPrice, _b, alephZeroPrice;
26
- return tslib_1.__generator(this, function (_c) {
27
- switch (_c.label) {
28
- case 0:
29
- if (!this.symbolMapping[tokenSymbol])
30
- throw new Error("".concat(tokenSymbol, " does not exist in mapping"));
31
- coingeckoInstance = Coingecko_1.Coingecko.get(this.logger, this.coingeckoProApiKey);
32
- return [4, coingeckoInstance.getCurrentPriceByContract(this.symbolMapping[tokenSymbol].addresses[constants_1.CHAIN_IDs.MAINNET], "usd")];
33
- case 1:
34
- _a = _c.sent(), tokenPrice = _a[1];
35
- return [4, coingeckoInstance.getCurrentPriceByContract(this.symbolMapping["AZERO"].addresses[constants_1.CHAIN_IDs.MAINNET], "usd")];
36
- case 2:
37
- _b = _c.sent(), alephZeroPrice = _b[1];
38
- return [2, Number((tokenPrice / alephZeroPrice).toFixed(this.symbolMapping["AZERO"].decimals))];
39
- }
40
- });
41
- });
42
- };
43
- return AlephZeroQueries;
44
- }(baseQuery_1.QueryBase));
45
- exports.AlephZeroQueries = AlephZeroQueries;
46
- //# sourceMappingURL=alephZero.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"alephZero.js","sourceRoot":"","sources":["../../../../src/relayFeeCalculator/chain-queries/alephZero.ts"],"names":[],"mappings":";;;;AAAA,0DAA4B;AAC5B,+DAAiE;AACjE,4DAA+D;AAE/D,6CAAkG;AAClG,uDAAsD;AACtD,qCAAwC;AACxC,yCAAwC;AAExC;IAAsC,4CAAS;IAC7C,0BACE,QAA4B,EAC5B,aAAiC,EACjC,gBAAwE,EACxE,uBAA2D,EAC3D,kBAA2B,EAC3B,MAA+B,EAC/B,SAAa;QALb,8BAAA,EAAA,gBAAgB,6BAAiB;QACjC,iCAAA,EAAA,uBAAmB,oCAAkB,EAAC,WAAW,EAAE,qBAAS,CAAC,UAAU,CAAC;QACxE,wCAAA,EAAA,0BAA0B,6CAAiC;QAE3D,uBAAA,EAAA,SAAiB,mCAAc;QAC/B,0BAAA,EAAA,aAAa;QAEb,IAAA,gBAAM,EAAC,IAAA,iBAAS,EAAC,gBAAgB,CAAC,CAAC,CAAC;eACpC,kBACE,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,uBAAuB,EACvB,SAAS,EACT,MAAM,EACN,kBAAkB,EAClB,SAAS,EACT,KAAK,CACN;IACH,CAAC;IAEc,wCAAa,GAA5B,UAA6B,WAAmB;;;;;;wBAC9C,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;4BAAE,MAAM,IAAI,KAAK,CAAC,UAAG,WAAW,+BAA4B,CAAC,CAAC;wBAC5F,iBAAiB,GAAG,qBAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;wBACvD,WAAM,iBAAiB,CAAC,yBAAyB,CACtE,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,qBAAS,CAAC,OAAO,CAAC,EAC5D,KAAK,CACN,EAAA;;wBAHK,KAAiB,SAGtB,EAHQ,UAAU,QAAA;wBAKQ,WAAM,iBAAiB,CAAC,yBAAyB,CAC1E,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,qBAAS,CAAC,OAAO,CAAC,EACxD,KAAK,CACN,EAAA;;wBAHK,KAAqB,SAG1B,EAHQ,cAAc,QAAA;wBAIvB,WAAO,MAAM,CAAC,CAAC,UAAU,GAAG,cAAc,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAC;;;;KAC5F;IACH,uBAAC;AAAD,CAAC,AAtCD,CAAsC,qBAAS,GAsC9C;AAtCY,4CAAgB"}