@paraswap/dex-lib 4.1.17-arena → 4.1.17

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/.idea/codeStyles/Project.xml +59 -0
  2. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/paraswap-dex-lib.iml +12 -0
  6. package/.idea/prettier.xml +7 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/build/dex/uniswap-v2/config.js +0 -8
  9. package/build/dex/uniswap-v2/config.js.map +1 -1
  10. package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +94 -0
  11. package/build/dex/uniswap-v3/uniswap-v3-new.js +923 -0
  12. package/build/dex/uniswap-v3/uniswap-v3-new.js.map +1 -0
  13. package/build/dex/zerox/index.d.ts +1 -1
  14. package/build/dex/zerox/index.js.map +1 -1
  15. package/package.json +1 -1
  16. package/scripts/get-uniswap-v3-dexes.ts +64 -0
  17. package/src/dex/uniswap-v2/config.ts +0 -9
  18. package/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts +1 -105
  19. package/tests/constants-e2e.ts +0 -5
  20. package/tests/token-storage-slots.json +0 -8
  21. package/build/abi/AaveV1_lending_pool.json +0 -27
  22. package/build/abi/Aave_GSM.json +0 -751
  23. package/build/abi/Balancer.json +0 -257
  24. package/build/abi/BalancerV2.json +0 -1179
  25. package/build/abi/RamsesV2Pool.abi.json +0 -1554
  26. package/build/abi/RamsesV2Quoter.abi.json +0 -274
  27. package/build/abi/USDM.json +0 -807
  28. package/build/abi/UniswapV2Router.json +0 -397
  29. package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +0 -1246
  30. package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +0 -509
  31. package/build/abi/curve-v1/CurveBUSDv2.abi.json +0 -1356
  32. package/build/abi/curve-v1/CurveTokenV1.json +0 -305
  33. package/build/abi/curve-v1/CurveTokenV2.json +0 -318
  34. package/build/abi/curve-v1/CurveV1StableNg.json +0 -1452
  35. package/build/abi/curve-v1/CurveV2Swap.json +0 -700
  36. package/build/abi/curve-v1/FactoryCryptoRegistry.json +0 -316
  37. package/build/abi/curve-v1/FactoryRegistry.json +0 -508
  38. package/build/abi/curve-v1/StableSwapAave.json +0 -1152
  39. package/build/abi/curve-v1/StableSwapBUSD.json +0 -814
  40. package/build/abi/curve-v1/StableSwapCompound.json +0 -814
  41. package/build/abi/curve-v1/StableSwapIDLE.json +0 -1253
  42. package/build/abi/curve-v1/StableSwapPax.json +0 -865
  43. package/build/abi/curve-v1/StableSwapSnow.json +0 -900
  44. package/build/abi/curve-v1/StableSwapUSDN.json +0 -1004
  45. package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
  46. package/build/abi/curve-v1/StableSwapY.json +0 -814
  47. package/build/abi/inception/inception-ineth-pool.json +0 -1062
  48. package/build/abi/inception/inception-ineth.json +0 -609
  49. package/build/abi/inception/inception-ratio-feed.json +0 -329
  50. package/build/abi/inception/inception-vault.json +0 -991
  51. package/build/abi/kyberdmm/kyber-storage.abi.json +0 -824
  52. package/build/abi/kyberdmm.abi.json +0 -1148
  53. package/build/abi/maverick-v2/MaverickV2Quoter.json +0 -278
  54. package/build/abi/nerve/nerve-metapool.json +0 -790
  55. package/build/abi/platypus/asset.json +0 -490
  56. package/build/abi/platypus/avax-pool.json +0 -820
  57. package/build/abi/platypus/oracle.json +0 -119
  58. package/build/abi/platypus/pool.json +0 -677
  59. package/build/abi/smardex/all/smardex-router.json +0 -648
  60. package/build/abi/smardex/layer-1/smardex-factory.json +0 -242
  61. package/build/abi/smardex/layer-1/smardex-pool.json +0 -506
  62. package/build/abi/smardex/layer-2/smardex-factory.json +0 -185
  63. package/build/abi/smardex/layer-2/smardex-pool.json +0 -578
  64. package/build/abi/swaap-v1/pool.json +0 -1346
  65. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  66. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
  67. package/build/dex/aave-v1/aave-v1.d.ts +0 -34
  68. package/build/dex/aave-v1/aave-v1.js +0 -180
  69. package/build/dex/aave-v1/aave-v1.js.map +0 -1
  70. package/build/dex/aave-v1/config.d.ts +0 -11
  71. package/build/dex/aave-v1/config.js +0 -20
  72. package/build/dex/aave-v1/config.js.map +0 -1
  73. package/build/dex/aave-v1/tokens-mainnet.json +0 -134
  74. package/build/dex/aave-v1/tokens.d.ts +0 -3
  75. package/build/dex/aave-v1/tokens.js +0 -50
  76. package/build/dex/aave-v1/tokens.js.map +0 -1
  77. package/build/dex/aave-v1/types.d.ts +0 -12
  78. package/build/dex/aave-v1/types.js +0 -3
  79. package/build/dex/aave-v1/types.js.map +0 -1
  80. package/build/dex/balancer-v1/balancer-pools.json +0 -33333
  81. package/build/dex/balancer-v3/gyroECLPPool.d.ts +0 -11
  82. package/build/dex/balancer-v3/gyroECLPPool.js +0 -6
  83. package/build/dex/balancer-v3/gyroECLPPool.js.map +0 -1
  84. package/build/dex/balancer-v3/utils.d.ts +0 -2
  85. package/build/dex/balancer-v3/utils.js +0 -11
  86. package/build/dex/balancer-v3/utils.js.map +0 -1
  87. package/build/dex/bebop/websocket-fetcher.d.ts +0 -35
  88. package/build/dex/bebop/websocket-fetcher.js +0 -87
  89. package/build/dex/bebop/websocket-fetcher.js.map +0 -1
  90. package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
  91. package/build/dex/idle-dao/idle-dao-pool.js +0 -176
  92. package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
  93. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
  94. package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
  95. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
  96. package/build/dex/idle-dao/scripts.d.ts +0 -9
  97. package/build/dex/idle-dao/scripts.js +0 -552
  98. package/build/dex/idle-dao/scripts.js.map +0 -1
  99. package/build/dex/inception/config.d.ts +0 -4
  100. package/build/dex/inception/config.js +0 -109
  101. package/build/dex/inception/config.js.map +0 -1
  102. package/build/dex/inception/inception-event-pool.d.ts +0 -16
  103. package/build/dex/inception/inception-event-pool.js +0 -51
  104. package/build/dex/inception/inception-event-pool.js.map +0 -1
  105. package/build/dex/inception/inception-native.d.ts +0 -43
  106. package/build/dex/inception/inception-native.js +0 -131
  107. package/build/dex/inception/inception-native.js.map +0 -1
  108. package/build/dex/inception/inception-pool.d.ts +0 -18
  109. package/build/dex/inception/inception-pool.js +0 -32
  110. package/build/dex/inception/inception-pool.js.map +0 -1
  111. package/build/dex/inception/inception-price-feed.d.ts +0 -19
  112. package/build/dex/inception/inception-price-feed.js +0 -51
  113. package/build/dex/inception/inception-price-feed.js.map +0 -1
  114. package/build/dex/inception/inception.d.ts +0 -43
  115. package/build/dex/inception/inception.js +0 -204
  116. package/build/dex/inception/inception.js.map +0 -1
  117. package/build/dex/inception/tokens.d.ts +0 -9
  118. package/build/dex/inception/tokens.js +0 -28
  119. package/build/dex/inception/tokens.js.map +0 -1
  120. package/build/dex/inception/types.d.ts +0 -22
  121. package/build/dex/inception/types.js +0 -3
  122. package/build/dex/inception/types.js.map +0 -1
  123. package/build/dex/inception/utils.d.ts +0 -6
  124. package/build/dex/inception/utils.js +0 -37
  125. package/build/dex/inception/utils.js.map +0 -1
  126. package/build/dex/platypus/asset.d.ts +0 -14
  127. package/build/dex/platypus/asset.js +0 -97
  128. package/build/dex/platypus/asset.js.map +0 -1
  129. package/build/dex/platypus/config.d.ts +0 -11
  130. package/build/dex/platypus/config.js +0 -69
  131. package/build/dex/platypus/config.js.map +0 -1
  132. package/build/dex/platypus/platypus.d.ts +0 -63
  133. package/build/dex/platypus/platypus.js +0 -473
  134. package/build/dex/platypus/platypus.js.map +0 -1
  135. package/build/dex/platypus/pool-avax.d.ts +0 -8
  136. package/build/dex/platypus/pool-avax.js +0 -54
  137. package/build/dex/platypus/pool-avax.js.map +0 -1
  138. package/build/dex/platypus/pool-base.d.ts +0 -19
  139. package/build/dex/platypus/pool-base.js +0 -86
  140. package/build/dex/platypus/pool-base.js.map +0 -1
  141. package/build/dex/platypus/pool-pure.d.ts +0 -8
  142. package/build/dex/platypus/pool-pure.js +0 -37
  143. package/build/dex/platypus/pool-pure.js.map +0 -1
  144. package/build/dex/platypus/pool-subscriber.d.ts +0 -14
  145. package/build/dex/platypus/pool-subscriber.js +0 -167
  146. package/build/dex/platypus/pool-subscriber.js.map +0 -1
  147. package/build/dex/platypus/pool.d.ts +0 -8
  148. package/build/dex/platypus/pool.js +0 -58
  149. package/build/dex/platypus/pool.js.map +0 -1
  150. package/build/dex/platypus/types.d.ts +0 -92
  151. package/build/dex/platypus/types.js +0 -10
  152. package/build/dex/platypus/types.js.map +0 -1
  153. package/build/dex/quickswap/spiritswap-v3.d.ts +0 -6
  154. package/build/dex/quickswap/spiritswap-v3.js +0 -19
  155. package/build/dex/quickswap/spiritswap-v3.js.map +0 -1
  156. package/build/dex/smardex/config.d.ts +0 -4
  157. package/build/dex/smardex/config.js +0 -64
  158. package/build/dex/smardex/config.js.map +0 -1
  159. package/build/dex/smardex/constants.d.ts +0 -18
  160. package/build/dex/smardex/constants.js +0 -33
  161. package/build/dex/smardex/constants.js.map +0 -1
  162. package/build/dex/smardex/sdk/constants.d.ts +0 -6
  163. package/build/dex/smardex/sdk/constants.js +0 -13
  164. package/build/dex/smardex/sdk/constants.js.map +0 -1
  165. package/build/dex/smardex/sdk/core.d.ts +0 -113
  166. package/build/dex/smardex/sdk/core.js +0 -499
  167. package/build/dex/smardex/sdk/core.js.map +0 -1
  168. package/build/dex/smardex/sdk/errors.d.ts +0 -15
  169. package/build/dex/smardex/sdk/errors.js +0 -22
  170. package/build/dex/smardex/sdk/errors.js.map +0 -1
  171. package/build/dex/smardex/sdk/types.d.ts +0 -62
  172. package/build/dex/smardex/sdk/types.js +0 -3
  173. package/build/dex/smardex/sdk/types.js.map +0 -1
  174. package/build/dex/smardex/sdk/utils.d.ts +0 -44
  175. package/build/dex/smardex/sdk/utils.js +0 -133
  176. package/build/dex/smardex/sdk/utils.js.map +0 -1
  177. package/build/dex/smardex/smardex-event-pool.d.ts +0 -28
  178. package/build/dex/smardex/smardex-event-pool.js +0 -119
  179. package/build/dex/smardex/smardex-event-pool.js.map +0 -1
  180. package/build/dex/smardex/smardex.d.ts +0 -65
  181. package/build/dex/smardex/smardex.js +0 -519
  182. package/build/dex/smardex/smardex.js.map +0 -1
  183. package/build/dex/smardex/types.d.ts +0 -55
  184. package/build/dex/smardex/types.js +0 -3
  185. package/build/dex/smardex/types.js.map +0 -1
  186. package/build/dex/solidly/forks-override/cone.d.ts +0 -22
  187. package/build/dex/solidly/forks-override/cone.js +0 -53
  188. package/build/dex/solidly/forks-override/cone.js.map +0 -1
  189. package/build/dex/solidly/forks-override/solisnek.d.ts +0 -8
  190. package/build/dex/solidly/forks-override/solisnek.js +0 -15
  191. package/build/dex/solidly/forks-override/solisnek.js.map +0 -1
  192. package/build/dex/swaap-v1/config.d.ts +0 -17
  193. package/build/dex/swaap-v1/config.js +0 -56
  194. package/build/dex/swaap-v1/config.js.map +0 -1
  195. package/build/dex/swaap-v1/constants.d.ts +0 -6
  196. package/build/dex/swaap-v1/constants.js +0 -17
  197. package/build/dex/swaap-v1/constants.js.map +0 -1
  198. package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +0 -25
  199. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +0 -62
  200. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +0 -1
  201. package/build/dex/swaap-v1/libraries/Const.d.ts +0 -18
  202. package/build/dex/swaap-v1/libraries/Const.js +0 -26
  203. package/build/dex/swaap-v1/libraries/Const.js.map +0 -1
  204. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +0 -77
  205. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +0 -316
  206. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +0 -1
  207. package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +0 -75
  208. package/build/dex/swaap-v1/libraries/LogExpMath.js +0 -418
  209. package/build/dex/swaap-v1/libraries/LogExpMath.js.map +0 -1
  210. package/build/dex/swaap-v1/libraries/MathMMM.d.ts +0 -185
  211. package/build/dex/swaap-v1/libraries/MathMMM.js +0 -453
  212. package/build/dex/swaap-v1/libraries/MathMMM.js.map +0 -1
  213. package/build/dex/swaap-v1/libraries/Num.d.ts +0 -31
  214. package/build/dex/swaap-v1/libraries/Num.js +0 -167
  215. package/build/dex/swaap-v1/libraries/Num.js.map +0 -1
  216. package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +0 -23
  217. package/build/dex/swaap-v1/libraries/PoolQuotations.js +0 -131
  218. package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +0 -1
  219. package/build/dex/swaap-v1/libraries/Struct.d.ts +0 -56
  220. package/build/dex/swaap-v1/libraries/Struct.js +0 -3
  221. package/build/dex/swaap-v1/libraries/Struct.js.map +0 -1
  222. package/build/dex/swaap-v1/swaap-v1-pool.d.ts +0 -45
  223. package/build/dex/swaap-v1/swaap-v1-pool.js +0 -656
  224. package/build/dex/swaap-v1/swaap-v1-pool.js.map +0 -1
  225. package/build/dex/swaap-v1/swaap-v1.d.ts +0 -62
  226. package/build/dex/swaap-v1/swaap-v1.js +0 -379
  227. package/build/dex/swaap-v1/swaap-v1.js.map +0 -1
  228. package/build/dex/swaap-v1/types.d.ts +0 -106
  229. package/build/dex/swaap-v1/types.js +0 -9
  230. package/build/dex/swaap-v1/types.js.map +0 -1
  231. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -16
  232. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -16
  233. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -16
  234. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -16
  235. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -16
  236. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -16
  237. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -16
  238. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -16
  239. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -9
  240. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -9
  241. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -9
  242. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +0 -9
  243. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +0 -9
  244. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -9
  245. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +0 -9
  246. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +0 -9
  247. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +0 -9
  248. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -12
  249. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -7
  250. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -7
  251. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -7
  252. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -7
  253. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -12
  254. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +0 -7
  255. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +0 -7
  256. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -78
  257. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -81
  258. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -78
  259. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -78
  260. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -81
  261. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -81
  262. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -81
  263. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -81
  264. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -64
  265. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -85
  266. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -64
  267. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +0 -52
  268. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +0 -52
  269. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -52
  270. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +0 -55
  271. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +0 -55
  272. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +0 -55
  273. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -23
  274. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -37
  275. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -23
  276. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -23
  277. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -51
  278. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +0 -58
  279. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -23
  280. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -23
  281. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -9
  282. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -16
  283. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -23
  284. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -12
  285. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -7
  286. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -12
  287. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -12
  288. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -7
  289. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +0 -7
  290. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -7
  291. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -7
  292. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -7
  293. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -7
  294. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -130
  295. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -136
  296. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -100
  297. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -100
  298. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -166
  299. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +0 -190
  300. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -114
  301. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -114
  302. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -55
  303. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -73
  304. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -82
