@paraswap/dex-lib 3.8.2 → 3.8.3

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 (346) hide show
  1. package/.vscode/launch.json +13 -0
  2. package/.vscode/settings.json +3 -0
  3. package/build/abi/AaveV1_lending_pool.json +27 -0
  4. package/build/abi/Uncompressor.json +250 -0
  5. package/build/abi/integral/factory.json +333 -0
  6. package/build/abi/integral/oracle.json +501 -0
  7. package/build/abi/integral/pool.json +1041 -0
  8. package/build/abi/integral/relayer.json +1536 -0
  9. package/build/abi/oswap/oswap.abi.json +452 -0
  10. package/build/abi/platypus/asset.json +490 -0
  11. package/build/abi/platypus/avax-pool.json +820 -0
  12. package/build/abi/platypus/oracle.json +119 -0
  13. package/build/abi/platypus/pool.json +677 -0
  14. package/build/abi/smardex/all/smardex-router.json +648 -0
  15. package/build/abi/smardex/layer-1/smardex-factory.json +242 -0
  16. package/build/abi/smardex/layer-1/smardex-pool.json +506 -0
  17. package/build/abi/smardex/layer-2/smardex-factory.json +185 -0
  18. package/build/abi/smardex/layer-2/smardex-pool.json +578 -0
  19. package/build/abi/swaap-v1/pool.json +1346 -0
  20. package/build/dex/aave-v1/aave-v1.d.ts +33 -0
  21. package/build/dex/aave-v1/aave-v1.js +158 -0
  22. package/build/dex/aave-v1/aave-v1.js.map +1 -0
  23. package/build/dex/aave-v1/config.d.ts +11 -0
  24. package/build/dex/aave-v1/config.js +20 -0
  25. package/build/dex/aave-v1/config.js.map +1 -0
  26. package/build/dex/aave-v1/tokens-mainnet.json +134 -0
  27. package/build/dex/aave-v1/tokens.d.ts +3 -0
  28. package/build/dex/aave-v1/tokens.js +50 -0
  29. package/build/dex/aave-v1/tokens.js.map +1 -0
  30. package/build/dex/aave-v1/types.d.ts +12 -0
  31. package/build/dex/aave-v1/types.js +3 -0
  32. package/build/dex/aave-v1/types.js.map +1 -0
  33. package/build/dex/aave-v3/aave-v3.js +2 -1
  34. package/build/dex/aave-v3/aave-v3.js.map +1 -1
  35. package/build/dex/aave-v3-stata/aave-v3-stata.js +1 -0
  36. package/build/dex/aave-v3-stata/aave-v3-stata.js.map +1 -1
  37. package/build/dex/angle-staked-stable/angle-staked-stable.js +4 -1
  38. package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -1
  39. package/build/dex/bProtocol.d.ts +18 -0
  40. package/build/dex/bProtocol.js +39 -0
  41. package/build/dex/bProtocol.js.map +1 -0
  42. package/build/dex/bancor.d.ts +26 -0
  43. package/build/dex/bancor.js +58 -0
  44. package/build/dex/bancor.js.map +1 -0
  45. package/build/dex/compound/compound.js +2 -1
  46. package/build/dex/compound/compound.js.map +1 -1
  47. package/build/dex/compound.d.ts +18 -0
  48. package/build/dex/compound.js +46 -0
  49. package/build/dex/compound.js.map +1 -0
  50. package/build/dex/curve-v2.d.ts +58 -0
  51. package/build/dex/curve-v2.js +180 -0
  52. package/build/dex/curve-v2.js.map +1 -0
  53. package/build/dex/dodo-v1.d.ts +33 -0
  54. package/build/dex/dodo-v1.js +63 -0
  55. package/build/dex/dodo-v1.js.map +1 -0
  56. package/build/dex/etherfi/etherfi.d.ts +26 -0
  57. package/build/dex/etherfi/etherfi.js +96 -0
  58. package/build/dex/etherfi/etherfi.js.map +1 -0
  59. package/build/dex/etherfi.js +4 -1
  60. package/build/dex/etherfi.js.map +1 -1
  61. package/build/dex/idle-dao/idle-dao.js +1 -0
  62. package/build/dex/idle-dao/idle-dao.js.map +1 -1
  63. package/build/dex/integral/config.d.ts +4 -0
  64. package/build/dex/integral/config.js +20 -0
  65. package/build/dex/integral/config.js.map +1 -0
  66. package/build/dex/integral/context.d.ts +33 -0
  67. package/build/dex/integral/context.js +98 -0
  68. package/build/dex/integral/context.js.map +1 -0
  69. package/build/dex/integral/helpers.d.ts +17 -0
  70. package/build/dex/integral/helpers.js +157 -0
  71. package/build/dex/integral/helpers.js.map +1 -0
  72. package/build/dex/integral/integral-factory.d.ts +21 -0
  73. package/build/dex/integral/integral-factory.js +92 -0
  74. package/build/dex/integral/integral-factory.js.map +1 -0
  75. package/build/dex/integral/integral-pool.d.ts +46 -0
  76. package/build/dex/integral/integral-pool.js +143 -0
  77. package/build/dex/integral/integral-pool.js.map +1 -0
  78. package/build/dex/integral/integral-pricing.d.ts +18 -0
  79. package/build/dex/integral/integral-pricing.js +114 -0
  80. package/build/dex/integral/integral-pricing.js.map +1 -0
  81. package/build/dex/integral/integral-relayer.d.ts +39 -0
  82. package/build/dex/integral/integral-relayer.js +189 -0
  83. package/build/dex/integral/integral-relayer.js.map +1 -0
  84. package/build/dex/integral/integral-token.d.ts +22 -0
  85. package/build/dex/integral/integral-token.js +55 -0
  86. package/build/dex/integral/integral-token.js.map +1 -0
  87. package/build/dex/integral/integral.d.ts +41 -0
  88. package/build/dex/integral/integral.js +382 -0
  89. package/build/dex/integral/integral.js.map +1 -0
  90. package/build/dex/integral/types.d.ts +84 -0
  91. package/build/dex/integral/types.js +9 -0
  92. package/build/dex/integral/types.js.map +1 -0
  93. package/build/dex/integral/utils.d.ts +6 -0
  94. package/build/dex/integral/utils.js +23 -0
  95. package/build/dex/integral/utils.js.map +1 -0
  96. package/build/dex/lido.d.ts +19 -0
  97. package/build/dex/lido.js +42 -0
  98. package/build/dex/lido.js.map +1 -0
  99. package/build/dex/mStable.js +1 -1
  100. package/build/dex/mStable.js.map +1 -1
  101. package/build/dex/onebit.d.ts +25 -0
  102. package/build/dex/onebit.js +42 -0
  103. package/build/dex/onebit.js.map +1 -0
  104. package/build/dex/oswap/config.d.ts +5 -0
  105. package/build/dex/oswap/config.js +31 -0
  106. package/build/dex/oswap/config.js.map +1 -0
  107. package/build/dex/oswap/oswap-pool.d.ts +51 -0
  108. package/build/dex/oswap/oswap-pool.js +150 -0
  109. package/build/dex/oswap/oswap-pool.js.map +1 -0
  110. package/build/dex/oswap/oswap.d.ts +46 -0
  111. package/build/dex/oswap/oswap.js +266 -0
  112. package/build/dex/oswap/oswap.js.map +1 -0
  113. package/build/dex/oswap/types.d.ts +20 -0
  114. package/build/dex/oswap/types.js +3 -0
  115. package/build/dex/oswap/types.js.map +1 -0
  116. package/build/dex/platypus/asset.d.ts +14 -0
  117. package/build/dex/platypus/asset.js +97 -0
  118. package/build/dex/platypus/asset.js.map +1 -0
  119. package/build/dex/platypus/config.d.ts +11 -0
  120. package/build/dex/platypus/config.js +69 -0
  121. package/build/dex/platypus/config.js.map +1 -0
  122. package/build/dex/platypus/platypus.d.ts +62 -0
  123. package/build/dex/platypus/platypus.js +442 -0
  124. package/build/dex/platypus/platypus.js.map +1 -0
  125. package/build/dex/platypus/pool-avax.d.ts +8 -0
  126. package/build/dex/platypus/pool-avax.js +54 -0
  127. package/build/dex/platypus/pool-avax.js.map +1 -0
  128. package/build/dex/platypus/pool-base.d.ts +19 -0
  129. package/build/dex/platypus/pool-base.js +86 -0
  130. package/build/dex/platypus/pool-base.js.map +1 -0
  131. package/build/dex/platypus/pool-pure.d.ts +8 -0
  132. package/build/dex/platypus/pool-pure.js +37 -0
  133. package/build/dex/platypus/pool-pure.js.map +1 -0
  134. package/build/dex/platypus/pool-subscriber.d.ts +14 -0
  135. package/build/dex/platypus/pool-subscriber.js +167 -0
  136. package/build/dex/platypus/pool-subscriber.js.map +1 -0
  137. package/build/dex/platypus/pool.d.ts +8 -0
  138. package/build/dex/platypus/pool.js +58 -0
  139. package/build/dex/platypus/pool.js.map +1 -0
  140. package/build/dex/platypus/types.d.ts +92 -0
  141. package/build/dex/platypus/types.js +10 -0
  142. package/build/dex/platypus/types.js.map +1 -0
  143. package/build/dex/quickswap/spiritswap-v3.d.ts +6 -0
  144. package/build/dex/quickswap/spiritswap-v3.js +19 -0
  145. package/build/dex/quickswap/spiritswap-v3.js.map +1 -0
  146. package/build/dex/sdai/config.d.ts +11 -0
  147. package/build/dex/sdai/config.js +21 -0
  148. package/build/dex/sdai/config.js.map +1 -0
  149. package/build/dex/sdai/constants.d.ts +2 -0
  150. package/build/dex/sdai/constants.js +6 -0
  151. package/build/dex/sdai/constants.js.map +1 -0
  152. package/build/dex/sdai/scripts/validate-state.d.ts +1 -0
  153. package/build/dex/sdai/scripts/validate-state.js +102 -0
  154. package/build/dex/sdai/scripts/validate-state.js.map +1 -0
  155. package/build/dex/sdai/sdai-pool.d.ts +16 -0
  156. package/build/dex/sdai/sdai-pool.js +85 -0
  157. package/build/dex/sdai/sdai-pool.js.map +1 -0
  158. package/build/dex/sdai/sdai.d.ts +51 -0
  159. package/build/dex/sdai/sdai.js +172 -0
  160. package/build/dex/sdai/sdai.js.map +1 -0
  161. package/build/dex/sdai/types.d.ts +21 -0
  162. package/build/dex/sdai/types.js +11 -0
  163. package/build/dex/sdai/types.js.map +1 -0
  164. package/build/dex/sdai/utils.d.ts +4 -0
  165. package/build/dex/sdai/utils.js +39 -0
  166. package/build/dex/sdai/utils.js.map +1 -0
  167. package/build/dex/simple-exchange.d.ts +1 -1
  168. package/build/dex/simple-exchange.js +4 -2
  169. package/build/dex/simple-exchange.js.map +1 -1
  170. package/build/dex/smardex/config.d.ts +4 -0
  171. package/build/dex/smardex/config.js +64 -0
  172. package/build/dex/smardex/config.js.map +1 -0
  173. package/build/dex/smardex/constants.d.ts +18 -0
  174. package/build/dex/smardex/constants.js +33 -0
  175. package/build/dex/smardex/constants.js.map +1 -0
  176. package/build/dex/smardex/sdk/constants.d.ts +6 -0
  177. package/build/dex/smardex/sdk/constants.js +13 -0
  178. package/build/dex/smardex/sdk/constants.js.map +1 -0
  179. package/build/dex/smardex/sdk/core.d.ts +113 -0
  180. package/build/dex/smardex/sdk/core.js +499 -0
  181. package/build/dex/smardex/sdk/core.js.map +1 -0
  182. package/build/dex/smardex/sdk/errors.d.ts +15 -0
  183. package/build/dex/smardex/sdk/errors.js +22 -0
  184. package/build/dex/smardex/sdk/errors.js.map +1 -0
  185. package/build/dex/smardex/sdk/types.d.ts +62 -0
  186. package/build/dex/smardex/sdk/types.js +3 -0
  187. package/build/dex/smardex/sdk/types.js.map +1 -0
  188. package/build/dex/smardex/sdk/utils.d.ts +44 -0
  189. package/build/dex/smardex/sdk/utils.js +133 -0
  190. package/build/dex/smardex/sdk/utils.js.map +1 -0
  191. package/build/dex/smardex/smardex-event-pool.d.ts +28 -0
  192. package/build/dex/smardex/smardex-event-pool.js +119 -0
  193. package/build/dex/smardex/smardex-event-pool.js.map +1 -0
  194. package/build/dex/smardex/smardex.d.ts +65 -0
  195. package/build/dex/smardex/smardex.js +519 -0
  196. package/build/dex/smardex/smardex.js.map +1 -0
  197. package/build/dex/smardex/types.d.ts +55 -0
  198. package/build/dex/smardex/types.js +3 -0
  199. package/build/dex/smardex/types.js.map +1 -0
  200. package/build/dex/smoothy.d.ts +26 -0
  201. package/build/dex/smoothy.js +48 -0
  202. package/build/dex/smoothy.js.map +1 -0
  203. package/build/dex/solidly/forks-override/cone.d.ts +22 -0
  204. package/build/dex/solidly/forks-override/cone.js +53 -0
  205. package/build/dex/solidly/forks-override/cone.js.map +1 -0
  206. package/build/dex/solidly/forks-override/solisnek.d.ts +8 -0
  207. package/build/dex/solidly/forks-override/solisnek.js +15 -0
  208. package/build/dex/solidly/forks-override/solisnek.js.map +1 -0
  209. package/build/dex/spark/spark.js +2 -1
  210. package/build/dex/spark/spark.js.map +1 -1
  211. package/build/dex/stable-pool.d.ts +28 -0
  212. package/build/dex/stable-pool.js +62 -0
  213. package/build/dex/stable-pool.js.map +1 -0
  214. package/build/dex/swaap-v1/config.d.ts +17 -0
  215. package/build/dex/swaap-v1/config.js +56 -0
  216. package/build/dex/swaap-v1/config.js.map +1 -0
  217. package/build/dex/swaap-v1/constants.d.ts +6 -0
  218. package/build/dex/swaap-v1/constants.js +17 -0
  219. package/build/dex/swaap-v1/constants.js.map +1 -0
  220. package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +25 -0
  221. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +62 -0
  222. package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +1 -0
  223. package/build/dex/swaap-v1/libraries/Const.d.ts +18 -0
  224. package/build/dex/swaap-v1/libraries/Const.js +26 -0
  225. package/build/dex/swaap-v1/libraries/Const.js.map +1 -0
  226. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +77 -0
  227. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +316 -0
  228. package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +1 -0
  229. package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +75 -0
  230. package/build/dex/swaap-v1/libraries/LogExpMath.js +418 -0
  231. package/build/dex/swaap-v1/libraries/LogExpMath.js.map +1 -0
  232. package/build/dex/swaap-v1/libraries/MathMMM.d.ts +185 -0
  233. package/build/dex/swaap-v1/libraries/MathMMM.js +453 -0
  234. package/build/dex/swaap-v1/libraries/MathMMM.js.map +1 -0
  235. package/build/dex/swaap-v1/libraries/Num.d.ts +31 -0
  236. package/build/dex/swaap-v1/libraries/Num.js +167 -0
  237. package/build/dex/swaap-v1/libraries/Num.js.map +1 -0
  238. package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +23 -0
  239. package/build/dex/swaap-v1/libraries/PoolQuotations.js +131 -0
  240. package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +1 -0
  241. package/build/dex/swaap-v1/libraries/Struct.d.ts +56 -0
  242. package/build/dex/swaap-v1/libraries/Struct.js +3 -0
  243. package/build/dex/swaap-v1/libraries/Struct.js.map +1 -0
  244. package/build/dex/swaap-v1/swaap-v1-pool.d.ts +45 -0
  245. package/build/dex/swaap-v1/swaap-v1-pool.js +656 -0
  246. package/build/dex/swaap-v1/swaap-v1-pool.js.map +1 -0
  247. package/build/dex/swaap-v1/swaap-v1.d.ts +61 -0
  248. package/build/dex/swaap-v1/swaap-v1.js +369 -0
  249. package/build/dex/swaap-v1/swaap-v1.js.map +1 -0
  250. package/build/dex/swaap-v1/types.d.ts +106 -0
  251. package/build/dex/swaap-v1/types.js +9 -0
  252. package/build/dex/swaap-v1/types.js.map +1 -0
  253. package/build/dex/trader-joe-v2.1.d.ts +43 -0
  254. package/build/dex/trader-joe-v2.1.js +79 -0
  255. package/build/dex/trader-joe-v2.1.js.map +1 -0
  256. package/build/executor/Executor01BytecodeBuilder.js +3 -1
  257. package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
  258. package/build/executor/Executor02BytecodeBuilder.js +3 -1
  259. package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
  260. package/build/executor/Executor03BytecodeBuilder.js +2 -0
  261. package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
  262. package/build/executor/ExecutorBytecodeBuilder.js +2 -0
  263. package/build/executor/ExecutorBytecodeBuilder.js.map +1 -1
  264. package/build/executor/compressor/Compressor.d.ts +23 -0
  265. package/build/executor/compressor/Compressor.js +144 -0
  266. package/build/executor/compressor/Compressor.js.map +1 -0
  267. package/build/executor/compressor/compress.d.ts +17 -0
  268. package/build/executor/compressor/compress.js +187 -0
  269. package/build/executor/compressor/compress.js.map +1 -0
  270. package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +6 -0
  271. package/build/executor/compressor/compress_functions/addressSubstitution.js +29 -0
  272. package/build/executor/compressor/compress_functions/addressSubstitution.js.map +1 -0
  273. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +10 -0
  274. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +40 -0
  275. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +1 -0
  276. package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +11 -0
  277. package/build/executor/compressor/compress_functions/byteSubstitution.js +64 -0
  278. package/build/executor/compressor/compress_functions/byteSubstitution.js.map +1 -0
  279. package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +7 -0
  280. package/build/executor/compressor/compress_functions/ffSubstitution.js +54 -0
  281. package/build/executor/compressor/compress_functions/ffSubstitution.js.map +1 -0
  282. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +8 -0
  283. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +67 -0
  284. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +1 -0
  285. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +8 -0
  286. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +61 -0
  287. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +1 -0
  288. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +6 -0
  289. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +37 -0
  290. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +1 -0
  291. package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +9 -0
  292. package/build/executor/compressor/compress_functions/searchUnusedBytes.js +33 -0
  293. package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +1 -0
  294. package/build/executor/compressor/fetchSaved.d.ts +0 -0
  295. package/build/executor/compressor/fetchSaved.js +17 -0
  296. package/build/executor/compressor/fetchSaved.js.map +1 -0
  297. package/build/executor/compressor/utils/computeCostL2.d.ts +2 -0
  298. package/build/executor/compressor/utils/computeCostL2.js +14 -0
  299. package/build/executor/compressor/utils/computeCostL2.js.map +1 -0
  300. package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +2 -0
  301. package/build/executor/compressor/utils/findLongestDuplicatedString.js +30 -0
  302. package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +1 -0
  303. package/build/executor/compressor/utils/getAllIndexes.d.ts +2 -0
  304. package/build/executor/compressor/utils/getAllIndexes.js +12 -0
  305. package/build/executor/compressor/utils/getAllIndexes.js.map +1 -0
  306. package/build/executor/compressor/utils/getByteForAddress.d.ts +2 -0
  307. package/build/executor/compressor/utils/getByteForAddress.js +14 -0
  308. package/build/executor/compressor/utils/getByteForAddress.js.map +1 -0
  309. package/build/executor/compressor/utils/intTo2Bytes.d.ts +2 -0
  310. package/build/executor/compressor/utils/intTo2Bytes.js +14 -0
  311. package/build/executor/compressor/utils/intTo2Bytes.js.map +1 -0
  312. package/build/executor/compressor/utils/intTo3Bytes.d.ts +2 -0
  313. package/build/executor/compressor/utils/intTo3Bytes.js +18 -0
  314. package/build/executor/compressor/utils/intTo3Bytes.js.map +1 -0
  315. package/build/executor/compressor/utils/intToByte.d.ts +2 -0
  316. package/build/executor/compressor/utils/intToByte.js +10 -0
  317. package/build/executor/compressor/utils/intToByte.js.map +1 -0
  318. package/build/types.d.ts +1 -0
  319. package/package.json +1 -1
  320. package/src/dex/aave-v3/aave-v3-e2e.test.ts +4 -9
  321. package/src/dex/aave-v3/aave-v3.ts +5 -0
  322. package/src/dex/aave-v3-stata/aave-v3-stata.ts +1 -0
  323. package/src/dex/angle-staked-stable/angle-staked-stable.ts +8 -0
  324. package/src/dex/compound/compound.ts +5 -0
  325. package/src/dex/etherfi.ts +5 -0
  326. package/src/dex/idle-dao/idle-dao.ts +1 -0
  327. package/src/dex/simple-exchange.ts +5 -5
  328. package/src/dex/spark/spark-e2e.test.ts +9 -1
  329. package/src/dex/spark/spark.ts +5 -0
  330. package/src/executor/Executor01BytecodeBuilder.ts +3 -1
  331. package/src/executor/Executor02BytecodeBuilder.ts +3 -1
  332. package/src/executor/Executor03BytecodeBuilder.ts +2 -0
  333. package/src/executor/ExecutorBytecodeBuilder.ts +2 -0
  334. package/src/executor/executor01-bytecode-builder-e2e.test.ts +25 -0
  335. package/src/executor/executor02-bytecode-builder-e2e.test.ts +29 -0
  336. package/src/types.ts +1 -0
  337. package/tests/constants-e2e.ts +13 -13
  338. package/tests/utils-e2e.ts +1 -1
  339. package/.idea/aws.xml +0 -17
  340. package/.idea/codeStyles/Project.xml +0 -19
  341. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  342. package/.idea/misc.xml +0 -6
  343. package/.idea/modules.xml +0 -8
  344. package/.idea/paraswap-dex-lib.iml +0 -9
  345. package/.idea/prettier.xml +0 -7
  346. package/.idea/vcs.xml +0 -6
