@paraswap/dex-lib 2.36.1 → 2.36.2-dexalot.2

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 (163) hide show
  1. package/.idea/aws.xml +17 -0
  2. package/.idea/codeStyles/Project.xml +19 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/misc.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/paraswap-dex-lib.iml +9 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/build/abi/algebra/AlgebraPool.abi.json +727 -0
  9. package/build/abi/curve-v1/StableSwapFRXETH.json +889 -0
  10. package/build/abi/curve-v1/StableSwapWBETH.json +1223 -0
  11. package/build/abi/dexalot/DexalotMainnetRFQ.json +887 -0
  12. package/build/abi/sushiswap-v3/QuoterV2.json +267 -0
  13. package/build/abi/sushiswap-v3/RouterProcessor3.json +289 -0
  14. package/build/abi/wBETH.json +1527 -0
  15. package/build/config.js +2 -0
  16. package/build/config.js.map +1 -1
  17. package/build/dex/algebra/algebra-pool.d.ts +46 -0
  18. package/build/dex/algebra/algebra-pool.js +336 -0
  19. package/build/dex/algebra/algebra-pool.js.map +1 -0
  20. package/build/dex/curve-v1/pools/frxETHpool.d.ts +7 -0
  21. package/build/dex/curve-v1/pools/frxETHpool.js +27 -0
  22. package/build/dex/curve-v1/pools/frxETHpool.js.map +1 -0
  23. package/build/dex/curve-v1/pools/wbETHpool.d.ts +29 -0
  24. package/build/dex/curve-v1/pools/wbETHpool.js +408 -0
  25. package/build/dex/curve-v1/pools/wbETHpool.js.map +1 -0
  26. package/build/dex/{test-dex → dexalot}/config.d.ts +1 -1
  27. package/build/dex/dexalot/config.js +18 -0
  28. package/build/dex/dexalot/config.js.map +1 -0
  29. package/build/dex/dexalot/constants.d.ts +16 -0
  30. package/build/dex/dexalot/constants.js +23 -0
  31. package/build/dex/dexalot/constants.js.map +1 -0
  32. package/build/dex/dexalot/dexalot.d.ts +66 -0
  33. package/build/dex/dexalot/dexalot.js +603 -0
  34. package/build/dex/dexalot/dexalot.js.map +1 -0
  35. package/build/dex/dexalot/rate-fetcher.d.ts +27 -0
  36. package/build/dex/dexalot/rate-fetcher.js +101 -0
  37. package/build/dex/dexalot/rate-fetcher.js.map +1 -0
  38. package/build/dex/dexalot/types.d.ts +106 -0
  39. package/build/dex/dexalot/types.js +12 -0
  40. package/build/dex/dexalot/types.js.map +1 -0
  41. package/build/dex/dexalot/validators.d.ts +5 -0
  42. package/build/dex/dexalot/validators.js +45 -0
  43. package/build/dex/dexalot/validators.js.map +1 -0
  44. package/build/dex/index.js +2 -0
  45. package/build/dex/index.js.map +1 -1
  46. package/build/dex/pancakeswap-v3/types.d.ts +14 -0
  47. package/build/dex/{test-dex → pancakeswap-v3}/types.js.map +1 -1
  48. package/build/dex/ramses-v2/config.d.ts +4 -0
  49. package/build/dex/ramses-v2/config.js +28 -0
  50. package/build/dex/ramses-v2/config.js.map +1 -0
  51. package/build/dex/ramses-v2/constants.d.ts +28 -0
  52. package/build/dex/ramses-v2/constants.js +35 -0
  53. package/build/dex/ramses-v2/constants.js.map +1 -0
  54. package/build/dex/ramses-v2/contract-math/BitMath.d.ts +4 -0
  55. package/build/dex/ramses-v2/contract-math/BitMath.js +93 -0
  56. package/build/dex/ramses-v2/contract-math/BitMath.js.map +1 -0
  57. package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +3 -0
  58. package/build/dex/ramses-v2/contract-math/FixedPoint128.js +8 -0
  59. package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +1 -0
  60. package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +4 -0
  61. package/build/dex/ramses-v2/contract-math/FixedPoint96.js +9 -0
  62. package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +1 -0
  63. package/build/dex/ramses-v2/contract-math/FullMath.d.ts +4 -0
  64. package/build/dex/ramses-v2/contract-math/FullMath.js +19 -0
  65. package/build/dex/ramses-v2/contract-math/FullMath.js.map +1 -0
  66. package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +3 -0
  67. package/build/dex/ramses-v2/contract-math/LiquidityMath.js +22 -0
  68. package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +1 -0
  69. package/build/dex/ramses-v2/contract-math/Oracle.d.ts +10 -0
  70. package/build/dex/ramses-v2/contract-math/Oracle.js +133 -0
  71. package/build/dex/ramses-v2/contract-math/Oracle.js.map +1 -0
  72. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +10 -0
  73. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +91 -0
  74. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +1 -0
  75. package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +8 -0
  76. package/build/dex/ramses-v2/contract-math/SwapMath.js +70 -0
  77. package/build/dex/ramses-v2/contract-math/SwapMath.js.map +1 -0
  78. package/build/dex/ramses-v2/contract-math/Tick.d.ts +7 -0
  79. package/build/dex/ramses-v2/contract-math/Tick.js +45 -0
  80. package/build/dex/ramses-v2/contract-math/Tick.js.map +1 -0
  81. package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +8 -0
  82. package/build/dex/ramses-v2/contract-math/TickBitMap.js +87 -0
  83. package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +1 -0
  84. package/build/dex/ramses-v2/contract-math/TickMath.d.ts +8 -0
  85. package/build/dex/ramses-v2/contract-math/TickMath.js +162 -0
  86. package/build/dex/ramses-v2/contract-math/TickMath.js.map +1 -0
  87. package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +3 -0
  88. package/build/dex/ramses-v2/contract-math/UnsafeMath.js +10 -0
  89. package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +1 -0
  90. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +18 -0
  91. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +392 -0
  92. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +1 -0
  93. package/build/dex/ramses-v2/contract-math/utils.d.ts +3 -0
  94. package/build/dex/ramses-v2/contract-math/utils.js +16 -0
  95. package/build/dex/ramses-v2/contract-math/utils.js.map +1 -0
  96. package/build/dex/ramses-v2/ramses-v2-pool.d.ts +42 -0
  97. package/build/dex/ramses-v2/ramses-v2-pool.js +307 -0
  98. package/build/dex/ramses-v2/ramses-v2-pool.js.map +1 -0
  99. package/build/dex/ramses-v2/ramses-v2.d.ts +61 -0
  100. package/build/dex/ramses-v2/ramses-v2.js +690 -0
  101. package/build/dex/ramses-v2/ramses-v2.js.map +1 -0
  102. package/build/dex/ramses-v2/types.d.ts +154 -0
  103. package/build/dex/ramses-v2/types.js +9 -0
  104. package/build/dex/ramses-v2/types.js.map +1 -0
  105. package/build/dex/ramses-v2/utils.d.ts +6 -0
  106. package/build/dex/ramses-v2/utils.js +71 -0
  107. package/build/dex/ramses-v2/utils.js.map +1 -0
  108. package/build/dex/sushiswap-v3/config.d.ts +4 -0
  109. package/build/dex/sushiswap-v3/config.js +132 -0
  110. package/build/dex/sushiswap-v3/config.js.map +1 -0
  111. package/build/dex/sushiswap-v3/constants.d.ts +4 -0
  112. package/build/dex/sushiswap-v3/constants.js +32 -0
  113. package/build/dex/sushiswap-v3/constants.js.map +1 -0
  114. package/build/dex/sushiswap-v3/sushiswap-v3-original.d.ts +56 -0
  115. package/build/dex/sushiswap-v3/sushiswap-v3-original.js +598 -0
  116. package/build/dex/sushiswap-v3/sushiswap-v3-original.js.map +1 -0
  117. package/build/dex/sushiswap-v3/sushiswap-v3-pool.d.ts +1 -0
  118. package/build/dex/sushiswap-v3/sushiswap-v3-pool.js +6 -0
  119. package/build/dex/sushiswap-v3/sushiswap-v3-pool.js.map +1 -0
  120. package/build/dex/sushiswap-v3/sushiswap-v3.d.ts +21 -0
  121. package/build/dex/sushiswap-v3/sushiswap-v3.js +58 -0
  122. package/build/dex/sushiswap-v3/sushiswap-v3.js.map +1 -0
  123. package/build/dex/sushiswap-v3/token.d.ts +6 -0
  124. package/build/dex/sushiswap-v3/token.js +23 -0
  125. package/build/dex/sushiswap-v3/token.js.map +1 -0
  126. package/build/dex/sushiswap-v3/types.d.ts +15 -0
  127. package/build/dex/sushiswap-v3/types.js +18 -0
  128. package/build/dex/sushiswap-v3/types.js.map +1 -0
  129. package/build/types.d.ts +1 -0
  130. package/package.json +1 -1
  131. package/src/abi/dexalot/DexalotMainnetRFQ.json +887 -0
  132. package/src/config.ts +3 -0
  133. package/src/dex/dexalot/config.ts +18 -0
  134. package/src/dex/dexalot/constants.ts +31 -0
  135. package/src/dex/dexalot/dexalot-e2e.test.ts +192 -0
  136. package/src/dex/dexalot/dexalot-integration.test.ts +188 -0
  137. package/src/dex/dexalot/dexalot.ts +911 -0
  138. package/src/dex/dexalot/rate-fetcher.ts +187 -0
  139. package/src/dex/dexalot/types.ts +122 -0
  140. package/src/dex/dexalot/validators.ts +46 -0
  141. package/src/dex/index.ts +2 -0
  142. package/src/types.ts +1 -0
  143. package/build/abi/quickPerps/fast-price-events.json +0 -70
  144. package/build/abi/quickPerps/fast-price-feed.json +0 -748
  145. package/build/abi/quickPerps/reader.json +0 -313
  146. package/build/abi/quickPerps/vault-price-feed.json +0 -477
  147. package/build/abi/quickPerps/vault.json +0 -1953
  148. package/build/dex/test-dex/config.js +0 -15
  149. package/build/dex/test-dex/config.js.map +0 -1
  150. package/build/dex/test-dex/test-dex-pool.d.ts +0 -39
  151. package/build/dex/test-dex/test-dex-pool.js +0 -63
  152. package/build/dex/test-dex/test-dex-pool.js.map +0 -1
  153. package/build/dex/test-dex/test-dex.d.ts +0 -37
  154. package/build/dex/test-dex/test-dex.js +0 -126
  155. package/build/dex/test-dex/test-dex.js.map +0 -1
  156. package/build/dex/test-dex/types.d.ts +0 -6
  157. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +0 -16
  158. package/build/dex/woo-fi-v2/woo-fi-math.js +0 -137
  159. package/build/dex/woo-fi-v2/woo-fi-math.js.map +0 -1
  160. package/build/workers.d.ts +0 -0
  161. package/build/workers.js +0 -2
  162. package/build/workers.js.map +0 -1
  163. /package/build/dex/{test-dex → pancakeswap-v3}/types.js +0 -0
