@paraswap/dex-lib 4.1.12 → 4.1.13

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 (353) hide show
  1. package/.idea/aws.xml +17 -0
  2. package/.idea/codeStyles/Project.xml +19 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/misc.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/paraswap-dex-lib.iml +9 -0
  7. package/.idea/prettier.xml +7 -0
  8. package/.idea/vcs.xml +6 -0
  9. package/build/abi/integral/factory.json +333 -0
  10. package/build/abi/integral/oracle.json +501 -0
  11. package/build/abi/{curve-v1/StableSwapUSDN.json → integral/pool.json} +487 -450
  12. package/build/abi/{RamsesV2Pool.abi.json → integral/relayer.json} +833 -851
  13. package/build/abi/{inception/inception-ineth.json → sdai/PSM3.abi.json} +354 -242
  14. package/build/abi/{angle-transmuter/ChainlinkEACAggregatorProxy.json → sdai/SSRAuthOracle.abi.json} +233 -220
  15. package/build/abi/uniswap-v4/pool-manager.abi.json +1366 -0
  16. package/build/abi/uniswap-v4/quoter.abi.json +461 -0
  17. package/build/abi/uniswap-v4/router.abi.json +230 -0
  18. package/build/abi/uniswap-v4/state-view.abi.json +365 -0
  19. package/build/dex/aave-v1/aave-v1.d.ts +1 -2
  20. package/build/dex/aave-v1/aave-v1.js +0 -22
  21. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  22. package/build/dex/bProtocol.d.ts +18 -0
  23. package/build/dex/bProtocol.js +39 -0
  24. package/build/dex/bProtocol.js.map +1 -0
  25. package/build/dex/bancor.d.ts +26 -0
  26. package/build/dex/bancor.js +58 -0
  27. package/build/dex/bancor.js.map +1 -0
  28. package/build/dex/compound.d.ts +18 -0
  29. package/build/dex/compound.js +46 -0
  30. package/build/dex/compound.js.map +1 -0
  31. package/build/dex/curve-v2.d.ts +58 -0
  32. package/build/dex/curve-v2.js +180 -0
  33. package/build/dex/curve-v2.js.map +1 -0
  34. package/build/dex/dodo-v1.d.ts +33 -0
  35. package/build/dex/dodo-v1.js +63 -0
  36. package/build/dex/dodo-v1.js.map +1 -0
  37. package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +49 -0
  38. package/build/dex/fluid-dex/fluid-dex-generate-pool.js +104 -0
  39. package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +1 -0
  40. package/build/dex/index.js +2 -0
  41. package/build/dex/index.js.map +1 -1
  42. package/build/dex/integral/config.d.ts +4 -0
  43. package/build/dex/integral/config.js +20 -0
  44. package/build/dex/integral/config.js.map +1 -0
  45. package/build/dex/integral/context.d.ts +40 -0
  46. package/build/dex/integral/context.js +158 -0
  47. package/build/dex/integral/context.js.map +1 -0
  48. package/build/dex/integral/integral-factory.d.ts +24 -0
  49. package/build/dex/integral/integral-factory.js +95 -0
  50. package/build/dex/integral/integral-factory.js.map +1 -0
  51. package/build/dex/integral/integral-pool.d.ts +50 -0
  52. package/build/dex/integral/integral-pool.js +149 -0
  53. package/build/dex/integral/integral-pool.js.map +1 -0
  54. package/build/dex/integral/integral-pricing.d.ts +18 -0
  55. package/build/dex/integral/integral-pricing.js +114 -0
  56. package/build/dex/integral/integral-pricing.js.map +1 -0
  57. package/build/dex/integral/integral-relayer.d.ts +42 -0
  58. package/build/dex/integral/integral-relayer.js +192 -0
  59. package/build/dex/integral/integral-relayer.js.map +1 -0
  60. package/build/dex/integral/integral-token.d.ts +27 -0
  61. package/build/dex/integral/integral-token.js +59 -0
  62. package/build/dex/integral/integral-token.js.map +1 -0
  63. package/build/dex/{inception/inception-native.d.ts → integral/integral.d.ts} +19 -21
  64. package/build/dex/integral/integral.js +376 -0
  65. package/build/dex/integral/integral.js.map +1 -0
  66. package/build/dex/integral/types.d.ts +85 -0
  67. package/build/dex/integral/types.js +9 -0
  68. package/build/dex/integral/types.js.map +1 -0
  69. package/build/dex/integral/utils-e2e.d.ts +9 -0
  70. package/build/dex/integral/utils-e2e.js +131 -0
  71. package/build/dex/integral/utils-e2e.js.map +1 -0
  72. package/build/dex/integral/utils.d.ts +17 -0
  73. package/build/dex/integral/utils.js +94 -0
  74. package/build/dex/integral/utils.js.map +1 -0
  75. package/build/dex/jarvis.d.ts +1 -2
  76. package/build/dex/jarvis.js +0 -58
  77. package/build/dex/jarvis.js.map +1 -1
  78. package/build/dex/lido.d.ts +19 -0
  79. package/build/dex/lido.js +42 -0
  80. package/build/dex/lido.js.map +1 -0
  81. package/build/dex/m-token/config.d.ts +3 -0
  82. package/build/dex/m-token/config.js +19 -0
  83. package/build/dex/m-token/config.js.map +1 -0
  84. package/build/dex/m-token/m-token.d.ts +29 -0
  85. package/build/dex/m-token/m-token.js +145 -0
  86. package/build/dex/m-token/m-token.js.map +1 -0
  87. package/build/dex/m-token/m-wrapped-m.d.ts +17 -0
  88. package/build/dex/m-token/m-wrapped-m.js +50 -0
  89. package/build/dex/m-token/m-wrapped-m.js.map +1 -0
  90. package/build/dex/m-token/types.d.ts +12 -0
  91. package/build/dex/{inception → m-token}/types.js.map +1 -1
  92. package/build/dex/onebit.d.ts +25 -0
  93. package/build/dex/onebit.js +42 -0
  94. package/build/dex/onebit.js.map +1 -0
  95. package/build/dex/platypus/platypus.d.ts +1 -2
  96. package/build/dex/platypus/platypus.js +0 -31
  97. package/build/dex/platypus/platypus.js.map +1 -1
  98. package/build/dex/smoothy.d.ts +26 -0
  99. package/build/dex/smoothy.js +48 -0
  100. package/build/dex/smoothy.js.map +1 -0
  101. package/build/dex/spark/config.js.map +1 -1
  102. package/build/dex/spark/spark-psm.d.ts +51 -0
  103. package/build/dex/spark/spark-psm.js +276 -0
  104. package/build/dex/spark/spark-psm.js.map +1 -0
  105. package/build/dex/spark/spark-sdai-pool.d.ts +1 -1
  106. package/build/dex/spark/spark-sdai-pool.js.map +1 -1
  107. package/build/dex/spark/spark.d.ts +4 -3
  108. package/build/dex/spark/spark.js +4 -2
  109. package/build/dex/spark/spark.js.map +1 -1
  110. package/build/dex/spark/susds-psm.d.ts +49 -0
  111. package/build/dex/spark/susds-psm.js +245 -0
  112. package/build/dex/spark/susds-psm.js.map +1 -0
  113. package/build/dex/spark/types.d.ts +13 -2
  114. package/build/dex/spark/types.js +8 -1
  115. package/build/dex/spark/types.js.map +1 -1
  116. package/build/dex/spark/utils.d.ts +2 -1
  117. package/build/dex/spark/utils.js +23 -0
  118. package/build/dex/spark/utils.js.map +1 -1
  119. package/build/dex/stable-pool.d.ts +28 -0
  120. package/build/dex/stable-pool.js +62 -0
  121. package/build/dex/stable-pool.js.map +1 -0
  122. package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
  123. package/build/dex/swaap-v1/swaap-v1.js +0 -10
  124. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  125. package/build/dex/trader-joe-v2.1/optimizer.d.ts +2 -0
  126. package/build/dex/trader-joe-v2.1/optimizer.js +47 -0
  127. package/build/dex/trader-joe-v2.1/optimizer.js.map +1 -0
  128. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +7 -0
  129. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +20 -0
  130. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +1 -0
  131. package/build/dex/trader-joe-v2.1.d.ts +43 -0
  132. package/build/dex/trader-joe-v2.1.js +79 -0
  133. package/build/dex/trader-joe-v2.1.js.map +1 -0
  134. package/build/dex/uniswap-v4/config.d.ts +3 -0
  135. package/build/dex/uniswap-v4/config.js +58 -0
  136. package/build/dex/uniswap-v4/config.js.map +1 -0
  137. package/build/dex/uniswap-v4/constants.d.ts +7 -0
  138. package/build/dex/uniswap-v4/constants.js +18 -0
  139. package/build/dex/uniswap-v4/constants.js.map +1 -0
  140. package/build/dex/uniswap-v4/contract-math/BitMath.d.ts +4 -0
  141. package/build/dex/uniswap-v4/contract-math/BitMath.js +93 -0
  142. package/build/dex/uniswap-v4/contract-math/BitMath.js.map +1 -0
  143. package/build/dex/uniswap-v4/contract-math/FixedPoint128.d.ts +3 -0
  144. package/build/dex/uniswap-v4/contract-math/FixedPoint128.js +8 -0
  145. package/build/dex/uniswap-v4/contract-math/FixedPoint128.js.map +1 -0
  146. package/build/dex/uniswap-v4/contract-math/FixedPoint96.d.ts +4 -0
  147. package/build/dex/uniswap-v4/contract-math/FixedPoint96.js +9 -0
  148. package/build/dex/uniswap-v4/contract-math/FixedPoint96.js.map +1 -0
  149. package/build/dex/uniswap-v4/contract-math/FullMath.d.ts +4 -0
  150. package/build/dex/uniswap-v4/contract-math/FullMath.js +19 -0
  151. package/build/dex/uniswap-v4/contract-math/FullMath.js.map +1 -0
  152. package/build/dex/uniswap-v4/contract-math/LiquidityMath.d.ts +3 -0
  153. package/build/dex/uniswap-v4/contract-math/LiquidityMath.js +22 -0
  154. package/build/dex/uniswap-v4/contract-math/LiquidityMath.js.map +1 -0
  155. package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.d.ts +10 -0
  156. package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.js +91 -0
  157. package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.js.map +1 -0
  158. package/build/dex/uniswap-v4/contract-math/SwapMath.d.ts +8 -0
  159. package/build/dex/uniswap-v4/contract-math/SwapMath.js +70 -0
  160. package/build/dex/uniswap-v4/contract-math/SwapMath.js.map +1 -0
  161. package/build/dex/uniswap-v4/contract-math/TickBitMap.d.ts +7 -0
  162. package/build/dex/uniswap-v4/contract-math/TickBitMap.js +86 -0
  163. package/build/dex/uniswap-v4/contract-math/TickBitMap.js.map +1 -0
  164. package/build/dex/uniswap-v4/contract-math/TickMath.d.ts +8 -0
  165. package/build/dex/uniswap-v4/contract-math/TickMath.js +162 -0
  166. package/build/dex/uniswap-v4/contract-math/TickMath.js.map +1 -0
  167. package/build/dex/uniswap-v4/contract-math/UnsafeMath.d.ts +3 -0
  168. package/build/dex/uniswap-v4/contract-math/UnsafeMath.js +10 -0
  169. package/build/dex/uniswap-v4/contract-math/UnsafeMath.js.map +1 -0
  170. package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.d.ts +8 -0
  171. package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.js +11 -0
  172. package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.js.map +1 -0
  173. package/build/dex/uniswap-v4/encoder.d.ts +16 -0
  174. package/build/dex/uniswap-v4/encoder.js +104 -0
  175. package/build/dex/uniswap-v4/encoder.js.map +1 -0
  176. package/build/dex/uniswap-v4/subgraph.d.ts +5 -0
  177. package/build/dex/uniswap-v4/subgraph.js +80 -0
  178. package/build/dex/uniswap-v4/subgraph.js.map +1 -0
  179. package/build/dex/uniswap-v4/types.d.ts +64 -0
  180. package/build/dex/uniswap-v4/types.js +3 -0
  181. package/build/dex/uniswap-v4/types.js.map +1 -0
  182. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.d.ts +33 -0
  183. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js +152 -0
  184. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js.map +1 -0
  185. package/build/dex/uniswap-v4/uniswap-v4.d.ts +38 -0
  186. package/build/dex/uniswap-v4/uniswap-v4.js +169 -0
  187. package/build/dex/uniswap-v4/uniswap-v4.js.map +1 -0
  188. package/build/dex/uniswap-v4/utils.d.ts +2 -0
  189. package/build/dex/uniswap-v4/utils.js +15 -0
  190. package/build/dex/uniswap-v4/utils.js.map +1 -0
  191. package/build/dex/zerox/index.d.ts +26 -4
  192. package/build/dex/zerox/index.js +42 -50
  193. package/build/dex/zerox/index.js.map +1 -1
  194. package/build/dex/zerox/types.d.ts +0 -29
  195. package/build/dex/zerox/types.js +1 -8
  196. package/build/dex/zerox/types.js.map +1 -1
  197. package/package.json +1 -1
  198. package/src/abi/sdai/PSM3.abi.json +721 -0
  199. package/src/abi/sdai/SSRAuthOracle.abi.json +522 -0
  200. package/src/dex/index.ts +2 -0
  201. package/src/dex/spark/config.ts +15 -2
  202. package/src/dex/spark/spark-e2e.test.ts +130 -13
  203. package/src/dex/spark/spark-events.test.ts +97 -0
  204. package/src/dex/spark/spark-integration.test.ts +256 -0
  205. package/src/dex/spark/spark-psm.ts +361 -0
  206. package/src/dex/spark/spark-sdai-pool.ts +1 -2
  207. package/src/dex/spark/spark.ts +4 -3
  208. package/src/dex/spark/types.ts +17 -2
  209. package/src/dex/spark/utils.ts +41 -1
  210. package/tests/constants-e2e.ts +18 -3
  211. package/build/abi/Aave_GSM.json +0 -751
  212. package/build/abi/Balancer.json +0 -257
  213. package/build/abi/BalancerV2.json +0 -1179
  214. package/build/abi/RamsesV2Quoter.abi.json +0 -274
  215. package/build/abi/USDM.json +0 -807
  216. package/build/abi/UniswapV2Router.json +0 -397
  217. package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +0 -1246
  218. package/build/abi/curve-v1/CurveBUSDv2.abi.json +0 -1356
  219. package/build/abi/curve-v1/CurveTokenV1.json +0 -305
  220. package/build/abi/curve-v1/CurveTokenV2.json +0 -318
  221. package/build/abi/curve-v1/CurveV1StableNg.json +0 -1452
  222. package/build/abi/curve-v1/CurveV2Swap.json +0 -700
  223. package/build/abi/curve-v1/FactoryCryptoRegistry.json +0 -316
  224. package/build/abi/curve-v1/FactoryRegistry.json +0 -508
  225. package/build/abi/curve-v1/StableSwapAave.json +0 -1152
  226. package/build/abi/curve-v1/StableSwapBUSD.json +0 -814
  227. package/build/abi/curve-v1/StableSwapCompound.json +0 -814
  228. package/build/abi/curve-v1/StableSwapIDLE.json +0 -1253
  229. package/build/abi/curve-v1/StableSwapPax.json +0 -865
  230. package/build/abi/curve-v1/StableSwapSnow.json +0 -900
  231. package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
  232. package/build/abi/curve-v1/StableSwapY.json +0 -814
  233. package/build/abi/inception/inception-ineth-pool.json +0 -1062
  234. package/build/abi/inception/inception-ratio-feed.json +0 -329
  235. package/build/abi/inception/inception-vault.json +0 -991
  236. package/build/abi/kyberdmm/kyber-storage.abi.json +0 -824
  237. package/build/abi/kyberdmm.abi.json +0 -1148
  238. package/build/abi/maverick-v2/MaverickV2Quoter.json +0 -278
  239. package/build/abi/nerve/nerve-metapool.json +0 -790
  240. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  241. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
  242. package/build/dex/balancer-v1/balancer-pools.json +0 -33333
  243. package/build/dex/bebop/websocket-fetcher.d.ts +0 -35
  244. package/build/dex/bebop/websocket-fetcher.js +0 -87
  245. package/build/dex/bebop/websocket-fetcher.js.map +0 -1
  246. package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
  247. package/build/dex/idle-dao/idle-dao-pool.js +0 -176
  248. package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
  249. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
  250. package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
  251. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
  252. package/build/dex/idle-dao/scripts.d.ts +0 -9
  253. package/build/dex/idle-dao/scripts.js +0 -552
  254. package/build/dex/idle-dao/scripts.js.map +0 -1
  255. package/build/dex/inception/config.d.ts +0 -4
  256. package/build/dex/inception/config.js +0 -109
  257. package/build/dex/inception/config.js.map +0 -1
  258. package/build/dex/inception/inception-event-pool.d.ts +0 -16
  259. package/build/dex/inception/inception-event-pool.js +0 -51
  260. package/build/dex/inception/inception-event-pool.js.map +0 -1
  261. package/build/dex/inception/inception-native.js +0 -131
  262. package/build/dex/inception/inception-native.js.map +0 -1
  263. package/build/dex/inception/inception-pool.d.ts +0 -18
  264. package/build/dex/inception/inception-pool.js +0 -32
  265. package/build/dex/inception/inception-pool.js.map +0 -1
  266. package/build/dex/inception/inception-price-feed.d.ts +0 -19
  267. package/build/dex/inception/inception-price-feed.js +0 -51
  268. package/build/dex/inception/inception-price-feed.js.map +0 -1
  269. package/build/dex/inception/inception.d.ts +0 -43
  270. package/build/dex/inception/inception.js +0 -204
  271. package/build/dex/inception/inception.js.map +0 -1
  272. package/build/dex/inception/tokens.d.ts +0 -9
  273. package/build/dex/inception/tokens.js +0 -28
  274. package/build/dex/inception/tokens.js.map +0 -1
  275. package/build/dex/inception/types.d.ts +0 -22
  276. package/build/dex/inception/utils.d.ts +0 -6
  277. package/build/dex/inception/utils.js +0 -37
  278. package/build/dex/inception/utils.js.map +0 -1
  279. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -16
  280. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -16
  281. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -16
  282. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -16
  283. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -16
  284. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -16
  285. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -16
  286. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -16
  287. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -9
  288. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -9
  289. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -9
  290. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +0 -9
  291. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +0 -9
  292. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -9
  293. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +0 -9
  294. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +0 -9
  295. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +0 -9
  296. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -12
  297. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -7
  298. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -7
  299. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -7
  300. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -7
  301. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -12
  302. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +0 -7
  303. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +0 -7
  304. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -78
  305. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -81
  306. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -78
  307. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -78
  308. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -81
  309. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -81
  310. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -81
  311. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -81
  312. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -64
  313. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -85
  314. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -64
  315. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +0 -52
  316. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +0 -52
  317. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -52
  318. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +0 -55
  319. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +0 -55
  320. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +0 -55
  321. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -23
  322. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -37
  323. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -23
  324. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -23
  325. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -51
  326. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +0 -58
  327. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -23
  328. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -23
  329. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -9
  330. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -16
  331. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -23
  332. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -12
  333. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -7
  334. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -12
  335. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -12
  336. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -7
  337. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +0 -7
  338. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -7
  339. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -7
  340. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -7
  341. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -7
  342. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -130
  343. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -136
  344. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -100
  345. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -100
  346. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -166
  347. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +0 -190
  348. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -114
  349. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -114
  350. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -55
  351. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -73
  352. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -82
  353. /package/build/dex/{inception → m-token}/types.js +0 -0
