@paraswap/dex-lib 4.0.17 → 4.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abi/aavev3statav2/Factory.json +131 -0
- package/build/abi/aavev3statav2/Pool.json +1459 -0
- package/build/abi/aavev3statav2/Token.json +997 -0
- package/build/dex/aave-gsm/config.js +2 -2
- package/build/dex/aave-gsm/config.js.map +1 -1
- package/build/dex/aave-v2/tokenlist.json +904 -0
- package/build/dex/aave-v2/tokens.js +6 -4
- package/build/dex/aave-v2/tokens.js.map +1 -1
- package/build/dex/aave-v3/config.js +6 -6
- package/build/dex/aave-v3/config.js.map +1 -1
- package/build/dex/aave-v3-stata-v2/aave-v3-stata-v2.d.ts +49 -0
- package/build/dex/aave-v3-stata-v2/aave-v3-stata-v2.js +377 -0
- package/build/dex/aave-v3-stata-v2/aave-v3-stata-v2.js.map +1 -0
- package/build/dex/aave-v3-stata-v2/config.d.ts +3 -0
- package/build/dex/aave-v3-stata-v2/config.js +21 -0
- package/build/dex/aave-v3-stata-v2/config.js.map +1 -0
- package/build/dex/aave-v3-stata-v2/tokens.d.ts +10 -0
- package/build/dex/aave-v3-stata-v2/tokens.js +43 -0
- package/build/dex/aave-v3-stata-v2/tokens.js.map +1 -0
- package/build/dex/aave-v3-stata-v2/types.d.ts +35 -0
- package/build/dex/aave-v3-stata-v2/types.js +25 -0
- package/build/dex/aave-v3-stata-v2/types.js.map +1 -0
- package/build/dex/aave-v3-stata-v2/utils.d.ts +4 -0
- package/build/dex/aave-v3-stata-v2/utils.js +67 -0
- package/build/dex/aave-v3-stata-v2/utils.js.map +1 -0
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/stkgho/config.js +2 -2
- package/build/dex/stkgho/config.js.map +1 -1
- package/package.json +2 -2
- package/src/abi/aavev3statav2/Factory.json +131 -0
- package/src/abi/aavev3statav2/Pool.json +1459 -0
- package/src/abi/aavev3statav2/Token.json +997 -0
- package/src/dex/aave-gsm/config.ts +3 -3
- package/src/dex/aave-v2/tokenlist.json +904 -0
- package/src/dex/aave-v2/tokens.ts +3 -4
- package/src/dex/aave-v3/config.ts +6 -7
- package/src/dex/aave-v3-stata-v2/aave-v3-stata-v2-e2e.test.ts +397 -0
- package/src/dex/aave-v3-stata-v2/aave-v3-stata-v2-integration.test.ts +600 -0
- package/src/dex/aave-v3-stata-v2/aave-v3-stata-v2.ts +477 -0
- package/src/dex/aave-v3-stata-v2/config.ts +24 -0
- package/src/dex/aave-v3-stata-v2/tokens.ts +48 -0
- package/src/dex/aave-v3-stata-v2/types.ts +41 -0
- package/src/dex/aave-v3-stata-v2/utils.ts +88 -0
- package/src/dex/index.ts +2 -0
- package/src/dex/stkgho/config.ts +3 -3
- package/tests/constants-e2e.ts +11 -1
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { Interface, Result } from '@ethersproject/abi';
|
|
6
|
+
import { DummyDexHelper } from '../../dex-helper/index';
|
|
7
|
+
import { Network, SwapSide } from '../../constants';
|
|
8
|
+
import { BI_POWS } from '../../bigint-constants';
|
|
9
|
+
import { AaveV3StataV2 } from './aave-v3-stata-v2';
|
|
10
|
+
import {
|
|
11
|
+
checkPoolPrices,
|
|
12
|
+
checkPoolsLiquidity,
|
|
13
|
+
checkConstantPoolPrices,
|
|
14
|
+
} from '../../../tests/utils';
|
|
15
|
+
import { Tokens } from '../../../tests/constants-e2e';
|
|
16
|
+
|
|
17
|
+
function getReaderCalldata(
|
|
18
|
+
exchangeAddress: string,
|
|
19
|
+
readerIface: Interface,
|
|
20
|
+
amounts: bigint[],
|
|
21
|
+
funcName: string,
|
|
22
|
+
) {
|
|
23
|
+
return amounts.map(amount => ({
|
|
24
|
+
target: exchangeAddress,
|
|
25
|
+
callData: readerIface.encodeFunctionData(funcName, [amount]),
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function decodeReaderResult(
|
|
30
|
+
results: Result,
|
|
31
|
+
readerIface: Interface,
|
|
32
|
+
funcName: string,
|
|
33
|
+
) {
|
|
34
|
+
return results.map(result => {
|
|
35
|
+
const parsed = readerIface.decodeFunctionResult(funcName, result);
|
|
36
|
+
return BigInt(parsed[0]._hex);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function checkOnChainPricing(
|
|
41
|
+
aaveV3Statav2: AaveV3StataV2,
|
|
42
|
+
exchangeAddress: string,
|
|
43
|
+
funcName: string,
|
|
44
|
+
blockNumber: number,
|
|
45
|
+
prices: bigint[],
|
|
46
|
+
amounts: bigint[],
|
|
47
|
+
) {
|
|
48
|
+
const readerIface = AaveV3StataV2.stata;
|
|
49
|
+
|
|
50
|
+
const readerCallData = getReaderCalldata(
|
|
51
|
+
exchangeAddress,
|
|
52
|
+
readerIface,
|
|
53
|
+
amounts.slice(1),
|
|
54
|
+
funcName,
|
|
55
|
+
);
|
|
56
|
+
const readerResult = (
|
|
57
|
+
await aaveV3Statav2.dexHelper.multiContract.methods
|
|
58
|
+
.aggregate(readerCallData)
|
|
59
|
+
.call({}, blockNumber)
|
|
60
|
+
).returnData;
|
|
61
|
+
|
|
62
|
+
const expectedPrices = [0n].concat(
|
|
63
|
+
decodeReaderResult(readerResult, readerIface, funcName),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
expect(prices).toEqual(expectedPrices);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function testPricingOnNetwork(
|
|
70
|
+
aaveV3Statav2: AaveV3StataV2,
|
|
71
|
+
network: Network,
|
|
72
|
+
dexKey: string,
|
|
73
|
+
blockNumber: number,
|
|
74
|
+
srcTokenSymbol: string,
|
|
75
|
+
destTokenSymbol: string,
|
|
76
|
+
side: SwapSide,
|
|
77
|
+
amounts: bigint[],
|
|
78
|
+
exchangeAddress: string,
|
|
79
|
+
funcNameToCheck: string,
|
|
80
|
+
) {
|
|
81
|
+
const networkTokens = Tokens[network];
|
|
82
|
+
|
|
83
|
+
const pools = await aaveV3Statav2.getPoolIdentifiers(
|
|
84
|
+
networkTokens[srcTokenSymbol],
|
|
85
|
+
networkTokens[destTokenSymbol],
|
|
86
|
+
side,
|
|
87
|
+
blockNumber,
|
|
88
|
+
);
|
|
89
|
+
console.log(
|
|
90
|
+
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Identifiers: `,
|
|
91
|
+
pools,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
95
|
+
|
|
96
|
+
const poolPrices = await aaveV3Statav2.getPricesVolume(
|
|
97
|
+
networkTokens[srcTokenSymbol],
|
|
98
|
+
networkTokens[destTokenSymbol],
|
|
99
|
+
amounts,
|
|
100
|
+
side,
|
|
101
|
+
blockNumber,
|
|
102
|
+
pools,
|
|
103
|
+
);
|
|
104
|
+
console.log(
|
|
105
|
+
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Prices: `,
|
|
106
|
+
poolPrices,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(poolPrices).not.toBeNull();
|
|
110
|
+
if (aaveV3Statav2.hasConstantPriceLargeAmounts) {
|
|
111
|
+
checkConstantPoolPrices(poolPrices!, amounts, dexKey);
|
|
112
|
+
} else {
|
|
113
|
+
checkPoolPrices(poolPrices!, amounts, side, dexKey);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Check if onchain pricing equals to calculated ones
|
|
117
|
+
await checkOnChainPricing(
|
|
118
|
+
aaveV3Statav2,
|
|
119
|
+
exchangeAddress,
|
|
120
|
+
funcNameToCheck,
|
|
121
|
+
blockNumber,
|
|
122
|
+
poolPrices![0].prices,
|
|
123
|
+
amounts,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
describe('AaveV3StataV2', function () {
|
|
128
|
+
const dexKey = 'AaveV3StataV2';
|
|
129
|
+
let blockNumber: number;
|
|
130
|
+
let aaveV3Statav2: AaveV3StataV2;
|
|
131
|
+
|
|
132
|
+
describe('Mainnet', () => {
|
|
133
|
+
const network = Network.MAINNET;
|
|
134
|
+
const dexHelper = new DummyDexHelper(network);
|
|
135
|
+
|
|
136
|
+
const tokens = Tokens[network];
|
|
137
|
+
|
|
138
|
+
const srcTokenSymbol = 'USDT';
|
|
139
|
+
const destTokenSymbol = 'waEthUSDT';
|
|
140
|
+
|
|
141
|
+
const amountsForSell = [
|
|
142
|
+
0n,
|
|
143
|
+
1n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
144
|
+
2n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
145
|
+
3n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
146
|
+
4n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
147
|
+
5n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
148
|
+
6n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
149
|
+
7n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
150
|
+
8n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
151
|
+
9n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
152
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
const amountsForBuy = [
|
|
156
|
+
0n,
|
|
157
|
+
1n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
158
|
+
2n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
159
|
+
3n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
160
|
+
4n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
161
|
+
5n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
162
|
+
6n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
163
|
+
7n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
164
|
+
8n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
165
|
+
9n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
166
|
+
10n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
beforeAll(async () => {
|
|
170
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
171
|
+
aaveV3Statav2 = new AaveV3StataV2(network, dexKey, dexHelper);
|
|
172
|
+
if (aaveV3Statav2.initializePricing) {
|
|
173
|
+
await aaveV3Statav2.initializePricing(blockNumber);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('getPoolIdentifiers and getPricesVolume SELL USDT -> waEthUSDT', async function () {
|
|
178
|
+
await testPricingOnNetwork(
|
|
179
|
+
aaveV3Statav2,
|
|
180
|
+
network,
|
|
181
|
+
dexKey,
|
|
182
|
+
blockNumber,
|
|
183
|
+
srcTokenSymbol,
|
|
184
|
+
destTokenSymbol,
|
|
185
|
+
SwapSide.SELL,
|
|
186
|
+
amountsForSell,
|
|
187
|
+
'0x7Bc3485026Ac48b6cf9BaF0A377477Fff5703Af8',
|
|
188
|
+
'previewDeposit',
|
|
189
|
+
);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('getPoolIdentifiers and getPricesVolume SELL waEthUSDT -> USDT ', async function () {
|
|
193
|
+
await testPricingOnNetwork(
|
|
194
|
+
aaveV3Statav2,
|
|
195
|
+
network,
|
|
196
|
+
dexKey,
|
|
197
|
+
blockNumber,
|
|
198
|
+
destTokenSymbol,
|
|
199
|
+
srcTokenSymbol,
|
|
200
|
+
SwapSide.SELL,
|
|
201
|
+
amountsForSell,
|
|
202
|
+
'0x7Bc3485026Ac48b6cf9BaF0A377477Fff5703Af8',
|
|
203
|
+
'previewRedeem',
|
|
204
|
+
);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('getPoolIdentifiers and getPricesVolume BUY USDT -> waEthUSDT', async function () {
|
|
208
|
+
await testPricingOnNetwork(
|
|
209
|
+
aaveV3Statav2,
|
|
210
|
+
network,
|
|
211
|
+
dexKey,
|
|
212
|
+
blockNumber,
|
|
213
|
+
srcTokenSymbol,
|
|
214
|
+
destTokenSymbol,
|
|
215
|
+
SwapSide.BUY,
|
|
216
|
+
amountsForBuy,
|
|
217
|
+
'0x7Bc3485026Ac48b6cf9BaF0A377477Fff5703Af8',
|
|
218
|
+
'previewMint',
|
|
219
|
+
);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('getPoolIdentifiers and getPricesVolume BUY waEthUSDT -> USDT', async function () {
|
|
223
|
+
await testPricingOnNetwork(
|
|
224
|
+
aaveV3Statav2,
|
|
225
|
+
network,
|
|
226
|
+
dexKey,
|
|
227
|
+
blockNumber,
|
|
228
|
+
destTokenSymbol,
|
|
229
|
+
srcTokenSymbol,
|
|
230
|
+
SwapSide.BUY,
|
|
231
|
+
amountsForBuy,
|
|
232
|
+
'0x7Bc3485026Ac48b6cf9BaF0A377477Fff5703Af8',
|
|
233
|
+
'previewWithdraw',
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it(`getTopPoolsForToken - ${srcTokenSymbol}`, async function () {
|
|
238
|
+
// We have to check without calling initializePricing, because
|
|
239
|
+
// pool-tracker is not calling that function
|
|
240
|
+
const newAaveV3Stata = new AaveV3StataV2(network, dexKey, dexHelper);
|
|
241
|
+
if (newAaveV3Stata.updatePoolState) {
|
|
242
|
+
await newAaveV3Stata.updatePoolState();
|
|
243
|
+
}
|
|
244
|
+
const poolLiquidity = await newAaveV3Stata.getTopPoolsForToken(
|
|
245
|
+
tokens[srcTokenSymbol].address,
|
|
246
|
+
10,
|
|
247
|
+
);
|
|
248
|
+
console.log(
|
|
249
|
+
`${srcTokenSymbol} Top Pools:`,
|
|
250
|
+
JSON.stringify(poolLiquidity, null, 2),
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
if (!newAaveV3Stata.hasConstantPriceLargeAmounts) {
|
|
254
|
+
checkPoolsLiquidity(
|
|
255
|
+
poolLiquidity,
|
|
256
|
+
Tokens[network][srcTokenSymbol].address,
|
|
257
|
+
dexKey,
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it(`getTopPoolsForToken - ${destTokenSymbol}`, async function () {
|
|
263
|
+
// We have to check without calling initializePricing, because
|
|
264
|
+
// pool-tracker is not calling that function
|
|
265
|
+
const newAaveV3Stata = new AaveV3StataV2(network, dexKey, dexHelper);
|
|
266
|
+
if (newAaveV3Stata.updatePoolState) {
|
|
267
|
+
await newAaveV3Stata.updatePoolState();
|
|
268
|
+
}
|
|
269
|
+
const poolLiquidity = await newAaveV3Stata.getTopPoolsForToken(
|
|
270
|
+
tokens[destTokenSymbol].address,
|
|
271
|
+
10,
|
|
272
|
+
);
|
|
273
|
+
console.log(
|
|
274
|
+
`${destTokenSymbol} Top Pools:`,
|
|
275
|
+
JSON.stringify(poolLiquidity, null, 2),
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
if (!newAaveV3Stata.hasConstantPriceLargeAmounts) {
|
|
279
|
+
checkPoolsLiquidity(
|
|
280
|
+
poolLiquidity,
|
|
281
|
+
Tokens[network][destTokenSymbol].address,
|
|
282
|
+
dexKey,
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
describe('Gnosis', () => {
|
|
289
|
+
const network = Network.GNOSIS;
|
|
290
|
+
const dexHelper = new DummyDexHelper(network);
|
|
291
|
+
|
|
292
|
+
const tokens = Tokens[network];
|
|
293
|
+
|
|
294
|
+
const srcTokenSymbol = 'wstETH';
|
|
295
|
+
const destTokenSymbol = 'waGnowstETH';
|
|
296
|
+
|
|
297
|
+
const amountsForSell = [
|
|
298
|
+
0n,
|
|
299
|
+
1n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
300
|
+
2n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
301
|
+
3n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
302
|
+
4n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
303
|
+
5n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
304
|
+
6n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
305
|
+
7n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
306
|
+
8n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
307
|
+
9n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
308
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
309
|
+
];
|
|
310
|
+
|
|
311
|
+
const amountsForBuy = [
|
|
312
|
+
0n,
|
|
313
|
+
1n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
314
|
+
2n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
315
|
+
3n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
316
|
+
4n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
317
|
+
5n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
318
|
+
6n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
319
|
+
7n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
320
|
+
8n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
321
|
+
9n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
322
|
+
10n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
323
|
+
];
|
|
324
|
+
|
|
325
|
+
beforeAll(async () => {
|
|
326
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
327
|
+
aaveV3Statav2 = new AaveV3StataV2(network, dexKey, dexHelper);
|
|
328
|
+
if (aaveV3Statav2.initializePricing) {
|
|
329
|
+
await aaveV3Statav2.initializePricing(blockNumber);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('getPoolIdentifiers and getPricesVolume SELL wstETH -> waGnowstETH', async function () {
|
|
334
|
+
await testPricingOnNetwork(
|
|
335
|
+
aaveV3Statav2,
|
|
336
|
+
network,
|
|
337
|
+
dexKey,
|
|
338
|
+
blockNumber,
|
|
339
|
+
srcTokenSymbol,
|
|
340
|
+
destTokenSymbol,
|
|
341
|
+
SwapSide.SELL,
|
|
342
|
+
amountsForSell,
|
|
343
|
+
'0x773CDA0CADe2A3d86E6D4e30699d40bB95174ff2',
|
|
344
|
+
'previewDeposit',
|
|
345
|
+
);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it('getPoolIdentifiers and getPricesVolume SELL waGnowstETH -> wstETH', async function () {
|
|
349
|
+
await testPricingOnNetwork(
|
|
350
|
+
aaveV3Statav2,
|
|
351
|
+
network,
|
|
352
|
+
dexKey,
|
|
353
|
+
blockNumber,
|
|
354
|
+
destTokenSymbol,
|
|
355
|
+
srcTokenSymbol,
|
|
356
|
+
SwapSide.SELL,
|
|
357
|
+
amountsForSell,
|
|
358
|
+
'0x773CDA0CADe2A3d86E6D4e30699d40bB95174ff2',
|
|
359
|
+
'previewRedeem',
|
|
360
|
+
);
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it('getPoolIdentifiers and getPricesVolume BUY wstETH -> waGnowstETH', async function () {
|
|
364
|
+
await testPricingOnNetwork(
|
|
365
|
+
aaveV3Statav2,
|
|
366
|
+
network,
|
|
367
|
+
dexKey,
|
|
368
|
+
blockNumber,
|
|
369
|
+
srcTokenSymbol,
|
|
370
|
+
destTokenSymbol,
|
|
371
|
+
SwapSide.BUY,
|
|
372
|
+
amountsForBuy,
|
|
373
|
+
'0x773CDA0CADe2A3d86E6D4e30699d40bB95174ff2',
|
|
374
|
+
'previewMint',
|
|
375
|
+
);
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it('getPoolIdentifiers and getPricesVolume BUY waGnowstETH -> wstETH', async function () {
|
|
379
|
+
await testPricingOnNetwork(
|
|
380
|
+
aaveV3Statav2,
|
|
381
|
+
network,
|
|
382
|
+
dexKey,
|
|
383
|
+
blockNumber,
|
|
384
|
+
destTokenSymbol,
|
|
385
|
+
srcTokenSymbol,
|
|
386
|
+
SwapSide.BUY,
|
|
387
|
+
amountsForBuy,
|
|
388
|
+
'0x773CDA0CADe2A3d86E6D4e30699d40bB95174ff2',
|
|
389
|
+
'previewWithdraw',
|
|
390
|
+
);
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it(`getTopPoolsForToken - ${srcTokenSymbol}`, async function () {
|
|
394
|
+
// We have to check without calling initializePricing, because
|
|
395
|
+
// pool-tracker is not calling that function
|
|
396
|
+
const newAaveV3Stata = new AaveV3StataV2(network, dexKey, dexHelper);
|
|
397
|
+
if (newAaveV3Stata.updatePoolState) {
|
|
398
|
+
await newAaveV3Stata.updatePoolState();
|
|
399
|
+
}
|
|
400
|
+
const poolLiquidity = await newAaveV3Stata.getTopPoolsForToken(
|
|
401
|
+
tokens[srcTokenSymbol].address,
|
|
402
|
+
10,
|
|
403
|
+
);
|
|
404
|
+
console.log(
|
|
405
|
+
`${srcTokenSymbol} Top Pools:`,
|
|
406
|
+
JSON.stringify(poolLiquidity, null, 2),
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
if (!newAaveV3Stata.hasConstantPriceLargeAmounts) {
|
|
410
|
+
checkPoolsLiquidity(
|
|
411
|
+
poolLiquidity,
|
|
412
|
+
Tokens[network][srcTokenSymbol].address,
|
|
413
|
+
dexKey,
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
it(`getTopPoolsForToken - ${destTokenSymbol}`, async function () {
|
|
419
|
+
// We have to check without calling initializePricing, because
|
|
420
|
+
// pool-tracker is not calling that function
|
|
421
|
+
const newAaveV3Stata = new AaveV3StataV2(network, dexKey, dexHelper);
|
|
422
|
+
if (newAaveV3Stata.updatePoolState) {
|
|
423
|
+
await newAaveV3Stata.updatePoolState();
|
|
424
|
+
}
|
|
425
|
+
const poolLiquidity = await newAaveV3Stata.getTopPoolsForToken(
|
|
426
|
+
tokens[destTokenSymbol].address,
|
|
427
|
+
10,
|
|
428
|
+
);
|
|
429
|
+
console.log(
|
|
430
|
+
`${destTokenSymbol} Top Pools:`,
|
|
431
|
+
JSON.stringify(poolLiquidity, null, 2),
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
if (!newAaveV3Stata.hasConstantPriceLargeAmounts) {
|
|
435
|
+
checkPoolsLiquidity(
|
|
436
|
+
poolLiquidity,
|
|
437
|
+
Tokens[network][destTokenSymbol].address,
|
|
438
|
+
dexKey,
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
// polygon is not yet live
|
|
445
|
+
describe.skip('Polygon', () => {
|
|
446
|
+
const network = Network.POLYGON;
|
|
447
|
+
const dexHelper = new DummyDexHelper(network);
|
|
448
|
+
|
|
449
|
+
const tokens = Tokens[network];
|
|
450
|
+
|
|
451
|
+
const srcTokenSymbol = 'USDCn';
|
|
452
|
+
const destTokenSymbol = 'stataUSDCn';
|
|
453
|
+
|
|
454
|
+
const amountsForSell = [
|
|
455
|
+
0n,
|
|
456
|
+
1n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
457
|
+
2n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
458
|
+
3n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
459
|
+
4n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
460
|
+
5n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
461
|
+
6n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
462
|
+
7n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
463
|
+
8n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
464
|
+
9n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
465
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
466
|
+
];
|
|
467
|
+
|
|
468
|
+
const amountsForBuy = [
|
|
469
|
+
0n,
|
|
470
|
+
1n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
471
|
+
2n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
472
|
+
3n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
473
|
+
4n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
474
|
+
5n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
475
|
+
6n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
476
|
+
7n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
477
|
+
8n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
478
|
+
9n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
479
|
+
10n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
480
|
+
];
|
|
481
|
+
|
|
482
|
+
beforeAll(async () => {
|
|
483
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
484
|
+
aaveV3Statav2 = new AaveV3StataV2(network, dexKey, dexHelper);
|
|
485
|
+
if (aaveV3Statav2.initializePricing) {
|
|
486
|
+
await aaveV3Statav2.initializePricing(blockNumber);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
it('getPoolIdentifiers and getPricesVolume SELL USDCn -> stataUSDCn', async function () {
|
|
491
|
+
await testPricingOnNetwork(
|
|
492
|
+
aaveV3Statav2,
|
|
493
|
+
network,
|
|
494
|
+
dexKey,
|
|
495
|
+
blockNumber,
|
|
496
|
+
srcTokenSymbol,
|
|
497
|
+
destTokenSymbol,
|
|
498
|
+
SwapSide.SELL,
|
|
499
|
+
amountsForSell,
|
|
500
|
+
'0x2dca80061632f3f87c9ca28364d1d0c30cd79a19',
|
|
501
|
+
'previewDeposit',
|
|
502
|
+
);
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
it('getPoolIdentifiers and getPricesVolume SELL stataUSDCn -> USDCn ', async function () {
|
|
506
|
+
await testPricingOnNetwork(
|
|
507
|
+
aaveV3Statav2,
|
|
508
|
+
network,
|
|
509
|
+
dexKey,
|
|
510
|
+
blockNumber,
|
|
511
|
+
destTokenSymbol,
|
|
512
|
+
srcTokenSymbol,
|
|
513
|
+
SwapSide.SELL,
|
|
514
|
+
amountsForSell,
|
|
515
|
+
'0x2dca80061632f3f87c9ca28364d1d0c30cd79a19',
|
|
516
|
+
'previewRedeem',
|
|
517
|
+
);
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
it('getPoolIdentifiers and getPricesVolume BUY USDC -> stataUSDCn', async function () {
|
|
521
|
+
await testPricingOnNetwork(
|
|
522
|
+
aaveV3Statav2,
|
|
523
|
+
network,
|
|
524
|
+
dexKey,
|
|
525
|
+
blockNumber,
|
|
526
|
+
srcTokenSymbol,
|
|
527
|
+
destTokenSymbol,
|
|
528
|
+
SwapSide.BUY,
|
|
529
|
+
amountsForBuy,
|
|
530
|
+
'0x2dca80061632f3f87c9ca28364d1d0c30cd79a19',
|
|
531
|
+
'previewMint',
|
|
532
|
+
);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
it('getPoolIdentifiers and getPricesVolume BUY stataUSDCn -> USDC', async function () {
|
|
536
|
+
await testPricingOnNetwork(
|
|
537
|
+
aaveV3Statav2,
|
|
538
|
+
network,
|
|
539
|
+
dexKey,
|
|
540
|
+
blockNumber,
|
|
541
|
+
destTokenSymbol,
|
|
542
|
+
srcTokenSymbol,
|
|
543
|
+
SwapSide.BUY,
|
|
544
|
+
amountsForBuy,
|
|
545
|
+
'0x2dca80061632f3f87c9ca28364d1d0c30cd79a19',
|
|
546
|
+
'previewWithdraw',
|
|
547
|
+
);
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
it(`getTopPoolsForToken - ${srcTokenSymbol}`, async function () {
|
|
551
|
+
// We have to check without calling initializePricing, because
|
|
552
|
+
// pool-tracker is not calling that function
|
|
553
|
+
const newAaveV3Stata = new AaveV3StataV2(network, dexKey, dexHelper);
|
|
554
|
+
if (newAaveV3Stata.updatePoolState) {
|
|
555
|
+
await newAaveV3Stata.updatePoolState();
|
|
556
|
+
}
|
|
557
|
+
const poolLiquidity = await newAaveV3Stata.getTopPoolsForToken(
|
|
558
|
+
tokens[srcTokenSymbol].address,
|
|
559
|
+
10,
|
|
560
|
+
);
|
|
561
|
+
console.log(
|
|
562
|
+
`${srcTokenSymbol} Top Pools:`,
|
|
563
|
+
JSON.stringify(poolLiquidity, null, 2),
|
|
564
|
+
);
|
|
565
|
+
|
|
566
|
+
if (!newAaveV3Stata.hasConstantPriceLargeAmounts) {
|
|
567
|
+
checkPoolsLiquidity(
|
|
568
|
+
poolLiquidity,
|
|
569
|
+
Tokens[network][srcTokenSymbol].address,
|
|
570
|
+
dexKey,
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
it(`getTopPoolsForToken - ${destTokenSymbol}`, async function () {
|
|
576
|
+
// We have to check without calling initializePricing, because
|
|
577
|
+
// pool-tracker is not calling that function
|
|
578
|
+
const newAaveV3Stata = new AaveV3StataV2(network, dexKey, dexHelper);
|
|
579
|
+
if (newAaveV3Stata.updatePoolState) {
|
|
580
|
+
await newAaveV3Stata.updatePoolState();
|
|
581
|
+
}
|
|
582
|
+
const poolLiquidity = await newAaveV3Stata.getTopPoolsForToken(
|
|
583
|
+
tokens[destTokenSymbol].address,
|
|
584
|
+
10,
|
|
585
|
+
);
|
|
586
|
+
console.log(
|
|
587
|
+
`${destTokenSymbol} Top Pools:`,
|
|
588
|
+
JSON.stringify(poolLiquidity, null, 2),
|
|
589
|
+
);
|
|
590
|
+
|
|
591
|
+
if (!newAaveV3Stata.hasConstantPriceLargeAmounts) {
|
|
592
|
+
checkPoolsLiquidity(
|
|
593
|
+
poolLiquidity,
|
|
594
|
+
Tokens[network][destTokenSymbol].address,
|
|
595
|
+
dexKey,
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
});
|
|
600
|
+
});
|