@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,444 +0,0 @@
1
- 'use strict';
2
- var __createBinding =
3
- (this && this.__createBinding) ||
4
- (Object.create
5
- ? function (o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (
9
- !desc ||
10
- ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)
11
- ) {
12
- desc = {
13
- enumerable: true,
14
- get: function () {
15
- return m[k];
16
- },
17
- };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }
21
- : function (o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- o[k2] = m[k];
24
- });
25
- var __setModuleDefault =
26
- (this && this.__setModuleDefault) ||
27
- (Object.create
28
- ? function (o, v) {
29
- Object.defineProperty(o, 'default', { enumerable: true, value: v });
30
- }
31
- : function (o, v) {
32
- o['default'] = v;
33
- });
34
- var __importStar =
35
- (this && this.__importStar) ||
36
- function (mod) {
37
- if (mod && mod.__esModule) return mod;
38
- var result = {};
39
- if (mod != null)
40
- for (var k in mod)
41
- if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k))
42
- __createBinding(result, mod, k);
43
- __setModuleDefault(result, mod);
44
- return result;
45
- };
46
- var __importDefault =
47
- (this && this.__importDefault) ||
48
- function (mod) {
49
- return mod && mod.__esModule ? mod : { default: mod };
50
- };
51
- Object.defineProperty(exports, '__esModule', { value: true });
52
- exports.LinearPool = exports.PairTypes = void 0;
53
- const abi_1 = require('@ethersproject/abi');
54
- const bignumber_1 = require('@ethersproject/bignumber');
55
- const utils_1 = require('./utils');
56
- const LinearMath = __importStar(require('./LinearMath'));
57
- const balancer_v2_pool_1 = require('./balancer-v2-pool');
58
- const linearPoolAbi_json_1 = __importDefault(
59
- require('../../abi/balancer-v2/linearPoolAbi.json'),
60
- );
61
- const lodash_1 = require('lodash');
62
- var PairTypes;
63
- (function (PairTypes) {
64
- PairTypes[(PairTypes['BptToMainToken'] = 0)] = 'BptToMainToken';
65
- PairTypes[(PairTypes['MainTokenToBpt'] = 1)] = 'MainTokenToBpt';
66
- PairTypes[(PairTypes['MainTokenToWrappedToken'] = 2)] =
67
- 'MainTokenToWrappedToken';
68
- PairTypes[(PairTypes['WrappedTokenToMainToken'] = 3)] =
69
- 'WrappedTokenToMainToken';
70
- PairTypes[(PairTypes['BptToWrappedToken'] = 4)] = 'BptToWrappedToken';
71
- PairTypes[(PairTypes['WrappedTokenToBpt'] = 5)] = 'WrappedTokenToBpt';
72
- })((PairTypes = exports.PairTypes || (exports.PairTypes = {})));
73
- /*
74
- Linear (Boosted) Pools are designed to facilitate trades between stablecoins while simultaneously forwarding much of the pool's
75
- liquidity to external protocols, such as Aave.
76
- One of the key features that makes trades through Boosted Pools so simple is the use of Phantom BPT. Normally when a Liquidity
77
- Provider joins/exits a pool, the pool mints/burns pool tokens as needed. This is gas intensive and requires users to execute a join or exit.
78
- In pools that use Phantom BPT, however, all pool tokens are minted at the time of pool creation and are held by the pool itself.
79
- With Phantom BPT, Liquidity Providers use a swap (or more likely a batchSwap) to trade to or from a pool token to join or exit, respectively.
80
- */
81
- class LinearPool extends balancer_v2_pool_1.BasePool {
82
- constructor(vaultAddress, vaultInterface) {
83
- super();
84
- // This is the maximum token amount the Vault can hold. In regular operation, the total BPT supply remains constant
85
- // and equal to _INITIAL_BPT_SUPPLY, but most of it remains in the Pool, waiting to be exchanged for tokens. The
86
- // actual amount of BPT in circulation is the total supply minus the amount held by the Pool, and is known as the
87
- // 'virtual supply'.
88
- this.MAX_TOKEN_BALANCE = bignumber_1.BigNumber.from('2')
89
- .pow('112')
90
- .sub('1');
91
- this.vaultAddress = vaultAddress;
92
- this.vaultInterface = vaultInterface;
93
- this.poolInterface = new abi_1.Interface(linearPoolAbi_json_1.default);
94
- }
95
- /*
96
- scaling factors should include rate:
97
- The wrapped token's scaling factor is not constant, but increases over time as the wrapped token increases in value.
98
- i.e.
99
- scalingFactors: pool.tokens.map(({ decimals, priceRate }) =>
100
- MathSol.mulDownFixed(getTokenScalingFactor(decimals), priceRate)
101
- )
102
- */
103
- onSell(amounts, poolPairData) {
104
- return this._swapGivenIn(
105
- amounts,
106
- poolPairData.tokens,
107
- poolPairData.balances,
108
- poolPairData.indexIn,
109
- poolPairData.indexOut,
110
- poolPairData.bptIndex,
111
- poolPairData.wrappedIndex,
112
- poolPairData.mainIndex,
113
- poolPairData.scalingFactors,
114
- poolPairData.swapFee,
115
- poolPairData.lowerTarget,
116
- poolPairData.upperTarget,
117
- );
118
- }
119
- _swapGivenIn(
120
- tokenAmountsIn,
121
- tokens,
122
- balances,
123
- indexIn,
124
- indexOut,
125
- bptIndex,
126
- wrappedIndex,
127
- mainIndex,
128
- scalingFactors,
129
- swapFeePercentage,
130
- lowerTarget,
131
- upperTarget,
132
- ) {
133
- /*
134
- Linear pools allow trading between:
135
- wrappedToken <> mainToken
136
- wrappedToken <> BPT
137
- mainToken <> BPT
138
- */
139
- let pairType;
140
- if ((0, utils_1.isSameAddress)(tokens[indexIn], tokens[bptIndex])) {
141
- if ((0, utils_1.isSameAddress)(tokens[indexOut], tokens[wrappedIndex]))
142
- pairType = PairTypes.BptToWrappedToken;
143
- else pairType = PairTypes.BptToMainToken;
144
- } else if ((0, utils_1.isSameAddress)(tokens[indexOut], tokens[bptIndex])) {
145
- if ((0, utils_1.isSameAddress)(tokens[indexIn], tokens[wrappedIndex]))
146
- pairType = PairTypes.WrappedTokenToBpt;
147
- else pairType = PairTypes.MainTokenToBpt;
148
- } else {
149
- if ((0, utils_1.isSameAddress)(tokens[indexIn], tokens[wrappedIndex]))
150
- pairType = PairTypes.WrappedTokenToMainToken;
151
- else pairType = PairTypes.MainTokenToWrappedToken;
152
- }
153
- const balancesUpscaled = this._upscaleArray(balances, scalingFactors);
154
- const tokenAmountsInScaled = tokenAmountsIn.map(a =>
155
- this._upscale(a, scalingFactors[indexIn]),
156
- );
157
- // VirtualBPTSupply must be used for the maths
158
- const virtualBptSupply = this.MAX_TOKEN_BALANCE.sub(
159
- balances[bptIndex],
160
- ).toBigInt();
161
- const amountsOut = this._onSwapGivenIn(
162
- tokenAmountsInScaled,
163
- balancesUpscaled[mainIndex],
164
- balancesUpscaled[wrappedIndex],
165
- swapFeePercentage,
166
- lowerTarget,
167
- upperTarget,
168
- virtualBptSupply,
169
- pairType,
170
- );
171
- // amountOut tokens are exiting the Pool, so we round down.
172
- return amountsOut.map(a =>
173
- this._downscaleDown(a, scalingFactors[indexOut]),
174
- );
175
- }
176
- /*
177
- Called when a swap with the Pool occurs, where the amount of tokens entering the Pool is known.
178
- All amounts are upscaled.
179
- Swap fee is NOT already deducted.
180
- The return value is also considered upscaled, and should be downscaled (rounding down)
181
- */
182
- _onSwapGivenIn(
183
- tokenAmountsIn,
184
- mainBalance,
185
- wrappedBalance,
186
- fee,
187
- lowerTarget,
188
- upperTarget,
189
- virtualBptSupply,
190
- pairType,
191
- ) {
192
- const amountsOut = [];
193
- switch (pairType) {
194
- case PairTypes.BptToMainToken:
195
- tokenAmountsIn.forEach(amountIn => {
196
- let amt;
197
- try {
198
- amt = LinearMath._calcMainOutPerBptIn(
199
- amountIn,
200
- mainBalance,
201
- wrappedBalance,
202
- virtualBptSupply,
203
- {
204
- fee: fee,
205
- lowerTarget: lowerTarget,
206
- upperTarget: upperTarget,
207
- },
208
- );
209
- } catch (err) {
210
- amt = 0n;
211
- }
212
- amountsOut.push(amt);
213
- });
214
- break;
215
- case PairTypes.MainTokenToBpt:
216
- tokenAmountsIn.forEach(amountIn => {
217
- let amt;
218
- try {
219
- amt = LinearMath._calcBptOutPerMainIn(
220
- amountIn,
221
- mainBalance,
222
- wrappedBalance,
223
- virtualBptSupply,
224
- {
225
- fee: fee,
226
- lowerTarget: lowerTarget,
227
- upperTarget: upperTarget,
228
- },
229
- );
230
- } catch (err) {
231
- amt = 0n;
232
- }
233
- amountsOut.push(amt);
234
- });
235
- break;
236
- case PairTypes.MainTokenToWrappedToken:
237
- tokenAmountsIn.forEach(amountIn => {
238
- let amt;
239
- try {
240
- amt = LinearMath._calcWrappedOutPerMainIn(amountIn, mainBalance, {
241
- fee: fee,
242
- lowerTarget: lowerTarget,
243
- upperTarget: upperTarget,
244
- });
245
- } catch (err) {
246
- amt = 0n;
247
- }
248
- amountsOut.push(amt);
249
- });
250
- break;
251
- case PairTypes.WrappedTokenToMainToken:
252
- tokenAmountsIn.forEach(amountIn => {
253
- let amt;
254
- try {
255
- amt = LinearMath._calcMainOutPerWrappedIn(amountIn, mainBalance, {
256
- fee: fee,
257
- lowerTarget: lowerTarget,
258
- upperTarget: upperTarget,
259
- });
260
- } catch (err) {
261
- amt = 0n;
262
- }
263
- amountsOut.push(amt);
264
- });
265
- break;
266
- case PairTypes.BptToWrappedToken:
267
- tokenAmountsIn.forEach(amountIn => {
268
- let amt;
269
- try {
270
- amt = LinearMath._calcWrappedOutPerBptIn(
271
- amountIn,
272
- mainBalance,
273
- wrappedBalance,
274
- virtualBptSupply,
275
- {
276
- fee: fee,
277
- lowerTarget: lowerTarget,
278
- upperTarget: upperTarget,
279
- },
280
- );
281
- } catch (err) {
282
- amt = 0n;
283
- }
284
- amountsOut.push(amt);
285
- });
286
- break;
287
- case PairTypes.WrappedTokenToBpt:
288
- tokenAmountsIn.forEach(amountIn => {
289
- let amt;
290
- try {
291
- amt = LinearMath._calcBptOutPerWrappedIn(
292
- amountIn,
293
- mainBalance,
294
- wrappedBalance,
295
- virtualBptSupply,
296
- {
297
- fee: fee,
298
- lowerTarget: lowerTarget,
299
- upperTarget: upperTarget,
300
- },
301
- );
302
- } catch (err) {
303
- amt = 0n;
304
- }
305
- amountsOut.push(amt);
306
- });
307
- break;
308
- default:
309
- amountsOut.push(0n);
310
- }
311
- return amountsOut;
312
- }
313
- /*
314
- Helper function to parse pool data into params for onSell function.
315
- */
316
- parsePoolPairData(pool, poolState, tokenIn, tokenOut) {
317
- let indexIn = 0,
318
- indexOut = 0,
319
- bptIndex = 0;
320
- const balances = [];
321
- const scalingFactors = [];
322
- const tokens = poolState.orderedTokens.map((tokenAddress, i) => {
323
- const t = pool.tokensMap[tokenAddress.toLowerCase()];
324
- if (t.address.toLowerCase() === tokenIn.toLowerCase()) indexIn = i;
325
- if (t.address.toLowerCase() === tokenOut.toLowerCase()) indexOut = i;
326
- if (t.address.toLowerCase() === pool.address.toLowerCase()) bptIndex = i;
327
- balances.push(poolState.tokens[t.address.toLowerCase()].balance);
328
- scalingFactors.push(
329
- poolState.tokens[t.address.toLowerCase()].scalingFactor || 0n,
330
- );
331
- return t.address;
332
- });
333
- const poolPairData = {
334
- tokens,
335
- balances,
336
- indexIn,
337
- indexOut,
338
- scalingFactors,
339
- bptIndex,
340
- swapFee: poolState.swapFee,
341
- amp: poolState.amp || 0n,
342
- wrappedIndex: poolState.wrappedIndex || 0,
343
- mainIndex: poolState.mainIndex || 0,
344
- lowerTarget: poolState.lowerTarget || 0n,
345
- upperTarget: poolState.upperTarget || 0n,
346
- };
347
- return poolPairData;
348
- }
349
- /*
350
- Helper function to construct onchain multicall data for Linear Pool.
351
- */
352
- getOnChainCalls(pool) {
353
- const poolCallData = [
354
- {
355
- target: this.vaultAddress,
356
- callData: this.vaultInterface.encodeFunctionData('getPoolTokens', [
357
- pool.id,
358
- ]),
359
- },
360
- {
361
- target: pool.address,
362
- callData: this.poolInterface.encodeFunctionData('getSwapFeePercentage'),
363
- },
364
- ];
365
- poolCallData.push({
366
- target: pool.address,
367
- callData: this.poolInterface.encodeFunctionData('getScalingFactors'),
368
- });
369
- // returns lowerTarget, upperTarget
370
- poolCallData.push({
371
- target: pool.address,
372
- callData: this.poolInterface.encodeFunctionData('getTargets'),
373
- });
374
- return poolCallData;
375
- }
376
- /*
377
- Helper function to decodes multicall data for a Linear Pool.
378
- data must contain returnData
379
- startIndex is where to start in returnData. Allows this decode function to be called along with other pool types.
380
- */
381
- decodeOnChainCalls(pool, data, startIndex) {
382
- const pools = {};
383
- const poolTokens = (0, utils_1.decodeThrowError)(
384
- this.vaultInterface,
385
- 'getPoolTokens',
386
- data[startIndex++],
387
- pool.address,
388
- );
389
- const swapFee = (0, utils_1.decodeThrowError)(
390
- this.poolInterface,
391
- 'getSwapFeePercentage',
392
- data[startIndex++],
393
- pool.address,
394
- )[0];
395
- const scalingFactors = (0, utils_1.decodeThrowError)(
396
- this.poolInterface,
397
- 'getScalingFactors',
398
- data[startIndex++],
399
- pool.address,
400
- )[0];
401
- const [lowerTarget, upperTarget] = (0, utils_1.decodeThrowError)(
402
- this.poolInterface,
403
- 'getTargets',
404
- data[startIndex++],
405
- pool.address,
406
- );
407
- const bptIndex = pool.tokens.findIndex(
408
- t => t.address.toLowerCase() === pool.address.toLowerCase(),
409
- );
410
- const tokens = poolTokens.tokens.map((address, idx) => ({
411
- address: address.toLowerCase(),
412
- balance: BigInt(poolTokens.balances[idx].toString()),
413
- scalingFactor: BigInt(scalingFactors[idx].toString()),
414
- }));
415
- const poolState = {
416
- swapFee: BigInt(swapFee.toString()),
417
- mainIndex: Number(pool.mainIndex),
418
- wrappedIndex: Number(pool.wrappedIndex),
419
- bptIndex,
420
- lowerTarget: BigInt(lowerTarget.toString()),
421
- upperTarget: BigInt(upperTarget.toString()),
422
- tokens: (0, lodash_1.keyBy)(tokens, 'address'),
423
- orderedTokens: poolTokens.tokens,
424
- };
425
- pools[pool.address] = poolState;
426
- return [pools, startIndex];
427
- }
428
- /*
429
- Swapping to BPT allows for a very large amount as pre-minted.
430
- Swapping to main token - you can use 99% of the balance of the main token (Dani)
431
- */
432
- getSwapMaxAmount(poolPairData, side) {
433
- return (
434
- (this._upscale(
435
- poolPairData.balances[poolPairData.indexOut],
436
- poolPairData.scalingFactors[poolPairData.indexOut],
437
- ) *
438
- 99n) /
439
- 100n
440
- );
441
- }
442
- }
443
- exports.LinearPool = LinearPool;
444
- //# sourceMappingURL=LinearPool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LinearPool.js","sourceRoot":"","sources":["../../../src/dex/balancer-v2/LinearPool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA+C;AAC/C,wDAAqD;AACrD,mCAA0D;AAC1D,yDAA2C;AAC3C,yDAA8C;AAE9C,kGAAqE;AAErE,mCAA+B;AAE/B,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,6DAAc,CAAA;IACd,6DAAc,CAAA;IACd,+EAAuB,CAAA;IACvB,+EAAuB,CAAA;IACvB,mEAAiB,CAAA;IACjB,mEAAiB,CAAA;AACnB,CAAC,EAPW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAOpB;AAiBD;;;;;;;EAOE;AACF,MAAa,UAAW,SAAQ,2BAAQ;IAUtC,YAAY,YAAoB,EAAE,cA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Interface } from '@ethersproject/abi';
2
- import { BigNumber } from '@ethersproject/bignumber';
3
- import { BasePool } from './balancer-v2-pool';
4
- import { SubgraphPoolBase, PoolState, callData } from './types';
5
- import { SwapSide } from '../../constants';
6
- declare enum PairTypes {
7
- BptToToken = 0,
8
- TokenToBpt = 1,
9
- TokenToToken = 2,
10
- }
11
- declare type PhantomStablePoolPairData = {
12
- tokens: string[];
13
- balances: bigint[];
14
- indexIn: number;
15
- indexOut: number;
16
- scalingFactors: bigint[];
17
- bptIndex: number;
18
- swapFee: bigint;
19
- amp: bigint;
20
- actualSupply: bigint | undefined;
21
- };
22
- export declare class PhantomStablePool extends BasePool {
23
- private isComposable;
24
- MAX_TOKEN_BALANCE: BigNumber;
25
- vaultAddress: string;
26
- vaultInterface: Interface;
27
- poolInterface: Interface;
28
- constructor(
29
- vaultAddress: string,
30
- vaultInterface: Interface,
31
- isComposable?: boolean,
32
- );
33
- onSell(amounts: bigint[], poolPairData: PhantomStablePoolPairData): bigint[];
34
- removeBPT(
35
- balances: bigint[],
36
- tokenIndexIn: number,
37
- tokenIndexOut: number,
38
- bptIndex: number,
39
- ): {
40
- balances: bigint[];
41
- indexIn: number;
42
- indexOut: number;
43
- };
44
- _swapGivenIn(
45
- tokenAmountsIn: bigint[],
46
- tokens: string[],
47
- balances: bigint[],
48
- indexIn: number,
49
- indexOut: number,
50
- bptIndex: number,
51
- scalingFactors: bigint[],
52
- swapFeePercentage: bigint,
53
- amplificationParameter: bigint,
54
- actualSupply: bigint | undefined,
55
- ): bigint[];
56
- _onSwapGivenIn(
57
- tokenAmountsIn: bigint[],
58
- balances: bigint[],
59
- indexIn: number,
60
- indexOut: number,
61
- _amplificationParameter: bigint,
62
- virtualBptSupply: bigint,
63
- pairType: PairTypes,
64
- ): bigint[];
65
- parsePoolPairData(
66
- pool: SubgraphPoolBase,
67
- poolState: PoolState,
68
- tokenIn: string,
69
- tokenOut: string,
70
- ): PhantomStablePoolPairData;
71
- getOnChainCalls(pool: SubgraphPoolBase): callData[];
72
- decodeOnChainCalls(
73
- pool: SubgraphPoolBase,
74
- data: {
75
- success: boolean;
76
- returnData: any;
77
- }[],
78
- startIndex: number,
79
- ): [
80
- {
81
- [address: string]: PoolState;
82
- },
83
- number,
84
- ];
85
- getSwapMaxAmount(
86
- poolPairData: PhantomStablePoolPairData,
87
- side: SwapSide,
88
- ): bigint;
89
- }
90
- export {};