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

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 +15 -154
  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 +17 -156
  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,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.estimateGasFee = estimateGasFee;
4
- const utils_1 = require("@mysten/sui/utils");
5
- const config_1 = require("../../config");
6
- const aggregator_1 = require("../../types/aggregator");
7
- const number_1 = require("../../utils/number");
8
- const prices_1 = require("../prices");
9
- const buildTx_1 = require("./buildTx");
10
- const types_1 = require("../../libs/protocols/bluefinx/types");
11
- async function estimateGasFee({ quoteResponse, accountAddress, slippage, suiPrice: _suiPrice, extendTx, commission, }) {
12
- if (!accountAddress)
13
- return 0;
14
- // BluefinX is sponsored, no need to estimate gas fee
15
- if (!accountAddress || (0, aggregator_1.isBluefinXRouting)(quoteResponse))
16
- return 0;
17
- const result = await (0, buildTx_1.buildTx)({
18
- extendTx,
19
- quoteResponse,
20
- accountAddress,
21
- slippage,
22
- commission,
23
- devInspect: true,
24
- }).catch((err) => {
25
- console.log("build tx error: ", err);
26
- return undefined;
27
- });
28
- const { tx } = result || {};
29
- if (!tx || tx instanceof types_1.BluefinXTx)
30
- return 0;
31
- const suiPrice = _suiPrice || (await (0, prices_1.getSuiPrice)());
32
- const suiDecimals = utils_1.SUI_DECIMALS;
33
- const { effects: { gasUsed, status }, } = await config_1.Config.getSuiClient().devInspectTransactionBlock({
34
- sender: accountAddress,
35
- transactionBlock: tx,
36
- });
37
- if (status.status !== "success")
38
- return 0;
39
- const fee = BigInt(gasUsed.computationCost) +
40
- BigInt(gasUsed.storageCost) -
41
- BigInt(gasUsed.storageRebate);
42
- const feeUsd = Number(suiPrice) * Number((0, number_1.formatBalance)(fee, suiDecimals));
43
- return feeUsd;
44
- }
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeTx = void 0;
4
- const config_1 = require("../../config");
5
- const client_1 = require("../../libs/protocols/bluefinx/client");
6
- const types_1 = require("../../libs/protocols/bluefinx/types");
7
- /**
8
- * Execute a transaction after it is signed
9
- *
10
- * Automatically handle BluefinX transaction execution if needed
11
- * @example
12
- * ```ts
13
- * const { mutateAsync: signTransaction } = useSignTransaction();
14
- * const quoteResponse = await getQuote(...quoteParams);
15
- * const { tx } = await buildTx(...buildTxParams);
16
- * const {signature, bytes} = await signTransaction({
17
- * transaction: tx instanceof BluefinXTx ? tx.txBytes : tx,
18
- * });
19
- * const res = await executeTx(tx, signature, bytes);
20
- * ```
21
- * @param tx - AggregatorTx - received from `buildTx`
22
- * @param signature - User signature after signing the transaction
23
- * @param signedTxBytes - Signed transaction bytes after signing the transaction
24
- * @param options - Options for the transaction
25
- * @returns `SuiTransactionBlockResponse`
26
- */
27
- const executeTx = async (tx, signature, signedTxBytes, options) => {
28
- const isBluefinTx = tx instanceof types_1.BluefinXTx;
29
- const client = config_1.Config.getSuiClient();
30
- let res;
31
- if (isBluefinTx) {
32
- try {
33
- const result = await (0, client_1.executeBluefinTx)(tx, signature);
34
- res = await client.waitForTransaction({
35
- digest: result.txDigest,
36
- options,
37
- });
38
- }
39
- catch (e) {
40
- throw Error(`Could not retrieve BluefinX transaction with quoteId: ${tx.quoteId} ${e}`);
41
- }
42
- }
43
- else {
44
- res = await client.executeTransactionBlock({
45
- transactionBlock: signedTxBytes,
46
- signature,
47
- options,
48
- });
49
- }
50
- return res;
51
- };
52
- exports.executeTx = executeTx;
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ORACLE_BASED_SOURCES = exports.DEFAULT_SOURCES = void 0;
4
- exports.getQuote = getQuote;
5
- const utils_1 = require("@mysten/sui/utils");
6
- const config_1 = require("../../config");
7
- const fetchClient_1 = require("../../config/fetchClient");
8
- const apiEndpoints_1 = require("../../constants/apiEndpoints");
9
- const aggregator_1 = require("../../types/aggregator");
10
- exports.DEFAULT_SOURCES = [
11
- "suiswap",
12
- "turbos",
13
- "cetus",
14
- "bluemove",
15
- "kriya",
16
- "kriya_v3",
17
- "aftermath",
18
- "deepbook_v3",
19
- "flowx",
20
- "flowx_v3",
21
- "bluefin",
22
- "springsui",
23
- "obric",
24
- "stsui",
25
- "steamm",
26
- "steamm_oracle_quoter",
27
- "steamm_oracle_quoter_v2",
28
- "magma",
29
- "haedal_pmm",
30
- "momentum",
31
- "sevenk_v1",
32
- "fullsail",
33
- "cetus_dlmm",
34
- "ferra_dlmm",
35
- "ferra_clmm",
36
- ];
37
- exports.ORACLE_BASED_SOURCES = new Set([
38
- "obric",
39
- "haedal_pmm",
40
- "sevenk_v1",
41
- "steamm_oracle_quoter",
42
- "steamm_oracle_quoter_v2",
43
- ]);
44
- async function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources = exports.DEFAULT_SOURCES, commissionBps, targetPools, excludedPools, taker, isSponsored, maxPaths, }) {
45
- let sources = _sources;
46
- if (isSponsored) {
47
- sources = _sources.filter((s) => !exports.ORACLE_BASED_SOURCES.has(s));
48
- }
49
- const params = new URLSearchParams({
50
- amount: amountIn,
51
- from: (0, utils_1.normalizeStructTag)(tokenIn),
52
- to: (0, utils_1.normalizeStructTag)(tokenOut),
53
- sources: sources.join(","),
54
- });
55
- if (targetPools?.length) {
56
- params.append("target_pools", targetPools.map((v) => (0, utils_1.normalizeSuiObjectId)(v)).join(","));
57
- }
58
- if (excludedPools?.length) {
59
- params.append("excluded_pools", excludedPools.map((v) => (0, utils_1.normalizeSuiObjectId)(v)).join(","));
60
- }
61
- if (taker) {
62
- params.append("taker", taker);
63
- }
64
- if (maxPaths) {
65
- params.append("max_paths", maxPaths.toString());
66
- }
67
- const response = await (0, fetchClient_1.fetchClient)(`${config_1.Config.getApi() || apiEndpoints_1.API_ENDPOINTS.MAIN}/quote?${params}`);
68
- if (!response.ok) {
69
- let responseText;
70
- try {
71
- responseText = await response.text();
72
- }
73
- catch {
74
- responseText = "Failed to fetch aggregator quote";
75
- }
76
- throw new Error(responseText);
77
- }
78
- const quoteResponse = (await response.json());
79
- computeReturnAmountAfterCommission(quoteResponse, commissionBps);
80
- return quoteResponse;
81
- }
82
- const computeReturnAmountAfterCommission = (quoteResponse, commissionBps) => {
83
- const _commissionBps = (0, aggregator_1.isBluefinXRouting)(quoteResponse) ? 0 : commissionBps;
84
- if (quoteResponse.returnAmount && +quoteResponse.returnAmount > 0) {
85
- quoteResponse.returnAmountAfterCommissionWithDecimal = ((BigInt(quoteResponse.returnAmountWithDecimal || 0) *
86
- BigInt(10000 - (_commissionBps ?? 0))) /
87
- BigInt(10000)).toString(10);
88
- const exp = Math.round(+quoteResponse.returnAmountWithDecimal / +quoteResponse.returnAmount);
89
- quoteResponse.returnAmountAfterCommission = (+quoteResponse.returnAmountAfterCommissionWithDecimal / exp).toString(10);
90
- }
91
- else {
92
- quoteResponse.returnAmountAfterCommission = "";
93
- quoteResponse.returnAmountAfterCommissionWithDecimal = "";
94
- }
95
- };
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSwapHistory = getSwapHistory;
4
- const fetchClient_1 = require("../../config/fetchClient");
5
- const apiEndpoints_1 = require("../../constants/apiEndpoints");
6
- const url_1 = require("../../libs/url");
7
- async function getSwapHistory({ owner, offset = 0, limit = 10, tokenPair, }) {
8
- const queryParams = {
9
- addr: owner,
10
- offset,
11
- limit,
12
- token_pair: tokenPair,
13
- };
14
- const paramsStr = (0, url_1.formatQueryParams)(queryParams);
15
- const response = await (0, fetchClient_1.fetchClient)(`${apiEndpoints_1.API_ENDPOINTS.STATISTIC}/trading-history?${paramsStr}`);
16
- if (!response.ok) {
17
- throw new Error("Failed to fetch open limit orders");
18
- }
19
- const orders = (await response.json());
20
- return orders;
21
- }
@@ -1,22 +0,0 @@
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("./buildTx"), exports);
18
- __exportStar(require("./buildTxV2"), exports);
19
- __exportStar(require("./estimateGasFee"), exports);
20
- __exportStar(require("./executeTx"), exports);
21
- __exportStar(require("./getQuote"), exports);
22
- __exportStar(require("./getSwapHistory"), exports);
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.groupSwapRoutes = groupSwapRoutes;
4
- const token_1 = require("../utils/token");
5
- function groupSwapRoutes(quoteResponse) {
6
- if (!quoteResponse.routes || !quoteResponse.swaps) {
7
- return [];
8
- }
9
- const poolDetails = mapPoolIdsToDetails(quoteResponse.routes);
10
- const items = getTxSorSwaps(quoteResponse.swaps, poolDetails);
11
- const groupedItems = [];
12
- let currentGroup = [];
13
- for (let i = 0; i < items.length; i++) {
14
- const item = items[i];
15
- currentGroup.push(item);
16
- const nextItem = items[i + 1];
17
- if (!nextItem || BigInt(nextItem.amount) > 0n) {
18
- groupedItems.push(currentGroup);
19
- currentGroup = [];
20
- }
21
- }
22
- if (currentGroup.length > 0) {
23
- groupedItems.push(currentGroup);
24
- }
25
- return groupedItems;
26
- }
27
- function mapPoolIdsToDetails(routes) {
28
- const poolTypes = {};
29
- routes.forEach((route) => {
30
- route.hops.forEach((hop) => {
31
- poolTypes[hop.poolId] = hop.pool;
32
- });
33
- });
34
- return poolTypes;
35
- }
36
- function getTxSorSwaps(swaps, poolDetails) {
37
- return swaps.map((swap) => {
38
- const pool = poolDetails[swap.poolId];
39
- const assetIn = (0, token_1.denormalizeTokenType)(swap.assetIn);
40
- const assetOut = (0, token_1.denormalizeTokenType)(swap.assetOut);
41
- const coinX = {
42
- type: (0, token_1.denormalizeTokenType)(pool?.allTokens?.[0]?.address),
43
- decimals: pool?.allTokens?.[0]?.decimal,
44
- };
45
- const coinY = {
46
- type: (0, token_1.denormalizeTokenType)(pool?.allTokens?.[1]?.address),
47
- decimals: pool?.allTokens?.[0]?.decimal,
48
- };
49
- const swapXtoY = assetIn === coinX.type;
50
- return {
51
- ...swap,
52
- pool,
53
- assetIn,
54
- assetOut,
55
- coinX,
56
- coinY,
57
- swapXtoY,
58
- };
59
- });
60
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AfterMathContract = void 0;
4
- const base_1 = require("../base");
5
- const token_1 = require("../../../utils/token");
6
- class AfterMathContract extends base_1.BaseContract {
7
- async swap(tx) {
8
- const poolId = this.swapInfo.poolId;
9
- const returnAmount = this.swapInfo.returnAmount;
10
- const coinInType = (0, token_1.normalizeTokenType)(this.swapInfo.assetIn);
11
- const coinOutType = (0, token_1.normalizeTokenType)(this.swapInfo.assetOut);
12
- const inputCoinObject = this.inputCoinObject;
13
- const [lpCoinType] = this.getTypeParams();
14
- if (!lpCoinType)
15
- throw new Error("lpCoinType is not defined");
16
- const config = this.config.aftermath;
17
- const [tokenOut] = tx.moveCall({
18
- target: `${config.package}::swap::swap_exact_in`,
19
- typeArguments: [lpCoinType, coinInType, coinOutType],
20
- arguments: [
21
- tx.object(poolId),
22
- tx.object(config.poolRegistry),
23
- tx.object(config.protocolFeeVault),
24
- tx.object(config.treasury),
25
- tx.object(config.insuranceFund),
26
- tx.object(config.referralVault),
27
- inputCoinObject,
28
- tx.pure.u64(returnAmount),
29
- tx.pure.u64("1000000000000000000"), // slippage
30
- ],
31
- });
32
- return tokenOut;
33
- }
34
- }
35
- exports.AfterMathContract = AfterMathContract;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseContract = void 0;
4
- const utils_1 = require("@mysten/sui/utils");
5
- const sui_1 = require("../../utils/sui");
6
- class BaseContract {
7
- constructor({ swapInfo, inputCoinObject, currentAccount, config, pythMap, }) {
8
- this.swapInfo = swapInfo;
9
- this.inputCoinObject = inputCoinObject;
10
- this.currentAccount = currentAccount;
11
- this.config = config;
12
- this.pythMap = pythMap;
13
- }
14
- getInputCoinValue(tx) {
15
- return sui_1.SuiUtils.getCoinValue(this.swapInfo.assetIn, this.inputCoinObject, tx);
16
- }
17
- getTypeParams() {
18
- return (0, utils_1.parseStructTag)(this.swapInfo.extra?.poolStructTag || "").typeParams.map(utils_1.normalizeStructTag);
19
- }
20
- get extra() {
21
- const extra = this.swapInfo.extra;
22
- if (!extra) {
23
- throw new Error(`Invalid extra info for getExtra`);
24
- }
25
- return extra;
26
- }
27
- getPythPriceInfoId(oracle) {
28
- // FIXME: deprecation price_identifier in the next version
29
- const bytes = oracle?.Pyth?.bytes || oracle?.Pyth?.price_identifier?.bytes;
30
- if (!bytes) {
31
- throw new Error(`Invalid oracle info for getPythPriceInfoId`);
32
- }
33
- const feedId = "0x" + (0, utils_1.toHex)(Uint8Array.from(bytes));
34
- const id = this.pythMap[feedId];
35
- if (!id) {
36
- throw new Error(`Missing price info for oracle ${feedId}`);
37
- }
38
- return id;
39
- }
40
- }
41
- exports.BaseContract = BaseContract;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BluefinContract = void 0;
4
- const base_1 = require("../base");
5
- const utils_1 = require("@mysten/sui/utils");
6
- const utils_2 = require("../utils");
7
- const sui_1 = require("../../../utils/sui");
8
- class BluefinContract extends base_1.BaseContract {
9
- async swap(tx) {
10
- const [coinX, coinY] = this.swapInfo.pool.allTokens;
11
- const swapXtoY = this.swapInfo.swapXtoY;
12
- const amountIn = this.getInputCoinValue(tx);
13
- const coinInBalance = sui_1.SuiUtils.coinIntoBalance(tx, this.swapInfo.assetIn, this.inputCoinObject);
14
- const coinOutBalance = sui_1.SuiUtils.zeroBalance(tx, this.swapInfo.assetOut);
15
- const config = this.config.bluefin;
16
- const [balanceOutX, balanceOutY] = tx.moveCall({
17
- target: `${config.package}::pool::swap`,
18
- typeArguments: [coinX.address, coinY.address],
19
- arguments: [
20
- tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
21
- tx.object(config.globalConfig),
22
- tx.object(this.swapInfo.poolId),
23
- swapXtoY ? coinInBalance : coinOutBalance,
24
- swapXtoY ? coinOutBalance : coinInBalance,
25
- tx.pure.bool(swapXtoY),
26
- tx.pure.bool(true),
27
- amountIn,
28
- tx.pure.u64(0),
29
- tx.pure.u128((0, utils_2.getDefaultSqrtPriceLimit)(swapXtoY) + (swapXtoY ? 1n : -1n)),
30
- ],
31
- });
32
- const coinOutX = sui_1.SuiUtils.coinFromBalance(tx, coinX.address, balanceOutX);
33
- const coinOutY = sui_1.SuiUtils.coinFromBalance(tx, coinY.address, balanceOutY);
34
- sui_1.SuiUtils.collectDust(tx, this.swapInfo.assetIn, swapXtoY ? coinOutX : coinOutY);
35
- return swapXtoY ? coinOutY : coinOutX;
36
- }
37
- }
38
- exports.BluefinContract = BluefinContract;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeBluefinTx = exports.sponsorBluefinX = void 0;
4
- const config_1 = require("../../../config");
5
- const apiEndpoints_1 = require("../../../constants/apiEndpoints");
6
- const request = async (path, body) => {
7
- const headers = new Headers({
8
- "Content-Type": "application/json",
9
- });
10
- const bluefinXApiKey = (config_1.Config.getBluefinXApiKey() || "").trim();
11
- if (bluefinXApiKey) {
12
- headers.set("Bluefin-X-API-Key", bluefinXApiKey);
13
- }
14
- const res = await fetch(`${config_1.Config.getApi() || apiEndpoints_1.API_ENDPOINTS.MAIN}/${path}`, {
15
- method: "POST",
16
- body: JSON.stringify(body),
17
- headers,
18
- });
19
- return res.json();
20
- };
21
- const sponsorBluefinX = async (body) => {
22
- return await request("bluefinx/sponsor", body);
23
- };
24
- exports.sponsorBluefinX = sponsorBluefinX;
25
- /**
26
- * Request BluefinX for signing sponsored tx and execute it
27
- *
28
- * @Warning
29
- * User must use this function to execute BluefinX tx, otherwise the tx will be rejected by BluefinX contract
30
- * @param tx - BluefinX tx which is generated by `buildTx`
31
- * @param signature - user signature after signing the transaction
32
- * @returns `SwapResponse`
33
- */
34
- const executeBluefinTx = async (tx, signature) => {
35
- return await request("bluefinx/swap", {
36
- quoteId: tx.quoteId,
37
- txBytes: tx.txBytes,
38
- signature,
39
- });
40
- };
41
- exports.executeBluefinTx = executeBluefinTx;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BluefinXContract = void 0;
4
- const bcs_1 = require("@mysten/sui/bcs");
5
- const utils_1 = require("@mysten/sui/utils");
6
- const sui_1 = require("../../../utils/sui");
7
- const base_1 = require("../base");
8
- const BcsQuote = bcs_1.bcs.struct("Quote", {
9
- vault: bcs_1.bcs.Address,
10
- id: bcs_1.bcs.string(),
11
- taker: bcs_1.bcs.Address,
12
- token_in_amount: bcs_1.bcs.u64(),
13
- token_out_amount: bcs_1.bcs.u64(),
14
- token_in_type: bcs_1.bcs.string(),
15
- token_out_type: bcs_1.bcs.string(),
16
- expires_at: bcs_1.bcs.u64(),
17
- created_at: bcs_1.bcs.u64(),
18
- });
19
- class BluefinXContract extends base_1.BaseContract {
20
- async swap(tx) {
21
- const extra = this.extra;
22
- const quoteBytes = BcsQuote.serialize({
23
- vault: extra.vault,
24
- id: extra.quoteId,
25
- taker: extra.taker,
26
- token_in_amount: this.swapInfo.amount,
27
- token_out_amount: this.swapInfo.returnAmount,
28
- token_in_type: (0, utils_1.normalizeStructTag)(this.swapInfo.assetIn).slice(2),
29
- token_out_type: (0, utils_1.normalizeStructTag)(this.swapInfo.assetOut).slice(2),
30
- expires_at: extra.quoteExpiresAtUtcMillis,
31
- created_at: extra.createdAtUtcMillis,
32
- }).toBytes();
33
- const [out] = tx.moveCall({
34
- arguments: [
35
- tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
36
- tx.object(extra.vault),
37
- tx.object(this.config.bluefinx.globalConfig),
38
- tx.pure.vector("u8", Array.from(quoteBytes)),
39
- tx.pure.vector("u8", Array.from((0, utils_1.fromBase64)(extra.signature))),
40
- sui_1.SuiUtils.coinIntoBalance(tx, this.swapInfo.assetIn, this.inputCoinObject),
41
- ],
42
- target: `${this.config.bluefinx.package}::vault::swap`,
43
- typeArguments: [this.swapInfo.assetIn, this.swapInfo.assetOut],
44
- });
45
- return sui_1.SuiUtils.coinFromBalance(tx, this.swapInfo.assetOut, out);
46
- }
47
- }
48
- exports.BluefinXContract = BluefinXContract;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BluefinXTx = void 0;
4
- class BluefinXTx {
5
- constructor(quoteId, txBytes) {
6
- this.quoteId = quoteId;
7
- this.txBytes = txBytes;
8
- }
9
- }
10
- exports.BluefinXTx = BluefinXTx;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BluemoveContract = void 0;
4
- const base_1 = require("../base");
5
- const sui_1 = require("../../../utils/sui");
6
- class BluemoveContract extends base_1.BaseContract {
7
- async swap(tx) {
8
- const config = this.config.bluemove;
9
- const [coinOut] = tx.moveCall({
10
- target: `${config.package}::router::swap_exact_input_`,
11
- typeArguments: [this.swapInfo.assetIn, this.swapInfo.assetOut],
12
- arguments: [
13
- sui_1.SuiUtils.getCoinValue(this.swapInfo.swapXtoY
14
- ? this.swapInfo.coinX.type
15
- : this.swapInfo.coinY.type, this.inputCoinObject, tx), // input amount
16
- this.inputCoinObject, // input coin
17
- tx.pure.u64(0), // min output amount
18
- tx.object(config.dexInfo),
19
- ],
20
- });
21
- return coinOut;
22
- }
23
- }
24
- exports.BluemoveContract = BluemoveContract;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CetusContract = void 0;
4
- const base_1 = require("../base");
5
- const utils_1 = require("@mysten/sui/utils");
6
- const utils_2 = require("../utils");
7
- const sui_1 = require("../../../utils/sui");
8
- class CetusContract extends base_1.BaseContract {
9
- async swap(tx) {
10
- const sqrtPriceLimit = (0, utils_2.getDefaultSqrtPriceLimit)(this.swapInfo.swapXtoY);
11
- const typeArguments = [this.swapInfo.coinX.type, this.swapInfo.coinY.type];
12
- const [zeroOut] = tx.moveCall({
13
- target: "0x2::coin::zero",
14
- typeArguments: [
15
- this.swapInfo.swapXtoY
16
- ? this.swapInfo.coinY.type
17
- : this.swapInfo.coinX.type,
18
- ],
19
- });
20
- const amountIn = sui_1.SuiUtils.getCoinValue(this.swapInfo.swapXtoY
21
- ? this.swapInfo.coinX.type
22
- : this.swapInfo.coinY.type, this.inputCoinObject, tx);
23
- const config = this.config.cetus;
24
- const [receiveA, receiveB] = tx.moveCall({
25
- target: `${config.package}::router::swap`,
26
- typeArguments,
27
- arguments: [
28
- tx.object(config.globalConfig),
29
- tx.object(this.swapInfo.poolId),
30
- this.swapInfo.swapXtoY ? this.inputCoinObject : zeroOut, // coin A
31
- this.swapInfo.swapXtoY ? zeroOut : this.inputCoinObject, // coin B
32
- tx.pure.bool(this.swapInfo.swapXtoY), // a to b or b to a
33
- tx.pure.bool(true), // exact in or out
34
- amountIn, // swap amount
35
- tx.pure.u128(sqrtPriceLimit.toString()), // sqrt price limit
36
- tx.pure.bool(false),
37
- tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
38
- ],
39
- });
40
- sui_1.SuiUtils.collectDust(tx, this.swapInfo.assetIn, this.swapInfo.swapXtoY ? receiveA : receiveB);
41
- return this.swapInfo.swapXtoY ? receiveB : receiveA;
42
- }
43
- }
44
- exports.CetusContract = CetusContract;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CetusDLMMContract = void 0;
4
- const utils_1 = require("@mysten/sui/utils");
5
- const sui_1 = require("../../utils/sui");
6
- const base_1 = require("./base");
7
- class CetusDLMMContract extends base_1.BaseContract {
8
- async swap(tx) {
9
- const config = this.config.cetus_dlmm;
10
- const [x, y, receipt] = tx.moveCall({
11
- target: `${config.package}::pool::flash_swap`,
12
- typeArguments: [this.swapInfo.coinX.type, this.swapInfo.coinY.type],
13
- arguments: [
14
- tx.object(this.swapInfo.poolId),
15
- tx.pure.bool(this.swapInfo.swapXtoY),
16
- tx.pure.bool(true), // exact in
17
- this.getInputCoinValue(tx),
18
- tx.object(config.globalConfig),
19
- tx.object(config.version),
20
- tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
21
- ],
22
- });
23
- const debtX = this.swapInfo.swapXtoY
24
- ? sui_1.SuiUtils.coinIntoBalance(tx, this.swapInfo.coinX.type, this.inputCoinObject)
25
- : sui_1.SuiUtils.zeroBalance(tx, this.swapInfo.coinX.type);
26
- const debtY = this.swapInfo.swapXtoY
27
- ? sui_1.SuiUtils.zeroBalance(tx, this.swapInfo.coinY.type)
28
- : sui_1.SuiUtils.coinIntoBalance(tx, this.swapInfo.coinY.type, this.inputCoinObject);
29
- tx.moveCall({
30
- target: `${config.package}::pool::repay_flash_swap`,
31
- typeArguments: [this.swapInfo.coinX.type, this.swapInfo.coinY.type],
32
- arguments: [
33
- tx.object(this.swapInfo.poolId),
34
- debtX,
35
- debtY,
36
- receipt,
37
- tx.object(config.version),
38
- ],
39
- });
40
- const [destroyType, destroyCoin, outType, outBalance] = this.swapInfo
41
- .swapXtoY
42
- ? [this.swapInfo.coinX.type, x, this.swapInfo.coinY.type, y]
43
- : [this.swapInfo.coinY.type, y, this.swapInfo.coinX.type, x];
44
- sui_1.SuiUtils.balanceDestroyZero(tx, destroyType, destroyCoin);
45
- return sui_1.SuiUtils.coinFromBalance(tx, outType, outBalance);
46
- }
47
- }
48
- exports.CetusDLMMContract = CetusDLMMContract;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MAX_SQRT_PRICE = exports.MIN_SQRT_PRICE = void 0;
4
- exports.MIN_SQRT_PRICE = "4295048016";
5
- exports.MAX_SQRT_PRICE = "79226673515401279992447579055";