@@ -1,43 +1,41 @@
1
- import { Interface } from '@ethersproject/abi';
2
- import { AsyncOrSync } from 'ts-essentials';
3
- import { NumberAsString, SwapSide } from '@paraswap/core';
4
- import { AdapterExchangeParam, Address, DexExchangeParam, ExchangePrices, Logger, PoolLiquidity, PoolPrices, Token } from '../../types';
5
- import { Network } from '../../constants';
6
- import { IDex } from '../../dex/idex';
1
+ import { Token, Address, ExchangePrices, AdapterExchangeParam, PoolLiquidity, Logger, PoolPrices, NumberAsString, DexExchangeParam } from '../../types';
2
+ import { SwapSide, Network } from '../../constants';
3
+ import { Context, IDex } from '../idex';
7
4
  import { IDexHelper } from '../../dex-helper/idex-helper';
8
- import { InceptionData } from './types';
5
+ import { IntegralData, QuotingProps } from './types';
9
6
  import { SimpleExchange } from '../simple-exchange';
10
- import { InceptionPool } from './inception-pool';
11
- export declare const depositETHFunction = "stake()";
12
- export declare class InceptionNative extends SimpleExchange implements IDex<InceptionData> {
7
+ export declare class Integral extends SimpleExchange implements IDex<IntegralData> {
13
8
  readonly network: Network;
14
9
  readonly dexKey: string;
15
10
  readonly dexHelper: IDexHelper;
16
- protected config: import("./types").DexParams;
17
11
  protected adapters: import("../../types").AdapterMappings;
18
- protected inceptionPool: InceptionPool;
19
- protected vaultInterface: Interface;
20
- protected tokenInterface: Interface;
12
+ protected subgraphURL: string | undefined;
21
13
  readonly hasConstantPriceLargeAmounts = false;
22
- readonly needWrapNative = false;
14
+ private readonly context;
23
15
  readonly isFeeOnTransferSupported = false;
24
16
  static dexKeysWithNetwork: {
25
17
  key: string;
26
18
  networks: Network[];
27
19
  }[];
28
20
  logger: Logger;
29
- constructor(network: Network, dexKey: string, dexHelper: IDexHelper, config?: import("./types").DexParams, adapters?: import("../../types").AdapterMappings);
21
+ constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings);
30
22
  initializePricing(blockNumber: number): Promise<void>;
31
23
  getAdapters(side: SwapSide): {
32
24
  name: string;
33
25
  index: number;
34
26
  }[] | null;
35
27
  getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
36
- getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<InceptionData>>;
37
- getCalldataGasCost(poolPrices: PoolPrices<InceptionData>): number | number[];
38
- getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: InceptionData, side: SwapSide): AdapterExchangeParam;
39
- getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: InceptionData, side: SwapSide): DexExchangeParam;
28
+ getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<IntegralData>>;
29
+ getCalldataGasCost(poolPrices: PoolPrices<IntegralData>): number | number[];
30
+ getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: IntegralData, side: SwapSide): AdapterExchangeParam;
31
+ getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: IntegralData, side: SwapSide, _: Context, executorAddress: Address): DexExchangeParam;
40
32
  updatePoolState(): Promise<void>;
