@paraswap/dex-lib 4.0.0 → 4.0.1-balancer-v3-cables.0

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 (359) hide show
  1. package/.vscode/launch.json +53 -0
  2. package/.vscode/settings.json +2 -0
  3. package/.vscode/tasks.json +15 -0
  4. package/build/abi/balancer-v3/batch-router.json +989 -0
  5. package/build/abi/balancer-v3/router.json +1792 -0
  6. package/build/abi/balancer-v3/vault-extension.json +2834 -0
  7. package/build/abi/permit2.json +581 -0
  8. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
  9. package/build/abi/usual-m-smart-m/usualM.abi.json +483 -0
  10. package/build/abi/usual-m-usd0/usualCollateralDao.abi.json +681 -0
  11. package/build/abi/{angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json → wombat/pool.json} +637 -594
  12. package/build/bigint-constants.d.ts +1 -0
  13. package/build/bigint-constants.js +2 -1
  14. package/build/bigint-constants.js.map +1 -1
  15. package/build/config.js +28 -0
  16. package/build/config.js.map +1 -1
  17. package/build/constants.d.ts +2 -0
  18. package/build/constants.js +4 -1
  19. package/build/constants.js.map +1 -1
  20. package/build/dex/aave-v1/aave-v1.js +1 -0
  21. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  22. package/build/dex/aave-v2/tokens-avalanche.json +44 -0
  23. package/build/dex/aave-v2/tokens-mainnet.json +188 -0
  24. package/build/dex/aave-v2/tokens-polygon.json +44 -0
  25. package/build/dex/augustus-approvals.d.ts +3 -2
  26. package/build/dex/augustus-approvals.js +35 -16
  27. package/build/dex/augustus-approvals.js.map +1 -1
  28. package/build/dex/bProtocol.d.ts +18 -0
  29. package/build/dex/bProtocol.js +39 -0
  30. package/build/dex/bProtocol.js.map +1 -0
  31. package/build/dex/balancer-v3/abi/balancerBatchRouter.d.ts +729 -0
  32. package/build/dex/balancer-v3/abi/balancerBatchRouter.js +732 -0
  33. package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +1 -0
  34. package/build/dex/balancer-v3/abi/balancerRouter.d.ts +1406 -0
  35. package/build/dex/balancer-v3/abi/balancerRouter.js +1175 -0
  36. package/build/dex/balancer-v3/abi/balancerRouter.js.map +1 -0
  37. package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +2081 -0
  38. package/build/dex/balancer-v3/abi/vaultExtension.V3.js +1851 -0
  39. package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +1 -0
  40. package/build/dex/balancer-v3/balancer-v3-pool.d.ts +80 -0
  41. package/build/dex/balancer-v3/balancer-v3-pool.js +469 -0
  42. package/build/dex/balancer-v3/balancer-v3-pool.js.map +1 -0
  43. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.d.ts +34 -0
  44. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js +406 -0
  45. package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js.map +1 -0
  46. package/build/dex/balancer-v3/balancer-v3.d.ts +56 -0
  47. package/build/dex/balancer-v3/balancer-v3.js +412 -0
  48. package/build/dex/balancer-v3/balancer-v3.js.map +1 -0
  49. package/build/dex/balancer-v3/config.d.ts +9 -0
  50. package/build/dex/balancer-v3/config.js +45 -0
  51. package/build/dex/balancer-v3/config.js.map +1 -0
  52. package/build/dex/balancer-v3/getGasCost.d.ts +2 -0
  53. package/build/dex/balancer-v3/getGasCost.js +40 -0
  54. package/build/dex/balancer-v3/getGasCost.js.map +1 -0
  55. package/build/dex/balancer-v3/getOnChainState.d.ts +10 -0
  56. package/build/dex/balancer-v3/getOnChainState.js +163 -0
  57. package/build/dex/balancer-v3/getOnChainState.js.map +1 -0
  58. package/build/dex/balancer-v3/getPoolsApi.d.ts +2 -0
  59. package/build/dex/balancer-v3/getPoolsApi.js +84 -0
  60. package/build/dex/balancer-v3/getPoolsApi.js.map +1 -0
  61. package/build/dex/balancer-v3/getTopPoolsApi.d.ts +17 -0
  62. package/build/dex/balancer-v3/getTopPoolsApi.js +65 -0
  63. package/build/dex/balancer-v3/getTopPoolsApi.js.map +1 -0
  64. package/build/dex/balancer-v3/optimizer.d.ts +2 -0
  65. package/build/dex/balancer-v3/optimizer.js +47 -0
  66. package/build/dex/balancer-v3/optimizer.js.map +1 -0
  67. package/build/dex/balancer-v3/stablePool.d.ts +7 -0
  68. package/build/dex/balancer-v3/stablePool.js +73 -0
  69. package/build/dex/balancer-v3/stablePool.js.map +1 -0
  70. package/build/dex/balancer-v3/types.d.ts +62 -0
  71. package/build/dex/balancer-v3/types.js +3 -0
  72. package/build/dex/balancer-v3/types.js.map +1 -0
  73. package/build/dex/balancer-v3/weightedPool.d.ts +1 -0
  74. package/build/dex/balancer-v3/weightedPool.js +6 -0
  75. package/build/dex/balancer-v3/weightedPool.js.map +1 -0
  76. package/build/dex/bancor.d.ts +26 -0
  77. package/build/dex/bancor.js +58 -0
  78. package/build/dex/bancor.js.map +1 -0
  79. package/build/dex/cables/cables.d.ts +7 -5
  80. package/build/dex/cables/cables.js +229 -86
  81. package/build/dex/cables/cables.js.map +1 -1
  82. package/build/dex/cables/constants.d.ts +13 -12
  83. package/build/dex/cables/constants.js +14 -16
  84. package/build/dex/cables/constants.js.map +1 -1
  85. package/build/dex/cables/types.d.ts +7 -0
  86. package/build/dex/cables/types.js +8 -1
  87. package/build/dex/cables/types.js.map +1 -1
  88. package/build/dex/compound.d.ts +18 -0
  89. package/build/dex/compound.js +46 -0
  90. package/build/dex/compound.js.map +1 -0
  91. package/build/dex/curve-v2.d.ts +58 -0
  92. package/build/dex/curve-v2.js +180 -0
  93. package/build/dex/curve-v2.js.map +1 -0
  94. package/build/dex/dodo-v1.d.ts +33 -0
  95. package/build/dex/dodo-v1.js +63 -0
  96. package/build/dex/dodo-v1.js.map +1 -0
  97. package/build/dex/fluid-dex/fluid-dex-pool.d.ts +47 -0
  98. package/build/dex/fluid-dex/fluid-dex-pool.js +119 -0
  99. package/build/dex/fluid-dex/fluid-dex-pool.js.map +1 -0
  100. package/build/dex/inception/inception-event-pool.d.ts +4 -4
  101. package/build/dex/inception/inception-event-pool.js +7 -9
  102. package/build/dex/inception/inception-event-pool.js.map +1 -1
  103. package/build/dex/inception/inception.d.ts +6 -6
  104. package/build/dex/inception/inception.js +16 -40
  105. package/build/dex/inception/inception.js.map +1 -1
  106. package/build/dex/inception/utils.d.ts +1 -0
  107. package/build/dex/inception/utils.js +22 -1
  108. package/build/dex/inception/utils.js.map +1 -1
  109. package/build/dex/index.js +4 -0
  110. package/build/dex/index.js.map +1 -1
  111. package/build/dex/lido.d.ts +19 -0
  112. package/build/dex/lido.js +42 -0
  113. package/build/dex/lido.js.map +1 -0
  114. package/build/dex/maker-psm/scripts/gem.abi.json +136 -0
  115. package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
  116. package/build/dex/maker-psm/scripts/validate-state.js +185 -0
  117. package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
  118. package/build/dex/maker-psm/scripts/vat.abi.json +243 -0
  119. package/build/dex/onebit.d.ts +25 -0
  120. package/build/dex/onebit.js +42 -0
  121. package/build/dex/onebit.js.map +1 -0
  122. package/build/dex/platypus/platypus.js +17 -3
  123. package/build/dex/platypus/platypus.js.map +1 -1
  124. package/build/dex/smoothy.d.ts +26 -0
  125. package/build/dex/smoothy.js +48 -0
  126. package/build/dex/smoothy.js.map +1 -0
  127. package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +1 -0
  128. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
  129. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
  130. package/build/dex/stable-pool.d.ts +28 -0
  131. package/build/dex/stable-pool.js +55 -0
  132. package/build/dex/stable-pool.js.map +1 -0
  133. package/build/dex/swaap-v1/swaap-v1.js +4 -0
  134. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  135. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +7 -0
  136. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +20 -0
  137. package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +1 -0
  138. package/build/dex/trader-joe-v2.1.d.ts +43 -0
  139. package/build/dex/trader-joe-v2.1.js +79 -0
  140. package/build/dex/trader-joe-v2.1.js.map +1 -0
  141. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
  142. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
  143. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
  144. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
  145. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
  146. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
  147. package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +4 -0
  148. package/build/dex/uniswap-v3/uniswap-v3-pricing.js +43 -0
  149. package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +1 -0
  150. package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +1 -0
  151. package/build/dex/uniswap-v3/uniswap-v3-worker.js +10 -0
  152. package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +1 -0
  153. package/build/dex/usual/types.d.ts +13 -0
  154. package/build/dex/usual/types.js +3 -0
  155. package/build/dex/usual/types.js.map +1 -0
  156. package/build/dex/usual/usual-bond.d.ts +18 -0
  157. package/build/dex/usual/usual-bond.js +52 -0
  158. package/build/dex/usual/usual-bond.js.map +1 -0
  159. package/build/dex/usual/usual-m-smart-m.d.ts +17 -0
  160. package/build/dex/usual/usual-m-smart-m.js +50 -0
  161. package/build/dex/usual/usual-m-smart-m.js.map +1 -0
  162. package/build/dex/usual/usual-m-usd0.d.ts +17 -0
  163. package/build/dex/usual/usual-m-usd0.js +51 -0
  164. package/build/dex/usual/usual-m-usd0.js.map +1 -0
  165. package/build/dex/usual/usual.d.ts +27 -0
  166. package/build/dex/usual/usual.js +125 -0
  167. package/build/dex/usual/usual.js.map +1 -0
  168. package/build/dex/usual-m-smart-m/config.d.ts +3 -0
  169. package/build/dex/usual-m-smart-m/config.js +13 -0
  170. package/build/dex/usual-m-smart-m/config.js.map +1 -0
  171. package/build/dex/usual-m-smart-m/types.d.ts +7 -0
  172. package/build/dex/usual-m-smart-m/types.js +3 -0
  173. package/build/dex/usual-m-smart-m/types.js.map +1 -0
  174. package/build/dex/usual-m-smart-m/usual-m-smart-m.d.ts +35 -0
  175. package/build/dex/usual-m-smart-m/usual-m-smart-m.js +161 -0
  176. package/build/dex/usual-m-smart-m/usual-m-smart-m.js.map +1 -0
  177. package/build/dex/usual-m-usd0/config.d.ts +3 -0
  178. package/build/dex/usual-m-usd0/config.js +14 -0
  179. package/build/dex/usual-m-usd0/config.js.map +1 -0
  180. package/build/dex/usual-m-usd0/types.d.ts +8 -0
  181. package/build/dex/usual-m-usd0/types.js +3 -0
  182. package/build/dex/usual-m-usd0/types.js.map +1 -0
  183. package/build/dex/usual-m-usd0/usual-m-usd0.d.ts +35 -0
  184. package/build/dex/usual-m-usd0/usual-m-usd0.js +159 -0
  185. package/build/dex/usual-m-usd0/usual-m-usd0.js.map +1 -0
  186. package/build/dex/weth/config.js +3 -0
  187. package/build/dex/weth/config.js.map +1 -1
  188. package/build/executor/Executor01BytecodeBuilder.js +2 -2
  189. package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
  190. package/build/executor/Executor02BytecodeBuilder.js +2 -2
  191. package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
  192. package/build/executor/Executor03BytecodeBuilder.js +2 -2
  193. package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
  194. package/build/executor/ExecutorBytecodeBuilder.d.ts +3 -1
  195. package/build/executor/ExecutorBytecodeBuilder.js +35 -2
  196. package/build/executor/ExecutorBytecodeBuilder.js.map +1 -1
  197. package/build/generic-swap-transaction-builder.js +5 -1
  198. package/build/generic-swap-transaction-builder.js.map +1 -1
  199. package/build/types.d.ts +1 -0
  200. package/package.json +2 -1
  201. package/scripts/run-dex-integration-v3.ts +78 -0
  202. package/src/abi/balancer-v3/batch-router.json +989 -0
  203. package/src/abi/balancer-v3/router.json +1792 -0
  204. package/src/abi/balancer-v3/vault-extension.json +2834 -0
  205. package/src/abi/permit2.json +581 -0
  206. package/src/bigint-constants.ts +1 -0
  207. package/src/config.ts +29 -0
  208. package/src/constants.ts +4 -0
  209. package/src/dex/augustus-approvals.ts +52 -19
  210. package/src/dex/balancer-v3/balancer-v3-e2e.test.ts +275 -0
  211. package/src/dex/balancer-v3/balancer-v3-events.test.ts +223 -0
  212. package/src/dex/balancer-v3/balancer-v3-integration.test.ts +879 -0
  213. package/src/dex/balancer-v3/balancer-v3-pool.ts +656 -0
  214. package/src/dex/balancer-v3/balancer-v3.ts +538 -0
  215. package/src/dex/balancer-v3/config.ts +46 -0
  216. package/src/dex/balancer-v3/getGasCost.ts +37 -0
  217. package/src/dex/balancer-v3/getOnChainState.ts +326 -0
  218. package/src/dex/balancer-v3/getPoolsApi.ts +129 -0
  219. package/src/dex/balancer-v3/getTopPoolsApi.ts +96 -0
  220. package/src/dex/balancer-v3/optimizer.ts +66 -0
  221. package/src/dex/balancer-v3/stablePool.ts +78 -0
  222. package/src/dex/balancer-v3/types.ts +86 -0
  223. package/src/dex/balancer-v3/weightedPool.ts +2 -0
  224. package/src/dex/index.ts +4 -0
  225. package/src/dex/weth/config.ts +3 -0
  226. package/src/executor/Executor01BytecodeBuilder.ts +2 -0
  227. package/src/executor/Executor02BytecodeBuilder.ts +2 -0
  228. package/src/executor/Executor03BytecodeBuilder.ts +2 -0
  229. package/src/executor/ExecutorBytecodeBuilder.ts +63 -2
  230. package/src/generic-swap-transaction-builder.ts +6 -2
  231. package/src/types.ts +1 -0
  232. package/tests/constants-e2e.ts +66 -0
  233. package/build/abi/Aave_GSM.json +0 -751
  234. package/build/abi/Balancer.json +0 -257
  235. package/build/abi/BalancerV2.json +0 -1179
  236. package/build/abi/RamsesV2Pool.abi.json +0 -1554
  237. package/build/abi/RamsesV2Quoter.abi.json +0 -274
  238. package/build/abi/USDM.json +0 -807
  239. package/build/abi/UniswapV2Router.json +0 -397
  240. package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +0 -509
  241. package/build/abi/curve-v1/CurveBUSDv2.abi.json +0 -1356
  242. package/build/abi/curve-v1/CurveTokenV1.json +0 -305
  243. package/build/abi/curve-v1/CurveTokenV2.json +0 -318
  244. package/build/abi/curve-v1/CurveV1StableNg.json +0 -1452
  245. package/build/abi/curve-v1/CurveV2Swap.json +0 -700
  246. package/build/abi/curve-v1/FactoryCryptoRegistry.json +0 -316
  247. package/build/abi/curve-v1/FactoryRegistry.json +0 -508
  248. package/build/abi/curve-v1/StableSwapAave.json +0 -1152
  249. package/build/abi/curve-v1/StableSwapBUSD.json +0 -814
  250. package/build/abi/curve-v1/StableSwapCompound.json +0 -814
  251. package/build/abi/curve-v1/StableSwapIDLE.json +0 -1253
  252. package/build/abi/curve-v1/StableSwapPax.json +0 -865
  253. package/build/abi/curve-v1/StableSwapSnow.json +0 -900
  254. package/build/abi/curve-v1/StableSwapUSDN.json +0 -1004
  255. package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
  256. package/build/abi/curve-v1/StableSwapY.json +0 -814
  257. package/build/abi/inception/inception-ineth.json +0 -609
  258. package/build/abi/kyberdmm/kyber-storage.abi.json +0 -824
  259. package/build/abi/kyberdmm.abi.json +0 -1148
  260. package/build/abi/maverick-v2/MaverickV2Quoter.json +0 -278
  261. package/build/abi/nerve/nerve-metapool.json +0 -790
  262. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  263. package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
  264. package/build/dex/balancer-v1/balancer-pools.json +0 -33333
  265. package/build/dex/bebop/websocket-fetcher.d.ts +0 -35
  266. package/build/dex/bebop/websocket-fetcher.js +0 -87
  267. package/build/dex/bebop/websocket-fetcher.js.map +0 -1
  268. package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
  269. package/build/dex/idle-dao/idle-dao-pool.js +0 -176
  270. package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
  271. package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
  272. package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
  273. package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
  274. package/build/dex/idle-dao/scripts.d.ts +0 -9
  275. package/build/dex/idle-dao/scripts.js +0 -552
  276. package/build/dex/idle-dao/scripts.js.map +0 -1
  277. package/build/dex/inception/inception-native.d.ts +0 -43
  278. package/build/dex/inception/inception-native.js +0 -131
  279. package/build/dex/inception/inception-native.js.map +0 -1
  280. package/build/dex/inception/inception-pool.d.ts +0 -18
  281. package/build/dex/inception/inception-pool.js +0 -32
  282. package/build/dex/inception/inception-pool.js.map +0 -1
  283. package/build/dex/inception/inception-price-feed.d.ts +0 -19
  284. package/build/dex/inception/inception-price-feed.js +0 -51
  285. package/build/dex/inception/inception-price-feed.js.map +0 -1
  286. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -16
  287. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -16
  288. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -16
  289. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -16
  290. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -16
  291. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -16
  292. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -16
  293. package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -16
  294. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -9
  295. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -9
  296. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -9
  297. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +0 -9
  298. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +0 -9
  299. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -9
  300. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +0 -9
  301. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +0 -9
  302. package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +0 -9
  303. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -12
  304. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -7
  305. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -7
  306. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -7
  307. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -7
  308. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -12
  309. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +0 -7
  310. package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +0 -7
  311. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -78
  312. package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -81
  313. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -78
  314. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -78
  315. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -81
  316. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -81
  317. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -81
  318. package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -81
  319. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -64
  320. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -85
  321. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -64
  322. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +0 -52
  323. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +0 -52
  324. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -52
  325. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +0 -55
  326. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +0 -55
  327. package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +0 -55
  328. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -23
  329. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -37
  330. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -23
  331. package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -23
  332. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -51
  333. package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +0 -58
  334. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -23
  335. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -23
  336. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -9
  337. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -16
  338. package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -23
  339. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -12
  340. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -7
  341. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -12
  342. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -12
  343. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -7
  344. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +0 -7
  345. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -7
  346. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -7
  347. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -7
  348. package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -7
  349. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -130
  350. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -136
  351. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -100
  352. package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -100
  353. package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -166
  354. package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +0 -190
  355. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -114
  356. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -114
  357. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -55
  358. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -73
  359. package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -82
