@paraswap/dex-lib 5.1.1 → 5.1.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 (292) hide show
  1. package/build/abi/pancakeswap-infinity/cl-pool-manager.json +80 -0
  2. package/build/dex/fluid-dex/scripts/measure-calc-time.js +178 -0
  3. package/build/dex/fluid-dex/scripts/measure-calc-time.js.map +1 -0
  4. package/build/dex/index.js +5 -6
  5. package/build/dex/index.js.map +1 -1
  6. package/build/dex/uniswap-v3/config.js +28 -0
  7. package/build/dex/uniswap-v3/config.js.map +1 -1
  8. package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.js +1 -0
  9. package/build/dex/uniswap-v3/forks/velodrome-slipstream/velodrome-slipstream.js.map +1 -1
  10. package/build/dex/uniswap-v4/api-go/compare-pricing.d.ts +1 -0
  11. package/build/dex/uniswap-v4/api-go/compare-pricing.js +187 -0
  12. package/build/dex/uniswap-v4/api-go/compare-pricing.js.map +1 -0
  13. package/build/dex/uniswap-v4/api-go/compare-states.d.ts +1 -0
  14. package/build/dex/uniswap-v4/api-go/compare-states.js +149 -0
  15. package/build/dex/uniswap-v4/api-go/compare-states.js.map +1 -0
  16. package/build/dex/uniswap-v4/api-go/fetch-pool-key.d.ts +0 -0
  17. package/build/dex/uniswap-v4/api-go/fetch-pool-key.js +140 -0
  18. package/build/dex/uniswap-v4/api-go/fetch-pool-key.js.map +1 -0
  19. package/build/executor/__test-utils__/snapshot-test-helpers.d.ts +10 -0
  20. package/build/executor/__test-utils__/snapshot-test-helpers.js +72 -0
  21. package/build/executor/__test-utils__/snapshot-test-helpers.js.map +1 -0
  22. package/build/executor/address-utils.d.ts +2 -0
  23. package/build/executor/address-utils.js +7 -0
  24. package/build/executor/address-utils.js.map +1 -0
  25. package/build/executor/approval.d.ts +9 -0
  26. package/build/executor/approval.js +29 -0
  27. package/build/executor/approval.js.map +1 -0
  28. package/build/executor/encoding-context.d.ts +4 -0
  29. package/build/executor/encoding-context.js +54 -0
  30. package/build/executor/encoding-context.js.map +1 -0
  31. package/build/executor/encoding-types.d.ts +75 -0
  32. package/build/{dex/quick-perps/types.js → executor/encoding-types.js} +1 -1
  33. package/build/executor/encoding-types.js.map +1 -0
  34. package/build/executor/factory.d.ts +4 -0
  35. package/build/executor/factory.js +23 -0
  36. package/build/executor/factory.js.map +1 -0
  37. package/build/executor/route-plan.d.ts +8 -0
  38. package/build/executor/route-plan.js +109 -0
  39. package/build/executor/route-plan.js.map +1 -0
  40. package/build/generic-swap-transaction-builder/dex-encoder/direct-methods.d.ts +6 -0
  41. package/build/generic-swap-transaction-builder/dex-encoder/direct-methods.js +39 -0
  42. package/build/generic-swap-transaction-builder/dex-encoder/direct-methods.js.map +1 -0
  43. package/build/generic-swap-transaction-builder/dex-encoder/index.d.ts +4 -0
  44. package/build/generic-swap-transaction-builder/dex-encoder/index.js +21 -0
  45. package/build/generic-swap-transaction-builder/dex-encoder/index.js.map +1 -0
  46. package/build/generic-swap-transaction-builder/dex-encoder/ports.d.ts +26 -0
  47. package/build/{dex/maker-psm/types.js → generic-swap-transaction-builder/dex-encoder/ports.js} +1 -1
  48. package/build/generic-swap-transaction-builder/dex-encoder/ports.js.map +1 -0
  49. package/build/generic-swap-transaction-builder/dex-encoder/ts-adapter.d.ts +22 -0
  50. package/build/generic-swap-transaction-builder/dex-encoder/ts-adapter.js +299 -0
  51. package/build/generic-swap-transaction-builder/dex-encoder/ts-adapter.js.map +1 -0
  52. package/build/generic-swap-transaction-builder/dex-encoder/types.d.ts +207 -0
  53. package/build/generic-swap-transaction-builder/dex-encoder/types.js +194 -0
  54. package/build/generic-swap-transaction-builder/dex-encoder/types.js.map +1 -0
  55. package/build/generic-swap-transaction-builder/orchestration.d.ts +65 -0
  56. package/build/generic-swap-transaction-builder/orchestration.js +198 -0
  57. package/build/generic-swap-transaction-builder/orchestration.js.map +1 -0
  58. package/build/generic-swap-transaction-builder/resolved/build-transaction.d.ts +13 -0
  59. package/build/generic-swap-transaction-builder/resolved/build-transaction.js +343 -0
  60. package/build/generic-swap-transaction-builder/resolved/build-transaction.js.map +1 -0
  61. package/build/generic-swap-transaction-builder/resolved/index.d.ts +4 -0
  62. package/build/generic-swap-transaction-builder/resolved/index.js +21 -0
  63. package/build/generic-swap-transaction-builder/resolved/index.js.map +1 -0
  64. package/build/generic-swap-transaction-builder/resolved/route-plan.d.ts +2 -0
  65. package/build/generic-swap-transaction-builder/resolved/route-plan.js +11 -0
  66. package/build/generic-swap-transaction-builder/resolved/route-plan.js.map +1 -0
  67. package/build/generic-swap-transaction-builder/resolved/types.d.ts +67 -0
  68. package/build/generic-swap-transaction-builder/resolved/types.js.map +1 -0
  69. package/build/generic-swap-transaction-builder/resolved/validation.d.ts +10 -0
  70. package/build/generic-swap-transaction-builder/resolved/validation.js +69 -0
  71. package/build/generic-swap-transaction-builder/resolved/validation.js.map +1 -0
  72. package/package.json +1 -1
  73. package/build/abi/BProtocol.json +0 -1155
  74. package/build/abi/Jarvis.json +0 -1172
  75. package/build/abi/MStableAsset.json +0 -1545
  76. package/build/abi/OneInchLp.json +0 -1304
  77. package/build/abi/Onebit.json +0 -736
  78. package/build/abi/Shell.json +0 -1294
  79. package/build/abi/TraderJoeV2Router.json +0 -50
  80. package/build/abi/idle-dao/idle-cdo-factory.json +0 -38
  81. package/build/abi/idle-dao/idle-cdo.json +0 -1245
  82. package/build/abi/infusion/InfusionFactory.json +0 -147
  83. package/build/abi/infusion/InfusionPair.json +0 -658
  84. package/build/abi/infusion/InfusionRouter.json +0 -442
  85. package/build/abi/maker-psm/pot.json +0 -322
  86. package/build/abi/maker-psm/psm.json +0 -243
  87. package/build/abi/maker-psm/vat.json +0 -363
  88. package/build/abi/nomiswap-v2/nomiswap-v2-pool.json +0 -773
  89. package/build/abi/quick-perps/fast-price-events.json +0 -70
  90. package/build/abi/quick-perps/fast-price-feed.json +0 -741
  91. package/build/abi/quick-perps/reader.json +0 -313
  92. package/build/abi/quick-perps/vault-price-feed.json +0 -323
  93. package/build/abi/quick-perps/vault.json +0 -1953
  94. package/build/abi/uniswap-v2/excalibur-pool.json +0 -881
  95. package/build/abi/uniswap-v2/mdex-factory.json +0 -759
  96. package/build/abi/wUSDM.json +0 -757
  97. package/build/abi/zrx.v2.json +0 -1967
  98. package/build/abi/zrx.v3.json +0 -3454
  99. package/build/abi/zrx.v4.json +0 -2193
  100. package/build/dex/OneInchLp.d.ts +0 -24
  101. package/build/dex/OneInchLp.js +0 -43
  102. package/build/dex/OneInchLp.js.map +0 -1
  103. package/build/dex/bProtocol/bProtocol.d.ts +0 -15
  104. package/build/dex/bProtocol/bProtocol.js +0 -56
  105. package/build/dex/bProtocol/bProtocol.js.map +0 -1
  106. package/build/dex/bProtocol/types.d.ts +0 -11
  107. package/build/dex/bProtocol/types.js +0 -8
  108. package/build/dex/bProtocol/types.js.map +0 -1
  109. package/build/dex/ekubo/pools/base-pool.d.ts +0 -47
  110. package/build/dex/ekubo/pools/base-pool.js +0 -184
  111. package/build/dex/ekubo/pools/base-pool.js.map +0 -1
  112. package/build/dex/ekubo/pools/iface.d.ts +0 -46
  113. package/build/dex/ekubo/pools/iface.js +0 -75
  114. package/build/dex/ekubo/pools/iface.js.map +0 -1
  115. package/build/dex/ekubo/pools/math/price.d.ts +0 -7
  116. package/build/dex/ekubo/pools/math/price.js +0 -112
  117. package/build/dex/ekubo/pools/math/price.js.map +0 -1
  118. package/build/dex/ekubo/pools/oracle-pool.d.ts +0 -10
  119. package/build/dex/ekubo/pools/oracle-pool.js +0 -19
  120. package/build/dex/ekubo/pools/oracle-pool.js.map +0 -1
  121. package/build/dex/ekubo/pools/pool-utils.d.ts +0 -44
  122. package/build/dex/ekubo/pools/pool-utils.js +0 -240
  123. package/build/dex/ekubo/pools/pool-utils.js.map +0 -1
  124. package/build/dex/idle-dao/config.d.ts +0 -5
  125. package/build/dex/idle-dao/config.js +0 -24
  126. package/build/dex/idle-dao/config.js.map +0 -1
  127. package/build/dex/idle-dao/idle-dao.d.ts +0 -42
  128. package/build/dex/idle-dao/idle-dao.js +0 -279
  129. package/build/dex/idle-dao/idle-dao.js.map +0 -1
  130. package/build/dex/idle-dao/token_list.d.ts +0 -4
  131. package/build/dex/idle-dao/token_list.js +0 -289
  132. package/build/dex/idle-dao/token_list.js.map +0 -1
  133. package/build/dex/idle-dao/tokens.d.ts +0 -9
  134. package/build/dex/idle-dao/tokens.js +0 -68
  135. package/build/dex/idle-dao/tokens.js.map +0 -1
  136. package/build/dex/idle-dao/types.d.ts +0 -35
  137. package/build/dex/idle-dao/types.js +0 -11
  138. package/build/dex/idle-dao/types.js.map +0 -1
  139. package/build/dex/idle-dao/utils.d.ts +0 -8
  140. package/build/dex/idle-dao/utils.js +0 -149
  141. package/build/dex/idle-dao/utils.js.map +0 -1
  142. package/build/dex/infusion/config.d.ts +0 -3
  143. package/build/dex/infusion/config.js +0 -20
  144. package/build/dex/infusion/config.js.map +0 -1
  145. package/build/dex/infusion/infusion-stable-pool.d.ts +0 -4
  146. package/build/dex/infusion/infusion-stable-pool.js +0 -74
  147. package/build/dex/infusion/infusion-stable-pool.js.map +0 -1
  148. package/build/dex/infusion/infusion.d.ts +0 -51
  149. package/build/dex/infusion/infusion.js +0 -500
  150. package/build/dex/infusion/infusion.js.map +0 -1
  151. package/build/dex/infusion/types.d.ts +0 -45
  152. package/build/dex/infusion/types.js.map +0 -1
  153. package/build/dex/infusion/utils/isStablePair.d.ts +0 -2
  154. package/build/dex/infusion/utils/isStablePair.js +0 -18
  155. package/build/dex/infusion/utils/isStablePair.js.map +0 -1
  156. package/build/dex/jarvis.d.ts +0 -56
  157. package/build/dex/jarvis.js +0 -163
  158. package/build/dex/jarvis.js.map +0 -1
  159. package/build/dex/mStable.d.ts +0 -44
  160. package/build/dex/mStable.js +0 -75
  161. package/build/dex/mStable.js.map +0 -1
  162. package/build/dex/maker-psm/config.d.ts +0 -11
  163. package/build/dex/maker-psm/config.js +0 -53
  164. package/build/dex/maker-psm/config.js.map +0 -1
  165. package/build/dex/maker-psm/maker-psm.d.ts +0 -103
  166. package/build/dex/maker-psm/maker-psm.js +0 -493
  167. package/build/dex/maker-psm/maker-psm.js.map +0 -1
  168. package/build/dex/maker-psm/types.d.ts +0 -39
  169. package/build/dex/maker-psm/types.js.map +0 -1
  170. package/build/dex/onebit/onebit.d.ts +0 -16
  171. package/build/dex/onebit/onebit.js +0 -61
  172. package/build/dex/onebit/onebit.js.map +0 -1
  173. package/build/dex/onebit/types.d.ts +0 -14
  174. package/build/dex/onebit/types.js +0 -8
  175. package/build/dex/onebit/types.js.map +0 -1
  176. package/build/dex/quick-perps/config.d.ts +0 -11
  177. package/build/dex/quick-perps/config.js +0 -27
  178. package/build/dex/quick-perps/config.js.map +0 -1
  179. package/build/dex/quick-perps/fast-price-feed.d.ts +0 -26
  180. package/build/dex/quick-perps/fast-price-feed.js +0 -184
  181. package/build/dex/quick-perps/fast-price-feed.js.map +0 -1
  182. package/build/dex/quick-perps/pool.d.ts +0 -21
  183. package/build/dex/quick-perps/pool.js +0 -229
  184. package/build/dex/quick-perps/pool.js.map +0 -1
  185. package/build/dex/quick-perps/quick-perps.d.ts +0 -53
  186. package/build/dex/quick-perps/quick-perps.js +0 -247
  187. package/build/dex/quick-perps/quick-perps.js.map +0 -1
  188. package/build/dex/quick-perps/types.d.ts +0 -98
  189. package/build/dex/quick-perps/types.js.map +0 -1
  190. package/build/dex/quick-perps/usdq.d.ts +0 -15
  191. package/build/dex/quick-perps/usdq.js +0 -62
  192. package/build/dex/quick-perps/usdq.js.map +0 -1
  193. package/build/dex/quick-perps/vault-price-feed.d.ts +0 -43
  194. package/build/dex/quick-perps/vault-price-feed.js +0 -203
  195. package/build/dex/quick-perps/vault-price-feed.js.map +0 -1
  196. package/build/dex/quick-perps/vault-utils.d.ts +0 -8
  197. package/build/dex/quick-perps/vault-utils.js +0 -42
  198. package/build/dex/quick-perps/vault-utils.js.map +0 -1
  199. package/build/dex/quick-perps/vault.d.ts +0 -46
  200. package/build/dex/quick-perps/vault.js +0 -182
  201. package/build/dex/quick-perps/vault.js.map +0 -1
  202. package/build/dex/se-vlr/config.d.ts +0 -3
  203. package/build/dex/se-vlr/config.js +0 -24
  204. package/build/dex/se-vlr/config.js.map +0 -1
  205. package/build/dex/se-vlr/se-vlr-pool.d.ts +0 -39
  206. package/build/dex/se-vlr/se-vlr-pool.js +0 -70
  207. package/build/dex/se-vlr/se-vlr-pool.js.map +0 -1
  208. package/build/dex/se-vlr/se-vlr.d.ts +0 -35
  209. package/build/dex/se-vlr/se-vlr.js +0 -131
  210. package/build/dex/se-vlr/se-vlr.js.map +0 -1
  211. package/build/dex/se-vlr/types.d.ts +0 -6
  212. package/build/dex/se-vlr/types.js +0 -3
  213. package/build/dex/se-vlr/types.js.map +0 -1
  214. package/build/dex/shell.d.ts +0 -25
  215. package/build/dex/shell.js +0 -41
  216. package/build/dex/shell.js.map +0 -1
  217. package/build/dex/solidly/forks-override/aerodrome.d.ts +0 -14
  218. package/build/dex/solidly/forks-override/aerodrome.js +0 -46
  219. package/build/dex/solidly/forks-override/aerodrome.js.map +0 -1
  220. package/build/dex/solidly/forks-override/chronos.d.ts +0 -23
  221. package/build/dex/solidly/forks-override/chronos.js +0 -141
  222. package/build/dex/solidly/forks-override/chronos.js.map +0 -1
  223. package/build/dex/solidly/forks-override/usdfi.d.ts +0 -8
  224. package/build/dex/solidly/forks-override/usdfi.js +0 -15
  225. package/build/dex/solidly/forks-override/usdfi.js.map +0 -1
  226. package/build/dex/solidly/forks-override/velocimeter.d.ts +0 -23
  227. package/build/dex/solidly/forks-override/velocimeter.js +0 -77
  228. package/build/dex/solidly/forks-override/velocimeter.js.map +0 -1
  229. package/build/dex/tessera/types.d.ts +0 -3
  230. package/build/dex/tessera/types.js +0 -3
  231. package/build/dex/tessera/types.js.map +0 -1
  232. package/build/dex/trader-joe-v2.d.ts +0 -40
  233. package/build/dex/trader-joe-v2.js +0 -74
  234. package/build/dex/trader-joe-v2.js.map +0 -1
  235. package/build/dex/uniswap-v2/dfyn.d.ts +0 -19
  236. package/build/dex/uniswap-v2/dfyn.js +0 -61
  237. package/build/dex/uniswap-v2/dfyn.js.map +0 -1
  238. package/build/dex/uniswap-v2/excalibur.d.ts +0 -24
  239. package/build/dex/uniswap-v2/excalibur.js +0 -47
  240. package/build/dex/uniswap-v2/excalibur.js.map +0 -1
  241. package/build/dex/uniswap-v2/mdex.d.ts +0 -24
  242. package/build/dex/uniswap-v2/mdex.js +0 -50
  243. package/build/dex/uniswap-v2/mdex.js.map +0 -1
  244. package/build/dex/uniswap-v2/nomiswap-v2.d.ts +0 -24
  245. package/build/dex/uniswap-v2/nomiswap-v2.js +0 -57
  246. package/build/dex/uniswap-v2/nomiswap-v2.js.map +0 -1
  247. package/build/dex/uniswap-v3/scripts/bench-all-dexes.js +0 -160
  248. package/build/dex/uniswap-v3/scripts/bench-all-dexes.js.map +0 -1
  249. package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +0 -94
  250. package/build/dex/uniswap-v3/uniswap-v3-new.js +0 -923
  251. package/build/dex/uniswap-v3/uniswap-v3-new.js.map +0 -1
  252. package/build/dex/uniswap-v4/contract-math/Position.d.ts +0 -3
  253. package/build/dex/uniswap-v4/contract-math/Position.js +0 -10
  254. package/build/dex/uniswap-v4/contract-math/Position.js.map +0 -1
  255. package/build/dex/usual-bond/config.d.ts +0 -3
  256. package/build/dex/usual-bond/config.js +0 -13
  257. package/build/dex/usual-bond/config.js.map +0 -1
  258. package/build/dex/usual-bond/types.d.ts +0 -7
  259. package/build/dex/usual-bond/types.js +0 -3
  260. package/build/dex/usual-bond/types.js.map +0 -1
  261. package/build/dex/usual-bond/usual-bond.d.ts +0 -35
  262. package/build/dex/usual-bond/usual-bond.js +0 -176
  263. package/build/dex/usual-bond/usual-bond.js.map +0 -1
  264. package/build/dex/wusdm/config.d.ts +0 -3
  265. package/build/dex/wusdm/config.js +0 -43
  266. package/build/dex/wusdm/config.js.map +0 -1
  267. package/build/dex/wusdm/constants.d.ts +0 -2
  268. package/build/dex/wusdm/constants.js +0 -6
  269. package/build/dex/wusdm/constants.js.map +0 -1
  270. package/build/dex/wusdm/types.d.ts +0 -18
  271. package/build/dex/wusdm/types.js +0 -11
  272. package/build/dex/wusdm/types.js.map +0 -1
  273. package/build/dex/wusdm/wusdm-pool.d.ts +0 -21
  274. package/build/dex/wusdm/wusdm-pool.js +0 -74
  275. package/build/dex/wusdm/wusdm-pool.js.map +0 -1
  276. package/build/dex/wusdm/wusdm.d.ts +0 -46
  277. package/build/dex/wusdm/wusdm.js +0 -243
  278. package/build/dex/wusdm/wusdm.js.map +0 -1
  279. package/build/dex/zerox/config.d.ts +0 -2
  280. package/build/dex/zerox/config.js +0 -33
  281. package/build/dex/zerox/config.js.map +0 -1
  282. package/build/dex/zerox/index.d.ts +0 -22
  283. package/build/dex/zerox/index.js +0 -225
  284. package/build/dex/zerox/index.js.map +0 -1
  285. package/build/dex/zerox/order.d.ts +0 -88
  286. package/build/dex/zerox/order.js +0 -53
  287. package/build/dex/zerox/order.js.map +0 -1
  288. package/build/dex/zerox/types.d.ts +0 -73
  289. package/build/dex/zerox/types.js +0 -21
  290. package/build/dex/zerox/types.js.map +0 -1
  291. /package/build/dex/{uniswap-v3/scripts/bench-all-dexes.d.ts → fluid-dex/scripts/measure-calc-time.d.ts} +0 -0
  292. /package/build/{dex/infusion → generic-swap-transaction-builder/resolved}/types.js +0 -0
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getApprovalTokenAndTarget = getApprovalTokenAndTarget;
4
+ const utils_1 = require("../utils");
5
+ const address_utils_1 = require("./address-utils");
6
+ function getApprovalTokenAndTarget(swap, exchangeParam, context) {
7
+ if (exchangeParam.skipApproval)
8
+ return null;
9
+ const target = exchangeParam.spender || exchangeParam.targetExchange;
10
+ if (exchangeParam.needUnwrapNative &&
11
+ (0, address_utils_1.isWrappedNativeTokenAddress)(swap.srcToken, context.wrappedNativeTokenAddress)) {
12
+ return null;
13
+ }
14
+ if (!(0, utils_1.isETHAddress)(swap.srcToken) &&
15
+ !exchangeParam.transferSrcTokenBeforeSwap) {
16
+ return {
17
+ token: swap.srcToken,
18
+ target,
19
+ };
20
+ }
21
+ if (exchangeParam.needWrapNative && (0, utils_1.isETHAddress)(swap.srcToken)) {
22
+ return {
23
+ token: exchangeParam.wethAddress || context.wrappedNativeTokenAddress,
24
+ target,
25
+ };
26
+ }
27
+ return null;
28
+ }
29
+ //# sourceMappingURL=approval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.js","sourceRoot":"","sources":["../../src/executor/approval.ts"],"names":[],"mappings":";;AAUA,8DAqCC;AA7CD,oCAAwC;AACxC,mDAA8D;AAO9D,SAAgB,yBAAyB,CACvC,IAA2B,EAC3B,aAAoC,EACpC,OAAmE;IAEnE,IAAI,aAAa,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IAE5C,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,IAAI,aAAa,CAAC,cAAc,CAAC;IAErE,IACE,aAAa,CAAC,gBAAgB;QAC9B,IAAA,2CAA2B,EACzB,IAAI,CAAC,QAAQ,EACb,OAAO,CAAC,yBAAyB,CAClC,EACD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IACE,CAAC,IAAA,oBAAY,EAAC,IAAI,CAAC,QAAQ,CAAC;QAC5B,CAAC,aAAa,CAAC,0BAA0B,EACzC,CAAC;QACD,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,QAAQ;YACpB,MAAM;SACP,CAAC;IACJ,CAAC;IAED,IAAI,aAAa,CAAC,cAAc,IAAI,IAAA,oBAAY,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChE,OAAO;YACL,KAAK,EAAE,aAAa,CAAC,WAAW,IAAI,OAAO,CAAC,yBAAyB;YACrE,MAAM;SACP,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { IDexHelper } from '../dex-helper';
2
+ import type { ExecutorEncodingContext, ExecutorEncodingLogger } from './encoding-types';
3
+ export declare function createNoopExecutorEncodingLogger(): ExecutorEncodingLogger;
4
+ export declare function createExecutorEncodingContextFromDexHelper(dexHelper: IDexHelper): ExecutorEncodingContext;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNoopExecutorEncodingLogger = createNoopExecutorEncodingLogger;
4
+ exports.createExecutorEncodingContextFromDexHelper = createExecutorEncodingContextFromDexHelper;
5
+ const types_1 = require("./types");
6
+ function createNoopExecutorEncodingLogger() {
7
+ return {
8
+ debug: () => undefined,
9
+ info: () => undefined,
10
+ warn: () => undefined,
11
+ error: () => undefined,
12
+ };
13
+ }
14
+ function createExecutorEncodingContextFromDexHelper(dexHelper) {
15
+ const logger = dexHelper.getLogger('ExecutorBytecodeBuilder');
16
+ const wrappedNativeTokenAddress = normalizeRequiredAddress(dexHelper.config.data.wrappedNativeTokenAddress, 'wrappedNativeTokenAddress');
17
+ assertConfiguredWethExecutorAddress(dexHelper.config.data.executorsAddresses?.[types_1.Executors.WETH], wrappedNativeTokenAddress);
18
+ const augustusV6Address = normalizeRequiredAddress(dexHelper.config.data.augustusV6Address, 'augustusV6Address');
19
+ return {
20
+ network: dexHelper.config.data.network,
21
+ augustusV6Address,
22
+ wrappedNativeTokenAddress,
23
+ executorsAddresses: {
24
+ [types_1.Executors.ONE]: normalizeRequiredAddress(dexHelper.config.data.executorsAddresses?.[types_1.Executors.ONE], `executorsAddresses.${types_1.Executors.ONE}`),
25
+ [types_1.Executors.TWO]: normalizeRequiredAddress(dexHelper.config.data.executorsAddresses?.[types_1.Executors.TWO], `executorsAddresses.${types_1.Executors.TWO}`),
26
+ [types_1.Executors.THREE]: normalizeRequiredAddress(dexHelper.config.data.executorsAddresses?.[types_1.Executors.THREE], `executorsAddresses.${types_1.Executors.THREE}`),
27
+ [types_1.Executors.WETH]: wrappedNativeTokenAddress,
28
+ },
29
+ // Keep method bindings: some logger implementations depend on `this`.
30
+ logger: {
31
+ debug: logger.debug.bind(logger),
32
+ info: logger.info.bind(logger),
33
+ warn: logger.warn.bind(logger),
34
+ error: logger.error.bind(logger),
35
+ },
36
+ };
37
+ }
38
+ function normalizeRequiredAddress(address, fieldName) {
39
+ if (!address) {
40
+ throw new Error(`${fieldName} is required`);
41
+ }
42
+ return normalizeAddress(address);
43
+ }
44
+ function assertConfiguredWethExecutorAddress(configuredWethExecutorAddress, wrappedNativeTokenAddress) {
45
+ if (configuredWethExecutorAddress &&
46
+ normalizeAddress(configuredWethExecutorAddress) !==
47
+ normalizeAddress(wrappedNativeTokenAddress)) {
48
+ throw new Error(`executorsAddresses.${types_1.Executors.WETH} must match wrappedNativeTokenAddress`);
49
+ }
50
+ }
51
+ function normalizeAddress(address) {
52
+ return address.toLowerCase();
53
+ }
54
+ //# sourceMappingURL=encoding-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding-context.js","sourceRoot":"","sources":["../../src/executor/encoding-context.ts"],"names":[],"mappings":";;AAQA,4EAOC;AAED,gGA4CC;AAvDD,mCAAoC;AAEpC,SAAgB,gCAAgC;IAC9C,OAAO;QACL,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS;QACtB,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS;QACrB,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS;QACrB,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS;KACvB,CAAC;AACJ,CAAC;AAED,SAAgB,0CAA0C,CACxD,SAAqB;IAErB,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;IAC9D,MAAM,yBAAyB,GAAG,wBAAwB,CACxD,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,EAC/C,2BAA2B,CAC5B,CAAC;IACF,mCAAmC,CACjC,SAAS,CAAC,MAAM,CAAC,IAAI,CAA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C;AACJ,CAAC;AAED,SAAS,wBAAwB,CAC/B,OAA4B,EAC5B,SAAiB;IAEjB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,cAAc,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,mCAAmC,CAC1C,6BAAkD,EAClD,yBAAkC;IAElC,IACE,6BAA6B;QAC7B,gBAAgB,CAAC,6BAA6B,CAAC;YAC7C,gBAAgB,CAAC,yBAAyB,CAAC,EAC7C,CAAC;QACD,MAAM,IAAI,KAAK,CACb,sBAAsB,iBAAS,CAAC,IAAI,uCAAuC,CAC5E,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAgB;IACxC,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,75 @@
1
+ import type { DepositWithdrawReturn } from '../dex/weth/types';
2
+ import type { Address, DexExchangeBuildParam } from '../types';
3
+ import type { Executors } from './types';
4
+ export type ExecutorEncodingLogger = {
5
+ debug: (message: unknown, ...args: unknown[]) => void;
6
+ info: (message: unknown, ...args: unknown[]) => void;
7
+ warn: (message: unknown, ...args: unknown[]) => void;
8
+ error: (message: unknown, ...args: unknown[]) => void;
9
+ };
10
+ export type ExecutorEncodingContext = {
11
+ network: number;
12
+ augustusV6Address: Address;
13
+ wrappedNativeTokenAddress: Address;
14
+ executorsAddresses: Record<Executors, Address>;
15
+ logger: ExecutorEncodingLogger;
16
+ };
17
+ export type RoutePlan = {
18
+ routes: RoutePlanRoute[];
19
+ };
20
+ export type RoutePlanRoute = {
21
+ percent: number;
22
+ swaps: RoutePlanSwap[];
23
+ };
24
+ export type RoutePlanSwap = {
25
+ srcToken: Address;
26
+ destToken: Address;
27
+ srcAmount: string;
28
+ destAmount: string;
29
+ swapExchanges: RoutePlanSwapExchange[];
30
+ };
31
+ export type RoutePlanSwapExchange = {
32
+ exchange: string;
33
+ percent: number;
34
+ srcAmount: string;
35
+ destAmount: string;
36
+ };
37
+ export type ExecutorRoute = {
38
+ srcToken: Address;
39
+ destToken: Address;
40
+ destAmount: string;
41
+ bestRoute: RoutePlanRoute[];
42
+ };
43
+ export type ExecutorRouteRoute = RoutePlanRoute;
44
+ export type ExecutorRouteSwap = RoutePlanSwap;
45
+ export type ExecutorRouteSwapExchange = RoutePlanSwapExchange;
46
+ export type RoutePosition = {
47
+ routeIndex: number;
48
+ swapIndex: number;
49
+ swapExchangeIndex: number;
50
+ };
51
+ export type ResolvedLeg = RoutePosition & {
52
+ exchangeParam: DexExchangeBuildParam;
53
+ normalizedSrcToken: Address;
54
+ normalizedDestToken: Address;
55
+ normalizedSrcAmount: string;
56
+ normalizedDestAmount: string;
57
+ recipient: Address;
58
+ };
59
+ export type RoutePlanExchange = RoutePosition & {
60
+ route: RoutePlanRoute;
61
+ swap: RoutePlanSwap;
62
+ swapExchange: RoutePlanSwapExchange;
63
+ };
64
+ export type OrderedExecutorLeg = RoutePlanExchange & {
65
+ resolvedLeg: ResolvedLeg;
66
+ };
67
+ export type ExecutorBytecodeBuildInput = {
68
+ routePlan: RoutePlan;
69
+ resolvedLegs: ResolvedLeg[];
70
+ sender: Address;
71
+ srcToken: Address;
72
+ destToken: Address;
73
+ destAmount: string;
74
+ wethPlan?: DepositWithdrawReturn;
75
+ };
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
3
+ //# sourceMappingURL=encoding-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding-types.js","sourceRoot":"","sources":["../../src/executor/encoding-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { ExecutorBytecodeBuilder } from './ExecutorBytecodeBuilder';
2
+ import type { ExecutorEncodingContext } from './encoding-types';
3
+ import { Executors } from './types';
4
+ export declare function createExecutorBytecodeBuilder(executorType: Executors, context: ExecutorEncodingContext): ExecutorBytecodeBuilder;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createExecutorBytecodeBuilder = createExecutorBytecodeBuilder;
4
+ const Executor01BytecodeBuilder_1 = require("./Executor01BytecodeBuilder");
5
+ const Executor02BytecodeBuilder_1 = require("./Executor02BytecodeBuilder");
6
+ const Executor03BytecodeBuilder_1 = require("./Executor03BytecodeBuilder");
7
+ const WETHBytecodeBuilder_1 = require("./WETHBytecodeBuilder");
8
+ const types_1 = require("./types");
9
+ function createExecutorBytecodeBuilder(executorType, context) {
10
+ switch (executorType) {
11
+ case types_1.Executors.ONE:
12
+ return new Executor01BytecodeBuilder_1.Executor01BytecodeBuilder(context);
13
+ case types_1.Executors.TWO:
14
+ return new Executor02BytecodeBuilder_1.Executor02BytecodeBuilder(context);
15
+ case types_1.Executors.THREE:
16
+ return new Executor03BytecodeBuilder_1.Executor03BytecodeBuilder(context);
17
+ case types_1.Executors.WETH:
18
+ return new WETHBytecodeBuilder_1.WETHBytecodeBuilder(context);
19
+ default:
20
+ throw new Error(`${executorType} is not supported`);
21
+ }
22
+ }
23
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/executor/factory.ts"],"names":[],"mappings":";;AAQA,sEAgBC;AAxBD,2EAAwE;AACxE,2EAAwE;AACxE,2EAAwE;AACxE,+DAA4D;AAG5D,mCAAoC;AAEpC,SAAgB,6BAA6B,CAC3C,YAAuB,EACvB,OAAgC;IAEhC,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,iBAAS,CAAC,GAAG;YAChB,OAAO,IAAI,qDAAyB,CAAC,OAAO,CAAC,CAAC;QAChD,KAAK,iBAAS,CAAC,GAAG;YAChB,OAAO,IAAI,qDAAyB,CAAC,OAAO,CAAC,CAAC;QAChD,KAAK,iBAAS,CAAC,KAAK;YAClB,OAAO,IAAI,qDAAyB,CAAC,OAAO,CAAC,CAAC;QAChD,KAAK,iBAAS,CAAC,IAAI;YACjB,OAAO,IAAI,yCAAmB,CAAC,OAAO,CAAC,CAAC;QAC1C;YACE,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,mBAAmB,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { OptimalRate } from '@paraswap/core';
2
+ import type { OrderedExecutorLeg, ResolvedLeg, RoutePlan, RoutePlanExchange, RoutePosition } from './encoding-types';
3
+ export declare function buildRoutePlan(priceRoute: OptimalRate): RoutePlan;
4
+ export declare function flattenRoutePlan(routePlan: RoutePlan): RoutePosition[];
5
+ export declare function walkRoutePlan(routePlan: RoutePlan): RoutePlanExchange[];
6
+ export declare function routePositionKey(position: RoutePosition): string;
7
+ export declare function getRoutePlanLegCount(routePlan: RoutePlan): number;
8
+ export declare function getOrderedExecutorLegs(routePlan: RoutePlan, resolvedLegs: ResolvedLeg[]): OrderedExecutorLeg[];
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildRoutePlan = buildRoutePlan;
4
+ exports.flattenRoutePlan = flattenRoutePlan;
5
+ exports.walkRoutePlan = walkRoutePlan;
6
+ exports.routePositionKey = routePositionKey;
7
+ exports.getRoutePlanLegCount = getRoutePlanLegCount;
8
+ exports.getOrderedExecutorLegs = getOrderedExecutorLegs;
9
+ function buildRoutePlan(priceRoute) {
10
+ return {
11
+ routes: priceRoute.bestRoute.map(route => ({
12
+ percent: route.percent,
13
+ swaps: route.swaps.map(swap => buildRoutePlanSwap(swap)),
14
+ })),
15
+ };
16
+ }
17
+ function flattenRoutePlan(routePlan) {
18
+ return walkRoutePlan(routePlan).map(({ routeIndex, swapIndex, swapExchangeIndex }) => ({
19
+ routeIndex,
20
+ swapIndex,
21
+ swapExchangeIndex,
22
+ }));
23
+ }
24
+ function walkRoutePlan(routePlan) {
25
+ return routePlan.routes.flatMap((route, routeIndex) => route.swaps.flatMap((swap, swapIndex) => swap.swapExchanges.map((swapExchange, swapExchangeIndex) => ({
26
+ routeIndex,
27
+ swapIndex,
28
+ swapExchangeIndex,
29
+ route,
30
+ swap,
31
+ swapExchange,
32
+ }))));
33
+ }
34
+ function routePositionKey(position) {
35
+ return [
36
+ position.routeIndex,
37
+ position.swapIndex,
38
+ position.swapExchangeIndex,
39
+ ].join(':');
40
+ }
41
+ function getRoutePlanLegCount(routePlan) {
42
+ return routePlan.routes.reduce((routeCount, route) => routeCount +
43
+ route.swaps.reduce((swapCount, swap) => swapCount + swap.swapExchanges.length, 0), 0);
44
+ }
45
+ function getOrderedExecutorLegs(routePlan, resolvedLegs) {
46
+ // Executor validation is deliberately local to bytecode traversal, even when
47
+ // callers already validated serialized boundary input.
48
+ const routePositions = walkRoutePlan(routePlan);
49
+ const routePositionKeys = new Set(routePositions.map(routePositionKey));
50
+ const resolvedLegByKey = new Map();
51
+ const duplicateKeys = new Set();
52
+ const extraKeys = new Set();
53
+ resolvedLegs.forEach(resolvedLeg => {
54
+ const key = routePositionKey(resolvedLeg);
55
+ if (resolvedLegByKey.has(key)) {
56
+ duplicateKeys.add(key);
57
+ }
58
+ if (!routePositionKeys.has(key)) {
59
+ extraKeys.add(key);
60
+ }
61
+ resolvedLegByKey.set(key, resolvedLeg);
62
+ });
63
+ if (duplicateKeys.size > 0) {
64
+ throw new Error(`duplicate resolved leg route position(s): ${[...duplicateKeys].join(', ')}`);
65
+ }
66
+ if (extraKeys.size > 0) {
67
+ throw new Error(`resolved leg route position(s) not present in route plan: ${[
68
+ ...extraKeys,
69
+ ].join(', ')}`);
70
+ }
71
+ return routePositions.map(routePosition => {
72
+ const key = routePositionKey(routePosition);
73
+ const resolvedLeg = resolvedLegByKey.get(key);
74
+ if (!resolvedLeg) {
75
+ throw new Error(`missing resolved leg for route position ${key}`);
76
+ }
77
+ return {
78
+ ...routePosition,
79
+ resolvedLeg,
80
+ };
81
+ });
82
+ }
83
+ function buildRoutePlanSwap(swap) {
84
+ return {
85
+ srcToken: normalizeAddress(swap.srcToken),
86
+ destToken: normalizeAddress(swap.destToken),
87
+ srcAmount: getSwapAmount(swap, 'srcAmount'),
88
+ destAmount: getSwapAmount(swap, 'destAmount'),
89
+ swapExchanges: swap.swapExchanges.map(swapExchange => ({
90
+ exchange: swapExchange.exchange,
91
+ percent: swapExchange.percent,
92
+ srcAmount: swapExchange.srcAmount,
93
+ destAmount: swapExchange.destAmount,
94
+ })),
95
+ };
96
+ }
97
+ function getSwapAmount(swap, amountField) {
98
+ const amount = swap[amountField];
99
+ if (amount !== undefined)
100
+ return amount;
101
+ return sumDecimalStrings(swap.swapExchanges.map(swapExchange => swapExchange[amountField]));
102
+ }
103
+ function sumDecimalStrings(amounts) {
104
+ return amounts.reduce((sum, amount) => sum + BigInt(amount), 0n).toString();
105
+ }
106
+ function normalizeAddress(address) {
107
+ return address.toLowerCase();
108
+ }
109
+ //# sourceMappingURL=route-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-plan.js","sourceRoot":"","sources":["../../src/executor/route-plan.ts"],"names":[],"mappings":";;AAkBA,wCAOC;AAED,4CAQC;AAED,sCAaC;AAED,4CAMC;AAED,oDAUC;AAED,wDAuDC;AA7GD,SAAgB,cAAc,CAAC,UAAuB;IACpD,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACzC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;SACzD,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,SAAoB;IACnD,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,GAAG,CACjC,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,i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@
1
+ import { ContractMethodV6, SwapSide } from '@paraswap/core';
2
+ export declare const DIRECT_CONTRACT_METHODS_V6: readonly [ContractMethodV6.swapExactAmountInOnUniswapV2, ContractMethodV6.swapExactAmountOutOnUniswapV2, ContractMethodV6.swapExactAmountInOnUniswapV3, ContractMethodV6.swapExactAmountOutOnUniswapV3, ContractMethodV6.swapExactAmountInOnBalancerV2, ContractMethodV6.swapExactAmountOutOnBalancerV2, ContractMethodV6.swapExactAmountInOnCurveV1, ContractMethodV6.swapExactAmountInOnCurveV2, ContractMethodV6.swapOnAugustusRFQTryBatchFill, ContractMethodV6.swapExactAmountInOutOnMakerPSM];
3
+ export type DirectContractMethodV6 = (typeof DIRECT_CONTRACT_METHODS_V6)[number];
4
+ export declare const DIRECT_CONTRACT_METHOD_SIDES_V6: Partial<Record<DirectContractMethodV6, SwapSide>>;
5
+ export declare function isDirectContractMethodV6(contractMethod: string): contractMethod is DirectContractMethodV6;
6
+ export declare function getDirectContractMethodSideV6(contractMethod: DirectContractMethodV6): SwapSide | undefined;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DIRECT_CONTRACT_METHOD_SIDES_V6 = exports.DIRECT_CONTRACT_METHODS_V6 = void 0;
4
+ exports.isDirectContractMethodV6 = isDirectContractMethodV6;
5
+ exports.getDirectContractMethodSideV6 = getDirectContractMethodSideV6;
6
+ const core_1 = require("@paraswap/core");
7
+ exports.DIRECT_CONTRACT_METHODS_V6 = [
8
+ core_1.ContractMethodV6.swapExactAmountInOnUniswapV2,
9
+ core_1.ContractMethodV6.swapExactAmountOutOnUniswapV2,
10
+ core_1.ContractMethodV6.swapExactAmountInOnUniswapV3,
11
+ core_1.ContractMethodV6.swapExactAmountOutOnUniswapV3,
12
+ core_1.ContractMethodV6.swapExactAmountInOnBalancerV2,
13
+ core_1.ContractMethodV6.swapExactAmountOutOnBalancerV2,
14
+ core_1.ContractMethodV6.swapExactAmountInOnCurveV1,
15
+ core_1.ContractMethodV6.swapExactAmountInOnCurveV2,
16
+ core_1.ContractMethodV6.swapOnAugustusRFQTryBatchFill,
17
+ core_1.ContractMethodV6.swapExactAmountInOutOnMakerPSM,
18
+ ];
19
+ const DIRECT_CONTRACT_METHOD_SET_V6 = new Set(exports.DIRECT_CONTRACT_METHODS_V6);
20
+ // Omits swapOnAugustusRFQTryBatchFill and swapExactAmountInOutOnMakerPSM:
21
+ // those methods do not encode side in the method name. An undefined lookup
22
+ // means side must come from the per-call route input.
23
+ exports.DIRECT_CONTRACT_METHOD_SIDES_V6 = {
24
+ [core_1.ContractMethodV6.swapExactAmountInOnUniswapV2]: core_1.SwapSide.SELL,
25
+ [core_1.ContractMethodV6.swapExactAmountOutOnUniswapV2]: core_1.SwapSide.BUY,
26
+ [core_1.ContractMethodV6.swapExactAmountInOnUniswapV3]: core_1.SwapSide.SELL,
27
+ [core_1.ContractMethodV6.swapExactAmountOutOnUniswapV3]: core_1.SwapSide.BUY,
28
+ [core_1.ContractMethodV6.swapExactAmountInOnBalancerV2]: core_1.SwapSide.SELL,
29
+ [core_1.ContractMethodV6.swapExactAmountOutOnBalancerV2]: core_1.SwapSide.BUY,
30
+ [core_1.ContractMethodV6.swapExactAmountInOnCurveV1]: core_1.SwapSide.SELL,
31
+ [core_1.ContractMethodV6.swapExactAmountInOnCurveV2]: core_1.SwapSide.SELL,
32
+ };
33
+ function isDirectContractMethodV6(contractMethod) {
34
+ return DIRECT_CONTRACT_METHOD_SET_V6.has(contractMethod);
35
+ }
36
+ function getDirectContractMethodSideV6(contractMethod) {
37
+ return exports.DIRECT_CONTRACT_METHOD_SIDES_V6[contractMethod];
38
+ }
39
+ //# sourceMappingURL=direct-methods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direct-methods.js","sourceRoot":"","sources":["../../../src/generic-swap-transaction-builder/dex-encoder/direct-methods.ts"],"names":[],"mappings":";;;AAsCA,4DAIC;AAED,sEAIC;AAhDD,yCAA4D;AAE/C,QA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,4 @@
1
+ export * from './direct-methods';
2
+ export * from './ports';
3
+ export * from './ts-adapter';
4
+ export * from './types';
@@ -0,0 +1,21 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./direct-methods"), exports);
18
+ __exportStar(require("./ports"), exports);
19
+ __exportStar(require("./ts-adapter"), exports);
20
+ __exportStar(require("./types"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generic-swap-transaction-builder/dex-encoder/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,0CAAwB;AACxB,+CAA6B;AAC7B,0CAAwB"}
@@ -0,0 +1,26 @@
1
+ import type { ExecutorEncodingContext } from '../../executor/encoding-types';
2
+ import type { DexExchangeParam, DexParamInput, DirectParamInput, DirectParamResult, NeedWrapNativeInput, WethDepositWithdrawInput, WethDepositWithdrawResult } from './types';
3
+ export type MaybePromise<T> = T | Promise<T>;
4
+ export type DexEncoderPort = {
5
+ needWrapNative(input: NeedWrapNativeInput): MaybePromise<boolean>;
6
+ getDexParam(input: DexParamInput): MaybePromise<DexExchangeParam>;
7
+ };
8
+ export type DirectDexEncoderPort = {
9
+ getDirectParam(input: DirectParamInput): MaybePromise<DirectParamResult>;
10
+ };
11
+ export type DexEncoderLookup = {
12
+ network: number;
13
+ dexKey: string;
14
+ };
15
+ export type DirectDexEncoderLookup = DexEncoderLookup & {
16
+ contractMethod: DirectParamInput['contractMethod'];
17
+ };
18
+ export type DexEncoderRegistryPort = {
19
+ getDexEncoder(lookup: DexEncoderLookup): MaybePromise<DexEncoderPort>;
20
+ getDirectDexEncoder(lookup: DirectDexEncoderLookup): MaybePromise<DirectDexEncoderPort>;
21
+ };
22
+ export type WethCallDataProviderPort = {
23
+ getDepositWithdrawCallData(input: WethDepositWithdrawInput): MaybePromise<WethDepositWithdrawResult | undefined>;
24
+ };
25
+ export type CreateWethCallDataProviderPort = (context: ExecutorEncodingContext) => WethCallDataProviderPort;
26
+ export type CreateWethCallDataProvider = CreateWethCallDataProviderPort;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
3
+ //# sourceMappingURL=ports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.js","sourceRoot":"","sources":["../../../src/generic-swap-transaction-builder/dex-encoder/ports.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import type { DexAdapterService } from '../../dex';
2
+ import type { ExecutorEncodingContext } from '../../executor/encoding-types';
3
+ import { type DirectParamInput } from './types';
4
+ import type { DexEncoderPort, DexEncoderRegistryPort, DirectDexEncoderPort, WethCallDataProviderPort } from './ports';
5
+ type TsDexAdapterService = Pick<DexAdapterService, 'network' | 'getTxBuilderDexByKey'>;
6
+ export declare function createTsDexEncoderRegistry(dexAdapterService: TsDexAdapterService): DexEncoderRegistryPort;
7
+ export declare class TsDexEncoderRegistryAdapter implements DexEncoderRegistryPort {
8
+ private readonly dexAdapterService;
9
+ constructor(dexAdapterService: TsDexAdapterService);
10
+ getDexEncoder({ network, dexKey, }: {
11
+ network: number;
12
+ dexKey: string;
13
+ }): Promise<DexEncoderPort>;
14
+ getDirectDexEncoder({ network, dexKey, contractMethod, }: {
15
+ network: number;
16
+ dexKey: string;
17
+ contractMethod: DirectParamInput['contractMethod'];
18
+ }): Promise<DirectDexEncoderPort>;
19
+ private assertNetwork;
20
+ }
21
+ export declare function createWethCallDataProvider(context: ExecutorEncodingContext): WethCallDataProviderPort;
22
+ export {};