@7kprotocol/sdk-ts 3.6.0 → 3.6.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/README.md +1 -11
  2. package/lib/cjs/config/fetchClient.js +1 -9
  3. package/lib/cjs/constants/_7k.js +13 -10
  4. package/lib/cjs/constants/apiEndpoints.js +1 -1
  5. package/lib/cjs/features/metaAg/common.js +2 -2
  6. package/lib/cjs/features/metaAg/error.js +0 -4
  7. package/lib/cjs/features/metaAg/index.js +3 -8
  8. package/lib/cjs/features/prices/index.js +51 -20
  9. package/lib/cjs/index.js +1 -35
  10. package/lib/cjs/types/config/fetchClient.d.ts.map +1 -1
  11. package/lib/cjs/types/constants/_7k.d.ts +0 -3
  12. package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
  13. package/lib/cjs/types/features/metaAg/common.d.ts +1 -1
  14. package/lib/cjs/types/features/metaAg/error.d.ts +1 -7
  15. package/lib/cjs/types/features/metaAg/error.d.ts.map +1 -1
  16. package/lib/cjs/types/features/metaAg/index.d.ts +1 -1
  17. package/lib/cjs/types/features/metaAg/index.d.ts.map +1 -1
  18. package/lib/cjs/types/features/prices/index.d.ts +16 -2
  19. package/lib/cjs/types/features/prices/index.d.ts.map +1 -1
  20. package/lib/cjs/types/index.d.ts +1 -32
  21. package/lib/cjs/types/index.d.ts.map +1 -1
  22. package/lib/cjs/types/metaAg.js +1 -3
  23. package/lib/cjs/types/types/metaAg.d.ts +2 -14
  24. package/lib/cjs/types/types/metaAg.d.ts.map +1 -1
  25. package/lib/cjs/types/utils/sui.d.ts +0 -31
  26. package/lib/cjs/types/utils/sui.d.ts.map +1 -1
  27. package/lib/cjs/types/utils/swap.d.ts +15 -0
  28. package/lib/cjs/types/utils/swap.d.ts.map +1 -0
  29. package/lib/cjs/utils/sui.js +3 -146
  30. package/lib/cjs/utils/swap.js +37 -0
  31. package/lib/esm/config/fetchClient.js +1 -9
  32. package/lib/esm/constants/_7k.js +12 -9
  33. package/lib/esm/constants/apiEndpoints.js +1 -1
  34. package/lib/esm/features/metaAg/common.js +1 -1
  35. package/lib/esm/features/metaAg/error.js +0 -4
  36. package/lib/esm/features/metaAg/index.js +2 -7
  37. package/lib/esm/features/prices/index.js +52 -21
  38. package/lib/esm/index.mjs +3 -31
  39. package/lib/esm/types/config/fetchClient.d.ts.map +1 -1
  40. package/lib/esm/types/constants/_7k.d.ts +0 -3
  41. package/lib/esm/types/constants/_7k.d.ts.map +1 -1
  42. package/lib/esm/types/features/metaAg/common.d.ts +1 -1
  43. package/lib/esm/types/features/metaAg/error.d.ts +1 -7
  44. package/lib/esm/types/features/metaAg/error.d.ts.map +1 -1
  45. package/lib/esm/types/features/metaAg/index.d.ts +1 -1
  46. package/lib/esm/types/features/metaAg/index.d.ts.map +1 -1
  47. package/lib/esm/types/features/prices/index.d.ts +16 -2
  48. package/lib/esm/types/features/prices/index.d.ts.map +1 -1
  49. package/lib/esm/types/index.d.ts +1 -32
  50. package/lib/esm/types/index.d.ts.map +1 -1
  51. package/lib/esm/types/metaAg.js +1 -3
  52. package/lib/esm/types/types/metaAg.d.ts +2 -14
  53. package/lib/esm/types/types/metaAg.d.ts.map +1 -1
  54. package/lib/esm/types/utils/sui.d.ts +0 -31
  55. package/lib/esm/types/utils/sui.d.ts.map +1 -1
  56. package/lib/esm/types/utils/swap.d.ts +15 -0
  57. package/lib/esm/types/utils/swap.d.ts.map +1 -0
  58. package/lib/esm/utils/sui.js +4 -147
  59. package/lib/esm/utils/swap.js +33 -0
  60. package/package.json +1 -1
  61. package/lib/cjs/config/index.js +0 -67
  62. package/lib/cjs/features/metaAg/providers/bluefin7kLegacy.js +0 -68
  63. package/lib/cjs/features/swap/buildTx.js +0 -198
  64. package/lib/cjs/features/swap/buildTxV2.js +0 -229
  65. package/lib/cjs/features/swap/config.js +0 -154
  66. package/lib/cjs/features/swap/estimateGasFee.js +0 -44
  67. package/lib/cjs/features/swap/executeTx.js +0 -52
  68. package/lib/cjs/features/swap/getQuote.js +0 -95
  69. package/lib/cjs/features/swap/getSwapHistory.js +0 -21
  70. package/lib/cjs/features/swap/index.js +0 -22
  71. package/lib/cjs/libs/groupSwapRoutes.js +0 -60
  72. package/lib/cjs/libs/protocols/aftermath/index.js +0 -35
  73. package/lib/cjs/libs/protocols/base.js +0 -41
  74. package/lib/cjs/libs/protocols/bluefin/index.js +0 -38
  75. package/lib/cjs/libs/protocols/bluefinx/client.js +0 -41
  76. package/lib/cjs/libs/protocols/bluefinx/index.js +0 -48
  77. package/lib/cjs/libs/protocols/bluefinx/types.js +0 -10
  78. package/lib/cjs/libs/protocols/bluemove/index.js +0 -24
  79. package/lib/cjs/libs/protocols/cetus/index.js +0 -44
  80. package/lib/cjs/libs/protocols/cetus_dlmm.js +0 -48
  81. package/lib/cjs/libs/protocols/constants.js +0 -5
  82. package/lib/cjs/libs/protocols/deepbookV3/sponsored.js +0 -30
  83. package/lib/cjs/libs/protocols/ferra_clmm.js +0 -44
  84. package/lib/cjs/libs/protocols/ferra_dlmm.js +0 -30
  85. package/lib/cjs/libs/protocols/flowx/index.js +0 -18
  86. package/lib/cjs/libs/protocols/flowxV3/index.js +0 -36
  87. package/lib/cjs/libs/protocols/fullsail/index.js +0 -39
  88. package/lib/cjs/libs/protocols/haedal_pmm/index.js +0 -31
  89. package/lib/cjs/libs/protocols/index.js +0 -55
  90. package/lib/cjs/libs/protocols/kriya/index.js +0 -30
  91. package/lib/cjs/libs/protocols/kriyaV3/index.js +0 -65
  92. package/lib/cjs/libs/protocols/magma/index.js +0 -40
  93. package/lib/cjs/libs/protocols/momentum/index.js +0 -49
  94. package/lib/cjs/libs/protocols/obric/index.js +0 -28
  95. package/lib/cjs/libs/protocols/sevenk/index.js +0 -55
  96. package/lib/cjs/libs/protocols/springsui/index.js +0 -24
  97. package/lib/cjs/libs/protocols/steamm/index.js +0 -160
  98. package/lib/cjs/libs/protocols/stsui/index.js +0 -24
  99. package/lib/cjs/libs/protocols/suiswap/index.js +0 -34
  100. package/lib/cjs/libs/protocols/turbos/index.js +0 -36
  101. package/lib/cjs/libs/protocols/utils.js +0 -7
  102. package/lib/cjs/libs/swapWithRoute.js +0 -22
  103. package/lib/cjs/types/aggregator.js +0 -19
  104. package/lib/cjs/types/config/index.d.ts +0 -30
  105. package/lib/cjs/types/config/index.d.ts.map +0 -1
  106. package/lib/cjs/types/features/metaAg/providers/bluefin7kLegacy.d.ts +0 -11
  107. package/lib/cjs/types/features/metaAg/providers/bluefin7kLegacy.d.ts.map +0 -1
  108. package/lib/cjs/types/features/swap/buildTx.d.ts +0 -17
  109. package/lib/cjs/types/features/swap/buildTx.d.ts.map +0 -1
  110. package/lib/cjs/types/features/swap/buildTxV2.d.ts +0 -20
  111. package/lib/cjs/types/features/swap/buildTxV2.d.ts.map +0 -1
  112. package/lib/cjs/types/features/swap/config.d.ts +0 -4
  113. package/lib/cjs/types/features/swap/config.d.ts.map +0 -1
  114. package/lib/cjs/types/features/swap/estimateGasFee.d.ts +0 -3
  115. package/lib/cjs/types/features/swap/estimateGasFee.d.ts.map +0 -1
  116. package/lib/cjs/types/features/swap/executeTx.d.ts +0 -24
  117. package/lib/cjs/types/features/swap/executeTx.d.ts.map +0 -1
  118. package/lib/cjs/types/features/swap/getQuote.d.ts +0 -27
  119. package/lib/cjs/types/features/swap/getQuote.d.ts.map +0 -1
  120. package/lib/cjs/types/features/swap/getSwapHistory.d.ts +0 -22
  121. package/lib/cjs/types/features/swap/getSwapHistory.d.ts.map +0 -1
  122. package/lib/cjs/types/features/swap/index.d.ts +0 -7
  123. package/lib/cjs/types/features/swap/index.d.ts.map +0 -1
  124. package/lib/cjs/types/libs/groupSwapRoutes.d.ts +0 -3
  125. package/lib/cjs/types/libs/groupSwapRoutes.d.ts.map +0 -1
  126. package/lib/cjs/types/libs/protocols/aftermath/index.d.ts +0 -9
  127. package/lib/cjs/types/libs/protocols/aftermath/index.d.ts.map +0 -1
  128. package/lib/cjs/types/libs/protocols/base.d.ts +0 -24
  129. package/lib/cjs/types/libs/protocols/base.d.ts.map +0 -1
  130. package/lib/cjs/types/libs/protocols/bluefin/index.d.ts +0 -9
  131. package/lib/cjs/types/libs/protocols/bluefin/index.d.ts.map +0 -1
  132. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts +0 -13
  133. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts.map +0 -1
  134. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts +0 -17
  135. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts.map +0 -1
  136. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts +0 -34
  137. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts.map +0 -1
  138. package/lib/cjs/types/libs/protocols/bluemove/index.d.ts +0 -9
  139. package/lib/cjs/types/libs/protocols/bluemove/index.d.ts.map +0 -1
  140. package/lib/cjs/types/libs/protocols/cetus/index.d.ts +0 -9
  141. package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +0 -1
  142. package/lib/cjs/types/libs/protocols/cetus_dlmm.d.ts +0 -9
  143. package/lib/cjs/types/libs/protocols/cetus_dlmm.d.ts.map +0 -1
  144. package/lib/cjs/types/libs/protocols/constants.d.ts +0 -3
  145. package/lib/cjs/types/libs/protocols/constants.d.ts.map +0 -1
  146. package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts +0 -7
  147. package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts.map +0 -1
  148. package/lib/cjs/types/libs/protocols/ferra_clmm.d.ts +0 -9
  149. package/lib/cjs/types/libs/protocols/ferra_clmm.d.ts.map +0 -1
  150. package/lib/cjs/types/libs/protocols/ferra_dlmm.d.ts +0 -9
  151. package/lib/cjs/types/libs/protocols/ferra_dlmm.d.ts.map +0 -1
  152. package/lib/cjs/types/libs/protocols/flowx/index.d.ts +0 -9
  153. package/lib/cjs/types/libs/protocols/flowx/index.d.ts.map +0 -1
  154. package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts +0 -9
  155. package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts.map +0 -1
  156. package/lib/cjs/types/libs/protocols/fullsail/index.d.ts +0 -9
  157. package/lib/cjs/types/libs/protocols/fullsail/index.d.ts.map +0 -1
  158. package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts +0 -14
  159. package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts.map +0 -1
  160. package/lib/cjs/types/libs/protocols/index.d.ts +0 -53
  161. package/lib/cjs/types/libs/protocols/index.d.ts.map +0 -1
  162. package/lib/cjs/types/libs/protocols/kriya/index.d.ts +0 -9
  163. package/lib/cjs/types/libs/protocols/kriya/index.d.ts.map +0 -1
  164. package/lib/cjs/types/libs/protocols/kriyaV3/index.d.ts +0 -9
  165. package/lib/cjs/types/libs/protocols/kriyaV3/index.d.ts.map +0 -1
  166. package/lib/cjs/types/libs/protocols/magma/index.d.ts +0 -9
  167. package/lib/cjs/types/libs/protocols/magma/index.d.ts.map +0 -1
  168. package/lib/cjs/types/libs/protocols/momentum/index.d.ts +0 -9
  169. package/lib/cjs/types/libs/protocols/momentum/index.d.ts.map +0 -1
  170. package/lib/cjs/types/libs/protocols/obric/index.d.ts +0 -14
  171. package/lib/cjs/types/libs/protocols/obric/index.d.ts.map +0 -1
  172. package/lib/cjs/types/libs/protocols/sevenk/index.d.ts +0 -18
  173. package/lib/cjs/types/libs/protocols/sevenk/index.d.ts.map +0 -1
  174. package/lib/cjs/types/libs/protocols/springsui/index.d.ts +0 -9
  175. package/lib/cjs/types/libs/protocols/springsui/index.d.ts.map +0 -1
  176. package/lib/cjs/types/libs/protocols/steamm/index.d.ts +0 -28
  177. package/lib/cjs/types/libs/protocols/steamm/index.d.ts.map +0 -1
  178. package/lib/cjs/types/libs/protocols/stsui/index.d.ts +0 -9
  179. package/lib/cjs/types/libs/protocols/stsui/index.d.ts.map +0 -1
  180. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts +0 -9
  181. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts.map +0 -1
  182. package/lib/cjs/types/libs/protocols/turbos/index.d.ts +0 -9
  183. package/lib/cjs/types/libs/protocols/turbos/index.d.ts.map +0 -1
  184. package/lib/cjs/types/libs/protocols/utils.d.ts +0 -2
  185. package/lib/cjs/types/libs/protocols/utils.d.ts.map +0 -1
  186. package/lib/cjs/types/libs/swapWithRoute.d.ts +0 -12
  187. package/lib/cjs/types/libs/swapWithRoute.d.ts.map +0 -1
  188. package/lib/cjs/types/sui.js +0 -2
  189. package/lib/cjs/types/tx.js +0 -2
  190. package/lib/cjs/types/types/aggregator.d.ts +0 -173
  191. package/lib/cjs/types/types/aggregator.d.ts.map +0 -1
  192. package/lib/cjs/types/types/sui.d.ts +0 -4
  193. package/lib/cjs/types/types/sui.d.ts.map +0 -1
  194. package/lib/cjs/types/types/tx.d.ts +0 -67
  195. package/lib/cjs/types/types/tx.d.ts.map +0 -1
  196. package/lib/cjs/types/types/utilities.d.ts +0 -5
  197. package/lib/cjs/types/types/utilities.d.ts.map +0 -1
  198. package/lib/cjs/types/utilities.js +0 -2
  199. package/lib/cjs/types/utils/number.d.ts +0 -2
  200. package/lib/cjs/types/utils/number.d.ts.map +0 -1
  201. package/lib/cjs/utils/number.js +0 -9
  202. package/lib/esm/config/index.js +0 -64
  203. package/lib/esm/features/metaAg/providers/bluefin7kLegacy.js +0 -66
  204. package/lib/esm/features/swap/buildTx.js +0 -188
  205. package/lib/esm/features/swap/buildTxV2.js +0 -223
  206. package/lib/esm/features/swap/config.js +0 -150
  207. package/lib/esm/features/swap/estimateGasFee.js +0 -41
  208. package/lib/esm/features/swap/executeTx.js +0 -48
  209. package/lib/esm/features/swap/getQuote.js +0 -91
  210. package/lib/esm/features/swap/getSwapHistory.js +0 -18
  211. package/lib/esm/features/swap/index.js +0 -6
  212. package/lib/esm/libs/groupSwapRoutes.js +0 -57
  213. package/lib/esm/libs/protocols/aftermath/index.js +0 -31
  214. package/lib/esm/libs/protocols/base.js +0 -42
  215. package/lib/esm/libs/protocols/bluefin/index.js +0 -34
  216. package/lib/esm/libs/protocols/bluefinx/client.js +0 -36
  217. package/lib/esm/libs/protocols/bluefinx/index.js +0 -44
  218. package/lib/esm/libs/protocols/bluefinx/types.js +0 -8
  219. package/lib/esm/libs/protocols/bluemove/index.js +0 -20
  220. package/lib/esm/libs/protocols/cetus/index.js +0 -40
  221. package/lib/esm/libs/protocols/cetus_dlmm.js +0 -44
  222. package/lib/esm/libs/protocols/constants.js +0 -2
  223. package/lib/esm/libs/protocols/deepbookV3/sponsored.js +0 -26
  224. package/lib/esm/libs/protocols/ferra_clmm.js +0 -40
  225. package/lib/esm/libs/protocols/ferra_dlmm.js +0 -26
  226. package/lib/esm/libs/protocols/flowx/index.js +0 -14
  227. package/lib/esm/libs/protocols/flowxV3/index.js +0 -32
  228. package/lib/esm/libs/protocols/fullsail/index.js +0 -35
  229. package/lib/esm/libs/protocols/haedal_pmm/index.js +0 -27
  230. package/lib/esm/libs/protocols/index.js +0 -52
  231. package/lib/esm/libs/protocols/kriya/index.js +0 -26
  232. package/lib/esm/libs/protocols/kriyaV3/index.js +0 -61
  233. package/lib/esm/libs/protocols/magma/index.js +0 -36
  234. package/lib/esm/libs/protocols/momentum/index.js +0 -45
  235. package/lib/esm/libs/protocols/obric/index.js +0 -24
  236. package/lib/esm/libs/protocols/sevenk/index.js +0 -51
  237. package/lib/esm/libs/protocols/springsui/index.js +0 -20
  238. package/lib/esm/libs/protocols/steamm/index.js +0 -156
  239. package/lib/esm/libs/protocols/stsui/index.js +0 -20
  240. package/lib/esm/libs/protocols/suiswap/index.js +0 -30
  241. package/lib/esm/libs/protocols/turbos/index.js +0 -32
  242. package/lib/esm/libs/protocols/utils.js +0 -4
  243. package/lib/esm/libs/swapWithRoute.js +0 -19
  244. package/lib/esm/types/aggregator.js +0 -14
  245. package/lib/esm/types/config/index.d.ts +0 -30
  246. package/lib/esm/types/config/index.d.ts.map +0 -1
  247. package/lib/esm/types/features/metaAg/providers/bluefin7kLegacy.d.ts +0 -11
  248. package/lib/esm/types/features/metaAg/providers/bluefin7kLegacy.d.ts.map +0 -1
  249. package/lib/esm/types/features/swap/buildTx.d.ts +0 -17
  250. package/lib/esm/types/features/swap/buildTx.d.ts.map +0 -1
  251. package/lib/esm/types/features/swap/buildTxV2.d.ts +0 -20
  252. package/lib/esm/types/features/swap/buildTxV2.d.ts.map +0 -1
  253. package/lib/esm/types/features/swap/config.d.ts +0 -4
  254. package/lib/esm/types/features/swap/config.d.ts.map +0 -1
  255. package/lib/esm/types/features/swap/estimateGasFee.d.ts +0 -3
  256. package/lib/esm/types/features/swap/estimateGasFee.d.ts.map +0 -1
  257. package/lib/esm/types/features/swap/executeTx.d.ts +0 -24
  258. package/lib/esm/types/features/swap/executeTx.d.ts.map +0 -1
  259. package/lib/esm/types/features/swap/getQuote.d.ts +0 -27
  260. package/lib/esm/types/features/swap/getQuote.d.ts.map +0 -1
  261. package/lib/esm/types/features/swap/getSwapHistory.d.ts +0 -22
  262. package/lib/esm/types/features/swap/getSwapHistory.d.ts.map +0 -1
  263. package/lib/esm/types/features/swap/index.d.ts +0 -7
  264. package/lib/esm/types/features/swap/index.d.ts.map +0 -1
  265. package/lib/esm/types/libs/groupSwapRoutes.d.ts +0 -3
  266. package/lib/esm/types/libs/groupSwapRoutes.d.ts.map +0 -1
  267. package/lib/esm/types/libs/protocols/aftermath/index.d.ts +0 -9
  268. package/lib/esm/types/libs/protocols/aftermath/index.d.ts.map +0 -1
  269. package/lib/esm/types/libs/protocols/base.d.ts +0 -24
  270. package/lib/esm/types/libs/protocols/base.d.ts.map +0 -1
  271. package/lib/esm/types/libs/protocols/bluefin/index.d.ts +0 -9
  272. package/lib/esm/types/libs/protocols/bluefin/index.d.ts.map +0 -1
  273. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts +0 -13
  274. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts.map +0 -1
  275. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts +0 -17
  276. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts.map +0 -1
  277. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts +0 -34
  278. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts.map +0 -1
  279. package/lib/esm/types/libs/protocols/bluemove/index.d.ts +0 -9
  280. package/lib/esm/types/libs/protocols/bluemove/index.d.ts.map +0 -1
  281. package/lib/esm/types/libs/protocols/cetus/index.d.ts +0 -9
  282. package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +0 -1
  283. package/lib/esm/types/libs/protocols/cetus_dlmm.d.ts +0 -9
  284. package/lib/esm/types/libs/protocols/cetus_dlmm.d.ts.map +0 -1
  285. package/lib/esm/types/libs/protocols/constants.d.ts +0 -3
  286. package/lib/esm/types/libs/protocols/constants.d.ts.map +0 -1
  287. package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts +0 -7
  288. package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts.map +0 -1
  289. package/lib/esm/types/libs/protocols/ferra_clmm.d.ts +0 -9
  290. package/lib/esm/types/libs/protocols/ferra_clmm.d.ts.map +0 -1
  291. package/lib/esm/types/libs/protocols/ferra_dlmm.d.ts +0 -9
  292. package/lib/esm/types/libs/protocols/ferra_dlmm.d.ts.map +0 -1
  293. package/lib/esm/types/libs/protocols/flowx/index.d.ts +0 -9
  294. package/lib/esm/types/libs/protocols/flowx/index.d.ts.map +0 -1
  295. package/lib/esm/types/libs/protocols/flowxV3/index.d.ts +0 -9
  296. package/lib/esm/types/libs/protocols/flowxV3/index.d.ts.map +0 -1
  297. package/lib/esm/types/libs/protocols/fullsail/index.d.ts +0 -9
  298. package/lib/esm/types/libs/protocols/fullsail/index.d.ts.map +0 -1
  299. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts +0 -14
  300. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts.map +0 -1
  301. package/lib/esm/types/libs/protocols/index.d.ts +0 -53
  302. package/lib/esm/types/libs/protocols/index.d.ts.map +0 -1
  303. package/lib/esm/types/libs/protocols/kriya/index.d.ts +0 -9
  304. package/lib/esm/types/libs/protocols/kriya/index.d.ts.map +0 -1
  305. package/lib/esm/types/libs/protocols/kriyaV3/index.d.ts +0 -9
  306. package/lib/esm/types/libs/protocols/kriyaV3/index.d.ts.map +0 -1
  307. package/lib/esm/types/libs/protocols/magma/index.d.ts +0 -9
  308. package/lib/esm/types/libs/protocols/magma/index.d.ts.map +0 -1
  309. package/lib/esm/types/libs/protocols/momentum/index.d.ts +0 -9
  310. package/lib/esm/types/libs/protocols/momentum/index.d.ts.map +0 -1
  311. package/lib/esm/types/libs/protocols/obric/index.d.ts +0 -14
  312. package/lib/esm/types/libs/protocols/obric/index.d.ts.map +0 -1
  313. package/lib/esm/types/libs/protocols/sevenk/index.d.ts +0 -18
  314. package/lib/esm/types/libs/protocols/sevenk/index.d.ts.map +0 -1
  315. package/lib/esm/types/libs/protocols/springsui/index.d.ts +0 -9
  316. package/lib/esm/types/libs/protocols/springsui/index.d.ts.map +0 -1
  317. package/lib/esm/types/libs/protocols/steamm/index.d.ts +0 -28
  318. package/lib/esm/types/libs/protocols/steamm/index.d.ts.map +0 -1
  319. package/lib/esm/types/libs/protocols/stsui/index.d.ts +0 -9
  320. package/lib/esm/types/libs/protocols/stsui/index.d.ts.map +0 -1
  321. package/lib/esm/types/libs/protocols/suiswap/index.d.ts +0 -9
  322. package/lib/esm/types/libs/protocols/suiswap/index.d.ts.map +0 -1
  323. package/lib/esm/types/libs/protocols/turbos/index.d.ts +0 -9
  324. package/lib/esm/types/libs/protocols/turbos/index.d.ts.map +0 -1
  325. package/lib/esm/types/libs/protocols/utils.d.ts +0 -2
  326. package/lib/esm/types/libs/protocols/utils.d.ts.map +0 -1
  327. package/lib/esm/types/libs/swapWithRoute.d.ts +0 -12
  328. package/lib/esm/types/libs/swapWithRoute.d.ts.map +0 -1
  329. package/lib/esm/types/sui.js +0 -1
  330. package/lib/esm/types/tx.js +0 -1
  331. package/lib/esm/types/types/aggregator.d.ts +0 -173
  332. package/lib/esm/types/types/aggregator.d.ts.map +0 -1
  333. package/lib/esm/types/types/sui.d.ts +0 -4
  334. package/lib/esm/types/types/sui.d.ts.map +0 -1
  335. package/lib/esm/types/types/tx.d.ts +0 -67
  336. package/lib/esm/types/types/tx.d.ts.map +0 -1
  337. package/lib/esm/types/types/utilities.d.ts +0 -5
  338. package/lib/esm/types/types/utilities.d.ts.map +0 -1
  339. package/lib/esm/types/utilities.js +0 -1
  340. package/lib/esm/types/utils/number.d.ts +0 -2
  341. package/lib/esm/types/utils/number.d.ts.map +0 -1
  342. package/lib/esm/utils/number.js +0 -6
