@paraswap/dex-lib 2.30.2-chronos-v3 → 2.30.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 (189) hide show
  1. package/build/dex/balancer-v2/balancer-v2.js +0 -2
  2. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  3. package/build/dex/balancer-v2/optimizer.js +38 -51
  4. package/build/dex/balancer-v2/optimizer.js.map +1 -1
  5. package/build/dex/balancer-v2/types.d.ts +0 -4
  6. package/build/dex/balancer-v2/types.js.map +1 -1
  7. package/build/dex/curve-v1-factory/config.js +17 -9
  8. package/build/dex/curve-v1-factory/config.js.map +1 -1
  9. package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +1 -1
  10. package/build/dex/curve-v1-factory/curve-v1-factory.js +192 -177
  11. package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
  12. package/build/dex/curve-v1-factory/curve-v1-pool-manager.js +4 -1
  13. package/build/dex/curve-v1-factory/curve-v1-pool-manager.js.map +1 -1
  14. package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js +1 -0
  15. package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js.map +1 -1
  16. package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js +1 -0
  17. package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js.map +1 -1
  18. package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js +1 -0
  19. package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js.map +1 -1
  20. package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js +1 -0
  21. package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js.map +1 -1
  22. package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js +1 -0
  23. package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js.map +1 -1
  24. package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js +61 -14
  25. package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js.map +1 -1
  26. package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js +1 -0
  27. package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js.map +1 -1
  28. package/build/dex/curve-v1-factory/price-handlers/functions/constants.js +10 -0
  29. package/build/dex/curve-v1-factory/price-handlers/functions/constants.js.map +1 -1
  30. package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js +1 -0
  31. package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js.map +1 -1
  32. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js +1 -0
  33. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js.map +1 -1
  34. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js +1 -0
  35. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js.map +1 -1
  36. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js +1 -0
  37. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js.map +1 -1
  38. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js +1 -0
  39. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js.map +1 -1
  40. package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js +1 -0
  41. package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js.map +1 -1
  42. package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js +1 -0
  43. package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js.map +1 -1
  44. package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.d.ts +1 -1
  45. package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js +2 -2
  46. package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js.map +1 -1
  47. package/build/dex/curve-v1-factory/types.d.ts +4 -1
  48. package/build/dex/curve-v1-factory/types.js +1 -0
  49. package/build/dex/curve-v1-factory/types.js.map +1 -1
  50. package/build/dex/solidly/forks-override/ramses.js +20 -8
  51. package/build/dex/solidly/forks-override/ramses.js.map +1 -1
  52. package/build/dex/solidly/solidly.js +1 -1
  53. package/build/dex/{ramses-v2 → test-dex}/config.d.ts +1 -1
  54. package/build/dex/test-dex/config.js +15 -0
  55. package/build/dex/test-dex/config.js.map +1 -0
  56. package/build/dex/test-dex/test-dex-pool.d.ts +39 -0
  57. package/build/dex/test-dex/test-dex-pool.js +63 -0
  58. package/build/dex/test-dex/test-dex-pool.js.map +1 -0
  59. package/build/dex/test-dex/test-dex.d.ts +37 -0
  60. package/build/dex/test-dex/test-dex.js +126 -0
  61. package/build/dex/test-dex/test-dex.js.map +1 -0
  62. package/build/dex/test-dex/types.d.ts +6 -0
  63. package/build/dex/{pancakeswap-v3 → test-dex}/types.js.map +1 -1
  64. package/build/dex/uniswap-v3/config.js +0 -14
  65. package/build/dex/uniswap-v3/config.js.map +1 -1
  66. package/build/dex/uniswap-v3/types.js.map +1 -1
  67. package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
  68. package/build/dex/uniswap-v3/uniswap-v3.js +1 -1
  69. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  70. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +16 -0
  71. package/build/dex/woo-fi-v2/woo-fi-math.js +137 -0
  72. package/build/dex/woo-fi-v2/woo-fi-math.js.map +1 -0
  73. package/package.json +1 -2
  74. package/scripts/dex-integration.ts +1 -1
  75. package/src/dex/balancer-v2/balancer-v2.ts +0 -2
  76. package/src/dex/balancer-v2/optimizer.ts +49 -62
  77. package/src/dex/balancer-v2/types.ts +0 -4
  78. package/src/dex/curve-v1-factory/config.ts +17 -9
  79. package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +19 -0
  80. package/src/dex/curve-v1-factory/curve-v1-factory-integration.test.ts +108 -45
  81. package/src/dex/curve-v1-factory/curve-v1-factory.ts +415 -367
  82. package/src/dex/curve-v1-factory/curve-v1-pool-manager.ts +4 -1
  83. package/src/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.ts +1 -0
  84. package/src/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.ts +1 -0
  85. package/src/dex/curve-v1-factory/price-handlers/functions/_rates.ts +1 -0
  86. package/src/dex/curve-v1-factory/price-handlers/functions/_xp.ts +1 -0
  87. package/src/dex/curve-v1-factory/price-handlers/functions/_xp_mem.ts +1 -0
  88. package/src/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.ts +71 -13
  89. package/src/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.ts +1 -0
  90. package/src/dex/curve-v1-factory/price-handlers/functions/constants.ts +11 -0
  91. package/src/dex/curve-v1-factory/price-handlers/functions/get_D.ts +2 -0
  92. package/src/dex/curve-v1-factory/price-handlers/functions/get_D_mem.ts +1 -0
  93. package/src/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.ts +1 -0
  94. package/src/dex/curve-v1-factory/price-handlers/functions/get_dy.ts +1 -0
  95. package/src/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.ts +1 -0
  96. package/src/dex/curve-v1-factory/price-handlers/functions/get_y.ts +1 -0
  97. package/src/dex/curve-v1-factory/price-handlers/functions/get_y_D.ts +1 -0
  98. package/src/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.ts +2 -1
  99. package/src/dex/curve-v1-factory/types.ts +3 -1
  100. package/src/dex/solidly/forks-override/ramses.ts +105 -76
  101. package/src/dex/solidly/solidly.ts +1 -1
  102. package/src/dex/uniswap-v3/config.ts +0 -16
  103. package/src/dex/uniswap-v3/types.ts +4 -2
  104. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +50 -133
  105. package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +2 -150
  106. package/src/dex/uniswap-v3/uniswap-v3-pool.ts +5 -2
  107. package/src/dex/uniswap-v3/uniswap-v3.ts +4 -3
  108. package/tests/constants-e2e.ts +10 -0
  109. package/.idea/aws.xml +0 -17
  110. package/.idea/codeStyles/Project.xml +0 -19
  111. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  112. package/.idea/misc.xml +0 -6
  113. package/.idea/modules.xml +0 -8
  114. package/.idea/paraswap-dex-lib.iml +0 -9
  115. package/.idea/vcs.xml +0 -6
  116. package/build/abi/algebra/AlgebraPool.abi.json +0 -727
  117. package/build/abi/curve-v1/StableSwapFRXETH.json +0 -889
  118. package/build/abi/curve-v1/StableSwapWBETH.json +0 -1223
  119. package/build/abi/wBETH.json +0 -1527
  120. package/build/dex/algebra/algebra-pool.d.ts +0 -46
  121. package/build/dex/algebra/algebra-pool.js +0 -336
  122. package/build/dex/algebra/algebra-pool.js.map +0 -1
  123. package/build/dex/curve-v1/pools/frxETHpool.d.ts +0 -7
  124. package/build/dex/curve-v1/pools/frxETHpool.js +0 -27
  125. package/build/dex/curve-v1/pools/frxETHpool.js.map +0 -1
  126. package/build/dex/curve-v1/pools/wbETHpool.d.ts +0 -29
  127. package/build/dex/curve-v1/pools/wbETHpool.js +0 -408
  128. package/build/dex/curve-v1/pools/wbETHpool.js.map +0 -1
  129. package/build/dex/pancakeswap-v3/types.d.ts +0 -14
  130. package/build/dex/ramses-v2/config.js +0 -28
  131. package/build/dex/ramses-v2/config.js.map +0 -1
  132. package/build/dex/ramses-v2/constants.d.ts +0 -28
  133. package/build/dex/ramses-v2/constants.js +0 -35
  134. package/build/dex/ramses-v2/constants.js.map +0 -1
  135. package/build/dex/ramses-v2/contract-math/BitMath.d.ts +0 -4
  136. package/build/dex/ramses-v2/contract-math/BitMath.js +0 -93
  137. package/build/dex/ramses-v2/contract-math/BitMath.js.map +0 -1
  138. package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +0 -3
  139. package/build/dex/ramses-v2/contract-math/FixedPoint128.js +0 -8
  140. package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +0 -1
  141. package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +0 -4
  142. package/build/dex/ramses-v2/contract-math/FixedPoint96.js +0 -9
  143. package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +0 -1
  144. package/build/dex/ramses-v2/contract-math/FullMath.d.ts +0 -4
  145. package/build/dex/ramses-v2/contract-math/FullMath.js +0 -19
  146. package/build/dex/ramses-v2/contract-math/FullMath.js.map +0 -1
  147. package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +0 -3
  148. package/build/dex/ramses-v2/contract-math/LiquidityMath.js +0 -22
  149. package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +0 -1
  150. package/build/dex/ramses-v2/contract-math/Oracle.d.ts +0 -10
  151. package/build/dex/ramses-v2/contract-math/Oracle.js +0 -133
  152. package/build/dex/ramses-v2/contract-math/Oracle.js.map +0 -1
  153. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +0 -10
  154. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +0 -91
  155. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +0 -1
  156. package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +0 -8
  157. package/build/dex/ramses-v2/contract-math/SwapMath.js +0 -70
  158. package/build/dex/ramses-v2/contract-math/SwapMath.js.map +0 -1
  159. package/build/dex/ramses-v2/contract-math/Tick.d.ts +0 -7
  160. package/build/dex/ramses-v2/contract-math/Tick.js +0 -45
  161. package/build/dex/ramses-v2/contract-math/Tick.js.map +0 -1
  162. package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +0 -8
  163. package/build/dex/ramses-v2/contract-math/TickBitMap.js +0 -87
  164. package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +0 -1
  165. package/build/dex/ramses-v2/contract-math/TickMath.d.ts +0 -8
  166. package/build/dex/ramses-v2/contract-math/TickMath.js +0 -162
  167. package/build/dex/ramses-v2/contract-math/TickMath.js.map +0 -1
  168. package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +0 -3
  169. package/build/dex/ramses-v2/contract-math/UnsafeMath.js +0 -10
  170. package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +0 -1
  171. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +0 -18
  172. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +0 -392
  173. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +0 -1
  174. package/build/dex/ramses-v2/contract-math/utils.d.ts +0 -3
  175. package/build/dex/ramses-v2/contract-math/utils.js +0 -16
  176. package/build/dex/ramses-v2/contract-math/utils.js.map +0 -1
  177. package/build/dex/ramses-v2/ramses-v2-pool.d.ts +0 -42
  178. package/build/dex/ramses-v2/ramses-v2-pool.js +0 -307
  179. package/build/dex/ramses-v2/ramses-v2-pool.js.map +0 -1
  180. package/build/dex/ramses-v2/ramses-v2.d.ts +0 -61
  181. package/build/dex/ramses-v2/ramses-v2.js +0 -690
  182. package/build/dex/ramses-v2/ramses-v2.js.map +0 -1
  183. package/build/dex/ramses-v2/types.d.ts +0 -154
  184. package/build/dex/ramses-v2/types.js +0 -9
  185. package/build/dex/ramses-v2/types.js.map +0 -1
  186. package/build/dex/ramses-v2/utils.d.ts +0 -6
  187. package/build/dex/ramses-v2/utils.js +0 -71
  188. package/build/dex/ramses-v2/utils.js.map +0 -1
  189. /package/build/dex/{pancakeswap-v3 → test-dex}/types.js +0 -0