@@ -1,19 +1,20 @@
1
- import BigNumber from 'bignumber.js';
2
1
  /**
3
2
  * Cables
4
3
  */
5
4
  export declare const CABLES_API_URL = "https://cables-evm-rfq-service.cryptosrvc.com/v1";
6
- export declare const CABLES_PRICES_CACHES_TTL_S = 3;
7
- export declare const CABLES_API_PRICES_POLLING_INTERVAL_MS = 1000;
8
- export declare const CABLES_PAIRS_CACHES_TTL_S: number;
9
- export declare const CABLES_API_PAIRS_POLLING_INTERVAL_MS: number;
10
- export declare const CABLES_BLACKLIST_CACHES_TTL_S: number;
11
- export declare const CABLES_API_BLACKLIST_POLLING_INTERVAL_MS: number;
12
- export declare const CABLES_TOKENS_CACHES_TTL_S: number;
5
+ export declare const CABLES_PRICES_CACHES_TTL_S = 10;
6
+ export declare const CABLES_API_PRICES_POLLING_INTERVAL_MS = 2000;
7
+ export declare const CABLES_PAIRS_CACHES_TTL_S = 12;
8
+ export declare const CABLES_API_PAIRS_POLLING_INTERVAL_MS = 10000;
9
+ export declare const CABLES_BLACKLIST_CACHES_TTL_S = 60;
10
+ export declare const CABLES_API_BLACKLIST_POLLING_INTERVAL_MS = 30000;
11
+ export declare const CABLES_TOKENS_CACHES_TTL_S = 60;
12
+ export declare const CABLES_API_TOKENS_POLLING_INTERVAL_MS = 30000;
13
13
  export declare const CABLES_FIRM_QUOTE_TIMEOUT_MS = 2000;