package/src/config.ts CHANGED
@@ -30,6 +30,7 @@ type BaseConfig = {
30
30
  hashFlowAuthToken?: string;
31
31
  hashFlowDisabledMMs: string[];
32
32
  swaapV2AuthToken?: string;
33
+ dexalotAuthToken?: string;
33
34
  forceRpcFallbackDexs: string[];
34
35
  };
35
36
 
@@ -219,6 +220,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
219
220
  hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
220
221
  hashFlowDisabledMMs:
221
222
  process.env[`HASHFLOW_DISABLED_MMS_43114`]?.split(',') || [],
223
+ dexalotAuthToken: process.env.API_KEY_DEXALOT_AUTH_TOKEN || '',
222
224
  adapterAddresses: {
223
225
  AvalancheAdapter01: '0x745Ec73855CeC7249E5fF4c9DD81cc65b4D297a9',
224
226
  AvalancheAdapter02: '0xFb8773AA4Fd02e54bbd352061D8Be1911FAa210a',
@@ -414,6 +416,7 @@ export function generateConfig(network: number): Config {
414
416
  baseConfig.rpcPollingBlocksBackToTriggerUpdate,
415
417
  hashFlowAuthToken: baseConfig.hashFlowAuthToken,
416
418
  swaapV2AuthToken: baseConfig.swaapV2AuthToken,
419
+ dexalotAuthToken: baseConfig.dexalotAuthToken,
417
420
  hashFlowDisabledMMs: baseConfig.hashFlowDisabledMMs,
418
421
  forceRpcFallbackDexs: baseConfig.forceRpcFallbackDexs,
419
422
  };
@@ -0,0 +1,18 @@
1
+ import { DexParams } from './types';
2
+ import { DexConfigMap, AdapterMappings } from '../../types';
3
+ import { Network, SwapSide } from '../../constants';
4
+
5
+ export const DexalotConfig: DexConfigMap<DexParams> = {
6
+ Dexalot: {
7
+ [Network.AVALANCHE]: {
8
+ mainnetRFQAddress: '0xEed3c159F3A96aB8d41c8B9cA49EE1e5071A7cdD',
9
+ },
10
+ },
11
+ };
12
+
13
+ export const Adapters: Record<number, AdapterMappings> = {
14
+ // [Network.AVALANCHE]: {
15
+ // [SwapSide.SELL]: [{ name: 'AvalancheAdapter02', index: 6 }],
16
+ // [SwapSide.BUY]: [{ name: 'AvalancheBuyAdapter', index: 8 }],
17
+ // },
18
+ };
@@ -0,0 +1,31 @@
1
+ import BigNumber from 'bignumber.js';
2
+
3
+ export const DEXALOT_RATE_LIMITED_TTL_S = 60 * 60; // 1 hour
4
+
5
+ export const DEXALOT_PRICES_CACHES_TTL_S = 3;
6
+
7
+ export const DEXALOT_PAIRS_CACHES_TTL_S = 11;
8
+
9
+ export const DEXALOT_TOKENS_CACHES_TTL_S = 11;
10
+
11
+ export const DEXALOT_API_PRICES_POLLING_INTERVAL_MS = 1000;
12
+
13
+ export const DEXALOT_API_PAIRS_POLLING_INTERVAL_MS = 1000 * 60 * 10; // 10 mins
14
+
15
+ export const DEXALOT_API_BLACKLIST_POLLING_INTERVAL_MS = 1000 * 60 * 60; // 1 hour
16
+
17
+ export const DEXALOT_API_URL = 'https://api.dexalot.com';
18
+
19
+ export const DEXALOT_GAS_COST = 120_000;
20
+
21
+ export const DEXALOT_RESTRICT_TTL_S = 60 * 30; // 30 minutes
22
+
23
+ export const DEXALOT_BLACKLIST_TTL_S = 60 * 60 * 24; // 24 hours
24
+
25
+ export const DEXALOT_BLACKLIST_CACHE_VALUE = 'blacklisted';
26
+
27
+ export const DEXALOT_RATELIMIT_CACHE_VALUE = 'limited';
28
+
29
+ export const DEXALOT_RESTRICTED_CACHE_KEY = 'restricted';
30
+
31
+ export const DEXALOT_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION = new BigNumber('0.001');
@@ -0,0 +1,192 @@
1
+ import dotenv from 'dotenv';
2
+ dotenv.config();
3
+
4
+ import { testE2E } from '../../../tests/utils-e2e';
5
+ import {
6
+ Tokens,
7
+ NativeTokenSymbols,
8
+ Holders,
9
+ } from '../../../tests/constants-e2e';
10
+ import { Network, ContractMethod, SwapSide } from '../../constants';
11
+ import { StaticJsonRpcProvider } from '@ethersproject/providers';
12
+ import { generateConfig } from '../../config';
13
+
14
+ function testForNetwork(
15
+ network: Network,
16
+ dexKey: string,
17
+ tokenASymbol: string,
18
+ tokenBSymbol: string,
19
+ tokenAAmount: string,
20
+ tokenBAmount: string,
21
+ nativeTokenAmount: string,
22
+ excludeNativeTokenTests: boolean = false,
23
+ ) {
24
+ const config = generateConfig(network);
25
+ const provider = new StaticJsonRpcProvider(
26
+ config.privateHttpProvider,
27
+ network,
28
+ );
29
+ const tokens = Tokens[network];
30
+ const holders = Holders[network];
31
+ const nativeTokenSymbol = NativeTokenSymbols[network];
32
+ const sleepMs = 5000;
33
+
34
+ const sideToContractMethods = new Map([
35
+ [SwapSide.SELL, [
36
+ ContractMethod.simpleSwap,
37
+ // ContractMethod.megaSwap,
38
+ // ContractMethod.multiSwap
39
+ ]],
40
+ [SwapSide.BUY, [
41
+ ContractMethod.simpleBuy,
42
+ // ContractMethod.buy
43
+ ]],
44
+ ]);
45
+
46
+ describe(`${network}`, () => {
47
+ sideToContractMethods.forEach((contractMethods, side) =>
48
+ describe(`${side}`, () => {
49
+ contractMethods.forEach((contractMethod: ContractMethod) => {
50
+ describe(`${contractMethod}`, () => {
51
+ if (excludeNativeTokenTests) {
52
+ it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
53
+ await testE2E(
54
+ tokens[tokenASymbol],
55
+ tokens[tokenBSymbol],
56
+ holders[tokenASymbol],
57
+ side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
58
+ side,
59
+ dexKey,
60
+ contractMethod,
61
+ network,
62
+ provider,
63
+ undefined,
64
+ undefined,
65
+ undefined,
66
+ undefined,
67
+ sleepMs,
68
+ );
69
+ });
70
+ it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
71
+ await testE2E(
72
+ tokens[tokenBSymbol],
73
+ tokens[tokenASymbol],
74
+ holders[tokenBSymbol],
75
+ side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
76
+ side,
77
+ dexKey,
78
+ contractMethod,
79
+ network,
80
+ provider,
81
+ undefined,
82
+ undefined,
83
+ undefined,
84
+ undefined,
85
+ sleepMs,
86
+ );
87
+ });
88
+ } else {
89
+ it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
90
+ await testE2E(
91
+ tokens[nativeTokenSymbol],
92
+ tokens[tokenASymbol],
93
+ holders[nativeTokenSymbol],
94
+ side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
95
+ side,
96
+ dexKey,
97
+ contractMethod,
98
+ network,
99
+ provider,
100
+ undefined,
101
+ undefined,
102
+ undefined,
103
+ undefined,
104
+ sleepMs,
105
+ );
106
+ });
107
+ it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
108
+ await testE2E(
109
+ tokens[tokenASymbol],
110
+ tokens[nativeTokenSymbol],
111
+ holders[tokenASymbol],
112
+ side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
113
+ side,
114
+ dexKey,
115
+ contractMethod,
116
+ network,
117
+ provider,
118
+ undefined,
119
+ undefined,
120
+ undefined,
121
+ undefined,
122
+ sleepMs,
123
+ );
124
+ });
125
+ it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
126
+ await testE2E(
127
+ tokens[tokenASymbol],
128
+ tokens[tokenBSymbol],
129
+ holders[tokenASymbol],
130
+ side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
131
+ side,
132
+ dexKey,
133
+ contractMethod,
134
+ network,
135
+ provider,
136
+ undefined,
137
+ undefined,
138
+ undefined,
139
+ undefined,
140
+ sleepMs,
141
+ );
142
+ });
143
+ it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
144
+ await testE2E(
145
+ tokens[tokenBSymbol],
146
+ tokens[tokenASymbol],
147
+ holders[tokenBSymbol],
148
+ side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
149
+ side,
150
+ dexKey,
151
+ contractMethod,
152
+ network,
153
+ provider,
154
+ undefined,
155
+ undefined,
156
+ undefined,
157
+ undefined,
158
+ sleepMs,
159
+ );
160
+ });
161
+ }
162
+ });
163
+ });
164
+ }),
165
+ );
166
+ });
167
+ }
168
+
169
+ describe('Dexalot E2E', () => {
170
+ const dexKey = 'Dexalot';
171
+
172
+ describe('Avalanche', () => {
173
+ const network = Network.AVALANCHE;
174
+
175
+ const tokenASymbol: string = 'USDC';
176
+ const tokenBSymbol: string = 'USDT';
177
+
178
+ const tokenAAmount: string = '1000000';
179
+ const tokenBAmount: string = '1000000';
180
+ const nativeTokenAmount = '1000000000000000000';
181
+
182
+ testForNetwork(
183
+ network,
184
+ dexKey,
185
+ tokenASymbol,
186
+ tokenBSymbol,
187
+ tokenAAmount,
188
+ tokenBAmount,
189
+ nativeTokenAmount,
190
+ );
191
+ });
192
+ });
@@ -0,0 +1,188 @@
1
+ /* eslint-disable no-console */
2
+ import dotenv from 'dotenv';
3
+ dotenv.config();
4
+
5
+ import { DummyDexHelper } from '../../dex-helper/index';
6
+ import { Network, SwapSide } from '../../constants';
7
+ import { BI_POWS } from '../../bigint-constants';
8
+ import { Dexalot } from './dexalot';
9
+ import {
10
+ checkPoolPrices,
11
+ checkPoolsLiquidity,
12
+ checkConstantPoolPrices,
13
+ sleep,
14
+ } from '../../../tests/utils';
15
+ import { Tokens } from '../../../tests/constants-e2e';
16
+
17
+ async function testPricingOnNetwork(
18
+ dexalot: Dexalot,
19
+ network: Network,
20
+ dexKey: string,
21
+ blockNumber: number,
22
+ srcTokenSymbol: string,
23
+ destTokenSymbol: string,
24
+ side: SwapSide,
25
+ amounts: bigint[],
26
+ ) {
27
+ const networkTokens = Tokens[network];
28
+
29
+ const pools = await dexalot.getPoolIdentifiers(
30
+ networkTokens[srcTokenSymbol],
31
+ networkTokens[destTokenSymbol],
32
+ side,
33
+ blockNumber,
34
+ );
35
+ console.log(
36
+ `${srcTokenSymbol} <> ${destTokenSymbol} Pool Identifiers: `,
37
+ pools,
38
+ );
39
+
40
+ expect(pools.length).toBeGreaterThan(0);
41
+
42
+ const poolPrices = await dexalot.getPricesVolume(
43
+ networkTokens[srcTokenSymbol],
44
+ networkTokens[destTokenSymbol],
45
+ amounts,
46
+ side,
47
+ blockNumber,
48
+ pools,
49
+ );
50
+ console.log(
51
+ `${srcTokenSymbol} <> ${destTokenSymbol} Pool Prices: `,
52
+ poolPrices,
53
+ );
54
+
55
+ expect(poolPrices).not.toBeNull();
56
+ if (dexalot.hasConstantPriceLargeAmounts) {
57
+ checkConstantPoolPrices(poolPrices!, amounts, dexKey);
58
+ } else {
59
+ checkPoolPrices(poolPrices!, amounts, side, dexKey);
60
+ }
61
+ }
62
+
63
+ describe('Dexalot', function () {
64
+ const dexKey = 'Dexalot';
65
+ let blockNumber: number;
66
+ let dexalot: Dexalot;
67
+
68
+ describe('Avalanche', () => {
69
+ const network = Network.AVALANCHE;
70
+ const dexHelper = new DummyDexHelper(network);
71
+
72
+ const tokens = Tokens[network];
73
+
74
+ const tokenASymbol = 'AVAX';
75
+ const tokenBSymbol = 'USDC';
76
+
77
+ const amountsForTokenA = [
78
+ 0n,
79
+ 1n * BI_POWS[tokens[tokenASymbol].decimals],
80
+ 2n * BI_POWS[tokens[tokenASymbol].decimals],
81
+ 3n * BI_POWS[tokens[tokenASymbol].decimals],
82
+ 4n * BI_POWS[tokens[tokenASymbol].decimals],
83
+ 5n * BI_POWS[tokens[tokenASymbol].decimals],
84
+ 6n * BI_POWS[tokens[tokenASymbol].decimals],
85
+ 7n * BI_POWS[tokens[tokenASymbol].decimals],
86
+ 8n * BI_POWS[tokens[tokenASymbol].decimals],
87
+ 9n * BI_POWS[tokens[tokenASymbol].decimals],
88
+ 10n * BI_POWS[tokens[tokenASymbol].decimals],
89
+ ];
90
+
91
+ const amountsForTokenB = [
92
+ 0n,
93
+ 1n * BI_POWS[tokens[tokenBSymbol].decimals],
94
+ 2n * BI_POWS[tokens[tokenBSymbol].decimals],
95
+ 3n * BI_POWS[tokens[tokenBSymbol].decimals],
96
+ 4n * BI_POWS[tokens[tokenBSymbol].decimals],
97
+ 5n * BI_POWS[tokens[tokenBSymbol].decimals],
98
+ 6n * BI_POWS[tokens[tokenBSymbol].decimals],
99
+ 7n * BI_POWS[tokens[tokenBSymbol].decimals],
100
+ 8n * BI_POWS[tokens[tokenBSymbol].decimals],
101
+ 9n * BI_POWS[tokens[tokenBSymbol].decimals],
102
+ 10n * BI_POWS[tokens[tokenBSymbol].decimals],
103
+ ];
104
+
105
+ beforeEach(async () => {
106
+ blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
107
+ dexalot = new Dexalot(network, dexKey, dexHelper);
108
+ await dexalot.initializePricing(blockNumber);
109
+ await sleep(5000);
110
+ });
111
+
112
+ afterEach(async () => {
113
+ dexalot.releaseResources();
114
+ await sleep(5000);
115
+ });
116
+
117
+ it(`getPoolIdentifiers and getPricesVolume SELL ${tokenASymbol} ${tokenBSymbol}`, async function () {
118
+ await testPricingOnNetwork(
119
+ dexalot,
120
+ network,
121
+ dexKey,
122
+ blockNumber,
123
+ tokenASymbol,
124
+ tokenBSymbol,
125
+ SwapSide.SELL,
126
+ amountsForTokenA,
127
+ );
128
+ });
129
+
130
+ it(`getPoolIdentifiers and getPricesVolume BUY ${tokenASymbol} ${tokenBSymbol}`, async function () {
131
+ await testPricingOnNetwork(
132
+ dexalot,
133
+ network,
134
+ dexKey,
135
+ blockNumber,
136
+ tokenASymbol,
137
+ tokenBSymbol,
138
+ SwapSide.BUY,
139
+ amountsForTokenB,
140
+ );
141
+ });
142
+
143
+ it(`getPoolIdentifiers and getPricesVolume SELL ${tokenBSymbol} ${tokenASymbol}`, async function () {
144
+ await testPricingOnNetwork(
145
+ dexalot,
146
+ network,
147
+ dexKey,
148
+ blockNumber,
149
+ tokenBSymbol,
150
+ tokenASymbol,
151
+ SwapSide.SELL,
152
+ amountsForTokenB,
153
+ );
154
+ });
155
+
156
+ it(`getPoolIdentifiers and getPricesVolume BUY ${tokenBSymbol} ${tokenASymbol}`, async function () {
157
+ await testPricingOnNetwork(
158
+ dexalot,
159
+ network,
160
+ dexKey,
161
+ blockNumber,
162
+ tokenBSymbol,
163
+ tokenASymbol,
164
+ SwapSide.BUY,
165
+ amountsForTokenA,
166
+ );
167
+ });
168
+
169
+ it('getTopPoolsForToken', async function () {
170
+ // We have to check without calling initializePricing, because
171
+ // pool-tracker is not calling that function
172
+ const dexalot = new Dexalot(network, dexKey, dexHelper);
173
+ const poolLiquidity = await dexalot.getTopPoolsForToken(
174
+ tokens[tokenASymbol].address,
175
+ 10,
176
+ );
177
+ console.log(`${tokenASymbol} Top Pools:`, poolLiquidity);
178
+
179
+ if (!dexalot.hasConstantPriceLargeAmounts) {
180
+ checkPoolsLiquidity(
181
+ poolLiquidity,
182
+ Tokens[network][tokenASymbol].address,
183
+ dexKey,
184
+ );
185
+ }
186
+ });
187
+ });
188
+ });