@paraswap/dex-lib 3.7.0 → 3.7.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 (304) hide show
  1. package/build/abi/Uncompressor.json +250 -0
  2. package/build/dex/aave-v1/aave-v1.d.ts +1 -2
  3. package/build/dex/aave-v1/aave-v1.js +0 -23
  4. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  5. package/build/dex/balancer-v2/balancer-v2.js +41 -19
  6. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  7. package/build/dex/compound.js +1 -1
  8. package/build/dex/compound.js.map +1 -1
  9. package/build/dex/etherfi/etherfi.d.ts +26 -0
  10. package/build/dex/etherfi/etherfi.js +96 -0
  11. package/build/dex/etherfi/etherfi.js.map +1 -0
  12. package/build/dex/platypus/platypus.d.ts +1 -2
  13. package/build/dex/platypus/platypus.js +0 -45
  14. package/build/dex/platypus/platypus.js.map +1 -1
  15. package/build/dex/sdai/config.d.ts +11 -0
  16. package/build/dex/sdai/config.js +21 -0
  17. package/build/dex/sdai/config.js.map +1 -0
  18. package/build/dex/sdai/constants.d.ts +2 -0
  19. package/build/dex/sdai/constants.js +6 -0
  20. package/build/dex/sdai/constants.js.map +1 -0
  21. package/build/dex/sdai/scripts/validate-state.d.ts +1 -0
  22. package/build/dex/sdai/scripts/validate-state.js +102 -0
  23. package/build/dex/sdai/scripts/validate-state.js.map +1 -0
  24. package/build/dex/sdai/sdai-pool.d.ts +16 -0
  25. package/build/dex/sdai/sdai-pool.js +85 -0
  26. package/build/dex/sdai/sdai-pool.js.map +1 -0
  27. package/build/dex/sdai/sdai.d.ts +51 -0
  28. package/build/dex/sdai/sdai.js +172 -0
  29. package/build/dex/sdai/sdai.js.map +1 -0
  30. package/build/dex/sdai/types.d.ts +21 -0
  31. package/build/dex/sdai/types.js +11 -0
  32. package/build/dex/sdai/types.js.map +1 -0
  33. package/build/dex/sdai/utils.d.ts +4 -0
  34. package/build/dex/sdai/utils.js +39 -0
  35. package/build/dex/sdai/utils.js.map +1 -0
  36. package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
  37. package/build/dex/swaap-v1/swaap-v1.js +0 -14
  38. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  39. package/build/executor/compressor/Compressor.d.ts +23 -0
  40. package/build/executor/compressor/Compressor.js +144 -0
  41. package/build/executor/compressor/Compressor.js.map +1 -0
  42. package/build/executor/compressor/compress.d.ts +17 -0
  43. package/build/executor/compressor/compress.js +187 -0
  44. package/build/executor/compressor/compress.js.map +1 -0
  45. package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +6 -0
  46. package/build/executor/compressor/compress_functions/addressSubstitution.js +29 -0
  47. package/build/executor/compressor/compress_functions/addressSubstitution.js.map +1 -0
  48. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +10 -0
  49. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +40 -0
  50. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +1 -0
  51. package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +11 -0
  52. package/build/executor/compressor/compress_functions/byteSubstitution.js +64 -0
  53. package/build/executor/compressor/compress_functions/byteSubstitution.js.map +1 -0
  54. package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +7 -0
  55. package/build/executor/compressor/compress_functions/ffSubstitution.js +54 -0
  56. package/build/executor/compressor/compress_functions/ffSubstitution.js.map +1 -0
  57. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +8 -0
  58. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +67 -0
  59. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +1 -0
  60. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +8 -0
  61. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +61 -0
  62. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +1 -0
  63. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +6 -0
  64. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +37 -0
  65. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +1 -0
  66. package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +9 -0
  67. package/build/executor/compressor/compress_functions/searchUnusedBytes.js +33 -0
  68. package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +1 -0
  69. package/build/executor/compressor/fetchSaved.d.ts +0 -0
  70. package/build/executor/compressor/fetchSaved.js +17 -0
  71. package/build/executor/compressor/fetchSaved.js.map +1 -0
  72. package/build/executor/compressor/utils/computeCostL2.d.ts +2 -0
  73. package/build/executor/compressor/utils/computeCostL2.js +14 -0
  74. package/build/executor/compressor/utils/computeCostL2.js.map +1 -0
  75. package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +2 -0
  76. package/build/executor/compressor/utils/findLongestDuplicatedString.js +30 -0
  77. package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +1 -0
  78. package/build/executor/compressor/utils/getAllIndexes.d.ts +2 -0
  79. package/build/executor/compressor/utils/getAllIndexes.js +12 -0
  80. package/build/executor/compressor/utils/getAllIndexes.js.map +1 -0
  81. package/build/executor/compressor/utils/getByteForAddress.d.ts +2 -0
  82. package/build/executor/compressor/utils/getByteForAddress.js +14 -0
  83. package/build/executor/compressor/utils/getByteForAddress.js.map +1 -0
  84. package/build/executor/compressor/utils/intTo2Bytes.d.ts +2 -0
  85. package/build/executor/compressor/utils/intTo2Bytes.js +14 -0
  86. package/build/executor/compressor/utils/intTo2Bytes.js.map +1 -0
  87. package/build/executor/compressor/utils/intTo3Bytes.d.ts +2 -0
  88. package/build/executor/compressor/utils/intTo3Bytes.js +18 -0
  89. package/build/executor/compressor/utils/intTo3Bytes.js.map +1 -0
  90. package/build/executor/compressor/utils/intToByte.d.ts +2 -0
  91. package/build/executor/compressor/utils/intToByte.js +10 -0
  92. package/build/executor/compressor/utils/intToByte.js.map +1 -0
  93. package/package.json +1 -1
  94. package/src/dex/balancer-v2/balancer-v2.ts +41 -19
  95. package/tests/utils-e2e.ts +114 -116
  96. package/.idea/aws.xml +0 -17
  97. package/.idea/codeStyles/Project.xml +0 -19
  98. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  99. package/.idea/misc.xml +0 -6
  100. package/.idea/modules.xml +0 -8
  101. package/.idea/paraswap-dex-lib.iml +0 -9
  102. package/.idea/prettier.xml +0 -7
  103. package/.idea/vcs.xml +0 -6
  104. package/build/abi/AugustusV6.abi.json +0 -395
  105. package/build/abi/algebra/AlgebraPool.abi.json +0 -727
  106. package/build/abi/curve-v1/StableSwapFRXETH.json +0 -889
  107. package/build/abi/curve-v1/StableSwapWBETH.json +0 -1223
  108. package/build/abi/integral/relayer.json +0 -1148
  109. package/build/abi/sushiswap-v3/QuoterV2.json +0 -267
  110. package/build/abi/sushiswap-v3/RouterProcessor3.json +0 -289
  111. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  112. package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3QuoterV2.abi.json +0 -285
  113. package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3Router.abi.json +0 -583
  114. package/build/abi/wBETH.json +0 -1527
  115. package/build/abi/woo-fi/WooFeeManager.abi.json +0 -318
  116. package/build/abi/woo-fi/WooPP.abi.json +0 -548
  117. package/build/abi/woo-fi/Wooracle.abi.json +0 -260
  118. package/build/dex/aave-v2/tokens-avalanche.json +0 -44
  119. package/build/dex/aave-v2/tokens-mainnet.json +0 -188
  120. package/build/dex/aave-v2/tokens-polygon.json +0 -44
  121. package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
  122. package/build/dex/aave-v3/tokens/avalanche.json +0 -74
  123. package/build/dex/aave-v3/tokens/fantom.json +0 -62
  124. package/build/dex/aave-v3/tokens/optimism.json +0 -50
  125. package/build/dex/aave-v3/tokens/polygon.json +0 -116
  126. package/build/dex/algebra/algebra-pool.d.ts +0 -114
  127. package/build/dex/algebra/algebra-pool.js +0 -448
  128. package/build/dex/algebra/algebra-pool.js.map +0 -1
  129. package/build/dex/balancer-v2/Gyro3Pool.d.ts +0 -43
  130. package/build/dex/balancer-v2/Gyro3Pool.js +0 -160
  131. package/build/dex/balancer-v2/Gyro3Pool.js.map +0 -1
  132. package/build/dex/balancer-v2/LinearMath.d.ts +0 -88
  133. package/build/dex/balancer-v2/LinearMath.js +0 -285
  134. package/build/dex/balancer-v2/LinearMath.js.map +0 -1
  135. package/build/dex/balancer-v2/LinearPool.d.ts +0 -81
  136. package/build/dex/balancer-v2/LinearPool.js +0 -444
  137. package/build/dex/balancer-v2/LinearPool.js.map +0 -1
  138. package/build/dex/balancer-v2/PhantomStablePool.d.ts +0 -90
  139. package/build/dex/balancer-v2/PhantomStablePool.js +0 -418
  140. package/build/dex/balancer-v2/PhantomStablePool.js.map +0 -1
  141. package/build/dex/balancer-v2/StableMath.d.ts +0 -9
  142. package/build/dex/balancer-v2/StableMath.js +0 -272
  143. package/build/dex/balancer-v2/StableMath.js.map +0 -1
  144. package/build/dex/balancer-v2/balancer-v2-pool.d.ts +0 -140
  145. package/build/dex/balancer-v2/balancer-v2-pool.js +0 -647
  146. package/build/dex/balancer-v2/balancer-v2-pool.js.map +0 -1
  147. package/build/dex/curve-v1/pools/frxETHpool.d.ts +0 -7
  148. package/build/dex/curve-v1/pools/frxETHpool.js +0 -27
  149. package/build/dex/curve-v1/pools/frxETHpool.js.map +0 -1
  150. package/build/dex/curve-v1/pools/wbETHpool.d.ts +0 -29
  151. package/build/dex/curve-v1/pools/wbETHpool.js +0 -408
  152. package/build/dex/curve-v1/pools/wbETHpool.js.map +0 -1
  153. package/build/dex/integral/config.d.ts +0 -4
  154. package/build/dex/integral/config.js +0 -18
  155. package/build/dex/integral/config.js.map +0 -1
  156. package/build/dex/integral/integral-pool.d.ts +0 -39
  157. package/build/dex/integral/integral-pool.js +0 -67
  158. package/build/dex/integral/integral-pool.js.map +0 -1
  159. package/build/dex/integral/integral.d.ts +0 -48
  160. package/build/dex/integral/integral.js +0 -402
  161. package/build/dex/integral/integral.js.map +0 -1
  162. package/build/dex/integral/types.d.ts +0 -25
  163. package/build/dex/integral/types.js +0 -9
  164. package/build/dex/integral/types.js.map +0 -1
  165. package/build/dex/lighter-v1/abi/erc20.json +0 -222
  166. package/build/dex/lighter-v1/abi/factory.json +0 -291
  167. package/build/dex/lighter-v1/abi/order_book.json +0 -594
  168. package/build/dex/lighter-v1/abi/order_book_helper.json +0 -176
  169. package/build/dex/lighter-v1/abi/router.json +0 -488
  170. package/build/dex/lighter-v1/config.d.ts +0 -4
  171. package/build/dex/lighter-v1/config.js +0 -17
  172. package/build/dex/lighter-v1/config.js.map +0 -1
  173. package/build/dex/lighter-v1/constants.d.ts +0 -2
  174. package/build/dex/lighter-v1/constants.js +0 -13
  175. package/build/dex/lighter-v1/constants.js.map +0 -1
  176. package/build/dex/lighter-v1/lighter-v1-pool.d.ts +0 -57
  177. package/build/dex/lighter-v1/lighter-v1-pool.js +0 -310
  178. package/build/dex/lighter-v1/lighter-v1-pool.js.map +0 -1
  179. package/build/dex/lighter-v1/lighter-v1.d.ts +0 -45
  180. package/build/dex/lighter-v1/lighter-v1.js +0 -331
  181. package/build/dex/lighter-v1/lighter-v1.js.map +0 -1
  182. package/build/dex/lighter-v1/types.d.ts +0 -40
  183. package/build/dex/lighter-v1/types.js +0 -3
  184. package/build/dex/lighter-v1/types.js.map +0 -1
  185. package/build/dex/pancakeswap-v3/types.d.ts +0 -14
  186. package/build/dex/pancakeswap-v3/types.js +0 -3
  187. package/build/dex/pancakeswap-v3/types.js.map +0 -1
  188. package/build/dex/quickswap/camelot-v3.d.ts +0 -6
  189. package/build/dex/quickswap/camelot-v3.js +0 -19
  190. package/build/dex/quickswap/camelot-v3.js.map +0 -1
  191. package/build/dex/quickswap/zyberswap-v3.d.ts +0 -6
  192. package/build/dex/quickswap/zyberswap-v3.js +0 -19
  193. package/build/dex/quickswap/zyberswap-v3.js.map +0 -1
  194. package/build/dex/quickswap-v3.d.ts +0 -21
  195. package/build/dex/quickswap-v3.js +0 -40
  196. package/build/dex/quickswap-v3.js.map +0 -1
  197. package/build/dex/ramses-v2/config.d.ts +0 -4
  198. package/build/dex/ramses-v2/config.js +0 -28
  199. package/build/dex/ramses-v2/config.js.map +0 -1
  200. package/build/dex/ramses-v2/constants.d.ts +0 -28
  201. package/build/dex/ramses-v2/constants.js +0 -35
  202. package/build/dex/ramses-v2/constants.js.map +0 -1
  203. package/build/dex/ramses-v2/contract-math/BitMath.d.ts +0 -4
  204. package/build/dex/ramses-v2/contract-math/BitMath.js +0 -93
  205. package/build/dex/ramses-v2/contract-math/BitMath.js.map +0 -1
  206. package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +0 -3
  207. package/build/dex/ramses-v2/contract-math/FixedPoint128.js +0 -8
  208. package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +0 -1
  209. package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +0 -4
  210. package/build/dex/ramses-v2/contract-math/FixedPoint96.js +0 -9
  211. package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +0 -1
  212. package/build/dex/ramses-v2/contract-math/FullMath.d.ts +0 -4
  213. package/build/dex/ramses-v2/contract-math/FullMath.js +0 -19
  214. package/build/dex/ramses-v2/contract-math/FullMath.js.map +0 -1
  215. package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +0 -3
  216. package/build/dex/ramses-v2/contract-math/LiquidityMath.js +0 -22
  217. package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +0 -1
  218. package/build/dex/ramses-v2/contract-math/Oracle.d.ts +0 -10
  219. package/build/dex/ramses-v2/contract-math/Oracle.js +0 -133
  220. package/build/dex/ramses-v2/contract-math/Oracle.js.map +0 -1
  221. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +0 -10
  222. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +0 -91
  223. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +0 -1
  224. package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +0 -8
  225. package/build/dex/ramses-v2/contract-math/SwapMath.js +0 -70
  226. package/build/dex/ramses-v2/contract-math/SwapMath.js.map +0 -1
  227. package/build/dex/ramses-v2/contract-math/Tick.d.ts +0 -7
  228. package/build/dex/ramses-v2/contract-math/Tick.js +0 -45
  229. package/build/dex/ramses-v2/contract-math/Tick.js.map +0 -1
  230. package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +0 -8
  231. package/build/dex/ramses-v2/contract-math/TickBitMap.js +0 -87
  232. package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +0 -1
  233. package/build/dex/ramses-v2/contract-math/TickMath.d.ts +0 -8
  234. package/build/dex/ramses-v2/contract-math/TickMath.js +0 -162
  235. package/build/dex/ramses-v2/contract-math/TickMath.js.map +0 -1
  236. package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +0 -3
  237. package/build/dex/ramses-v2/contract-math/UnsafeMath.js +0 -10
  238. package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +0 -1
  239. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +0 -18
  240. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +0 -392
  241. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +0 -1
  242. package/build/dex/ramses-v2/contract-math/utils.d.ts +0 -3
  243. package/build/dex/ramses-v2/contract-math/utils.js +0 -16
  244. package/build/dex/ramses-v2/contract-math/utils.js.map +0 -1
  245. package/build/dex/ramses-v2/ramses-v2-pool.d.ts +0 -42
  246. package/build/dex/ramses-v2/ramses-v2-pool.js +0 -307
  247. package/build/dex/ramses-v2/ramses-v2-pool.js.map +0 -1
  248. package/build/dex/ramses-v2/ramses-v2.d.ts +0 -61
  249. package/build/dex/ramses-v2/ramses-v2.js +0 -690
  250. package/build/dex/ramses-v2/ramses-v2.js.map +0 -1
  251. package/build/dex/ramses-v2/types.d.ts +0 -154
  252. package/build/dex/ramses-v2/types.js +0 -9
  253. package/build/dex/ramses-v2/types.js.map +0 -1
  254. package/build/dex/ramses-v2/utils.d.ts +0 -6
  255. package/build/dex/ramses-v2/utils.js +0 -71
  256. package/build/dex/ramses-v2/utils.js.map +0 -1
  257. package/build/dex/solidly/forks-override/fvm.d.ts +0 -20
  258. package/build/dex/solidly/forks-override/fvm.js +0 -42
  259. package/build/dex/solidly/forks-override/fvm.js.map +0 -1
  260. package/build/dex/sushiswap-v3/config.d.ts +0 -4
  261. package/build/dex/sushiswap-v3/config.js +0 -132
  262. package/build/dex/sushiswap-v3/config.js.map +0 -1
  263. package/build/dex/sushiswap-v3/constants.d.ts +0 -4
  264. package/build/dex/sushiswap-v3/constants.js +0 -32
  265. package/build/dex/sushiswap-v3/constants.js.map +0 -1
  266. package/build/dex/sushiswap-v3/sushiswap-v3-original.d.ts +0 -56
  267. package/build/dex/sushiswap-v3/sushiswap-v3-original.js +0 -598
  268. package/build/dex/sushiswap-v3/sushiswap-v3-original.js.map +0 -1
  269. package/build/dex/sushiswap-v3/sushiswap-v3-pool.d.ts +0 -1
  270. package/build/dex/sushiswap-v3/sushiswap-v3-pool.js +0 -6
  271. package/build/dex/sushiswap-v3/sushiswap-v3-pool.js.map +0 -1
  272. package/build/dex/sushiswap-v3/sushiswap-v3.d.ts +0 -21
  273. package/build/dex/sushiswap-v3/sushiswap-v3.js +0 -58
  274. package/build/dex/sushiswap-v3/sushiswap-v3.js.map +0 -1
  275. package/build/dex/sushiswap-v3/token.d.ts +0 -6
  276. package/build/dex/sushiswap-v3/token.js +0 -23
  277. package/build/dex/sushiswap-v3/token.js.map +0 -1
  278. package/build/dex/sushiswap-v3/types.d.ts +0 -15
  279. package/build/dex/sushiswap-v3/types.js +0 -18
  280. package/build/dex/sushiswap-v3/types.js.map +0 -1
  281. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.d.ts +0 -12
  282. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js +0 -23
  283. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js.map +0 -1
  284. package/build/dex/woo-fi/config.d.ts +0 -4
  285. package/build/dex/woo-fi/config.js +0 -141
  286. package/build/dex/woo-fi/config.js.map +0 -1
  287. package/build/dex/woo-fi/constants.d.ts +0 -5
  288. package/build/dex/woo-fi/constants.js +0 -20
  289. package/build/dex/woo-fi/constants.js.map +0 -1
  290. package/build/dex/woo-fi/types.d.ts +0 -48
  291. package/build/dex/woo-fi/types.js +0 -3
  292. package/build/dex/woo-fi/types.js.map +0 -1
  293. package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +0 -14
  294. package/build/dex/woo-fi/woo-fi-decimal-math.js +0 -42
  295. package/build/dex/woo-fi/woo-fi-decimal-math.js.map +0 -1
  296. package/build/dex/woo-fi/woo-fi-math.d.ts +0 -31
  297. package/build/dex/woo-fi/woo-fi-math.js +0 -300
  298. package/build/dex/woo-fi/woo-fi-math.js.map +0 -1
  299. package/build/dex/woo-fi/woo-fi.d.ts +0 -65
  300. package/build/dex/woo-fi/woo-fi.js +0 -480
  301. package/build/dex/woo-fi/woo-fi.js.map +0 -1
  302. package/build/executor/IExecutorBytecodeBuilder.d.ts +0 -6
  303. package/build/executor/IExecutorBytecodeBuilder.js +0 -3
  304. package/build/executor/IExecutorBytecodeBuilder.js.map +0 -1
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FRXETHPool = exports.address = void 0;
7
- const utils_1 = require("../../../utils");
8
- const StableSwapFRXETH_json_1 = __importDefault(require("../../../abi/curve-v1/StableSwapFRXETH.json"));
9
- const _3pool_1 = require("./3pool");
10
- const pool = 'frxETH';
11
- exports.address = '0xa1f8a6807c402e4a15ef4eba36528a3fed24e577'.toLowerCase();
12
- const tokenAddress = '0xf43211935c781d5ca1a41d2041f397b8a7366c7a';
13
- const N_COINS = 2;
14
- const PRECISION_MUL = ['1', '1'].map(utils_1.bigNumberify);
15
- const USE_LENDING = [false, false];
16
- const COINS = [
17
- '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
18
- '0x5e8422345238f34275888049021821e8e08caa1f',
19
- ];
20
- const trackCoins = true;
21
- class FRXETHPool extends _3pool_1.ThreePool {
22
- constructor(parentName, dexHelper) {
23
- super(parentName, dexHelper, pool, exports.address, tokenAddress, trackCoins, StableSwapFRXETH_json_1.default, N_COINS, PRECISION_MUL, USE_LENDING, COINS, 'FRXETHPool');
24
- }
25
- }
26
- exports.FRXETHPool = FRXETHPool;
27
- //# sourceMappingURL=frxETHpool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frxETHpool.js","sourceRoot":"","sources":["../../../../src/dex/curve-v1/pools/frxETHpool.ts"],"names":[],"mappings":";;;;;;AAEA,0CAA8C;AAC9C,wGAA2E;AAC3E,oCAAoC;AAEpC,MAAM,IAAI,GAAG,QAAQ,CAAC;AACT,QAAA,OAAO,GAClB,4CAA4C,CAAC,WAAW,EAAE,CAAC;AAC7D,MAAM,YAAY,GAAY,4CAA4C,CAAC;AAC3E,MAAM,OAAO,GAAW,CAAC,CAAC;AAC1B,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,oBAAY,CAAC,CAAC;AACnD,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACnC,MAAM,KAAK,GAAG;IACZ,4CAA4C;IAC5C,4CAA4C;CAC7C,CAAC;AACF,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,MAAa,UAAW,SAAQ,kBAAS;IACvC,YAAY,UAAkB,EAAE,SAAqB;QACnD,KAAK,CACH,UAAU,EACV,SAAS,EACT,IAAI,EACJ,eAAO,EACP,YAAY,EACZ,UAAU,EACV,+BAAgB,EAChB,OAAO,EACP,aAAa,EACb,WAAW,EACX,KAAK,EACL,YAAY,CACb,CAAC;IACJ,CAAC;CACF;AAjBD,gCAiBC"}
@@ -1,29 +0,0 @@
1
- import { Address, Log } from '../../../types';
2
- import { IDexHelper } from '../../../dex-helper';
3
- import BigNumber from 'bignumber.js';
4
- import { CurvePool, PoolState } from './curve-pool';
5
- import { DeepReadonly } from 'ts-essentials';
6
- export declare const address: Address;
7
- export declare class WBETHPool extends CurvePool {
8
- isAdminBalancesSupported: boolean;
9
- lastTransferredCoin?: Address;
10
- constructor(parentName: string, dexHelper: IDexHelper, _pool?: string, _address?: string, _tokenAddress?: string, _trackCoins?: boolean, _abi?: any, _N_COINS?: number, _PRECISION_MUL?: BigNumber[], _USE_LENDING?: boolean[], _COINS?: string[], prefix?: string);
11
- processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
12
- handleExchangeRateUpdated(event: any, state: PoolState): PoolState;
13
- handleCoinTransfer(event: any, state: PoolState, log: Log): PoolState;
14
- handleRemoveLiquidityOne(event: any, state: PoolState, log: Log): PoolState;
15
- handleNewFee(event: any, state: PoolState, log: Log): PoolState;
16
- handleRemoveLiquidity(event: any, state: PoolState, log: Log): PoolState;
17
- handleRemoveLiquidityImbalances(event: any, state: PoolState, log: Log): PoolState;
18
- handleAddLiquidity(event: any, state: PoolState, log: Log): PoolState;
19
- exchange(i: number, j: number, dx: BigNumber, state: PoolState): BigNumber;
20
- private _balances;
21
- get_dy(i: number, j: number, dx: BigNumber, state: Readonly<PoolState>): BigNumber;
22
- _get_dy(i: number, j: number, dx: BigNumber, A: BigNumber, fee: BigNumber, balances: BigNumber[], rates: BigNumber[], usefee?: boolean): BigNumber;
23
- protected _xp_mem(_rates: BigNumber[], _balances: BigNumber[]): BigNumber[];
24
- _get_y(i: number, j: number, x: BigNumber, xp: BigNumber[], A: BigNumber): BigNumber;
25
- remove_liquidity_one_coin(token_amount: BigNumber, token_supply: BigNumber, i: number, state: PoolState): BigNumber;
26
- private _calc_withdraw_one_coin;
27
- private get_y_D;
28
- _get_D(xp: BigNumber[], amp: BigNumber): BigNumber;
29
- }
@@ -1,408 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.WBETHPool = exports.address = void 0;
7
- const utils_1 = require("../../../utils");
8
- const StableSwapWBETH_json_1 = __importDefault(require("../../../abi/curve-v1/StableSwapWBETH.json"));
9
- const wBETH_json_1 = __importDefault(require("../../../abi/wBETH.json"));
10
- const bignumber_constants_1 = require("../../../bignumber-constants");
11
- const lodash_1 = __importDefault(require("lodash"));
12
- const curve_pool_1 = require("./curve-pool");
13
- const abi_1 = require("@ethersproject/abi");
14
- const wBETHInterface = new abi_1.Interface(wBETH_json_1.default);
15
- const pool = 'wbETH';
16
- exports.address = '0xbfab6fa95e0091ed66058ad493189d2cb29385e6'.toLowerCase();
17
- const tokenAddress = '0xbfab6fa95e0091ed66058ad493189d2cb29385e6';
18
- const N_COINS = 2;
19
- const PRECISION_MUL = ['1', '1'].map(utils_1.bigNumberify);
20
- const A_PRECISION = (0, utils_1.bigNumberify)(100);
21
- const USE_LENDING = [false, false];
22
- const ADMIN_FEE = (0, utils_1.bigNumberify)(5000000000);
23
- const COINS = [
24
- '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
25
- '0xa2e3356610840701bdf5611a53974510ae27e2e1',
26
- ];
27
- const trackCoins = true;
28
- class WBETHPool extends curve_pool_1.CurvePool {
29
- constructor(parentName, dexHelper, _pool = pool, _address = exports.address, _tokenAddress = tokenAddress, _trackCoins = trackCoins, _abi = StableSwapWBETH_json_1.default, _N_COINS = N_COINS, _PRECISION_MUL = PRECISION_MUL, _USE_LENDING = USE_LENDING, _COINS = COINS, prefix = 'WBETHPool') {
30
- super(parentName, dexHelper, dexHelper.getLogger(prefix), _pool, _address, _tokenAddress, _trackCoins, _abi, _N_COINS, _PRECISION_MUL, _USE_LENDING, _COINS);
31
- this.isAdminBalancesSupported = true;
32
- this.decoder = (log) => {
33
- if (this.trackCoins &&
34
- lodash_1.default.findIndex(this.COINS, c => c.toLowerCase() === log.address.toLowerCase()) != -1)
35
- return wBETHInterface.parseLog(log);
36
- return this.poolIface.parseLog(log);
37
- };
38
- // Add pool specific handlers or overloaded handlers
39
- this.handlers['RemoveLiquidityOne'] =
40
- this.handleRemoveLiquidityOne.bind(this);
41
- this.handlers['CommitNewFee'] = this.handleNewFee.bind(this);
42
- this.handlers['Transfer'] = this.handleCoinTransfer.bind(this);
43
- this.handlers['ExchangeRateUpdated'] = this.handleExchangeRateUpdated.bind(this);
44
- }
45
- processLog(state, log) {
46
- let _state = {
47
- A: (0, utils_1.bigNumberify)(state.A),
48
- fee: (0, utils_1.bigNumberify)(state.fee),
49
- admin_fee: (0, utils_1.bigNumberify)(state.admin_fee),
50
- supply: (0, utils_1.bigNumberify)(state.supply),
51
- balances: state.balances.map(utils_1.bigNumberify),
52
- eth_balance: (0, utils_1.bigNumberify)(state.eth_balance),
53
- token_balance: (0, utils_1.bigNumberify)(state.token_balance),
54
- stored_rates: state.stored_rates.map(utils_1.bigNumberify),
55
- admin_balances: state.admin_balances.map(utils_1.bigNumberify),
56
- };
57
- try {
58
- const event = this.decoder(log);
59
- if (event.name in this.handlers) {
60
- return this.handlers[event.name](event, _state, log);
61
- }
62
- return _state;
63
- }
64
- catch (e) {
65
- (0, utils_1.catchParseLogError)(e, this.logger);
66
- }
67
- return _state;
68
- }
69
- handleExchangeRateUpdated(event, state) {
70
- this.logger.info(`CurveV1: wbETH pool handle exchange rate updated state before: ${JSON.stringify(state)}`);
71
- this.logger.info(`CurveV1: wbETH pool handle exchange rate updated event args: ${JSON.stringify(event.args)}`);
72
- this.logger.info(`CurveV1: wbETH pool handle exchange rate updated newExchangeRate: ${event.args.newExchangeRate}`);
73
- this.logger.info(`CurveV1: wbETH pool handle exchange rate updated newExchangeRate big number: ${(0, utils_1.bigNumberify)((0, utils_1.stringify)(event.args.newExchangeRate))}`);
74
- const newExchangeRateUpdated = (0, utils_1.bigNumberify)((0, utils_1.stringify)(event.args.newExchangeRate));
75
- this.logger.info(`CurveV1: wbETH pool handle exchange rate updated: ${newExchangeRateUpdated}`);
76
- state.stored_rates[1] = newExchangeRateUpdated;
77
- this.logger.info(`CurveV1: wbETH pool handle exchange rate updated state after: ${JSON.stringify(state)}`);
78
- return state;
79
- }
80
- handleCoinTransfer(event, state, log) {
81
- this.logger.info(`CurveV1: wbETH pool handle coin transfer before lastTransferredCoin: ${this.lastTransferredCoin}`);
82
- const from = event.args.from;
83
- const coin = log.address;
84
- this.logger.info(`CurveV1: wbETH pool handle coin transfer coin: ${coin}`);
85
- if (from.toLowerCase() === this.address.toLowerCase())
86
- this.lastTransferredCoin = coin.toLowerCase();
87
- this.logger.info(`CurveV1: wbETH pool handle coin transfer after lastTransferredCoin: ${this.lastTransferredCoin}`);
88
- return state;
89
- }
90
- handleRemoveLiquidityOne(event, state, log) {
91
- this.logger.info(`CurveV1: wbETH pool handle remove liquidity one before state: ${JSON.stringify(state)}`);
92
- const _token_amount = (0, utils_1.bigNumberify)((0, utils_1.stringify)(event.args.token_amount));
93
- const token_supply = (0, utils_1.bigNumberify)((0, utils_1.stringify)(event.args.token_supply));
94
- const i = lodash_1.default.findIndex(this.COINS, c => c.toLowerCase() === this.lastTransferredCoin?.toLowerCase());
95
- if (i == -1) {
96
- this.logger.error(`Error: expected coin to have a transfer event before RemoveLiquidityOne event`);
97
- return state;
98
- }
99
- this.remove_liquidity_one_coin(_token_amount, token_supply, i, state);
100
- this.logger.info(`CurveV1: wbETH pool handle remove liquidity one after state: ${JSON.stringify(state)}`);
101
- return state;
102
- }
103
- handleNewFee(event, state, log) {
104
- this.logger.info(`CurveV1: wbETH pool handle new fee before state: ${JSON.stringify(state)}`);
105
- const fee = (0, utils_1.bigNumberify)((0, utils_1.stringify)(event.args.new_fee));
106
- state.fee = fee;
107
- this.logger.info(`CurveV1: wbETH pool handle new fee after state: ${JSON.stringify(state)}`);
108
- return state;
109
- }
110
- handleRemoveLiquidity(event, state, log) {
111
- this.logger.info(`CurveV1: wbETH pool handle remove liquidity before state: ${JSON.stringify(state)}`);
112
- const token_supply = (0, utils_1.bigNumberify)((0, utils_1.stringify)(event.args.token_supply));
113
- const amounts = event.args.token_amounts
114
- .map(utils_1.stringify)
115
- .map(utils_1.bigNumberify);
116
- for (let i = 0; i < this.N_COINS; i++) {
117
- if (i === 0) {
118
- state.eth_balance = state.eth_balance?.minus(amounts[i]);
119
- }
120
- else {
121
- state.token_balance = state.token_balance.minus(amounts[i]);
122
- }
123
- }
124
- state.supply = token_supply;
125
- this.logger.info(`CurveV1: wbETH pool handle remove liquidity after state: ${JSON.stringify(state)}`);
126
- return state;
127
- }
128
- handleRemoveLiquidityImbalances(event, state, log) {
129
- this.logger.info(`CurveV1: wbETH pool handle remove liquidity imbalances before state: ${JSON.stringify(state)}`);
130
- const amounts = event.args.token_amounts.map(utils_1.stringify).map(utils_1.bigNumberify);
131
- const { A, stored_rates: rates, fee, supply: total_supply } = state;
132
- const amp = A.times(A_PRECISION);
133
- const old_balances = this._balances(state);
134
- const D0 = this.get_D_mem(rates, old_balances, amp);
135
- let new_balances = lodash_1.default.clone(old_balances);
136
- for (let i = 0; i < this.N_COINS; i++) {
137
- new_balances[i] = new_balances[i].minus(amounts[i]);
138
- }
139
- const D1 = this.get_D_mem(rates, new_balances, amp);
140
- const fees = new Array(this.N_COINS);
141
- const base_fee = fee.times(this.N_COINS).idiv(4 * (this.N_COINS - 1));
142
- for (let i = 0; i < this.N_COINS; i++) {
143
- const ideal_balance = D1.times(old_balances[i]).idiv(D0);
144
- let difference = bignumber_constants_1.BN_0;
145
- const new_balance = new_balances[i];
146
- if (ideal_balance.gt(new_balance)) {
147
- difference = ideal_balance.minus(new_balances[i]);
148
- }
149
- else {
150
- difference = new_balances[i].minus(ideal_balance);
151
- }
152
- fees[i] = base_fee.times(difference).idiv(this.FEE_DENOMINATOR);
153
- state.admin_balances[i] = state.admin_balances[i].plus(fees[i].times(ADMIN_FEE).idiv(this.FEE_DENOMINATOR));
154
- new_balances[i] = new_balances[i].minus(fees[i]);
155
- }
156
- new_balances = this._xp_mem(rates, new_balances);
157
- const D2 = this.get_D(new_balances, amp);
158
- const burn_amount = D0.minus(D2).times(total_supply).idiv(D0).plus(1);
159
- state.supply = state.supply.minus(burn_amount);
160
- if (!amounts[0].eq(bignumber_constants_1.BN_0)) {
161
- state.eth_balance = state.eth_balance.minus(amounts[0]);
162
- }
163
- if (!amounts[1].eq(bignumber_constants_1.BN_0)) {
164
- state.token_balance = state.token_balance.minus(amounts[1]);
165
- }
166
- this.logger.info(`CurveV1: wbETH pool handle remove liquidity imbalances after state: ${JSON.stringify(state)}`);
167
- return state;
168
- }
169
- handleAddLiquidity(event, state, log) {
170
- this.logger.info(`CurveV1: wbETH pool handle add liquidity before state: ${JSON.stringify(state)}`);
171
- const amounts = event.args.token_amounts.map(utils_1.stringify).map(utils_1.bigNumberify);
172
- const fees = event.args.fees.map(utils_1.stringify).map(utils_1.bigNumberify);
173
- const total_supply = (0, utils_1.bigNumberify)((0, utils_1.stringify)(event.args.token_supply));
174
- for (let i = 0; i < this.N_COINS; i++) {
175
- state.admin_balances[i] = state.admin_balances[i].plus(fees[i].times(ADMIN_FEE).idiv(this.FEE_DENOMINATOR));
176
- }
177
- if (amounts[0].gt(0)) {
178
- state.eth_balance = state.eth_balance.plus(amounts[0]);
179
- }
180
- if (amounts[1].gt(0)) {
181
- state.token_balance = state.token_balance.plus(amounts[1]);
182
- }
183
- state.supply = total_supply;
184
- this.logger.info(`CurveV1: wbETH pool handle add liquidity after state: ${JSON.stringify(state)}`);
185
- return state;
186
- }
187
- exchange(i, j, dx, state) {
188
- this.logger.info(`CurveV1: wbETH pool exchange before state: ${JSON.stringify(state)}`);
189
- const rates = state.stored_rates;
190
- let msgValue;
191
- if (i === 0) {
192
- msgValue = (0, utils_1.bigNumberify)(dx);
193
- }
194
- else {
195
- msgValue = bignumber_constants_1.BN_0;
196
- }
197
- this.logger.info(`CurveV1: wbETH pool exchange msg value: ${msgValue}`);
198
- const old_balances = this._balances(state, msgValue);
199
- const xp = this._xp_mem(rates, old_balances);
200
- const x = xp[i].plus(dx.times(rates[i]).idiv(this.PRECISION));
201
- const y = this._get_y(i, j, x, xp, state.A);
202
- let dy = xp[j].minus(y).minus(1);
203
- const dy_fee = dy.times(state.fee).idiv(this.FEE_DENOMINATOR);
204
- dy = dy.minus(dy_fee).times(this.PRECISION).idiv(rates[j]);
205
- xp[i] = x;
206
- xp[j] = y;
207
- const dy_admin_fee = dy_fee.times(ADMIN_FEE).idiv(this.FEE_DENOMINATOR).times(this.PRECISION).idiv(rates[j]);
208
- if (!dy_admin_fee.eq(bignumber_constants_1.BN_0)) {
209
- state.admin_balances[j] = state.admin_balances[j].plus(dy_admin_fee);
210
- }
211
- if (i === 0) {
212
- state.eth_balance = state.eth_balance.plus(dx);
213
- state.token_balance = state.token_balance.minus(dy);
214
- }
215
- else {
216
- state.token_balance = state.token_balance.plus(dx);
217
- state.eth_balance = state.eth_balance?.minus(dy);
218
- }
219
- this.logger.info(`CurveV1: wbETH pool exchange after state: ${JSON.stringify(state)}`);
220
- return dy;
221
- }
222
- _balances(state, value = bignumber_constants_1.BN_0) {
223
- const { admin_balances, eth_balance, token_balance } = state;
224
- state.balances = [
225
- eth_balance.minus(admin_balances[0]).minus(value),
226
- token_balance.minus(admin_balances[1]),
227
- ];
228
- return state.balances;
229
- }
230
- get_dy(i, j, dx, state) {
231
- const { stored_rates: rates } = state;
232
- this.logger.info(`CurveV1: wbETH pool get_dy state: ${JSON.stringify(state)}`);
233
- return this._get_dy(i, j, dx, (0, utils_1.bigNumberify)(state.A), (0, utils_1.bigNumberify)(state.fee), this._balances(state), rates);
234
- }
235
- _get_dy(i, j, dx, A, fee, balances, rates, usefee = true) {
236
- const xp = this._xp_mem(rates, balances);
237
- const x = xp[i].plus(dx.times(rates[i]).idiv(this.PRECISION));
238
- const y = this._get_y(i, j, x, xp, A);
239
- const dy = xp[j].minus(y).minus(bignumber_constants_1.BN_1);
240
- const _fee = fee.times(dy).idiv(this.FEE_DENOMINATOR);
241
- return dy.minus(_fee).times(this.PRECISION).idiv(rates[j]);
242
- }
243
- _xp_mem(_rates, _balances) {
244
- const result = new Array(N_COINS).fill(0n);
245
- for (const i of lodash_1.default.range(Number(N_COINS))) {
246
- result[i] = _rates[i].times(_balances[i]).idiv(this.PRECISION);
247
- }
248
- return result;
249
- }
250
- _get_y(i, j, x, xp, A) {
251
- let S_ = bignumber_constants_1.BN_0;
252
- let _x = bignumber_constants_1.BN_0;
253
- const amp = A.times(A_PRECISION);
254
- const D = this._get_D(xp, amp);
255
- let c = (0, utils_1.bigNumberify)(D);
256
- let y_prev = bignumber_constants_1.BN_0;
257
- const Ann = amp.times(this.N_COINS);
258
- for (const _i of lodash_1.default.range(N_COINS)) {
259
- if (_i === i) {
260
- _x = (0, utils_1.bigNumberify)(x);
261
- }
262
- else if (_i !== j) {
263
- _x = (0, utils_1.bigNumberify)(xp[_i]);
264
- }
265
- else {
266
- continue;
267
- }
268
- S_ = S_.plus(_x);
269
- c = c.times(D).idiv(_x.times(this.N_COINS)); // c = c * D / (_x * N_COINS)
270
- }
271
- // c = c * D * A_PRECISION / (Ann * N_COINS)
272
- c = c.times(D).times(A_PRECISION).idiv(Ann.times(this.N_COINS));
273
- // b: uint256 = S_ + D * A_PRECISION / Ann # - D
274
- const b = S_.plus(D.times(A_PRECISION).idiv(Ann));
275
- let y = (0, utils_1.bigNumberify)(D);
276
- for (const _i of lodash_1.default.range(255)) {
277
- y_prev = (0, utils_1.bigNumberify)(y);
278
- y = y.times(y).plus(c).idiv(bignumber_constants_1.BN_2.times(y).plus(b).minus(D)); // y = (y*y + c) / (2 * y + b - D)
279
- // Equality with the precision of 1
280
- if (y > y_prev) {
281
- if (y.minus(y_prev).lte(1)) {
282
- return y;
283
- }
284
- }
285
- else {
286
- if (y_prev.minus(y).lte(1)) {
287
- return y;
288
- }
289
- }
290
- }
291
- throw Error('Error when calculate y');
292
- }
293
- remove_liquidity_one_coin(token_amount, token_supply, i, state) {
294
- let { dy, dy_fee } = this._calc_withdraw_one_coin(token_amount, i, state);
295
- state.admin_balances[i] = state.admin_balances[i].plus(dy_fee.times(ADMIN_FEE).idiv(this.FEE_DENOMINATOR));
296
- state.supply = token_supply;
297
- if (i === 0) {
298
- state.eth_balance = state.eth_balance.minus(dy);
299
- }
300
- else {
301
- state.token_balance = state.token_balance.minus(dy);
302
- }
303
- return dy;
304
- }
305
- _calc_withdraw_one_coin(_token_amount, i, state) {
306
- const { A, fee, supply, stored_rates: rates } = state;
307
- const amp = A.times(A_PRECISION);
308
- const xp = this._xp_mem(rates, this._balances(state));
309
- const D0 = this._get_D(xp, amp);
310
- const total_supply = (0, utils_1.bigNumberify)(supply);
311
- const D1 = D0.minus(_token_amount.idiv(total_supply));
312
- const new_y = this.get_y_D(amp, i, xp, D1);
313
- const base_fee = fee.times(this.N_COINS).idiv(4 * (this.N_COINS - 1));
314
- let xp_reduced = new Array(N_COINS).fill(0n);
315
- for (const j of lodash_1.default.range(N_COINS)) {
316
- let dx_expected = bignumber_constants_1.BN_0;
317
- const xp_j = (0, utils_1.bigNumberify)(xp[j]);
318
- if (j === i) {
319
- dx_expected = xp_j.times(D1).idiv(D0).minus(new_y);
320
- }
321
- else {
322
- dx_expected = xp_j.minus(xp_j.times(D1).idiv(D0));
323
- }
324
- xp_reduced[j] = xp_j.minus(base_fee.times(dx_expected).idiv(this.FEE_DENOMINATOR));
325
- }
326
- let dy = xp_reduced[i].minus(this.get_y_D(amp, i, xp_reduced, D1));
327
- const dy_0 = xp[i].minus(new_y).times(this.PRECISION).idiv(rates[i]);
328
- dy = dy.minus(1).times(this.PRECISION).idiv(rates[i]);
329
- return { dy, dy_fee: dy_0.minus(dy) };
330
- }
331
- get_y_D(A_, i, xp, D) {
332
- let c = D;
333
- let S_ = bignumber_constants_1.BN_0;
334
- const Ann = A_.times(this.N_COINS);
335
- let _x = bignumber_constants_1.BN_0;
336
- for (let _i = 0; _i < this.N_COINS; _i++) {
337
- if (_i !== i) {
338
- _x = xp[_i];
339
- }
340
- else {
341
- continue;
342
- }
343
- S_ = S_.plus(_x);
344
- c = c.times(D).idiv(_x.times(this.N_COINS));
345
- }
346
- c = c.times(D).idiv(Ann.times(this.N_COINS));
347
- const b = S_.plus(D.idiv(Ann));
348
- let y_prev = bignumber_constants_1.BN_0;
349
- let y = D;
350
- for (let _i = 0; _i < 255; _i++) {
351
- y_prev = y;
352
- y = y.times(y).plus(c).idiv(y.times(2).plus(b).minus(D));
353
- // Equality with the precision of 1
354
- if (y.gt(y_prev)) {
355
- if (y.minus(y_prev).lte(1)) {
356
- break;
357
- }
358
- }
359
- else {
360
- if (y_prev.minus(y).lte(1)) {
361
- break;
362
- }
363
- }
364
- }
365
- return y;
366
- }
367
- _get_D(xp, amp) {
368
- let S = bignumber_constants_1.BN_0;
369
- for (const _x of xp) {
370
- S = S.plus(_x);
371
- }
372
- if (S.eq(bignumber_constants_1.BN_0)) {
373
- return bignumber_constants_1.BN_0;
374
- }
375
- let D = (0, utils_1.bigNumberify)(S);
376
- const Ann = amp.times(this.N_COINS);
377
- for (const _i of lodash_1.default.range(255)) {
378
- let D_P = D.times(D)
379
- .idiv(xp[0])
380
- .times(D)
381
- .idiv(xp[1])
382
- .idiv(this.N_COINS ** 2); // D_P: uint256 = D * D / _xp[0] * D / _xp[1] / (N_COINS)**2
383
- let Dprev = (0, utils_1.bigNumberify)(D);
384
- const dividend = Ann.times(S)
385
- .idiv(A_PRECISION)
386
- .plus(D_P.times(this.N_COINS))
387
- .times(D);
388
- const divisor = Ann.minus(A_PRECISION)
389
- .times(D)
390
- .idiv(A_PRECISION)
391
- .plus(D_P.times(this.N_COINS + 1));
392
- D = dividend.idiv(divisor); // D = (Ann * S / A_PRECISION + D_P * N_COINS) * D / ((Ann - A_PRECISION) * D / A_PRECISION + (N_COINS + 1) * D_P)
393
- if (D.gt(Dprev)) {
394
- if (D.minus(Dprev).lte(1)) {
395
- return D;
396
- }
397
- }
398
- else {
399
- if (Dprev.minus(D).lte(1)) {
400
- return D;
401
- }
402
- }
403
- }
404
- throw Error('Error when calcucate D');
405
- }
406
- }
407
- exports.WBETHPool = WBETHPool;
408
- //# sourceMappingURL=wbETHpool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wbETHpool.js","sourceRoot":"","sources":["../../../../src/dex/curve-v1/pools/wbETHpool.ts"],"names":[],"mappings":";;;;;;AAEA,0CAA6E;AAC7E,sGAAyE;AACzE,yEAA+C;AAE/C,sEAAgE;AAChE,oDAAuB;AACvB,6CAAoD;AAEpD,4CAA+C;AAE/C,MAAM,cAAc,GAAG,IAAI,eAAS,CAAC,oBAAQ,CAAC,CAAC;AAE/C,MAAM,IAAI,GAAG,OAAO,CAAC;AACR,QAAA,OAAO,GAClB,4CAA4C,CAAC,WAAW,EAAE,CAAC;AAC7D,MAAM,YAAY,GAAY,4CAA4C,CAAC;AAC3E,MAAM,OAAO,GAAW,CAAC,CAAC;AAC1B,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,oBAAY,CAAC,CAAC;AACnD,MAAM,WAAW,GAAG,IAAA,oBAAY,EAAC,GAAG,CAAC,CAAC;AACtC,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACnC,MAAM,SAAS,GAAG,IAAA,oBAAY,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,KAAK,GAAG;IACZ,4CAA4C;IAC5C,4CAA4C;CAC7C,CAAC;AACF,MAAM,UAAU,GAAG,IAAI,CAAC;AAGxB,MAAa,SAAU,SAAQ,sBAAS;IAKtC,YACE,UAAkB,EAClB,SAAqB,EACrB,KAAK,GAAG,IAAI,EACZ,QAAQ,GAAG,eAAO,EAClB,aAAa,GAAG,YAAY,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,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;iBACX,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,4DAA4D;YAExF,IAAI,KAAK,GAAG,IAAA,oBAAY,EAAC,CAAC,CAAC,CAAC;YAE5B,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;iBAC1B,IAAI,CAAC,WAAW,CAAC;iBACjB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBAC7B,KAAK,CAAC,CAAC,CAAC,CAAC;YACZ,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC;iBACnC,KAAK,CAAC,CAAC,CAAC;iBACR,IAAI,CAAC,WAAW,CAAC;iBACjB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;YACrC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,kHAAkH;YAE9I,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE;gBACf,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;oBACzB,OAAO,CAAC,CAAC;iBACV;aACF;iBAAM;gBACL,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;oBACzB,OAAO,CAAC,CAAC;iBACV;aACF;SACF;QAED,MAAM,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACxC,CAAC;CACF;AA1iBD,8BA0iBC"}
@@ -1,4 +0,0 @@
1
- import { DexParams } from './types';
2
- import { DexConfigMap, AdapterMappings } from '../../types';
3
- export declare const IntegralConfig: DexConfigMap<DexParams>;
4
- export declare const Adapters: Record<number, AdapterMappings>;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Adapters = exports.IntegralConfig = void 0;
4
- const constants_1 = require("../../constants");
5
- exports.IntegralConfig = {
6
- Integral: {
7
- [constants_1.Network.MAINNET]: {
8
- relayerAddress: '0xd17b3c9784510E33cD5B87b490E79253BcD81e2E',
9
- subgraphURL: 'https://api.thegraph.com/subgraphs/name/integralhq/integral-size',
10
- },
11
- [constants_1.Network.ARBITRUM]: {
12
- relayerAddress: '0x3c6951FDB433b5b8442e7aa126D50fBFB54b5f42',
13
- subgraphURL: 'https://api.thegraph.com/subgraphs/name/integralhq/integral-size-arbitrum',
14
- },
15
- },
16
- };
17
- exports.Adapters = {};
18
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/integral/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE7B,QAAA,cAAc,GAA4B;IACrD,QAAQ,EAAE;QACR,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,cAAc,EAAE,4CAA4C;YAC5D,WAAW,EACT,kEAAkE;SACrE;QACD,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE;YAClB,cAAc,EAAE,4CAA4C;YAC5D,WAAW,EACT,2EAA2E;SAC9E;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC,EAAE,CAAC"}
@@ -1,39 +0,0 @@
1
- import { Interface } from '@ethersproject/abi';
2
- import { DeepReadonly } from 'ts-essentials';
3
- import { Log, Logger } from '../../types';
4
- import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
5
- import { IDexHelper } from '../../dex-helper/idex-helper';
6
- import { IntegralPoolState } from './types';
7
- import { Address } from '../../types';
8
- export declare class IntegralEventPool extends StatefulEventSubscriber<IntegralPoolState> {
9
- parentName: string;
10
- protected network: number;
11
- protected dexHelper: IDexHelper;
12
- protected integralIface: Interface;
13
- handlers: {
14
- [event: string]: (event: any, pool: DeepReadonly<IntegralPoolState>, log: Log) => IntegralPoolState;
15
- };
16
- logDecoder: (log: Log) => any;
17
- addressesSubscribed: string[];
18
- constructor(parentName: string, network: number, dexHelper: IDexHelper, token0: Address, token1: Address, logger: Logger, integralIface?: Interface);
19
- /**
20
- * The function is called every time any of the subscribed
21
- * addresses release log. The function accepts the current
22
- * state, updates the state according to the log, and returns
23
- * the updated state.
24
- * @param state - Current state of event subscriber
25
- * @param log - Log released by one of the subscribed addresses
26
- * @returns Updates state of the event subscriber after the log
27
- */
28
- protected processLog(state: DeepReadonly<IntegralPoolState>, log: Readonly<Log>): DeepReadonly<IntegralPoolState> | null;
29
- /**
30
- * The function generates state using on-chain calls. This
31
- * function is called to regenerate state if the event based
32
- * system fails to fetch events and the local state is no
33
- * more correct.
34
- * @param blockNumber - Blocknumber for which the state should
35
- * should be generated
36
- * @returns state of the event subscriber at blocknumber
37
- */
38
- generateState(blockNumber: number): Promise<Readonly<IntegralPoolState>>;
39
- }
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IntegralEventPool = void 0;
7
- const abi_1 = require("@ethersproject/abi");
8
- const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
9
- const relayer_json_1 = __importDefault(require("../../abi/integral/relayer.json"));
10
- class IntegralEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
11
- constructor(parentName, network, dexHelper, token0, token1, logger, integralIface = new abi_1.Interface(relayer_json_1.default)) {
12
- super(parentName, `${token0}_${token1}`, dexHelper, logger);
13
- this.parentName = parentName;
14
- this.network = network;
15
- this.dexHelper = dexHelper;
16
- this.integralIface = integralIface;
17
- this.handlers = {};
18
- // TODO: make logDecoder decode logs that
19
- this.logDecoder = (log) => this.integralIface.parseLog(log);
20
- this.addressesSubscribed = [
21
- /* subscribed addresses */
22
- ];
23
- }
24
- /**
25
- * The function is called every time any of the subscribed
26
- * addresses release log. The function accepts the current
27
- * state, updates the state according to the log, and returns
28
- * the updated state.
29
- * @param state - Current state of event subscriber
30
- * @param log - Log released by one of the subscribed addresses
31
- * @returns Updates state of the event subscriber after the log
32
- */
33
- processLog(state, log) {
34
- try {
35
- const event = this.logDecoder(log);
36
- if (event.name in this.handlers) {
37
- return this.handlers[event.name](event, state, log);
38
- }
39
- return state;
40
- }
41
- catch (e) {
42
- this.logger.error(`Error_${this.parentName}_processLog could not parse the log with topic ${log.topics}:`, e);
43
- return null;
44
- }
45
- }
46
- /**
47
- * The function generates state using on-chain calls. This
48
- * function is called to regenerate state if the event based
49
- * system fails to fetch events and the local state is no
50
- * more correct.
51
- * @param blockNumber - Blocknumber for which the state should
52
- * should be generated
53
- * @returns state of the event subscriber at blocknumber
54
- */
55
- async generateState(blockNumber) {
56
- // TODO: complete me!
57
- return {
58
- price: 0n,
59
- invertedPrice: 0n,
60
- fee: 0n,
61
- limits0: [0n, 0n],
62
- limits1: [0n, 0n],
63
- };
64
- }
65
- }
66
- exports.IntegralEventPool = IntegralEventPool;
67
- //# sourceMappingURL=integral-pool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"integral-pool.js","sourceRoot":"","sources":["../../../src/dex/integral/integral-pool.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAG/C,+EAA0E;AAG1E,mFAAiE;AAGjE,MAAa,iBAAkB,SAAQ,mDAA0C;IAa/E,YACS,UAAkB,EACf,OAAe,EACf,SAAqB,EAC/B,MAAe,EACf,MAAe,EACf,MAAc,EACJ,gBAAgB,IAAI,eAAS,CAAC,sBAAkB,CAAC;QAE3D,KAAK,CAAC,UAAU,EAAE,GAAG,MAAM,IAAI,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QARrD,eAAU,GAAV,UAAU,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAY;QAIrB,kBAAa,GAAb,aAAa,CA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