14
- export declare const CABLES_RATE_LIMITED_TTL_S: number;
15
- export declare const CABLES_RATELIMIT_CACHE_VALUE = "limited";
16
- export declare const CABLES_RESTRICT_TTL_S: number;
14
+ export declare const CABLES_BLACKLIST_CACHE_KEY = "cablesBlacklistCacheKey";
17
15
  export declare const CABLES_RESTRICTED_CACHE_KEY = "restricted";
18
- export declare const CABLES_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION: BigNumber;
16
+ export declare const CABLES_ERRORS_CACHE_KEY = "errors";
17
+ export declare const CABLES_RESTRICT_CHECK_INTERVAL_MS: number;
18
+ export declare const CABLES_RESTRICT_COUNT_THRESHOLD = 3;
19
+ export declare const CABLES_RESTRICT_TTL_S: number;
19
20
  export declare const CABLES_GAS_COST = 120000;
@@ -1,26 +1,24 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CABLES_GAS_COST = exports.CABLES_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION = exports.CABLES_RESTRICTED_CACHE_KEY = exports.CABLES_RESTRICT_TTL_S = exports.CABLES_RATELIMIT_CACHE_VALUE = exports.CABLES_RATE_LIMITED_TTL_S = exports.CABLES_FIRM_QUOTE_TIMEOUT_MS = exports.CABLES_TOKENS_CACHES_TTL_S = exports.CABLES_API_BLACKLIST_POLLING_INTERVAL_MS = exports.CABLES_BLACKLIST_CACHES_TTL_S = exports.CABLES_API_PAIRS_POLLING_INTERVAL_MS = exports.CABLES_PAIRS_CACHES_TTL_S = exports.CABLES_API_PRICES_POLLING_INTERVAL_MS = exports.CABLES_PRICES_CACHES_TTL_S = exports.CABLES_API_URL = void 0;
7
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
3
+ exports.CABLES_GAS_COST = exports.CABLES_RESTRICT_TTL_S = exports.CABLES_RESTRICT_COUNT_THRESHOLD = exports.CABLES_RESTRICT_CHECK_INTERVAL_MS = exports.CABLES_ERRORS_CACHE_KEY = exports.CABLES_RESTRICTED_CACHE_KEY = exports.CABLES_BLACKLIST_CACHE_KEY = exports.CABLES_FIRM_QUOTE_TIMEOUT_MS = exports.CABLES_API_TOKENS_POLLING_INTERVAL_MS = exports.CABLES_TOKENS_CACHES_TTL_S = exports.CABLES_API_BLACKLIST_POLLING_INTERVAL_MS = exports.CABLES_BLACKLIST_CACHES_TTL_S = exports.CABLES_API_PAIRS_POLLING_INTERVAL_MS = exports.CABLES_PAIRS_CACHES_TTL_S = exports.CABLES_API_PRICES_POLLING_INTERVAL_MS = exports.CABLES_PRICES_CACHES_TTL_S = exports.CABLES_API_URL = void 0;
8
4
  /**
9
5
  * Cables
10
6
  */