41
33
  getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
42
- releaseResources(): AsyncOrSync<void>;
34
+ getPriceOnChain(tokenIn: Token, tokenOut: Token, inverted: boolean, blockNumber: number): Promise<QuotingProps | null>;
35
+ private getQuotingProps;
36
+ private quoteSell;
37
+ private quoteBuy;
38
+ private checkLimits;
39
+ private getStates;
40
+ private getMaxLimits;
43
41
  }
@@ -0,0 +1,376 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.Integral = void 0;
30
+ const lodash_1 = __importDefault(require("lodash"));
31
+ const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
32
+ const constants_1 = require("../../constants");
33
+ const utils_1 = require("../../utils");
34
+ const types_1 = require("./types");
35
+ const simple_exchange_1 = require("../simple-exchange");
36
+ const config_1 = require("./config");
37
+ const relayer_json_1 = __importDefault(require("../../abi/integral/relayer.json"));
38
+ const abi_1 = require("@ethersproject/abi");
39
+ const bigint_constants_1 = require("../../bigint-constants");
40
+ const utils_2 = require("./utils");
41
+ const context_1 = require("./context");
42
+ const utils_3 = require("./utils");
43
+ const PRECISION = bigint_constants_1.BI_POWS[18];
44
+ const SUBGRAPH_TIMEOUT = 20 * 1000;
45
+ const SWAP_ORDER_TIMEOUT = Math.floor(Date.now() / 1000) + 24 * 3600;
46
+ const relayerInterface = new abi_1.Interface(relayer_json_1.default);
47
+ class Integral extends simple_exchange_1.SimpleExchange {
48
+ constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network] || {}) {
49
+ super(dexHelper, dexKey);
50
+ this.network = network;
51
+ this.dexKey = dexKey;
52
+ this.dexHelper = dexHelper;
53
+ this.adapters = adapters;
54
+ this.hasConstantPriceLargeAmounts = false;
55
+ this.isFeeOnTransferSupported = false;
56
+ this.logger = dexHelper.getLogger(dexKey);
57
+ this.context = context_1.IntegralContext.initialize(network, dexKey, dexHelper, this.erc20Interface, config_1.IntegralConfig[dexKey][network].factoryAddress.toLowerCase(), config_1.IntegralConfig[dexKey][network].relayerAddress.toLowerCase());
58
+ this.subgraphURL = config_1.IntegralConfig[dexKey][network].subgraphURL;
59
+ }
60
+ async initializePricing(blockNumber) {
61
+ await this.context.factory.initialize(blockNumber);
62
+ const factoryState = this.context.factory.getState(blockNumber);
63
+ if (factoryState) {
64
+ await this.context.addPools(factoryState.pools, blockNumber, true);
65
+ }
66
+ }
67
+ // Returns the list of contract adapters (name and index)
68
+ // for a buy/sell. Return null if there are no adapters.
69
+ getAdapters(side) {
70
+ return this.adapters[side] ? this.adapters[side] : null;
71
+ }
72
+ async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
73
+ const src = this.dexHelper.config.wrapETH(srcToken);
74
+ const dest = this.dexHelper.config.wrapETH(destToken);
75
+ if (src.address.toLowerCase() === dest.address.toLowerCase()) {
76
+ return [];
77
+ }
78
+ const tokenAddresses = [
79
+ src.address.toLowerCase(),
80
+ dest.address.toLowerCase(),
81
+ ]
82
+ .sort((a, b) => (a > b ? 1 : -1))
83
+ .join('_');
84
+ const poolIdentifier = `${this.dexKey}_${tokenAddresses}`;
85
+ return [poolIdentifier];
86
+ }
87
+ // Returns pool prices for amounts.
88
+ // If limitPools is defined only pools in limitPools
89
+ // should be used. If limitPools is undefined then
90
+ // any pools can be used.
91
+ async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
92
+ const src = this.dexHelper.config.wrapETH(srcToken);
93
+ const dest = this.dexHelper.config.wrapETH(destToken);
94
+ if (src.address.toLowerCase() === dest.address.toLowerCase()) {
95
+ return null;
96
+ }
97
+ const poolIdentifier = (0, utils_2.getPoolIdentifier)(this.dexKey, src.address, dest.address);
98
+ if (limitPools && limitPools.every(p => p !== poolIdentifier)) {
99
+ return null;
100
+ }
101
+ const props = await this.getQuotingProps(src, dest, blockNumber);
102
+ if (!props) {
103
+ return null;
104
+ }
105
+ const unitAmount = (0, utils_1.getBigIntPow)(side == constants_1.SwapSide.SELL ? src.decimals : dest.decimals);
106
+ const unit = side == constants_1.SwapSide.SELL
107
+ ? this.quoteSell(unitAmount, props, false)
108
+ : this.quoteBuy(unitAmount, props, false);
109
+ try {
110
+ const prices = side == constants_1.SwapSide.SELL
111
+ ? amounts.map(amount => this.quoteSell(amount, props))
112
+ : amounts.map(amount => this.quoteBuy(amount, props));
113
+ return [
114
+ {
115
+ prices: prices,
116
+ unit: unit,
117
+ data: {
118
+ relayer: this.context.relayerAddress,
119
+ },
120
+ exchange: this.dexKey,
121
+ poolIdentifier,
122
+ gasCost: 350000,
123
+ poolAddresses: [props.poolAddress],
124
+ },
125
+ ];
126
+ }
127
+ catch (e) {
128
+ this.logger.error(`Error_getPricesVolume could not get price with error:`, e);
129
+ return null;
130
+ }
131
+ }
132
+ // Returns estimated gas cost of calldata for this DEX in multiSwap
133
+ getCalldataGasCost(poolPrices) {
134
+ return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
135
+ }
136
+ // Encode params required by the exchange adapter
137
+ // Used for multiSwap, buy & megaSwap
138
+ // Hint: abiCoder.encodeParameter() could be useful
139
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
140
+ const { relayer: exchange } = data;
141
+ // Encode here the payload for adapter
142
+ const payload = '0x';
143
+ return {
144
+ targetExchange: exchange,
145
+ payload,
146
+ networkFee: '0',
147
+ };
148
+ }
149
+ getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side, _, executorAddress) {
150
+ const tokenIn = this.dexHelper.config.wrapETH(srcToken);
151
+ const tokenOut = this.dexHelper.config.wrapETH(destToken);
152
+ const swapData = relayerInterface.encodeFunctionData(side === constants_1.SwapSide.SELL ? types_1.IntegralFunctions.swap : types_1.IntegralFunctions.buy, [
153
+ {
154
+ ...{
155
+ tokenIn,
156
+ tokenOut,
157
+ wrapUnwrap: (0, utils_1.isETHAddress)(srcToken) || (0, utils_1.isETHAddress)(destToken),
158
+ to: recipient,
159
+ submitDeadline: SWAP_ORDER_TIMEOUT,
160
+ },
161
+ ...(side === constants_1.SwapSide.SELL
162
+ ? { amountIn: srcAmount, amountOutMin: destAmount }
163
+ : { amountInMax: srcAmount, amountOut: destAmount }),
164
+ },
165
+ ]);
166
+ return {
167
+ needWrapNative: this.needWrapNative,
168
+ dexFuncHasRecipient: true,
169
+ exchangeData: swapData,
170
+ targetExchange: this.context.relayerAddress,
171
+ returnAmountPos: undefined,
172
+ };
173
+ }
174
+ async updatePoolState() { }
175
+ async getTopPoolsForToken(tokenAddress, limit) {
176
+ if (!this.subgraphURL) {
177
+ return [];
178
+ }
179
+ const query = `
180
+ query ($token: Bytes!, $limit: Int) {
181
+ pools0: pairs(
182
+ first: $limit
183
+ orderBy: reserveUSD
184
+ orderDirection: desc
185
+ where: {token0: $token}
186
+ ) {
187
+ id
188
+ token0 {
189
+ id
190
+ decimals
191
+ }
192
+ token1 {
193
+ id
194
+ decimals
195
+ }
196
+ reserveUSD
197
+ }
198
+ pools1: pairs(
199
+ first: $limit
200
+ orderBy: reserveUSD
201
+ orderDirection: desc
202
+ where: {token1: $token}
203
+ ) {
204
+ id
205
+ token0 {
206
+ id
207
+ decimals
208
+ }
209
+ token1 {
210
+ id
211
+ decimals
212
+ }
213
+ reserveUSD
214
+ }
215
+ }`;
216
+ const { data } = await this.dexHelper.httpRequest.querySubgraph(this.subgraphURL, {
217
+ query,
218
+ variables: { token: tokenAddress.toLowerCase(), limit },
219
+ }, { timeout: SUBGRAPH_TIMEOUT });
220
+ if (!(data && data.pools0 && data.pools1))
221
+ throw new Error("Couldn't fetch the pools from the subgraph");
222
+ const pools0 = lodash_1.default.map(data.pools0, pool => ({
223
+ exchange: this.dexKey,
224
+ address: pool.id.toLowerCase(),
225
+ connectorTokens: [
226
+ {
227
+ address: pool.token1.id.toLowerCase(),
228
+ decimals: parseInt(pool.token1.decimals),
229
+ },
230
+ ],
231
+ liquidityUSD: parseFloat(pool.reserveUSD),
232
+ }));
233
+ const pools1 = lodash_1.default.map(data.pools1, pool => ({
234
+ exchange: this.dexKey,
235
+ address: pool.id.toLowerCase(),
236
+ connectorTokens: [
237
+ {
238
+ address: pool.token0.id.toLowerCase(),
239
+ decimals: parseInt(pool.token0.decimals),
240
+ },
241
+ ],
242
+ liquidityUSD: parseFloat(pool.reserveUSD),
243
+ }));
244
+ return lodash_1.default.slice(lodash_1.default.sortBy(lodash_1.default.concat(pools0, pools1), [pool => -1 * pool.liquidityUSD]), 0, limit);
245
+ }
246
+ async getPriceOnChain(tokenIn, tokenOut, inverted, blockNumber) {
247
+ try {
248
+ const calldata = [
249
+ {
250
+ target: this.context.relayerAddress,
251
+ callData: relayerInterface.encodeFunctionData('getPoolState', [
252
+ tokenIn.address,
253
+ tokenOut.address,
254
+ ]),
255
+ },
256
+ ];
257
+ const data = await this.dexHelper.multiContract.methods
258
+ .aggregate(calldata)
259
+ .call({}, blockNumber);
260
+ const result = relayerInterface.decodeFunctionResult('getPoolState', data.returnData[0]);
261
+ const _limits = inverted
262
+ ? [result.limitMin1, result.limitMax1]
263
+ : [result.limitMin0, result.limitMax0];
264
+ const limits = [
265
+ BigInt(_limits[0].toString()),
266
+ BigInt(_limits[1].toString()),
267
+ ];
268
+ const [decimals0, decimals1] = inverted
269
+ ? [tokenOut.decimals, tokenIn.decimals]
270
+ : [tokenIn.decimals, tokenOut.decimals];
271
+ return {
272
+ price: BigInt(result.price.toString()),
273
+ poolAddress: result.poolAddress,
274
+ fee: BigInt(result.fee.toString()),
275
+ tokenOutLimits: limits,
276
+ decimalsConverter: (0, utils_2.getDecimalsConverter)(decimals0, decimals1, inverted),
277
+ };
278
+ }
279
+ catch (e) {
280
+ this.logger.error(`Error_getPriceOnChain could not get data with error:`, e);
281
+ return null;
282
+ }
283
+ }
284
+ async getQuotingProps(src, dest, blockNumber) {
285
+ const poolId = (0, utils_2.getPoolIdentifier)(this.dexKey, src.address, dest.address);
286
+ const inverted = (0, utils_2.isInverted)(src.address, dest.address);
287
+ const states = this.getStates(poolId, blockNumber);
288
+ if (!states) {
289
+ const resp = await this.getPriceOnChain(src, dest, inverted, blockNumber);
290
+ return resp;
291
+ }
292
+ const { base, poolAddress, relayer, relayerTokens } = states;
293
+ const price = (0, utils_2.getPrice)(states, inverted);
294
+ const token0 = (0, utils_2.sortTokens)(src.address, dest.address)[0];
295
+ const { max0, max1 } = this.getMaxLimits(poolAddress, relayer, relayerTokens);
296
+ return {
297
+ price,
298
+ poolAddress: states.poolAddress,
299
+ fee: relayer.swapFee,
300
+ tokenOutLimits: dest.address === token0
301
+ ? [relayer.limits.min0, max0]
302
+ : [relayer.limits.min1, max1],
303
+ decimalsConverter: (0, utils_2.getDecimalsConverter)(base.decimals0, base.decimals1, inverted),
304
+ };
305
+ }
306
+ quoteSell(amountIn, props, checkLimit = true) {
307
+ if (amountIn === 0n) {
308
+ return 0n;
309
+ }
310
+ const fee = (amountIn * props.fee) / PRECISION;
311
+ const amountInMinusFee = amountIn - fee;
312
+ const amountOut = (amountInMinusFee * props.price) / props.decimalsConverter;
313
+ if (checkLimit && !this.checkLimits(amountOut, props.tokenOutLimits)) {
314
+ return 0n;
315
+ // throw new Error(
316
+ // `Out of Limits - amountOut ${amountOut} not in between limits ${props.tokenOutLimits}`,
317
+ // );
318
+ }
319
+ return amountOut;
320
+ }
321
+ quoteBuy(amountOut, props, checkLimit = true) {
322
+ if (amountOut === 0n) {
323
+ return 0n;
324
+ }
325
+ if (checkLimit && !this.checkLimits(amountOut, props.tokenOutLimits)) {
326
+ return 0n;
327
+ // throw new Error(
328
+ // `Out of Limits - amountOut ${amountOut} not in between limits ${props.tokenOutLimits}`,
329
+ // );
330
+ }
331
+ const amountIn = (0, utils_3.ceil_div)(amountOut * props.decimalsConverter, props.price);
332
+ if (amountIn <= 0n) {
333
+ return 0n;
334
+ }
335
+ const amountInPlusFee = (0, utils_3.ceil_div)(amountIn * PRECISION, PRECISION - props.fee);
336
+ return amountInPlusFee;
337
+ }
338
+ checkLimits(amount, limits) {
339
+ if (amount < limits[0] || amount > limits[1]) {
340
+ return false;
341
+ }
342
+ return true;
343
+ }
344
+ getStates(poolId, blockNumber) {
345
+ const poolStates = this.context.pools[poolId];
346
+ if (poolStates && poolStates.base) {
347
+ const base = poolStates.base.getState(blockNumber);
348
+ const pricing = poolStates.pricing && poolStates.pricing.getState(blockNumber);
349
+ const relayerState = this.context.relayer.getState(blockNumber);
350
+ const relayer = relayerState && relayerState.pools[poolStates.base.poolAddress];
351
+ return base && pricing && relayer
352
+ ? {
353
+ base,
354
+ pricing,
355
+ relayer,
356
+ relayerTokens: relayerState.tokens,
357
+ poolAddress: poolStates.base.poolAddress,
358
+ }
359
+ : null;
360
+ }
361
+ else {
362
+ return null;
363
+ }
364
+ }
365
+ getMaxLimits(poolAddress, relayer, relayerTokens) {
366
+ const { token0, token1 } = this.context.relayer.getPools()[poolAddress.toLowerCase()];
367
+ const max0 = (relayerTokens[token0].balance * relayer.limits.maxMultiplier0) /
368
+ 10n ** 18n;
369
+ const max1 = (relayerTokens[token1].balance * relayer.limits.maxMultiplier1) /
370
+ 10n ** 18n;
371
+ return { max0, max1 };
372
+ }
373
+ }
374
+ exports.Integral = Integral;
375
+ Integral.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.IntegralConfig);
376
+ //# sourceMappingURL=integral.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integral.js","sourceRoot":"","sources":["../../../src/dex/integral/integral.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAuB;AAEvB,2EAA6D;AAY7D,+CAAoD;AACpD,uCAAgF;AAGhF,mCAOiB;AACjB,wDAAoD;AACpD,qCAAoD;AACpD,mFAAiE;AACjE,4CAA+C;AAC/C,6DAAiD;AACjD,mCAMiB;AACjB,uCAA4C;AAC5C,mCAAmC;AAEnC,MAAM,SAAS,GAAG,0BAAO,CAAC,EAAE,CAAC,CAAC;AAC9B,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,CAAC;AACnC,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACrE,MAAM,gBAAgB,GAAG,IAAI,eAAS,CAAC,sBAAkB,CAAC,CAAC;AAE3D,MAAa,QAAS,SAAQ,gCAAc;IAY1C,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB,EACpB,WAAW,iBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;QAE5C,KAAK,CAAC,SAAS,EAAE,M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AI,CAAC,WAAW;iBACzC;gBACH,CAAC,CAAC,IAAI,CAAC;SACV;aAAM;YACL,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAEO,YAAY,CAClB,WAAoB,EACpB,OAAyB,EACzB,aAAiC;QAEjC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GACtB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC;QAC7D,MAAM,IAAI,GACR,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC;YAC/D,GAAG,IAAI,GAAG,CAAC;QACb,MAAM,IAAI,GACR,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC;YAC/D,GAAG,IAAI,GAAG,CAAC;QACb,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,CAAC;;AAzdH,4BA0dC;AAnde,2BAAkB,GAC9B,IAAA,6BAAqB,EAAC,uBAAc,CAAC,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { Address } from '../../types';
2
+ import { IntegralEventPool } from './integral-pool';
3
+ import { PoolState as UniswapPoolState } from '../uniswap-v3/types';
4
+ import { BigNumber } from 'ethers';
5
+ import { IntegralPricing } from './integral-pricing';
6
+ export declare type Requires<Class, Prop extends keyof Class> = Class & Required<Pick<Class, Prop>>;
7
+ export declare type IntegralPool = {
8
+ base?: IntegralEventPool;
9
+ pricing?: IntegralPricing;
10
+ enabled: boolean;
11
+ };
12
+ export declare type QuotingProps = {
13
+ poolAddress: Address;
14
+ price: bigint;
15
+ fee: bigint;
16
+ tokenOutLimits: [bigint, bigint];
17
+ decimalsConverter: bigint;
18
+ };
19
+ export declare type PoolState = {
20
+ swapFee: bigint;
21
+ mintFee: bigint;
22
+ burnFee: bigint;
23
+ decimals0: number;
24
+ decimals1: number;
25
+ oracle: Address;
26
+ uniswapPool: Address;
27
+ uniswapPoolFee: bigint;
28
+ };
29
+ export declare type RelayerPoolState = {
30
+ isEnabled: boolean;
31
+ swapFee: bigint;
32
+ twapInterval: number;
33
+ limits: {
34
+ min0: bigint;
35
+ min1: bigint;
36
+ maxMultiplier0: bigint;
37
+ maxMultiplier1: bigint;
38
+ };
39
+ };
40
+ export declare type RelayerTokensState = {
41
+ [tokenAddress: string]: {
42
+ balance: bigint;
43
+ };
44
+ };
45
+ export declare type RelayerState = {
46
+ pools: {
47
+ [poolAddress: string]: RelayerPoolState;
48
+ };
49
+ tokens: RelayerTokensState;
50
+ };
51
+ export declare type PoolInitProps = {
52
+ [poolAddress: string]: {
53
+ token0: Address;
54
+ token1: Address;
55
+ };
56
+ };
57
+ export declare type FactoryState = {
58
+ pools: PoolInitProps;
59
+ };
60
+ export declare type PoolStates = {
61
+ base: PoolState;
62
+ relayer: RelayerPoolState;
63
+ relayerTokens: RelayerTokensState;
64
+ pricing: UniswapPoolState;
65
+ poolAddress: Address;
66
+ };
67
+ export declare type TokenState = Record<string, never>;
68
+ export declare type IntegralData = {
69
+ relayer: Address;
70
+ };
71
+ export declare type DexParams = {
72
+ factoryAddress: string;
73
+ relayerAddress: string;
74
+ subgraphURL?: string;
75
+ };
76
+ export declare enum IntegralFunctions {
77
+ swap = "sell",
78
+ buy = "buy"
79
+ }
80
+ export declare type Observation = {
81
+ blockTimestamp: number;
82
+ initialized: boolean;
83
+ secondsPerLiquidityCumulativeX128: BigNumber;
84
+ tickCumulative: BigNumber;
85
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntegralFunctions = void 0;
4
+ var IntegralFunctions;
5
+ (function (IntegralFunctions) {
6
+ IntegralFunctions["swap"] = "sell";
7
+ IntegralFunctions["buy"] = "buy";
8
+ })(IntegralFunctions = exports.IntegralFunctions || (exports.IntegralFunctions = {}));
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/integral/types.ts"],"names":[],"mappings":";;;AA8EA,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,kCAAa,CAAA;IACb,gCAAW,CAAA;AACb,CAAC,EAHW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAG5B"}
@@ -0,0 +1,9 @@
1
+ import { Address } from '../../types';
2
+ import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
3
+ import { Provider } from '@ethersproject/providers';
4
+ export declare function updateEventSubscriber<SubscriberState>(eventSubscriber: StatefulEventSubscriber<SubscriberState>, subscribedAddress: Address[], fetchState: (blocknumber: number) => Promise<SubscriberState>, blockNumber: number, cacheKey: string, provider: Provider): Promise<void>;
5
+ export declare function checkEventSubscriber<SubscriberState>(eventSubscriber: StatefulEventSubscriber<SubscriberState>, fetchState: (blocknumber: number) => Promise<SubscriberState>, blockNumber: number, cacheKey: string, stateCompare?: (state: SubscriberState, expectedState: SubscriberState) => void): Promise<void>;
6
+ export declare function deepTypecast<T>(obj: any, checker: (val: any) => boolean, caster: (val: T) => any): any;
7
+ export declare function getSavedConfig<Config>(blockNumber: number, cacheKey: string): Config | undefined;
8
+ export declare function saveConfig<Config>(blockNumber: number, cacheKey: string, config: Config): void;
9
+ export declare function getSavedState<SubscriberState>(blockNumber: number, cacheKey: string): SubscriberState | undefined;