@paraswap/dex-lib 3.5.6-maverick-v2-7 → 3.6.0

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 (111) hide show
  1. package/.vscode/launch.json +53 -0
  2. package/.vscode/settings.json +2 -0
  3. package/.vscode/tasks.json +15 -0
  4. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
  5. package/build/abi/wombat/pool.json +1289 -0
  6. package/build/constants.d.ts +2 -0
  7. package/build/constants.js +3 -1
  8. package/build/constants.js.map +1 -1
  9. package/build/dex/aave-v1/aave-v1.d.ts +2 -1
  10. package/build/dex/aave-v1/aave-v1.js +23 -0
  11. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  12. package/build/dex/aave-v2/tokens-avalanche.json +44 -0
  13. package/build/dex/aave-v2/tokens-mainnet.json +188 -0
  14. package/build/dex/aave-v2/tokens-polygon.json +44 -0
  15. package/build/dex/compound.js +1 -1
  16. package/build/dex/compound.js.map +1 -1
  17. package/build/dex/index.js +0 -2
  18. package/build/dex/index.js.map +1 -1
  19. package/build/dex/maker-psm/scripts/gem.abi.json +136 -0
  20. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  21. package/build/dex/maker-psm/scripts/validate-state.js +185 -0
  22. package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
  23. package/build/dex/maker-psm/scripts/vat.abi.json +243 -0
  24. package/build/dex/maverick-v2/config.d.ts +2 -1
  25. package/build/dex/maverick-v2/config.js +6 -2
  26. package/build/dex/maverick-v2/config.js.map +1 -1
  27. package/build/dex/maverick-v2/maverick-v2.d.ts +3 -2
  28. package/build/dex/maverick-v2/maverick-v2.js +17 -6
  29. package/build/dex/maverick-v2/maverick-v2.js.map +1 -1
  30. package/build/dex/platypus/platypus.d.ts +2 -1
  31. package/build/dex/platypus/platypus.js +45 -0
  32. package/build/dex/platypus/platypus.js.map +1 -1
  33. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
  34. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
  35. package/build/dex/stable-pool.js +1 -8
  36. package/build/dex/stable-pool.js.map +1 -1
  37. package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
  38. package/build/dex/swaap-v1/swaap-v1.js +14 -0
  39. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  40. package/build/dex/uniswap-v2/uniswap-v2.d.ts +2 -2
  41. package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
  42. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
  43. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
  44. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
  45. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
  46. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
  47. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
  48. package/build/dex/uniswap-v3/uniswap-v3.d.ts +2 -2
  49. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  50. package/build/dex/zerox/index.d.ts +1 -1
  51. package/build/dex/zerox/index.js.map +1 -1
  52. package/build/executor/Executor03BytecodeBuilder.js +1 -12
  53. package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
  54. package/build/generic-swap-transaction-builder.d.ts +5 -3
  55. package/build/generic-swap-transaction-builder.js +22 -7
  56. package/build/generic-swap-transaction-builder.js.map +1 -1
  57. package/package.json +2 -2
  58. package/src/constants.ts +2 -0
  59. package/src/dex/index.ts +0 -2
  60. package/src/dex/maker-psm/scripts/gem.abi.json +136 -0
  61. package/src/dex/maker-psm/scripts/validate-state.ts +221 -0
  62. package/src/dex/maker-psm/scripts/vat.abi.json +243 -0
  63. package/src/dex/uniswap-v2/uniswap-v2.ts +2 -2
  64. package/src/dex/uniswap-v3/uniswap-v3.ts +2 -2
  65. package/src/dex/zerox/index.ts +1 -1
  66. package/src/executor/Executor03BytecodeBuilder.ts +1 -15
  67. package/src/generic-swap-transaction-builder.ts +40 -0
  68. package/tests/constants-e2e.ts +2 -2
  69. package/build/dex/etherfi/etherfi.d.ts +0 -26
  70. package/build/dex/etherfi/etherfi.js +0 -96
  71. package/build/dex/etherfi/etherfi.js.map +0 -1
  72. package/build/dex/sdai/config.d.ts +0 -11
  73. package/build/dex/sdai/config.js +0 -21
  74. package/build/dex/sdai/config.js.map +0 -1
  75. package/build/dex/sdai/constants.d.ts +0 -2
  76. package/build/dex/sdai/constants.js +0 -6
  77. package/build/dex/sdai/constants.js.map +0 -1
  78. package/build/dex/sdai/scripts/validate-state.js +0 -102
  79. package/build/dex/sdai/scripts/validate-state.js.map +0 -1
  80. package/build/dex/sdai/sdai-pool.d.ts +0 -16
  81. package/build/dex/sdai/sdai-pool.js +0 -85
  82. package/build/dex/sdai/sdai-pool.js.map +0 -1
  83. package/build/dex/sdai/sdai.d.ts +0 -51
  84. package/build/dex/sdai/sdai.js +0 -172
  85. package/build/dex/sdai/sdai.js.map +0 -1
  86. package/build/dex/sdai/types.d.ts +0 -21
  87. package/build/dex/sdai/types.js +0 -11
  88. package/build/dex/sdai/types.js.map +0 -1
  89. package/build/dex/sdai/utils.d.ts +0 -4
  90. package/build/dex/sdai/utils.js +0 -39
  91. package/build/dex/sdai/utils.js.map +0 -1
  92. package/src/abi/maverick-v2/MaverickV2Pool.json +0 -1234
  93. package/src/abi/maverick-v2/MaverickV2PoolLens.json +0 -1232
  94. package/src/abi/maverick-v2/MaverickV2Quoter.json +0 -278
  95. package/src/dex/maverick-v2/config.ts +0 -17
  96. package/src/dex/maverick-v2/maverick-math/maverick-basic-math.ts +0 -152
  97. package/src/dex/maverick-v2/maverick-math/maverick-bin-math.ts +0 -288
  98. package/src/dex/maverick-v2/maverick-math/maverick-delta-math.ts +0 -32
  99. package/src/dex/maverick-v2/maverick-math/maverick-math.ts +0 -30
  100. package/src/dex/maverick-v2/maverick-math/maverick-pool-lib.ts +0 -42
  101. package/src/dex/maverick-v2/maverick-math/maverick-pool-math.ts +0 -709
  102. package/src/dex/maverick-v2/maverick-math/maverick-swap-math.ts +0 -199
  103. package/src/dex/maverick-v2/maverick-math/maverick-tick-math.ts +0 -171
  104. package/src/dex/maverick-v2/maverick-math/maverick-twa-math.ts +0 -54
  105. package/src/dex/maverick-v2/maverick-v2-e2e.test.ts +0 -176
  106. package/src/dex/maverick-v2/maverick-v2-events.test.ts +0 -112
  107. package/src/dex/maverick-v2/maverick-v2-integration.test.ts +0 -269
  108. package/src/dex/maverick-v2/maverick-v2-pool.ts +0 -276
  109. package/src/dex/maverick-v2/maverick-v2.ts +0 -424
  110. package/src/dex/maverick-v2/types.ts +0 -152
  111. /package/build/dex/{sdai/scripts/validate-state.d.ts → solidly-v3/scripts/check-event-pool-event.d.ts} +0 -0
