forked from paraswap/paraswap-dex-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaave-v2-integration.test.ts
100 lines (82 loc) · 2.97 KB
/
aave-v2-integration.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import dotenv from 'dotenv';
dotenv.config();
import { DummyDexHelper } from '../../dex-helper/index';
import { Network, SwapSide } from '../../constants';
import { AaveV2 } from './aave-v2';
import {
checkPoolsLiquidity,
checkConstantPoolPrices,
} from '../../../tests/utils';
import { Tokens } from '../../../tests/constants-e2e';
import { aaveV2GetToken } from './tokens';
import { BI_POWS } from '../../bigint-constants';
describe('AaveV2', function () {
describe('AaveV2 MAINNET', () => {
const network = Network.MAINNET;
const USDTSymbol = 'USDT';
const USDT = Tokens[network][USDTSymbol];
const aUSDTSymbol = 'aUSDT';
const aUSDT = aaveV2GetToken(network, aUSDTSymbol);
const amounts = [0n, BI_POWS[18], 2000000000000000000n];
const dexKey = 'AaveV2';
if (!aUSDT) {
expect(aUSDT).not.toBe(null);
return;
}
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
const dexHelper = new DummyDexHelper(network);
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
const aaveV2 = new AaveV2(network, dexKey, dexHelper);
const pools = await aaveV2.getPoolIdentifiers(
USDT,
aUSDT,
SwapSide.SELL,
blocknumber,
);
console.log(`${USDTSymbol} <> ${aUSDTSymbol} Pool Identifiers: `, pools);
expect(pools.length).toBeGreaterThan(0);
const poolPrices = await aaveV2.getPricesVolume(
USDT,
aUSDT,
amounts,
SwapSide.SELL,
blocknumber,
pools,
);
console.log('${USDTSymbol} <> ${aUSDTSymbol} Pool Prices: ', poolPrices);
expect(poolPrices).not.toBeNull();
checkConstantPoolPrices(poolPrices!, amounts, dexKey);
});
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
const dexHelper = new DummyDexHelper(network);
const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
const aaveV2 = new AaveV2(network, dexKey, dexHelper);
const pools = await aaveV2.getPoolIdentifiers(
USDT,
aUSDT,
SwapSide.BUY,
blocknumber,
);
console.log(`${USDTSymbol} <> ${aUSDTSymbol} Pool Identifiers: `, pools);
expect(pools.length).toBeGreaterThan(0);
const poolPrices = await aaveV2.getPricesVolume(
USDT,
aUSDT,
amounts,
SwapSide.BUY,
blocknumber,
pools,
);
console.log('${USDTSymbol} <> ${aUSDTSymbol} Pool Prices: ', poolPrices);
expect(poolPrices).not.toBeNull();
checkConstantPoolPrices(poolPrices!, amounts, dexKey);
});
it('getTopPoolsForToken', async function () {
const dexHelper = new DummyDexHelper(network);
const aaveV2 = new AaveV2(network, dexKey, dexHelper);
const poolLiquidity = await aaveV2.getTopPoolsForToken(USDT.address, 10);
console.log(`${USDTSymbol} Top Pools:`, poolLiquidity);
checkPoolsLiquidity(poolLiquidity, USDT.address, dexKey);
});
});
});