@@ -1,499 +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.getPathFromOutput = exports.getPathFromInput = exports.computeAmountIn = exports.computeAmountOut = exports.getUpdatedPriceAverage = exports.getAmountIn = exports.getAmountOut = exports.computeReserveFic = void 0;
7
- const constants_1 = require("./constants");
8
- const utils_1 = require("./utils");
9
- const errors_1 = __importDefault(require("./errors"));
10
- // compute first trade amountIn using arbitrage feature
11
- function computeFirstTradeQtyIn(amountIn, reserveInFic, reserveOutFic, priceAverageIn, priceAverageOut, feesLP, feesPool) {
12
- // default value
13
- let firstAmountIn = amountIn;
14
- // if trade is in the good direction
15
- if (reserveOutFic * priceAverageIn > reserveInFic * priceAverageOut) {
16
- // pre-compute all operands
17
- const feesTotalReversed = constants_1.FEES_BASE - feesLP - feesPool;
18
- const toSub = reserveInFic * (constants_1.FEES_BASE + feesTotalReversed - feesPool);
19
- const toDiv = (feesTotalReversed + feesLP) * 2n;
20
- const inSqrt = ((reserveInFic * reserveOutFic * 4n) / priceAverageOut) *
21
- priceAverageIn *
22
- feesTotalReversed *
23
- (constants_1.FEES_BASE - feesPool) +
24
- reserveInFic * reserveInFic * feesLP * feesLP;
25
- // reverse sqrt check to only compute sqrt if really needed
26
- if (inSqrt < (amountIn * toDiv + toSub) ** 2n) {
27
- firstAmountIn = ((0, utils_1.sqrt)(inSqrt) - toSub) / toDiv;
28
- }
29
- }
30
- return firstAmountIn;
31
- }
32
- // compute first trade amountOut using arbitrage feature
33
- function computeFirstTradeQtyOut(amountOut, reserveInFic, reserveOutFic, priceAverageIn, priceAverageOut, feesLP, feesPool) {
34
- // default value
35
- let firstAmountOut = amountOut;
36
- // if trade is in the good direction
37
- if (reserveOutFic * priceAverageIn > reserveInFic * priceAverageOut) {
38
- // pre-compute all operands
39
- const feesTotalReversed = constants_1.FEES_BASE - feesLP - feesPool;
40
- const reserveOutFicPredictedFees = (reserveInFic * feesLP * priceAverageOut) / priceAverageIn;
41
- const toAdd = reserveOutFic * feesTotalReversed * 2n + reserveOutFicPredictedFees;
42
- const toDiv = feesTotalReversed * 2n;
43
- const inSqrt = (reserveOutFic *
44
- reserveOutFicPredictedFees *
45
- 4n *
46
- feesTotalReversed *
47
- (constants_1.FEES_BASE - feesPool)) /
48
- feesLP +
49
- reserveOutFicPredictedFees ** 2n;
50
- // reverse sqrt check to only compute sqrt if really needed
51
- if (inSqrt > (toAdd - amountOut * toDiv) ** 2n) {
52
- firstAmountOut = (toAdd - (0, utils_1.sqrt)(inSqrt)) / toDiv;
53
- }
54
- }
55
- return firstAmountOut;
56
- }
57
- // apply uniswap k const rule. amountIn -> amountOut
58
- // return [amountOut, newResIn, newResOut, newResInFic, newResOutFic]
59
- function applyKConstRuleOut(amountIn, reserveIn, reserveOut, reserveInFic, reserveOutFic, feesLP, feesPool) {
60
- // k const rule
61
- const feesTotalReversed = constants_1.FEES_BASE - feesLP - feesPool;
62
- const amountInWithFee = amountIn * feesTotalReversed;
63
- const numerator = amountInWithFee * reserveOutFic;
64
- const denominator = reserveInFic * constants_1.FEES_BASE + amountInWithFee;
65
- if (denominator === 0n) {
66
- throw new errors_1.default('SMARDEX_K_ERROR');
67
- }
68
- const amountOut = numerator / denominator;
69
- // update new reserves and add lp-fees to pools
70
- const amountInWithFeeLp = (amountIn * feesLP + amountInWithFee) / constants_1.FEES_BASE;
71
- const newResIn = reserveIn + amountInWithFeeLp;
72
- const newResInFic = reserveInFic + amountInWithFeeLp;
73
- const newResOut = reserveOut - amountOut;
74
- const newResOutFic = reserveOutFic - amountOut;
75
- return [amountOut, newResIn, newResOut, newResInFic, newResOutFic];
76
- }
77
- // apply uniswap k const rule. amountOut -> amountIn
78
- // returns [amountIn, newResIn, newResOut, newResInFic, newResOutFic]
79
- function applyKConstRuleIn(amountOut, reserveIn, reserveOut, reserveInFic, reserveOutFic, feesLP, feesPool) {
80
- // k const rule
81
- const feesTotalReversed = constants_1.FEES_BASE - feesLP - feesPool;
82
- const numerator = reserveInFic * amountOut * constants_1.FEES_BASE;
83
- const denominator = (reserveOutFic - amountOut) * feesTotalReversed;
84
- if (denominator === 0n) {
85
- throw new errors_1.default('SMARDEX_K_ERROR');
86
- }
87
- const amountIn = numerator / denominator + 1n;
88
- // update new reserves
89
- const amountInWithFeeLp = ((feesTotalReversed + feesLP) * amountIn) / constants_1.FEES_BASE;
90
- const newResIn = reserveIn + amountInWithFeeLp;
91
- const newResInFic = reserveInFic + amountInWithFeeLp;
92
- const newResOut = reserveOut - amountOut;
93
- const newResOutFic = reserveOutFic - amountOut;
94
- return [amountIn, newResIn, newResOut, newResInFic, newResOutFic];
95
- }
96
- /**
97
- * Compute fictive reserves based on current reserves state
98
- *
99
- * @param {bigint} reserveIn the reserves of input token.
100
- * @param {bigint} reserveOut the reserves of output token.
101
- * @param {bigint} reserveInFic the fictive reserves of input token.
102
- * @param {bigint} reserveOutFic the fictive reserves of output token.
103
- * @returns {Array} [ficIn, ficOut]
104
- */
105
- function computeReserveFic(reserveIn, reserveOut, reserveInFic, reserveOutFic) {
106
- if (reserveOut * reserveInFic < reserveIn * reserveOutFic) {
107
- const temp = (((reserveOut * reserveOut) / reserveOutFic) * reserveInFic) / reserveIn;
108
- const newResFicIn = (temp * reserveInFic) / reserveOutFic +
109
- (reserveOut * reserveInFic) / reserveOutFic;
110
- const newResFicOut = reserveOut + temp;
111
- return [newResFicIn / 4n, newResFicOut / 4n];
112
- }
113
- const newResFicIn = (reserveInFic * reserveOut) / reserveOutFic + reserveIn;
114
- const newResFicOut = (reserveIn * reserveOutFic) / reserveInFic + reserveOut;
115
- return [newResFicIn / 4n, newResFicOut / 4n];
116
- }
117
- exports.computeReserveFic = computeReserveFic;
118
- /**
119
- * Simulate a full trasaction, if you know the "in" token quantity, provide you the "out" and all reserves change
120
- * Use case: you want to receive exactly amountOut and want to know the exact amountIn to send.
121
- * @param {bigint} amountIn the desired input amount of the trade.
122
- * @param {bigint} reserveIn the reserves of input token.
123
- * @param {bigint} reserveOut the reserves of output token.
124
- * @param {bigint} reserveInFic the fictive reserves of input token.
125
- * @param {bigint} reserveOutFic the fictive reserves of output token.
126
- * @param {bigint} priceAverageIn the price average of input token.
127
- * @param {bigint} priceAverageOut the price average of output token.
128
- * @param {bigint} feesLP LP fees
129
- * @param {bigint} feesPool Pool fees
130
- * @returns {Array} [amountOut, newResIn, newResOut, newResInFic, newResOutFic]
131
- */
132
- function getAmountOut(amountIn, reserveIn, reserveOut, reserveInFic, reserveOutFic, priceAverageIn, priceAverageOut, feesLP, feesPool) {
133
- // if (amountIn <= 0n) {
134
- // throw new SmardexError('INSUFFICIENT_INPUT_AMOUNT');
135
- // }
136
- if (reserveIn <= 0n || reserveOut <= 0n) {
137
- throw new errors_1.default('INSUFFICIENT_LIQUIDITY');
138
- }
139
- if (reserveInFic <= 0n || reserveOutFic <= 0n) {
140
- throw new errors_1.default('INSUFFICIENT_LIQUIDITY');
141
- }
142
- if (priceAverageIn <= 0n || priceAverageOut <= 0n) {
143
- throw new errors_1.default('INSUFFICIENT_PRICE_AVERAGE');
144
- }
145
- let reserveInFicUpdated = reserveInFic;
146
- let reserveOutFicUpdated = reserveOutFic;
147
- const feesTotalReversed = constants_1.FEES_BASE - feesLP - feesPool;
148
- const amountWithFees = (amountIn * feesTotalReversed) / constants_1.FEES_BASE;
149
- const firstAmount = computeFirstTradeQtyIn(amountWithFees, reserveInFic, reserveOutFic, priceAverageIn, priceAverageOut, feesLP, feesPool);
150
- // if there are 2 trades: 1st trade mustn't re-compute ReserveFic, 2nd should
151
- if (firstAmount === amountWithFees &&
152
- (0, utils_1.ratioApproxEq)(reserveInFic, reserveOutFic, priceAverageIn, priceAverageOut)) {
153
- [reserveInFicUpdated, reserveOutFicUpdated] = computeReserveFic(reserveIn, reserveOut, reserveInFic, reserveOutFic);
154
- }
155
- // avoid K constant division by 0
156
- if (reserveInFicUpdated <= 0n) {
157
- return [
158
- 0n,
159
- reserveIn,
160
- reserveOut,
161
- reserveInFicUpdated,
162
- reserveOutFicUpdated,
163
- ];
164
- }
165
- const firstAmountNoFees = (firstAmount * constants_1.FEES_BASE) / feesTotalReversed;
166
- let [amountOut, newResIn, newResOut, newResInFic, newResOutFic] = applyKConstRuleOut(firstAmountNoFees, reserveIn, reserveOut, reserveInFicUpdated, reserveOutFicUpdated, feesLP, feesPool);
167
- // if we need a second trade
168
- if (firstAmount < amountWithFees && firstAmountNoFees < amountIn) {
169
- [newResInFic, newResOutFic] = computeReserveFic(newResIn, newResOut, newResInFic, newResOutFic);
170
- // Avoid K constant division by 0
171
- if (newResInFic <= 0n) {
172
- return [
173
- 0n,
174
- reserveIn,
175
- reserveOut,
176
- reserveInFicUpdated,
177
- reserveOutFicUpdated,
178
- ];
179
- }
180
- let secondAmountOutNoFees;
181
- [secondAmountOutNoFees, newResIn, newResOut, newResInFic, newResOutFic] =
182
- applyKConstRuleOut(amountIn - firstAmountNoFees, newResIn, newResOut, newResInFic, newResOutFic, feesLP, feesPool);
183
- amountOut += secondAmountOutNoFees;
184
- }
185
- if (newResIn <= 0n ||
186
- newResOut <= 0n ||
187
- newResInFic <= 0n ||
188
- newResOutFic <= 0n) {
189
- throw new errors_1.default('INSUFFICIENT_LIQUIDITY');
190
- }
191
- return [amountOut, newResIn, newResOut, newResInFic, newResOutFic];
192
- }
193
- exports.getAmountOut = getAmountOut;
194
- /**
195
- * Simulate a full transaction, if you know the "out" token quantity, provide you the "in" and all reserves change
196
- * Use case: you want to receive exactly amountOut and want to know the exact amountIn to send.
197
- * @param {bigint} amountOut the desired output amount of the trade.
198
- * @param {bigint} reserveIn the reserves of input token.
199
- * @param {bigint} reserveOut the reserves of output token.
200
- * @param {bigint} reserveInFic the fictive reserves of input token.
201
- * @param {bigint} reserveOutFic the fictive reserves of output token.
202
- * @param {bigint} priceAverageIn the price average of input token.
203
- * @param {bigint} priceAverageOut the price average of output token.
204
- * @param {bigint} feesLP LP fees
205
- * @param {bigint} feesPool Pool fees
206
- * @returns {Array} [amountIn, newResIn, newResOut, newResInFic, newResOutFic]
207
- */
208
- function getAmountIn(amountOut, reserveIn, reserveOut, reserveInFic, reserveOutFic, priceAverageIn, priceAverageOut, feesLP, feesPool) {
209
- // if (amountOut <= 0n) {
210
- // throw new SmardexError('INSUFFICIENT_OUTPUT_AMOUNT');
211
- // }
212
- if (reserveIn <= 0n || reserveOut <= 0n) {
213
- throw new errors_1.default('INSUFFICIENT_LIQUIDITY');
214
- }
215
- if (reserveInFic <= 0n || reserveOutFic <= 0n) {
216
- throw new errors_1.default('INSUFFICIENT_LIQUIDITY');
217
- }
218
- if (priceAverageIn <= 0n || priceAverageOut <= 0n) {
219
- throw new errors_1.default('INSUFFICIENT_PRICE_AVERAGE');
220
- }
221
- let reserveInFicUpdated = reserveInFic;
222
- let reserveOutFicUpdated = reserveOutFic;
223
- const firstAmount = computeFirstTradeQtyOut(amountOut, reserveInFic, reserveOutFic, priceAverageIn, priceAverageOut, feesLP, feesPool);
224
- // if there are 2 trades: 1st trade mustn't re-compute ReserveFic, 2nd should
225
- if (firstAmount === amountOut &&
226
- (0, utils_1.ratioApproxEq)(reserveInFic, reserveOutFic, priceAverageIn, priceAverageOut)) {
227
- [reserveInFicUpdated, reserveOutFicUpdated] = computeReserveFic(reserveIn, reserveOut, reserveInFic, reserveOutFic);
228
- }
229
- if (
230
- // Avoid K constant division by 0
231
- reserveInFic <= 0n ||
232
- // Avoid finding an amountIn for an exact amountOut that is equal to 0
233
- amountOut <= 0n) {
234
- return [
235
- BigInt('0'),
236
- reserveIn,
237
- reserveOut,
238
- reserveInFicUpdated,
239
- reserveOutFicUpdated,
240
- ];
241
- }
242
- let [amountIn, newResIn, newResOut, newResInFic, newResOutFic] = applyKConstRuleIn(firstAmount, reserveIn, reserveOut, reserveInFicUpdated, reserveOutFicUpdated, feesLP, feesPool);
243
- // if we need a second trade
244
- if (firstAmount < amountOut) {
245
- // in the second trade ALWAYS recompute fictive reserves
246
- [newResInFic, newResOutFic] = computeReserveFic(newResIn, newResOut, newResInFic, newResOutFic);
247
- // Avoid K constant division by 0
248
- if (newResInFic <= 0n) {
249
- return [
250
- BigInt('0'),
251
- reserveIn,
252
- reserveOut,
253
- reserveInFicUpdated,
254
- reserveOutFicUpdated,
255
- ];
256
- }
257
- let secondAmountIn;
258
- [secondAmountIn, newResIn, newResOut, newResInFic, newResOutFic] =
259
- applyKConstRuleIn(amountOut - firstAmount, newResIn, newResOut, newResInFic, newResOutFic, feesLP, feesPool);
260
- amountIn += secondAmountIn;
261
- }
262
- if (newResIn <= 0n ||
263
- newResOut <= 0n ||
264
- newResInFic <= 0n ||
265
- newResOutFic <= 0n) {
266
- throw new errors_1.default('INSUFFICIENT_LIQUIDITY');
267
- }
268
- return [amountIn, newResIn, newResOut, newResInFic, newResOutFic];
269
- }
270
- exports.getAmountIn = getAmountIn;
271
- /**
272
- * Computes the priceAverageIn and priceAverageOut.
273
- * Use case: you want to send an exact amount of tokenIn and know exactly how much you it will give you of tokenOut.
274
- * Price averages are modified only if current timestamp does not match last timestamp
275
- * @param {bigint} reserveFicIn the fictuve reserves of input token.
276
- * @param {bigint} reserveFicOut the fictuve reserves of output token.
277
- * @param {number} priceAverageLastTimestamp last timestamp in seconds of price average values.
278
- * @param {bigint} priceAverageIn the latest price average of input token.
279
- * @param {bigint} priceAverageOut the latest price average of output token.
280
- * @param {number} currentTimestampInSecond current timestamp in seconds.
281
- * @param {number} maxBlockDiffSeconds: Max block difference in seconds
282
- * @returns {Array} [priceAverageIn, priceAverageOut]
283
- */
284
- function getUpdatedPriceAverage(reserveFicIn, reserveFicOut, priceAverageLastTimestamp, priceAverageIn, priceAverageOut, currentTimestampInSecond, maxBlockDiffSeconds) {
285
- if (currentTimestampInSecond < priceAverageLastTimestamp) {
286
- throw new errors_1.default('INVALID_TIMESTAMP', 'SmarDexError');
287
- }
288
- // very first time
289
- if (priceAverageLastTimestamp === 0 ||
290
- priceAverageIn === 0n ||
291
- priceAverageOut === 0n) {
292
- return [reserveFicIn, reserveFicOut];
293
- }
294
- // another tx has been done in the same block
295
- if (priceAverageLastTimestamp === currentTimestampInSecond) {
296
- return [priceAverageIn, priceAverageOut];
297
- }
298
- // need to compute new linear-average price
299
- // compute new price:
300
- const timeDiff = Math.min(currentTimestampInSecond - priceAverageLastTimestamp, maxBlockDiffSeconds);
301
- const priceAverageInRet = reserveFicIn;
302
- const priceAverageOutRet = ((priceAverageOut *
303
- priceAverageInRet *
304
- BigInt(maxBlockDiffSeconds - timeDiff)) /
305
- priceAverageIn +
306
- reserveFicOut * BigInt(timeDiff)) /
307
- BigInt(maxBlockDiffSeconds);
308
- return [priceAverageInRet, priceAverageOutRet];
309
- }
310
- exports.getUpdatedPriceAverage = getUpdatedPriceAverage;
311
- /**
312
- * Computes the amount of tokenOut, at the precision of 1 wei.
313
- * Use case: you want to send an exact amount of tokenIn and know exactly how much you it will give you of tokenOut.
314
- * WARNING: token0 and token1 are pair tokens which addresses hexadecimal's values are sorted as token0 < token1.
315
- * @param {string} token0 the currency address of token0.
316
- * @param {string} token1 the currency address of token1.
317
- * @param {bigint} reserve0 the reserves of token0.
318
- * @param {bigint} reserve1 the reserves of token1.
319
- * @param {bigint} reserve0Fic the fictionnal reserves of token0.
320
- * @param {bigint} reserve1Fic the fictionnal reserves of token1.
321
- * @param {bigint} tokenAmountIn the input amount of the trade.
322
- * @param {bigint} tokenAddressIn address of the input token.
323
- * @param {number} priceAverageLastTimestamp: timestamp in seconds of the latest price average.
324
- * @param {bigint} priceAverage0 latest price average of token0.
325
- * @param {bigint} priceAverage1 latest price average of token1.
326
- * @param {bigint} feesLP LP fees
327
- * @param {bigint} feesPool Pool fees
328
- * @param {number} forcedPriceAverageTimestamp: current timestamp or timestamp of the trade in seconds.
329
- * @param {number} maxBlockDiffSeconds: Max block difference in seconds
330
- * @returns {Object} { currency, amount, amountMax, newResIn, newResOut, newResInFic, newResOutFic }
331
- */
332
- function computeAmountOut(token0, token1, reserve0, reserve1, reserve0Fic, reserve1Fic, tokenAmountIn, tokenAddressIn, priceAverageLastTimestamp, priceAverage0, priceAverage1, feesLP, feesPool, forcedPriceAverageTimestamp = Math.ceil(Date.now() / 1000) +
333
- constants_1.LATENCY_OFFSET_SECONDS, maxBlockDiffSeconds = 300) {
334
- if (tokenAddressIn === token0) {
335
- const [newPriceAverage0, newPriceAverage1] = getUpdatedPriceAverage(reserve0Fic, reserve1Fic, priceAverageLastTimestamp, priceAverage0, priceAverage1, forcedPriceAverageTimestamp, maxBlockDiffSeconds);
336
- const [amountOut, newRes0, newRes1, newRes0Fic, newRes1Fic] = getAmountOut(tokenAmountIn, reserve0, reserve1, reserve0Fic, reserve1Fic, newPriceAverage0, newPriceAverage1, feesLP, feesPool);
337
- // const [amountMax] = getAmountOut(
338
- // tokenAmountIn,
339
- // reserve0,
340
- // reserve1,
341
- // reserve0Fic.sub(1).lt(0) ? reserve0Fic : reserve0Fic.sub(1),
342
- // reserve1Fic,
343
- // newPriceAverage0,
344
- // newPriceAverage1,
345
- // );
346
- return {
347
- currency: token1,
348
- amount: amountOut,
349
- amountMax: amountOut,
350
- newRes0,
351
- newRes1,
352
- newRes0Fic,
353
- newRes1Fic,
354
- newPriceAverage0,
355
- newPriceAverage1,
356
- };
357
- }
358
- // token1 is tokenIn
359
- const [newPriceAverage1, newPriceAverage0] = getUpdatedPriceAverage(reserve1Fic, reserve0Fic, priceAverageLastTimestamp, priceAverage1, priceAverage0, forcedPriceAverageTimestamp, maxBlockDiffSeconds);
360
- const [amountOut, newRes1, newRes0, newRes1Fic, newRes0Fic] = getAmountOut(tokenAmountIn, reserve1, reserve0, reserve1Fic, reserve0Fic, newPriceAverage1, newPriceAverage0, feesLP, feesPool);
361
- // const [amountMax] = getAmountOut(
362
- // tokenAmountIn,
363
- // reserve1,
364
- // reserve0,
365
- // reserve1Fic.sub(1).lt(0) ? reserve1Fic : reserve1Fic.sub(1),
366
- // reserve0Fic,
367
- // newPriceAverage1,
368
- // newPriceAverage0,
369
- // );
370
- return {
371
- currency: token0,
372
- amount: amountOut,
373
- amountMax: amountOut,
374
- newRes0,
375
- newRes1,
376
- newRes0Fic,
377
- newRes1Fic,
378
- newPriceAverage0,
379
- newPriceAverage1,
380
- forcedPriceAverageTimestamp,
381
- };
382
- }
383
- exports.computeAmountOut = computeAmountOut;
384
- /**
385
- * Computes the amount of tokenIn, at the precision of 1 wei.
386
- * Use case: you want to receive exactly tokenOut amount and want to know the exact tokenIn amount to send.
387
- * WARNING: token0 and token1 are pair tokens which addresses hexadecimal's values are sorted as token0 < token1.
388
- * @param {string} token0 the currency address of token0.
389
- * @param {string} token1 the currency address of token1.
390
- * @param {bigint} reserve0 the reserves of token0.
391
- * @param {bigint} reserve1 the reserves of token1.
392
- * @param {bigint} reserve0Fic the fictionnal reserves of token0.
393
- * @param {bigint} reserve1Fic the fictionnal reserves of token1.
394
- * @param {bigint} tokenAmountOut the output amount of the trade.
395
- * @param {bigint} tokenAddressOut address of the output token.
396
- * @param {number} priceAverageLastTimestamp timestamp in seconds of the latest price average.
397
- * @param {bigint} priceAverage0 latest price average of token0.
398
- * @param {bigint} priceAverage1 latest price average of token1.
399
- * @param {bigint} feesLP LP fees
400
- * @param {bigint} feesPool Pool fees
401
- * @param {number} forcedPriceAverageTimestamp current timestamp or timestamp of the trade in seconds.
402
- * @param {number} maxBlockDiffSeconds: Max block difference in seconds
403
- * @returns {Object} { currency, amount, amountMax, newResIn, newResOut, newResInFic, newResOutFic }
404
- */
405
- function computeAmountIn(token0, token1, reserve0, reserve1, reserve0Fic, reserve1Fic, tokenAmountOut, tokenAddressOut, priceAverageLastTimestamp, priceAverage0, priceAverage1, feesLP, feesPool, forcedPriceAverageTimestamp = Math.ceil(Date.now() / 1000) +
406
- constants_1.LATENCY_OFFSET_SECONDS, maxBlockDiffSeconds = 300) {
407
- if (tokenAddressOut === token0) {
408
- const [newPriceAverage1, newPriceAverage0] = getUpdatedPriceAverage(reserve1Fic, reserve0Fic, priceAverageLastTimestamp, priceAverage1, priceAverage0, forcedPriceAverageTimestamp, maxBlockDiffSeconds);
409
- const [amountIn, newRes1, newRes0, newRes1Fic, newRes0Fic] = getAmountIn(tokenAmountOut, reserve1, reserve0, reserve1Fic, reserve0Fic, newPriceAverage1, newPriceAverage0, feesLP, feesPool);
410
- // const [amountMax] = getAmountIn(
411
- // tokenAmountOut,
412
- // reserve1,
413
- // reserve0,
414
- // reserve1Fic,
415
- // reserve0Fic.sub(1).lt(0) ? reserve0Fic : reserve0Fic.sub(1),
416
- // newPriceAverage1,
417
- // newPriceAverage0,
418
- // );
419
- return {
420
- currency: token1,
421
- amount: amountIn,
422
- amountMax: amountIn,
423
- newRes0,
424
- newRes1,
425
- newRes0Fic,
426
- newRes1Fic,
427
- newPriceAverage0,
428
- newPriceAverage1,
429
- };
430
- }
431
- // token1 is tokenOut
432
- const [newPriceAverage0, newPriceAverage1] = getUpdatedPriceAverage(reserve0Fic, reserve1Fic, priceAverageLastTimestamp, priceAverage0, priceAverage1, forcedPriceAverageTimestamp, maxBlockDiffSeconds);
433
- const [amountIn, newRes0, newRes1, newRes0Fic, newRes1Fic] = getAmountIn(tokenAmountOut, reserve0, reserve1, reserve0Fic, reserve1Fic, newPriceAverage0, newPriceAverage1, feesLP, feesPool);
434
- // const [amountMax] = getAmountIn(
435
- // tokenAmountOut,
436
- // reserve0,
437
- // reserve1,
438
- // reserve0Fic,
439
- // reserve1Fic.sub(1).lt(0) ? reserve1Fic : reserve1Fic.sub(1),
440
- // newPriceAverage0,
441
- // newPriceAverage1,
442
- // );
443
- return {
444
- currency: token0,
445
- amount: amountIn,
446
- amountMax: amountIn,
447
- newRes0,
448
- newRes1,
449
- newRes0Fic,
450
- newRes1Fic,
451
- newPriceAverage0,
452
- newPriceAverage1,
453
- forcedPriceAverageTimestamp,
454
- };
455
- }
456
- exports.computeAmountIn = computeAmountIn;
457
- /**
458
- * Extracts the token addresses composing the route ordered in the route's direction starting with inputCurrency.
459
- * @param {Pair[]} pairs array of pairs composing the trade.
460
- * @param {string} inputCurrency the currency from which the route starts.
461
- * @return {string[]} Array of token addresses composing the route ordered in the route's direction starting with inputCurrency.
462
- */
463
- function getPathFromInput(pairs, inputCurrency) {
464
- const path = [];
465
- for (let i = 0; i < pairs.length; i += 1) {
466
- const pairCurrencyIn = path.length === 0 ? inputCurrency : path[path.length - 1];
467
- const [tokenIn, tokenOut] = pairCurrencyIn === pairs[i].token0
468
- ? [pairs[i].token0, pairs[i].token1]
469
- : [pairs[i].token1, pairs[i].token0];
470
- if (path.length === 0) {
471
- path.push(tokenIn);
472
- }
473
- path.push(tokenOut);
474
- }
475
- return path;
476
- }
477
- exports.getPathFromInput = getPathFromInput;
478
- /**
479
- * Extracts the token addresses composing the route ordered in the route's direction ending with outputCurrency.
480
- * @param {Pair[]} pairs array of pairs composing the trade.
481
- * @param {string} outputCurrency the currency for which the route finishes.
482
- * @return {string[]} Array of token addresses composing the route ordered in the route's direction ending with outputCurrency.
483
- */
484
- function getPathFromOutput(pairs, outputCurrency) {
485
- const path = [];
486
- for (let i = pairs.length - 1; i >= 0; i -= 1) {
487
- const pairCurrencyOut = path.length === 0 ? outputCurrency : path[path.length - 1];
488
- const [tokenOut, tokenIn] = pairCurrencyOut === pairs[i].token0
489
- ? [pairs[i].token0, pairs[i].token1]
490
- : [pairs[i].token1, pairs[i].token0];
491
- if (path.length === 0) {
492
- path.push(tokenOut);
493
- }
494
- path.push(tokenIn);
495
- }
496
- return path.reverse();
497
- }
498
- exports.getPathFromOutput = getPathFromOutput;
499
- //# sourceMappingURL=core.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../../../src/dex/smardex/sdk/core.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,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;QAC7C,MAAM,eAAe,GACnB,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC7D,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GACvB,eAAe,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;YACjC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACpC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACrB;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KACpB;IACD,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;AACxB,CAAC;AAlBD,8CAkBC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * SmardexError class
3
- *
4
- * @class SmardexError extends Error
5
- */
6
- export default class SmardexError extends Error {
7
- /**
8
- * Create SmardexError object
9
- *
10
- * @param {string} message - error message
11
- * @param {string} [errorName=SmarDexSDK] - identifier for the error
12
- * @returns {SmardexError} SmarDex Error object
13
- */
14
- constructor(message: string, errorName?: string);
15
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * SmardexError class
5
- *
6
- * @class SmardexError extends Error
7
- */
8
- class SmardexError extends Error {
9
- /**
10
- * Create SmardexError object
11
- *
12
- * @param {string} message - error message
13
- * @param {string} [errorName=SmarDexSDK] - identifier for the error
14
- * @returns {SmardexError} SmarDex Error object
15
- */
16
- constructor(message, errorName = 'SmarDexSDK') {
17
- super(message);
18
- this.name = errorName;
19
- }
20
- }
21
- exports.default = SmardexError;
22
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/dex/smardex/sdk/errors.ts"],"names":[],"mappings":";;AAAA;;;;GAIG;AACH,MAAqB,YAAa,SAAQ,KAAK;IAC7C;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,SAAS,GAAG,YAAY;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACxB,CAAC;CACF;AAZD,+BAYC"}
@@ -1,62 +0,0 @@
1
- import { TradeType } from './constants';
2
- export interface Pair {
3
- address?: string;
4
- token0: string;
5
- token1: string;
6
- reserve0: bigint;
7
- reserve1: bigint;
8
- reserve0LastFictive: bigint;
9
- reserve1LastFictive: bigint;
10
- priceAverageLastTimestamp: number;
11
- priceAverage0: bigint;
12
- priceAverage1: bigint;
13
- forcedPriceAverageTimestamp?: number;
14
- prevReserveFic0?: bigint;
15
- prevReserveFic1?: bigint;
16
- feesLP: bigint;
17
- feesPool: bigint;
18
- }
19
- export interface CurrencyAmount {
20
- currency: string;
21
- amount: bigint;
22
- amountMax?: bigint;
23
- newRes0?: bigint;
24
- newRes1?: bigint;
25
- newRes0Fic?: bigint;
26
- newRes1Fic?: bigint;
27
- newPriceAverage0?: bigint;
28
- newPriceAverage1?: bigint;
29
- forcedPriceAverageTimestamp?: number;
30
- }
31
- export interface BestTradeOptions {
32
- maxNumResults?: number;
33
- maxHops?: number;
34
- arbitrage?: boolean;
35
- }
36
- export interface Route {
37
- pairs: Pair[];
38
- path: string[];
39
- input: string;
40
- output: string;
41
- }
42
- export interface Trade {
43
- route: Route;
44
- amountIn: CurrencyAmount;
45
- amountOut: CurrencyAmount;
46
- tradeType: TradeType;
47
- priceImpact?: bigint;
48
- gasFeesUSD?: bigint;
49
- amountInUSD?: bigint;
50
- amountOutUSD?: bigint;
51
- }
52
- export interface GasEstimateData {
53
- gasPrice: bigint;
54
- gasQuantitiesFirstHop: number;
55
- gasQuantitiesAdditionalHop: number;
56
- nativeTokenPrice: bigint;
57
- nativeTokenDecimals: number;
58
- inputTokenPrice: bigint;
59
- inputTokenDecimals: number;
60
- outputTokenPrice: bigint;
61
- outputTokenDecimals: number;
62
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/dex/smardex/sdk/types.ts"],"names":[],"mappings":""}