@7kprotocol/sdk-ts 3.5.4 → 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 (379) 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 +103 -0
  6. package/lib/cjs/features/metaAg/error.js +31 -0
  7. package/lib/cjs/features/metaAg/index.js +96 -117
  8. package/lib/cjs/features/metaAg/providers/bluefin7k.js +57 -0
  9. package/lib/cjs/features/metaAg/providers/cetus.js +7 -7
  10. package/lib/cjs/features/metaAg/providers/flowx.js +6 -6
  11. package/lib/cjs/features/metaAg/providers/okx.js +182 -0
  12. package/lib/cjs/features/prices/index.js +51 -20
  13. package/lib/cjs/index.js +1 -35
  14. package/lib/cjs/types/config/fetchClient.d.ts.map +1 -1
  15. package/lib/cjs/types/constants/_7k.d.ts +0 -3
  16. package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
  17. package/lib/cjs/types/features/metaAg/common.d.ts +24 -0
  18. package/lib/cjs/types/features/metaAg/common.d.ts.map +1 -0
  19. package/lib/cjs/types/features/metaAg/error.d.ts +54 -0
  20. package/lib/cjs/types/features/metaAg/error.d.ts.map +1 -0
  21. package/lib/cjs/types/features/metaAg/index.d.ts +11 -2
  22. package/lib/cjs/types/features/metaAg/index.d.ts.map +1 -1
  23. package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts +11 -0
  24. package/lib/cjs/types/features/metaAg/providers/bluefin7k.d.ts.map +1 -0
  25. package/lib/cjs/types/features/metaAg/providers/cetus.d.ts +4 -5
  26. package/lib/cjs/types/features/metaAg/providers/cetus.d.ts.map +1 -1
  27. package/lib/cjs/types/features/metaAg/providers/flowx.d.ts +3 -3
  28. package/lib/cjs/types/features/metaAg/providers/flowx.d.ts.map +1 -1
  29. package/lib/cjs/types/features/metaAg/providers/okx.d.ts +21 -0
  30. package/lib/cjs/types/features/metaAg/providers/okx.d.ts.map +1 -0
  31. package/lib/cjs/types/features/prices/index.d.ts +16 -2
  32. package/lib/cjs/types/features/prices/index.d.ts.map +1 -1
  33. package/lib/cjs/types/index.d.ts +1 -30
  34. package/lib/cjs/types/index.d.ts.map +1 -1
  35. package/lib/cjs/types/metaAg.js +8 -4
  36. package/lib/cjs/types/okx.js +6 -0
  37. package/lib/cjs/types/types/metaAg.d.ts +50 -12
  38. package/lib/cjs/types/types/metaAg.d.ts.map +1 -1
  39. package/lib/cjs/types/types/okx.d.ts +206 -0
  40. package/lib/cjs/types/types/okx.d.ts.map +1 -0
  41. package/lib/cjs/types/utils/sui.d.ts +1 -31
  42. package/lib/cjs/types/utils/sui.d.ts.map +1 -1
  43. package/lib/cjs/types/utils/swap.d.ts +15 -0
  44. package/lib/cjs/types/utils/swap.d.ts.map +1 -0
  45. package/lib/cjs/utils/sui.js +19 -146
  46. package/lib/cjs/utils/swap.js +37 -0
  47. package/lib/esm/config/fetchClient.js +1 -9
  48. package/lib/esm/constants/_7k.js +12 -9
  49. package/lib/esm/constants/apiEndpoints.js +1 -1
  50. package/lib/esm/features/metaAg/common.js +96 -0
  51. package/lib/esm/features/metaAg/error.js +29 -0
  52. package/lib/esm/features/metaAg/index.js +96 -117
  53. package/lib/esm/features/metaAg/providers/{bluefin.js → bluefin7k.js} +12 -23
  54. package/lib/esm/features/metaAg/providers/cetus.js +7 -7
  55. package/lib/esm/features/metaAg/providers/flowx.js +6 -6
  56. package/lib/esm/features/metaAg/providers/okx.js +147 -0
  57. package/lib/esm/features/prices/index.js +52 -21
  58. package/lib/esm/index.mjs +3 -31
  59. package/lib/esm/types/config/fetchClient.d.ts.map +1 -1
  60. package/lib/esm/types/constants/_7k.d.ts +0 -3
  61. package/lib/esm/types/constants/_7k.d.ts.map +1 -1
  62. package/lib/esm/types/features/metaAg/common.d.ts +24 -0
  63. package/lib/esm/types/features/metaAg/common.d.ts.map +1 -0
  64. package/lib/esm/types/features/metaAg/error.d.ts +54 -0
  65. package/lib/esm/types/features/metaAg/error.d.ts.map +1 -0
  66. package/lib/esm/types/features/metaAg/index.d.ts +11 -2
  67. package/lib/esm/types/features/metaAg/index.d.ts.map +1 -1
  68. package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts +11 -0
  69. package/lib/esm/types/features/metaAg/providers/bluefin7k.d.ts.map +1 -0
  70. package/lib/esm/types/features/metaAg/providers/cetus.d.ts +4 -5
  71. package/lib/esm/types/features/metaAg/providers/cetus.d.ts.map +1 -1
  72. package/lib/esm/types/features/metaAg/providers/flowx.d.ts +3 -3
  73. package/lib/esm/types/features/metaAg/providers/flowx.d.ts.map +1 -1
  74. package/lib/esm/types/features/metaAg/providers/okx.d.ts +21 -0
  75. package/lib/esm/types/features/metaAg/providers/okx.d.ts.map +1 -0
  76. package/lib/esm/types/features/prices/index.d.ts +16 -2
  77. package/lib/esm/types/features/prices/index.d.ts.map +1 -1
  78. package/lib/esm/types/index.d.ts +1 -30
  79. package/lib/esm/types/index.d.ts.map +1 -1
  80. package/lib/esm/types/metaAg.js +5 -2
  81. package/lib/esm/types/okx.js +5 -0
  82. package/lib/esm/types/types/metaAg.d.ts +50 -12
  83. package/lib/esm/types/types/metaAg.d.ts.map +1 -1
  84. package/lib/esm/types/types/okx.d.ts +206 -0
  85. package/lib/esm/types/types/okx.d.ts.map +1 -0
  86. package/lib/esm/types/utils/sui.d.ts +1 -31
  87. package/lib/esm/types/utils/sui.d.ts.map +1 -1
  88. package/lib/esm/types/utils/swap.d.ts +15 -0
  89. package/lib/esm/types/utils/swap.d.ts.map +1 -0
  90. package/lib/esm/utils/sui.js +19 -147
  91. package/lib/esm/utils/swap.js +33 -0
  92. package/package.json +3 -1
  93. package/lib/cjs/config/index.js +0 -58
  94. package/lib/cjs/features/metaAg/providers/bluefin.js +0 -68
  95. package/lib/cjs/features/swap/buildTx.js +0 -195
  96. package/lib/cjs/features/swap/buildTxV2.js +0 -225
  97. package/lib/cjs/features/swap/config.js +0 -153
  98. package/lib/cjs/features/swap/estimateGasFee.js +0 -44
  99. package/lib/cjs/features/swap/executeTx.js +0 -52
  100. package/lib/cjs/features/swap/getQuote.js +0 -94
  101. package/lib/cjs/features/swap/getSwapHistory.js +0 -21
  102. package/lib/cjs/features/swap/index.js +0 -22
  103. package/lib/cjs/libs/groupSwapRoutes.js +0 -60
  104. package/lib/cjs/libs/protocols/aftermath/index.js +0 -35
  105. package/lib/cjs/libs/protocols/base.js +0 -41
  106. package/lib/cjs/libs/protocols/bluefin/index.js +0 -38
  107. package/lib/cjs/libs/protocols/bluefinx/client.js +0 -41
  108. package/lib/cjs/libs/protocols/bluefinx/index.js +0 -48
  109. package/lib/cjs/libs/protocols/bluefinx/types.js +0 -10
  110. package/lib/cjs/libs/protocols/bluemove/index.js +0 -24
  111. package/lib/cjs/libs/protocols/cetus/index.js +0 -44
  112. package/lib/cjs/libs/protocols/cetus_dlmm.js +0 -48
  113. package/lib/cjs/libs/protocols/constants.js +0 -5
  114. package/lib/cjs/libs/protocols/deepbookV3/sponsored.js +0 -30
  115. package/lib/cjs/libs/protocols/ferra_clmm.js +0 -44
  116. package/lib/cjs/libs/protocols/ferra_dlmm.js +0 -30
  117. package/lib/cjs/libs/protocols/flowx/index.js +0 -18
  118. package/lib/cjs/libs/protocols/flowxV3/index.js +0 -36
  119. package/lib/cjs/libs/protocols/fullsail/index.js +0 -39
  120. package/lib/cjs/libs/protocols/haedal_pmm/index.js +0 -31
  121. package/lib/cjs/libs/protocols/index.js +0 -55
  122. package/lib/cjs/libs/protocols/kriya/index.js +0 -30
  123. package/lib/cjs/libs/protocols/kriyaV3/index.js +0 -65
  124. package/lib/cjs/libs/protocols/magma/index.js +0 -40
  125. package/lib/cjs/libs/protocols/momentum/index.js +0 -49
  126. package/lib/cjs/libs/protocols/obric/index.js +0 -28
  127. package/lib/cjs/libs/protocols/sevenk/index.js +0 -55
  128. package/lib/cjs/libs/protocols/springsui/index.js +0 -24
  129. package/lib/cjs/libs/protocols/steamm/index.js +0 -160
  130. package/lib/cjs/libs/protocols/stsui/index.js +0 -24
  131. package/lib/cjs/libs/protocols/suiswap/index.js +0 -34
  132. package/lib/cjs/libs/protocols/turbos/index.js +0 -36
  133. package/lib/cjs/libs/protocols/utils.js +0 -7
  134. package/lib/cjs/libs/swapWithRoute.js +0 -22
  135. package/lib/cjs/types/aggregator.js +0 -19
  136. package/lib/cjs/types/config/index.d.ts +0 -26
  137. package/lib/cjs/types/config/index.d.ts.map +0 -1
  138. package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts +0 -11
  139. package/lib/cjs/types/features/metaAg/providers/bluefin.d.ts.map +0 -1
  140. package/lib/cjs/types/features/swap/buildTx.d.ts +0 -17
  141. package/lib/cjs/types/features/swap/buildTx.d.ts.map +0 -1
  142. package/lib/cjs/types/features/swap/buildTxV2.d.ts +0 -20
  143. package/lib/cjs/types/features/swap/buildTxV2.d.ts.map +0 -1
  144. package/lib/cjs/types/features/swap/config.d.ts +0 -4
  145. package/lib/cjs/types/features/swap/config.d.ts.map +0 -1
  146. package/lib/cjs/types/features/swap/estimateGasFee.d.ts +0 -3
  147. package/lib/cjs/types/features/swap/estimateGasFee.d.ts.map +0 -1
  148. package/lib/cjs/types/features/swap/executeTx.d.ts +0 -24
  149. package/lib/cjs/types/features/swap/executeTx.d.ts.map +0 -1
  150. package/lib/cjs/types/features/swap/getQuote.d.ts +0 -29
  151. package/lib/cjs/types/features/swap/getQuote.d.ts.map +0 -1
  152. package/lib/cjs/types/features/swap/getSwapHistory.d.ts +0 -22
  153. package/lib/cjs/types/features/swap/getSwapHistory.d.ts.map +0 -1
  154. package/lib/cjs/types/features/swap/index.d.ts +0 -7
  155. package/lib/cjs/types/features/swap/index.d.ts.map +0 -1
  156. package/lib/cjs/types/libs/groupSwapRoutes.d.ts +0 -3
  157. package/lib/cjs/types/libs/groupSwapRoutes.d.ts.map +0 -1
  158. package/lib/cjs/types/libs/protocols/aftermath/index.d.ts +0 -9
  159. package/lib/cjs/types/libs/protocols/aftermath/index.d.ts.map +0 -1
  160. package/lib/cjs/types/libs/protocols/base.d.ts +0 -24
  161. package/lib/cjs/types/libs/protocols/base.d.ts.map +0 -1
  162. package/lib/cjs/types/libs/protocols/bluefin/index.d.ts +0 -9
  163. package/lib/cjs/types/libs/protocols/bluefin/index.d.ts.map +0 -1
  164. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts +0 -13
  165. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts.map +0 -1
  166. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts +0 -17
  167. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts.map +0 -1
  168. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts +0 -34
  169. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts.map +0 -1
  170. package/lib/cjs/types/libs/protocols/bluemove/index.d.ts +0 -9
  171. package/lib/cjs/types/libs/protocols/bluemove/index.d.ts.map +0 -1
  172. package/lib/cjs/types/libs/protocols/cetus/index.d.ts +0 -9
  173. package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +0 -1
  174. package/lib/cjs/types/libs/protocols/cetus_dlmm.d.ts +0 -9
  175. package/lib/cjs/types/libs/protocols/cetus_dlmm.d.ts.map +0 -1
  176. package/lib/cjs/types/libs/protocols/constants.d.ts +0 -3
  177. package/lib/cjs/types/libs/protocols/constants.d.ts.map +0 -1
  178. package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts +0 -7
  179. package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts.map +0 -1
  180. package/lib/cjs/types/libs/protocols/ferra_clmm.d.ts +0 -9
  181. package/lib/cjs/types/libs/protocols/ferra_clmm.d.ts.map +0 -1
  182. package/lib/cjs/types/libs/protocols/ferra_dlmm.d.ts +0 -9
  183. package/lib/cjs/types/libs/protocols/ferra_dlmm.d.ts.map +0 -1
  184. package/lib/cjs/types/libs/protocols/flowx/index.d.ts +0 -9
  185. package/lib/cjs/types/libs/protocols/flowx/index.d.ts.map +0 -1
  186. package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts +0 -9
  187. package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts.map +0 -1
  188. package/lib/cjs/types/libs/protocols/fullsail/index.d.ts +0 -9
  189. package/lib/cjs/types/libs/protocols/fullsail/index.d.ts.map +0 -1
  190. package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts +0 -14
  191. package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts.map +0 -1
  192. package/lib/cjs/types/libs/protocols/index.d.ts +0 -53
  193. package/lib/cjs/types/libs/protocols/index.d.ts.map +0 -1
  194. package/lib/cjs/types/libs/protocols/kriya/index.d.ts +0 -9
  195. package/lib/cjs/types/libs/protocols/kriya/index.d.ts.map +0 -1
  196. package/lib/cjs/types/libs/protocols/kriyaV3/index.d.ts +0 -9
  197. package/lib/cjs/types/libs/protocols/kriyaV3/index.d.ts.map +0 -1
  198. package/lib/cjs/types/libs/protocols/magma/index.d.ts +0 -9
  199. package/lib/cjs/types/libs/protocols/magma/index.d.ts.map +0 -1
  200. package/lib/cjs/types/libs/protocols/momentum/index.d.ts +0 -9
  201. package/lib/cjs/types/libs/protocols/momentum/index.d.ts.map +0 -1
  202. package/lib/cjs/types/libs/protocols/obric/index.d.ts +0 -14
  203. package/lib/cjs/types/libs/protocols/obric/index.d.ts.map +0 -1
  204. package/lib/cjs/types/libs/protocols/sevenk/index.d.ts +0 -18
  205. package/lib/cjs/types/libs/protocols/sevenk/index.d.ts.map +0 -1
  206. package/lib/cjs/types/libs/protocols/springsui/index.d.ts +0 -9
  207. package/lib/cjs/types/libs/protocols/springsui/index.d.ts.map +0 -1
  208. package/lib/cjs/types/libs/protocols/steamm/index.d.ts +0 -28
  209. package/lib/cjs/types/libs/protocols/steamm/index.d.ts.map +0 -1
  210. package/lib/cjs/types/libs/protocols/stsui/index.d.ts +0 -9
  211. package/lib/cjs/types/libs/protocols/stsui/index.d.ts.map +0 -1
  212. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts +0 -9
  213. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts.map +0 -1
  214. package/lib/cjs/types/libs/protocols/turbos/index.d.ts +0 -9
  215. package/lib/cjs/types/libs/protocols/turbos/index.d.ts.map +0 -1
  216. package/lib/cjs/types/libs/protocols/utils.d.ts +0 -2
  217. package/lib/cjs/types/libs/protocols/utils.d.ts.map +0 -1
  218. package/lib/cjs/types/libs/swapWithRoute.d.ts +0 -12
  219. package/lib/cjs/types/libs/swapWithRoute.d.ts.map +0 -1
  220. package/lib/cjs/types/sui.js +0 -2
  221. package/lib/cjs/types/tx.js +0 -2
  222. package/lib/cjs/types/types/aggregator.d.ts +0 -173
  223. package/lib/cjs/types/types/aggregator.d.ts.map +0 -1
  224. package/lib/cjs/types/types/sui.d.ts +0 -4
  225. package/lib/cjs/types/types/sui.d.ts.map +0 -1
  226. package/lib/cjs/types/types/tx.d.ts +0 -67
  227. package/lib/cjs/types/types/tx.d.ts.map +0 -1
  228. package/lib/cjs/types/types/utilities.d.ts +0 -5
  229. package/lib/cjs/types/types/utilities.d.ts.map +0 -1
  230. package/lib/cjs/types/utilities.js +0 -2
  231. package/lib/cjs/types/utils/condition.d.ts +0 -2
  232. package/lib/cjs/types/utils/condition.d.ts.map +0 -1
  233. package/lib/cjs/types/utils/number.d.ts +0 -2
  234. package/lib/cjs/types/utils/number.d.ts.map +0 -1
  235. package/lib/cjs/utils/condition.js +0 -8
  236. package/lib/cjs/utils/number.js +0 -9
  237. package/lib/esm/config/index.js +0 -55
  238. package/lib/esm/features/swap/buildTx.js +0 -185
  239. package/lib/esm/features/swap/buildTxV2.js +0 -219
  240. package/lib/esm/features/swap/config.js +0 -149
  241. package/lib/esm/features/swap/estimateGasFee.js +0 -41
  242. package/lib/esm/features/swap/executeTx.js +0 -48
  243. package/lib/esm/features/swap/getQuote.js +0 -90
  244. package/lib/esm/features/swap/getSwapHistory.js +0 -18
  245. package/lib/esm/features/swap/index.js +0 -6
  246. package/lib/esm/libs/groupSwapRoutes.js +0 -57
  247. package/lib/esm/libs/protocols/aftermath/index.js +0 -31
  248. package/lib/esm/libs/protocols/base.js +0 -42
  249. package/lib/esm/libs/protocols/bluefin/index.js +0 -34
  250. package/lib/esm/libs/protocols/bluefinx/client.js +0 -36
  251. package/lib/esm/libs/protocols/bluefinx/index.js +0 -44
  252. package/lib/esm/libs/protocols/bluefinx/types.js +0 -8
  253. package/lib/esm/libs/protocols/bluemove/index.js +0 -20
  254. package/lib/esm/libs/protocols/cetus/index.js +0 -40
  255. package/lib/esm/libs/protocols/cetus_dlmm.js +0 -44
  256. package/lib/esm/libs/protocols/constants.js +0 -2
  257. package/lib/esm/libs/protocols/deepbookV3/sponsored.js +0 -26
  258. package/lib/esm/libs/protocols/ferra_clmm.js +0 -40
  259. package/lib/esm/libs/protocols/ferra_dlmm.js +0 -26
  260. package/lib/esm/libs/protocols/flowx/index.js +0 -14
  261. package/lib/esm/libs/protocols/flowxV3/index.js +0 -32
  262. package/lib/esm/libs/protocols/fullsail/index.js +0 -35
  263. package/lib/esm/libs/protocols/haedal_pmm/index.js +0 -27
  264. package/lib/esm/libs/protocols/index.js +0 -52
  265. package/lib/esm/libs/protocols/kriya/index.js +0 -26
  266. package/lib/esm/libs/protocols/kriyaV3/index.js +0 -61
  267. package/lib/esm/libs/protocols/magma/index.js +0 -36
  268. package/lib/esm/libs/protocols/momentum/index.js +0 -45
  269. package/lib/esm/libs/protocols/obric/index.js +0 -24
  270. package/lib/esm/libs/protocols/sevenk/index.js +0 -51
  271. package/lib/esm/libs/protocols/springsui/index.js +0 -20
  272. package/lib/esm/libs/protocols/steamm/index.js +0 -156
  273. package/lib/esm/libs/protocols/stsui/index.js +0 -20
  274. package/lib/esm/libs/protocols/suiswap/index.js +0 -30
  275. package/lib/esm/libs/protocols/turbos/index.js +0 -32
  276. package/lib/esm/libs/protocols/utils.js +0 -4
  277. package/lib/esm/libs/swapWithRoute.js +0 -19
  278. package/lib/esm/types/aggregator.js +0 -14
  279. package/lib/esm/types/config/index.d.ts +0 -26
  280. package/lib/esm/types/config/index.d.ts.map +0 -1
  281. package/lib/esm/types/features/metaAg/providers/bluefin.d.ts +0 -11
  282. package/lib/esm/types/features/metaAg/providers/bluefin.d.ts.map +0 -1
  283. package/lib/esm/types/features/swap/buildTx.d.ts +0 -17
  284. package/lib/esm/types/features/swap/buildTx.d.ts.map +0 -1
  285. package/lib/esm/types/features/swap/buildTxV2.d.ts +0 -20
  286. package/lib/esm/types/features/swap/buildTxV2.d.ts.map +0 -1
  287. package/lib/esm/types/features/swap/config.d.ts +0 -4
  288. package/lib/esm/types/features/swap/config.d.ts.map +0 -1
  289. package/lib/esm/types/features/swap/estimateGasFee.d.ts +0 -3
  290. package/lib/esm/types/features/swap/estimateGasFee.d.ts.map +0 -1
  291. package/lib/esm/types/features/swap/executeTx.d.ts +0 -24
  292. package/lib/esm/types/features/swap/executeTx.d.ts.map +0 -1
  293. package/lib/esm/types/features/swap/getQuote.d.ts +0 -29
  294. package/lib/esm/types/features/swap/getQuote.d.ts.map +0 -1
  295. package/lib/esm/types/features/swap/getSwapHistory.d.ts +0 -22
  296. package/lib/esm/types/features/swap/getSwapHistory.d.ts.map +0 -1
  297. package/lib/esm/types/features/swap/index.d.ts +0 -7
  298. package/lib/esm/types/features/swap/index.d.ts.map +0 -1
  299. package/lib/esm/types/libs/groupSwapRoutes.d.ts +0 -3
  300. package/lib/esm/types/libs/groupSwapRoutes.d.ts.map +0 -1
  301. package/lib/esm/types/libs/protocols/aftermath/index.d.ts +0 -9
  302. package/lib/esm/types/libs/protocols/aftermath/index.d.ts.map +0 -1
  303. package/lib/esm/types/libs/protocols/base.d.ts +0 -24
  304. package/lib/esm/types/libs/protocols/base.d.ts.map +0 -1
  305. package/lib/esm/types/libs/protocols/bluefin/index.d.ts +0 -9
  306. package/lib/esm/types/libs/protocols/bluefin/index.d.ts.map +0 -1
  307. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts +0 -13
  308. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts.map +0 -1
  309. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts +0 -17
  310. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts.map +0 -1
  311. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts +0 -34
  312. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts.map +0 -1
  313. package/lib/esm/types/libs/protocols/bluemove/index.d.ts +0 -9
  314. package/lib/esm/types/libs/protocols/bluemove/index.d.ts.map +0 -1
  315. package/lib/esm/types/libs/protocols/cetus/index.d.ts +0 -9
  316. package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +0 -1
  317. package/lib/esm/types/libs/protocols/cetus_dlmm.d.ts +0 -9
  318. package/lib/esm/types/libs/protocols/cetus_dlmm.d.ts.map +0 -1
  319. package/lib/esm/types/libs/protocols/constants.d.ts +0 -3
  320. package/lib/esm/types/libs/protocols/constants.d.ts.map +0 -1
  321. package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts +0 -7
  322. package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts.map +0 -1
  323. package/lib/esm/types/libs/protocols/ferra_clmm.d.ts +0 -9
  324. package/lib/esm/types/libs/protocols/ferra_clmm.d.ts.map +0 -1
  325. package/lib/esm/types/libs/protocols/ferra_dlmm.d.ts +0 -9
  326. package/lib/esm/types/libs/protocols/ferra_dlmm.d.ts.map +0 -1
  327. package/lib/esm/types/libs/protocols/flowx/index.d.ts +0 -9
  328. package/lib/esm/types/libs/protocols/flowx/index.d.ts.map +0 -1
  329. package/lib/esm/types/libs/protocols/flowxV3/index.d.ts +0 -9
  330. package/lib/esm/types/libs/protocols/flowxV3/index.d.ts.map +0 -1
  331. package/lib/esm/types/libs/protocols/fullsail/index.d.ts +0 -9
  332. package/lib/esm/types/libs/protocols/fullsail/index.d.ts.map +0 -1
  333. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts +0 -14
  334. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts.map +0 -1
  335. package/lib/esm/types/libs/protocols/index.d.ts +0 -53
  336. package/lib/esm/types/libs/protocols/index.d.ts.map +0 -1
  337. package/lib/esm/types/libs/protocols/kriya/index.d.ts +0 -9
  338. package/lib/esm/types/libs/protocols/kriya/index.d.ts.map +0 -1
  339. package/lib/esm/types/libs/protocols/kriyaV3/index.d.ts +0 -9
  340. package/lib/esm/types/libs/protocols/kriyaV3/index.d.ts.map +0 -1
  341. package/lib/esm/types/libs/protocols/magma/index.d.ts +0 -9
  342. package/lib/esm/types/libs/protocols/magma/index.d.ts.map +0 -1
  343. package/lib/esm/types/libs/protocols/momentum/index.d.ts +0 -9
  344. package/lib/esm/types/libs/protocols/momentum/index.d.ts.map +0 -1
  345. package/lib/esm/types/libs/protocols/obric/index.d.ts +0 -14
  346. package/lib/esm/types/libs/protocols/obric/index.d.ts.map +0 -1
  347. package/lib/esm/types/libs/protocols/sevenk/index.d.ts +0 -18
  348. package/lib/esm/types/libs/protocols/sevenk/index.d.ts.map +0 -1
  349. package/lib/esm/types/libs/protocols/springsui/index.d.ts +0 -9
  350. package/lib/esm/types/libs/protocols/springsui/index.d.ts.map +0 -1
  351. package/lib/esm/types/libs/protocols/steamm/index.d.ts +0 -28
  352. package/lib/esm/types/libs/protocols/steamm/index.d.ts.map +0 -1
  353. package/lib/esm/types/libs/protocols/stsui/index.d.ts +0 -9
  354. package/lib/esm/types/libs/protocols/stsui/index.d.ts.map +0 -1
  355. package/lib/esm/types/libs/protocols/suiswap/index.d.ts +0 -9
  356. package/lib/esm/types/libs/protocols/suiswap/index.d.ts.map +0 -1
  357. package/lib/esm/types/libs/protocols/turbos/index.d.ts +0 -9
  358. package/lib/esm/types/libs/protocols/turbos/index.d.ts.map +0 -1
  359. package/lib/esm/types/libs/protocols/utils.d.ts +0 -2
  360. package/lib/esm/types/libs/protocols/utils.d.ts.map +0 -1
  361. package/lib/esm/types/libs/swapWithRoute.d.ts +0 -12
  362. package/lib/esm/types/libs/swapWithRoute.d.ts.map +0 -1
  363. package/lib/esm/types/sui.js +0 -1
  364. package/lib/esm/types/tx.js +0 -1
  365. package/lib/esm/types/types/aggregator.d.ts +0 -173
  366. package/lib/esm/types/types/aggregator.d.ts.map +0 -1
  367. package/lib/esm/types/types/sui.d.ts +0 -4
  368. package/lib/esm/types/types/sui.d.ts.map +0 -1
  369. package/lib/esm/types/types/tx.d.ts +0 -67
  370. package/lib/esm/types/types/tx.d.ts.map +0 -1
  371. package/lib/esm/types/types/utilities.d.ts +0 -5
  372. package/lib/esm/types/types/utilities.d.ts.map +0 -1
  373. package/lib/esm/types/utilities.js +0 -1
  374. package/lib/esm/types/utils/condition.d.ts +0 -2
  375. package/lib/esm/types/utils/condition.d.ts.map +0 -1
  376. package/lib/esm/types/utils/number.d.ts +0 -2
  377. package/lib/esm/types/utils/number.d.ts.map +0 -1
  378. package/lib/esm/utils/condition.js +0 -5
  379. package/lib/esm/utils/number.js +0 -6
