@paraswap/dex-lib 4.1.13 → 4.1.14-balv3

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/Aave_GSM.json +751 -0
  2. package/build/abi/Balancer.json +257 -0
  3. package/build/abi/BalancerV2.json +1179 -0
  4. package/build/abi/{integral/relayer.json → RamsesV2Pool.abi.json} +850 -832
  5. package/build/abi/RamsesV2Quoter.abi.json +274 -0
  6. package/build/abi/USDM.json +807 -0
  7. package/build/abi/UniswapV2Router.json +397 -0
  8. package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +1246 -0
  9. package/build/abi/{integral/oracle.json → angle-transmuter/ChainlinkEACAggregatorProxy.json} +247 -239
  10. package/build/abi/curve-v1/CurveBUSDv2.abi.json +1356 -0
  11. package/build/abi/curve-v1/CurveTokenV1.json +305 -0
  12. package/build/abi/curve-v1/CurveTokenV2.json +318 -0
  13. package/build/abi/curve-v1/CurveV1StableNg.json +1452 -0
  14. package/build/abi/curve-v1/CurveV2Swap.json +700 -0
  15. package/build/abi/curve-v1/FactoryCryptoRegistry.json +316 -0
  16. package/build/abi/curve-v1/FactoryRegistry.json +508 -0
  17. package/build/abi/curve-v1/StableSwapAave.json +1152 -0
  18. package/build/abi/curve-v1/StableSwapBUSD.json +814 -0
  19. package/build/abi/curve-v1/StableSwapCompound.json +814 -0
  20. package/build/abi/curve-v1/StableSwapIDLE.json +1253 -0
  21. package/build/abi/curve-v1/StableSwapPax.json +865 -0
  22. package/build/abi/curve-v1/StableSwapSnow.json +900 -0
  23. package/build/abi/{integral/pool.json → curve-v1/StableSwapUSDN.json} +450 -487
  24. package/build/abi/curve-v1/StableSwapUSDT.json +814 -0
  25. package/build/abi/curve-v1/StableSwapY.json +814 -0
  26. package/build/abi/inception/inception-ineth-pool.json +1062 -0
  27. package/build/abi/inception/inception-ineth.json +609 -0
  28. package/build/abi/inception/inception-ratio-feed.json +329 -0
  29. package/build/abi/inception/inception-vault.json +991 -0
  30. package/build/abi/kyberdmm/kyber-storage.abi.json +824 -0
  31. package/build/abi/kyberdmm.abi.json +1148 -0
  32. package/build/abi/maverick-v2/MaverickV2Quoter.json +278 -0
  33. package/build/abi/nerve/nerve-metapool.json +790 -0
  34. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
  35. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +267 -0
  36. package/build/dex/aave-v1/aave-v1.d.ts +2 -1
  37. package/build/dex/aave-v1/aave-v1.js +22 -0
  38. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  39. package/build/dex/balancer-v1/balancer-pools.json +33333 -0
  40. package/build/dex/balancer-v3/balancer-v3-pool.js +9 -0
  41. package/build/dex/balancer-v3/balancer-v3-pool.js.map +1 -1
  42. package/build/dex/balancer-v3/balancer-v3.js +9 -2
  43. package/build/dex/balancer-v3/balancer-v3.js.map +1 -1
  44. package/build/dex/bebop/websocket-fetcher.d.ts +35 -0
  45. package/build/dex/bebop/websocket-fetcher.js +87 -0
  46. package/build/dex/bebop/websocket-fetcher.js.map +1 -0
  47. package/build/dex/hashflow/config.js +3 -0
  48. package/build/dex/hashflow/config.js.map +1 -1
  49. package/build/dex/hashflow/hashflow.js +4 -8
  50. package/build/dex/hashflow/hashflow.js.map +1 -1
  51. package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
  52. package/build/dex/idle-dao/idle-dao-pool.js +176 -0
  53. package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
  54. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
  55. package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
  56. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
  57. package/build/dex/idle-dao/scripts.d.ts +9 -0
  58. package/build/dex/idle-dao/scripts.js +552 -0
  59. package/build/dex/idle-dao/scripts.js.map +1 -0
  60. package/build/dex/inception/config.d.ts +4 -0
  61. package/build/dex/inception/config.js +109 -0
  62. package/build/dex/inception/config.js.map +1 -0
  63. package/build/dex/inception/inception-event-pool.d.ts +16 -0
  64. package/build/dex/inception/inception-event-pool.js +51 -0
  65. package/build/dex/inception/inception-event-pool.js.map +1 -0
  66. package/build/dex/{integral/integral.d.ts → inception/inception-native.d.ts} +21 -19
  67. package/build/dex/inception/inception-native.js +131 -0
  68. package/build/dex/inception/inception-native.js.map +1 -0
  69. package/build/dex/inception/inception-pool.d.ts +18 -0
  70. package/build/dex/inception/inception-pool.js +32 -0
  71. package/build/dex/inception/inception-pool.js.map +1 -0
  72. package/build/dex/inception/inception-price-feed.d.ts +19 -0
  73. package/build/dex/inception/inception-price-feed.js +51 -0
  74. package/build/dex/inception/inception-price-feed.js.map +1 -0
  75. package/build/dex/inception/inception.d.ts +43 -0
  76. package/build/dex/inception/inception.js +204 -0
  77. package/build/dex/inception/inception.js.map +1 -0
  78. package/build/dex/inception/tokens.d.ts +9 -0
  79. package/build/dex/inception/tokens.js +28 -0
  80. package/build/dex/inception/tokens.js.map +1 -0
  81. package/build/dex/inception/types.d.ts +22 -0
  82. package/build/dex/{m-token → inception}/types.js.map +1 -1
  83. package/build/dex/inception/utils.d.ts +6 -0
  84. package/build/dex/inception/utils.js +37 -0
  85. package/build/dex/inception/utils.js.map +1 -0
  86. package/build/dex/jarvis.d.ts +2 -1
  87. package/build/dex/jarvis.js +58 -0
  88. package/build/dex/jarvis.js.map +1 -1
  89. package/build/dex/platypus/platypus.d.ts +2 -1
  90. package/build/dex/platypus/platypus.js +31 -0
  91. package/build/dex/platypus/platypus.js.map +1 -1
  92. package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
  93. package/build/dex/swaap-v1/swaap-v1.js +10 -0
  94. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  95. package/build/dex/woo-fi-v2/config.js +1 -1
  96. package/build/dex/zerox/index.d.ts +4 -26
  97. package/build/dex/zerox/index.js +50 -42
  98. package/build/dex/zerox/index.js.map +1 -1
  99. package/build/dex/zerox/types.d.ts +29 -0
  100. package/build/dex/zerox/types.js +8 -1
  101. package/build/dex/zerox/types.js.map +1 -1
  102. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +16 -0
  103. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +16 -0
  104. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +16 -0
  105. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +16 -0
  106. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +16 -0
  107. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +16 -0
  108. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +16 -0
  109. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +16 -0
  110. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +9 -0
  111. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +9 -0
  112. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +9 -0
  113. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +9 -0
  114. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +9 -0
  115. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +9 -0
  116. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +9 -0
  117. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +9 -0
  118. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +9 -0
  119. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +12 -0
  120. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +7 -0
  121. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +7 -0
  122. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +7 -0
  123. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +7 -0
  124. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +12 -0
  125. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +7 -0
  126. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +7 -0
  127. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +78 -0
  128. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +81 -0
  129. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +78 -0
  130. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +78 -0
  131. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +81 -0
  132. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +81 -0
  133. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +81 -0
  134. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +81 -0
  135. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +64 -0
  136. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +85 -0
  137. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +64 -0
  138. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +52 -0
  139. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +52 -0
  140. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +52 -0
  141. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +55 -0
  142. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +55 -0
  143. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +55 -0
  144. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +23 -0
  145. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +37 -0
  146. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +23 -0
  147. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +23 -0
  148. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +51 -0
  149. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +58 -0
  150. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +23 -0
  151. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +23 -0
  152. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +9 -0
  153. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +16 -0
  154. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +23 -0
  155. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +12 -0
  156. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +7 -0
  157. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +12 -0
  158. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +12 -0
  159. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +7 -0
  160. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +7 -0
  161. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +7 -0
  162. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +7 -0
  163. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +7 -0
  164. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +7 -0
  165. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +130 -0
  166. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +136 -0
  167. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +100 -0
  168. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +100 -0
  169. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +166 -0
  170. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +190 -0
  171. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +114 -0
  172. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +114 -0
  173. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +55 -0
  174. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +73 -0
  175. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +82 -0
  176. package/package.json +2 -2
  177. package/src/dex/balancer-v3/balancer-v3-e2e.test.ts +62 -42
  178. package/src/dex/balancer-v3/balancer-v3-pool.ts +9 -0
  179. package/src/dex/balancer-v3/balancer-v3.ts +15 -4
  180. package/src/dex/hashflow/config.ts +3 -0
  181. package/src/dex/hashflow/hashflow-e2e.test.ts +30 -18
  182. package/src/dex/hashflow/hashflow.ts +6 -10
  183. package/src/dex/woo-fi-v2/config.ts +1 -1
  184. package/src/dex/woo-fi-v2/woo-fi-v2-e2e.test.ts +1 -0
  185. package/tests/constants-e2e.ts +6 -1
  186. package/.idea/aws.xml +0 -17
  187. package/.idea/codeStyles/Project.xml +0 -19
  188. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  189. package/.idea/misc.xml +0 -6
  190. package/.idea/modules.xml +0 -8
  191. package/.idea/paraswap-dex-lib.iml +0 -9
  192. package/.idea/prettier.xml +0 -7
  193. package/.idea/vcs.xml +0 -6
  194. package/build/abi/integral/factory.json +0 -333
  195. package/build/abi/uniswap-v4/pool-manager.abi.json +0 -1366
  196. package/build/abi/uniswap-v4/quoter.abi.json +0 -461
  197. package/build/abi/uniswap-v4/router.abi.json +0 -230
  198. package/build/abi/uniswap-v4/state-view.abi.json +0 -365
  199. package/build/dex/bProtocol.d.ts +0 -18
  200. package/build/dex/bProtocol.js +0 -39
  201. package/build/dex/bProtocol.js.map +0 -1
  202. package/build/dex/bancor.d.ts +0 -26
  203. package/build/dex/bancor.js +0 -58
  204. package/build/dex/bancor.js.map +0 -1
  205. package/build/dex/compound.d.ts +0 -18
  206. package/build/dex/compound.js +0 -46
  207. package/build/dex/compound.js.map +0 -1
  208. package/build/dex/curve-v2.d.ts +0 -58
  209. package/build/dex/curve-v2.js +0 -180
  210. package/build/dex/curve-v2.js.map +0 -1
  211. package/build/dex/dodo-v1.d.ts +0 -33
  212. package/build/dex/dodo-v1.js +0 -63
  213. package/build/dex/dodo-v1.js.map +0 -1
  214. package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +0 -49
  215. package/build/dex/fluid-dex/fluid-dex-generate-pool.js +0 -104
  216. package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +0 -1
  217. package/build/dex/integral/config.d.ts +0 -4
  218. package/build/dex/integral/config.js +0 -20
  219. package/build/dex/integral/config.js.map +0 -1
  220. package/build/dex/integral/context.d.ts +0 -40
  221. package/build/dex/integral/context.js +0 -158
  222. package/build/dex/integral/context.js.map +0 -1
  223. package/build/dex/integral/integral-factory.d.ts +0 -24
  224. package/build/dex/integral/integral-factory.js +0 -95
  225. package/build/dex/integral/integral-factory.js.map +0 -1
  226. package/build/dex/integral/integral-pool.d.ts +0 -50
  227. package/build/dex/integral/integral-pool.js +0 -149
  228. package/build/dex/integral/integral-pool.js.map +0 -1
  229. package/build/dex/integral/integral-pricing.d.ts +0 -18
  230. package/build/dex/integral/integral-pricing.js +0 -114
  231. package/build/dex/integral/integral-pricing.js.map +0 -1
  232. package/build/dex/integral/integral-relayer.d.ts +0 -42
  233. package/build/dex/integral/integral-relayer.js +0 -192
  234. package/build/dex/integral/integral-relayer.js.map +0 -1
  235. package/build/dex/integral/integral-token.d.ts +0 -27
  236. package/build/dex/integral/integral-token.js +0 -59
  237. package/build/dex/integral/integral-token.js.map +0 -1
  238. package/build/dex/integral/integral.js +0 -376
  239. package/build/dex/integral/integral.js.map +0 -1
  240. package/build/dex/integral/types.d.ts +0 -85
  241. package/build/dex/integral/types.js +0 -9
  242. package/build/dex/integral/types.js.map +0 -1
  243. package/build/dex/integral/utils-e2e.d.ts +0 -9
  244. package/build/dex/integral/utils-e2e.js +0 -131
  245. package/build/dex/integral/utils-e2e.js.map +0 -1
  246. package/build/dex/integral/utils.d.ts +0 -17
  247. package/build/dex/integral/utils.js +0 -94
  248. package/build/dex/integral/utils.js.map +0 -1
  249. package/build/dex/lido.d.ts +0 -19
  250. package/build/dex/lido.js +0 -42
  251. package/build/dex/lido.js.map +0 -1
  252. package/build/dex/m-token/config.d.ts +0 -3
  253. package/build/dex/m-token/config.js +0 -19
  254. package/build/dex/m-token/config.js.map +0 -1
  255. package/build/dex/m-token/m-token.d.ts +0 -29
  256. package/build/dex/m-token/m-token.js +0 -145
  257. package/build/dex/m-token/m-token.js.map +0 -1
  258. package/build/dex/m-token/m-wrapped-m.d.ts +0 -17
  259. package/build/dex/m-token/m-wrapped-m.js +0 -50
  260. package/build/dex/m-token/m-wrapped-m.js.map +0 -1
  261. package/build/dex/m-token/types.d.ts +0 -12
  262. package/build/dex/onebit.d.ts +0 -25
  263. package/build/dex/onebit.js +0 -42
  264. package/build/dex/onebit.js.map +0 -1
  265. package/build/dex/smoothy.d.ts +0 -26
  266. package/build/dex/smoothy.js +0 -48
  267. package/build/dex/smoothy.js.map +0 -1
  268. package/build/dex/spark/susds-psm.d.ts +0 -49
  269. package/build/dex/spark/susds-psm.js +0 -245
  270. package/build/dex/spark/susds-psm.js.map +0 -1
  271. package/build/dex/stable-pool.d.ts +0 -28
  272. package/build/dex/stable-pool.js +0 -62
  273. package/build/dex/stable-pool.js.map +0 -1
  274. package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
  275. package/build/dex/trader-joe-v2.1/optimizer.js +0 -47
  276. package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
  277. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
  278. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
  279. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
  280. package/build/dex/trader-joe-v2.1.d.ts +0 -43
  281. package/build/dex/trader-joe-v2.1.js +0 -79
  282. package/build/dex/trader-joe-v2.1.js.map +0 -1
  283. package/build/dex/uniswap-v4/config.d.ts +0 -3
  284. package/build/dex/uniswap-v4/config.js +0 -58
  285. package/build/dex/uniswap-v4/config.js.map +0 -1
  286. package/build/dex/uniswap-v4/constants.d.ts +0 -7
  287. package/build/dex/uniswap-v4/constants.js +0 -18
  288. package/build/dex/uniswap-v4/constants.js.map +0 -1
  289. package/build/dex/uniswap-v4/contract-math/BitMath.d.ts +0 -4
  290. package/build/dex/uniswap-v4/contract-math/BitMath.js +0 -93
  291. package/build/dex/uniswap-v4/contract-math/BitMath.js.map +0 -1
  292. package/build/dex/uniswap-v4/contract-math/FixedPoint128.d.ts +0 -3
  293. package/build/dex/uniswap-v4/contract-math/FixedPoint128.js +0 -8
  294. package/build/dex/uniswap-v4/contract-math/FixedPoint128.js.map +0 -1
  295. package/build/dex/uniswap-v4/contract-math/FixedPoint96.d.ts +0 -4
  296. package/build/dex/uniswap-v4/contract-math/FixedPoint96.js +0 -9
  297. package/build/dex/uniswap-v4/contract-math/FixedPoint96.js.map +0 -1
  298. package/build/dex/uniswap-v4/contract-math/FullMath.d.ts +0 -4
  299. package/build/dex/uniswap-v4/contract-math/FullMath.js +0 -19
  300. package/build/dex/uniswap-v4/contract-math/FullMath.js.map +0 -1
  301. package/build/dex/uniswap-v4/contract-math/LiquidityMath.d.ts +0 -3
  302. package/build/dex/uniswap-v4/contract-math/LiquidityMath.js +0 -22
  303. package/build/dex/uniswap-v4/contract-math/LiquidityMath.js.map +0 -1
  304. package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.d.ts +0 -10
  305. package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.js +0 -91
  306. package/build/dex/uniswap-v4/contract-math/SqrtPriceMath.js.map +0 -1
  307. package/build/dex/uniswap-v4/contract-math/SwapMath.d.ts +0 -8
  308. package/build/dex/uniswap-v4/contract-math/SwapMath.js +0 -70
  309. package/build/dex/uniswap-v4/contract-math/SwapMath.js.map +0 -1
  310. package/build/dex/uniswap-v4/contract-math/TickBitMap.d.ts +0 -7
  311. package/build/dex/uniswap-v4/contract-math/TickBitMap.js +0 -86
  312. package/build/dex/uniswap-v4/contract-math/TickBitMap.js.map +0 -1
  313. package/build/dex/uniswap-v4/contract-math/TickMath.d.ts +0 -8
  314. package/build/dex/uniswap-v4/contract-math/TickMath.js +0 -162
  315. package/build/dex/uniswap-v4/contract-math/TickMath.js.map +0 -1
  316. package/build/dex/uniswap-v4/contract-math/UnsafeMath.d.ts +0 -3
  317. package/build/dex/uniswap-v4/contract-math/UnsafeMath.js +0 -10
  318. package/build/dex/uniswap-v4/contract-math/UnsafeMath.js.map +0 -1
  319. package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.d.ts +0 -8
  320. package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.js +0 -11
  321. package/build/dex/uniswap-v4/contract-math/uniswap-v4-math.js.map +0 -1
  322. package/build/dex/uniswap-v4/encoder.d.ts +0 -16
  323. package/build/dex/uniswap-v4/encoder.js +0 -104
  324. package/build/dex/uniswap-v4/encoder.js.map +0 -1
  325. package/build/dex/uniswap-v4/subgraph.d.ts +0 -5
  326. package/build/dex/uniswap-v4/subgraph.js +0 -80
  327. package/build/dex/uniswap-v4/subgraph.js.map +0 -1
  328. package/build/dex/uniswap-v4/types.d.ts +0 -64
  329. package/build/dex/uniswap-v4/types.js +0 -3
  330. package/build/dex/uniswap-v4/types.js.map +0 -1
  331. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.d.ts +0 -33
  332. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js +0 -152
  333. package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js.map +0 -1
  334. package/build/dex/uniswap-v4/uniswap-v4.d.ts +0 -38
  335. package/build/dex/uniswap-v4/uniswap-v4.js +0 -169
  336. package/build/dex/uniswap-v4/uniswap-v4.js.map +0 -1
  337. package/build/dex/uniswap-v4/utils.d.ts +0 -2
  338. package/build/dex/uniswap-v4/utils.js +0 -15
  339. package/build/dex/uniswap-v4/utils.js.map +0 -1
  340. /package/build/dex/{m-token → inception}/types.js +0 -0
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Adapters = exports.IntegralConfig = void 0;
4
- const constants_1 = require("../../constants");
5
- exports.IntegralConfig = {
6
- Integral: {
7
- [constants_1.Network.MAINNET]: {
8
- factoryAddress: '0xC480b33eE5229DE3FbDFAD1D2DCD3F3BAD0C56c6',
9
- relayerAddress: '0xd17b3c9784510E33cD5B87b490E79253BcD81e2E',
10
- subgraphURL: 'ANd5QJuYtyfngmXvBMu9kZAv935vhcqp4xAGBkmCADN3',
11
- },
12
- [constants_1.Network.ARBITRUM]: {
13
- factoryAddress: '0x717EF162cf831db83c51134734A15D1EBe9E516a',
14
- relayerAddress: '0x3c6951FDB433b5b8442e7aa126D50fBFB54b5f42',
15
- subgraphURL: 'HXeVedRK7VgogXwbK5Sc4mjyLkhBAS5akskRvbSYnkHU',
16
- },
17
- },
18
- };
19
- exports.Adapters = {};
20
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/integral/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAE7B,QAAA,cAAc,GAA4B;IACrD,QAAQ,EAAE;QACR,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,cAAc,EAAE,4CAA4C;YAC5D,cAAc,EAAE,4CAA4C;YAC5D,WAAW,EAAE,8CAA8C;SAC5D;QACD,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE;YAClB,cAAc,EAAE,4CAA4C;YAC5D,cAAc,EAAE,4CAA4C;YAC5D,WAAW,EAAE,8CAA8C;SAC5D;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC,EAAE,CAAC"}
@@ -1,40 +0,0 @@
1
- import { Address } from '@paraswap/core';
2
- import { IntegralFactory } from './integral-factory';
3
- import { IntegralRelayer } from './integral-relayer';
4
- import { Network } from '../../constants';
5
- import { IDexHelper } from '../../dex-helper';
6
- import { Logger } from 'log4js';
7
- import { Interface } from '@ethersproject/abi';
8
- import { IntegralPool, PoolInitProps, RelayerPoolState } from './types';
9
- import { IntegralToken } from './integral-token';
10
- export declare class IntegralContext {
11
- readonly network: Network;
12
- readonly dexKey: string;
13
- readonly dexHelper: IDexHelper;
14
- readonly erc20Interface: Interface;
15
- readonly factoryAddress: Address;
16
- readonly relayerAddress: Address;
17
- static instances: {
18
- [network: number]: IntegralContext;
19
- };
20
- pools: {
21
- [poolId: string]: IntegralPool;
22
- };
23
- tokens: {
24
- [tokenAddress: Address]: IntegralToken;
25
- };
26
- factory: IntegralFactory;
27
- relayer: IntegralRelayer;
28
- logger: Logger;
29
- private constructor();
30
- addPools(pools: PoolInitProps, blockNumber: number, initPhase?: boolean): Promise<void>;
31
- getPoolAddresses(): string[];
32
- private removeDisabledPoolInitProps;
33
- static initialize(network: Network, dexKey: string, dexHelper: IDexHelper, erc20Interface: Interface, factoryAddress: Address, relayerAddress: Address): IntegralContext;
34
- static getInstance(network: Network): IntegralContext;
35
- onRelayerPoolEnabledSet(poolAddress: Address, state: RelayerPoolState, blockNumber: number): Promise<void>;
36
- onRebalanceSellOrderExecuted(blockNumber: number, orderId: bigint): void;
37
- onPoolCreatedAddPool(token0: Address, token1: Address, poolAddress: Address, blockNumber: number): Promise<void>;
38
- onPoolSwapForRelayer(blockNumber: number, poolAddress: Address, recipient: Address, amount0Out: bigint, amount1Out: bigint): Promise<void>;
39
- onTransferUpdateBalance(token: Address, from: Address, to: Address, amount: bigint, blockNumber: number): Promise<void>;
40
- }
@@ -1,158 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IntegralContext = void 0;
7
- const integral_pool_1 = require("./integral-pool");
8
- const integral_pricing_1 = require("./integral-pricing");
9
- const integral_factory_1 = require("./integral-factory");
10
- const integral_relayer_1 = require("./integral-relayer");
11
- const integral_token_1 = require("./integral-token");
12
- const utils_1 = require("./utils");
13
- const lodash_1 = __importDefault(require("lodash"));
14
- class IntegralContext {
15
- constructor(network, dexKey, dexHelper, erc20Interface, factoryAddress, relayerAddress) {
16
- this.network = network;
17
- this.dexKey = dexKey;
18
- this.dexHelper = dexHelper;
19
- this.erc20Interface = erc20Interface;
20
- this.factoryAddress = factoryAddress;
21
- this.relayerAddress = relayerAddress;
22
- this.pools = {};
23
- this.tokens = {};
24
- this.logger = dexHelper.getLogger(dexKey);
25
- this.factory = new integral_factory_1.IntegralFactory(dexHelper, dexKey, this.factoryAddress, this.onPoolCreatedAddPool, this.logger);
26
- this.relayer = new integral_relayer_1.IntegralRelayer(dexHelper, dexKey, this.erc20Interface, this.relayerAddress, {}, this.onRelayerPoolEnabledSet, this.logger);
27
- }
28
- async addPools(pools, blockNumber, initPhase = false) {
29
- this.relayer.addPools(pools);
30
- if (initPhase) {
31
- await this.relayer.initialize(blockNumber);
32
- }
33
- const _relayerState = this.relayer.getState(blockNumber);
34
- const relayerState = _relayerState
35
- ? _relayerState
36
- : await this.relayer.generateState(blockNumber);
37
- if (!_relayerState) {
38
- this.relayer.setState(relayerState, blockNumber);
39
- }
40
- const poolInitProps = this.removeDisabledPoolInitProps(relayerState, pools);
41
- const bases = Object.entries(poolInitProps).map(([poolAddress, p]) => {
42
- const poolId = (0, utils_1.getPoolIdentifier)(this.dexKey, p.token0, p.token1);
43
- const base = (this.pools[poolId] && this.pools[poolId].base) ||
44
- new integral_pool_1.IntegralEventPool(this.dexKey, this.network, this.dexHelper, poolAddress, p.token0, p.token1, this.logger);
45
- this.pools[poolId] = { base, enabled: true };
46
- return base;
47
- });
48
- await Promise.all(bases.map(base => !base.isInitialized && base.initialize(blockNumber)));
49
- const pricings = await Promise.all(bases.map(async (base) => {
50
- const _poolState = base.getState(blockNumber);
51
- const poolState = _poolState
52
- ? _poolState
53
- : await base.generateState(blockNumber);
54
- const poolId = (0, utils_1.getPoolIdentifier)(this.dexKey, base.token0, base.token1);
55
- const pricing = (this.pools[poolId] && this.pools[poolId].pricing) ||
56
- new integral_pricing_1.IntegralPricing(this.dexHelper, poolId, this.erc20Interface, poolState.uniswapPool, base.token0, base.token1, poolState.uniswapPoolFee, this.logger, this.network);
57
- this.pools[poolId].pricing = pricing;
58
- return pricing;
59
- }));
60
- await Promise.all(pricings.map(pricing => !pricing.isInitialized && pricing.initialize(blockNumber)));
61
- const initIntegralToken = (token) => new integral_token_1.IntegralToken(this.network, this.dexHelper, this.dexKey, this.erc20Interface, token, this.relayerAddress, this.onTransferUpdateBalance, this.logger);
62
- bases.map(base => {
63
- this.tokens[base.token0] =
64
- this.tokens[base.token0] || initIntegralToken(base.token0);
65
- this.tokens[base.token1] =
66
- this.tokens[base.token1] || initIntegralToken(base.token1);
67
- });
68
- await Promise.all(Object.values(this.tokens).map(token => !token.isInitialized && token.initialize(blockNumber)));
69
- }
70
- getPoolAddresses() {
71
- return Object.values(this.pools)
72
- .filter((pool) => !!pool.base && pool.enabled)
73
- .map(({ base }) => base.poolAddress);
74
- }
75
- removeDisabledPoolInitProps(state, props) {
76
- Object.entries(state.pools).forEach(([poolAddress, poolState]) => !poolState.isEnabled && delete props[poolAddress]);
77
- return props;
78
- }
79
- static initialize(network, dexKey, dexHelper, erc20Interface, factoryAddress, relayerAddress) {
80
- if (!this.instances[network]) {
81
- this.instances[network] = new IntegralContext(network, dexKey, dexHelper, erc20Interface, factoryAddress, relayerAddress);
82
- }
83
- return this.instances[network];
84
- }
85
- static getInstance(network) {
86
- if (!this.instances[network]) {
87
- throw new Error('IntegralContext instance not initialized');
88
- }
89
- return this.instances[network];
90
- }
91
- async onRelayerPoolEnabledSet(poolAddress, state, blockNumber) {
92
- const poolEntry = (0, utils_1.getPoolBackReferencedFrom)(this, poolAddress);
93
- if (state.isEnabled && (!poolEntry || !poolEntry[1].enabled)) {
94
- const _factoryState = this.factory.getStaleState();
95
- const factoryState = _factoryState
96
- ? _factoryState
97
- : await this.factory.generateState(blockNumber);
98
- const { token0, token1 } = factoryState.pools[poolAddress];
99
- await this.addPools({ [poolAddress]: { token0, token1 } }, blockNumber);
100
- }
101
- else if (!state.isEnabled && poolEntry && poolEntry[1].enabled) {
102
- this.pools[poolEntry[0]].enabled = false;
103
- }
104
- }
105
- onRebalanceSellOrderExecuted(blockNumber, orderId) {
106
- this.relayer.executeOrder(orderId, blockNumber);
107
- }
108
- async onPoolCreatedAddPool(token0, token1, poolAddress, blockNumber) {
109
- await this.addPools({ [poolAddress]: { token0, token1 } }, blockNumber);
110
- }
111
- async onPoolSwapForRelayer(blockNumber, poolAddress, recipient, amount0Out, amount1Out) {
112
- if (recipient.toLowerCase() === this.relayerAddress.toLowerCase()) {
113
- const pools = this.relayer.getPools();
114
- if (pools[poolAddress.toLowerCase()]) {
115
- const token0 = pools[poolAddress.toLowerCase()].token0;
116
- const token1 = pools[poolAddress.toLowerCase()].token1;
117
- let _state = this.relayer.getStaleState();
118
- if (!_state) {
119
- _state = await this.relayer.generateState(blockNumber);
120
- this.relayer.setState(_state, blockNumber);
121
- return;
122
- }
123
- else {
124
- blockNumber = this.relayer.getStateBlockNumber();
125
- }
126
- const state = lodash_1.default.cloneDeep(_state);
127
- if (amount1Out > 0n) {
128
- state.tokens[token1].balance += amount1Out;
129
- }
130
- else {
131
- state.tokens[token0].balance += amount0Out;
132
- }
133
- this.relayer.setState(state, blockNumber);
134
- }
135
- else {
136
- this.logger.error('Integral Relayer: Pool address not found for', poolAddress);
137
- }
138
- }
139
- }
140
- async onTransferUpdateBalance(token, from, to, amount, blockNumber) {
141
- let _state = this.relayer.getStaleState();
142
- if (!_state) {
143
- this.logger.error('Integral Token: Relayer stale state not found');
144
- return;
145
- }
146
- const state = lodash_1.default.cloneDeep(_state);
147
- if (this.relayer.relayerAddress.toLowerCase() === from) {
148
- state.tokens[token].balance -= amount;
149
- }
150
- else if (this.relayer.relayerAddress.toLowerCase() === to) {
151
- state.tokens[token].balance += amount;
152
- }
153
- this.relayer.setState(state, blockNumber);
154
- }
155
- }
156
- exports.IntegralContext = IntegralContext;
157
- IntegralContext.instances = {};
158
- //# sourceMappingURL=context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/dex/integral/context.ts"],"names":[],"mappings":";;;;;;AACA,mDAAoD;AACpD,yDAAqD;AACrD,yDAAqD;AACrD,yDAAqD;AAYrD,qDAAiD;AACjD,mCAAuE;AACvE,oDAAuB;AAEvB,MAAa,eAAe;IAU1B,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB,EACrB,cAAyB,EACzB,cAAuB,EACvB,cAAuB;QALvB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;QACrB,mBAAc,GAAd,cAAc,CAAW;QACzB,mBAAc,GAAd,cAAc,CAAS;QACvB,mBAAc,GAAd,cAAc,CAAS;QAblC,UAAK,GAAuC,EAAE,CAAC;QAC/C,WAAM,GAA+C,EAAE,CAAC;QActD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,IAAI,kCAAe,CAChC,SAAS,EACT,MAAM,EACN,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,oBAAoB,EACzB,IAAI,CAAC,MAAM,CACZ,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,IAAI,kC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,OAAO,CAAC,aAAa,EAAE,CAAC;QAC1C,IAAI,CAAC,MAAM,EAAE;YACX,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;YACnE,OAAO;SACR;QACD,MAAM,KAAK,GAAiB,gBAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE;YACtD,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC;SACvC;aAAM,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE;YAC3D,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC;SACvC;QACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAC5C,CAAC;;AAzQH,0CA0QC;AAzQQ,yBAAS,GAA2C,EAAE,CAAC"}
@@ -1,24 +0,0 @@
1
- import { Interface } from '@ethersproject/abi';
2
- import { LogDescription } from 'ethers/lib/utils';
3
- import { IDexHelper } from '../../dex-helper';
4
- import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
5
- import { Address, BlockHeader, Log, Logger } from '../../types';
6
- import { FactoryState } from './types';
7
- export declare type OnPoolCreatedCallback = (token0: Address, token1: Address, poolAddress: Address, blockNumber: number) => Promise<void>;
8
- export declare class IntegralFactory extends StatefulEventSubscriber<FactoryState> {
9
- readonly dexHelper: IDexHelper;
10
- protected readonly factoryAddress: Address;
11
- protected readonly onPoolCreated: OnPoolCreatedCallback;
12
- handlers: {
13
- [event: string]: (event: any, state: FactoryState, blockHeader: Readonly<BlockHeader>) => Promise<FactoryState>;
14
- };
15
- logDecoder: (log: Log) => any;
16
- readonly factoryIface: Interface;
17
- constructor(dexHelper: IDexHelper, parentName: string, factoryAddress: Address, onPoolCreated: OnPoolCreatedCallback, logger: Logger, mapKey?: string);
18
- protected getPoolIdentifierData(): {
19
- factory: string;
20
- };
21
- generateState(blockNumber?: number | 'latest'): Promise<FactoryState>;
22
- protected processLog(state: FactoryState, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): Promise<FactoryState>;
23
- handlePairCreated(event: LogDescription, state: FactoryState, blockHeader: Readonly<BlockHeader>): Promise<FactoryState>;
24
- }
@@ -1,95 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IntegralFactory = void 0;
7
- const abi_1 = require("@ethersproject/abi");
8
- const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
9
- const factory_json_1 = __importDefault(require("../../abi/integral/factory.json"));
10
- const pool_json_1 = __importDefault(require("../../abi/integral/pool.json"));
11
- const decoders_1 = require("../../lib/decoders");
12
- class IntegralFactory extends stateful_event_subscriber_1.StatefulEventSubscriber {
13
- constructor(dexHelper, parentName, factoryAddress, onPoolCreated, logger, mapKey = '') {
14
- super(parentName, `${parentName} Factory`, dexHelper, logger, true, mapKey);
15
- this.dexHelper = dexHelper;
16
- this.factoryAddress = factoryAddress;
17
- this.onPoolCreated = onPoolCreated;
18
- this.handlers = {};
19
- this.factoryIface = new abi_1.Interface(factory_json_1.default);
20
- this.addressesSubscribed = [factoryAddress];
21
- this.logDecoder = (log) => this.factoryIface.parseLog(log);
22
- this.handlers['PairCreated'] = this.handlePairCreated.bind(this);
23
- }
24
- getPoolIdentifierData() {
25
- return { factory: this.factoryAddress };
26
- }
27
- async generateState(blockNumber) {
28
- const factory = new this.dexHelper.web3Provider.eth.Contract(factory_json_1.default, this.factoryAddress);
29
- const poolCountResult = await factory.methods
30
- .allPairsLength()
31
- .call(undefined, blockNumber);
32
- const poolCount = Number(poolCountResult);
33
- const poolAddressCallDatas = [
34
- ...Array(poolCount),
35
- ].map((_, i) => {
36
- return {
37
- target: this.factoryAddress,
38
- callData: factory.methods.allPairs(i).encodeABI(),
39
- decodeFunction: decoders_1.addressDecode,
40
- };
41
- });
42
- const poolAddresses = await this.dexHelper.multiWrapper.tryAggregate(false, poolAddressCallDatas, blockNumber, this.dexHelper.multiWrapper.defaultBatchSize, false);
43
- const poolIface = new abi_1.Interface(pool_json_1.default);
44
- const poolInfosCallDatas = poolAddresses
45
- .map(poolAddress => {
46
- return [
47
- {
48
- target: poolAddress.returnData,
49
- callData: poolIface.encodeFunctionData('token0', []),
50
- decodeFunction: decoders_1.addressDecode,
51
- },
52
- {
53
- target: poolAddress.returnData,
54
- callData: poolIface.encodeFunctionData('token1', []),
55
- decodeFunction: decoders_1.addressDecode,
56
- },
57
- ];
58
- })
59
- .flat();
60
- const poolInfos = await this.dexHelper.multiWrapper.aggregate(poolInfosCallDatas, blockNumber);
61
- const state = { pools: {} };
62
- poolAddresses.forEach((poolAddress, i) => {
63
- const tokens = [
64
- poolInfos[i * 2].toLowerCase(),
65
- poolInfos[i * 2 + 1].toLowerCase(),
66
- ];
67
- state.pools[poolAddress.returnData.toLowerCase()] = {
68
- token0: tokens[0],
69
- token1: tokens[1],
70
- };
71
- });
72
- return state;
73
- }
74
- async processLog(state, log, blockHeader) {
75
- const event = this.logDecoder(log);
76
- if (event.name in this.handlers) {
77
- return await this.handlers[event.name](event, state, blockHeader);
78
- }
79
- return state;
80
- }
81
- async handlePairCreated(event, state, blockHeader) {
82
- const tokens = [
83
- event.args.token0.toLowerCase(),
84
- event.args.token1.toLowerCase(),
85
- ];
86
- state.pools[event.args.pair.toLowerCase()] = {
87
- token0: tokens[0],
88
- token1: tokens[1],
89
- };
90
- await this.onPoolCreated(tokens[0], tokens[1], event.args.pair.toLowerCase(), blockHeader.number);
91
- return state;
92
- }
93
- }
94
- exports.IntegralFactory = IntegralFactory;
95
- //# sourceMappingURL=integral-factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"integral-factory.js","s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AC,aAAa,CACtB,MAAM,CAAC,CAAC,CAAC,EACT,MAAM,CAAC,CAAC,CAAC,EACT,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAC7B,WAAW,CAAC,MAAM,CACnB,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAnID,0CAmIC"}
@@ -1,50 +0,0 @@
1
- import { Interface } from '@ethersproject/abi';
2
- import { LogDescription } from 'ethers/lib/utils';
3
- import { AsyncOrSync } from 'ts-essentials';
4
- import { BlockHeader, Log, Logger } from '../../types';
5
- import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
6
- import { IDexHelper } from '../../dex-helper/idex-helper';
7
- import { PoolState } from './types';
8
- import { Address } from '../../types';
9
- export declare class IntegralEventPool extends StatefulEventSubscriber<PoolState> {
10
- parentName: string;
11
- protected network: number;
12
- protected dexHelper: IDexHelper;
13
- protected poolIface: Interface;
14
- handlers: {
15
- [event: string]: (event: any, pool: PoolState, blockHeader: Readonly<BlockHeader>) => AsyncOrSync<PoolState>;
16
- };
17
- logDecoder: (log: Log) => any;
18
- addressesSubscribed: string[];
19
- readonly poolAddress: Address;
20
- readonly token0: Address;
21
- readonly token1: Address;
22
- constructor(parentName: string, network: number, dexHelper: IDexHelper, poolAddress: Address, token0: Address, token1: Address, logger: Logger, poolIface?: Interface);
23
- protected getPoolIdentifierData(): {
24
- token0: string;
25
- token1: string;
26
- };
27
- /**
28
- * The function is called every time any of the subscribed
29
- * addresses release log. The function accepts the current
30
- * state, updates the state according to the log, and returns
31
- * the updated state.
32
- * @param state - Current state of event subscriber
33
- * @param log - Log released by one of the subscribed addresses
34
- * @returns Updates state of the event subscriber after the log
35
- */
36
- protected processLog(state: PoolState, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): Promise<PoolState | null>;
37
- /**
38
- * The function generates state using on-chain calls. This
39
- * function is called to regenerate state if the event based
40
- * system fails to fetch events and the local state is no
41
- * more correct.
42
- * @param blockNumber - Blocknumber for which the state should
43
- * should be generated
44
- * @returns state of the event subscriber at blocknumber
45
- */
46
- generateState(blockNumber: number): Promise<Readonly<PoolState>>;
47
- handleSetSwapFee(event: LogDescription, pool: PoolState): PoolState;
48
- handleSetMintFee(event: LogDescription, pool: PoolState): PoolState;
49
- handleSetBurnFee(event: LogDescription, pool: PoolState): PoolState;
50
- }
@@ -1,149 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IntegralEventPool = void 0;
7
- const abi_1 = require("@ethersproject/abi");
8
- const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
9
- const pool_json_1 = __importDefault(require("../../abi/integral/pool.json"));
10
- const oracle_json_1 = __importDefault(require("../../abi/integral/oracle.json"));
11
- const UniswapV3Pool_abi_json_1 = __importDefault(require("../../abi/uniswap-v3/UniswapV3Pool.abi.json"));
12
- const decoders_1 = require("../../lib/decoders");
13
- const ethers_1 = require("ethers");
14
- class IntegralEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
15
- constructor(parentName, network, dexHelper, poolAddress, token0, token1, logger, poolIface = new abi_1.Interface(pool_json_1.default)) {
16
- super(parentName, `${token0}_${token1}`, dexHelper, logger);
17
- this.parentName = parentName;
18
- this.network = network;
19
- this.dexHelper = dexHelper;
20
- this.poolIface = poolIface;
21
- this.handlers = {};
22
- this.token0 = token0.toLowerCase();
23
- this.token1 = token1.toLowerCase();
24
- this.poolAddress = poolAddress.toLowerCase();
25
- this.logDecoder = (log) => this.poolIface.parseLog(log);
26
- this.addressesSubscribed = [this.poolAddress];
27
- this.handlers['SetSwapFee'] = this.handleSetSwapFee.bind(this);
28
- this.handlers['SetMintFee'] = this.handleSetMintFee.bind(this);
29
- this.handlers['SetBurnFee'] = this.handleSetBurnFee.bind(this);
30
- }
31
- getPoolIdentifierData() {
32
- return {
33
- token0: this.token0,
34
- token1: this.token1,
35
- };
36
- }
37
- /**
38
- * The function is called every time any of the subscribed
39
- * addresses release log. The function accepts the current
40
- * state, updates the state according to the log, and returns
41
- * the updated state.
42
- * @param state - Current state of event subscriber
43
- * @param log - Log released by one of the subscribed addresses
44
- * @returns Updates state of the event subscriber after the log
45
- */
46
- async processLog(state, log, blockHeader) {
47
- try {
48
- const event = this.logDecoder(log);
49
- if (event.name in this.handlers) {
50
- return await this.handlers[event.name](event, state, blockHeader);
51
- }
52
- return state;
53
- }
54
- catch (e) {
55
- this.logger.error(`Error_${this.parentName}_processLog could not parse the log with topic ${log.topics}:`, e);
56
- return null;
57
- }
58
- }
59
- /**
60
- * The function generates state using on-chain calls. This
61
- * function is called to regenerate state if the event based
62
- * system fails to fetch events and the local state is no
63
- * more correct.
64
- * @param blockNumber - Blocknumber for which the state should
65
- * should be generated
66
- * @returns state of the event subscriber at blocknumber
67
- */
68
- async generateState(blockNumber) {
69
- const state = {};
70
- const pool = new this.dexHelper.web3Provider.eth.Contract(pool_json_1.default, this.poolAddress);
71
- const poolInfoCallDatas = [
72
- {
73
- target: this.poolAddress,
74
- callData: pool.methods.oracle().encodeABI(),
75
- decodeFunction: decoders_1.addressDecode,
76
- },
77
- {
78
- target: this.poolAddress,
79
- callData: pool.methods.mintFee().encodeABI(),
80
- decodeFunction: decoders_1.uint256ToBigInt,
81
- },
82
- {
83
- target: this.poolAddress,
84
- callData: pool.methods.burnFee().encodeABI(),
85
- decodeFunction: decoders_1.uint256ToBigInt,
86
- },
87
- {
88
- target: this.poolAddress,
89
- callData: pool.methods.swapFee().encodeABI(),
90
- decodeFunction: decoders_1.uint256ToBigInt,
91
- },
92
- ];
93
- const poolInfos = await this.dexHelper.multiWrapper.aggregate(poolInfoCallDatas, blockNumber);
94
- const oracleAddress = poolInfos[0].toString();
95
- state.mintFee = BigInt(poolInfos[1]);
96
- state.burnFee = BigInt(poolInfos[2]);
97
- state.swapFee = BigInt(poolInfos[3]);
98
- state.oracle = oracleAddress;
99
- const historyState = this.getStaleState();
100
- if (!historyState) {
101
- const oracle = new this.dexHelper.web3Provider.eth.Contract(oracle_json_1.default, oracleAddress);
102
- const oracleInfosCallDatas = [
103
- {
104
- target: oracleAddress,
105
- callData: oracle.methods.xDecimals().encodeABI(),
106
- decodeFunction: decoders_1.uint8ToNumber,
107
- },
108
- {
109
- target: oracleAddress,
110
- callData: oracle.methods.yDecimals().encodeABI(),
111
- decodeFunction: decoders_1.uint8ToNumber,
112
- },
113
- {
114
- target: oracleAddress,
115
- callData: oracle.methods.uniswapPair().encodeABI(),
116
- decodeFunction: decoders_1.addressDecode,
117
- },
118
- ];
119
- const oracleInfos = await this.dexHelper.multiWrapper.aggregate(oracleInfosCallDatas, blockNumber);
120
- state.uniswapPool = oracleInfos[2].toString();
121
- state.decimals0 = Number(oracleInfos[0]);
122
- state.decimals1 = Number(oracleInfos[1]);
123
- const uniswapPool = new this.dexHelper.web3Provider.eth.Contract(UniswapV3Pool_abi_json_1.default, state.uniswapPool);
124
- const fee = await uniswapPool.methods.fee().call(undefined, blockNumber);
125
- state.uniswapPoolFee = BigInt(fee);
126
- }
127
- else {
128
- state.uniswapPool = historyState.uniswapPool;
129
- state.decimals0 = historyState.decimals0;
130
- state.decimals1 = historyState.decimals1;
131
- state.uniswapPoolFee = historyState.uniswapPoolFee;
132
- }
133
- return state;
134
- }
135
- handleSetSwapFee(event, pool) {
136
- pool.swapFee = BigInt(ethers_1.BigNumber.from(event.args.fee).toString());
137
- return pool;
138
- }
139
- handleSetMintFee(event, pool) {
140
- pool.mintFee = BigInt(ethers_1.BigNumber.from(event.args.fee).toString());
141
- return pool;
142
- }
143
- handleSetBurnFee(event, pool) {
144
- pool.burnFee = BigInt(ethers_1.BigNumber.from(event.args.fee).toString());
145
- return pool;
146
- }
147
- }
148
- exports.IntegralEventPool = IntegralEventPool;
149
- //# sourceMappingURL=integral-pool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"integral-pool.js","sourceRoot":"","sources":["../../../src/dex/integral/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AAO,GAAG,MAAM,CAAC,kBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB,CAAC,KAAqB,EAAE,IAAe;QACrD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,kBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB,CAAC,KAAqB,EAAE,IAAe;QACrD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,kBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAvLD,8CAuLC"}
@@ -1,18 +0,0 @@
1
- import { Interface } from '@ethersproject/abi';
2
- import { IDexHelper } from '../../dex-helper';
3
- import { Address, Logger } from '../../types';
4
- import { UniswapV3EventPool } from '../uniswap-v3/uniswap-v3-pool';
5
- import { Network } from '../../constants';
6
- import { PoolState } from '../uniswap-v3/types';
7
- import { Observation } from './types';
8
- import { MultiResult } from '../../lib/multi-wrapper';
9
- import { BytesLike } from 'ethers';
10
- export declare function decodeStateMultiCallResultWithObservation(result: MultiResult<BytesLike> | BytesLike): Observation;
11
- export declare class IntegralPricing extends UniswapV3EventPool {
12
- readonly dexHelper: IDexHelper;
13
- private readonly providedPoolAddress;
14
- constructor(dexHelper: IDexHelper, parentName: string, erc20Interface: Interface, poolAddress: Address, token0: Address, token1: Address, feeCode: bigint, logger: Logger, network: Network, mapKey?: string);
15
- get poolAddress(): Address;
16
- set poolAddress(_address: Address);
17
- generateState(blockNumber: number): Promise<Readonly<PoolState>>;
18
- }