@@ -1,41 +0,0 @@
1
- import { SUI_DECIMALS } from "@mysten/sui/utils";
2
- import { Config } from "../../config";
3
- import { isBluefinXRouting } from "../../types/aggregator";
4
- import { formatBalance } from "../../utils/number";
5
- import { getSuiPrice } from "../prices";
6
- import { buildTx } from "./buildTx";
7
- import { BluefinXTx } from "../../libs/protocols/bluefinx/types";
8
- export async function estimateGasFee({ quoteResponse, accountAddress, slippage, suiPrice: _suiPrice, extendTx, commission, }) {
9
- if (!accountAddress)
10
- return 0;
11
- // BluefinX is sponsored, no need to estimate gas fee
12
- if (!accountAddress || isBluefinXRouting(quoteResponse))
13
- return 0;
14
- const result = await buildTx({
15
- extendTx,
16
- quoteResponse,
17
- accountAddress,
18
- slippage,
19
- commission,
20
- devInspect: true,
21
- }).catch((err) => {
22
- console.log("build tx error: ", err);
23
- return undefined;
24
- });
25
- const { tx } = result || {};
26
- if (!tx || tx instanceof BluefinXTx)
27
- return 0;
28
- const suiPrice = _suiPrice || (await getSuiPrice());
29
- const suiDecimals = SUI_DECIMALS;
30
- const { effects: { gasUsed, status }, } = await Config.getSuiClient().devInspectTransactionBlock({
31
- sender: accountAddress,
32
- transactionBlock: tx,
33
- });
34
- if (status.status !== "success")
35
- return 0;
36
- const fee = BigInt(gasUsed.computationCost) +
37
- BigInt(gasUsed.storageCost) -
38
- BigInt(gasUsed.storageRebate);
39
- const feeUsd = Number(suiPrice) * Number(formatBalance(fee, suiDecimals));
40
- return feeUsd;
41
- }
@@ -1,48 +0,0 @@
1
- import { Config } from "../../config";
2
- import { executeBluefinTx } from "../../libs/protocols/bluefinx/client";
3
- import { BluefinXTx } from "../../libs/protocols/bluefinx/types";
4
- /**
5
- * Execute a transaction after it is signed
6
- *
7
- * Automatically handle BluefinX transaction execution if needed
8
- * @example
9
- * ```ts
10
- * const { mutateAsync: signTransaction } = useSignTransaction();
11
- * const quoteResponse = await getQuote(...quoteParams);
12
- * const { tx } = await buildTx(...buildTxParams);
13
- * const {signature, bytes} = await signTransaction({
14
- * transaction: tx instanceof BluefinXTx ? tx.txBytes : tx,
15
- * });
16
- * const res = await executeTx(tx, signature, bytes);
17
- * ```
18
- * @param tx - AggregatorTx - received from `buildTx`
19
- * @param signature - User signature after signing the transaction
20
- * @param signedTxBytes - Signed transaction bytes after signing the transaction
21
- * @param options - Options for the transaction
22
- * @returns `SuiTransactionBlockResponse`
23
- */
24
- export const executeTx = async (tx, signature, signedTxBytes, options) => {
25
- const isBluefinTx = tx instanceof BluefinXTx;
26
- const client = Config.getSuiClient();
27
- let res;
28
- if (isBluefinTx) {
29
- try {
30
- const result = await executeBluefinTx(tx, signature);
31
- res = await client.waitForTransaction({
32
- digest: result.txDigest,
33
- options,
34
- });
35
- }
36
- catch (e) {
37
- throw Error(`Could not retrieve BluefinX transaction with quoteId: ${tx.quoteId} ${e}`);
38
- }
39
- }
40
- else {
41
- res = await client.executeTransactionBlock({
42
- transactionBlock: signedTxBytes,
43
- signature,
44
- options,
45
- });
46
- }
47
- return res;
48
- };
@@ -1,91 +0,0 @@
1
- import { normalizeStructTag, normalizeSuiObjectId } from "@mysten/sui/utils";
2
- import { Config } from "../../config";
3
- import { fetchClient } from "../../config/fetchClient";
4
- import { API_ENDPOINTS } from "../../constants/apiEndpoints";
5
- import { isBluefinXRouting, } from "../../types/aggregator";
6
- export const DEFAULT_SOURCES = [
7
- "suiswap",
8
- "turbos",
9
- "cetus",
10
- "bluemove",
11
- "kriya",
12
- "kriya_v3",
13
- "aftermath",
14
- "deepbook_v3",
15
- "flowx",
16
- "flowx_v3",
17
- "bluefin",
18
- "springsui",
19
- "obric",
20
- "stsui",
21
- "steamm",
22
- "steamm_oracle_quoter",
23
- "steamm_oracle_quoter_v2",
24
- "magma",
25
- "haedal_pmm",
26
- "momentum",
27
- "sevenk_v1",
28
- "fullsail",
29
- "cetus_dlmm",
30
- "ferra_dlmm",
31
- "ferra_clmm",
32
- ];
33
- export const ORACLE_BASED_SOURCES = new Set([
34
- "obric",
35
- "haedal_pmm",
36
- "sevenk_v1",
37
- "steamm_oracle_quoter",
38
- "steamm_oracle_quoter_v2",
39
- ]);
40
- export async function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources = DEFAULT_SOURCES, commissionBps, targetPools, excludedPools, taker, isSponsored, maxPaths, }) {
41
- let sources = _sources;
42
- if (isSponsored) {
43
- sources = _sources.filter((s) => !ORACLE_BASED_SOURCES.has(s));
44
- }
45
- const params = new URLSearchParams({
46
- amount: amountIn,
47
- from: normalizeStructTag(tokenIn),
48
- to: normalizeStructTag(tokenOut),
49
- sources: sources.join(","),
50
- });
51
- if (targetPools?.length) {
52
- params.append("target_pools", targetPools.map((v) => normalizeSuiObjectId(v)).join(","));
53
- }
54
- if (excludedPools?.length) {
55
- params.append("excluded_pools", excludedPools.map((v) => normalizeSuiObjectId(v)).join(","));
56
- }
57
- if (taker) {
58
- params.append("taker", taker);
59
- }
60
- if (maxPaths) {
61
- params.append("max_paths", maxPaths.toString());
62
- }
63
- const response = await fetchClient(`${Config.getApi() || API_ENDPOINTS.MAIN}/quote?${params}`);
64
- if (!response.ok) {
65
- let responseText;
66
- try {
67
- responseText = await response.text();
68
- }
69
- catch {
70
- responseText = "Failed to fetch aggregator quote";
71
- }
72
- throw new Error(responseText);
73
- }
74
- const quoteResponse = (await response.json());
75
- computeReturnAmountAfterCommission(quoteResponse, commissionBps);
76
- return quoteResponse;
77
- }
78
- const computeReturnAmountAfterCommission = (quoteResponse, commissionBps) => {
79
- const _commissionBps = isBluefinXRouting(quoteResponse) ? 0 : commissionBps;
80
- if (quoteResponse.returnAmount && +quoteResponse.returnAmount > 0) {
81
- quoteResponse.returnAmountAfterCommissionWithDecimal = ((BigInt(quoteResponse.returnAmountWithDecimal || 0) *
82
- BigInt(10_000 - (_commissionBps ?? 0))) /
83
- BigInt(10_000)).toString(10);
84
- const exp = Math.round(+quoteResponse.returnAmountWithDecimal / +quoteResponse.returnAmount);
85
- quoteResponse.returnAmountAfterCommission = (+quoteResponse.returnAmountAfterCommissionWithDecimal / exp).toString(10);
86
- }
87
- else {
88
- quoteResponse.returnAmountAfterCommission = "";
89
- quoteResponse.returnAmountAfterCommissionWithDecimal = "";
90
- }
91
- };
@@ -1,18 +0,0 @@
1
- import { fetchClient } from "../../config/fetchClient";
2
- import { API_ENDPOINTS } from "../../constants/apiEndpoints";
3
- import { formatQueryParams } from "../../libs/url";
4
- export async function getSwapHistory({ owner, offset = 0, limit = 10, tokenPair, }) {
5
- const queryParams = {
6
- addr: owner,
7
- offset,
8
- limit,
9
- token_pair: tokenPair,
10
- };
11
- const paramsStr = formatQueryParams(queryParams);
12
- const response = await fetchClient(`${API_ENDPOINTS.STATISTIC}/trading-history?${paramsStr}`);
13
- if (!response.ok) {
14
- throw new Error("Failed to fetch open limit orders");
15
- }
16
- const orders = (await response.json());
17
- return orders;
18
- }
@@ -1,6 +0,0 @@
1
- export * from "./buildTx";
2
- export * from "./buildTxV2";
3
- export * from "./estimateGasFee";
4
- export * from "./executeTx";
5
- export * from "./getQuote";
6
- export * from "./getSwapHistory";
@@ -1,57 +0,0 @@
1
- import { denormalizeTokenType } from "../utils/token";
2
- export function groupSwapRoutes(quoteResponse) {
3
- if (!quoteResponse.routes || !quoteResponse.swaps) {
4
- return [];
5
- }
6
- const poolDetails = mapPoolIdsToDetails(quoteResponse.routes);
7
- const items = getTxSorSwaps(quoteResponse.swaps, poolDetails);
8
- const groupedItems = [];
9
- let currentGroup = [];
10
- for (let i = 0; i < items.length; i++) {
11
- const item = items[i];
12
- currentGroup.push(item);
13
- const nextItem = items[i + 1];
14
- if (!nextItem || BigInt(nextItem.amount) > 0n) {
15
- groupedItems.push(currentGroup);
16
- currentGroup = [];
17
- }
18
- }
19
- if (currentGroup.length > 0) {
20
- groupedItems.push(currentGroup);
21
- }
22
- return groupedItems;
23
- }
24
- function mapPoolIdsToDetails(routes) {
25
- const poolTypes = {};
26
- routes.forEach((route) => {
27
- route.hops.forEach((hop) => {
28
- poolTypes[hop.poolId] = hop.pool;
29
- });
30
- });
31
- return poolTypes;
32
- }
33
- function getTxSorSwaps(swaps, poolDetails) {
34
- return swaps.map((swap) => {
35
- const pool = poolDetails[swap.poolId];
36
- const assetIn = denormalizeTokenType(swap.assetIn);
37
- const assetOut = denormalizeTokenType(swap.assetOut);
38
- const coinX = {
39
- type: denormalizeTokenType(pool?.allTokens?.[0]?.address),
40
- decimals: pool?.allTokens?.[0]?.decimal,
41
- };
42
- const coinY = {
43
- type: denormalizeTokenType(pool?.allTokens?.[1]?.address),
44
- decimals: pool?.allTokens?.[0]?.decimal,
45
- };
46
- const swapXtoY = assetIn === coinX.type;
47
- return {
48
- ...swap,
49
- pool,
50
- assetIn,
51
- assetOut,
52
- coinX,
53
- coinY,
54
- swapXtoY,
55
- };
56
- });
57
- }
@@ -1,31 +0,0 @@
1
- import { BaseContract } from "../base";
2
- import { normalizeTokenType } from "../../../utils/token";
3
- export class AfterMathContract extends BaseContract {
4
- async swap(tx) {
5
- const poolId = this.swapInfo.poolId;
6
- const returnAmount = this.swapInfo.returnAmount;
7
- const coinInType = normalizeTokenType(this.swapInfo.assetIn);
8
- const coinOutType = normalizeTokenType(this.swapInfo.assetOut);
9
- const inputCoinObject = this.inputCoinObject;
10
- const [lpCoinType] = this.getTypeParams();
11
- if (!lpCoinType)
12
- throw new Error("lpCoinType is not defined");
13
- const config = this.config.aftermath;
14
- const [tokenOut] = tx.moveCall({
15
- target: `${config.package}::swap::swap_exact_in`,
16
- typeArguments: [lpCoinType, coinInType, coinOutType],
17
- arguments: [
18
- tx.object(poolId),
19
- tx.object(config.poolRegistry),
20
- tx.object(config.protocolFeeVault),
21
- tx.object(config.treasury),
22
- tx.object(config.insuranceFund),
23
- tx.object(config.referralVault),
24
- inputCoinObject,
25
- tx.pure.u64(returnAmount),
26
- tx.pure.u64("1000000000000000000"), // slippage
27
- ],
28
- });
29
- return tokenOut;
30
- }
31
- }
@@ -1,42 +0,0 @@
1
- import { normalizeStructTag, parseStructTag, toHex } from "@mysten/sui/utils";
2
- import { SuiUtils } from "../../utils/sui";
3
- export class BaseContract {
4
- swapInfo;
5
- inputCoinObject;
6
- currentAccount;
7
- config;
8
- pythMap;
9
- constructor({ swapInfo, inputCoinObject, currentAccount, config, pythMap, }) {
10
- this.swapInfo = swapInfo;
11
- this.inputCoinObject = inputCoinObject;
12
- this.currentAccount = currentAccount;
13
- this.config = config;
14
- this.pythMap = pythMap;
15
- }
16
- getInputCoinValue(tx) {
17
- return SuiUtils.getCoinValue(this.swapInfo.assetIn, this.inputCoinObject, tx);
18
- }
19
- getTypeParams() {
20
- return parseStructTag(this.swapInfo.extra?.poolStructTag || "").typeParams.map(normalizeStructTag);
21
- }
22
- get extra() {
23
- const extra = this.swapInfo.extra;
24
- if (!extra) {
25
- throw new Error(`Invalid extra info for getExtra`);
26
- }
27
- return extra;
28
- }
29
- getPythPriceInfoId(oracle) {
30
- // FIXME: deprecation price_identifier in the next version
31
- const bytes = oracle?.Pyth?.bytes || oracle?.Pyth?.price_identifier?.bytes;
32
- if (!bytes) {
33
- throw new Error(`Invalid oracle info for getPythPriceInfoId`);
34
- }
35
- const feedId = "0x" + toHex(Uint8Array.from(bytes));
36
- const id = this.pythMap[feedId];
37
- if (!id) {
38
- throw new Error(`Missing price info for oracle ${feedId}`);
39
- }
40
- return id;
41
- }
42
- }
@@ -1,34 +0,0 @@
1
- import { BaseContract } from "../base";
2
- import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
3
- import { getDefaultSqrtPriceLimit } from "../utils";
4
- import { SuiUtils } from "../../../utils/sui";
5
- export class BluefinContract extends BaseContract {
6
- async swap(tx) {
7
- const [coinX, coinY] = this.swapInfo.pool.allTokens;
8
- const swapXtoY = this.swapInfo.swapXtoY;
9
- const amountIn = this.getInputCoinValue(tx);
10
- const coinInBalance = SuiUtils.coinIntoBalance(tx, this.swapInfo.assetIn, this.inputCoinObject);
11
- const coinOutBalance = SuiUtils.zeroBalance(tx, this.swapInfo.assetOut);
12
- const config = this.config.bluefin;
13
- const [balanceOutX, balanceOutY] = tx.moveCall({
14
- target: `${config.package}::pool::swap`,
15
- typeArguments: [coinX.address, coinY.address],
16
- arguments: [
17
- tx.object(SUI_CLOCK_OBJECT_ID),
18
- tx.object(config.globalConfig),
19
- tx.object(this.swapInfo.poolId),
20
- swapXtoY ? coinInBalance : coinOutBalance,
21
- swapXtoY ? coinOutBalance : coinInBalance,
22
- tx.pure.bool(swapXtoY),
23
- tx.pure.bool(true),
24
- amountIn,
25
- tx.pure.u64(0),
26
- tx.pure.u128(getDefaultSqrtPriceLimit(swapXtoY) + (swapXtoY ? 1n : -1n)),
27
- ],
28
- });
29
- const coinOutX = SuiUtils.coinFromBalance(tx, coinX.address, balanceOutX);
30
- const coinOutY = SuiUtils.coinFromBalance(tx, coinY.address, balanceOutY);
31
- SuiUtils.collectDust(tx, this.swapInfo.assetIn, swapXtoY ? coinOutX : coinOutY);
32
- return swapXtoY ? coinOutY : coinOutX;
33
- }
34
- }
@@ -1,36 +0,0 @@
1
- import { Config } from "../../../config";
2
- import { API_ENDPOINTS } from "../../../constants/apiEndpoints";
3
- const request = async (path, body) => {
4
- const headers = new Headers({
5
- "Content-Type": "application/json",
6
- });
7
- const bluefinXApiKey = (Config.getBluefinXApiKey() || "").trim();
8
- if (bluefinXApiKey) {
9
- headers.set("Bluefin-X-API-Key", bluefinXApiKey);
10
- }
11
- const res = await fetch(`${Config.getApi() || API_ENDPOINTS.MAIN}/${path}`, {
12
- method: "POST",
13
- body: JSON.stringify(body),
14
- headers,
15
- });
16
- return res.json();
17
- };
18
- export const sponsorBluefinX = async (body) => {
19
- return await request("bluefinx/sponsor", body);
20
- };
21
- /**
22
- * Request BluefinX for signing sponsored tx and execute it
23
- *
24
- * @Warning
25
- * User must use this function to execute BluefinX tx, otherwise the tx will be rejected by BluefinX contract
26
- * @param tx - BluefinX tx which is generated by `buildTx`
27
- * @param signature - user signature after signing the transaction
28
- * @returns `SwapResponse`
29
- */
30
- export const executeBluefinTx = async (tx, signature) => {
31
- return await request("bluefinx/swap", {
32
- quoteId: tx.quoteId,
33
- txBytes: tx.txBytes,
34
- signature,
35
- });
36
- };
@@ -1,44 +0,0 @@
1
- import { bcs } from "@mysten/sui/bcs";
2
- import { fromBase64, normalizeStructTag, SUI_CLOCK_OBJECT_ID, } from "@mysten/sui/utils";
3
- import { SuiUtils } from "../../../utils/sui";
4
- import { BaseContract } from "../base";
5
- const BcsQuote = bcs.struct("Quote", {
6
- vault: bcs.Address,
7
- id: bcs.string(),
8
- taker: bcs.Address,
9
- token_in_amount: bcs.u64(),
10
- token_out_amount: bcs.u64(),
11
- token_in_type: bcs.string(),
12
- token_out_type: bcs.string(),
13
- expires_at: bcs.u64(),
14
- created_at: bcs.u64(),
15
- });
16
- export class BluefinXContract extends BaseContract {
17
- async swap(tx) {
18
- const extra = this.extra;
19
- const quoteBytes = BcsQuote.serialize({
20
- vault: extra.vault,
21
- id: extra.quoteId,
22
- taker: extra.taker,
23
- token_in_amount: this.swapInfo.amount,
24
- token_out_amount: this.swapInfo.returnAmount,
25
- token_in_type: normalizeStructTag(this.swapInfo.assetIn).slice(2),
26
- token_out_type: normalizeStructTag(this.swapInfo.assetOut).slice(2),
27
- expires_at: extra.quoteExpiresAtUtcMillis,
28
- created_at: extra.createdAtUtcMillis,
29
- }).toBytes();
30
- const [out] = tx.moveCall({
31
- arguments: [
32
- tx.object(SUI_CLOCK_OBJECT_ID),
33
- tx.object(extra.vault),
34
- tx.object(this.config.bluefinx.globalConfig),
35
- tx.pure.vector("u8", Array.from(quoteBytes)),
36
- tx.pure.vector("u8", Array.from(fromBase64(extra.signature))),
37
- SuiUtils.coinIntoBalance(tx, this.swapInfo.assetIn, this.inputCoinObject),
38
- ],
39
- target: `${this.config.bluefinx.package}::vault::swap`,
40
- typeArguments: [this.swapInfo.assetIn, this.swapInfo.assetOut],
41
- });
42
- return SuiUtils.coinFromBalance(tx, this.swapInfo.assetOut, out);
43
- }
44
- }
@@ -1,8 +0,0 @@
1
- export class BluefinXTx {
2
- quoteId;
3
- txBytes;
4
- constructor(quoteId, txBytes) {
5
- this.quoteId = quoteId;
6
- this.txBytes = txBytes;
7
- }
8
- }
@@ -1,20 +0,0 @@
1
- import { BaseContract } from "../base";
2
- import { SuiUtils } from "../../../utils/sui";
3
- export class BluemoveContract extends BaseContract {
4
- async swap(tx) {
5
- const config = this.config.bluemove;
6
- const [coinOut] = tx.moveCall({
7
- target: `${config.package}::router::swap_exact_input_`,
8
- typeArguments: [this.swapInfo.assetIn, this.swapInfo.assetOut],
9
- arguments: [
10
- SuiUtils.getCoinValue(this.swapInfo.swapXtoY
11
- ? this.swapInfo.coinX.type
12
- : this.swapInfo.coinY.type, this.inputCoinObject, tx), // input amount
13
- this.inputCoinObject, // input coin
14
- tx.pure.u64(0), // min output amount
15
- tx.object(config.dexInfo),
16
- ],
17
- });
18
- return coinOut;
19
- }
20
- }
@@ -1,40 +0,0 @@
1
- import { BaseContract } from "../base";
2
- import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
3
- import { getDefaultSqrtPriceLimit } from "../utils";
4
- import { SuiUtils } from "../../../utils/sui";
5
- export class CetusContract extends BaseContract {
6
- async swap(tx) {
7
- const sqrtPriceLimit = getDefaultSqrtPriceLimit(this.swapInfo.swapXtoY);
8
- const typeArguments = [this.swapInfo.coinX.type, this.swapInfo.coinY.type];
9
- const [zeroOut] = tx.moveCall({
10
- target: "0x2::coin::zero",
11
- typeArguments: [
12
- this.swapInfo.swapXtoY
13
- ? this.swapInfo.coinY.type
14
- : this.swapInfo.coinX.type,
15
- ],
16
- });
17
- const amountIn = SuiUtils.getCoinValue(this.swapInfo.swapXtoY
18
- ? this.swapInfo.coinX.type
19
- : this.swapInfo.coinY.type, this.inputCoinObject, tx);
20
- const config = this.config.cetus;
21
- const [receiveA, receiveB] = tx.moveCall({
22
- target: `${config.package}::router::swap`,
23
- typeArguments,
24
- arguments: [
25
- tx.object(config.globalConfig),
26
- tx.object(this.swapInfo.poolId),
27
- this.swapInfo.swapXtoY ? this.inputCoinObject : zeroOut, // coin A
28
- this.swapInfo.swapXtoY ? zeroOut : this.inputCoinObject, // coin B
29
- tx.pure.bool(this.swapInfo.swapXtoY), // a to b or b to a
30
- tx.pure.bool(true), // exact in or out
31
- amountIn, // swap amount
32
- tx.pure.u128(sqrtPriceLimit.toString()), // sqrt price limit
33
- tx.pure.bool(false),
34
- tx.object(SUI_CLOCK_OBJECT_ID),
35
- ],
36
- });
37
- SuiUtils.collectDust(tx, this.swapInfo.assetIn, this.swapInfo.swapXtoY ? receiveA : receiveB);
38
- return this.swapInfo.swapXtoY ? receiveB : receiveA;
39
- }
40
- }
@@ -1,44 +0,0 @@
1
- import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
2
- import { SuiUtils } from "../../utils/sui";
3
- import { BaseContract } from "./base";
4
- export class CetusDLMMContract extends BaseContract {
5
- async swap(tx) {
6
- const config = this.config.cetus_dlmm;
7
- const [x, y, receipt] = tx.moveCall({
8
- target: `${config.package}::pool::flash_swap`,
9
- typeArguments: [this.swapInfo.coinX.type, this.swapInfo.coinY.type],
10
- arguments: [
11
- tx.object(this.swapInfo.poolId),
12
- tx.pure.bool(this.swapInfo.swapXtoY),
13
- tx.pure.bool(true), // exact in
14
- this.getInputCoinValue(tx),
15
- tx.object(config.globalConfig),
16
- tx.object(config.version),
17
- tx.object(SUI_CLOCK_OBJECT_ID),
18
- ],
19
- });
20
- const debtX = this.swapInfo.swapXtoY
21
- ? SuiUtils.coinIntoBalance(tx, this.swapInfo.coinX.type, this.inputCoinObject)
22
- : SuiUtils.zeroBalance(tx, this.swapInfo.coinX.type);
23
- const debtY = this.swapInfo.swapXtoY
24
- ? SuiUtils.zeroBalance(tx, this.swapInfo.coinY.type)
25
- : SuiUtils.coinIntoBalance(tx, this.swapInfo.coinY.type, this.inputCoinObject);
26
- tx.moveCall({
27
- target: `${config.package}::pool::repay_flash_swap`,
28
- typeArguments: [this.swapInfo.coinX.type, this.swapInfo.coinY.type],
29
- arguments: [
30
- tx.object(this.swapInfo.poolId),
31
- debtX,
32
- debtY,
33
- receipt,
34
- tx.object(config.version),
35
- ],
36
- });
37
- const [destroyType, destroyCoin, outType, outBalance] = this.swapInfo
38
- .swapXtoY
39
- ? [this.swapInfo.coinX.type, x, this.swapInfo.coinY.type, y]
40
- : [this.swapInfo.coinY.type, y, this.swapInfo.coinX.type, x];
41
- SuiUtils.balanceDestroyZero(tx, destroyType, destroyCoin);
42
- return SuiUtils.coinFromBalance(tx, outType, outBalance);
43
- }
44
- }
@@ -1,2 +0,0 @@
1
- export const MIN_SQRT_PRICE = "4295048016";
2
- export const MAX_SQRT_PRICE = "79226673515401279992447579055";
@@ -1,26 +0,0 @@
1
- import { BaseContract } from "../base";
2
- import { normalizeStructTag, SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
3
- import { SuiUtils } from "../../../utils/sui";
4
- export class SponsoredDeepBookV3Contract extends BaseContract {
5
- async swap(tx) {
6
- const [coinX] = this.swapInfo.pool.allTokens;
7
- const swapXtoY = normalizeStructTag(coinX.address) ===
8
- normalizeStructTag(this.swapInfo.assetIn);
9
- const config = this.config.deepbook_v3;
10
- const [base, quote] = tx.moveCall({
11
- target: `${config.sponsor}::sponsored::${swapXtoY ? "swap_exact_base_for_quote" : "swap_exact_quote_for_base"}`,
12
- typeArguments: this.getTypeParams(),
13
- arguments: [
14
- tx.object(config.sponsorFund),
15
- tx.object(this.swapInfo.poolId),
16
- this.inputCoinObject,
17
- tx.pure.u64(0),
18
- tx.object(SUI_CLOCK_OBJECT_ID),
19
- ],
20
- });
21
- const coinIn = swapXtoY ? base : quote;
22
- const coinOut = swapXtoY ? quote : base;
23
- SuiUtils.collectDust(tx, this.swapInfo.assetIn, coinIn);
24
- return coinOut;
25
- }
26
- }
@@ -1,40 +0,0 @@
1
- import { SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
2
- import { SuiUtils } from "../../utils/sui";
3
- import { BaseContract } from "./base";
4
- import { getDefaultSqrtPriceLimit } from "./utils";
5
- export class FerraCLMMContract extends BaseContract {
6
- async swap(tx) {
7
- const sqrtPriceLimit = getDefaultSqrtPriceLimit(this.swapInfo.swapXtoY);
8
- const typeArguments = [this.swapInfo.coinX.type, this.swapInfo.coinY.type];
9
- const [zeroOut] = tx.moveCall({
10
- target: "0x2::coin::zero",
11
- typeArguments: [
12
- this.swapInfo.swapXtoY
13
- ? this.swapInfo.coinY.type
14
- : this.swapInfo.coinX.type,
15
- ],
16
- });
17
- const amountIn = SuiUtils.getCoinValue(this.swapInfo.swapXtoY
18
- ? this.swapInfo.coinX.type
19
- : this.swapInfo.coinY.type, this.inputCoinObject, tx);
20
- const config = this.config.ferra_clmm;
21
- const [receiveA, receiveB] = tx.moveCall({
22
- target: `${config.integrate}::router::swap`,
23
- typeArguments,
24
- arguments: [
25
- tx.object(config.globalConfig),
26
- tx.object(this.swapInfo.poolId),
27
- this.swapInfo.swapXtoY ? this.inputCoinObject : zeroOut, // coin A
28
- this.swapInfo.swapXtoY ? zeroOut : this.inputCoinObject, // coin B
29
- tx.pure.bool(this.swapInfo.swapXtoY), // a to b or b to a
30
- tx.pure.bool(true), // exact in or out
31
- amountIn, // swap amount
32
- tx.pure.u128(sqrtPriceLimit.toString()), // sqrt price limit
33
- tx.pure.bool(false),
34
- tx.object(SUI_CLOCK_OBJECT_ID),
35
- ],
36
- });
37
- SuiUtils.collectDust(tx, this.swapInfo.assetIn, this.swapInfo.swapXtoY ? receiveA : receiveB);
38
- return this.swapInfo.swapXtoY ? receiveB : receiveA;
39
- }
40
- }