@paraswap/dex-lib 4.2.5 → 4.2.7

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 (369) hide show
  1. package/build/constants.js +1 -1
  2. package/build/dex/uniswap-v4/constants.d.ts +1 -2
  3. package/build/dex/uniswap-v4/constants.js +2 -3
  4. package/build/dex/uniswap-v4/constants.js.map +1 -1
  5. package/build/dex/uniswap-v4/contract-math/Tick.d.ts +1 -1
  6. package/build/dex/uniswap-v4/contract-math/Tick.js +13 -9
  7. package/build/dex/uniswap-v4/contract-math/Tick.js.map +1 -1
  8. package/build/dex/uniswap-v4/contract-math/uniswap-v4-pool-math.js +6 -5
  9. package/build/dex/uniswap-v4/contract-math/uniswap-v4-pool-math.js.map +1 -1
  10. package/build/dex/uniswap-v4/optimizer.d.ts +2 -0
  11. package/build/dex/uniswap-v4/optimizer.js +47 -0
  12. package/build/dex/uniswap-v4/optimizer.js.map +1 -0
  13. package/build/dex/uniswap-v4/uniswap-v4-pool.js +14 -6
  14. package/build/dex/uniswap-v4/uniswap-v4-pool.js.map +1 -1
  15. package/build/dex/uniswap-v4/uniswap-v4.js +7 -1
  16. package/build/dex/uniswap-v4/uniswap-v4.js.map +1 -1
  17. package/package.json +1 -1
  18. package/build/abi/AaveV1_lending_pool.json +0 -27
  19. package/build/abi/Aave_GSM.json +0 -751
  20. package/build/abi/BProtocol.json +0 -1155
  21. package/build/abi/Balancer.json +0 -257
  22. package/build/abi/BalancerV2.json +0 -1179
  23. package/build/abi/Jarvis.json +0 -1172
  24. package/build/abi/MStableAsset.json +0 -1545
  25. package/build/abi/OneInchLp.json +0 -1304
  26. package/build/abi/Onebit.json +0 -736
  27. package/build/abi/RamsesV2Pool.abi.json +0 -1554
  28. package/build/abi/RamsesV2Quoter.abi.json +0 -274
  29. package/build/abi/Shell.json +0 -1294
  30. package/build/abi/TraderJoeV2Router.json +0 -50
  31. package/build/abi/USDM.json +0 -807
  32. package/build/abi/UniswapV2Router.json +0 -397
  33. package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +0 -1246
  34. package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +0 -509
  35. package/build/abi/curve-v1/CurveBUSDv2.abi.json +0 -1356
  36. package/build/abi/curve-v1/CurveTokenV1.json +0 -305
  37. package/build/abi/curve-v1/CurveTokenV2.json +0 -318
  38. package/build/abi/curve-v1/CurveV1StableNg.json +0 -1452
  39. package/build/abi/curve-v1/CurveV2Swap.json +0 -700
  40. package/build/abi/curve-v1/FactoryCryptoRegistry.json +0 -316
  41. package/build/abi/curve-v1/FactoryRegistry.json +0 -508
  42. package/build/abi/curve-v1/StableSwapAave.json +0 -1152
  43. package/build/abi/curve-v1/StableSwapBUSD.json +0 -814
  44. package/build/abi/curve-v1/StableSwapCompound.json +0 -814
  45. package/build/abi/curve-v1/StableSwapIDLE.json +0 -1253
  46. package/build/abi/curve-v1/StableSwapPax.json +0 -865
  47. package/build/abi/curve-v1/StableSwapSnow.json +0 -900
  48. package/build/abi/curve-v1/StableSwapUSDN.json +0 -1004
  49. package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
  50. package/build/abi/curve-v1/StableSwapY.json +0 -814
  51. package/build/abi/inception/inception-ineth-pool.json +0 -1062
  52. package/build/abi/inception/inception-ineth.json +0 -609
  53. package/build/abi/inception/inception-ratio-feed.json +0 -329
  54. package/build/abi/inception/inception-vault.json +0 -991
  55. package/build/abi/kyberdmm/kyber-storage.abi.json +0 -824
  56. package/build/abi/kyberdmm.abi.json +0 -1148
  57. package/build/abi/maverick-v2/MaverickV2Quoter.json +0 -278
  58. package/build/abi/nerve/nerve-metapool.json +0 -790
  59. package/build/abi/platypus/asset.json +0 -490
  60. package/build/abi/platypus/avax-pool.json +0 -820
  61. package/build/abi/platypus/oracle.json +0 -119
  62. package/build/abi/platypus/pool.json +0 -677
  63. package/build/abi/smardex/all/smardex-router.json +0 -648
  64. package/build/abi/smardex/layer-1/smardex-factory.json +0 -242
  65. package/build/abi/smardex/layer-1/smardex-pool.json +0 -506
  66. package/build/abi/smardex/layer-2/smardex-factory.json +0 -185
  67. package/build/abi/smardex/layer-2/smardex-pool.json +0 -578
  68. package/build/abi/swaap-v1/pool.json +0 -1346
  69. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  70. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
  71. package/build/abi/wUSDM.json +0 -757
  72. package/build/abi/zrx.v2.json +0 -1967
  73. package/build/abi/zrx.v3.json +0 -3454
  74. package/build/abi/zrx.v4.json +0 -2193
  75. package/build/dex/OneInchLp.d.ts +0 -24
  76. package/build/dex/OneInchLp.js +0 -43
  77. package/build/dex/OneInchLp.js.map +0 -1
  78. package/build/dex/aave-v1/aave-v1.d.ts +0 -34
  79. package/build/dex/aave-v1/aave-v1.js +0 -180
  80. package/build/dex/aave-v1/aave-v1.js.map +0 -1
  81. package/build/dex/aave-v1/config.d.ts +0 -11
  82. package/build/dex/aave-v1/config.js +0 -20
  83. package/build/dex/aave-v1/config.js.map +0 -1
  84. package/build/dex/aave-v1/tokens-mainnet.json +0 -134
  85. package/build/dex/aave-v1/tokens.d.ts +0 -3
  86. package/build/dex/aave-v1/tokens.js +0 -50
  87. package/build/dex/aave-v1/tokens.js.map +0 -1
  88. package/build/dex/aave-v1/types.d.ts +0 -12
  89. package/build/dex/aave-v1/types.js +0 -3
  90. package/build/dex/aave-v1/types.js.map +0 -1
  91. package/build/dex/bProtocol/bProtocol.d.ts +0 -15
  92. package/build/dex/bProtocol/bProtocol.js +0 -56
  93. package/build/dex/bProtocol/bProtocol.js.map +0 -1
  94. package/build/dex/bProtocol/types.d.ts +0 -11
  95. package/build/dex/bProtocol/types.js +0 -8
  96. package/build/dex/bProtocol/types.js.map +0 -1
  97. package/build/dex/balancer-v1/balancer-pools.json +0 -33333
  98. package/build/dex/bebop/websocket-fetcher.d.ts +0 -35
  99. package/build/dex/bebop/websocket-fetcher.js +0 -87
  100. package/build/dex/bebop/websocket-fetcher.js.map +0 -1
  101. package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
  102. package/build/dex/idle-dao/idle-dao-pool.js +0 -176
  103. package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
  104. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
  105. package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
  106. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
  107. package/build/dex/idle-dao/scripts.d.ts +0 -9
  108. package/build/dex/idle-dao/scripts.js +0 -552
  109. package/build/dex/idle-dao/scripts.js.map +0 -1
  110. package/build/dex/inception/config.d.ts +0 -4
  111. package/build/dex/inception/config.js +0 -109
  112. package/build/dex/inception/config.js.map +0 -1
  113. package/build/dex/inception/inception-event-pool.d.ts +0 -16
  114. package/build/dex/inception/inception-event-pool.js +0 -51
  115. package/build/dex/inception/inception-event-pool.js.map +0 -1
  116. package/build/dex/inception/inception-native.d.ts +0 -43
  117. package/build/dex/inception/inception-native.js +0 -131
  118. package/build/dex/inception/inception-native.js.map +0 -1
  119. package/build/dex/inception/inception-pool.d.ts +0 -18
  120. package/build/dex/inception/inception-pool.js +0 -32
  121. package/build/dex/inception/inception-pool.js.map +0 -1
  122. package/build/dex/inception/inception-price-feed.d.ts +0 -19
  123. package/build/dex/inception/inception-price-feed.js +0 -51
  124. package/build/dex/inception/inception-price-feed.js.map +0 -1
  125. package/build/dex/inception/inception.d.ts +0 -43
  126. package/build/dex/inception/inception.js +0 -204
  127. package/build/dex/inception/inception.js.map +0 -1
  128. package/build/dex/inception/tokens.d.ts +0 -9
  129. package/build/dex/inception/tokens.js +0 -28
  130. package/build/dex/inception/tokens.js.map +0 -1
  131. package/build/dex/inception/types.d.ts +0 -22
  132. package/build/dex/inception/types.js +0 -3
  133. package/build/dex/inception/types.js.map +0 -1
  134. package/build/dex/inception/utils.d.ts +0 -6
  135. package/build/dex/inception/utils.js +0 -37
  136. package/build/dex/inception/utils.js.map +0 -1
  137. package/build/dex/jarvis.d.ts +0 -56
  138. package/build/dex/jarvis.js +0 -163
  139. package/build/dex/jarvis.js.map +0 -1
  140. package/build/dex/mStable.d.ts +0 -44
  141. package/build/dex/mStable.js +0 -75
  142. package/build/dex/mStable.js.map +0 -1
  143. package/build/dex/onebit/onebit.d.ts +0 -16
  144. package/build/dex/onebit/onebit.js +0 -61
  145. package/build/dex/onebit/onebit.js.map +0 -1
  146. package/build/dex/onebit/types.d.ts +0 -14
  147. package/build/dex/onebit/types.js +0 -8
  148. package/build/dex/onebit/types.js.map +0 -1
  149. package/build/dex/platypus/asset.d.ts +0 -14
  150. package/build/dex/platypus/asset.js +0 -97
  151. package/build/dex/platypus/asset.js.map +0 -1
  152. package/build/dex/platypus/config.d.ts +0 -11
  153. package/build/dex/platypus/config.js +0 -69
  154. package/build/dex/platypus/config.js.map +0 -1
  155. package/build/dex/platypus/platypus.d.ts +0 -63
  156. package/build/dex/platypus/platypus.js +0 -473
  157. package/build/dex/platypus/platypus.js.map +0 -1
  158. package/build/dex/platypus/pool-avax.d.ts +0 -8
  159. package/build/dex/platypus/pool-avax.js +0 -54
  160. package/build/dex/platypus/pool-avax.js.map +0 -1
  161. package/build/dex/platypus/pool-base.d.ts +0 -19
  162. package/build/dex/platypus/pool-base.js +0 -86
  163. package/build/dex/platypus/pool-base.js.map +0 -1
  164. package/build/dex/platypus/pool-pure.d.ts +0 -8
  165. package/build/dex/platypus/pool-pure.js +0 -37
  166. package/build/dex/platypus/pool-pure.js.map +0 -1
  167. package/build/dex/platypus/pool-subscriber.d.ts +0 -14
  168. package/build/dex/platypus/pool-subscriber.js +0 -167
  169. package/build/dex/platypus/pool-subscriber.js.map +0 -1
  170. package/build/dex/platypus/pool.d.ts +0 -8
  171. package/build/dex/platypus/pool.js +0 -58
  172. package/build/dex/platypus/pool.js.map +0 -1
  173. package/build/dex/platypus/types.d.ts +0 -92
  174. package/build/dex/platypus/types.js +0 -10
  175. package/build/dex/platypus/types.js.map +0 -1
  176. package/build/dex/quickswap/spiritswap-v3.d.ts +0 -6
  177. package/build/dex/quickswap/spiritswap-v3.js +0 -19
  178. package/build/dex/quickswap/spiritswap-v3.js.map +0 -1
  179. package/build/dex/shell.d.ts +0 -25
  180. package/build/dex/shell.js +0 -41
  181. package/build/dex/shell.js.map +0 -1
  182. package/build/dex/smardex/config.d.ts +0 -4
  183. package/build/dex/smardex/config.js +0 -64
  184. package/build/dex/smardex/config.js.map +0 -1
  185. package/build/dex/smardex/constants.d.ts +0 -18
  186. package/build/dex/smardex/constants.js +0 -33
  187. package/build/dex/smardex/constants.js.map +0 -1
  188. package/build/dex/smardex/sdk/constants.d.ts +0 -6
  189. package/build/dex/smardex/sdk/constants.js +0 -13
  190. package/build/dex/smardex/sdk/constants.js.map +0 -1
  191. package/build/dex/smardex/sdk/core.d.ts +0 -113
  192. package/build/dex/smardex/sdk/core.js +0 -499
  193. package/build/dex/smardex/sdk/core.js.map +0 -1
  194. package/build/dex/smardex/sdk/errors.d.ts +0 -15
  195. package/build/dex/smardex/sdk/errors.js +0 -22
  196. package/build/dex/smardex/sdk/errors.js.map +0 -1
  197. package/build/dex/smardex/sdk/types.d.ts +0 -62
  198. package/build/dex/smardex/sdk/types.js +0 -3
  199. package/build/dex/smardex/sdk/types.js.map +0 -1
  200. package/build/dex/smardex/sdk/utils.d.ts +0 -44
  201. package/build/dex/smardex/sdk/utils.js +0 -133
  202. package/build/dex/smardex/sdk/utils.js.map +0 -1
  203. package/build/dex/smardex/smardex-event-pool.d.ts +0 -28
  204. package/build/dex/smardex/smardex-event-pool.js +0 -119
  205. package/build/dex/smardex/smardex-event-pool.js.map +0 -1
  206. package/build/dex/smardex/smardex.d.ts +0 -65
  207. package/build/dex/smardex/smardex.js +0 -519
  208. package/build/dex/smardex/smardex.js.map +0 -1
  209. package/build/dex/smardex/types.d.ts +0 -55
  210. package/build/dex/smardex/types.js +0 -3
  211. package/build/dex/smardex/types.js.map +0 -1
  212. package/build/dex/solidly/forks-override/cone.d.ts +0 -22
  213. package/build/dex/solidly/forks-override/cone.js +0 -53
  214. package/build/dex/solidly/forks-override/cone.js.map +0 -1
  215. package/build/dex/solidly/forks-override/solisnek.d.ts +0 -8
  216. package/build/dex/solidly/forks-override/solisnek.js +0 -15
  217. package/build/dex/solidly/forks-override/solisnek.js.map +0 -1
  218. package/build/dex/swaap-v1/config.d.ts +0 -17
  219. package/build/dex/swaap-v1/config.js +0 -56
  220. package/build/dex/swaap-v1/config.js.map +0 -1
  221. package/build/dex/swaap-v1/constants.d.ts +0 -6
  222. package/build/dex/swaap-v1/constants.js +0 -17
  223. package/build/dex/swaap-v1/constants.js.map +0 -1
  224. package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +0 -25
  225. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +0 -62
  226. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +0 -1
  227. package/build/dex/swaap-v1/libraries/Const.d.ts +0 -18
  228. package/build/dex/swaap-v1/libraries/Const.js +0 -26
  229. package/build/dex/swaap-v1/libraries/Const.js.map +0 -1
  230. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +0 -77
  231. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +0 -316
  232. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +0 -1
  233. package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +0 -75
  234. package/build/dex/swaap-v1/libraries/LogExpMath.js +0 -418
  235. package/build/dex/swaap-v1/libraries/LogExpMath.js.map +0 -1
  236. package/build/dex/swaap-v1/libraries/MathMMM.d.ts +0 -185
  237. package/build/dex/swaap-v1/libraries/MathMMM.js +0 -453
  238. package/build/dex/swaap-v1/libraries/MathMMM.js.map +0 -1
  239. package/build/dex/swaap-v1/libraries/Num.d.ts +0 -31
  240. package/build/dex/swaap-v1/libraries/Num.js +0 -167
  241. package/build/dex/swaap-v1/libraries/Num.js.map +0 -1
  242. package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +0 -23
  243. package/build/dex/swaap-v1/libraries/PoolQuotations.js +0 -131
  244. package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +0 -1
  245. package/build/dex/swaap-v1/libraries/Struct.d.ts +0 -56
  246. package/build/dex/swaap-v1/libraries/Struct.js +0 -3
  247. package/build/dex/swaap-v1/libraries/Struct.js.map +0 -1
  248. package/build/dex/swaap-v1/swaap-v1-pool.d.ts +0 -45
  249. package/build/dex/swaap-v1/swaap-v1-pool.js +0 -656
  250. package/build/dex/swaap-v1/swaap-v1-pool.js.map +0 -1
  251. package/build/dex/swaap-v1/swaap-v1.d.ts +0 -62
  252. package/build/dex/swaap-v1/swaap-v1.js +0 -379
  253. package/build/dex/swaap-v1/swaap-v1.js.map +0 -1
  254. package/build/dex/swaap-v1/types.d.ts +0 -106
  255. package/build/dex/swaap-v1/types.js +0 -9
  256. package/build/dex/swaap-v1/types.js.map +0 -1
  257. package/build/dex/trader-joe-v2.d.ts +0 -40
  258. package/build/dex/trader-joe-v2.js +0 -74
  259. package/build/dex/trader-joe-v2.js.map +0 -1
  260. package/build/dex/usual-bond/config.d.ts +0 -3
  261. package/build/dex/usual-bond/config.js +0 -13
  262. package/build/dex/usual-bond/config.js.map +0 -1
  263. package/build/dex/usual-bond/types.d.ts +0 -7
  264. package/build/dex/usual-bond/types.js +0 -3
  265. package/build/dex/usual-bond/types.js.map +0 -1
  266. package/build/dex/usual-bond/usual-bond.d.ts +0 -35
  267. package/build/dex/usual-bond/usual-bond.js +0 -176
  268. package/build/dex/usual-bond/usual-bond.js.map +0 -1
  269. package/build/dex/wusdm/config.d.ts +0 -3
  270. package/build/dex/wusdm/config.js +0 -43
  271. package/build/dex/wusdm/config.js.map +0 -1
  272. package/build/dex/wusdm/constants.d.ts +0 -2
  273. package/build/dex/wusdm/constants.js +0 -6
  274. package/build/dex/wusdm/constants.js.map +0 -1
  275. package/build/dex/wusdm/types.d.ts +0 -18
  276. package/build/dex/wusdm/types.js +0 -11
  277. package/build/dex/wusdm/types.js.map +0 -1
  278. package/build/dex/wusdm/wusdm-pool.d.ts +0 -21
  279. package/build/dex/wusdm/wusdm-pool.js +0 -74
  280. package/build/dex/wusdm/wusdm-pool.js.map +0 -1
  281. package/build/dex/wusdm/wusdm.d.ts +0 -46
  282. package/build/dex/wusdm/wusdm.js +0 -243
  283. package/build/dex/wusdm/wusdm.js.map +0 -1
  284. package/build/dex/zerox/config.d.ts +0 -2
  285. package/build/dex/zerox/config.js +0 -33
  286. package/build/dex/zerox/config.js.map +0 -1
  287. package/build/dex/zerox/index.d.ts +0 -22
  288. package/build/dex/zerox/index.js +0 -225
  289. package/build/dex/zerox/index.js.map +0 -1
  290. package/build/dex/zerox/order.d.ts +0 -88
  291. package/build/dex/zerox/order.js +0 -53
  292. package/build/dex/zerox/order.js.map +0 -1
  293. package/build/dex/zerox/types.d.ts +0 -73
  294. package/build/dex/zerox/types.js +0 -21
  295. package/build/dex/zerox/types.js.map +0 -1
  296. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -16
  297. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -16
  298. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -16
  299. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -16
  300. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -16
  301. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -16
  302. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -16
  303. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -16
  304. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -9
  305. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -9
  306. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -9
  307. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +0 -9
  308. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +0 -9
  309. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -9
  310. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +0 -9
  311. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +0 -9
  312. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +0 -9
  313. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -12
  314. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -7
  315. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -7
  316. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -7
  317. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -7
  318. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -12
  319. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +0 -7
  320. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +0 -7
  321. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -78
  322. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -81
  323. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -78
  324. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -78
  325. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -81
  326. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -81
  327. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -81
  328. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -81
  329. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -64
  330. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -85
  331. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -64
  332. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +0 -52
  333. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +0 -52
  334. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -52
  335. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +0 -55
  336. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +0 -55
  337. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +0 -55
  338. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -23
  339. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -37
  340. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -23
  341. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -23
  342. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -51
  343. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +0 -58
  344. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -23
  345. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -23
  346. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -9
  347. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -16
  348. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -23
  349. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -12
  350. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -7
  351. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -12
  352. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -12
  353. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -7
  354. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +0 -7
  355. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -7
  356. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -7
  357. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -7
  358. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -7
  359. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -130
  360. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -136
  361. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -100
  362. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -100
  363. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -166
  364. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +0 -190
  365. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -114
  366. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -114
  367. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -55
  368. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -73
  369. 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.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAgE;AAChE,mCAA8C;AAC9C,sDAAoC;AAGpC,uDAAuD;AACvD,SAAS,sBAAsB,CAC7B,QAAgB,EAChB,YAAoB,EACpB,aAAqB,EACrB,cAAsB,EACtB,eAAuB,EACvB,MAAc,EACd,QAAgB;IAEhB,gBAAgB;IAChB,IAAI,aAAa,GAAG,QAAQ,CAAC;IAE7B,oCAAoC;IACpC,IAAI,aAAa,GAAG,cAAc,GAAG,YAAY,GAAG,eAAe,EAAE;QACnE,2BAA2B;QAC3B,MAAM,iBAAiB,GAAG,qBAAS,GAAG,MAAM,GAAG,QAA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,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":""}