@@ -1,424 +0,0 @@
1
- import { AsyncOrSync } from 'ts-essentials';
2
- import _, { chain } from 'lodash';
3
- import {
4
- Token,
5
- Address,
6
- ExchangePrices,
7
- PoolPrices,
8
- AdapterExchangeParam,
9
- PoolLiquidity,
10
- Logger,
11
- NumberAsString,
12
- DexExchangeParam,
13
- } from '../../types';
14
- import { SwapSide, Network, NULL_ADDRESS } from '../../constants';
15
- import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
16
- import { getBigIntPow, getDexKeysWithNetwork, isTruthy } from '../../utils';
17
- import { Context, IDex } from '../../dex/idex';
18
- import { IDexHelper } from '../../dex-helper/idex-helper';
19
- import {
20
- DexParams,
21
- MaverickV2Data,
22
- PoolAPIResponse,
23
- SubgraphPoolBase,
24
- } from './types';
25
- import { SimpleExchange } from '../simple-exchange';
26
- import {
27
- MaverickV2Config,
28
- MAV_V2_BASE_GAS_COST,
29
- MAV_V2_TICK_GAS_COST,
30
- } from './config';
31
- import { MaverickV2EventPool } from './maverick-v2-pool';
32
- import { SUBGRAPH_TIMEOUT } from '../../constants';
33
- import { Interface } from '@ethersproject/abi';
34
- import MaverickV2PoolABI from '../../abi/maverick-v2/MaverickV2Pool.json';
35
- import ERC20ABI from '../../abi/erc20.json';
36
- import { extractReturnAmountPosition } from '../../executor/utils';
37
- const EFFICIENCY_FACTOR = 3;
38
-
39
- export class MaverickV2 extends SimpleExchange implements IDex<MaverickV2Data> {
40
- pools: { [key: string]: MaverickV2EventPool } = {};
41
- readonly hasConstantPriceLargeAmounts = false;
42
- readonly needWrapNative = true;
43
-
44
- readonly isFeeOnTransferSupported = false;
45
-
46
- public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
47
- getDexKeysWithNetwork(MaverickV2Config);
48
-
49
- logger: Logger;
50
-
51
- public static erc20Interface = new Interface(ERC20ABI);
52
-
53
- constructor(
54
- readonly network: Network,
55
- readonly dexKey: string,
56
- readonly dexHelper: IDexHelper,
57
- protected adapters = {},
58
- protected config = MaverickV2Config[dexKey][network],
59
- protected maverickV2Iface = new Interface(MaverickV2PoolABI),
60
- ) {
61
- super(dexHelper, dexKey);
62
- this.logger = dexHelper.getLogger(dexKey);
63
- }
64
-
65
- async initializePricing(blockNumber: number) {
66
- await this.setupEventPools(blockNumber);
67
- }
68
-
69
- async setupEventPools(blockNumber: number) {
70
- const pools = (await this._queryPoolsAPI(SUBGRAPH_TIMEOUT))?.pools;
71
-
72
- await Promise.all(
73
- pools?.map(async (pool: any) => {
74
- const eventPool = new MaverickV2EventPool(
75
- this.dexKey,
76
- this.network,
77
- this.dexHelper,
78
- this.logger,
79
- {
80
- address: pool.tokenA.address,
81
- symbol: pool.tokenA.symbol,
82
- decimals: pool.tokenA.decimals,
83
- },
84
- {
85
- address: pool.tokenB.address,
86
- symbol: pool.tokenB.symbol,
87
- decimals: pool.tokenB.decimals,
88
- },
89
- pool.fee * 1e4 * 1e14,
90
- pool.feeB * 1e4 * 1e14,
91
- pool.tickSpacing,
92
- 0,
93
- pool.lookback,
94
- pool.lowerTick,
95
- pool.id,
96
- this.config.poolLensAddress,
97
- );
98
- const onChainState = await eventPool.generateState(blockNumber);
99
- if (blockNumber) {
100
- eventPool.setState(onChainState, blockNumber);
101
- this.dexHelper.blockManager.subscribeToLogs(
102
- eventPool,
103
- eventPool.addressesSubscribed,
104
- blockNumber,
105
- );
106
- }
107
- this.pools[eventPool.address] = eventPool;
108
- }) || [],
109
- );
110
- }
111
-
112
- getAdapters(side: SwapSide): { name: string; index: number }[] | null {
113
- return null;
114
- }
115
-
116
- async getPoolIdentifiers(
117
- srcToken: Token,
118
- destToken: Token,
119
- side: SwapSide,
120
- blockNumber: number,
121
- ): Promise<string[]> {
122
- const from = this.dexHelper.config.wrapETH(srcToken);
123
- const to = this.dexHelper.config.wrapETH(destToken);
124
- if (from.address.toLowerCase() === to.address.toLowerCase()) {
125
- return [];
126
- }
127
-
128
- const pools = await this.getPools(from, to);
129
- return pools.map(
130
- (pool: any) => `${this.dexKey}_${pool.address.toLowerCase()}`,
131
- );
132
- }
133
-
134
- async getPools(srcToken: Token, destToken: Token) {
135
- return Object.values(this.pools).filter((pool: MaverickV2EventPool) => {
136
- return (
137
- (pool.tokenA.address.toLowerCase() == srcToken.address.toLowerCase() ||
138
- pool.tokenA.address.toLowerCase() ==
139
- destToken.address.toLowerCase()) &&
140
- (pool.tokenB.address.toLowerCase() == srcToken.address.toLowerCase() ||
141
- pool.tokenB.address.toLowerCase() == destToken.address.toLowerCase())
142
- );
143
- });
144
- }
145
-
146
- async getPricesVolume(
147
- srcToken: Token,
148
- destToken: Token,
149
- amounts: bigint[],
150
- side: SwapSide,
151
- blockNumber: number,
152
- limitPools?: string[],
153
- ): Promise<null | ExchangePrices<MaverickV2Data>> {
154
- try {
155
- const from = this.dexHelper.config.wrapETH(srcToken);
156
- const to = this.dexHelper.config.wrapETH(destToken);
157
-
158
- if (from.address.toLowerCase() === to.address.toLowerCase()) {
159
- return null;
160
- }
161
-
162
- const allPools = await this.getPools(from, to);
163
-
164
- const allowedPools = limitPools
165
- ? allPools.filter(pool =>
166
- limitPools.includes(`${this.dexKey}_${pool.address.toLowerCase()}`),
167
- )
168
- : allPools;
169
-
170
- if (!allowedPools.length) return null;
171
-
172
- const unitAmount = getBigIntPow(
173
- side == SwapSide.BUY ? to.decimals : from.decimals,
174
- );
175
-
176
- return (
177
- await Promise.all(
178
- allowedPools.map(async (pool: MaverickV2EventPool) => {
179
- try {
180
- let state = pool.getState(blockNumber);
181
- if (state === null) {
182
- state = await pool.generateState(blockNumber);
183
- pool.setState(state, blockNumber);
184
- }
185
- if (state === null) {
186
- this.logger.debug(
187
- `Received null state for pool ${pool.address}`,
188
- );
189
- return null;
190
- }
191
-
192
- const [unit] = pool.swap(
193
- unitAmount,
194
- from,
195
- to,
196
- side == SwapSide.BUY,
197
- );
198
- // We stop iterating if it becomes 0n at some point
199
- let lastOutput = 1n;
200
- let dataList: [bigint, number][] = await Promise.all(
201
- amounts.map(amount => {
202
- if (amount === 0n) {
203
- return [0n, 0];
204
- }
205
- // We don't want to proceed with calculations if lower amount was not fillable
206
- if (lastOutput === 0n) {
207
- return [0n, 0];
208
- }
209
- const output = pool.swap(
210
- amount,
211
- from,
212
- to,
213
- side == SwapSide.BUY,
214
- );
215
- lastOutput = output[0];
216
- return output;
217
- }),
218
- );
219
-
220
- let prices = dataList.map(d => d[0]);
221
-
222
- let gasCosts: number[] = dataList.map(
223
- ([d, t]: [BigInt, number]) => {
224
- if (d == 0n) return 0;
225
- return MAV_V2_BASE_GAS_COST + MAV_V2_TICK_GAS_COST * t;
226
- },
227
- );
228
-
229
- return {
230
- prices: prices,
231
- unit: BigInt(unit),
232
- data: {
233
- pool: pool.address,
234
- tokenA: pool.tokenA.address,
235
- tokenB: pool.tokenB.address,
236
- activeTick: state.activeTick,
237
- },
238
- exchange: this.dexKey,
239
- poolIdentifier: pool.name,
240
- gasCost: gasCosts,
241
- poolAddresses: [pool.address],
242
- };
243
- } catch (e) {
244
- this.logger.debug(
245
- `Failed to get prices for pool ${pool.address}, from=${from.address}, to=${to.address}`,
246
- e,
247
- );
248
- return null;
249
- }
250
- }),
251
- )
252
- ).filter(isTruthy);
253
- } catch (e) {
254
- this.logger.error(
255
- `Error_getPricesVolume ${srcToken.symbol || srcToken.address}, ${
256
- destToken.symbol || destToken.address
257
- }, ${side}:`,
258
- e,
259
- );
260
- return null;
261
- }
262
- }
263
-
264
- // Returns estimated gas cost of calldata for this DEX in multiSwap
265
- getCalldataGasCost(
266
- poolPrices: PoolPrices<MaverickV2Data>,
267
- ): number | number[] {
268
- const gasCost = CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
269
-
270
- const arr = new Array(poolPrices.prices.length);
271
- poolPrices.prices.forEach((p, index) => {
272
- if (p == 0n) {
273
- arr[index] = 0;
274
- } else {
275
- arr[index] = gasCost;
276
- }
277
- });
278
- return arr;
279
- }
280
-
281
- // Encode params required by the exchange adapter
282
- // Used for multiSwap, buy & megaSwap
283
- // Hint: abiCoder.encodeParameter() could be useful
284
- getAdapterParam(
285
- srcToken: string,
286
- destToken: string,
287
- srcAmount: string,
288
- destAmount: string,
289
- data: MaverickV2Data,
290
- side: SwapSide,
291
- ): AdapterExchangeParam {
292
- return {
293
- targetExchange: NULL_ADDRESS,
294
- payload: '0x',
295
- networkFee: '0',
296
- };
297
- }
298
-
299
- getDexParam(
300
- srcToken: Address,
301
- destToken: Address,
302
- srcAmount: NumberAsString,
303
- destAmount: NumberAsString,
304
- recipient: Address,
305
- data: MaverickV2Data,
306
- side: SwapSide,
307
- _: Context,
308
- executorAddress: Address,
309
- ): DexExchangeParam {
310
- const { pool } = data;
311
-
312
- const exchangeData = this.maverickV2Iface.encodeFunctionData('swap', [
313
- recipient,
314
- {
315
- amount: side === SwapSide.SELL ? srcAmount : destAmount,
316
- tokenAIn: data.tokenA.toLowerCase() === srcToken.toLowerCase(),
317
- exactOutput: side === SwapSide.BUY,
318
- tickLimit:
319
- data.tokenA.toLowerCase() === srcToken.toLowerCase()
320
- ? BigInt(data.activeTick) + 100n
321
- : BigInt(data.activeTick) - 100n,
322
- },
323
- '0x',
324
- ]);
325
-
326
- return {
327
- needWrapNative: this.needWrapNative,
328
- transferSrcTokenBeforeSwap: pool,
329
- // skipApproval: true,
330
- targetExchange: pool,
331
- dexFuncHasRecipient: true,
332
- exchangeData,
333
- returnAmountPos:
334
- side === SwapSide.SELL
335
- ? extractReturnAmountPosition(
336
- this.maverickV2Iface,
337
- 'swap',
338
- 'amountOut',
339
- )
340
- : undefined,
341
- };
342
- }
343
-
344
- // This is called once before getTopPoolsForToken is
345
- // called for multiple tokens. This can be helpful to
346
- // update common state required for calculating
347
- // getTopPoolsForToken. It is optional for a DEX
348
- // to implement this
349
- async updatePoolState(): Promise<void> {
350
- return Promise.resolve();
351
- }
352
-
353
- // Returns list of top pools based on liquidity. Max
354
- // limit number pools should be returned.
355
- async getTopPoolsForToken(
356
- tokenAddress: Address,
357
- limit: number,
358
- ): Promise<PoolLiquidity[]> {
359
- const _tokenAddress = tokenAddress.toLowerCase();
360
-
361
- const res: PoolAPIResponse | null = await this._queryPoolsAPI(
362
- SUBGRAPH_TIMEOUT,
363
- );
364
-
365
- if (!(res && res.pools)) {
366
- this.logger.error(
367
- `Error_${this.dexKey}_Subgraph: couldn't fetch the pools from the subgraph`,
368
- );
369
- return [];
370
- }
371
-
372
- const filteredPools = _.filter(res.pools, pool => {
373
- return (
374
- pool.tokenA.address.toLowerCase() === _tokenAddress ||
375
- pool.tokenB.address.toLowerCase() === _tokenAddress
376
- );
377
- });
378
-
379
- const labeledPools = _.map(filteredPools, pool => {
380
- let token =
381
- pool.tokenA.address.toLowerCase() === _tokenAddress
382
- ? pool.tokenB
383
- : pool.tokenA;
384
-
385
- return {
386
- exchange: this.dexKey,
387
- address: pool.id.toLowerCase(),
388
- connectorTokens: [
389
- {
390
- address: token.address.toLowerCase(),
391
- decimals: token.decimals,
392
- },
393
- ],
394
- liquidityUSD: pool.tvl.amount * EFFICIENCY_FACTOR,
395
- };
396
- });
397
-
398
- const pools = _.slice(
399
- _.sortBy(labeledPools, [pool => -1 * pool.liquidityUSD]),
400
- 0,
401
- limit,
402
- );
403
- return pools;
404
- }
405
-
406
- // This is optional function in case if your implementation has acquired any resources
407
- // you need to release for graceful shutdown. For example, it may be any interval timer
408
- releaseResources(): AsyncOrSync<void> {
409
- // TODO: complete me!
410
- }
411
-
412
- private async _queryPoolsAPI(timeout = 30000) {
413
- try {
414
- const res = await this.dexHelper.httpRequest.get<PoolAPIResponse>(
415
- `${this.config.apiURL}/api/v5/poolsNoBins/${this.network}`,
416
- timeout,
417
- );
418
- return res;
419
- } catch (e) {
420
- this.logger.error(`${this.dexKey}: can not query subgraph: `, e);
421
- return null;
422
- }
423
- }
424
- }
@@ -1,152 +0,0 @@
1
- import { Address, NumberAsString } from '../../types';
2
-
3
- export type Bin = {
4
- mergeBinBalance: bigint;
5
- mergeId: bigint;
6
- totalSupply: bigint;
7
- kind: bigint;
8
- tick: bigint;
9
- tickBalance: bigint;
10
- };
11
-
12
- export type BinDelta = {
13
- deltaA: bigint;
14
- deltaB: bigint;
15
- };
16
-
17
- export type TickData = {
18
- currentReserveA: bigint;
19
- currentReserveB: bigint;
20
- currentLiquidity: bigint;
21
- };
22
-
23
- export type AddLiquidityInfo = {
24
- deltaA: bigint;
25
- deltaB: bigint;
26
- tickLtActive: boolean;
27
- tickSpacing: bigint;
28
- tick: bigint;
29
- };
30
-
31
- export type MoveData = {
32
- kind: bigint;
33
- tickSearchStart: bigint;
34
- tickSearchEnd: bigint;
35
- tickLimit: bigint;
36
- firstBinTick: bigint;
37
- firstBinId: bigint;
38
- mergeBinBalance: bigint;
39
- totalReserveA: bigint;
40
- totalReserveB: bigint;
41
- mergeBins: { [id: string]: bigint };
42
- counter: bigint;
43
- };
44
-
45
- export type Tick = {
46
- reserveA: bigint;
47
- reserveB: bigint;
48
- totalSupply: bigint;
49
- binIdsByTick: { [id: string]: bigint };
50
- };
51
-
52
- export type RemoveLiquidityParams = {
53
- binIds: bigint[];
54
- amounts: bigint[];
55
- };
56
-
57
- export type AddLiquidityParams = {
58
- ticks: bigint[];
59
- amounts: bigint[];
60
- kind: bigint;
61
- };
62
-
63
- export type PoolState = {
64
- activeTick: bigint;
65
- binCounter: bigint;
66
- reserveA: bigint;
67
- reserveB: bigint;
68
- lastTwaD8: bigint;
69
- lastLogPriceD8: bigint;
70
- lastTimestamp: bigint;
71
- bins: { [id: string]: Bin };
72
- ticks: { [id: string]: Tick };
73
- };
74
-
75
- export interface SubgraphToken {
76
- id: string;
77
- symbol: string;
78
- name: string;
79
- }
80
-
81
- export interface SubgraphPoolBase {
82
- id: string;
83
- tickSpacing: number;
84
- fee: number;
85
- lookback: number;
86
- protocolFeeRatio: number;
87
- tokenA: SubgraphToken;
88
- tokenB: SubgraphToken;
89
- }
90
-
91
- export type MaverickV2Data = {
92
- pool: Address;
93
- tokenA: Address;
94
- tokenB: Address;
95
- activeTick: bigint;
96
- };
97
-
98
- export interface SubgraphPoolBase {
99
- id: string;
100
- tickSpacing: number;
101
- feeAIn: number;
102
- feeBIn: number;
103
- lookback: number;
104
- protocolFeeRatio: number;
105
- tokenA: SubgraphToken;
106
- tokenB: SubgraphToken;
107
- }
108
-
109
- type SwapParams = {
110
- amount: NumberAsString;
111
- tokenAIn: boolean;
112
- exactOutput: boolean;
113
- tickLimit: NumberAsString;
114
- };
115
-
116
- export type MaverickV2Param = {
117
- recipient: Address;
118
- params: SwapParams;
119
- data: string;
120
- };
121
-
122
- export type DexParams = {
123
- poolLensAddress: string;
124
- apiURL: string;
125
- quoterAddress: string;
126
- };
127
-
128
- export type PoolAPIResponse = {
129
- pools: {
130
- fee: number;
131
- feeB: number;
132
- lookback: number;
133
- lowerTick: number;
134
- tickSpacing: number;
135
- id: string;
136
- tokenA: {
137
- name: string;
138
- symbol: string;
139
- address: string;
140
- decimals: number;
141
- };
142
- tokenB: {
143
- name: string;
144
- symbol: string;
145
- address: string;
146
- decimals: number;
147
- };
148
- tvl: {
149
- amount: number;
150
- };
151
- }[];
152
- };