11
7
  exports.CABLES_API_URL = 'https://cables-evm-rfq-service.cryptosrvc.com/v1';
12
- exports.CABLES_PRICES_CACHES_TTL_S = 3;
13
- exports.CABLES_API_PRICES_POLLING_INTERVAL_MS = 1000; // 1 sec
14
- exports.CABLES_PAIRS_CACHES_TTL_S = 10 * 60; // 10 mins
15
- exports.CABLES_API_PAIRS_POLLING_INTERVAL_MS = 1000 * 60 * 10; // 10 mins
16
- exports.CABLES_BLACKLIST_CACHES_TTL_S = 30 * 60; // 30 mins
17
- exports.CABLES_API_BLACKLIST_POLLING_INTERVAL_MS = 1000 * 60 * 60; // 60 mins
18
- exports.CABLES_TOKENS_CACHES_TTL_S = 10 * 60; // 10 mins
8
+ exports.CABLES_PRICES_CACHES_TTL_S = 10;
9
+ exports.CABLES_API_PRICES_POLLING_INTERVAL_MS = 2000; // 2 sec
10
+ exports.CABLES_PAIRS_CACHES_TTL_S = 12;
11
+ exports.CABLES_API_PAIRS_POLLING_INTERVAL_MS = 10000; // 10 sec
12
+ exports.CABLES_BLACKLIST_CACHES_TTL_S = 60;
13
+ exports.CABLES_API_BLACKLIST_POLLING_INTERVAL_MS = 30000; // 30 sec
14
+ exports.CABLES_TOKENS_CACHES_TTL_S = 60;
15
+ exports.CABLES_API_TOKENS_POLLING_INTERVAL_MS = 30000; // 30 sec
19
16
  exports.CABLES_FIRM_QUOTE_TIMEOUT_MS = 2000;
20
- exports.CABLES_RATE_LIMITED_TTL_S = 60 * 60; // 1 hour
21
- exports.CABLES_RATELIMIT_CACHE_VALUE = 'limited';
22
- exports.CABLES_RESTRICT_TTL_S = 60 * 30; // 30 minutes
17
+ exports.CABLES_BLACKLIST_CACHE_KEY = 'cablesBlacklistCacheKey';
23
18
  exports.CABLES_RESTRICTED_CACHE_KEY = 'restricted';
24
- exports.CABLES_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION = new bignumber_js_1.default('0.005');
19
+ exports.CABLES_ERRORS_CACHE_KEY = 'errors';
20
+ exports.CABLES_RESTRICT_CHECK_INTERVAL_MS = 1000 * 60 * 3; // 3 min
21
+ exports.CABLES_RESTRICT_COUNT_THRESHOLD = 3;
22
+ exports.CABLES_RESTRICT_TTL_S = 10 * 60; // 10 min
25
23
  exports.CABLES_GAS_COST = 120000;
26
24
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/cables/constants.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAErC;;GAEG;AACU,QAAA,cAAc,GACzB,kDAAkD,CAAC;AAExC,QAAA,0BAA0B,GAAG,CAAC,CAAC;AAC/B,QAAA,qCAAqC,GAAG,IAAI,CAAC,CAAC,QAAQ;AAEtD,QAAA,yBAAyB,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;AAC/C,QAAA,oCAAoC,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;AAEjE,QAAA,6BAA6B,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;AACnD,QAAA,wCAAwC,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;AAErE,QAAA,0BAA0B,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;AAChD,QAAA,4BAA4B,GAAG,IAAI,CAAC;AAEpC,QAAA,yBAAyB,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,SAAS;AAC9C,QAAA,4BAA4B,GAAG,SAAS,CAAC;AAEzC,QAAA,qBAAqB,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,aAAa;AAC9C,QAAA,2BAA2B,GAAG,YAAY,CAAC;AAE3C,QAAA,oDAAoD,GAC/D,IAAI,sBAAS,CAAC,OAAO,CAAC,CAAC;AAEZ,QAAA,eAAe,GAAG,MAAO,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/cables/constants.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACU,QAAA,cAAc,GACzB,kDAAkD,CAAC;AAExC,QAAA,0BAA0B,GAAG,EAAE,CAAC;AAChC,QAAA,qCAAqC,GAAG,IAAI,CAAC,CAAC,QAAQ;AAEtD,QAAA,yBAAyB,GAAG,EAAE,CAAC;AAC/B,QAAA,oCAAoC,GAAG,KAAK,CAAC,CAAC,SAAS;AAEvD,QAAA,6BAA6B,GAAG,EAAE,CAAC;AACnC,QAAA,wCAAwC,GAAG,KAAK,CAAC,CAAC,SAAS;AAE3D,QAAA,0BAA0B,GAAG,EAAE,CAAC;AAChC,QAAA,qCAAqC,GAAG,KAAK,CAAC,CAAC,SAAS;AAExD,QAAA,4BAA4B,GAAG,IAAI,CAAC;AAEpC,QAAA,0BAA0B,GAAG,yBAAyB,CAAC;AAEvD,QAAA,2BAA2B,GAAG,YAAY,CAAC;AAE3C,QAAA,uBAAuB,GAAG,QAAQ,CAAC;AAEnC,QAAA,iCAAiC,GAAG,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ;AAE3D,QAAA,+BAA+B,GAAG,CAAC,CAAC;AAEpC,QAAA,qBAAqB,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,SAAS;AAE1C,QAAA,eAAe,GAAG,MAAO,CAAC"}
@@ -104,3 +104,10 @@ export declare type CablesRateFetcherConfig = {
104
104
  tokensCacheTTLSecs: number;
105
105
  };