@@ -1,83 +1,70 @@
1
- import _ from 'lodash';
2
- import { UnoptimizedRate } from '../../types';
1
+ import { UnoptimizedRate, OptimalSwapExchange } from '../../types';
2
+ import { BalancerSwapV2 } from './types';
3
3
  import { SwapSide } from '../../constants';
4
4
  import { BalancerConfig } from './config';
5
- import { OptimalSwap } from '@paraswap/core';
5
+
6
+ const MAX_UINT256 =
7
+ '115792089237316195423570985008687907853269984665640564039457584007913129639935';
8
+
9
+ const AllBalancerV2Forks = Object.keys(BalancerConfig);
6
10
 
7
11
  export function balancerV2Merge(or: UnoptimizedRate): UnoptimizedRate {
8
- const balancerForksList = Object.keys(BalancerConfig).map(b =>
9
- b.toLowerCase(),
10
- );
11
- const fixSwap = (rawRate: OptimalSwap[], side: SwapSide): OptimalSwap[] => {
12
- let lastExchange: false | OptimalSwap = false;
13
- let optimizedRate = new Array<OptimalSwap>();
14
- rawRate.forEach((s: OptimalSwap) => {
15
- if (
16
- s.swapExchanges.length !== 1 ||
17
- !balancerForksList.includes(s.swapExchanges[0].exchange.toLowerCase())
18
- ) {
19
- lastExchange = false;
20
- optimizedRate.push(s);
21
- } else if (
22
- lastExchange &&
23
- lastExchange.swapExchanges[0].exchange.toLowerCase() ===
24
- s.swapExchanges[0].exchange.toLowerCase() &&
25
- _.last(
26
- <any[]>lastExchange.swapExchanges[0].data.swaps,
27
- )!.tokenOut.toLowerCase() ===
28
- s.swapExchanges[0].data.tokenIn.toLowerCase()
29
- ) {
30
- const [lastExchangeSwap] = lastExchange.swapExchanges;
31
- const [currentSwap] = s.swapExchanges;
32
- lastExchangeSwap.srcAmount = (
33
- BigInt(lastExchangeSwap.srcAmount) + BigInt(currentSwap.srcAmount)
12
+ const fixSwap = (
13
+ rawSwap: OptimalSwapExchange<any>[],
14
+ side: SwapSide,
15
+ ): OptimalSwapExchange<any>[] => {
16
+ const newBalancers: { [key: string]: OptimalSwapExchange<any> } = {};
17
+ let optimizedSwap = new Array<OptimalSwapExchange<any>>();
18
+ rawSwap.forEach((s: OptimalSwapExchange<any>) => {
19
+ const exchangeKey = s.exchange.toLowerCase();
20
+ if (AllBalancerV2Forks.some(d => d.toLowerCase() === exchangeKey)) {
21
+ if (!(exchangeKey in newBalancers)) {
22
+ newBalancers[exchangeKey] = {
23
+ exchange: s.exchange,
24
+ srcAmount: '0',
25
+ destAmount: '0',
26
+ percent: 0,
27
+ poolAddresses: [],
28
+ data: {
29
+ swaps: new Array<BalancerSwapV2>(),
30
+ gasUSD: '0',
31
+ },
32
+ };
33
+ }
34
+ newBalancers[exchangeKey].srcAmount = (
35
+ BigInt(newBalancers[exchangeKey].srcAmount) + BigInt(s.srcAmount)
34
36
  ).toString();
35
37
 
36
- lastExchangeSwap.destAmount = (
37
- BigInt(lastExchangeSwap.destAmount) + BigInt(currentSwap.destAmount)
38
+ newBalancers[exchangeKey].destAmount = (
39
+ BigInt(newBalancers[exchangeKey].destAmount) + BigInt(s.destAmount)
38
40
  ).toString();
39
41
 
40
- lastExchangeSwap.percent += currentSwap.percent;
41
- lastExchangeSwap.data.gasUSD = (
42
- parseFloat(lastExchangeSwap.data.gasUSD) +
43
- parseFloat(currentSwap.data.gasUSD)
42
+ newBalancers[exchangeKey].percent += s.percent;
43
+ newBalancers[exchangeKey].data.exchangeProxy = s.data.exchangeProxy;
44
+ newBalancers[exchangeKey].data.gasUSD = (
45
+ parseFloat(newBalancers[exchangeKey].data.gasUSD) +
46
+ parseFloat(s.data.gasUSD)
44
47
  ).toFixed(6);
45
48
 
46
- lastExchangeSwap.data.swaps.push({
47
- poolId: currentSwap.data.poolId,
48
- amount:
49
- side === SwapSide.SELL
50
- ? currentSwap.srcAmount
51
- : currentSwap.destAmount,
52
- tokenIn: currentSwap.data.tokenIn,
53
- tokenOut: currentSwap.data.tokenOut,
49
+ newBalancers[exchangeKey].data.swaps.push({
50
+ poolId: s.data.poolId,
51
+ amount: side === SwapSide.SELL ? s.srcAmount : s.destAmount,
54
52
  });
55
- lastExchangeSwap.poolAddresses!.push(currentSwap.poolAddresses![0]);
53
+ newBalancers[exchangeKey].poolAddresses!.push(s.poolAddresses![0]);
56
54
  } else {
57
- lastExchange = _.cloneDeep(s);
58
- lastExchange.swapExchanges[0].data = {};
59
- lastExchange.swapExchanges[0].data.gasUSD =
60
- s.swapExchanges[0].data.gasUSD;
61
- lastExchange.swapExchanges[0].data.swaps = [
62
- {
63
- poolId: s.swapExchanges[0].data.poolId,
64
- amount:
65
- side === SwapSide.SELL
66
- ? s.swapExchanges[0].srcAmount
67
- : s.swapExchanges[0].destAmount,
68
- tokenIn: s.swapExchanges[0].data.tokenIn,
69
- tokenOut: s.swapExchanges[0].data.tokenOut,
70
- },
71
- ];
72
- optimizedRate.push(lastExchange);
55
+ optimizedSwap.push(s);
73
56
  }
74
57
  });
75
- return optimizedRate;
58
+ optimizedSwap = optimizedSwap.concat(Object.values(newBalancers));
59
+ return optimizedSwap;
76
60
  };
77
61
 
78
62
  or.bestRoute = or.bestRoute.map(r => ({
79
63
  ...r,
80
- swaps: fixSwap(r.swaps, or.side),
64
+ swaps: r.swaps.map(s => ({
65
+ ...s,
66
+ swapExchanges: fixSwap(s.swapExchanges, or.side),
67
+ })),
81
68
  }));
82
69
  return or;
83
70
  }
@@ -82,8 +82,6 @@ export interface SubgraphPoolBase {
82
82
  export type BalancerSwapV2 = {
83
83
  poolId: string;
84
84
  amount: string;
85
- tokenIn: string;
86
- tokenOut: string;
87
85
  };
88
86
 
89
87
  export type OptimizedBalancerV2Data = {
@@ -141,8 +139,6 @@ export type BalancerV2DirectParam = [
141
139
 
142
140
  export type BalancerV2Data = {
143
141
  poolId: string;
144
- tokenIn: string;
145
- tokenOut: string;
146
142
  };
147
143
 
148
144
  export type DexParams = {
@@ -13,7 +13,10 @@ import { normalizeAddress } from '../../utils';
13
13
  const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
14
14
  CurveV1Factory: {
15
15
  [Network.MAINNET]: {
16
- factoryAddress: '0xB9fC157394Af804a3578134A6585C0dc9cc990d4',
16
+ factoryAddresses: [
17
+ '0xB9fC157394Af804a3578134A6585C0dc9cc990d4',
18
+ '0x4f8846ae9380b90d2e71d5e3d042dff3e7ebb40d',
19
+ ],
17
20
  stateUpdatePeriodMs: 5 * 1000,
18
21
  disabledPools: new Set([
19
22
  '0x28B0Cf1baFB707F2c6826d10caf6DD901a6540C5', // It is rug pool token
@@ -150,6 +153,11 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
150
153
  name: ImplementationNames.FACTORY_PLAIN_4_OPTIMIZED,
151
154
  address: '0xad4753d045d3aed5c1a6606dfb6a7d7ad67c1ad7',
152
155
  },
156
+ '0x67fe41A94e779CcFa22cff02cc2957DC9C0e4286': {
157
+ name: ImplementationNames.FACTORY_PLAIN_2_CRV_EMA,
158
+ address: '0x67fe41A94e779CcFa22cff02cc2957DC9C0e4286',
159
+ liquidityApiSlug: '/factory-crvusd',
160
+ },
153
161
  },
154
162
  customPools: {
155
163
  '0xDcEF968d416a41Cdac0ED8702fAC8128A64241A2': {
@@ -200,7 +208,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
200
208
  },
201
209
  },
202
210
  [Network.POLYGON]: {
203
- factoryAddress: '0x722272D36ef0Da72FF51c5A65Db7b870E2e8D4ee',
211
+ factoryAddresses: ['0x722272D36ef0Da72FF51c5A65Db7b870E2e8D4ee'],
204
212
  stateUpdatePeriodMs: 2 * 1000,
205
213
  disabledPools: new Set([
206
214
  '0x666Dc3b4baBfd063FaF965BD020024AF0dC51B64',
@@ -306,7 +314,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
306
314
  },
307
315
  },
308
316
  [Network.FANTOM]: {
309
- factoryAddress: '0x686d67265703D1f124c45E33d47d794c566889Ba',
317
+ factoryAddresses: ['0x686d67265703D1f124c45E33d47d794c566889Ba'],
310
318
  stateUpdatePeriodMs: 2 * 1000,
311
319
  disabledPools: new Set([]),
312
320
  disabledImplementations: new Set([]),
@@ -421,7 +429,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
421
429
  },
422
430
  },
423
431
  [Network.AVALANCHE]: {
424
- factoryAddress: '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
432
+ factoryAddresses: ['0xb17b674D9c5CB2e441F8e196a2f048A81355d031'],
425
433
  stateUpdatePeriodMs: 2 * 1000,
426
434
  // FIX: This must be removed when we go for full CurveV1 event based support
427
435
  disabledPools: new Set(['0x16a7da911a4dd1d83f3ff066fe28f3c792c50d90']),
@@ -519,7 +527,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
519
527
  },
520
528
  },
521
529
  [Network.ARBITRUM]: {
522
- factoryAddress: '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
530
+ factoryAddresses: ['0xb17b674D9c5CB2e441F8e196a2f048A81355d031'],
523
531
  stateUpdatePeriodMs: 2 * 1000,
524
532
  disabledPools: new Set([]),
525
533
  disabledImplementations: new Set([]),
@@ -645,7 +653,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
645
653
  },
646
654
  },
647
655
  [Network.OPTIMISM]: {
648
- factoryAddress: '0x2db0E83599a91b508Ac268a6197b8B14F5e72840',
656
+ factoryAddresses: ['0x2db0E83599a91b508Ac268a6197b8B14F5e72840'],
649
657
  stateUpdatePeriodMs: 2 * 1000,
650
658
  disabledPools: new Set([]),
651
659
  disabledImplementations: new Set([]),
@@ -869,9 +877,9 @@ const configAddressesNormalizer = (
869
877
 
870
878
  // Unite everything into top level config
871
879
  const normalizedConfig: DexParams = {
872
- factoryAddress: _config.factoryAddress
873
- ? _config.factoryAddress.toLowerCase()
874
- : _config.factoryAddress,
880
+ factoryAddresses: _config.factoryAddresses
881
+ ? _config.factoryAddresses.map(e => e.toLowerCase())
882
+ : _config.factoryAddresses,
875
883
  stateUpdatePeriodMs: _config.stateUpdatePeriodMs,
876
884
  factoryPoolImplementations,
877
885
  customPools,
@@ -111,6 +111,25 @@ describe('CurveV1Factory E2E', () => {
111
111
  tokenBAmount,
112
112
  );
113
113
  });
114
+
115
+ describe('Mainnet crvUSD', () => {
116
+ const network = Network.MAINNET;
117
+
118
+ const tokenASymbol: string = 'crvUSD';
119
+ const tokenBSymbol: string = 'USDT';
120
+
121
+ const tokenAAmount: string = '10000000000000000000';
122
+ const tokenBAmount: string = '10000000';
123
+
124
+ testForNetwork(
125
+ network,
126
+ dexKey,
127
+ tokenASymbol,
128
+ tokenBSymbol,
129
+ tokenAAmount,
130
+ tokenBAmount,
131
+ );
132
+ });
114
133
  describe('Mainnet ng pool', () => {
115
134
  const network = Network.MAINNET;
116
135
 
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-console */
1
2
  import dotenv from 'dotenv';
2
3
  dotenv.config();
3
4
 
@@ -143,23 +144,6 @@ describe('CurveV1Factory', function () {
143
144
 
144
145
  const tokens = Tokens[network];
145
146
 
146
- const srcTokenSymbol = 'USDD';
147
- const destTokenSymbol = 'USDT';
148
-
149
- const amountsForSell = [
150
- 0n,
151
- 1n * BI_POWS[tokens[srcTokenSymbol].decimals],
152
- 2n * BI_POWS[tokens[srcTokenSymbol].decimals],
153
- 3n * BI_POWS[tokens[srcTokenSymbol].decimals],
154
- 4n * BI_POWS[tokens[srcTokenSymbol].decimals],
155
- 5n * BI_POWS[tokens[srcTokenSymbol].decimals],
156
- 6n * BI_POWS[tokens[srcTokenSymbol].decimals],
157
- 7n * BI_POWS[tokens[srcTokenSymbol].decimals],
158
- 8n * BI_POWS[tokens[srcTokenSymbol].decimals],
159
- 9n * BI_POWS[tokens[srcTokenSymbol].decimals],
160
- 10n * BI_POWS[tokens[srcTokenSymbol].decimals],
161
- ];
162
-
163
147
  beforeAll(async () => {
164
148
  blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
165
149
  // @ts-expect-error for testing there is dummy blocknumber, but it is not
@@ -178,39 +162,118 @@ describe('CurveV1Factory', function () {
178
162
  if (curveV1Factory) curveV1Factory.releaseResources();
179
163
  });
180
164
 
181
- it('getPoolIdentifiers and getPricesVolume SELL', async function () {
182
- await testPricingOnNetwork(
183
- curveV1Factory,
184
- network,
185
- dexKey,
186
- blockNumber,
187
- srcTokenSymbol,
188
- destTokenSymbol,
189
- SwapSide.SELL,
190
- amountsForSell,
191
- );
165
+ describe(`USDD-USDT`, () => {
166
+ const srcTokenSymbol = 'USDD';
167
+ const destTokenSymbol = 'USDT';
168
+ const amountsForSell = [
169
+ 0n,
170
+ 1n * BI_POWS[tokens[srcTokenSymbol].decimals],
171
+ 2n * BI_POWS[tokens[srcTokenSymbol].decimals],
172
+ 3n * BI_POWS[tokens[srcTokenSymbol].decimals],
173
+ 4n * BI_POWS[tokens[srcTokenSymbol].decimals],
174
+ 5n * BI_POWS[tokens[srcTokenSymbol].decimals],
175
+ 6n * BI_POWS[tokens[srcTokenSymbol].decimals],
176
+ 7n * BI_POWS[tokens[srcTokenSymbol].decimals],
177
+ 8n * BI_POWS[tokens[srcTokenSymbol].decimals],
178
+ 9n * BI_POWS[tokens[srcTokenSymbol].decimals],
179
+ 10n * BI_POWS[tokens[srcTokenSymbol].decimals],
180
+ ];
181
+
182
+ it('getPoolIdentifiers and getPricesVolume SELL', async function () {
183
+ await testPricingOnNetwork(
184
+ curveV1Factory,
185
+ network,
186
+ dexKey,
187
+ blockNumber,
188
+ srcTokenSymbol,
189
+ destTokenSymbol,
190
+ SwapSide.SELL,
191
+ amountsForSell,
192
+ );
193
+ });
194
+
195
+ it('getTopPoolsForToken', async function () {
196
+ // We have to check without calling initializePricing, because
197
+ // pool-tracker is not calling that function
198
+ const newCurveV1Factory = new CurveV1Factory(
199
+ network,
200
+ dexKey,
201
+ dexHelper,
202
+ );
203
+ if (newCurveV1Factory.updatePoolState) {
204
+ await newCurveV1Factory.updatePoolState();
205
+ }
206
+ const poolLiquidity = await newCurveV1Factory.getTopPoolsForToken(
207
+ tokens[srcTokenSymbol].address,
208
+ 10,
209
+ );
210
+ console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
211
+
212
+ if (!newCurveV1Factory.hasConstantPriceLargeAmounts) {
213
+ checkPoolsLiquidity(
214
+ poolLiquidity,
215
+ Tokens[network][srcTokenSymbol].address,
216
+ dexKey,
217
+ );
218
+ }
219
+ });
192
220
  });
193
221
 
194
- it('getTopPoolsForToken', async function () {
195
- // We have to check without calling initializePricing, because
196
- // pool-tracker is not calling that function
197
- const newCurveV1Factory = new CurveV1Factory(network, dexKey, dexHelper);
198
- if (newCurveV1Factory.updatePoolState) {
199
- await newCurveV1Factory.updatePoolState();
200
- }
201
- const poolLiquidity = await newCurveV1Factory.getTopPoolsForToken(
202
- tokens[srcTokenSymbol].address,
203
- 10,
204
- );
205
- console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
222
+ describe(`crvUSD-GHO`, () => {
223
+ const srcTokenSymbol = 'crvUSD';
224
+ const destTokenSymbol = 'GHO';
225
+ const amountsForSell = [
226
+ 0n,
227
+ 1n * BI_POWS[tokens[srcTokenSymbol].decimals],
228
+ 2n * BI_POWS[tokens[srcTokenSymbol].decimals],
229
+ 3n * BI_POWS[tokens[srcTokenSymbol].decimals],
230
+ 4n * BI_POWS[tokens[srcTokenSymbol].decimals],
231
+ 5n * BI_POWS[tokens[srcTokenSymbol].decimals],
232
+ 6n * BI_POWS[tokens[srcTokenSymbol].decimals],
233
+ 7n * BI_POWS[tokens[srcTokenSymbol].decimals],
234
+ 8n * BI_POWS[tokens[srcTokenSymbol].decimals],
235
+ 9n * BI_POWS[tokens[srcTokenSymbol].decimals],
236
+ 10n * BI_POWS[tokens[srcTokenSymbol].decimals],
237
+ ];
238
+
239
+ it('getPoolIdentifiers and getPricesVolume SELL', async function () {
240
+ await testPricingOnNetwork(
241
+ curveV1Factory,
242
+ network,
243
+ dexKey,
244
+ blockNumber,
245
+ srcTokenSymbol,
246
+ destTokenSymbol,
247
+ SwapSide.SELL,
248
+ amountsForSell,
249
+ );
250
+ });
206
251
 
207
- if (!newCurveV1Factory.hasConstantPriceLargeAmounts) {
208
- checkPoolsLiquidity(
209
- poolLiquidity,
210
- Tokens[network][srcTokenSymbol].address,
252
+ it('getTopPoolsForToken', async function () {
253
+ // We have to check without calling initializePricing, because
254
+ // pool-tracker is not calling that function
255
+ const newCurveV1Factory = new CurveV1Factory(
256
+ network,
211
257
  dexKey,
258
+ dexHelper,
212
259
  );
213
- }
260
+ if (newCurveV1Factory.updatePoolState) {
261
+ await newCurveV1Factory.updatePoolState();
262
+ }
263
+ const poolLiquidity = await newCurveV1Factory.getTopPoolsForToken(
264
+ tokens[srcTokenSymbol].address,
265
+ 10,
266
+ );
267
+ console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
268
+
269
+ if (!newCurveV1Factory.hasConstantPriceLargeAmounts) {
270
+ checkPoolsLiquidity(
271
+ poolLiquidity,
272
+ Tokens[network][srcTokenSymbol].address,
273
+ dexKey,
274
+ );
275
+ }
276
+ });
214
277
  });
215
278
  });
216
279
  describe('Polygon', () => {