@paraswap/dex-lib 4.1.23 → 4.1.24-uni-v4.1

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 (340) hide show
  1. package/build/abi/integral/factory.json +333 -0
  2. package/build/abi/{angle-transmuter/ChainlinkEACAggregatorProxy.json → integral/oracle.json} +239 -247
  3. package/build/abi/{curve-v1/StableSwapUSDN.json → integral/pool.json} +487 -450
  4. package/build/abi/{RamsesV2Pool.abi.json → integral/relayer.json} +833 -851
  5. package/build/abi/uniswap-v4/pool-manager.abi.json +1367 -0
  6. package/build/abi/uniswap-v4/quoter.abi.json +461 -0
  7. package/build/abi/uniswap-v4/router.abi.json +230 -0
  8. package/build/abi/uniswap-v4/state-view.abi.json +365 -0
  9. package/build/dex/aave-v1/aave-v1.d.ts +1 -2
  10. package/build/dex/aave-v1/aave-v1.js +0 -22
  11. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  12. package/build/dex/bProtocol.d.ts +18 -0
  13. package/build/dex/bProtocol.js +39 -0
  14. package/build/dex/bProtocol.js.map +1 -0
  15. package/build/dex/bancor.d.ts +26 -0
  16. package/build/dex/bancor.js +58 -0
  17. package/build/dex/bancor.js.map +1 -0
  18. package/build/dex/compound.d.ts +18 -0
  19. package/build/dex/compound.js +46 -0
  20. package/build/dex/compound.js.map +1 -0
  21. package/build/dex/curve-v2.d.ts +58 -0
  22. package/build/dex/curve-v2.js +180 -0
  23. package/build/dex/curve-v2.js.map +1 -0
  24. package/build/dex/dodo-v1.d.ts +33 -0
  25. package/build/dex/dodo-v1.js +63 -0
  26. package/build/dex/dodo-v1.js.map +1 -0
  27. package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +49 -0
  28. package/build/dex/fluid-dex/fluid-dex-generate-pool.js +104 -0
  29. package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +1 -0
  30. package/build/dex/index.js +2 -0
  31. package/build/dex/index.js.map +1 -1
  32. package/build/dex/integral/config.d.ts +4 -0
  33. package/build/dex/integral/config.js +20 -0
  34. package/build/dex/integral/config.js.map +1 -0
  35. package/build/dex/integral/context.d.ts +40 -0
  36. package/build/dex/integral/context.js +158 -0
  37. package/build/dex/integral/context.js.map +1 -0
  38. package/build/dex/integral/integral-factory.d.ts +24 -0
  39. package/build/dex/integral/integral-factory.js +95 -0
  40. package/build/dex/integral/integral-factory.js.map +1 -0
  41. package/build/dex/integral/integral-pool.d.ts +50 -0
  42. package/build/dex/integral/integral-pool.js +149 -0
  43. package/build/dex/integral/integral-pool.js.map +1 -0
  44. package/build/dex/integral/integral-pricing.d.ts +18 -0
  45. package/build/dex/integral/integral-pricing.js +114 -0
  46. package/build/dex/integral/integral-pricing.js.map +1 -0
  47. package/build/dex/integral/integral-relayer.d.ts +42 -0
  48. package/build/dex/integral/integral-relayer.js +192 -0
  49. package/build/dex/integral/integral-relayer.js.map +1 -0
  50. package/build/dex/integral/integral-token.d.ts +27 -0
  51. package/build/dex/integral/integral-token.js +59 -0
  52. package/build/dex/integral/integral-token.js.map +1 -0
  53. package/build/dex/{inception/inception-native.d.ts → integral/integral.d.ts} +19 -21
  54. package/build/dex/integral/integral.js +376 -0
  55. package/build/dex/integral/integral.js.map +1 -0
  56. package/build/dex/integral/types.d.ts +85 -0
  57. package/build/dex/integral/types.js +9 -0
  58. package/build/dex/integral/types.js.map +1 -0
  59. package/build/dex/integral/utils-e2e.d.ts +9 -0
  60. package/build/dex/integral/utils-e2e.js +131 -0
  61. package/build/dex/integral/utils-e2e.js.map +1 -0
  62. package/build/dex/integral/utils.d.ts +17 -0
  63. package/build/dex/integral/utils.js +94 -0
  64. package/build/dex/integral/utils.js.map +1 -0
  65. package/build/dex/jarvis.d.ts +1 -2
  66. package/build/dex/jarvis.js +0 -58
  67. package/build/dex/jarvis.js.map +1 -1
  68. package/build/dex/lido.d.ts +19 -0
  69. package/build/dex/lido.js +42 -0
  70. package/build/dex/lido.js.map +1 -0
  71. package/build/dex/m-token/config.d.ts +3 -0
  72. package/build/dex/m-token/config.js +19 -0
  73. package/build/dex/m-token/config.js.map +1 -0
  74. package/build/dex/m-token/m-token.d.ts +29 -0
  75. package/build/dex/m-token/m-token.js +145 -0
  76. package/build/dex/m-token/m-token.js.map +1 -0
  77. package/build/dex/m-token/m-wrapped-m.d.ts +17 -0
  78. package/build/dex/m-token/m-wrapped-m.js +50 -0
  79. package/build/dex/m-token/m-wrapped-m.js.map +1 -0
  80. package/build/dex/m-token/types.d.ts +12 -0
  81. package/build/dex/{inception → m-token}/types.js.map +1 -1
  82. package/build/dex/onebit.d.ts +25 -0
  83. package/build/dex/onebit.js +42 -0
  84. package/build/dex/onebit.js.map +1 -0
  85. package/build/dex/platypus/platypus.d.ts +1 -2
  86. package/build/dex/platypus/platypus.js +0 -31
  87. package/build/dex/platypus/platypus.js.map +1 -1
  88. package/build/dex/smoothy.d.ts +26 -0
  89. package/build/dex/smoothy.js +48 -0
  90. package/build/dex/smoothy.js.map +1 -0
  91. package/build/dex/spark/susds-psm.d.ts +49 -0
  92. package/build/dex/spark/susds-psm.js +245 -0
  93. package/build/dex/spark/susds-psm.js.map +1 -0
  94. package/build/dex/stable-pool.d.ts +28 -0
  95. package/build/dex/stable-pool.js +62 -0
  96. package/build/dex/stable-pool.js.map +1 -0
  97. package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
  98. package/build/dex/swaap-v1/swaap-v1.js +0 -10
  99. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  100. package/build/dex/trader-joe-v2.1/optimizer.d.ts +2 -0
  101. package/build/dex/trader-joe-v2.1/optimizer.js +47 -0
  102. package/build/dex/trader-joe-v2.1/optimizer.js.map +1 -0
  103. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +7 -0
  104. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +20 -0
  105. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +1 -0
  106. package/build/dex/trader-joe-v2.1.d.ts +43 -0
  107. package/build/dex/trader-joe-v2.1.js +79 -0
  108. package/build/dex/trader-joe-v2.1.js.map +1 -0
  109. package/build/dex/uniswap-v4/config.d.ts +3 -0
  110. package/build/dex/uniswap-v4/config.js +58 -0
  111. package/build/dex/uniswap-v4/config.js.map +1 -0
  112. package/build/dex/uniswap-v4/constants.d.ts +9 -0
  113. package/build/dex/uniswap-v4/constants.js +18 -0
  114. package/build/dex/uniswap-v4/constants.js.map +1 -0
  115. package/build/dex/uniswap-v4/contract-math/BalanceDelta.d.ts +6 -0
  116. package/build/dex/uniswap-v4/contract-math/BalanceDelta.js +22 -0
  117. package/build/dex/uniswap-v4/contract-math/BalanceDelta.js.map +1 -0
  118. package/build/dex/uniswap-v4/contract-math/BitMath.d.ts +4 -0
  119. package/build/dex/uniswap-v4/contract-math/BitMath.js +53 -0
  120. package/build/dex/uniswap-v4/contract-math/BitMath.js.map +1 -0
  121. package/build/dex/uniswap-v4/contract-math/FixedPoint128.d.ts +3 -0
  122. package/build/dex/uniswap-v4/contract-math/FixedPoint128.js +8 -0
  123. package/build/dex/uniswap-v4/contract-math/FixedPoint128.js.map +1 -0
  124. package/build/dex/uniswap-v4/contract-math/FixedPoint96.d.ts +4 -0
  125. package/build/dex/uniswap-v4/contract-math/FixedPoint96.js +9 -0
  126. package/build/dex/uniswap-v4/contract-math/FixedPoint96.js.map +1 -0
  127. package/build/dex/uniswap-v4/contract-math/FullMath.d.ts +4 -0
  128. package/build/dex/uniswap-v4/contract-math/FullMath.js +20 -0
  129. package/build/dex/uniswap-v4/contract-math/FullMath.js.map +1 -0
  130. package/build/dex/uniswap-v4/contract-math/LPFeeLibrary.d.ts +13 -0
  131. package/build/dex/uniswap-v4/contract-math/LPFeeLibrary.js +35 -0
  132. package/build/dex/uniswap-v4/contract-math/LPFeeLibrary.js.map +1 -0
  133. package/build/dex/uniswap-v4/contract-math/LiquidityMath.d.ts +3 -0
  134. package/build/dex/uniswap-v4/contract-math/LiquidityMath.js +16 -0
  135. package/build/dex/uniswap-v4/contract-math/LiquidityMath.js.map +1 -0
  136. package/build/dex/uniswap-v4/contract-math/Position.d.ts +9 -0
  137. package/build/dex/uniswap-v4/contract-math/Position.js +39 -0
  138. package/build/dex/uniswap-v4/contract-math/Position.js.map +1 -0
  139. package/build/dex/uniswap-v4/contract-math/ProtocolFeeLibrary.d.ts +10 -0
  140. package/build/dex/uniswap-v4/contract-math/ProtocolFeeLibrary.js +28 -0
  141. package/build/dex/uniswap-v4/contract-math/ProtocolFeeLibrary.js.map +1 -0
  142. package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.d.ts +8 -0
  143. package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.js +67 -0
  144. package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.js.map +1 -0
  145. package/build/dex/uniswap-v4/contract-math/SwapMath.d.ts +10 -0
  146. package/build/dex/uniswap-v4/contract-math/SwapMath.js +63 -0
  147. package/build/dex/uniswap-v4/contract-math/SwapMath.js.map +1 -0
  148. package/build/dex/uniswap-v4/contract-math/Tick.d.ts +10 -0
  149. package/build/dex/uniswap-v4/contract-math/Tick.js +64 -0
  150. package/build/dex/uniswap-v4/contract-math/Tick.js.map +1 -0
  151. package/build/dex/uniswap-v4/contract-math/TickBitMap.d.ts +9 -0
  152. package/build/dex/uniswap-v4/contract-math/TickBitMap.js +64 -0
  153. package/build/dex/uniswap-v4/contract-math/TickBitMap.js.map +1 -0
  154. package/build/dex/uniswap-v4/contract-math/TickMath.d.ts +9 -0
  155. package/build/dex/uniswap-v4/contract-math/TickMath.js +83 -0
  156. package/build/dex/uniswap-v4/contract-math/TickMath.js.map +1 -0
  157. package/build/dex/uniswap-v4/contract-math/UnsafeMath.d.ts +4 -0
  158. package/build/dex/uniswap-v4/contract-math/UnsafeMath.js +17 -0
  159. package/build/dex/uniswap-v4/contract-math/UnsafeMath.js.map +1 -0
  160. package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.d.ts +8 -0
  161. package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.js +11 -0
  162. package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.js.map +1 -0
  163. package/build/dex/uniswap-v4/contract-math/uniswap-v4-pool-math.d.ts +29 -0
  164. package/build/dex/uniswap-v4/contract-math/uniswap-v4-pool-math.js +419 -0
  165. package/build/dex/uniswap-v4/contract-math/uniswap-v4-pool-math.js.map +1 -0
  166. package/build/dex/uniswap-v4/contract-math/utils.d.ts +3 -0
  167. package/build/dex/uniswap-v4/contract-math/utils.js +15 -0
  168. package/build/dex/uniswap-v4/contract-math/utils.js.map +1 -0
  169. package/build/dex/uniswap-v4/encoder.d.ts +17 -0
  170. package/build/dex/uniswap-v4/encoder.js +160 -0
  171. package/build/dex/uniswap-v4/encoder.js.map +1 -0
  172. package/build/dex/uniswap-v4/subgraph.d.ts +7 -0
  173. package/build/dex/uniswap-v4/subgraph.js +122 -0
  174. package/build/dex/uniswap-v4/subgraph.js.map +1 -0
  175. package/build/dex/uniswap-v4/types.d.ts +92 -0
  176. package/build/dex/uniswap-v4/types.js +3 -0
  177. package/build/dex/uniswap-v4/types.js.map +1 -0
  178. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.d.ts +31 -0
  179. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js +135 -0
  180. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js.map +1 -0
  181. package/build/dex/uniswap-v4/uniswap-v4-pool.d.ts +43 -0
  182. package/build/dex/uniswap-v4/uniswap-v4-pool.js +327 -0
  183. package/build/dex/uniswap-v4/uniswap-v4-pool.js.map +1 -0
  184. package/build/dex/uniswap-v4/uniswap-v4.d.ts +41 -0
  185. package/build/dex/uniswap-v4/uniswap-v4.js +205 -0
  186. package/build/dex/uniswap-v4/uniswap-v4.js.map +1 -0
  187. package/build/dex/uniswap-v4/utils.d.ts +2 -0
  188. package/build/dex/uniswap-v4/utils.js +15 -0
  189. package/build/dex/uniswap-v4/utils.js.map +1 -0
  190. package/build/dex/zerox/index.d.ts +26 -4
  191. package/build/dex/zerox/index.js +42 -50
  192. package/build/dex/zerox/index.js.map +1 -1
  193. package/build/dex/zerox/types.d.ts +0 -29
  194. package/build/dex/zerox/types.js +1 -8
  195. package/build/dex/zerox/types.js.map +1 -1
  196. package/package.json +1 -1
  197. package/build/abi/Aave_GSM.json +0 -751
  198. package/build/abi/Balancer.json +0 -257
  199. package/build/abi/BalancerV2.json +0 -1179
  200. package/build/abi/RamsesV2Quoter.abi.json +0 -274
  201. package/build/abi/USDM.json +0 -807
  202. package/build/abi/UniswapV2Router.json +0 -397
  203. package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +0 -1246
  204. package/build/abi/curve-v1/CurveBUSDv2.abi.json +0 -1356
  205. package/build/abi/curve-v1/CurveTokenV1.json +0 -305
  206. package/build/abi/curve-v1/CurveTokenV2.json +0 -318
  207. package/build/abi/curve-v1/CurveV1StableNg.json +0 -1452
  208. package/build/abi/curve-v1/CurveV2Swap.json +0 -700
  209. package/build/abi/curve-v1/FactoryCryptoRegistry.json +0 -316
  210. package/build/abi/curve-v1/FactoryRegistry.json +0 -508
  211. package/build/abi/curve-v1/StableSwapAave.json +0 -1152
  212. package/build/abi/curve-v1/StableSwapBUSD.json +0 -814
  213. package/build/abi/curve-v1/StableSwapCompound.json +0 -814
  214. package/build/abi/curve-v1/StableSwapIDLE.json +0 -1253
  215. package/build/abi/curve-v1/StableSwapPax.json +0 -865
  216. package/build/abi/curve-v1/StableSwapSnow.json +0 -900
  217. package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
  218. package/build/abi/curve-v1/StableSwapY.json +0 -814
  219. package/build/abi/inception/inception-ineth-pool.json +0 -1062
  220. package/build/abi/inception/inception-ineth.json +0 -609
  221. package/build/abi/inception/inception-ratio-feed.json +0 -329
  222. package/build/abi/inception/inception-vault.json +0 -991
  223. package/build/abi/kyberdmm/kyber-storage.abi.json +0 -824
  224. package/build/abi/kyberdmm.abi.json +0 -1148
  225. package/build/abi/maverick-v2/MaverickV2Quoter.json +0 -278
  226. package/build/abi/nerve/nerve-metapool.json +0 -790
  227. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  228. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
  229. package/build/dex/balancer-v1/balancer-pools.json +0 -33333
  230. package/build/dex/bebop/websocket-fetcher.d.ts +0 -35
  231. package/build/dex/bebop/websocket-fetcher.js +0 -87
  232. package/build/dex/bebop/websocket-fetcher.js.map +0 -1
  233. package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
  234. package/build/dex/idle-dao/idle-dao-pool.js +0 -176
  235. package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
  236. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
  237. package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
  238. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
  239. package/build/dex/idle-dao/scripts.d.ts +0 -9
  240. package/build/dex/idle-dao/scripts.js +0 -552
  241. package/build/dex/idle-dao/scripts.js.map +0 -1
  242. package/build/dex/inception/config.d.ts +0 -4
  243. package/build/dex/inception/config.js +0 -109
  244. package/build/dex/inception/config.js.map +0 -1
  245. package/build/dex/inception/inception-event-pool.d.ts +0 -16
  246. package/build/dex/inception/inception-event-pool.js +0 -51
  247. package/build/dex/inception/inception-event-pool.js.map +0 -1
  248. package/build/dex/inception/inception-native.js +0 -131
  249. package/build/dex/inception/inception-native.js.map +0 -1
  250. package/build/dex/inception/inception-pool.d.ts +0 -18
  251. package/build/dex/inception/inception-pool.js +0 -32
  252. package/build/dex/inception/inception-pool.js.map +0 -1
  253. package/build/dex/inception/inception-price-feed.d.ts +0 -19
  254. package/build/dex/inception/inception-price-feed.js +0 -51
  255. package/build/dex/inception/inception-price-feed.js.map +0 -1
  256. package/build/dex/inception/inception.d.ts +0 -43
  257. package/build/dex/inception/inception.js +0 -204
  258. package/build/dex/inception/inception.js.map +0 -1
  259. package/build/dex/inception/tokens.d.ts +0 -9
  260. package/build/dex/inception/tokens.js +0 -28
  261. package/build/dex/inception/tokens.js.map +0 -1
  262. package/build/dex/inception/types.d.ts +0 -22
  263. package/build/dex/inception/utils.d.ts +0 -6
  264. package/build/dex/inception/utils.js +0 -37
  265. package/build/dex/inception/utils.js.map +0 -1
  266. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -16
  267. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -16
  268. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -16
  269. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -16
  270. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -16
  271. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -16
  272. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -16
  273. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -16
  274. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -9
  275. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -9
  276. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -9
  277. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +0 -9
  278. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +0 -9
  279. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -9
  280. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +0 -9
  281. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +0 -9
  282. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +0 -9
  283. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -12
  284. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -7
  285. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -7
  286. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -7
  287. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -7
  288. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -12
  289. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +0 -7
  290. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +0 -7
  291. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -78
  292. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -81
  293. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -78
  294. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -78
  295. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -81
  296. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -81
  297. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -81
  298. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -81
  299. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -64
  300. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -85
  301. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -64
  302. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +0 -52
  303. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +0 -52
  304. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -52
  305. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +0 -55
  306. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +0 -55
  307. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +0 -55
  308. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -23
  309. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -37
  310. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -23
  311. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -23
  312. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -51
  313. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +0 -58
  314. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -23
  315. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -23
  316. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -9
  317. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -16
  318. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -23
  319. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -12
  320. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -7
  321. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -12
  322. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -12
  323. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -7
  324. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +0 -7
  325. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -7
  326. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -7
  327. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -7
  328. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -7
  329. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -130
  330. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -136
  331. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -100
  332. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -100
  333. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -166
  334. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +0 -190
  335. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -114
  336. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -114
  337. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -55
  338. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -73
  339. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -82
  340. /package/build/dex/{inception → m-token}/types.js +0 -0