106
106
  };
107
+ export declare type RestrictData = {
108
+ count: number;
109
+ addedDatetimeMs: number;
110
+ } | null;
111
+ export declare class SlippageError extends Error {
112
+ isSlippageError: boolean;
113
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CablesRfqError = exports.OrderbookSide = void 0;
3
+ exports.SlippageError = exports.CablesRfqError = exports.OrderbookSide = void 0;
4
4
  var OrderbookSide;
5
5
  (function (OrderbookSide) {
6
6
  OrderbookSide["bids"] = "bids";
@@ -9,4 +9,11 @@ var OrderbookSide;
9
9
  class CablesRfqError extends Error {
10
10
  }
11
11
  exports.CablesRfqError = CablesRfqError;
12
+ class SlippageError extends Error {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.isSlippageError = true;
16
+ }
17
+ }
18
+ exports.SlippageError = SlippageError;
12
19
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/cables/types.ts"],"names":[],"mappings":";;;AAcA,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,8BAAa,CAAA;AACf,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AASD,MAAa,cAAe,SAAQ,KAAK;CAAG;AAA5C,wCAA4C"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/cables/types.ts"],"names":[],"mappings":";;;AAcA,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,8BAAa,CAAA;AACf,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AASD,MAAa,cAAe,SAAQ,KAAK;CAAG;AAA5C,wCAA4C;AAmG5C,MAAa,aAAc,SAAQ,KAAK;IAAxC;;QACE,oBAAe,GAAG,IAAI,CAAC;IACzB,CAAC;CAAA;AAFD,sCAEC"}
@@ -0,0 +1,18 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { SwapSide } from '../constants';
3
+ import { AdapterExchangeParam, SimpleExchangeParam } from '../types';
4
+ import { IDexTxBuilder } from './idex';
5
+ import { SimpleExchange } from './simple-exchange';
6
+ import { IDexHelper } from '../dex-helper';
7
+ export declare type CompoundData = {
8
+ fromCToken: boolean;
9
+ };
10
+ declare type CompoundParam = [srcAmount: string];
11
+ export declare class Compound extends SimpleExchange implements IDexTxBuilder<CompoundData, CompoundParam> {
12
+ static dexKeys: string[];
13
+ cethInterface: Interface;
14
+ constructor(dexHelper: IDexHelper);
15
+ getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: CompoundData, side: SwapSide): AdapterExchangeParam;
16
+ getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: CompoundData, side: SwapSide): Promise<SimpleExchangeParam>;
17
+ }
18
+ export {};
@@ -0,0 +1,46 @@
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.Compound = void 0;
7
+ const abi_1 = require("@ethersproject/abi");
8
+ const constants_1 = require("../constants");
9
+ const simple_exchange_1 = require("./simple-exchange");
10
+ const Compound_CETH_json_1 = __importDefault(require("../abi/Compound_CETH.json")); // CETH abi
11
+ const utils_1 = require("../utils");
12
+ var CompoundFunctions;
13
+ (function (CompoundFunctions) {
14
+ CompoundFunctions["redeem"] = "redeem";
15
+ CompoundFunctions["mint"] = "mint";
16
+ })(CompoundFunctions || (CompoundFunctions = {}));
17
+ class Compound extends simple_exchange_1.SimpleExchange {
18
+ constructor(dexHelper) {
19
+ super(dexHelper, 'compound');
20
+ this.cethInterface = new abi_1.Interface(Compound_CETH_json_1.default);
21
+ }
22
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
23
+ const cToken = data.fromCToken ? srcToken : destToken; // Warning
24
+ const payload = this.abiCoder.encodeParameter({
25
+ ParentStruct: {
26
+ cToken: 'address',
27
+ },
28
+ }, { cToken });
29
+ return {
30
+ // target exchange is not used by the contract
31
+ targetExchange: constants_1.NULL_ADDRESS,
32
+ payload,
33
+ networkFee: '0',
34
+ };
35
+ }
36
+ async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
37
+ const cToken = data.fromCToken ? srcToken : destToken;
38
+ const swapData = (0, utils_1.isETHAddress)(srcToken)
39
+ ? this.cethInterface.encodeFunctionData(CompoundFunctions.mint)
40
+ : this.erc20Interface.encodeFunctionData(data.fromCToken ? CompoundFunctions.redeem : CompoundFunctions.mint, [srcAmount]);
41
+ return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, cToken);
42
+ }
43
+ }
44
+ exports.Compound = Compound;
45
+ Compound.dexKeys = ['compound'];
46
+ //# sourceMappingURL=compound.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compound.js","sourceRoot":"","sources":["../../src/dex/compound.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAsD;AAGtD,uDAAmD;AACnD,mFAA6C,CAAC,WAAW;AACzD,oCAAwC;AAQxC,IAAK,iBAGJ;AAHD,WAAK,iBAAiB;IACpB,sCAAiB,CAAA;IACjB,kCAAa,CAAA;AACf,CAAC,EAHI,iBAAiB,KAAjB,iBAAiB,QAGrB;AAED,MAAa,QACX,SAAQ,gCAAc;IAMtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,eAAS,CAAC,4BAAsB,CAAC,CAAC;IAC7D,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAkB,EAClB,IAAc;QAEd,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU;QAEjE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAC3C;YACE,YAAY,EAAE;gBACZ,MAAM,EAAE,SAAS;aAClB;SACF,EACD,EAAE,MAAM,EAAE,CACX,CAAC;QAEF,OAAO;YACL,8CAA8C;YAC9C,cAAc,EAAE,wBAAY;YAC5B,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAkB,EAClB,IAAc;QAEd,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QACtD,MAAM,QAAQ,GAAG,IAAA,oBAAY,EAAC,QAAQ,CAAC;YACrC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC;YAC/D,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,kBAAkB,CACpC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,EACnE,CAAC,SAAS,CAAC,CACZ,CAAC;QAEN,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,CACP,CAAC;IACJ,CAAC;;AA/DH,4BAgEC;AA5DQ,gBAAO,GAAG,CAAC,UAAU,CAAC,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { SwapSide } from '../constants';
3
+ import { AdapterExchangeParam, Address, ExchangeTxInfo, NumberAsString, PreprocessTransactionOptions, SimpleExchangeParam, Token, TxInfo } from '../types';
4
+ import { IDexTxBuilder } from './idex';
5
+ import { SimpleExchange } from './simple-exchange';
6
+ import { IDexHelper } from '../dex-helper';
7
+ import { Logger } from 'log4js';
8
+ import { OptimalSwapExchange } from '@paraswap/core';
9
+ export declare enum CurveV2SwapType {
10
+ EXCHANGE = 0,
11
+ EXCHANGE_UNDERLYING = 1,
12
+ EXCHANGE_GENERIC_FACTORY_ZAP = 2
13
+ }
14
+ declare type CurveV2Data = {
15
+ i: number;
16
+ j: number;
17
+ exchange: string;
18
+ originalPoolAddress: Address;
19
+ swapType: CurveV2SwapType;
20
+ isApproved?: boolean;
21
+ };
22
+ export declare type DirectCurveV2Param = [
23
+ fromToken: Address,
24
+ toToken: Address,
25
+ exchange: Address,
26
+ poolAddress: Address,
27
+ fromAmount: NumberAsString,
28
+ toAmount: NumberAsString,
29
+ expectedAmount: NumberAsString,
30
+ feePercent: NumberAsString,
31
+ i: NumberAsString,
32
+ j: NumberAsString,
33
+ partner: Address,
34
+ isApproved: boolean,
35
+ swapType: CurveV2SwapType,
36
+ beneficiary: Address,
37
+ needWrapNative: boolean,
38
+ permit: string,
39
+ uuid: string
40
+ ];
41
+ export declare class CurveV2 extends SimpleExchange implements IDexTxBuilder<CurveV2Data, DirectCurveV2Param> {
42
+ readonly dexHelper: IDexHelper;
43
+ static dexKeys: string[];
44
+ exchangeRouterInterface: Interface;
45
+ genericFactoryZapIface: Interface;
46
+ minConversionRate: string;
47
+ needWrapNative: boolean;
48
+ logger: Logger;
49
+ readonly directSwapIface: Interface;
50
+ constructor(dexHelper: IDexHelper);
51
+ getAdapterParam(_0: string, _1: string, _2: string, _3: string, data: CurveV2Data, side: SwapSide): AdapterExchangeParam;
52
+ getTokenFromAddress(address: Address): Token;
53
+ preProcessTransaction(optimalSwapExchange: OptimalSwapExchange<CurveV2Data>, srcToken: Token, _0: Token, _1: SwapSide, options: PreprocessTransactionOptions): Promise<[OptimalSwapExchange<CurveV2Data>, ExchangeTxInfo]>;
54
+ getDirectParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, expectedAmount: NumberAsString, data: CurveV2Data, side: SwapSide, permit: string, uuid: string, feePercent: NumberAsString, _0: NumberAsString, partner: string, beneficiary: string, contractMethod?: string): TxInfo<DirectCurveV2Param>;
55
+ static getDirectFunctionName(): string[];
56
+ getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: CurveV2Data, side: SwapSide): Promise<SimpleExchangeParam>;
57
+ }
58
+ export {};
@@ -0,0 +1,180 @@
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.CurveV2 = exports.CurveV2SwapType = void 0;
7
+ const abi_1 = require("@ethersproject/abi");
8
+ const constants_1 = require("../constants");
9
+ const simple_exchange_1 = require("./simple-exchange");
10
+ const GenericFactoryZap_json_1 = __importDefault(require("../abi/curve-v2/GenericFactoryZap.json"));
11
+ const DirectSwap_json_1 = __importDefault(require("../abi/DirectSwap.json"));
12
+ const CurveV2_json_1 = __importDefault(require("../abi/CurveV2.json"));
13
+ const ts_essentials_1 = require("ts-essentials");
14
+ const utils_1 = require("../utils");
15
+ var CurveV2SwapType;
16
+ (function (CurveV2SwapType) {
17
+ CurveV2SwapType[CurveV2SwapType["EXCHANGE"] = 0] = "EXCHANGE";
18
+ CurveV2SwapType[CurveV2SwapType["EXCHANGE_UNDERLYING"] = 1] = "EXCHANGE_UNDERLYING";
19
+ CurveV2SwapType[CurveV2SwapType["EXCHANGE_GENERIC_FACTORY_ZAP"] = 2] = "EXCHANGE_GENERIC_FACTORY_ZAP";
20
+ })(CurveV2SwapType = exports.CurveV2SwapType || (exports.CurveV2SwapType = {}));
21
+ const DIRECT_METHOD_NAME = 'directCurveV2Swap';
22
+ var CurveV2SwapFunctions;
23
+ (function (CurveV2SwapFunctions) {
24
+ CurveV2SwapFunctions["exchange"] = "exchange(uint256 i, uint256 j, uint256 dx, uint256 minDy)";
25
+ CurveV2SwapFunctions["exchange_underlying"] = "exchange_underlying(uint256 i, uint256 j, uint256 dx, uint256 minDy)";
26
+ CurveV2SwapFunctions["exchange_in_generic_factory_zap"] = "exchange(address _pool, uint256 i, uint256 j, uint256 _dx, uint256 _min_dy)";
27
+ })(CurveV2SwapFunctions || (CurveV2SwapFunctions = {}));
28
+ class CurveV2 extends simple_exchange_1.SimpleExchange {
29
+ constructor(dexHelper) {
30
+ super(dexHelper, 'curvev2');
31
+ this.dexHelper = dexHelper;
32
+ this.minConversionRate = '1';
33
+ this.needWrapNative = true;
34
+ this.directSwapIface = new abi_1.Interface(DirectSwap_json_1.default);
35
+ this.exchangeRouterInterface = new abi_1.Interface(CurveV2_json_1.default);
36
+ this.genericFactoryZapIface = new abi_1.Interface(GenericFactoryZap_json_1.default);
37
+ this.logger = dexHelper.getLogger(`CurveV2_${dexHelper.config.data.network}`);
38
+ }
39
+ getAdapterParam(_0, _1, _2, _3, data, side) {
40
+ if (side === constants_1.SwapSide.BUY)
41
+ throw new Error(`Buy not supported`);
42
+ const { i, j, originalPoolAddress, swapType } = data;
43
+ const payload = this.abiCoder.encodeParameter({
44
+ ParentStruct: {
45
+ i: 'uint256',
46
+ j: 'uint256',
47
+ originalPoolAddress: 'address',
48
+ swapType: 'uint8',
49
+ },
50
+ }, {
51
+ i,
52
+ j,
53
+ originalPoolAddress,
54
+ swapType,
55
+ });
56
+ return {
57
+ targetExchange: data.exchange,
58
+ payload,
59
+ networkFee: '0',
60
+ };
61
+ }
62
+ getTokenFromAddress(address) {
63
+ // In this Dex decimals are not used
64
+ return { address, decimals: 0 };
65
+ }
66
+ async preProcessTransaction(optimalSwapExchange, srcToken, _0, _1, options) {
67
+ if (!options.isDirectMethod) {
68
+ return [
69
+ optimalSwapExchange,
70
+ {
71
+ deadline: BigInt((0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)()),
72
+ },
73
+ ];
74
+ }
75
+ (0, ts_essentials_1.assert)(optimalSwapExchange.data !== undefined, `preProcessTransaction: data field is missing`);
76
+ let isApproved;
77
+ try {
78
+ this.erc20Contract.options.address =
79
+ this.dexHelper.config.wrapETH(srcToken).address;
80
+ const allowance = await this.erc20Contract.methods
81
+ .allowance(this.augustusAddress, optimalSwapExchange.data.exchange)
82
+ .call(undefined, 'latest');
83
+ isApproved =
84
+ BigInt(allowance.toString()) >= BigInt(optimalSwapExchange.srcAmount);
85
+ }
86
+ catch (e) {
87
+ this.logger.error(`preProcessTransaction failed to retrieve allowance info: `, e);
88
+ }
89
+ return [
90
+ {
91
+ ...optimalSwapExchange,
92
+ data: {
93
+ ...optimalSwapExchange.data,
94
+ isApproved,
95
+ },
96
+ },
97
+ {
98
+ deadline: BigInt((0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)()),
99
+ },
100
+ ];
101
+ }
102
+ getDirectParam(srcToken, destToken, srcAmount, destAmount, expectedAmount, data, side, permit, uuid, feePercent, _0, partner, beneficiary, contractMethod) {
103
+ if (contractMethod !== DIRECT_METHOD_NAME) {
104
+ throw new Error(`Invalid contract method ${contractMethod}`);
105
+ }
106
+ (0, ts_essentials_1.assert)(side === constants_1.SwapSide.SELL, 'Buy not supported');
107
+ let isApproved = !!data.isApproved;
108
+ if (data.isApproved === undefined) {
109
+ this.logger.warn(`isApproved is undefined, defaulting to false`);
110
+ }
111
+ const swapParams = [
112
+ srcToken,
113
+ destToken,
114
+ data.exchange,
115
+ data.originalPoolAddress,
116
+ srcAmount,
117
+ destAmount,
118
+ expectedAmount,
119
+ feePercent,
120
+ data.i.toString(),
121
+ data.j.toString(),
122
+ partner,
123
+ isApproved,
124
+ data.swapType,
125
+ beneficiary,
126
+ // For now we always wrap native. We don't support non native trade
127
+ true,
128
+ permit,
129
+ (0, utils_1.uuidToBytes16)(uuid),
130
+ ];
131
+ const encoder = (...params) => {
132
+ return this.directSwapIface.encodeFunctionData(DIRECT_METHOD_NAME, [
133
+ params,
134
+ ]);
135
+ };
136
+ return {
137
+ params: swapParams,
138
+ encoder,
139
+ networkFee: '0',
140
+ };
141
+ }
142
+ static getDirectFunctionName() {
143
+ return [DIRECT_METHOD_NAME];
144
+ }
145
+ async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
146
+ if (side === constants_1.SwapSide.BUY)
147
+ throw new Error(`Buy not supported`);
148
+ const { exchange, i, j, originalPoolAddress, swapType } = data;
149
+ const args = swapType === CurveV2SwapType.EXCHANGE_GENERIC_FACTORY_ZAP
150
+ ? [
151
+ originalPoolAddress,
152
+ i.toString(),
153
+ j.toString(),
154
+ srcAmount,
155
+ this.minConversionRate,
156
+ ]
157
+ : [i.toString(), j.toString(), srcAmount, this.minConversionRate];
158
+ let swapMethod;
159
+ switch (swapType) {
160
+ case CurveV2SwapType.EXCHANGE:
161
+ swapMethod = CurveV2SwapFunctions.exchange;
162
+ break;
163
+ case CurveV2SwapType.EXCHANGE_UNDERLYING:
164
+ swapMethod = CurveV2SwapFunctions.exchange_underlying;
165
+ break;
166
+ case CurveV2SwapType.EXCHANGE_GENERIC_FACTORY_ZAP:
167
+ swapMethod = CurveV2SwapFunctions.exchange_in_generic_factory_zap;
168
+ break;
169
+ default:
170
+ throw new Error(`getSimpleParam: not all cases covered for CurveV2SwapTypes`);
171
+ }
172
+ const swapData = swapMethod === CurveV2SwapFunctions.exchange_in_generic_factory_zap
173
+ ? this.genericFactoryZapIface.encodeFunctionData(swapMethod, args)
174
+ : this.exchangeRouterInterface.encodeFunctionData(swapMethod, args);
175
+ return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, exchange);
176
+ }
177
+ }
178
+ exports.CurveV2 = CurveV2;
179
+ CurveV2.dexKeys = ['curvev2'];
180
+ //# sourceMappingURL=curve-v2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curve-v2.js","sourceRoot":"","sources":["../../src/dex/curve-v2.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAwC;AAYxC,uDAG2B;AAC3B,oGAA0E;AAC1E,6EAAmD;AACnD,uEAA6C;AAE7C,iDAAuC;AAGvC,oCAAyC;AAEzC,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,6DAAQ,CAAA;IACR,mFAAmB,CAAA;IACnB,qGAA4B,CAAA;AAC9B,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B;AAED,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AA+C/C,IAAK,oBAIJ;AAJD,WAAK,oBAAoB;IACvB,8FAAsE,CAAA;IACtE,oHAA4F,CAAA;IAC5F,uIAA+G,CAAA;AACjH,CAAC,EAJI,oBAAoB,KAApB,oBAAoB,QAIxB;AAED,MAAa,OACX,SAAQ,gCAAc;IAYtB,YAAqB,SAAqB;QACxC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QADT,cAAS,GAAT,SAAS,CA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;;AAvOH,0BAwOC;AApOQ,eAAO,GAAG,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { SwapSide } from '../constants';
3
+ import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
4
+ import { IDexTxBuilder } from './idex';
5
+ import { SimpleExchange } from './simple-exchange';
6
+ import { NumberAsString } from '@paraswap/core';
7
+ import { IDexHelper } from '../dex-helper';
8
+ export declare type DodoV1Data = {
9
+ fromToken: Address;
10
+ toToken: Address;
11
+ dodoPairs: Address[];
12
+ directions: string;
13
+ isIncentive: boolean;
14
+ deadLine: string;
15
+ };
16
+ declare type DodoV1Param = [
17
+ fromToken: Address,
18
+ toToken: Address,
19
+ fromTokenAmount: NumberAsString,
20
+ minReturnAmount: NumberAsString,
21
+ dodoPairs: Address[],
22
+ directions: NumberAsString,
23
+ isIncentive: boolean,
24
+ deadLine: NumberAsString
25
+ ];
26
+ export declare class DodoV1 extends SimpleExchange implements IDexTxBuilder<DodoV1Data, DodoV1Param> {
27
+ static dexKeys: string[];
28
+ dodoV2Proxy: Interface;
29
+ constructor(dexHelper: IDexHelper);
30
+ getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: DodoV1Data, side: SwapSide): AdapterExchangeParam;
31
+ getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: DodoV1Data, side: SwapSide): Promise<SimpleExchangeParam>;
32
+ }
33
+ export {};
@@ -0,0 +1,63 @@
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.DodoV1 = void 0;
7
+ const abi_1 = require("@ethersproject/abi");
8
+ const constants_1 = require("../constants");
9
+ const simple_exchange_1 = require("./simple-exchange");
10
+ const dodo_v2_proxy_json_1 = __importDefault(require("../abi/dodo-v2-proxy.json"));
11
+ // We use dodo-v2 proxy as the new proxy supports both v1 and v2
12
+ const DODOV2ProxyAddress = {
13
+ 1: '0xa356867fdcea8e71aeaf87805808803806231fdc',
14
+ 56: '0x8F8Dd7DB1bDA5eD3da8C9daf3bfa471c12d58486',
15
+ 42161: '0x88CBf433471A0CD8240D2a12354362988b4593E5',
16
+ };
17
+ const DODOAproveAddress = {
18
+ 1: '0xCB859eA579b28e02B87A1FDE08d087ab9dbE5149',
19
+ 56: '0xa128Ba44B2738A558A1fdC06d6303d52D3Cef8c1',
20
+ 42161: '0xA867241cDC8d3b0C07C85cC06F25a0cD3b5474d8',
21
+ };
22
+ var DodoV1Functions;
23
+ (function (DodoV1Functions) {
24
+ DodoV1Functions["dodoSwapV1"] = "dodoSwapV1";
25
+ })(DodoV1Functions || (DodoV1Functions = {}));
26
+ class DodoV1 extends simple_exchange_1.SimpleExchange {
27
+ constructor(dexHelper) {
28
+ super(dexHelper, 'dodov1');
29
+ this.dodoV2Proxy = new abi_1.Interface(dodo_v2_proxy_json_1.default);
30
+ }
31
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
32
+ const { dodoPairs, directions } = data;
33
+ const payload = this.abiCoder.encodeParameter({
34
+ ParentStruct: {
35
+ dodoPairs: 'address[]',
36
+ directions: 'uint256',
37
+ },
38
+ }, { dodoPairs, directions });
39
+ return {
40
+ targetExchange: DODOV2ProxyAddress[this.network],
41
+ payload,
42
+ networkFee: '0',
43
+ };
44
+ }
45
+ async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
46
+ const swapFunction = DodoV1Functions.dodoSwapV1;
47
+ const swapFunctionParams = [
48
+ srcToken,
49
+ destToken,
50
+ srcAmount,
51
+ destAmount,
52
+ data.dodoPairs,
53
+ data.directions,
54
+ data.isIncentive,
55
+ constants_1.MAX_UINT,
56
+ ];
57
+ const swapData = this.dodoV2Proxy.encodeFunctionData(swapFunction, swapFunctionParams);
58
+ return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, DODOV2ProxyAddress[this.network], DODOAproveAddress[this.network]);
59
+ }
60
+ }
61
+ exports.DodoV1 = DodoV1;
62
+ DodoV1.dexKeys = ['dodov1'];
63
+ //# sourceMappingURL=dodo-v1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dodo-v1.js","sourceRoot":"","sources":["../../src/dex/dodo-v1.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAkD;AAGlD,uDAAmD;AACnD,mFAAuD;AAKvD,gEAAgE;AAChE,MAAM,kBAAkB,GAAmC;IACzD,CAAC,EAAE,4CAA4C;IAC/C,EAAE,EAAE,4CAA4C;IAChD,KAAK,EAAE,4CAA4C;CACpD,CAAC;AAEF,MAAM,iBAAiB,GAAmC;IACxD,CAAC,EAAE,4CAA4C;IAC/C,EAAE,EAAE,4CAA4C;IAChD,KAAK,EAAE,4CAA4C;CACpD,CAAC;AAqBF,IAAK,eAEJ;AAFD,WAAK,eAAe;IAClB,4CAAyB,CAAA;AAC3B,CAAC,EAFI,eAAe,KAAf,eAAe,QAEnB;AAED,MAAa,MACX,SAAQ,gCAAc;IAMtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,eAAS,CAAC,4BAAgC,CAAC,CAAC;IACrE,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAgB,EAChB,IAAc;QAEd,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAC3C;YACE,YAAY,EAAE;gBACZ,SAAS,EAAE,WAAW;gBACtB,UAAU,EAAE,SAAS;aACtB;SACF,EACD,EAAE,SAAS,EAAE,UAAU,EAAE,CAC1B,CAAC;QAEF,OAAO;YACL,cAAc,EAAE,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC;YAChD,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAgB,EAChB,IAAc;QAEd,MAAM,YAAY,GAAG,eAAe,CAAC,UAAU,CAAC;QAChD,MAAM,kBAAkB,GAAgB;YACtC,QAAQ;YACR,SAAS;YACT,SAAS;YACT,UAAU;YACV,IAAI,CAAC,SAAS;YACd,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,WAAW;YAChB,oBAAQ;SACT,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAClD,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,EAChC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAChC,CAAC;IACJ,CAAC;;AAvEH,wBAwEC;AApEQ,cAAO,GAAG,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { DeepReadonly } from 'ts-essentials';
3
+ import { Log, Logger } from '../../types';
4
+ import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
5
+ import { IDexHelper } from '../../dex-helper/idex-helper';
6
+ import { CommonAddresses, FluidDexPoolState } from './types';
7
+ import { Address } from '../../types';
8
+ export declare class FluidDexEventPool extends StatefulEventSubscriber<FluidDexPoolState> {
9
+ readonly parentName: string;
10
+ readonly pool: Address;
11
+ readonly commonAddresses: CommonAddresses;
12
+ protected network: number;
13
+ readonly dexHelper: IDexHelper;
14
+ handlers: {
15
+ [event: string]: (event: any, state: DeepReadonly<FluidDexPoolState>, log: Readonly<Log>) => Promise<DeepReadonly<FluidDexPoolState> | null>;
16
+ };
17
+ logDecoder: (log: Log) => any;
18
+ addressesSubscribed: Address[];
19
+ protected liquidityIface: Interface;
20
+ constructor(parentName: string, pool: Address, commonAddresses: CommonAddresses, network: number, dexHelper: IDexHelper, logger: Logger);
21
+ /**
22
+ * Handle a trade rate change on the pool.
23
+ */
24
+ handleOperate(event: any, state: DeepReadonly<FluidDexPoolState>, log: Readonly<Log>): Promise<DeepReadonly<FluidDexPoolState> | null>;
25
+ /**
26
+ * The function is called every time any of the subscribed
27
+ * addresses release log. The function accepts the current
28
+ * state, updates the state according to the log, and returns
29
+ * the updated state.
30
+ * @param state - Current state of event subscriber
31
+ * @param log - Log released by one of the subscribed addresses
32
+ * @returns Updates state of the event subscriber after the log
33
+ */
34
+ processLog(state: DeepReadonly<FluidDexPoolState>, log: Readonly<Log>): Promise<DeepReadonly<FluidDexPoolState> | null>;
35
+ getStateOrGenerate(blockNumber: number, readonly?: boolean): Promise<FluidDexPoolState>;
36
+ /**
37
+ * The function generates state using on-chain calls. This
38
+ * function is called to regenerate state if the event based
39
+ * system fails to fetch events and the local state is no
40
+ * more correct.
41
+ * @param blockNumber - Blocknumber for which the state should
42
+ * should be generated
43
+ * @returns state of the event subscriber at blocknumber
44
+ */
45
+ generateState(blockNumber: number): Promise<DeepReadonly<FluidDexPoolState>>;
46
+ private convertToFluidDexPoolState;
47
+ }