@paraswap/dex-lib 3.8.25 → 3.8.26-aave-gsm
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/Aave_GSM.json +751 -0
- package/build/abi/{integral/pool.json → inception/inception-ineth-pool.json} +558 -537
- package/build/abi/inception/inception-ineth.json +609 -0
- package/build/abi/inception/inception-ratio-feed.json +93 -0
- package/build/abi/inception/inception-vault.json +991 -0
- package/build/dex/aave-gsm/aave-gsm.d.ts +33 -0
- package/build/dex/aave-gsm/aave-gsm.js +278 -0
- package/build/dex/aave-gsm/aave-gsm.js.map +1 -0
- package/build/dex/aave-gsm/config.d.ts +3 -0
- package/build/dex/aave-gsm/config.js +17 -0
- package/build/dex/aave-gsm/config.js.map +1 -0
- package/build/dex/aave-gsm/types.d.ts +11 -0
- package/build/dex/aave-gsm/types.js +3 -0
- package/build/dex/aave-gsm/types.js.map +1 -0
- package/build/dex/aave-v1/aave-v1.d.ts +2 -1
- package/build/dex/aave-v1/aave-v1.js +22 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/generic-rfq/rate-fetcher.js +1 -1
- package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
- package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
- package/build/dex/idle-dao/idle-dao-pool.js +176 -0
- package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
- package/build/dex/idle-dao/scripts.d.ts +9 -0
- package/build/dex/idle-dao/scripts.js +552 -0
- package/build/dex/idle-dao/scripts.js.map +1 -0
- package/build/dex/inception/config.d.ts +5 -0
- package/build/dex/inception/config.js +112 -0
- package/build/dex/inception/config.js.map +1 -0
- package/build/dex/inception/inception-event-pool.d.ts +25 -0
- package/build/dex/inception/inception-event-pool.js +57 -0
- package/build/dex/inception/inception-event-pool.js.map +1 -0
- package/build/dex/{integral/integral.d.ts → inception/inception-native.d.ts} +21 -19
- package/build/dex/inception/inception-native.js +131 -0
- package/build/dex/inception/inception-native.js.map +1 -0
- package/build/dex/inception/inception-pool.d.ts +18 -0
- package/build/dex/inception/inception-pool.js +32 -0
- package/build/dex/inception/inception-pool.js.map +1 -0
- package/build/dex/inception/inception-price-feed.d.ts +19 -0
- package/build/dex/inception/inception-price-feed.js +51 -0
- package/build/dex/inception/inception-price-feed.js.map +1 -0
- package/build/dex/inception/inception.d.ts +44 -0
- package/build/dex/inception/inception.js +177 -0
- package/build/dex/inception/inception.js.map +1 -0
- package/build/dex/inception/tokens.d.ts +9 -0
- package/build/dex/inception/tokens.js +28 -0
- package/build/dex/inception/tokens.js.map +1 -0
- package/build/dex/inception/types.d.ts +22 -0
- package/build/dex/inception/types.js +3 -0
- package/build/dex/inception/types.js.map +1 -0
- package/build/dex/inception/utils.d.ts +7 -0
- package/build/dex/inception/utils.js +58 -0
- package/build/dex/inception/utils.js.map +1 -0
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +2 -1
- package/build/dex/platypus/platypus.js +31 -0
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
- package/build/dex/swaap-v1/swaap-v1.js +10 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/Aave_GSM.json +751 -0
- package/src/dex/aave-gsm/aave-gsm-e2e.test.ts +109 -0
- package/src/dex/aave-gsm/aave-gsm-integration.test.ts +318 -0
- package/src/dex/aave-gsm/aave-gsm.ts +359 -0
- package/src/dex/aave-gsm/config.ts +16 -0
- package/src/dex/aave-gsm/types.ts +15 -0
- package/src/dex/generic-rfq/rate-fetcher.ts +6 -5
- package/src/dex/index.ts +2 -0
- package/.vscode/launch.json +0 -16
- package/.vscode/settings.json +0 -3
- package/build/abi/Uncompressor.json +0 -250
- package/build/abi/integral/factory.json +0 -333
- package/build/abi/integral/oracle.json +0 -501
- package/build/abi/integral/relayer.json +0 -1536
- package/build/dex/bProtocol.d.ts +0 -18
- package/build/dex/bProtocol.js +0 -39
- package/build/dex/bProtocol.js.map +0 -1
- package/build/dex/bancor.d.ts +0 -26
- package/build/dex/bancor.js +0 -58
- package/build/dex/bancor.js.map +0 -1
- package/build/dex/compound.d.ts +0 -18
- package/build/dex/compound.js +0 -46
- package/build/dex/compound.js.map +0 -1
- package/build/dex/curve-v2.d.ts +0 -58
- package/build/dex/curve-v2.js +0 -180
- package/build/dex/curve-v2.js.map +0 -1
- package/build/dex/dodo-v1.d.ts +0 -33
- package/build/dex/dodo-v1.js +0 -63
- package/build/dex/dodo-v1.js.map +0 -1
- package/build/dex/etherfi/etherfi.d.ts +0 -26
- package/build/dex/etherfi/etherfi.js +0 -96
- package/build/dex/etherfi/etherfi.js.map +0 -1
- package/build/dex/integral/config.d.ts +0 -4
- package/build/dex/integral/config.js +0 -20
- package/build/dex/integral/config.js.map +0 -1
- package/build/dex/integral/context.d.ts +0 -40
- package/build/dex/integral/context.js +0 -158
- package/build/dex/integral/context.js.map +0 -1
- package/build/dex/integral/helpers.d.ts +0 -17
- package/build/dex/integral/helpers.js +0 -157
- package/build/dex/integral/helpers.js.map +0 -1
- package/build/dex/integral/integral-factory.d.ts +0 -24
- package/build/dex/integral/integral-factory.js +0 -95
- package/build/dex/integral/integral-factory.js.map +0 -1
- package/build/dex/integral/integral-pool.d.ts +0 -50
- package/build/dex/integral/integral-pool.js +0 -149
- package/build/dex/integral/integral-pool.js.map +0 -1
- package/build/dex/integral/integral-pricing.d.ts +0 -18
- package/build/dex/integral/integral-pricing.js +0 -114
- package/build/dex/integral/integral-pricing.js.map +0 -1
- package/build/dex/integral/integral-relayer.d.ts +0 -42
- package/build/dex/integral/integral-relayer.js +0 -192
- package/build/dex/integral/integral-relayer.js.map +0 -1
- package/build/dex/integral/integral-token.d.ts +0 -27
- package/build/dex/integral/integral-token.js +0 -59
- package/build/dex/integral/integral-token.js.map +0 -1
- package/build/dex/integral/integral.js +0 -376
- package/build/dex/integral/integral.js.map +0 -1
- package/build/dex/integral/types.d.ts +0 -85
- package/build/dex/integral/types.js +0 -9
- package/build/dex/integral/types.js.map +0 -1
- package/build/dex/integral/utils-e2e.d.ts +0 -9
- package/build/dex/integral/utils-e2e.js +0 -131
- package/build/dex/integral/utils-e2e.js.map +0 -1
- package/build/dex/integral/utils.d.ts +0 -17
- package/build/dex/integral/utils.js +0 -94
- package/build/dex/integral/utils.js.map +0 -1
- package/build/dex/lido.d.ts +0 -19
- package/build/dex/lido.js +0 -42
- package/build/dex/lido.js.map +0 -1
- package/build/dex/onebit.d.ts +0 -25
- package/build/dex/onebit.js +0 -42
- package/build/dex/onebit.js.map +0 -1
- package/build/dex/sdai/config.d.ts +0 -11
- package/build/dex/sdai/config.js +0 -21
- package/build/dex/sdai/config.js.map +0 -1
- package/build/dex/sdai/constants.d.ts +0 -2
- package/build/dex/sdai/constants.js +0 -6
- package/build/dex/sdai/constants.js.map +0 -1
- package/build/dex/sdai/scripts/validate-state.d.ts +0 -1
- package/build/dex/sdai/scripts/validate-state.js +0 -102
- package/build/dex/sdai/scripts/validate-state.js.map +0 -1
- package/build/dex/sdai/sdai-pool.d.ts +0 -16
- package/build/dex/sdai/sdai-pool.js +0 -85
- package/build/dex/sdai/sdai-pool.js.map +0 -1
- package/build/dex/sdai/sdai.d.ts +0 -51
- package/build/dex/sdai/sdai.js +0 -172
- package/build/dex/sdai/sdai.js.map +0 -1
- package/build/dex/sdai/types.d.ts +0 -21
- package/build/dex/sdai/types.js +0 -11
- package/build/dex/sdai/types.js.map +0 -1
- package/build/dex/sdai/utils.d.ts +0 -4
- package/build/dex/sdai/utils.js +0 -39
- package/build/dex/sdai/utils.js.map +0 -1
- package/build/dex/smoothy.d.ts +0 -26
- package/build/dex/smoothy.js +0 -48
- package/build/dex/smoothy.js.map +0 -1
- package/build/dex/stable-pool.d.ts +0 -28
- package/build/dex/stable-pool.js +0 -62
- package/build/dex/stable-pool.js.map +0 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
- package/build/dex/trader-joe-v2.1/optimizer.js +0 -44
- package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
- package/build/dex/trader-joe-v2.1.d.ts +0 -43
- package/build/dex/trader-joe-v2.1.js +0 -79
- package/build/dex/trader-joe-v2.1.js.map +0 -1
- package/build/executor/compressor/Compressor.d.ts +0 -23
- package/build/executor/compressor/Compressor.js +0 -144
- package/build/executor/compressor/Compressor.js.map +0 -1
- package/build/executor/compressor/compress.d.ts +0 -17
- package/build/executor/compressor/compress.js +0 -187
- package/build/executor/compressor/compress.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/addressSubstitution.js +0 -29
- package/build/executor/compressor/compress_functions/addressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +0 -10
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +0 -40
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +0 -1
- package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +0 -11
- package/build/executor/compressor/compress_functions/byteSubstitution.js +0 -64
- package/build/executor/compressor/compress_functions/byteSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +0 -7
- package/build/executor/compressor/compress_functions/ffSubstitution.js +0 -54
- package/build/executor/compressor/compress_functions/ffSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +0 -67
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +0 -61
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +0 -1
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +0 -37
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +0 -9
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js +0 -33
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +0 -1
- package/build/executor/compressor/fetchSaved.d.ts +0 -0
- package/build/executor/compressor/fetchSaved.js +0 -17
- package/build/executor/compressor/fetchSaved.js.map +0 -1
- package/build/executor/compressor/utils/computeCostL2.d.ts +0 -2
- package/build/executor/compressor/utils/computeCostL2.js +0 -14
- package/build/executor/compressor/utils/computeCostL2.js.map +0 -1
- package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +0 -2
- package/build/executor/compressor/utils/findLongestDuplicatedString.js +0 -30
- package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +0 -1
- package/build/executor/compressor/utils/getAllIndexes.d.ts +0 -2
- package/build/executor/compressor/utils/getAllIndexes.js +0 -12
- package/build/executor/compressor/utils/getAllIndexes.js.map +0 -1
- package/build/executor/compressor/utils/getByteForAddress.d.ts +0 -2
- package/build/executor/compressor/utils/getByteForAddress.js +0 -14
- package/build/executor/compressor/utils/getByteForAddress.js.map +0 -1
- package/build/executor/compressor/utils/intTo2Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo2Bytes.js +0 -14
- package/build/executor/compressor/utils/intTo2Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intTo3Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo3Bytes.js +0 -18
- package/build/executor/compressor/utils/intTo3Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intToByte.d.ts +0 -2
- package/build/executor/compressor/utils/intToByte.js +0 -10
- package/build/executor/compressor/utils/intToByte.js.map +0 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { testE2E } from '../../../tests/utils-e2e';
|
|
6
|
+
import { Tokens, Holders } from '../../../tests/constants-e2e';
|
|
7
|
+
import { Network, ContractMethod, SwapSide } from '../../constants';
|
|
8
|
+
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
9
|
+
import { generateConfig } from '../../config';
|
|
10
|
+
|
|
11
|
+
function testForNetwork(
|
|
12
|
+
network: Network,
|
|
13
|
+
dexKey: string,
|
|
14
|
+
tokenASymbol: string,
|
|
15
|
+
tokenBSymbol: string,
|
|
16
|
+
tokenAAmount: string,
|
|
17
|
+
tokenBAmount: string,
|
|
18
|
+
) {
|
|
19
|
+
const provider = new StaticJsonRpcProvider(
|
|
20
|
+
generateConfig(network).privateHttpProvider,
|
|
21
|
+
network,
|
|
22
|
+
);
|
|
23
|
+
const tokens = Tokens[network];
|
|
24
|
+
const holders = Holders[network];
|
|
25
|
+
|
|
26
|
+
const sideToContractMethods = new Map([
|
|
27
|
+
[SwapSide.SELL, [ContractMethod.swapExactAmountIn]],
|
|
28
|
+
[SwapSide.BUY, [ContractMethod.swapExactAmountOut]],
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
describe.only(`${network}`, () => {
|
|
32
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
33
|
+
describe(`${side}`, () => {
|
|
34
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
35
|
+
describe(`${contractMethod}`, () => {
|
|
36
|
+
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
|
|
37
|
+
await testE2E(
|
|
38
|
+
tokens[tokenASymbol],
|
|
39
|
+
tokens[tokenBSymbol],
|
|
40
|
+
holders[tokenASymbol],
|
|
41
|
+
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
|
|
42
|
+
side,
|
|
43
|
+
dexKey,
|
|
44
|
+
contractMethod,
|
|
45
|
+
network,
|
|
46
|
+
provider,
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
|
|
50
|
+
await testE2E(
|
|
51
|
+
tokens[tokenBSymbol],
|
|
52
|
+
tokens[tokenASymbol],
|
|
53
|
+
holders[tokenBSymbol],
|
|
54
|
+
side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
|
|
55
|
+
side,
|
|
56
|
+
dexKey,
|
|
57
|
+
contractMethod,
|
|
58
|
+
network,
|
|
59
|
+
provider,
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
describe('AaveGsm E2E', () => {
|
|
70
|
+
const dexKey = 'AaveGsm';
|
|
71
|
+
|
|
72
|
+
describe('Mainnet GHO -> USDT', () => {
|
|
73
|
+
const network = Network.MAINNET;
|
|
74
|
+
|
|
75
|
+
const tokenASymbol: string = 'GHO';
|
|
76
|
+
const tokenBSymbol: string = 'USDT';
|
|
77
|
+
|
|
78
|
+
const tokenAAmount: string = '1000000000000000000';
|
|
79
|
+
const tokenBAmount: string = '1000000';
|
|
80
|
+
|
|
81
|
+
testForNetwork(
|
|
82
|
+
network,
|
|
83
|
+
dexKey,
|
|
84
|
+
tokenASymbol,
|
|
85
|
+
tokenBSymbol,
|
|
86
|
+
tokenAAmount,
|
|
87
|
+
tokenBAmount,
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('Mainnet GHO -> USDC', () => {
|
|
92
|
+
const network = Network.MAINNET;
|
|
93
|
+
|
|
94
|
+
const tokenASymbol: string = 'GHO';
|
|
95
|
+
const tokenBSymbol: string = 'USDC';
|
|
96
|
+
|
|
97
|
+
const tokenAAmount: string = '1000000000000000000';
|
|
98
|
+
const tokenBAmount: string = '1000000';
|
|
99
|
+
|
|
100
|
+
testForNetwork(
|
|
101
|
+
network,
|
|
102
|
+
dexKey,
|
|
103
|
+
tokenASymbol,
|
|
104
|
+
tokenBSymbol,
|
|
105
|
+
tokenAAmount,
|
|
106
|
+
tokenBAmount,
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,318 @@
|
|
|
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 { AaveGsm } from './aave-gsm';
|
|
10
|
+
import {
|
|
11
|
+
checkPoolPrices,
|
|
12
|
+
checkPoolsLiquidity,
|
|
13
|
+
checkConstantPoolPrices,
|
|
14
|
+
} from '../../../tests/utils';
|
|
15
|
+
import { Tokens } from '../../../tests/constants-e2e';
|
|
16
|
+
import GSM_ABI from '../../abi/Aave_GSM.json';
|
|
17
|
+
|
|
18
|
+
function getReaderCalldata(
|
|
19
|
+
exchangeAddress: string,
|
|
20
|
+
readerIface: Interface,
|
|
21
|
+
amounts: bigint[],
|
|
22
|
+
funcName: string,
|
|
23
|
+
) {
|
|
24
|
+
return amounts.map(amount => ({
|
|
25
|
+
target: exchangeAddress,
|
|
26
|
+
callData: readerIface.encodeFunctionData(funcName, [amount]),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function decodeReaderResult(
|
|
31
|
+
results: Result,
|
|
32
|
+
readerIface: Interface,
|
|
33
|
+
funcName: string,
|
|
34
|
+
index: number,
|
|
35
|
+
) {
|
|
36
|
+
return results.map(result => {
|
|
37
|
+
const parsed = readerIface.decodeFunctionResult(funcName, result);
|
|
38
|
+
return BigInt(parsed[index]._hex);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function checkOnChainPricing(
|
|
43
|
+
aaveGsm: AaveGsm,
|
|
44
|
+
funcName: string,
|
|
45
|
+
blockNumber: number,
|
|
46
|
+
prices: bigint[],
|
|
47
|
+
amounts: bigint[],
|
|
48
|
+
) {
|
|
49
|
+
const exchangeAddress = '0x686F8D21520f4ecEc7ba577be08354F4d1EB8262'; // TODO: Put here the real exchange address
|
|
50
|
+
const readerIface = new Interface(GSM_ABI);
|
|
51
|
+
|
|
52
|
+
const readerCallData = getReaderCalldata(
|
|
53
|
+
exchangeAddress,
|
|
54
|
+
readerIface,
|
|
55
|
+
amounts.slice(1),
|
|
56
|
+
funcName,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const readerResult = (
|
|
60
|
+
await aaveGsm.dexHelper.multiContract.methods
|
|
61
|
+
.aggregate(readerCallData)
|
|
62
|
+
.call({}, blockNumber)
|
|
63
|
+
).returnData;
|
|
64
|
+
|
|
65
|
+
const expectedPrices = [0n].concat(
|
|
66
|
+
decodeReaderResult(
|
|
67
|
+
readerResult,
|
|
68
|
+
readerIface,
|
|
69
|
+
funcName,
|
|
70
|
+
funcName.indexOf('getGho') == 0 ? 1 : 0,
|
|
71
|
+
),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
expect(prices).toEqual(expectedPrices);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function testPricingOnNetwork(
|
|
78
|
+
aaveGsm: AaveGsm,
|
|
79
|
+
network: Network,
|
|
80
|
+
dexKey: string,
|
|
81
|
+
blockNumber: number,
|
|
82
|
+
srcTokenSymbol: string,
|
|
83
|
+
destTokenSymbol: string,
|
|
84
|
+
side: SwapSide,
|
|
85
|
+
amounts: bigint[],
|
|
86
|
+
funcNameToCheck: string,
|
|
87
|
+
) {
|
|
88
|
+
const networkTokens = Tokens[network];
|
|
89
|
+
|
|
90
|
+
const pools = await aaveGsm.getPoolIdentifiers(
|
|
91
|
+
networkTokens[srcTokenSymbol],
|
|
92
|
+
networkTokens[destTokenSymbol],
|
|
93
|
+
side,
|
|
94
|
+
blockNumber,
|
|
95
|
+
);
|
|
96
|
+
console.log(
|
|
97
|
+
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Identifiers: `,
|
|
98
|
+
pools,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
102
|
+
|
|
103
|
+
const poolPrices = await aaveGsm.getPricesVolume(
|
|
104
|
+
networkTokens[srcTokenSymbol],
|
|
105
|
+
networkTokens[destTokenSymbol],
|
|
106
|
+
amounts,
|
|
107
|
+
side,
|
|
108
|
+
blockNumber,
|
|
109
|
+
pools,
|
|
110
|
+
);
|
|
111
|
+
console.log(
|
|
112
|
+
`${srcTokenSymbol} <> ${destTokenSymbol} Pool Prices: `,
|
|
113
|
+
poolPrices,
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
expect(poolPrices).not.toBeNull();
|
|
117
|
+
if (aaveGsm.hasConstantPriceLargeAmounts) {
|
|
118
|
+
checkConstantPoolPrices(poolPrices!, amounts, dexKey);
|
|
119
|
+
} else {
|
|
120
|
+
checkPoolPrices(poolPrices!, amounts, side, dexKey);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Check if onchain pricing equals to calculated ones
|
|
124
|
+
await checkOnChainPricing(
|
|
125
|
+
aaveGsm,
|
|
126
|
+
funcNameToCheck,
|
|
127
|
+
blockNumber,
|
|
128
|
+
poolPrices![0].prices,
|
|
129
|
+
amounts,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
describe('AaveGsm', function () {
|
|
134
|
+
const dexKey = 'AaveGsm';
|
|
135
|
+
let blockNumber: number;
|
|
136
|
+
let aaveGsm: AaveGsm;
|
|
137
|
+
|
|
138
|
+
describe('Mainnet GSM_USDT', () => {
|
|
139
|
+
const network = Network.MAINNET;
|
|
140
|
+
const dexHelper = new DummyDexHelper(network);
|
|
141
|
+
|
|
142
|
+
const tokens = Tokens[network];
|
|
143
|
+
|
|
144
|
+
const srcTokenSymbol = 'USDT';
|
|
145
|
+
const destTokenSymbol = 'GHO';
|
|
146
|
+
|
|
147
|
+
const amountsForSell = [
|
|
148
|
+
0n,
|
|
149
|
+
1n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
150
|
+
2n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
151
|
+
3n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
152
|
+
4n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
153
|
+
5n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
154
|
+
6n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
155
|
+
7n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
156
|
+
8n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
157
|
+
9n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
158
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
const amountsForBuy = [
|
|
162
|
+
0n,
|
|
163
|
+
1n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
164
|
+
2n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
165
|
+
3n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
166
|
+
4n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
167
|
+
5n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
168
|
+
6n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
169
|
+
7n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
170
|
+
8n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
171
|
+
9n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
172
|
+
10n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
beforeAll(async () => {
|
|
176
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
177
|
+
aaveGsm = new AaveGsm(network, dexKey, dexHelper);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
181
|
+
await testPricingOnNetwork(
|
|
182
|
+
aaveGsm,
|
|
183
|
+
network,
|
|
184
|
+
dexKey,
|
|
185
|
+
blockNumber,
|
|
186
|
+
srcTokenSymbol,
|
|
187
|
+
destTokenSymbol,
|
|
188
|
+
SwapSide.SELL,
|
|
189
|
+
amountsForSell,
|
|
190
|
+
'getGhoAmountForSellAsset',
|
|
191
|
+
);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
195
|
+
await testPricingOnNetwork(
|
|
196
|
+
aaveGsm,
|
|
197
|
+
network,
|
|
198
|
+
dexKey,
|
|
199
|
+
blockNumber,
|
|
200
|
+
srcTokenSymbol,
|
|
201
|
+
destTokenSymbol,
|
|
202
|
+
SwapSide.BUY,
|
|
203
|
+
amountsForBuy,
|
|
204
|
+
'getAssetAmountForSellAsset',
|
|
205
|
+
);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('getTopPoolsForToken', async function () {
|
|
209
|
+
// We have to check without calling initializePricing, because
|
|
210
|
+
// pool-tracker is not calling that function
|
|
211
|
+
const newAaveGsm = new AaveGsm(network, dexKey, dexHelper);
|
|
212
|
+
const poolLiquidity = await newAaveGsm.getTopPoolsForToken(
|
|
213
|
+
tokens[srcTokenSymbol].address,
|
|
214
|
+
10,
|
|
215
|
+
);
|
|
216
|
+
console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
|
|
217
|
+
|
|
218
|
+
if (!newAaveGsm.hasConstantPriceLargeAmounts) {
|
|
219
|
+
checkPoolsLiquidity(
|
|
220
|
+
poolLiquidity,
|
|
221
|
+
Tokens[network][srcTokenSymbol].address,
|
|
222
|
+
dexKey,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe('Mainnet GSM_USDC', () => {
|
|
229
|
+
const network = Network.MAINNET;
|
|
230
|
+
const dexHelper = new DummyDexHelper(network);
|
|
231
|
+
|
|
232
|
+
const tokens = Tokens[network];
|
|
233
|
+
|
|
234
|
+
// Don't forget to update relevant tokens in constant-e2e.ts
|
|
235
|
+
const srcTokenSymbol = 'USDC';
|
|
236
|
+
const destTokenSymbol = 'GHO';
|
|
237
|
+
|
|
238
|
+
const amountsForSell = [
|
|
239
|
+
0n,
|
|
240
|
+
1n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
241
|
+
2n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
242
|
+
3n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
243
|
+
4n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
244
|
+
5n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
245
|
+
6n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
246
|
+
7n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
247
|
+
8n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
248
|
+
9n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
249
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
250
|
+
];
|
|
251
|
+
|
|
252
|
+
const amountsForBuy = [
|
|
253
|
+
0n,
|
|
254
|
+
1n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
255
|
+
2n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
256
|
+
3n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
257
|
+
4n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
258
|
+
5n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
259
|
+
6n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
260
|
+
7n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
261
|
+
8n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
262
|
+
9n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
263
|
+
10n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
264
|
+
];
|
|
265
|
+
|
|
266
|
+
beforeAll(async () => {
|
|
267
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
268
|
+
aaveGsm = new AaveGsm(network, dexKey, dexHelper);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
272
|
+
await testPricingOnNetwork(
|
|
273
|
+
aaveGsm,
|
|
274
|
+
network,
|
|
275
|
+
dexKey,
|
|
276
|
+
blockNumber,
|
|
277
|
+
srcTokenSymbol,
|
|
278
|
+
destTokenSymbol,
|
|
279
|
+
SwapSide.SELL,
|
|
280
|
+
amountsForSell,
|
|
281
|
+
'getGhoAmountForSellAsset',
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
286
|
+
await testPricingOnNetwork(
|
|
287
|
+
aaveGsm,
|
|
288
|
+
network,
|
|
289
|
+
dexKey,
|
|
290
|
+
blockNumber,
|
|
291
|
+
srcTokenSymbol,
|
|
292
|
+
destTokenSymbol,
|
|
293
|
+
SwapSide.BUY,
|
|
294
|
+
amountsForBuy,
|
|
295
|
+
'getAssetAmountForSellAsset',
|
|
296
|
+
);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('getTopPoolsForToken', async function () {
|
|
300
|
+
// We have to check without calling initializePricing, because
|
|
301
|
+
// pool-tracker is not calling that function
|
|
302
|
+
const newAaveGsm = new AaveGsm(network, dexKey, dexHelper);
|
|
303
|
+
const poolLiquidity = await newAaveGsm.getTopPoolsForToken(
|
|
304
|
+
tokens[srcTokenSymbol].address,
|
|
305
|
+
10,
|
|
306
|
+
);
|
|
307
|
+
console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
|
|
308
|
+
|
|
309
|
+
if (!newAaveGsm.hasConstantPriceLargeAmounts) {
|
|
310
|
+
checkPoolsLiquidity(
|
|
311
|
+
poolLiquidity,
|
|
312
|
+
Tokens[network][srcTokenSymbol].address,
|
|
313
|
+
dexKey,
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
});
|