@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.
Files changed (224) hide show
  1. package/build/abi/Aave_GSM.json +751 -0
  2. package/build/abi/{integral/pool.json → inception/inception-ineth-pool.json} +558 -537
  3. package/build/abi/inception/inception-ineth.json +609 -0
  4. package/build/abi/inception/inception-ratio-feed.json +93 -0
  5. package/build/abi/inception/inception-vault.json +991 -0
  6. package/build/dex/aave-gsm/aave-gsm.d.ts +33 -0
  7. package/build/dex/aave-gsm/aave-gsm.js +278 -0
  8. package/build/dex/aave-gsm/aave-gsm.js.map +1 -0
  9. package/build/dex/aave-gsm/config.d.ts +3 -0
  10. package/build/dex/aave-gsm/config.js +17 -0
  11. package/build/dex/aave-gsm/config.js.map +1 -0
  12. package/build/dex/aave-gsm/types.d.ts +11 -0
  13. package/build/dex/aave-gsm/types.js +3 -0
  14. package/build/dex/aave-gsm/types.js.map +1 -0
  15. package/build/dex/aave-v1/aave-v1.d.ts +2 -1
  16. package/build/dex/aave-v1/aave-v1.js +22 -0
  17. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  18. package/build/dex/generic-rfq/rate-fetcher.js +1 -1
  19. package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
  20. package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
  21. package/build/dex/idle-dao/idle-dao-pool.js +176 -0
  22. package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
  23. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
  24. package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
  25. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
  26. package/build/dex/idle-dao/scripts.d.ts +9 -0
  27. package/build/dex/idle-dao/scripts.js +552 -0
  28. package/build/dex/idle-dao/scripts.js.map +1 -0
  29. package/build/dex/inception/config.d.ts +5 -0
  30. package/build/dex/inception/config.js +112 -0
  31. package/build/dex/inception/config.js.map +1 -0
  32. package/build/dex/inception/inception-event-pool.d.ts +25 -0
  33. package/build/dex/inception/inception-event-pool.js +57 -0
  34. package/build/dex/inception/inception-event-pool.js.map +1 -0
  35. package/build/dex/{integral/integral.d.ts → inception/inception-native.d.ts} +21 -19
  36. package/build/dex/inception/inception-native.js +131 -0
  37. package/build/dex/inception/inception-native.js.map +1 -0
  38. package/build/dex/inception/inception-pool.d.ts +18 -0
  39. package/build/dex/inception/inception-pool.js +32 -0
  40. package/build/dex/inception/inception-pool.js.map +1 -0
  41. package/build/dex/inception/inception-price-feed.d.ts +19 -0
  42. package/build/dex/inception/inception-price-feed.js +51 -0
  43. package/build/dex/inception/inception-price-feed.js.map +1 -0
  44. package/build/dex/inception/inception.d.ts +44 -0
  45. package/build/dex/inception/inception.js +177 -0
  46. package/build/dex/inception/inception.js.map +1 -0
  47. package/build/dex/inception/tokens.d.ts +9 -0
  48. package/build/dex/inception/tokens.js +28 -0
  49. package/build/dex/inception/tokens.js.map +1 -0
  50. package/build/dex/inception/types.d.ts +22 -0
  51. package/build/dex/inception/types.js +3 -0
  52. package/build/dex/inception/types.js.map +1 -0
  53. package/build/dex/inception/utils.d.ts +7 -0
  54. package/build/dex/inception/utils.js +58 -0
  55. package/build/dex/inception/utils.js.map +1 -0
  56. package/build/dex/index.js +2 -0
  57. package/build/dex/index.js.map +1 -1
  58. package/build/dex/platypus/platypus.d.ts +2 -1
  59. package/build/dex/platypus/platypus.js +31 -0
  60. package/build/dex/platypus/platypus.js.map +1 -1
  61. package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
  62. package/build/dex/swaap-v1/swaap-v1.js +10 -0
  63. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  64. package/package.json +1 -1
  65. package/src/abi/Aave_GSM.json +751 -0
  66. package/src/dex/aave-gsm/aave-gsm-e2e.test.ts +109 -0
  67. package/src/dex/aave-gsm/aave-gsm-integration.test.ts +318 -0
  68. package/src/dex/aave-gsm/aave-gsm.ts +359 -0
  69. package/src/dex/aave-gsm/config.ts +16 -0
  70. package/src/dex/aave-gsm/types.ts +15 -0
  71. package/src/dex/generic-rfq/rate-fetcher.ts +6 -5
  72. package/src/dex/index.ts +2 -0
  73. package/.vscode/launch.json +0 -16
  74. package/.vscode/settings.json +0 -3
  75. package/build/abi/Uncompressor.json +0 -250
  76. package/build/abi/integral/factory.json +0 -333
  77. package/build/abi/integral/oracle.json +0 -501
  78. package/build/abi/integral/relayer.json +0 -1536
  79. package/build/dex/bProtocol.d.ts +0 -18
  80. package/build/dex/bProtocol.js +0 -39
  81. package/build/dex/bProtocol.js.map +0 -1
  82. package/build/dex/bancor.d.ts +0 -26
  83. package/build/dex/bancor.js +0 -58
  84. package/build/dex/bancor.js.map +0 -1
  85. package/build/dex/compound.d.ts +0 -18
  86. package/build/dex/compound.js +0 -46
  87. package/build/dex/compound.js.map +0 -1
  88. package/build/dex/curve-v2.d.ts +0 -58
  89. package/build/dex/curve-v2.js +0 -180
  90. package/build/dex/curve-v2.js.map +0 -1
  91. package/build/dex/dodo-v1.d.ts +0 -33
  92. package/build/dex/dodo-v1.js +0 -63
  93. package/build/dex/dodo-v1.js.map +0 -1
  94. package/build/dex/etherfi/etherfi.d.ts +0 -26
  95. package/build/dex/etherfi/etherfi.js +0 -96
  96. package/build/dex/etherfi/etherfi.js.map +0 -1
  97. package/build/dex/integral/config.d.ts +0 -4
  98. package/build/dex/integral/config.js +0 -20
  99. package/build/dex/integral/config.js.map +0 -1
  100. package/build/dex/integral/context.d.ts +0 -40
  101. package/build/dex/integral/context.js +0 -158
  102. package/build/dex/integral/context.js.map +0 -1
  103. package/build/dex/integral/helpers.d.ts +0 -17
  104. package/build/dex/integral/helpers.js +0 -157
  105. package/build/dex/integral/helpers.js.map +0 -1
  106. package/build/dex/integral/integral-factory.d.ts +0 -24
  107. package/build/dex/integral/integral-factory.js +0 -95
  108. package/build/dex/integral/integral-factory.js.map +0 -1
  109. package/build/dex/integral/integral-pool.d.ts +0 -50
  110. package/build/dex/integral/integral-pool.js +0 -149
  111. package/build/dex/integral/integral-pool.js.map +0 -1
  112. package/build/dex/integral/integral-pricing.d.ts +0 -18
  113. package/build/dex/integral/integral-pricing.js +0 -114
  114. package/build/dex/integral/integral-pricing.js.map +0 -1
  115. package/build/dex/integral/integral-relayer.d.ts +0 -42
  116. package/build/dex/integral/integral-relayer.js +0 -192
  117. package/build/dex/integral/integral-relayer.js.map +0 -1
  118. package/build/dex/integral/integral-token.d.ts +0 -27
  119. package/build/dex/integral/integral-token.js +0 -59
  120. package/build/dex/integral/integral-token.js.map +0 -1
  121. package/build/dex/integral/integral.js +0 -376
  122. package/build/dex/integral/integral.js.map +0 -1
  123. package/build/dex/integral/types.d.ts +0 -85
  124. package/build/dex/integral/types.js +0 -9
  125. package/build/dex/integral/types.js.map +0 -1
  126. package/build/dex/integral/utils-e2e.d.ts +0 -9
  127. package/build/dex/integral/utils-e2e.js +0 -131
  128. package/build/dex/integral/utils-e2e.js.map +0 -1
  129. package/build/dex/integral/utils.d.ts +0 -17
  130. package/build/dex/integral/utils.js +0 -94
  131. package/build/dex/integral/utils.js.map +0 -1
  132. package/build/dex/lido.d.ts +0 -19
  133. package/build/dex/lido.js +0 -42
  134. package/build/dex/lido.js.map +0 -1
  135. package/build/dex/onebit.d.ts +0 -25
  136. package/build/dex/onebit.js +0 -42
  137. package/build/dex/onebit.js.map +0 -1
  138. package/build/dex/sdai/config.d.ts +0 -11
  139. package/build/dex/sdai/config.js +0 -21
  140. package/build/dex/sdai/config.js.map +0 -1
  141. package/build/dex/sdai/constants.d.ts +0 -2
  142. package/build/dex/sdai/constants.js +0 -6
  143. package/build/dex/sdai/constants.js.map +0 -1
  144. package/build/dex/sdai/scripts/validate-state.d.ts +0 -1
  145. package/build/dex/sdai/scripts/validate-state.js +0 -102
  146. package/build/dex/sdai/scripts/validate-state.js.map +0 -1
  147. package/build/dex/sdai/sdai-pool.d.ts +0 -16
  148. package/build/dex/sdai/sdai-pool.js +0 -85
  149. package/build/dex/sdai/sdai-pool.js.map +0 -1
  150. package/build/dex/sdai/sdai.d.ts +0 -51
  151. package/build/dex/sdai/sdai.js +0 -172
  152. package/build/dex/sdai/sdai.js.map +0 -1
  153. package/build/dex/sdai/types.d.ts +0 -21
  154. package/build/dex/sdai/types.js +0 -11
  155. package/build/dex/sdai/types.js.map +0 -1
  156. package/build/dex/sdai/utils.d.ts +0 -4
  157. package/build/dex/sdai/utils.js +0 -39
  158. package/build/dex/sdai/utils.js.map +0 -1
  159. package/build/dex/smoothy.d.ts +0 -26
  160. package/build/dex/smoothy.js +0 -48
  161. package/build/dex/smoothy.js.map +0 -1
  162. package/build/dex/stable-pool.d.ts +0 -28
  163. package/build/dex/stable-pool.js +0 -62
  164. package/build/dex/stable-pool.js.map +0 -1
  165. package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
  166. package/build/dex/trader-joe-v2.1/optimizer.js +0 -44
  167. package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
  168. package/build/dex/trader-joe-v2.1.d.ts +0 -43
  169. package/build/dex/trader-joe-v2.1.js +0 -79
  170. package/build/dex/trader-joe-v2.1.js.map +0 -1
  171. package/build/executor/compressor/Compressor.d.ts +0 -23
  172. package/build/executor/compressor/Compressor.js +0 -144
  173. package/build/executor/compressor/Compressor.js.map +0 -1
  174. package/build/executor/compressor/compress.d.ts +0 -17
  175. package/build/executor/compressor/compress.js +0 -187
  176. package/build/executor/compressor/compress.js.map +0 -1
  177. package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +0 -6
  178. package/build/executor/compressor/compress_functions/addressSubstitution.js +0 -29
  179. package/build/executor/compressor/compress_functions/addressSubstitution.js.map +0 -1
  180. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +0 -10
  181. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +0 -40
  182. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +0 -1
  183. package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +0 -11
  184. package/build/executor/compressor/compress_functions/byteSubstitution.js +0 -64
  185. package/build/executor/compressor/compress_functions/byteSubstitution.js.map +0 -1
  186. package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +0 -7
  187. package/build/executor/compressor/compress_functions/ffSubstitution.js +0 -54
  188. package/build/executor/compressor/compress_functions/ffSubstitution.js.map +0 -1
  189. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +0 -8
  190. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +0 -67
  191. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +0 -1
  192. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +0 -8
  193. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +0 -61
  194. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +0 -1
  195. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +0 -6
  196. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +0 -37
  197. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +0 -1
  198. package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +0 -9
  199. package/build/executor/compressor/compress_functions/searchUnusedBytes.js +0 -33
  200. package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +0 -1
  201. package/build/executor/compressor/fetchSaved.d.ts +0 -0
  202. package/build/executor/compressor/fetchSaved.js +0 -17
  203. package/build/executor/compressor/fetchSaved.js.map +0 -1
  204. package/build/executor/compressor/utils/computeCostL2.d.ts +0 -2
  205. package/build/executor/compressor/utils/computeCostL2.js +0 -14
  206. package/build/executor/compressor/utils/computeCostL2.js.map +0 -1
  207. package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +0 -2
  208. package/build/executor/compressor/utils/findLongestDuplicatedString.js +0 -30
  209. package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +0 -1
  210. package/build/executor/compressor/utils/getAllIndexes.d.ts +0 -2
  211. package/build/executor/compressor/utils/getAllIndexes.js +0 -12
  212. package/build/executor/compressor/utils/getAllIndexes.js.map +0 -1
  213. package/build/executor/compressor/utils/getByteForAddress.d.ts +0 -2
  214. package/build/executor/compressor/utils/getByteForAddress.js +0 -14
  215. package/build/executor/compressor/utils/getByteForAddress.js.map +0 -1
  216. package/build/executor/compressor/utils/intTo2Bytes.d.ts +0 -2
  217. package/build/executor/compressor/utils/intTo2Bytes.js +0 -14
  218. package/build/executor/compressor/utils/intTo2Bytes.js.map +0 -1
  219. package/build/executor/compressor/utils/intTo3Bytes.d.ts +0 -2
  220. package/build/executor/compressor/utils/intTo3Bytes.js +0 -18
  221. package/build/executor/compressor/utils/intTo3Bytes.js.map +0 -1
  222. package/build/executor/compressor/utils/intToByte.d.ts +0 -2
  223. package/build/executor/compressor/utils/intToByte.js +0 -10
  224. 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
+ });