@@ -0,0 +1,42 @@
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.Onebit = void 0;
7
+ const abi_1 = require("@ethersproject/abi");
8
+ const simple_exchange_1 = require("./simple-exchange");
9
+ const Onebit_json_1 = __importDefault(require("../abi/Onebit.json"));
10
+ var OnebitFunctions;
11
+ (function (OnebitFunctions) {
12
+ OnebitFunctions["swapTokensWithTrust"] = "swapTokensWithTrust";
13
+ })(OnebitFunctions || (OnebitFunctions = {}));
14
+ class Onebit extends simple_exchange_1.SimpleExchange {
15
+ constructor(dexHelper) {
16
+ super(dexHelper, 'omm1');
17
+ this.needWrapNative = true;
18
+ this.exchangeRouterInterface = new abi_1.Interface(Onebit_json_1.default);
19
+ }
20
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
21
+ return {
22
+ targetExchange: data.router,
23
+ payload: '0x',
24
+ networkFee: '0',
25
+ };
26
+ }
27
+ async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
28
+ const swapFunction = OnebitFunctions.swapTokensWithTrust;
29
+ const swapFunctionParams = [
30
+ srcToken,
31
+ destToken,
32
+ srcAmount,
33
+ destAmount,
34
+ this.augustusAddress,
35
+ ];
36
+ const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
37
+ return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.router);
38
+ }
39
+ }
40
+ exports.Onebit = Onebit;
41
+ Onebit.dexKeys = ['omm1'];
42
+ //# sourceMappingURL=onebit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onebit.js","sourceRoot":"","sources":["../../src/dex/onebit.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAK7D,uDAAmD;AACnD,qEAA2C;AAc3C,IAAK,eAEJ;AAFD,WAAK,eAAe;IAClB,8DAA2C,CAAA;AAC7C,CAAC,EAFI,eAAe,KAAf,eAAe,QAEnB;AAED,MAAa,MACX,SAAQ,gCAAc;IAOtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAH3B,mBAAc,GAAG,IAAI,CAAC;QAIpB,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAAC,qBAA2B,CAAC,CAAC;IAC5E,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAgB,EAChB,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,MAAM;YAC3B,OAAO,EAAE,IAAI;YACb,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,mBAAmB,CAAC;QACzD,MAAM,kBAAkB,GAAgB;YACtC,QAAQ;YACR,SAAS;YACT,SAAS;YACT,UAAU;YACV,IAAI,CAAC,eAAe;SACrB,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;;AAzDH,wBA0DC;AAtDQ,cAAO,GAAG,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { DexParams } from './types';
2
+ import { DexConfigMap, AdapterMappings } from '../../types';
3
+ export declare const OSWAP_GAS_COST = 80000;
4
+ export declare const OSwapConfig: DexConfigMap<DexParams>;
5
+ export declare const Adapters: Record<number, AdapterMappings>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Adapters = exports.OSwapConfig = exports.OSWAP_GAS_COST = void 0;
4
+ const constants_1 = require("../../constants");
5
+ exports.OSWAP_GAS_COST = 80000;
6
+ // Important:
7
+ // - All addresses should be lower case.
8
+ // - Only tokens with 18 decimals are supported.
9
+ exports.OSwapConfig = {
10
+ OSwap: {
11
+ [constants_1.Network.MAINNET]: {
12
+ pools: [
13
+ {
14
+ id: 'OSwap_0x85b78aca6deae198fbf201c82daf6ca21942acc6',
15
+ address: '0x85b78aca6deae198fbf201c82daf6ca21942acc6',
16
+ token0: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
17
+ token1: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84', // STETH
18
+ },
19
+ ],
20
+ },
21
+ },
22
+ };
23
+ exports.Adapters = {
24
+ [constants_1.Network.MAINNET]: {
25
+ // Note: We re-use the SmarDex adapters since it implements
26
+ // an Uniswap V2 router compatible interface, which OSwap supports.
27
+ [constants_1.SwapSide.SELL]: [{ name: 'Adapter04', index: 6 }],
28
+ [constants_1.SwapSide.BUY]: [{ name: 'BuyAdapter02', index: 2 }],
29
+ },
30
+ };
31
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/oswap/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,cAAc,GAAG,KAAM,CAAC;AAErC,aAAa;AACb,yCAAyC;AACzC,iDAAiD;AACpC,QAAA,WAAW,GAA4B;IAClD,KAAK,EAAE;QACL,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,KAAK,EAAE;gBACL;oBACE,EAAE,EAAE,kDAAkD;oBACtD,OAAO,EAAE,4CAA4C;oBACrD,MAAM,EAAE,4CAA4C;oBACpD,MAAM,EAAE,4CAA4C,EAAE,QAAQ;iBAC/D;aACF;SACF;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC;IACvD,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;QACjB,2DAA2D;QAC3D,mEAAmE;QACnE,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAClD,CAAC,oBAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KACrD;CACF,CAAC"}
@@ -0,0 +1,51 @@
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 { OSwapPool, OSwapPoolState } from './types';
7
+ export declare class OSwapEventPool extends StatefulEventSubscriber<OSwapPoolState> {
8
+ readonly parentName: string;
9
+ readonly pool: OSwapPool;
10
+ protected network: number;
11
+ protected dexHelper: IDexHelper;
12
+ protected iOSwap: Interface;
13
+ protected iERC20: Interface;
14
+ handlers: {
15
+ [event: string]: (event: any, state: DeepReadonly<OSwapPoolState>, log: Readonly<Log>) => DeepReadonly<OSwapPoolState> | null;
16
+ };
17
+ logDecoder: (log: Log) => any;
18
+ addressesSubscribed: string[];
19
+ constructor(parentName: string, pool: OSwapPool, network: number, dexHelper: IDexHelper, logger: Logger, iOSwap?: Interface, iERC20?: Interface);
20
+ protected parseLog(log: Log): import("@ethersproject/abi").LogDescription;
21
+ /**
22
+ * The function is called every time any of the subscribed
23
+ * addresses release log. The function accepts the current
24
+ * state, updates the state according to the log, and returns
25
+ * the updated state.
26
+ * @param state - Current state of event subscriber
27
+ * @param log - Log released by one of the subscribed addresses
28
+ * @returns Updates state of the event subscriber after the log
29
+ */
30
+ protected processLog(state: DeepReadonly<OSwapPoolState>, log: Readonly<Log>): DeepReadonly<OSwapPoolState> | null;
31
+ /**
32
+ * The function generates state using on-chain calls. This
33
+ * function is called to regenerate state if the event based
34
+ * system fails to fetch events and the local state is no
35
+ * more correct.
36
+ * @param blockNumber - Blocknumber for which the state should
37
+ * should be generated
38
+ * @returns state of the event subscriber at blocknumber
39
+ */
40
+ generateState(blockNumber: number): Promise<DeepReadonly<OSwapPoolState>>;
41
+ getStateOrGenerate(blockNumber: number, readonly?: boolean): Promise<OSwapPoolState>;
42
+ /**
43
+ * Handle a trade rate change on the pool.
44
+ */
45
+ handleTraderateChanged(event: any, state: DeepReadonly<OSwapPoolState>, log: Readonly<Log>): DeepReadonly<OSwapPoolState> | null;
46
+ /**
47
+ * Process the transfer events for tokens in/out of the pool
48
+ * to keep the state's token balances up to date.
49
+ */
50
+ handleTransfer(event: any, state: DeepReadonly<OSwapPoolState>, log: Readonly<Log>): DeepReadonly<OSwapPoolState> | null;
51
+ }
@@ -0,0 +1,150 @@
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.OSwapEventPool = void 0;
7
+ const abi_1 = require("@ethersproject/abi");
8
+ const utils_1 = require("../../utils");
9
+ const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
10
+ const decoders_1 = require("../../lib/decoders");
11
+ const oswap_abi_json_1 = __importDefault(require("../../abi/oswap/oswap.abi.json"));
12
+ const ERC20_abi_json_1 = __importDefault(require("../../abi/ERC20.abi.json"));
13
+ class OSwapEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
14
+ constructor(parentName, pool, network, dexHelper, logger, iOSwap = new abi_1.Interface(oswap_abi_json_1.default), iERC20 = new abi_1.Interface(ERC20_abi_json_1.default)) {
15
+ super(parentName, pool.id, dexHelper, logger);
16
+ this.parentName = parentName;
17
+ this.pool = pool;
18
+ this.network = network;
19
+ this.dexHelper = dexHelper;
20
+ this.iOSwap = iOSwap;
21
+ this.iERC20 = iERC20;
22
+ this.handlers = {};
23
+ this.logDecoder = (log) => this.parseLog(log);
24
+ this.addressesSubscribed = [pool.address, pool.token0, pool.token1];
25
+ this.handlers['TraderateChanged'] = this.handleTraderateChanged.bind(this);
26
+ this.handlers['Transfer'] = this.handleTransfer.bind(this);
27
+ }
28
+ parseLog(log) {
29
+ if (log.address.toLowerCase() === this.pool.address) {
30
+ return this.iOSwap.parseLog(log);
31
+ }
32
+ return this.iERC20.parseLog(log);
33
+ }
34
+ /**
35
+ * The function is called every time any of the subscribed
36
+ * addresses release log. The function accepts the current
37
+ * state, updates the state according to the log, and returns
38
+ * the updated state.
39
+ * @param state - Current state of event subscriber
40
+ * @param log - Log released by one of the subscribed addresses
41
+ * @returns Updates state of the event subscriber after the log
42
+ */
43
+ processLog(state, log) {
44
+ try {
45
+ const event = this.logDecoder(log);
46
+ if (event.name in this.handlers) {
47
+ return this.handlers[event.name](event, state, log);
48
+ }
49
+ }
50
+ catch (e) {
51
+ (0, utils_1.catchParseLogError)(e, this.logger);
52
+ }
53
+ return null;
54
+ }
55
+ /**
56
+ * The function generates state using on-chain calls. This
57
+ * function is called to regenerate state if the event based
58
+ * system fails to fetch events and the local state is no
59
+ * more correct.
60
+ * @param blockNumber - Blocknumber for which the state should
61
+ * should be generated
62
+ * @returns state of the event subscriber at blocknumber
63
+ */
64
+ async generateState(blockNumber) {
65
+ const iERC20 = new abi_1.Interface(ERC20_abi_json_1.default);
66
+ const callData = [
67
+ {
68
+ target: this.pool.token0,
69
+ callData: iERC20.encodeFunctionData('balanceOf', [this.pool.address]),
70
+ decodeFunction: decoders_1.uint256ToBigInt,
71
+ },
72
+ {
73
+ target: this.pool.token1,
74
+ callData: iERC20.encodeFunctionData('balanceOf', [this.pool.address]),
75
+ decodeFunction: decoders_1.uint256ToBigInt,
76
+ },
77
+ {
78
+ target: this.pool.address,
79
+ callData: this.iOSwap.encodeFunctionData('traderate0', []),
80
+ decodeFunction: decoders_1.uint256ToBigInt,
81
+ },
82
+ {
83
+ target: this.pool.address,
84
+ callData: this.iOSwap.encodeFunctionData('traderate1', []),
85
+ decodeFunction: decoders_1.uint256ToBigInt,
86
+ },
87
+ ];
88
+ const results = await this.dexHelper.multiWrapper.aggregate(callData, blockNumber, this.dexHelper.multiWrapper.defaultBatchSize);
89
+ return {
90
+ balance0: results[0],
91
+ balance1: results[1],
92
+ traderate0: results[2],
93
+ traderate1: results[3],
94
+ };
95
+ }
96
+ async getStateOrGenerate(blockNumber, readonly = true) {
97
+ let state = this.getState(blockNumber);
98
+ if (!state) {
99
+ state = await this.generateState(blockNumber);
100
+ if (!readonly)
101
+ this.setState(state, blockNumber);
102
+ }
103
+ return state;
104
+ }
105
+ /**
106
+ * Handle a trade rate change on the pool.
107
+ */
108
+ handleTraderateChanged(event, state, log) {
109
+ return {
110
+ ...state,
111
+ traderate0: event.args.traderate0.toBigInt(),
112
+ traderate1: event.args.traderate1.toBigInt(),
113
+ };
114
+ }
115
+ /**
116
+ * Process the transfer events for tokens in/out of the pool
117
+ * to keep the state's token balances up to date.
118
+ */
119
+ handleTransfer(event, state, log) {
120
+ let balance0 = state.balance0;
121
+ let balance1 = state.balance1;
122
+ const tokenAddress = log.address.toLowerCase();
123
+ const fromAddress = event.args.from.toLowerCase();
124
+ const toAddress = event.args.to.toLowerCase();
125
+ const amount = event.args.value.toBigInt();
126
+ if (fromAddress == this.pool.address) {
127
+ if (tokenAddress === this.pool.token0) {
128
+ balance0 -= amount;
129
+ }
130
+ else if (tokenAddress === this.pool.token1) {
131
+ balance1 -= amount;
132
+ }
133
+ }
134
+ else if (toAddress == this.pool.address) {
135
+ if (tokenAddress === this.pool.token0) {
136
+ balance0 += amount;
137
+ }
138
+ else if (tokenAddress === this.pool.token1) {
139
+ balance1 += amount;
140
+ }
141
+ }
142
+ return {
143
+ ...state,
144
+ balance0,
145
+ balance1,
146
+ };
147
+ }
148
+ }
149
+ exports.OSwapEventPool = OSwapEventPool;
150
+ //# sourceMappingURL=oswap-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oswap-pool.js","sourceRoot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AmC,EACnC,GAAkB;QAElB,IAAI,QAAQ,GAAW,KAAK,CAAC,QAAQ,CAAC;QACtC,IAAI,QAAQ,GAAW,KAAK,CAAC,QAAQ,CAAC;QAEtC,MAAM,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAClD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAE3C,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACpC,IAAI,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBACrC,QAAQ,IAAI,MAAM,CAAC;aACpB;iBAAM,IAAI,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC5C,QAAQ,IAAI,MAAM,CAAC;aACpB;SACF;aAAM,IAAI,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACzC,IAAI,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBACrC,QAAQ,IAAI,MAAM,CAAC;aACpB;iBAAM,IAAI,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC5C,QAAQ,IAAI,MAAM,CAAC;aACpB;SACF;QAED,OAAO;YACL,GAAG,KAAK;YACR,QAAQ;YACR,QAAQ;SACT,CAAC;IACJ,CAAC;CACF;AAjLD,wCAiLC"}
@@ -0,0 +1,46 @@
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { AsyncOrSync } from 'ts-essentials';
3
+ import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, PoolLiquidity, Logger, NumberAsString, DexExchangeParam } from '../../types';
4
+ import { SwapSide, Network } from '../../constants';
5
+ import { Context, IDex } from '../../dex/idex';
6
+ import { IDexHelper } from '../../dex-helper/idex-helper';
7
+ import { OSwapData, OSwapPool, OSwapPoolState } from './types';
8
+ import { SimpleExchange } from '../simple-exchange';
9
+ import { OSwapEventPool } from './oswap-pool';
10
+ export declare class OSwap extends SimpleExchange implements IDex<OSwapData> {
11
+ readonly network: Network;
12
+ readonly dexKey: string;
13
+ readonly dexHelper: IDexHelper;
14
+ protected adapters: import("../../types").AdapterMappings;
15
+ readonly eventPools: {
16
+ [id: string]: OSwapEventPool;
17
+ };
18
+ readonly hasConstantPriceLargeAmounts = false;
19
+ readonly needWrapNative = true;
20
+ readonly isFeeOnTransferSupported = false;
21
+ static dexKeysWithNetwork: {
22
+ key: string;
23
+ networks: Network[];
24
+ }[];
25
+ logger: Logger;
26
+ readonly iOSwap: Interface;
27
+ readonly pools: [OSwapPool];
28
+ constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings);
29
+ getAdapters(side: SwapSide): {
30
+ name: string;
31
+ index: number;
32
+ }[] | null;
33
+ getPoolByTokenPair(srcToken: Token, destToken: Token): OSwapPool | null;
34
+ getPoolById(id: string): OSwapPool | null;
35
+ getPoolsByTokenAddress(tokenAddress: Address): OSwapPool[];
36
+ getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
37
+ calcPrice(pool: OSwapPool, state: OSwapPoolState, from: Token, amount: bigint, side: SwapSide): bigint;
38
+ checkLiquidity(pool: OSwapPool, state: OSwapPoolState, from: Token, amount: bigint, side: SwapSide): boolean;
39
+ getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<OSwapData>>;
40
+ getCalldataGasCost(poolPrices: PoolPrices<OSwapData>): number | number[];
41
+ getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OSwapData, side: SwapSide): AdapterExchangeParam;
42
+ getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: OSwapData, side: SwapSide, _: Context, executorAddress: Address): DexExchangeParam;
43
+ updatePoolState(): Promise<void>;
44
+ getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
45
+ releaseResources(): AsyncOrSync<void>;
46
+ }
@@ -0,0 +1,266 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.OSwap = void 0;
30
+ const abi_1 = require("@ethersproject/abi");
31
+ const constants_1 = require("../../constants");
32
+ const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
33
+ const utils_1 = require("../../utils");
34
+ const simple_exchange_1 = require("../simple-exchange");
35
+ const config_1 = require("./config");
36
+ const oswap_pool_1 = require("./oswap-pool");
37
+ const oswap_abi_json_1 = __importDefault(require("../../abi/oswap/oswap.abi.json"));
38
+ const utils_2 = require("../../executor/utils");
39
+ class OSwap extends simple_exchange_1.SimpleExchange {
40
+ constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network] || {}) {
41
+ super(dexHelper, dexKey);
42
+ this.network = network;
43
+ this.dexKey = dexKey;
44
+ this.dexHelper = dexHelper;
45
+ this.adapters = adapters;
46
+ this.eventPools = {};
47
+ this.hasConstantPriceLargeAmounts = false;
48
+ // This may change in the future, but currently OSwap does not support native ETH.
49
+ this.needWrapNative = true;
50
+ this.isFeeOnTransferSupported = false;
51
+ this.logger = dexHelper.getLogger(dexKey);
52
+ this.iOSwap = new abi_1.Interface(oswap_abi_json_1.default);
53
+ this.pools = config_1.OSwapConfig[dexKey][network].pools;
54
+ // Create an OSwapEventPool per pool, to track each pool's state by subscribing to on-chain events.
55
+ for (const pool of this.pools) {
56
+ this.eventPools[pool.id] = new oswap_pool_1.OSwapEventPool(dexKey, pool, network, dexHelper, this.logger);
57
+ }
58
+ }
59
+ // Returns the list of contract adapters (name and index)
60
+ // for a buy/sell. Return null if there are no adapters.
61
+ getAdapters(side) {
62
+ return null;
63
+ }
64
+ // Returns the pool matching the specified token pair or null if none found.
65
+ // Note: OSwap V1 does not support more than 1 pool per pair.
66
+ getPoolByTokenPair(srcToken, destToken) {
67
+ const srcAddress = srcToken.address.toLowerCase();
68
+ const destAddress = destToken.address.toLowerCase();
69
+ // A pair must have 2 different tokens.
70
+ if (srcAddress === destAddress)
71
+ return null;
72
+ for (const pool of this.pools) {
73
+ if ((srcAddress === pool.token0 && destAddress === pool.token1) ||
74
+ (srcAddress === pool.token1 && destAddress === pool.token0)) {
75
+ return pool;
76
+ }
77
+ }
78
+ return null;
79
+ }
80
+ getPoolById(id) {
81
+ for (const pool of this.pools) {
82
+ if (pool.id === id)
83
+ return pool;
84
+ }
85
+ return null;
86
+ }
87
+ // Returns a list of pool using the token.
88
+ getPoolsByTokenAddress(tokenAddress) {
89
+ const address = tokenAddress.toLowerCase();
90
+ let pools = [];
91
+ for (const pool of this.pools) {
92
+ if (address === pool.token0 || address === pool.token1) {
93
+ pools.push(pool);
94
+ }
95
+ }
96
+ return pools;
97
+ }
98
+ // Returns the list of pool identifiers that can be used
99
+ // for a given swap. poolIdentifiers must be unique
100
+ // across DEXes. It is recommended to use
101
+ // ${dexKey}_${poolAddress} as a poolIdentifier
102
+ async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
103
+ const pool = this.getPoolByTokenPair(srcToken, destToken);
104
+ return pool ? [pool.id] : [];
105
+ }
106
+ // Sell: Given "amount" of "from" token, how much of "to" token will be received by the trader.
107
+ // Buy: Given "amount" of "dest" token, how much of "to" token is required from the trader.
108
+ // Note: OSwap traderate is at precision 36.
109
+ calcPrice(pool, state, from, amount, side) {
110
+ const rate = from.address.toLowerCase() === pool.token0
111
+ ? state.traderate0
112
+ : state.traderate1;
113
+ return side === constants_1.SwapSide.SELL
114
+ ? (amount * rate) / (0, utils_1.getBigIntPow)(36)
115
+ : (amount * (0, utils_1.getBigIntPow)(36)) / rate;
116
+ }
117
+ // Returns true if the pool has enough liquidity for the swap. False otherwise.
118
+ checkLiquidity(pool, state, from, amount, side) {
119
+ if (side === constants_1.SwapSide.SELL) {
120
+ const needed = this.calcPrice(pool, state, from, amount, side);
121
+ return from.address.toLowerCase() === pool.token0
122
+ ? needed <= state.balance1
123
+ : needed <= state.balance0;
124
+ }
125
+ // SwapSide.BUY
126
+ return from.address.toLowerCase() === pool.token0
127
+ ? amount <= state.balance1
128
+ : amount <= state.balance0;
129
+ }
130
+ // Returns pool prices for amounts.
131
+ // If limitPools is defined only pools in limitPools
132
+ // should be used. If limitPools is undefined then
133
+ // any pool can be used.
134
+ async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
135
+ // Get the pool to use.
136
+ const pool = this.getPoolByTokenPair(srcToken, destToken);
137
+ if (!pool)
138
+ return null;
139
+ // Make sure the pool meets the optional limitPools filter.
140
+ if (limitPools && !limitPools.includes(pool.id))
141
+ return null;
142
+ const eventPool = this.eventPools[pool.id];
143
+ if (!eventPool)
144
+ throw new Error(`OSwap pool ${pool.id}: No EventPool found.`);
145
+ const state = await eventPool.getStateOrGenerate(blockNumber);
146
+ // Ensure there is enough liquidity in the pool to process all the requested swaps.
147
+ const totalAmount = amounts.reduce((a, b) => a + b, BigInt(0));
148
+ if (!this.checkLiquidity(pool, state, srcToken, totalAmount, side)) {
149
+ return null;
150
+ }
151
+ // Calculate the prices
152
+ const unitAmount = (0, utils_1.getBigIntPow)(18);
153
+ const unitPrice = this.calcPrice(pool, state, srcToken, unitAmount, side);
154
+ const prices = amounts.map(amount => this.calcPrice(pool, state, srcToken, amount, side));
155
+ return [
156
+ {
157
+ prices,
158
+ unit: unitPrice,
159
+ data: {
160
+ pool: pool.address,
161
+ path: [srcToken.address, destToken.address],
162
+ },
163
+ exchange: this.dexKey,
164
+ poolIdentifier: pool.id,
165
+ gasCost: config_1.OSWAP_GAS_COST,
166
+ poolAddresses: [pool.address],
167
+ },
168
+ ];
169
+ }
170
+ // Returns estimated gas cost of calldata for this DEX in multiSwap
171
+ getCalldataGasCost(poolPrices) {
172
+ return (CALLDATA_GAS_COST.DEX_OVERHEAD +
173
+ // ParentStruct header
174
+ CALLDATA_GAS_COST.OFFSET_SMALL +
175
+ // ParentStruct -> path[] header
176
+ CALLDATA_GAS_COST.OFFSET_SMALL +
177
+ // ParentStruct -> path length
178
+ CALLDATA_GAS_COST.LENGTH_SMALL +
179
+ // ParentStruct -> path[0]
180
+ CALLDATA_GAS_COST.ADDRESS +
181
+ // ParentStruct -> path[1]
182
+ CALLDATA_GAS_COST.ADDRESS +
183
+ // ParentStruct -> receiver header
184
+ CALLDATA_GAS_COST.OFFSET_SMALL +
185
+ // ParentStruct -> receiver
186
+ CALLDATA_GAS_COST.ADDRESS);
187
+ }
188
+ // Encode params required by the exchange adapter
189
+ // Used for multiSwap, buy & megaSwap
190
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
191
+ return {
192
+ targetExchange: data.pool,
193
+ payload: '',
194
+ networkFee: '0',
195
+ };
196
+ }
197
+ // Encode call data used by simpleSwap like routers
198
+ // Used for simpleSwap & simpleBuy
199
+ getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side, _, executorAddress) {
200
+ let method;
201
+ let args;
202
+ let returnAmountPos = undefined;
203
+ const deadline = (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)();
204
+ if (side === constants_1.SwapSide.SELL) {
205
+ method = 'swapExactTokensForTokens';
206
+ returnAmountPos = (0, utils_2.extractReturnAmountPosition)(this.iOSwap, method, 'amounts', 1);
207
+ args = [srcAmount, destAmount, data.path, recipient, deadline];
208
+ }
209
+ else {
210
+ method = 'swapTokensForExactTokens';
211
+ args = [destAmount, srcAmount, data.path, recipient, deadline];
212
+ }
213
+ const swapData = this.iOSwap.encodeFunctionData(method, args);
214
+ return {
215
+ needWrapNative: this.needWrapNative,
216
+ dexFuncHasRecipient: true,
217
+ exchangeData: swapData,
218
+ targetExchange: data.pool,
219
+ returnAmountPos,
220
+ };
221
+ }
222
+ // This is called once before getTopPoolsForToken is
223
+ // called for multiple tokens. This can be helpful to
224
+ // update common state required for calculating
225
+ // getTopPoolsForToken. It is optional for a DEX
226
+ // to implement this
227
+ async updatePoolState() {
228
+ return Promise.resolve();
229
+ }
230
+ // Returns a list of top pools based on liquidity. Max
231
+ // limit number pools should be returned.
232
+ async getTopPoolsForToken(tokenAddress, limit) {
233
+ // Get the list of pools using the token.
234
+ const pools = this.getPoolsByTokenAddress(tokenAddress);
235
+ if (!pools.length)
236
+ return [];
237
+ const results = await Promise.all(pools.map(async (pool) => {
238
+ // Get the pool's balance and its USD value.
239
+ const eventPool = this.eventPools[pool.id];
240
+ const blockNumber = await this.dexHelper.web3Provider.eth.getBlockNumber();
241
+ const state = await eventPool.getStateOrGenerate(blockNumber);
242
+ const usd0 = await this.dexHelper.getTokenUSDPrice({ address: pool.token0, decimals: 18 }, state.balance0);
243
+ const usd1 = await this.dexHelper.getTokenUSDPrice({ address: pool.token1, decimals: 18 }, state.balance1);
244
+ // Get the other token in the pair.
245
+ const pairedToken = pool.token0 === tokenAddress.toLowerCase()
246
+ ? { address: pool.token1, decimals: 18 }
247
+ : { address: pool.token0, decimals: 18 };
248
+ return {
249
+ exchange: this.dexKey,
250
+ address: pool.address,
251
+ connectorTokens: [pairedToken],
252
+ liquidityUSD: usd0 + usd1,
253
+ };
254
+ }));
255
+ return results
256
+ .filter(r => r)
257
+ .sort((a, b) => a.liquidityUSD - b.liquidityUSD)
258
+ .slice(0, limit);
259
+ }
260
+ // This is optional function in case if your implementation has acquired any resources
261
+ // you need to release for graceful shutdown. For example, it may be any interval timer
262
+ releaseResources() { }
263
+ }
264
+ exports.OSwap = OSwap;
265
+ OSwap.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.OSwapConfig);
266
+ //# sourceMappingURL=oswap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oswap.js","sourceRoot":"","sources":["../../../src/dex/oswap/oswap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA+C;AAc/C,+CAAoD;AACpD,2EAA6D;AAC7D,uCAAkE;AAIlE,wDAG4B;AAC5B,qCAAiE;AACjE,6CAA8C;AAC9C,oFAAsD;AACtD,gDAAmE;AAEnE,MAAa,KAAM,SAAQ,gCAAc;IAmBvC,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB,EACpB,WAAW,iBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;QAE5C,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QALhB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAA0B;QAtBrC,eAAU,GAAqC,EAAE,CAAC;QAElD,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= {
3
+ traderate0: bigint;
4
+ traderate1: bigint;
5
+ balance0: bigint;
6
+ balance1: bigint;
7
+ };
8
+ export declare type OSwapData = {
9
+ pool: Address;
10
+ path: Address[];
11
+ };
12
+ export declare type OSwapPool = {
13
+ id: string;
14
+ address: Address;
15
+ token0: Address;
16
+ token1: Address;
17
+ };
18
+ export declare type DexParams = {
19
+ pools: [OSwapPool];
20
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/oswap/types.ts"],"names":[],"mappings":""}