@@ -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,94 +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 fetchClient_1 = require("../../config/fetchClient");
7
- const apiEndpoints_1 = require("../../constants/apiEndpoints");
8
- const aggregator_1 = require("../../types/aggregator");
9
- exports.DEFAULT_SOURCES = [
10
- "suiswap",
11
- "turbos",
12
- "cetus",
13
- "bluemove",
14
- "kriya",
15
- "kriya_v3",
16
- "aftermath",
17
- "deepbook_v3",
18
- "flowx",
19
- "flowx_v3",
20
- "bluefin",
21
- "springsui",
22
- "obric",
23
- "stsui",
24
- "steamm",
25
- "steamm_oracle_quoter",
26
- "steamm_oracle_quoter_v2",
27
- "magma",
28
- "haedal_pmm",
29
- "momentum",
30
- "sevenk_v1",
31
- "fullsail",
32
- "cetus_dlmm",
33
- "ferra_dlmm",
34
- "ferra_clmm",
35
- ];
36
- exports.ORACLE_BASED_SOURCES = new Set([
37
- "obric",
38
- "haedal_pmm",
39
- "sevenk_v1",
40
- "steamm_oracle_quoter",
41
- "steamm_oracle_quoter_v2",
42
- ]);
43
- async function getQuote({ tokenIn, tokenOut, amountIn, sources: _sources = exports.DEFAULT_SOURCES, commissionBps, targetPools, excludedPools, taker, isSponsored, api, maxPaths, }) {
44
- let sources = _sources;
45
- if (isSponsored) {
46
- sources = _sources.filter((s) => !exports.ORACLE_BASED_SOURCES.has(s));
47
- }
48
- const params = new URLSearchParams({
49
- amount: amountIn,
50
- from: (0, utils_1.normalizeStructTag)(tokenIn),
51
- to: (0, utils_1.normalizeStructTag)(tokenOut),
52
- sources: sources.join(","),
53
- });
54
- if (targetPools?.length) {
55
- params.append("target_pools", targetPools.map((v) => (0, utils_1.normalizeSuiObjectId)(v)).join(","));
56
- }
57
- if (excludedPools?.length) {
58
- params.append("excluded_pools", excludedPools.map((v) => (0, utils_1.normalizeSuiObjectId)(v)).join(","));
59
- }
60
- if (taker) {
61
- params.append("taker", taker);
62
- }
63
- if (maxPaths) {
64
- params.append("max_paths", maxPaths.toString());
65
- }
66
- const response = await (0, fetchClient_1.fetchClient)(`${api || apiEndpoints_1.API_ENDPOINTS.MAIN}/quote?${params}`);
67
- if (!response.ok) {
68
- let responseText;
69
- try {
70
- responseText = await response.text();
71
- }
72
- catch {
73
- responseText = "Failed to fetch aggregator quote";
74
- }
75
- throw new Error(responseText);
76
- }
77
- const quoteResponse = (await response.json());
78
- computeReturnAmountAfterCommission(quoteResponse, commissionBps);
79
- return quoteResponse;
80
- }
81
- const computeReturnAmountAfterCommission = (quoteResponse, commissionBps) => {
82
- const _commissionBps = (0, aggregator_1.isBluefinXRouting)(quoteResponse) ? 0 : commissionBps;
83
- if (quoteResponse.returnAmount && +quoteResponse.returnAmount > 0) {
84
- quoteResponse.returnAmountAfterCommissionWithDecimal = ((BigInt(quoteResponse.returnAmountWithDecimal || 0) *
85
- BigInt(10000 - (_commissionBps ?? 0))) /
86
- BigInt(10000)).toString(10);
87
- const exp = Math.round(+quoteResponse.returnAmountWithDecimal / +quoteResponse.returnAmount);
88
- quoteResponse.returnAmountAfterCommission = (+quoteResponse.returnAmountAfterCommissionWithDecimal / exp).toString(10);
89
- }
90
- else {
91
- quoteResponse.returnAmountAfterCommission = "";
92
- quoteResponse.returnAmountAfterCommissionWithDecimal = "";
93
- }
94
- };
@@ -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(`${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";
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SponsoredDeepBookV3Contract = void 0;
4
- const base_1 = require("../base");
5
- const utils_1 = require("@mysten/sui/utils");
6
- const sui_1 = require("../../../utils/sui");
7
- class SponsoredDeepBookV3Contract extends base_1.BaseContract {
8
- async swap(tx) {
9
- const [coinX] = this.swapInfo.pool.allTokens;
10
- const swapXtoY = (0, utils_1.normalizeStructTag)(coinX.address) ===
11
- (0, utils_1.normalizeStructTag)(this.swapInfo.assetIn);
12
- const config = this.config.deepbook_v3;
13
- const [base, quote] = tx.moveCall({
14
- target: `${config.sponsor}::sponsored::${swapXtoY ? "swap_exact_base_for_quote" : "swap_exact_quote_for_base"}`,
15
- typeArguments: this.getTypeParams(),
16
- arguments: [
17
- tx.object(config.sponsorFund),
18
- tx.object(this.swapInfo.poolId),
19
- this.inputCoinObject,
20
- tx.pure.u64(0),
21
- tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
22
- ],
23
- });
24
- const coinIn = swapXtoY ? base : quote;
25
- const coinOut = swapXtoY ? quote : base;
26
- sui_1.SuiUtils.collectDust(tx, this.swapInfo.assetIn, coinIn);
27
- return coinOut;
28
- }
29
- }
30
- exports.SponsoredDeepBookV3Contract = SponsoredDeepBookV3Contract;