@paraswap/dex-lib 2.37.6-dexalot → 2.37.6

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 (203) hide show
  1. package/build/abi/quickPerps/fast-price-events.json +70 -0
  2. package/build/abi/quickPerps/fast-price-feed.json +748 -0
  3. package/build/abi/quickPerps/reader.json +313 -0
  4. package/build/abi/quickPerps/vault-price-feed.json +477 -0
  5. package/build/abi/quickPerps/vault.json +1953 -0
  6. package/build/config.js +2 -4
  7. package/build/config.js.map +1 -1
  8. package/build/dex/idex.d.ts +1 -1
  9. package/build/dex/index.js +0 -2
  10. package/build/dex/index.js.map +1 -1
  11. package/build/dex/maverick-v1/scripts/event-sequence.d.ts +1 -0
  12. package/build/dex/maverick-v1/scripts/event-sequence.js +110 -0
  13. package/build/dex/maverick-v1/scripts/event-sequence.js.map +1 -0
  14. package/build/dex/{dexalot → test-dex}/config.d.ts +1 -1
  15. package/build/dex/test-dex/config.js +15 -0
  16. package/build/dex/test-dex/config.js.map +1 -0
  17. package/build/dex/test-dex/test-dex-pool.d.ts +39 -0
  18. package/build/dex/test-dex/test-dex-pool.js +63 -0
  19. package/build/dex/test-dex/test-dex-pool.js.map +1 -0
  20. package/build/dex/test-dex/test-dex.d.ts +37 -0
  21. package/build/dex/test-dex/test-dex.js +126 -0
  22. package/build/dex/test-dex/test-dex.js.map +1 -0
  23. package/build/dex/test-dex/types.d.ts +6 -0
  24. package/build/dex/{pancakeswap-v3 → test-dex}/types.js.map +1 -1
  25. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +16 -0
  26. package/build/dex/woo-fi-v2/woo-fi-math.js +137 -0
  27. package/build/dex/woo-fi-v2/woo-fi-math.js.map +1 -0
  28. package/build/router/buy.d.ts +1 -1
  29. package/build/router/buy.js +3 -3
  30. package/build/router/buy.js.map +1 -1
  31. package/build/router/directswap.d.ts +1 -1
  32. package/build/router/directswap.js +3 -3
  33. package/build/router/directswap.js.map +1 -1
  34. package/build/router/irouter.d.ts +1 -1
  35. package/build/router/megaswap.d.ts +1 -1
  36. package/build/router/megaswap.js +3 -3
  37. package/build/router/megaswap.js.map +1 -1
  38. package/build/router/multiswap.d.ts +1 -1
  39. package/build/router/multiswap.js +3 -3
  40. package/build/router/multiswap.js.map +1 -1
  41. package/build/router/payload-encoder.d.ts +3 -3
  42. package/build/router/payload-encoder.js +6 -6
  43. package/build/router/payload-encoder.js.map +1 -1
  44. package/build/router/simpleswap.d.ts +2 -2
  45. package/build/router/simpleswap.js +3 -3
  46. package/build/router/simpleswap.js.map +1 -1
  47. package/build/router/simpleswapnft.d.ts +1 -1
  48. package/build/router/simpleswapnft.js +3 -3
  49. package/build/router/simpleswapnft.js.map +1 -1
  50. package/build/transaction-builder.d.ts +2 -2
  51. package/build/transaction-builder.js +2 -2
  52. package/build/transaction-builder.js.map +1 -1
  53. package/build/types.d.ts +0 -1
  54. package/build/workers.d.ts +0 -0
  55. package/build/workers.js +2 -0
  56. package/build/workers.js.map +1 -0
  57. package/package.json +1 -1
  58. package/src/config.ts +2 -5
  59. package/src/dex/idex.ts +0 -2
  60. package/src/dex/index.ts +0 -2
  61. package/src/router/buy.ts +3 -7
  62. package/src/router/directswap.ts +3 -7
  63. package/src/router/irouter.ts +1 -1
  64. package/src/router/megaswap.ts +3 -7
  65. package/src/router/multiswap.ts +3 -7
  66. package/src/router/payload-encoder.ts +7 -7
  67. package/src/router/simpleswap.ts +4 -8
  68. package/src/router/simpleswapnft.ts +3 -7
  69. package/src/transaction-builder.ts +3 -3
  70. package/src/types.ts +0 -1
  71. package/tests/constants-e2e.ts +2 -2
  72. package/.idea/aws.xml +0 -17
  73. package/.idea/codeStyles/Project.xml +0 -19
  74. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  75. package/.idea/misc.xml +0 -6
  76. package/.idea/modules.xml +0 -8
  77. package/.idea/paraswap-dex-lib.iml +0 -9
  78. package/.idea/vcs.xml +0 -6
  79. package/build/abi/algebra/AlgebraPool.abi.json +0 -727
  80. package/build/abi/curve-v1/StableSwapFRXETH.json +0 -889
  81. package/build/abi/curve-v1/StableSwapWBETH.json +0 -1223
  82. package/build/abi/dexalot/DexalotMainnetRFQ.json +0 -952
  83. package/build/abi/sushiswap-v3/QuoterV2.json +0 -267
  84. package/build/abi/sushiswap-v3/RouterProcessor3.json +0 -289
  85. package/build/abi/wBETH.json +0 -1527
  86. package/build/dex/algebra/algebra-pool.d.ts +0 -46
  87. package/build/dex/algebra/algebra-pool.js +0 -336
  88. package/build/dex/algebra/algebra-pool.js.map +0 -1
  89. package/build/dex/curve-v1/pools/frxETHpool.d.ts +0 -7
  90. package/build/dex/curve-v1/pools/frxETHpool.js +0 -27
  91. package/build/dex/curve-v1/pools/frxETHpool.js.map +0 -1
  92. package/build/dex/curve-v1/pools/wbETHpool.d.ts +0 -29
  93. package/build/dex/curve-v1/pools/wbETHpool.js +0 -408
  94. package/build/dex/curve-v1/pools/wbETHpool.js.map +0 -1
  95. package/build/dex/dexalot/config.js +0 -18
  96. package/build/dex/dexalot/config.js.map +0 -1
  97. package/build/dex/dexalot/constants.d.ts +0 -15
  98. package/build/dex/dexalot/constants.js +0 -22
  99. package/build/dex/dexalot/constants.js.map +0 -1
  100. package/build/dex/dexalot/dexalot.d.ts +0 -69
  101. package/build/dex/dexalot/dexalot.js +0 -642
  102. package/build/dex/dexalot/dexalot.js.map +0 -1
  103. package/build/dex/dexalot/rate-fetcher.d.ts +0 -28
  104. package/build/dex/dexalot/rate-fetcher.js +0 -100
  105. package/build/dex/dexalot/rate-fetcher.js.map +0 -1
  106. package/build/dex/dexalot/types.d.ts +0 -114
  107. package/build/dex/dexalot/types.js +0 -12
  108. package/build/dex/dexalot/types.js.map +0 -1
  109. package/build/dex/dexalot/validators.d.ts +0 -5
  110. package/build/dex/dexalot/validators.js +0 -45
  111. package/build/dex/dexalot/validators.js.map +0 -1
  112. package/build/dex/pancakeswap-v3/types.d.ts +0 -14
  113. package/build/dex/ramses-v2/config.d.ts +0 -4
  114. package/build/dex/ramses-v2/config.js +0 -28
  115. package/build/dex/ramses-v2/config.js.map +0 -1
  116. package/build/dex/ramses-v2/constants.d.ts +0 -28
  117. package/build/dex/ramses-v2/constants.js +0 -35
  118. package/build/dex/ramses-v2/constants.js.map +0 -1
  119. package/build/dex/ramses-v2/contract-math/BitMath.d.ts +0 -4
  120. package/build/dex/ramses-v2/contract-math/BitMath.js +0 -93
  121. package/build/dex/ramses-v2/contract-math/BitMath.js.map +0 -1
  122. package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +0 -3
  123. package/build/dex/ramses-v2/contract-math/FixedPoint128.js +0 -8
  124. package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +0 -1
  125. package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +0 -4
  126. package/build/dex/ramses-v2/contract-math/FixedPoint96.js +0 -9
  127. package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +0 -1
  128. package/build/dex/ramses-v2/contract-math/FullMath.d.ts +0 -4
  129. package/build/dex/ramses-v2/contract-math/FullMath.js +0 -19
  130. package/build/dex/ramses-v2/contract-math/FullMath.js.map +0 -1
  131. package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +0 -3
  132. package/build/dex/ramses-v2/contract-math/LiquidityMath.js +0 -22
  133. package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +0 -1
  134. package/build/dex/ramses-v2/contract-math/Oracle.d.ts +0 -10
  135. package/build/dex/ramses-v2/contract-math/Oracle.js +0 -133
  136. package/build/dex/ramses-v2/contract-math/Oracle.js.map +0 -1
  137. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +0 -10
  138. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +0 -91
  139. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +0 -1
  140. package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +0 -8
  141. package/build/dex/ramses-v2/contract-math/SwapMath.js +0 -70
  142. package/build/dex/ramses-v2/contract-math/SwapMath.js.map +0 -1
  143. package/build/dex/ramses-v2/contract-math/Tick.d.ts +0 -7
  144. package/build/dex/ramses-v2/contract-math/Tick.js +0 -45
  145. package/build/dex/ramses-v2/contract-math/Tick.js.map +0 -1
  146. package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +0 -8
  147. package/build/dex/ramses-v2/contract-math/TickBitMap.js +0 -87
  148. package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +0 -1
  149. package/build/dex/ramses-v2/contract-math/TickMath.d.ts +0 -8
  150. package/build/dex/ramses-v2/contract-math/TickMath.js +0 -162
  151. package/build/dex/ramses-v2/contract-math/TickMath.js.map +0 -1
  152. package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +0 -3
  153. package/build/dex/ramses-v2/contract-math/UnsafeMath.js +0 -10
  154. package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +0 -1
  155. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +0 -18
  156. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +0 -392
  157. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +0 -1
  158. package/build/dex/ramses-v2/contract-math/utils.d.ts +0 -3
  159. package/build/dex/ramses-v2/contract-math/utils.js +0 -16
  160. package/build/dex/ramses-v2/contract-math/utils.js.map +0 -1
  161. package/build/dex/ramses-v2/ramses-v2-pool.d.ts +0 -42
  162. package/build/dex/ramses-v2/ramses-v2-pool.js +0 -307
  163. package/build/dex/ramses-v2/ramses-v2-pool.js.map +0 -1
  164. package/build/dex/ramses-v2/ramses-v2.d.ts +0 -61
  165. package/build/dex/ramses-v2/ramses-v2.js +0 -690
  166. package/build/dex/ramses-v2/ramses-v2.js.map +0 -1
  167. package/build/dex/ramses-v2/types.d.ts +0 -154
  168. package/build/dex/ramses-v2/types.js +0 -9
  169. package/build/dex/ramses-v2/types.js.map +0 -1
  170. package/build/dex/ramses-v2/utils.d.ts +0 -6
  171. package/build/dex/ramses-v2/utils.js +0 -71
  172. package/build/dex/ramses-v2/utils.js.map +0 -1
  173. package/build/dex/sushiswap-v3/config.d.ts +0 -4
  174. package/build/dex/sushiswap-v3/config.js +0 -132
  175. package/build/dex/sushiswap-v3/config.js.map +0 -1
  176. package/build/dex/sushiswap-v3/constants.d.ts +0 -4
  177. package/build/dex/sushiswap-v3/constants.js +0 -32
  178. package/build/dex/sushiswap-v3/constants.js.map +0 -1
  179. package/build/dex/sushiswap-v3/sushiswap-v3-original.d.ts +0 -56
  180. package/build/dex/sushiswap-v3/sushiswap-v3-original.js +0 -598
  181. package/build/dex/sushiswap-v3/sushiswap-v3-original.js.map +0 -1
  182. package/build/dex/sushiswap-v3/sushiswap-v3-pool.d.ts +0 -1
  183. package/build/dex/sushiswap-v3/sushiswap-v3-pool.js +0 -6
  184. package/build/dex/sushiswap-v3/sushiswap-v3-pool.js.map +0 -1
  185. package/build/dex/sushiswap-v3/sushiswap-v3.d.ts +0 -21
  186. package/build/dex/sushiswap-v3/sushiswap-v3.js +0 -58
  187. package/build/dex/sushiswap-v3/sushiswap-v3.js.map +0 -1
  188. package/build/dex/sushiswap-v3/token.d.ts +0 -6
  189. package/build/dex/sushiswap-v3/token.js +0 -23
  190. package/build/dex/sushiswap-v3/token.js.map +0 -1
  191. package/build/dex/sushiswap-v3/types.d.ts +0 -15
  192. package/build/dex/sushiswap-v3/types.js +0 -18
  193. package/build/dex/sushiswap-v3/types.js.map +0 -1
  194. package/src/abi/dexalot/DexalotMainnetRFQ.json +0 -952
  195. package/src/dex/dexalot/config.ts +0 -18
  196. package/src/dex/dexalot/constants.ts +0 -29
  197. package/src/dex/dexalot/dexalot-e2e.test.ts +0 -192
  198. package/src/dex/dexalot/dexalot-integration.test.ts +0 -188
  199. package/src/dex/dexalot/dexalot.ts +0 -998
  200. package/src/dex/dexalot/rate-fetcher.ts +0 -197
  201. package/src/dex/dexalot/types.ts +0 -131
  202. package/src/dex/dexalot/validators.ts +0 -46
  203. /package/build/dex/{pancakeswap-v3 → test-dex}/types.js +0 -0
@@ -1,18 +0,0 @@
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
- };
@@ -1,29 +0,0 @@
1
- import BigNumber from 'bignumber.js';
2
-
3
- export const DEXALOT_PRICES_CACHES_TTL_S = 3;
4
-
5
- export const DEXALOT_PAIRS_CACHES_TTL_S = 21 * 60; // 21 mins
6
-
7
- export const DEXALOT_TOKENS_CACHES_TTL_S = 21 * 60; // 21 mins
8
-
9
- export const DEXALOT_BLACKLIST_CACHES_TTL_S = 180 * 60; // 3 hours
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_RATE_LIMITED_TTL_S = 60 * 60; // 1 hour
22
-
23
- export const DEXALOT_RATELIMIT_CACHE_VALUE = 'limited';
24
-
25
- export const DEXALOT_RESTRICT_TTL_S = 60 * 30; // 30 minutes
26
-
27
- export const DEXALOT_RESTRICTED_CACHE_KEY = 'restricted';
28
-
29
- export const DEXALOT_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION = new BigNumber('0.001');
@@ -1,192 +0,0 @@
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 = 20000;
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
- });
@@ -1,188 +0,0 @@
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
- });