@@ -0,0 +1,79 @@
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.TraderJoeV21 = void 0;
7
+ const constants_1 = require("../constants");
8
+ const simple_exchange_1 = require("./simple-exchange");
9
+ const abi_1 = require("@ethersproject/abi");
10
+ const TraderJoeV21Router_json_1 = __importDefault(require("../abi/TraderJoeV21Router.json"));
11
+ const TRADERJOE_V2_1_ROUTER_ADDRESS = {
12
+ [constants_1.Network.AVALANCHE]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
13
+ [constants_1.Network.ARBITRUM]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
14
+ [constants_1.Network.BSC]: '0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30',
15
+ [constants_1.Network.MAINNET]: '0x9A93a421b74F1c5755b83dD2C211614dC419C44b',
16
+ };
17
+ var TraderJoeV2RouterFunctions;
18
+ (function (TraderJoeV2RouterFunctions) {
19
+ TraderJoeV2RouterFunctions["swapExactTokensForTokens"] = "swapExactTokensForTokens";
20
+ TraderJoeV2RouterFunctions["swapTokensForExactTokens"] = "swapTokensForExactTokens";
21
+ })(TraderJoeV2RouterFunctions || (TraderJoeV2RouterFunctions = {}));
22
+ class TraderJoeV21 extends simple_exchange_1.SimpleExchange {
23
+ constructor(dexHelper) {
24
+ super(dexHelper, 'traderjoev2.1');
25
+ this.needWrapNative = true;
26
+ this.routerAddress =
27
+ TRADERJOE_V2_1_ROUTER_ADDRESS[dexHelper.config.data.network];
28
+ this.exchangeRouterInterface = new abi_1.Interface(TraderJoeV21Router_json_1.default);
29
+ }
30
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
31
+ let payload = this.abiCoder.encodeParameters(['tuple(tuple(uint256[],uint8[],address[]),uint256)'], [
32
+ [
33
+ [
34
+ [
35
+ data.binStep, // _pairBinSteps: uint256[]
36
+ ],
37
+ [
38
+ 2, // _versions: uint8[]
39
+ ],
40
+ [
41
+ data.tokenIn,
42
+ data.tokenOut, // _tokenPath: address[]
43
+ ],
44
+ ],
45
+ (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(), // _deadline: uint256
46
+ ],
47
+ ]);
48
+ return {
49
+ targetExchange: this.routerAddress,
50
+ payload,
51
+ networkFee: '0',
52
+ };
53
+ }
54
+ getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
55
+ const swapFunction = side === constants_1.SwapSide.SELL
56
+ ? TraderJoeV2RouterFunctions.swapExactTokensForTokens
57
+ : TraderJoeV2RouterFunctions.swapTokensForExactTokens;
58
+ const swapFunctionParams = side === constants_1.SwapSide.SELL
59
+ ? [
60
+ srcAmount,
61
+ destAmount,
62
+ [[data.binStep], ['2'], [srcToken, destToken]],
63
+ this.augustusAddress,
64
+ (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
65
+ ]
66
+ : [
67
+ destAmount,
68
+ srcAmount,
69
+ [[data.binStep], ['2'], [srcToken, destToken]],
70
+ this.augustusAddress,
71
+ (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
72
+ ];
73
+ const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
74
+ return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, this.routerAddress);
75
+ }
76
+ }
77
+ exports.TraderJoeV21 = TraderJoeV21;
78
+ TraderJoeV21.dexKeys = ['traderjoev2.1'];
79
+ //# sourceMappingURL=trader-joe-v2.1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trader-joe-v2.1.js","sourceRoot":"","sources":["../../src/dex/trader-joe-v2.1.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAiD;AAIjD,uDAG2B;AAG3B,4CAA6D;AAC7D,6FAAmE;AAEnE,MAAM,6BAA6B,GAAmC;IACpE,CAAC,mBAAO,CAAC,SAAS,CAAC,EAAE,4CAA4C;IACjE,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE,4CAA4C;IAChE,CAAC,mBAAO,CAAC,GAAG,CAAC,EAAE,4CAA4C;IAC3D,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,4CAA4C;CAChE,CAAC;AAiCF,IAAK,0BAGJ;AAHD,WAAK,0BAA0B;IAC7B,mFAAqD,CAAA;IACrD,mFAAqD,CAAA;AACvD,CAAC,EAHI,0BAA0B,KAA1B,0BAA0B,QAG9B;AACD,MAAa,YACX,SAAQ,gCAAc;IAQtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;QAHpC,mBAAc,GAAG,IAAI,CAAC;QAKpB,IAAI,CAAC,aAAa;YAChB,6BAA6B,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE/D,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAC1C,iCAAuC,CACxC,CAAC;IACJ,CAAC;IAED,eAAe,CACb,QAAiB,EACjB,SAAkB,EAClB,SAAyB,EACzB,UAA0B,EAC1B,IAAqB,EACrB,IAAc;QAEd,IAAI,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAC1C,CAAC,mDAAmD,CAAC,EACrD;YACE;gBACE;oBACE;wBACE,IAAI,CAAC,OAAO,EAAE,2BAA2B;qBAC1C;oBACD;wBACE,CAAC,EAAE,qBAAqB;qBACzB;oBACD;wBACE,IAAI,CAAC,OAAO;wBACZ,IAAI,CAAC,QAAQ,EAAE,wBAAwB;qBACxC;iBACF;gBACD,IAAA,uDAAqC,GAAE,EAAE,qBAAqB;aAC/D;SACF,CACF,CAAC;QAEF,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,aAAa;YAClC,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,cAAc,CACZ,QAAiB,EACjB,SAAkB,EAClB,SAAyB,EACzB,UAA0B,EAC1B,IAAqB,EACrB,IAAc;QAEd,MAAM,YAAY,GAChB,IAAI,KAAK,oBAAQ,CAAC,IAAI;YACpB,CAAC,CAAC,0BAA0B,CAAC,wBAAwB;YACrD,CAAC,CAAC,0BAA0B,CAAC,wBAAwB,CAAC;QAE1D,MAAM,kBAAkB,GACtB,IAAI,KAAK,oBAAQ,CAAC,IAAI;YACpB,CAAC,CAAC;gBACE,SAAS;gBACT,UAAU;gBACV,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;gBAC9C,IAAI,CAAC,eAAe;gBACpB,IAAA,uDAAqC,GAAE;aACxC;YACH,CAAC,CAAC;gBACE,UAAU;gBACV,SAAS;gBACT,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;gBAC9C,IAAI,CAAC,eAAe;gBACpB,IAAA,uDAAqC,GAAE;aACxC,CAAC;QAER,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;;AAnGH,oCAoGC;AAhGQ,oBAAO,GAAG,CAAC,eAAe,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { DexConfigMap } from '../../types';
2
+ import { DexParams } from './types';
3
+ export declare const UniswapV4Config: DexConfigMap<DexParams>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UniswapV4Config = void 0;
4
+ const constants_1 = require("../../constants");
5
+ exports.UniswapV4Config = {
6
+ UniswapV4: {
7
+ [constants_1.Network.MAINNET]: {
8
+ poolManager: '0x000000000004444c5dc75cB358380D2e3dE08A90',
9
+ subgraphURL: 'DiYPVdygkfjDWhbxGSqAQxwBKmfKnkWQojqeM2rkLb3G',
10
+ quoter: '0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203',
11
+ router: '0x66a9893cc07d91d95644aedd05d03f95e1dba8af',
12
+ stateView: '0x7ffe42c4a5deea5b0fec41c94c136cf115597227',
13
+ },
14
+ [constants_1.Network.BASE]: {
15
+ poolManager: '0x498581ff718922c3f8e6a244956af099b2652b2b',
16
+ subgraphURL: 'HNCFA9TyBqpo5qpe6QreQABAA1kV8g46mhkCcicu6v2R',
17
+ quoter: '0x0d5e0f971ed27fbff6c2837bf31316121532048d',
18
+ router: '0x6ff5693b99212da76ad316178a184ab56d299b43',
19
+ stateView: '0xa3c0c9b65bad0b08107aa264b0f3db444b867a71',
20
+ },
21
+ [constants_1.Network.OPTIMISM]: {
22
+ poolManager: '0x9a13f98cb987694c9f086b1f5eb990eea8264ec3',
23
+ subgraphURL: '6RBtsmGUYfeLeZsYyxyKSUiaA6WpuC69shMEQ1Cfuj9u',
24
+ quoter: '0x1f3131a13296fb91c90870043742c3cdbff1a8d7',
25
+ router: '0x851116d9223fabed8e56c0e6b8ad0c31d98b3507',
26
+ stateView: '0xc18a3169788f4f75a170290584eca6395c75ecdb',
27
+ },
28
+ [constants_1.Network.ARBITRUM]: {
29
+ poolManager: '0x360e68faccca8ca495c1b759fd9eee466db9fb32',
30
+ subgraphURL: 'G5TsTKNi8yhPSV7kycaE23oWbqv9zzNqR49FoEQjzq1r',
31
+ quoter: '0x3972c00f7ed4885e145823eb7c655375d275a1c5',
32
+ router: '0xa51afafe0263b40edaef0df8781ea9aa03e381a3',
33
+ stateView: '0x76fd297e2d437cd7f76d50f01afe6160f86e9990',
34
+ },
35
+ [constants_1.Network.POLYGON]: {
36
+ poolManager: '0x67366782805870060151383f4bbff9dab53e5cd6',
37
+ subgraphURL: 'CwpebM66AH5uqS5sreKij8yEkkPcHvmyEs7EwFtdM5ND',
38
+ quoter: '0xb3d5c3dfc3a7aebff71895a7191796bffc2c81b9',
39
+ router: '0x1095692a6237d83c6a72f3f5efedb9a670c49223',
40
+ stateView: '0x5ea1bd7974c8a611cbab0bdcafcb1d9cc9b3ba5a',
41
+ },
42
+ [constants_1.Network.AVALANCHE]: {
43
+ poolManager: '0x06380c0e0912312b5150364b9dc4542ba0dbbc85',
44
+ subgraphURL: '49JxRo9FGxWpSf5Y5GKQPj5NUpX2HhpoZHpGzNEWQZjq',
45
+ quoter: '0xbe40675bb704506a3c2ccfb762dcfd1e979845c2',
46
+ router: '0x94b75331ae8d42c1b61065089b7d48fe14aa73b7',
47
+ stateView: '0xc3c9e198c735a4b97e3e683f391ccbdd60b69286',
48
+ },
49
+ [constants_1.Network.BSC]: {
50
+ poolManager: '0x28e2ea090877bf75740558f6bfb36a5ffee9e9df',
51
+ subgraphURL: '2qQpC8inZPZL4tYfRQPFGZhsE8mYzE67n5z3Yf5uuKMu',
52
+ quoter: '0x9f75dd27d6664c475b90e105573e550ff69437b0',
53
+ router: '0x1906c1d672b88cd1b9ac7593301ca990f94eae07',
54
+ stateView: '0xd13dd3d6e93f276fafc9db9e6bb47c1180aee0c4',
55
+ },
56
+ },
57
+ };
58
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/uniswap-v4/config.ts"],"names":[],"mappings":";;;AACA,+CAA0C;AAG7B,QAAA,eAAe,GAA4B;IACtD,SAAS,EAAE;QACT,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,WAAW,EAAE,4CAA4C;YACzD,WAAW,EAAE,8CAA8C;YAC3D,MAAM,EAAE,4CAA4C;YACpD,MAAM,EAAE,4CAA4C;YACpD,SAAS,EAAE,4CAA4C;SACxD;QACD,CAAC,mBAAO,CAAC,IAAI,CAAC,EAAE;YACd,WAAW,EAAE,4CAA4C;YACzD,WAAW,EAAE,8CAA8C;YAC3D,MAAM,EAAE,4CAA4C;YACpD,MAAM,EAAE,4CAA4C;YACpD,SAAS,EAAE,4CAA4C;SACxD;QACD,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE;YAClB,WAAW,EAAE,4CAA4C;YACzD,WAAW,EAAE,8CAA8C;YAC3D,MAAM,EAAE,4CAA4C;YACpD,MAAM,EAAE,4CAA4C;YACpD,SAAS,EAAE,4CAA4C;SACxD;QACD,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE;YAClB,WAAW,EAAE,4CAA4C;YACzD,WAAW,EAAE,8CAA8C;YAC3D,MAAM,EAAE,4CAA4C;YACpD,MAAM,EAAE,4CAA4C;YACpD,SAAS,EAAE,4CAA4C;SACxD;QACD,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,WAAW,EAAE,4CAA4C;YACzD,WAAW,EAAE,8CAA8C;YAC3D,MAAM,EAAE,4CAA4C;YACpD,MAAM,EAAE,4CAA4C;YACpD,SAAS,EAAE,4CAA4C;SACxD;QACD,CAAC,mBAAO,CAAC,SAAS,CAAC,EAAE;YACnB,WAAW,EAAE,4CAA4C;YACzD,WAAW,EAAE,8CAA8C;YAC3D,MAAM,EAAE,4CAA4C;YACpD,MAAM,EAAE,4CAA4C;YACpD,SAAS,EAAE,4CAA4C;SACxD;QACD,CAAC,mBAAO,CAAC,GAAG,CAAC,EAAE;YACb,WAAW,EAAE,4CAA4C;YACzD,WAAW,EAAE,8CAA8C;YAC3D,MAAM,EAAE,4CAA4C;YACpD,MAAM,EAAE,4CAA4C;YACpD,SAAS,EAAE,4CAA4C;SACxD;KACF;CACF,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const TICK_BITMAP_TO_USE = 4n;
2
+ export declare const TICK_BITMAP_BUFFER = 8n;
3
+ export declare const TICK_BITMAP_TO_USE_BY_CHAIN: Record<number, bigint>;
4
+ export declare const TICK_BITMAP_BUFFER_BY_CHAIN: Record<number, bigint>;
5
+ export declare const OUT_OF_RANGE_ERROR_POSTFIX = "INVALID_TICK_BIT_MAP_RANGES";
6
+ export declare const SUBGRAPH_TIMEOUT: number;
7
+ export declare const POOL_CACHE_REFRESH_INTERVAL: number;
8
+ export declare const POOLS_INITIALIZATION_LIMIT = 5;
9
+ export declare const SWAP_EVENT_MAX_CYCLES = 10000;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SWAP_EVENT_MAX_CYCLES = exports.POOLS_INITIALIZATION_LIMIT = exports.POOL_CACHE_REFRESH_INTERVAL = exports.SUBGRAPH_TIMEOUT = exports.OUT_OF_RANGE_ERROR_POSTFIX = exports.TICK_BITMAP_BUFFER_BY_CHAIN = exports.TICK_BITMAP_TO_USE_BY_CHAIN = exports.TICK_BITMAP_BUFFER = exports.TICK_BITMAP_TO_USE = void 0;
4
+ const constants_1 = require("../../constants");
5
+ exports.TICK_BITMAP_TO_USE = 4n;
6
+ exports.TICK_BITMAP_BUFFER = 8n;
7
+ exports.TICK_BITMAP_TO_USE_BY_CHAIN = {
8
+ [constants_1.Network.MAINNET]: 8n,
9
+ };
10
+ exports.TICK_BITMAP_BUFFER_BY_CHAIN = {
11
+ [constants_1.Network.MAINNET]: 16n,
12
+ };
13
+ exports.OUT_OF_RANGE_ERROR_POSTFIX = `INVALID_TICK_BIT_MAP_RANGES`;
14
+ exports.SUBGRAPH_TIMEOUT = 30 * 1000;
15
+ exports.POOL_CACHE_REFRESH_INTERVAL = 60 * 60; // 1 hour
16
+ exports.POOLS_INITIALIZATION_LIMIT = 5;
17
+ exports.SWAP_EVENT_MAX_CYCLES = 10_000;
18
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/uniswap-v4/constants.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE7B,QAAA,kBAAkB,GAAG,EAAE,CAAC;AAExB,QAAA,kBAAkB,GAAG,EAAE,CAAC;AAExB,QAAA,2BAA2B,GAA2B;IACjE,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,EAAE;CACtB,CAAC;AAEW,QAAA,2BAA2B,GAA2B;IACjE,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,GAAG;CACvB,CAAC;AAEW,QAAA,0BAA0B,GAAG,6BAA6B,CAAC;AAE3D,QAAA,gBAAgB,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7B,QAAA,2BAA2B,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,SAAS;AAEhD,QAAA,0BAA0B,GAAG,CAAC,CAAC;AAE/B,QAAA,qBAAqB,GAAG,MAAM,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function toBalanceDelta(amount0: bigint, amount1: bigint): bigint;
2
+ export declare class BalanceDelta {
3
+ static readonly ZERO_DELTA = 0n;
4
+ static amount0(balanceDelta: bigint): bigint;
5
+ static amount1(balanceDelta: bigint): bigint;
6
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BalanceDelta = void 0;
4
+ exports.toBalanceDelta = toBalanceDelta;
5
+ function toBalanceDelta(amount0, amount1) {
6
+ const shiftedAmount0 = amount0 << 128n;
7
+ const mask = (1n << 128n) - 1n;
8
+ const maskedAmount1 = amount1 & mask;
9
+ const balanceDelta = shiftedAmount0 | maskedAmount1;
10
+ return balanceDelta;
11
+ }
12
+ class BalanceDelta {
13
+ static ZERO_DELTA = 0n;
14
+ static amount0(balanceDelta) {
15
+ return balanceDelta >> BigInt(128);
16
+ }
17
+ static amount1(balanceDelta) {
18
+ return BigInt.asIntN(128, balanceDelta);
19
+ }
20
+ }
21
+ exports.BalanceDelta = BalanceDelta;
22
+ //# sourceMappingURL=BalanceDelta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BalanceDelta.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/contract-math/BalanceDelta.ts"],"names":[],"mappings":";;;AAAA,wCAUC;AAVD,SAAgB,cAAc,CAAC,OAAe,EAAE,OAAe;IAC7D,MAAM,cAAc,GAAG,OAAO,IAAI,IAAI,CAAC;IAEvC,MAAM,IAAI,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAE/B,MAAM,aAAa,GAAG,OAAO,GAAG,IAAI,CAAC;IAErC,MAAM,YAAY,GAAG,cAAc,GAAG,aAAa,CAAC;IAEpD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAa,YAAY;IACvB,MAAM,CAAU,UAAU,GAAG,EAAE,CAAC;IAEhC,MAAM,CAAC,OAAO,CAAC,YAAoB;QACjC,OAAO,YAAY,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,YAAoB;QACjC,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAC1C,CAAC;;AATH,oCAUC"}
@@ -0,0 +1,4 @@
1
+ export declare class BitMath {
2
+ static mostSignificantBit(x: bigint): bigint;
3
+ static leastSignificantBit(x: bigint): bigint;
4
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BitMath = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ class BitMath {
6
+ static mostSignificantBit(x) {
7
+ (0, utils_1._require)(x > 0, '', { x }, 'x > 0');
8
+ let r = 0n;
9
+ if (x > 0xffffffffffffffffffffffffffffffffn) {
10
+ x >>= 128n;
11
+ r += 128n;
12
+ }
13
+ if (x > 0xffffffffffffffffn) {
14
+ x >>= 64n;
15
+ r += 64n;
16
+ }
17
+ if (x > 0xffffffffn) {
18
+ x >>= 32n;
19
+ r += 32n;
20
+ }
21
+ if (x > 0xffffn) {
22
+ x >>= 16n;
23
+ r += 16n;
24
+ }
25
+ if (x > 0xffn) {
26
+ x >>= 8n;
27
+ r += 8n;
28
+ }
29
+ if (x > 0xfn) {
30
+ x >>= 4n;
31
+ r += 4n;
32
+ }
33
+ if (x > 0x3n) {
34
+ x >>= 2n;
35
+ r += 2n;
36
+ }
37
+ if (x > 0x1n) {
38
+ r += 1n;
39
+ }
40
+ return r;
41
+ }
42
+ static leastSignificantBit(x) {
43
+ (0, utils_1._require)(x > 0, '', { x }, 'x > 0');
44
+ let r = 0n;
45
+ while ((x & 1n) === 0n) {
46
+ x >>= 1n;
47
+ r++;
48
+ }
49
+ return r;
50
+ }
51
+ }
52
+ exports.BitMath = BitMath;
53
+ //# sourceMappingURL=BitMath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BitMath.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/contract-math/BitMath.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAE1C,MAAa,OAAO;IAClB,MAAM,CAAC,kBAAkB,CAAC,CAAS;QACjC,IAAA,gBAAQ,EAAC,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAEpC,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,IAAI,CAAC,GAAG,mCAAmC,EAAE,CAAC;YAC5C,CAAC,KAAK,IAAI,CAAC;YACX,CAAC,IAAI,IAAI,CAAC;QACZ,CAAC;QACD,IAAI,CAAC,GAAG,mBAAmB,EAAE,CAAC;YAC5B,CAAC,KAAK,GAAG,CAAC;YACV,CAAC,IAAI,GAAG,CAAC;QACX,CAAC;QACD,IAAI,CAAC,GAAG,WAAW,EAAE,CAAC;YACpB,CAAC,KAAK,GAAG,CAAC;YACV,CAAC,IAAI,GAAG,CAAC;QACX,CAAC;QACD,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC;YAChB,CAAC,KAAK,GAAG,CAAC;YACV,CAAC,IAAI,GAAG,CAAC;QACX,CAAC;QACD,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC;YACd,CAAC,KAAK,EAAE,CAAC;YACT,CAAC,IAAI,EAAE,CAAC;QACV,CAAC;QACD,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;YACb,CAAC,KAAK,EAAE,CAAC;YACT,CAAC,IAAI,EAAE,CAAC;QACV,CAAC;QACD,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;YACb,CAAC,KAAK,EAAE,CAAC;YACT,CAAC,IAAI,EAAE,CAAC;QACV,CAAC;QACD,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;YACb,CAAC,IAAI,EAAE,CAAC;QACV,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,CAAS;QAClC,IAAA,gBAAQ,EAAC,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAEpC,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACvB,CAAC,KAAK,EAAE,CAAC;YACT,CAAC,EAAE,CAAC;QACN,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAnDD,0BAmDC"}
@@ -0,0 +1,3 @@
1
+ export declare class FixedPoint128 {
2
+ static readonly Q128 = 340282366920938463463374607431768211456n;
3
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FixedPoint128 = void 0;
4
+ class FixedPoint128 {
5
+ static Q128 = 0x100000000000000000000000000000000n;
6
+ }
7
+ exports.FixedPoint128 = FixedPoint128;
8
+ //# sourceMappingURL=FixedPoint128.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FixedPoint128.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/contract-math/FixedPoint128.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;IACxB,MAAM,CAAU,IAAI,GAAG,oCAAoC,CAAC;;AAD9D,sCAEC"}
@@ -0,0 +1,4 @@
1
+ export declare class FixedPoint96 {
2
+ static readonly RESOLUTION = 96n;
3
+ static readonly Q96 = 79228162514264337593543950336n;
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FixedPoint96 = void 0;
4
+ class FixedPoint96 {
5
+ static RESOLUTION = 96n;
6
+ static Q96 = 0x1000000000000000000000000n;
7
+ }
8
+ exports.FixedPoint96 = FixedPoint96;
9
+ //# sourceMappingURL=FixedPoint96.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FixedPoint96.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/contract-math/FixedPoint96.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAY;IACvB,MAAM,CAAU,UAAU,GAAG,GAAG,CAAC;IACjC,MAAM,CAAU,GAAG,GAAG,4BAA4B,CAAC;;AAFrD,oCAGC"}
@@ -0,0 +1,4 @@
1
+ export declare class FullMath {
2
+ static mulDiv(a: bigint, b: bigint, denominator: bigint): bigint;
3
+ static mulDivRoundingUp(a: bigint, b: bigint, denominator: bigint): bigint;
4
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FullMath = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ class FullMath {
6
+ static mulDiv(a, b, denominator) {
7
+ (0, utils_1._require)(denominator !== 0n, 'Denominator cannot be zero', { denominator }, 'denominator !== 0n');
8
+ const product = a * b;
9
+ return product / denominator;
10
+ }
11
+ static mulDivRoundingUp(a, b, denominator) {
12
+ (0, utils_1._require)(denominator !== 0n, 'Denominator cannot be zero', { denominator }, 'denominator !== 0n');
13
+ const product = a * b;
14
+ const result = product / denominator;
15
+ const remainder = product % denominator;
16
+ return remainder === 0n ? result : result + 1n;
17
+ }
18
+ }
19
+ exports.FullMath = FullMath;
20
+ //# sourceMappingURL=FullMath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FullMath.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/contract-math/FullMath.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAE1C,MAAa,QAAQ;IACnB,MAAM,CAAC,MAAM,CAAC,CAAS,EAAE,CAAS,EAAE,WAAmB;QACrD,IAAA,gBAAQ,EACN,WAAW,KAAK,EAAE,EAClB,4BAA4B,EAC5B,EAAE,WAAW,EAAE,EACf,oBAAoB,CACrB,CAAC;QAEF,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,OAAO,OAAO,GAAG,WAAW,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,CAAS,EAAE,CAAS,EAAE,WAAmB;QAC/D,IAAA,gBAAQ,EACN,WAAW,KAAK,EAAE,EAClB,4BAA4B,EAC5B,EAAE,WAAW,EAAE,EACf,oBAAoB,CACrB,CAAC;QAEF,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,MAAM,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;QACrC,MAAM,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC;QAExC,OAAO,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC;IACjD,CAAC;CACF;AA3BD,4BA2BC"}
@@ -0,0 +1,13 @@
1
+ export declare class LPFeeLibrary {
2
+ static readonly DYNAMIC_FEE_FLAG: bigint;
3
+ static readonly OVERRIDE_FEE_FLAG: bigint;
4
+ static readonly REMOVE_OVERRIDE_MASK: bigint;
5
+ static readonly MAX_LP_FEE: bigint;
6
+ static isDynamicFee(fee: bigint): boolean;
7
+ static isValid(fee: bigint): boolean;
8
+ static validate(fee: bigint): void;
9
+ static getInitialLPFee(fee: bigint): bigint;
10
+ static isOverride(fee: bigint): boolean;
11
+ static removeOverrideFlag(fee: bigint): bigint;
12
+ static removeOverrideFlagAndValidate(fee: bigint): bigint;
13
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LPFeeLibrary = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ class LPFeeLibrary {
6
+ static DYNAMIC_FEE_FLAG = 0x800000n;
7
+ static OVERRIDE_FEE_FLAG = 0x400000n;
8
+ static REMOVE_OVERRIDE_MASK = 0xbfffffn;
9
+ static MAX_LP_FEE = 1000000n;
10
+ static isDynamicFee(fee) {
11
+ return fee === this.DYNAMIC_FEE_FLAG;
12
+ }
13
+ static isValid(fee) {
14
+ return fee <= this.MAX_LP_FEE;
15
+ }
16
+ static validate(fee) {
17
+ (0, utils_1._require)(this.isValid(fee), `LPFeeTooLarge: ${fee}`, { fee });
18
+ }
19
+ static getInitialLPFee(fee) {
20
+ return this.isDynamicFee(fee) ? 0n : (this.validate(fee), fee);
21
+ }
22
+ static isOverride(fee) {
23
+ return (fee & this.OVERRIDE_FEE_FLAG) !== 0n;
24
+ }
25
+ static removeOverrideFlag(fee) {
26
+ return fee & this.REMOVE_OVERRIDE_MASK;
27
+ }
28
+ static removeOverrideFlagAndValidate(fee) {
29
+ const newFee = this.removeOverrideFlag(fee);
30
+ this.validate(newFee);
31
+ return newFee;
32
+ }
33
+ }
34
+ exports.LPFeeLibrary = LPFeeLibrary;
35
+ //# sourceMappingURL=LPFeeLibrary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LPFeeLibrary.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/contract-math/LPFeeLibrary.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAE1C,MAAa,YAAY;IACvB,MAAM,CAAU,gBAAgB,GAAW,SAAS,CAAC;IACrD,MAAM,CAAU,iBAAiB,GAAW,SAAS,CAAC;IACtD,MAAM,CAAU,oBAAoB,GAAW,SAAS,CAAC;IACzD,MAAM,CAAU,UAAU,GAAW,QAAQ,CAAC;IAE9C,MAAM,CAAC,YAAY,CAAC,GAAW;QAC7B,OAAO,GAAG,KAAK,IAAI,CAAC,gBAAgB,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,GAAW;QACxB,OAAO,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,GAAW;QACzB,IAAA,gBAAQ,EAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,kBAAkB,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,GAAW;QAChC,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,GAAW;QAC3B,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,GAAW;QACnC,OAAO,GAAG,GAAG,IAAI,CAAC,oBAAoB,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,6BAA6B,CAAC,GAAW;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtB,OAAO,MAAM,CAAC;IAChB,CAAC;;AAlCH,oCAmCC"}
@@ -0,0 +1,3 @@
1
+ export declare class LiquidityMath {
2
+ static addDelta(x: bigint, y: bigint): bigint;
3
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LiquidityMath = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ class LiquidityMath {
6
+ static addDelta(x, y) {
7
+ const maxUint128 = (1n << 128n) - 1n;
8
+ (0, utils_1._require)(x >= 0n && x < maxUint128, 'x is out of uint128 range', { x }, 'x >= 0n && x < maxUint128');
9
+ (0, utils_1._require)(y >= -(1n << 127n) && y < 1n << 127n, 'y is out of int128 range', { y }, 'y >= -(1n << 127n) && y < 1n << 127n');
10
+ const z = x + y;
11
+ (0, utils_1._require)(z >= 0n && z <= maxUint128, 'SafeCastOverflow', { z, maxUint128 }, 'z >= 0n && z <= maxUint128');
12
+ return z;
13
+ }
14
+ }
15
+ exports.LiquidityMath = LiquidityMath;
16
+ //# sourceMappingURL=LiquidityMath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiquidityMath.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/contract-math/LiquidityMath.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAE1C,MAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,CAAS,EAAE,CAAS;QAClC,MAAM,UAAU,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QAErC,IAAA,gBAAQ,EACN,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,UAAU,EACzB,2BAA2B,EAC3B,EAAE,CAAC,EAAE,EACL,2BAA2B,CAC5B,CAAC;QAEF,IAAA,gBAAQ,EACN,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,EACpC,0BAA0B,EAC1B,EAAE,CAAC,EAAE,EACL,sCAAsC,CACvC,CAAC;QAEF,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEhB,IAAA,gBAAQ,EACN,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,UAAU,EAC1B,kBAAkB,EAClB,EAAE,CAAC,EAAE,UAAU,EAAE,EACjB,4BAA4B,CAC7B,CAAC;QAEF,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA7BD,sCA6BC"}
@@ -0,0 +1,9 @@
1
+ import { PoolState, PositionState } from '../types';
2
+ export declare class Position {
3
+ static calculatePositionKey(owner: string, tickLower: bigint, tickUpper: bigint, salt: string): string;
4
+ static get(poolState: PoolState, owner: string, tickLower: bigint, tickUpper: bigint, salt: string): PositionState | undefined;
5
+ static update(poolState: PoolState, owner: string, tickLower: bigint, tickUpper: bigint, salt: string, liquidityDelta: bigint, feeGrowthInside0X128: bigint, feeGrowthInside1X128: bigint): {
6
+ feesOwed0: bigint;
7
+ feesOwed1: bigint;
8
+ };
9
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Position = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ class Position {
6
+ static calculatePositionKey(owner, tickLower, tickUpper, salt) {
7
+ return `${owner}-${tickLower.toString()}-${tickUpper.toString()}-${salt}`;
8
+ }
9
+ static get(poolState, owner, tickLower, tickUpper, salt) {
10
+ const positionKey = Position.calculatePositionKey(owner, tickLower, tickUpper, salt);
11
+ return poolState.positions[positionKey];
12
+ }
13
+ static update(poolState, owner, tickLower, tickUpper, salt, liquidityDelta, feeGrowthInside0X128, feeGrowthInside1X128) {
14
+ const positionKey = Position.calculatePositionKey(owner, tickLower, tickUpper, salt);
15
+ let position = poolState.positions[positionKey];
16
+ (0, utils_1._require)(Boolean(position), 'Position does not exist', { position });
17
+ let { liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128 } = position;
18
+ if (liquidityDelta === 0n) {
19
+ (0, utils_1._require)(liquidity !== 0n, 'Cannot update empty position', {
20
+ liquidityDelta,
21
+ });
22
+ }
23
+ else {
24
+ liquidity += liquidityDelta;
25
+ }
26
+ const feesOwed0 = ((feeGrowthInside0X128 - feeGrowthInside0LastX128) * liquidity) /
27
+ BigInt(1 << 128);
28
+ const feesOwed1 = ((feeGrowthInside1X128 - feeGrowthInside1LastX128) * liquidity) /
29
+ BigInt(1 << 128);
30
+ poolState.positions[positionKey] = {
31
+ liquidity,
32
+ feeGrowthInside0LastX128: feeGrowthInside0X128,
33
+ feeGrowthInside1LastX128: feeGrowthInside1X128,
34
+ };
35
+ return { feesOwed0, feesOwed1 };
36
+ }
37
+ }
38
+ exports.Position = Position;
39
+ //# sourceMappingURL=Position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Position.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/contract-math/Position.ts"],"names":[],"mappings":";;;AACA,0CAA0C;AAE1C,MAAa,QAAQ;IACZ,MAAM,CAAC,oBAAoB,CAChC,KAAa,EACb,SAAiB,EACjB,SAAiB,EACjB,IAAY;QAEZ,OAAO,GAAG,KAAK,IAAI,SAAS,CAAC,QAAQ,EAAE,IAAI,SAAS,CAAC,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC;IAC5E,CAAC;IAED,MAAM,CAAC,GAAG,CACR,SAAoB,EACpB,KAAa,EACb,SAAiB,EACjB,SAAiB,EACjB,IAAY;QAEZ,MAAM,WAAW,GAAG,QAAQ,CAAC,oBAAoB,CAC/C,KAAK,EACL,SAAS,EACT,SAAS,EACT,IAAI,CACL,CAAC;QAEF,OAAO,SAAS,CAAC,SAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,MAAM,CACX,SAAoB,EACpB,KAAa,EACb,SAAiB,EACjB,SAAiB,EACjB,IAAY,EACZ,cAAsB,EACtB,oBAA4B,EAC5B,oBAA4B;QAE5B,MAAM,WAAW,GAAG,QAAQ,CAAC,oBAAoB,CAC/C,KAAK,EACL,SAAS,EACT,SAAS,EACT,IAAI,CACL,CAAC;QACF,IAAI,QAAQ,GAAG,SAAS,CAAC,SAAU,CAAC,WAAW,CAAC,CAAC;QAEjD,IAAA,gBAAQ,EAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,yBAAyB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAErE,IAAI,EAAE,SAAS,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,GACnE,QAAQ,CAAC;QAEX,IAAI,cAAc,KAAK,EAAE,EAAE,CAAC;YAC1B,IAAA,gBAAQ,EAAC,SAAS,KAAK,EAAE,EAAE,8BAA8B,EAAE;gBACzD,cAAc;aACf,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,SAAS,IAAI,cAAc,CAAC;QAC9B,CAAC;QAED,MAAM,SAAS,GACb,CAAC,CAAC,oBAAoB,GAAG,wBAAwB,CAAC,GAAG,SAAS,CAAC;YAC/D,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QACnB,MAAM,SAAS,GACb,CAAC,CAAC,oBAAoB,GAAG,wBAAwB,CAAC,GAAG,SAAS,CAAC;YAC/D,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;QAEnB,SAAS,CAAC,SAAU,CAAC,WAAW,CAAC,GAAG;YAClC,SAAS;YACT,wBAAwB,EAAE,oBAAoB;YAC9C,wBAAwB,EAAE,oBAAoB;SAC/C,CAAC;QAEF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IAClC,CAAC;CACF;AAzED,4BAyEC"}
@@ -0,0 +1,10 @@
1
+ export declare class ProtocolFeeLibrary {
2
+ static readonly MAX_PROTOCOL_FEE: bigint;
3
+ static readonly FEE_0_THRESHOLD: bigint;
4
+ static readonly FEE_1_THRESHOLD: bigint;
5
+ static readonly PIPS_DENOMINATOR: bigint;
6
+ static getZeroForOneFee(protocolFee: bigint): bigint;
7
+ static getOneForZeroFee(protocolFee: bigint): bigint;
8
+ static isValidProtocolFee(protocolFee: bigint): boolean;
9
+ static calculateSwapFee(protocolFee: bigint, lpFee: bigint): bigint;
10
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProtocolFeeLibrary = void 0;
4
+ class ProtocolFeeLibrary {
5
+ static MAX_PROTOCOL_FEE = 1000n;
6
+ static FEE_0_THRESHOLD = 1001n;
7
+ static FEE_1_THRESHOLD = 1001n << 12n;
8
+ static PIPS_DENOMINATOR = 1000000n;
9
+ static getZeroForOneFee(protocolFee) {
10
+ return BigInt(Number(protocolFee) & 0xfff);
11
+ }
12
+ static getOneForZeroFee(protocolFee) {
13
+ return protocolFee >> 12n;
14
+ }
15
+ static isValidProtocolFee(protocolFee) {
16
+ let isZeroForOneFeeOk = (protocolFee & 0xfffn) < ProtocolFeeLibrary.FEE_0_THRESHOLD;
17
+ let isOneForZeroFeeOk = (protocolFee & 0xfff000n) < ProtocolFeeLibrary.FEE_1_THRESHOLD;
18
+ return isZeroForOneFeeOk && isOneForZeroFeeOk;
19
+ }
20
+ static calculateSwapFee(protocolFee, lpFee) {
21
+ protocolFee &= 0xfffn;
22
+ lpFee &= 0xffffffn;
23
+ let numerator = protocolFee * lpFee;
24
+ return (protocolFee + lpFee - numerator / ProtocolFeeLibrary.PIPS_DENOMINATOR);
25
+ }
26
+ }
27
+ exports.ProtocolFeeLibrary = ProtocolFeeLibrary;
28
+ //# sourceMappingURL=ProtocolFeeLibrary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProtocolFeeLibrary.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/contract-math/ProtocolFeeLibrary.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAkB;IAC7B,MAAM,CAAU,gBAAgB,GAAW,KAAK,CAAC;IACjD,MAAM,CAAU,eAAe,GAAW,KAAK,CAAC;IAChD,MAAM,CAAU,eAAe,GAAW,KAAK,IAAI,GAAG,CAAC;IACvD,MAAM,CAAU,gBAAgB,GAAW,QAAU,CAAC;IAEtD,MAAM,CAAC,gBAAgB,CAAC,WAAmB;QACzC,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,WAAmB;QACzC,OAAO,WAAW,IAAI,GAAG,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,WAAmB;QAC3C,IAAI,iBAAiB,GACnB,CAAC,WAAW,GAAG,MAAM,CAAC,GAAG,kBAAkB,CAAC,eAAe,CAAC;QAC9D,IAAI,iBAAiB,GACnB,CAAC,WAAW,GAAG,SAAS,CAAC,GAAG,kBAAkB,CAAC,eAAe,CAAC;QACjE,OAAO,iBAAiB,IAAI,iBAAiB,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,WAAmB,EAAE,KAAa;QACxD,WAAW,IAAI,MAAM,CAAC;QACtB,KAAK,IAAI,SAAS,CAAC;QACnB,IAAI,SAAS,GAAG,WAAW,GAAG,KAAK,CAAC;QACpC,OAAO,CACL,WAAW,GAAG,KAAK,GAAG,SAAS,GAAG,kBAAkB,CAAC,gBAAgB,CACtE,CAAC;IACJ,CAAC;;AA7BH,gDA8BC"}
@@ -0,0 +1,8 @@
1
+ export declare class SqrtPriceMath {
2
+ static getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96: bigint, liquidity: bigint, amount: bigint, add: boolean): bigint;
3
+ static getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96: bigint, liquidity: bigint, amount: bigint, add: boolean): bigint;
4
+ static getNextSqrtPriceFromInput(sqrtPX96: bigint, liquidity: bigint, amountIn: bigint, zeroForOne: boolean): bigint;
5
+ static getNextSqrtPriceFromOutput(sqrtPX96: bigint, liquidity: bigint, amountOut: bigint, zeroForOne: boolean): bigint;
6
+ static getAmount0Delta(sqrtPriceAX96: bigint, sqrtPriceBX96: bigint, liquidity: bigint, roundUp: boolean): bigint;
7
+ static getAmount1Delta(sqrtPriceAX96: bigint, sqrtPriceBX96: bigint, liquidity: bigint, roundUp: boolean): bigint;
8
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SqrtPriceMath = void 0;
4
+ const FixedPoint96_1 = require("./FixedPoint96");
5
+ const FullMath_1 = require("./FullMath");
6
+ const UnsafeMath_1 = require("./UnsafeMath");
7
+ const utils_1 = require("../../../utils");
8
+ class SqrtPriceMath {
9
+ static getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amount, add) {
10
+ if (amount === 0n)
11
+ return sqrtPX96;
12
+ let numerator1 = liquidity << 96n;
13
+ if (add) {
14
+ let product = amount * sqrtPX96;
15
+ let denominator = numerator1 + product;
16
+ return (numerator1 * sqrtPX96 + denominator - 1n) / denominator;
17
+ }
18
+ else {
19
+ let product = amount * sqrtPX96;
20
+ (0, utils_1._require)(product < numerator1, 'PriceOverflow', { product, numerator1 }, 'product < numerator1');
21
+ let denominator = numerator1 - product;
22
+ return (numerator1 * sqrtPX96 + denominator - 1n) / denominator;
23
+ }
24
+ }
25
+ static getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amount, add) {
26
+ if (add) {
27
+ let quotient = (amount * FixedPoint96_1.FixedPoint96.Q96) / liquidity;
28
+ return sqrtPX96 + quotient;
29
+ }
30
+ else {
31
+ let quotient = (amount * FixedPoint96_1.FixedPoint96.Q96 + liquidity - 1n) / liquidity;
32
+ (0, utils_1._require)(sqrtPX96 > quotient, 'NotEnoughLiquidity', { sqrtPX96, quotient }, 'sqrtPX96 > quotient');
33
+ return sqrtPX96 - quotient;
34
+ }
35
+ }
36
+ static getNextSqrtPriceFromInput(sqrtPX96, liquidity, amountIn, zeroForOne) {
37
+ (0, utils_1._require)(sqrtPX96 !== 0n && liquidity !== 0n, 'InvalidPriceOrLiquidity', { sqrtPX96, liquidity }, 'sqrtPX96 !== 0n && liquidity !== 0n');
38
+ return zeroForOne
39
+ ? SqrtPriceMath.getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true)
40
+ : SqrtPriceMath.getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true);
41
+ }
42
+ static getNextSqrtPriceFromOutput(sqrtPX96, liquidity, amountOut, zeroForOne) {
43
+ (0, utils_1._require)(sqrtPX96 !== 0n && liquidity !== 0n, 'InvalidPriceOrLiquidity', { sqrtPX96, liquidity }, 'sqrtPX96 !== 0n && liquidity !== 0n');
44
+ return zeroForOne
45
+ ? SqrtPriceMath.getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false)
46
+ : SqrtPriceMath.getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);
47
+ }
48
+ static getAmount0Delta(sqrtPriceAX96, sqrtPriceBX96, liquidity, roundUp) {
49
+ if (sqrtPriceAX96 > sqrtPriceBX96)
50
+ [sqrtPriceAX96, sqrtPriceBX96] = [sqrtPriceBX96, sqrtPriceAX96];
51
+ let numerator1 = BigInt.asIntN(256, liquidity) << FixedPoint96_1.FixedPoint96.RESOLUTION;
52
+ let numerator2 = sqrtPriceBX96 - sqrtPriceAX96;
53
+ return roundUp
54
+ ? UnsafeMath_1.UnsafeMath.divRoundingUp(FullMath_1.FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtPriceBX96), sqrtPriceAX96)
55
+ : FullMath_1.FullMath.mulDiv(numerator1, numerator2, sqrtPriceBX96) / sqrtPriceAX96;
56
+ }
57
+ static getAmount1Delta(sqrtPriceAX96, sqrtPriceBX96, liquidity, roundUp) {
58
+ if (sqrtPriceAX96 > sqrtPriceBX96)
59
+ [sqrtPriceAX96, sqrtPriceBX96] = [sqrtPriceBX96, sqrtPriceAX96];
60
+ const _liquidity = BigInt.asUintN(256, liquidity);
61
+ return roundUp
62
+ ? FullMath_1.FullMath.mulDivRoundingUp(_liquidity, sqrtPriceBX96 - sqrtPriceAX96, FixedPoint96_1.FixedPoint96.Q96)
63
+ : FullMath_1.FullMath.mulDiv(_liquidity, sqrtPriceBX96 - sqrtPriceAX96, FixedPoint96_1.FixedPoint96.Q96);
64
+ }
65
+ }
66
+ exports.SqrtPriceMath = SqrtPriceMath;
67
+ //# sourceMappingURL=SqrtPriceMath.js.map