@7kprotocol/sdk-ts 1.0.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 (201) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +122 -0
  3. package/lib/cjs/buildTx.js +93 -0
  4. package/lib/cjs/constants/explorer.js +6 -0
  5. package/lib/cjs/constants/tokens.js +5 -0
  6. package/lib/cjs/estimateGasFee.js +52 -0
  7. package/lib/cjs/getQuote.js +22 -0
  8. package/lib/cjs/getSuiPrice.js +31 -0
  9. package/lib/cjs/index.js +37 -0
  10. package/lib/cjs/libs/getCoinOjectIdsByAmount.js +74 -0
  11. package/lib/cjs/libs/getSplitCoinForTx.js +55 -0
  12. package/lib/cjs/libs/groupSwapRoutes.js +62 -0
  13. package/lib/cjs/libs/protocols/aftermath/index.js +52 -0
  14. package/lib/cjs/libs/protocols/base.js +20 -0
  15. package/lib/cjs/libs/protocols/bluemove/index.js +36 -0
  16. package/lib/cjs/libs/protocols/cetus/index.js +56 -0
  17. package/lib/cjs/libs/protocols/constants.js +5 -0
  18. package/lib/cjs/libs/protocols/deepbook/index.js +96 -0
  19. package/lib/cjs/libs/protocols/flowx/index.js +31 -0
  20. package/lib/cjs/libs/protocols/index.js +21 -0
  21. package/lib/cjs/libs/protocols/kriya/index.js +42 -0
  22. package/lib/cjs/libs/protocols/suiswap/index.js +45 -0
  23. package/lib/cjs/libs/protocols/turbos/constants.js +7 -0
  24. package/lib/cjs/libs/protocols/turbos/index.js +53 -0
  25. package/lib/cjs/libs/protocols/utils.js +11 -0
  26. package/lib/cjs/libs/swapWithRoute.js +31 -0
  27. package/lib/cjs/suiClient.js +14 -0
  28. package/lib/cjs/types/aggregator.js +2 -0
  29. package/lib/cjs/types/buildTx.d.ts +4 -0
  30. package/lib/cjs/types/buildTx.d.ts.map +1 -0
  31. package/lib/cjs/types/constants/explorer.d.ts +4 -0
  32. package/lib/cjs/types/constants/explorer.d.ts.map +1 -0
  33. package/lib/cjs/types/constants/tokens.d.ts +3 -0
  34. package/lib/cjs/types/constants/tokens.d.ts.map +1 -0
  35. package/lib/cjs/types/estimateGasFee.d.ts +3 -0
  36. package/lib/cjs/types/estimateGasFee.d.ts.map +1 -0
  37. package/lib/cjs/types/getQuote.d.ts +9 -0
  38. package/lib/cjs/types/getQuote.d.ts.map +1 -0
  39. package/lib/cjs/types/getSuiPrice.d.ts +2 -0
  40. package/lib/cjs/types/getSuiPrice.d.ts.map +1 -0
  41. package/lib/cjs/types/index.d.ts +17 -0
  42. package/lib/cjs/types/index.d.ts.map +1 -0
  43. package/lib/cjs/types/libs/getCoinOjectIdsByAmount.d.ts +7 -0
  44. package/lib/cjs/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -0
  45. package/lib/cjs/types/libs/getSplitCoinForTx.d.ts +6 -0
  46. package/lib/cjs/types/libs/getSplitCoinForTx.d.ts.map +1 -0
  47. package/lib/cjs/types/libs/groupSwapRoutes.d.ts +3 -0
  48. package/lib/cjs/types/libs/groupSwapRoutes.d.ts.map +1 -0
  49. package/lib/cjs/types/libs/protocols/aftermath/index.d.ts +10 -0
  50. package/lib/cjs/types/libs/protocols/aftermath/index.d.ts.map +1 -0
  51. package/lib/cjs/types/libs/protocols/base.d.ts +37 -0
  52. package/lib/cjs/types/libs/protocols/base.d.ts.map +1 -0
  53. package/lib/cjs/types/libs/protocols/bluemove/index.d.ts +10 -0
  54. package/lib/cjs/types/libs/protocols/bluemove/index.d.ts.map +1 -0
  55. package/lib/cjs/types/libs/protocols/cetus/index.d.ts +10 -0
  56. package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +1 -0
  57. package/lib/cjs/types/libs/protocols/constants.d.ts +3 -0
  58. package/lib/cjs/types/libs/protocols/constants.d.ts.map +1 -0
  59. package/lib/cjs/types/libs/protocols/deepbook/index.d.ts +12 -0
  60. package/lib/cjs/types/libs/protocols/deepbook/index.d.ts.map +1 -0
  61. package/lib/cjs/types/libs/protocols/flowx/index.d.ts +10 -0
  62. package/lib/cjs/types/libs/protocols/flowx/index.d.ts.map +1 -0
  63. package/lib/cjs/types/libs/protocols/index.d.ts +19 -0
  64. package/lib/cjs/types/libs/protocols/index.d.ts.map +1 -0
  65. package/lib/cjs/types/libs/protocols/kriya/index.d.ts +10 -0
  66. package/lib/cjs/types/libs/protocols/kriya/index.d.ts.map +1 -0
  67. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts +10 -0
  68. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts.map +1 -0
  69. package/lib/cjs/types/libs/protocols/turbos/constants.d.ts +5 -0
  70. package/lib/cjs/types/libs/protocols/turbos/constants.d.ts.map +1 -0
  71. package/lib/cjs/types/libs/protocols/turbos/index.d.ts +10 -0
  72. package/lib/cjs/types/libs/protocols/turbos/index.d.ts.map +1 -0
  73. package/lib/cjs/types/libs/protocols/utils.d.ts +3 -0
  74. package/lib/cjs/types/libs/protocols/utils.d.ts.map +1 -0
  75. package/lib/cjs/types/libs/swapWithRoute.d.ts +10 -0
  76. package/lib/cjs/types/libs/swapWithRoute.d.ts.map +1 -0
  77. package/lib/cjs/types/sui.js +2 -0
  78. package/lib/cjs/types/suiClient.d.ts +4 -0
  79. package/lib/cjs/types/suiClient.d.ts.map +1 -0
  80. package/lib/cjs/types/token.js +2 -0
  81. package/lib/cjs/types/tx.js +2 -0
  82. package/lib/cjs/types/types/aggregator.d.ts +69 -0
  83. package/lib/cjs/types/types/aggregator.d.ts.map +1 -0
  84. package/lib/cjs/types/types/sui.d.ts +4 -0
  85. package/lib/cjs/types/types/sui.d.ts.map +1 -0
  86. package/lib/cjs/types/types/token.d.ts +30 -0
  87. package/lib/cjs/types/types/token.d.ts.map +1 -0
  88. package/lib/cjs/types/types/tx.d.ts +14 -0
  89. package/lib/cjs/types/types/tx.d.ts.map +1 -0
  90. package/lib/cjs/types/types/utilities.d.ts +5 -0
  91. package/lib/cjs/types/types/utilities.d.ts.map +1 -0
  92. package/lib/cjs/types/utilities.js +2 -0
  93. package/lib/cjs/types/utils/number.d.ts +4 -0
  94. package/lib/cjs/types/utils/number.d.ts.map +1 -0
  95. package/lib/cjs/types/utils/sui.d.ts +39 -0
  96. package/lib/cjs/types/utils/sui.d.ts.map +1 -0
  97. package/lib/cjs/types/utils/token.d.ts +6 -0
  98. package/lib/cjs/types/utils/token.d.ts.map +1 -0
  99. package/lib/cjs/utils/number.js +15 -0
  100. package/lib/cjs/utils/sui.js +180 -0
  101. package/lib/cjs/utils/token.js +36 -0
  102. package/lib/esm/buildTx.js +77 -0
  103. package/lib/esm/constants/explorer.js +3 -0
  104. package/lib/esm/constants/tokens.js +2 -0
  105. package/lib/esm/estimateGasFee.js +35 -0
  106. package/lib/esm/getQuote.js +8 -0
  107. package/lib/esm/getSuiPrice.js +13 -0
  108. package/lib/esm/index.mjs +15 -0
  109. package/lib/esm/libs/getCoinOjectIdsByAmount.js +61 -0
  110. package/lib/esm/libs/getSplitCoinForTx.js +39 -0
  111. package/lib/esm/libs/groupSwapRoutes.js +58 -0
  112. package/lib/esm/libs/protocols/aftermath/index.js +37 -0
  113. package/lib/esm/libs/protocols/base.js +18 -0
  114. package/lib/esm/libs/protocols/bluemove/index.js +21 -0
  115. package/lib/esm/libs/protocols/cetus/index.js +41 -0
  116. package/lib/esm/libs/protocols/constants.js +2 -0
  117. package/lib/esm/libs/protocols/deepbook/index.js +80 -0
  118. package/lib/esm/libs/protocols/flowx/index.js +16 -0
  119. package/lib/esm/libs/protocols/index.js +18 -0
  120. package/lib/esm/libs/protocols/kriya/index.js +27 -0
  121. package/lib/esm/libs/protocols/suiswap/index.js +30 -0
  122. package/lib/esm/libs/protocols/turbos/constants.js +4 -0
  123. package/lib/esm/libs/protocols/turbos/index.js +38 -0
  124. package/lib/esm/libs/protocols/utils.js +5 -0
  125. package/lib/esm/libs/swapWithRoute.js +17 -0
  126. package/lib/esm/suiClient.js +10 -0
  127. package/lib/esm/types/aggregator.js +1 -0
  128. package/lib/esm/types/buildTx.d.ts +4 -0
  129. package/lib/esm/types/buildTx.d.ts.map +1 -0
  130. package/lib/esm/types/constants/explorer.d.ts +4 -0
  131. package/lib/esm/types/constants/explorer.d.ts.map +1 -0
  132. package/lib/esm/types/constants/tokens.d.ts +3 -0
  133. package/lib/esm/types/constants/tokens.d.ts.map +1 -0
  134. package/lib/esm/types/estimateGasFee.d.ts +3 -0
  135. package/lib/esm/types/estimateGasFee.d.ts.map +1 -0
  136. package/lib/esm/types/getQuote.d.ts +9 -0
  137. package/lib/esm/types/getQuote.d.ts.map +1 -0
  138. package/lib/esm/types/getSuiPrice.d.ts +2 -0
  139. package/lib/esm/types/getSuiPrice.d.ts.map +1 -0
  140. package/lib/esm/types/index.d.ts +17 -0
  141. package/lib/esm/types/index.d.ts.map +1 -0
  142. package/lib/esm/types/libs/getCoinOjectIdsByAmount.d.ts +7 -0
  143. package/lib/esm/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -0
  144. package/lib/esm/types/libs/getSplitCoinForTx.d.ts +6 -0
  145. package/lib/esm/types/libs/getSplitCoinForTx.d.ts.map +1 -0
  146. package/lib/esm/types/libs/groupSwapRoutes.d.ts +3 -0
  147. package/lib/esm/types/libs/groupSwapRoutes.d.ts.map +1 -0
  148. package/lib/esm/types/libs/protocols/aftermath/index.d.ts +10 -0
  149. package/lib/esm/types/libs/protocols/aftermath/index.d.ts.map +1 -0
  150. package/lib/esm/types/libs/protocols/base.d.ts +37 -0
  151. package/lib/esm/types/libs/protocols/base.d.ts.map +1 -0
  152. package/lib/esm/types/libs/protocols/bluemove/index.d.ts +10 -0
  153. package/lib/esm/types/libs/protocols/bluemove/index.d.ts.map +1 -0
  154. package/lib/esm/types/libs/protocols/cetus/index.d.ts +10 -0
  155. package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +1 -0
  156. package/lib/esm/types/libs/protocols/constants.d.ts +3 -0
  157. package/lib/esm/types/libs/protocols/constants.d.ts.map +1 -0
  158. package/lib/esm/types/libs/protocols/deepbook/index.d.ts +12 -0
  159. package/lib/esm/types/libs/protocols/deepbook/index.d.ts.map +1 -0
  160. package/lib/esm/types/libs/protocols/flowx/index.d.ts +10 -0
  161. package/lib/esm/types/libs/protocols/flowx/index.d.ts.map +1 -0
  162. package/lib/esm/types/libs/protocols/index.d.ts +19 -0
  163. package/lib/esm/types/libs/protocols/index.d.ts.map +1 -0
  164. package/lib/esm/types/libs/protocols/kriya/index.d.ts +10 -0
  165. package/lib/esm/types/libs/protocols/kriya/index.d.ts.map +1 -0
  166. package/lib/esm/types/libs/protocols/suiswap/index.d.ts +10 -0
  167. package/lib/esm/types/libs/protocols/suiswap/index.d.ts.map +1 -0
  168. package/lib/esm/types/libs/protocols/turbos/constants.d.ts +5 -0
  169. package/lib/esm/types/libs/protocols/turbos/constants.d.ts.map +1 -0
  170. package/lib/esm/types/libs/protocols/turbos/index.d.ts +10 -0
  171. package/lib/esm/types/libs/protocols/turbos/index.d.ts.map +1 -0
  172. package/lib/esm/types/libs/protocols/utils.d.ts +3 -0
  173. package/lib/esm/types/libs/protocols/utils.d.ts.map +1 -0
  174. package/lib/esm/types/libs/swapWithRoute.d.ts +10 -0
  175. package/lib/esm/types/libs/swapWithRoute.d.ts.map +1 -0
  176. package/lib/esm/types/sui.js +1 -0
  177. package/lib/esm/types/suiClient.d.ts +4 -0
  178. package/lib/esm/types/suiClient.d.ts.map +1 -0
  179. package/lib/esm/types/token.js +1 -0
  180. package/lib/esm/types/tx.js +1 -0
  181. package/lib/esm/types/types/aggregator.d.ts +69 -0
  182. package/lib/esm/types/types/aggregator.d.ts.map +1 -0
  183. package/lib/esm/types/types/sui.d.ts +4 -0
  184. package/lib/esm/types/types/sui.d.ts.map +1 -0
  185. package/lib/esm/types/types/token.d.ts +30 -0
  186. package/lib/esm/types/types/token.d.ts.map +1 -0
  187. package/lib/esm/types/types/tx.d.ts +14 -0
  188. package/lib/esm/types/types/tx.d.ts.map +1 -0
  189. package/lib/esm/types/types/utilities.d.ts +5 -0
  190. package/lib/esm/types/types/utilities.d.ts.map +1 -0
  191. package/lib/esm/types/utilities.js +1 -0
  192. package/lib/esm/types/utils/number.d.ts +4 -0
  193. package/lib/esm/types/utils/number.d.ts.map +1 -0
  194. package/lib/esm/types/utils/sui.d.ts +39 -0
  195. package/lib/esm/types/utils/sui.d.ts.map +1 -0
  196. package/lib/esm/types/utils/token.d.ts +6 -0
  197. package/lib/esm/types/utils/token.d.ts.map +1 -0
  198. package/lib/esm/utils/number.js +8 -0
  199. package/lib/esm/utils/sui.js +167 -0
  200. package/lib/esm/utils/token.js +19 -0
  201. package/package.json +70 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,EAAE,qBAAqB,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,8BAAsB,YAAY;IAChC,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC9B,SAAS,CAAC,eAAe,EAAE,qBAAqB,CAAC;IACjD,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;gBAErB,EACV,QAAQ,EACR,eAAe,EACf,cAAc,GACf,EAAE,kBAAkB;IAMrB,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,gBAAgB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAEnE,SAAS,CAAC,iBAAiB,CAAC,EAAE,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;IAQhD,SAAS,CAAC,aAAa;CAKxB"}
@@ -0,0 +1,10 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { BaseContract } from "../base";
3
+ export declare class BluemoveContract extends BaseContract {
4
+ swap(tx: TransactionBlock): Promise<{
5
+ index: number;
6
+ resultIndex: number;
7
+ kind: "NestedResult";
8
+ }>;
9
+ }
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/bluemove/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;CAoBhC"}
@@ -0,0 +1,10 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { BaseContract } from "../base";
3
+ export declare class CetusContract extends BaseContract {
4
+ swap(tx: TransactionBlock): Promise<{
5
+ index: number;
6
+ resultIndex: number;
7
+ kind: "NestedResult";
8
+ }>;
9
+ }
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/cetus/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAWvC,qBAAa,aAAc,SAAQ,YAAY;IACvC,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;CAyChC"}
@@ -0,0 +1,3 @@
1
+ export declare const MIN_SQRT_PRICE = "4295048016";
2
+ export declare const MAX_SQRT_PRICE = "79226673515401279992447579055";
3
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,eAAe,CAAC;AAC3C,eAAO,MAAM,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { BaseContract } from "../base";
3
+ export declare class DeepBookContract extends BaseContract {
4
+ swap(tx: TransactionBlock): Promise<{
5
+ index: number;
6
+ resultIndex: number;
7
+ kind: "NestedResult";
8
+ }>;
9
+ private createAccountCap;
10
+ private deleteAccountCap;
11
+ }
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/deepbook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAOvC,qBAAa,gBAAiB,SAAQ,YAAY;IAC1C,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;IA+D/B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;CAMzB"}
@@ -0,0 +1,10 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { BaseContract } from "../base";
3
+ export declare class FlowXContract extends BaseContract {
4
+ swap(tx: TransactionBlock): Promise<{
5
+ index: number;
6
+ resultIndex: number;
7
+ kind: "NestedResult";
8
+ }>;
9
+ }
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/flowx/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQvC,qBAAa,aAAc,SAAQ,YAAY;IACvC,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;CAYhC"}
@@ -0,0 +1,19 @@
1
+ import { FlowXContract } from "./flowx";
2
+ import { AfterMathContract } from "./aftermath";
3
+ import { CetusContract } from "./cetus";
4
+ import { DeepBookContract } from "./deepbook";
5
+ import { KriyaContract } from "./kriya";
6
+ import { TurbosContract } from "./turbos";
7
+ import { SuiswapContract } from "./suiswap";
8
+ import { BluemoveContract } from "./bluemove";
9
+ export declare const ProtocolContract: {
10
+ cetus: typeof CetusContract;
11
+ turbos: typeof TurbosContract;
12
+ bluemove: typeof BluemoveContract;
13
+ kriya: typeof KriyaContract;
14
+ suiswap: typeof SuiswapContract;
15
+ aftermath: typeof AfterMathContract;
16
+ deepbook: typeof DeepBookContract;
17
+ flowx: typeof FlowXContract;
18
+ };
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,gBAAgB;;;;;;;;;CAS5B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { BaseContract } from "../base";
3
+ export declare class KriyaContract extends BaseContract {
4
+ swap(tx: TransactionBlock): Promise<{
5
+ index: number;
6
+ resultIndex: number;
7
+ kind: "NestedResult";
8
+ }>;
9
+ }
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/kriya/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAOvC,qBAAa,aAAc,SAAQ,YAAY;IACvC,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;CAyBhC"}
@@ -0,0 +1,10 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { BaseContract } from "../base";
3
+ export declare class SuiswapContract extends BaseContract {
4
+ swap(tx: TransactionBlock): Promise<{
5
+ index: number;
6
+ resultIndex: number;
7
+ kind: "NestedResult";
8
+ }>;
9
+ }
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/suiswap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,eAAgB,SAAQ,YAAY;IACzC,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;CA2BhC"}
@@ -0,0 +1,5 @@
1
+ export declare const MAX_TICK_STEP = 100;
2
+ export declare const MAX_TICK_INDEX = 443636;
3
+ export declare const MIN_TICK_INDEX = -443636;
4
+ export declare const ONE_MINUTE: number;
5
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/turbos/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,eAAO,MAAM,UAAU,QAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { BaseContract } from "../base";
3
+ export declare class TurbosContract extends BaseContract {
4
+ swap(tx: TransactionBlock): Promise<{
5
+ index: number;
6
+ resultIndex: number;
7
+ kind: "NestedResult";
8
+ }>;
9
+ }
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/libs/protocols/turbos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAUvC,qBAAa,cAAe,SAAQ,YAAY;IACxC,IAAI,CAAC,EAAE,EAAE,gBAAgB;;;;;CAqChC"}
@@ -0,0 +1,3 @@
1
+ import BN from "bn.js";
2
+ export declare function getDefaultSqrtPriceLimit(a2b: boolean): BN;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/libs/protocols/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,OAAO,CAAC;AAGvB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,EAAE,CAEzD"}
@@ -0,0 +1,10 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { TxSorSwap } from "../types/aggregator";
3
+ import { TransactionResultItem } from "../types/sui";
4
+ export declare function swapWithRoute({ route, inputCoinObject, currentAccount, tx, }: {
5
+ route: TxSorSwap[];
6
+ inputCoinObject: TransactionResultItem;
7
+ currentAccount: string;
8
+ tx: TransactionBlock;
9
+ }): Promise<TransactionResultItem | undefined>;
10
+ //# sourceMappingURL=swapWithRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swapWithRoute.d.ts","sourceRoot":"","sources":["../../../../src/libs/swapWithRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,eAAe,EACf,cAAc,EACd,EAAE,GACH,EAAE;IACD,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,eAAe,EAAE,qBAAqB,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,EAAE,EAAE,gBAAgB,CAAC;CACtB,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAiB7C"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import { SuiClient } from "@mysten/sui.js/client";
2
+ export declare function getSuiClient(): SuiClient;
3
+ export declare function setSuiClient(client: SuiClient): void;
4
+ //# sourceMappingURL=suiClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suiClient.d.ts","sourceRoot":"","sources":["../../../src/suiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,uBAAuB,CAAC;AAMlE,wBAAgB,YAAY,cAE3B;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,QAE7C"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,69 @@
1
+ export type SourceDex = "suiswap" | "turbos" | "cetus" | "bluemove" | "kriya" | "aftermath" | "deepbook" | "flowx";
2
+ export type SorSwap = {
3
+ poolId: string;
4
+ assetInIndex: number;
5
+ assetOutIndex: number;
6
+ amount: string;
7
+ returnAmount: string;
8
+ assetIn: string;
9
+ assetOut: string;
10
+ functionName: string;
11
+ arguments: string[];
12
+ extra?: any;
13
+ };
14
+ export type SorPool = {
15
+ allTokens: Array<{
16
+ address: string;
17
+ decimal: number;
18
+ }>;
19
+ type: SourceDex;
20
+ };
21
+ export type SorHop = {
22
+ poolId: string;
23
+ tokenInAmount: string;
24
+ tokenOutAmount: string;
25
+ tokenIn: string;
26
+ tokenOut: string;
27
+ pool: SorPool;
28
+ };
29
+ export type SorRoute = {
30
+ hops: SorHop[];
31
+ share?: number;
32
+ tokenIn: string;
33
+ tokenInAmount: string;
34
+ tokenOut: string;
35
+ tokenOutAmount: string;
36
+ };
37
+ export type QuoteResponse = {
38
+ effectivePrice: number | null;
39
+ effectivePriceReserved: number | null;
40
+ priceImpact: number | null;
41
+ swapAmount: string;
42
+ returnAmount: string;
43
+ returnAmountWithDecimal: string;
44
+ returnAmountConsiderGasFees?: string;
45
+ returnAmountWithoutSwapFees?: string;
46
+ swapAmountWithDecimal: string;
47
+ tokenAddresses: string[];
48
+ tokenIn: string;
49
+ tokenOut: string;
50
+ marketSp: string;
51
+ routes?: SorRoute[];
52
+ swaps: SorSwap[];
53
+ warning: string;
54
+ };
55
+ export interface Coin {
56
+ type: string;
57
+ decimals: number;
58
+ }
59
+ export interface TxSorSwap extends SorSwap {
60
+ pool: SorPool;
61
+ coinX: Coin;
62
+ coinY: Coin;
63
+ swapXtoY: boolean;
64
+ }
65
+ export interface Commission {
66
+ partner: string;
67
+ commissionBps: number;
68
+ }
69
+ //# sourceMappingURL=aggregator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregator.d.ts","sourceRoot":"","sources":["../../../../src/types/aggregator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,UAAU,GACV,OAAO,GACP,WAAW,GACX,UAAU,GACV,OAAO,CAAC;AAEZ,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,uBAAuB,EAAE,MAAM,CAAC;IAChC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAU,SAAQ,OAAO;IACxC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,IAAI,CAAC;IACZ,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,4 @@
1
+ import { TransactionResult } from "@mysten/sui.js/transactions";
2
+ import { Unarray } from "./utilities";
3
+ export type TransactionResultItem = Unarray<TransactionResult>;
4
+ //# sourceMappingURL=sui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/types/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ export interface SuiscanToken {
2
+ type: string;
3
+ objectId: string;
4
+ name: string;
5
+ supply: number | null;
6
+ supplyInUsd: number | null;
7
+ tokenPrice: number | null;
8
+ dominance: number | null;
9
+ circulatingSupply: number | null;
10
+ marketCap: number | null;
11
+ totalVolume: number | null;
12
+ maxSupply: number | null;
13
+ fdv: number | null;
14
+ holders: number | null;
15
+ denom: string;
16
+ packageId: string;
17
+ createTimestamp: number;
18
+ creator: string;
19
+ creatorName: string | null;
20
+ creatorImg: string | null;
21
+ creatorScamMessage: string | null;
22
+ scamMessage: string | null;
23
+ decimals: number;
24
+ symbol: string;
25
+ iconUrl: string | null;
26
+ description: string;
27
+ bridge: boolean;
28
+ verified: boolean;
29
+ }
30
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../src/types/token.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB"}
@@ -0,0 +1,14 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { Commission, QuoteResponse } from "./aggregator";
3
+ import BigNumber from "bignumber.js";
4
+ export interface BuildTxParams {
5
+ tx?: TransactionBlock;
6
+ quoteResponse: QuoteResponse;
7
+ accountAddress: string;
8
+ slippage: BigNumber.Value;
9
+ commission?: Commission;
10
+ }
11
+ export interface EstimateGasFeeParams extends BuildTxParams {
12
+ suiPrice?: number;
13
+ }
14
+ //# sourceMappingURL=tx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../../src/types/tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,gBAAgB,CAAC;IACtB,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,5 @@
1
+ export type ValueOf<T> = T[keyof T];
2
+ export type PropName<T> = keyof T;
3
+ export type Unarray<T> = T extends Array<infer U> ? U : T;
4
+ export type Modify<T, R extends Partial<T>> = Omit<T, keyof R> & R;
5
+ //# sourceMappingURL=utilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../src/types/utilities.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACpC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAClC,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC1D,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import BigNumber from "bignumber.js";
2
+ export declare function formatBalance(balance: BigNumber.Value, decimals: number): BigNumber;
3
+ export declare function formatRawBalance(balance: BigNumber.Value, decimals: number): BigNumber;
4
+ //# sourceMappingURL=number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../../src/utils/number.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,aAEvE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,aAK1E"}
@@ -0,0 +1,39 @@
1
+ import { TransactionArgument, TransactionBlock } from "@mysten/sui.js/transactions";
2
+ import { CoinStruct, SuiObjectResponseQuery } from "@mysten/sui.js/client";
3
+ type DataPage<T> = {
4
+ data: T[];
5
+ nextCursor?: any;
6
+ hasNextPage: boolean;
7
+ };
8
+ type PageQuery = {
9
+ cursor?: any;
10
+ limit?: number | null;
11
+ };
12
+ type PaginationArgs = "all" | PageQuery;
13
+ export declare const SuiUtils: {
14
+ getSuiCoin(amount: bigint | TransactionArgument, txb: TransactionBlock): TransactionArgument;
15
+ mergeCoins(coinObjects: Array<string | TransactionArgument>, txb: TransactionBlock): TransactionArgument | undefined;
16
+ getCoinValue(coinType: string, coinObject: string | TransactionArgument, txb: TransactionBlock): TransactionArgument;
17
+ getExactCoinByAmount(coinType: string, coins: {
18
+ objectId: string;
19
+ balance: bigint;
20
+ }[], amount: bigint, txb: TransactionBlock): {
21
+ index: number;
22
+ resultIndex: number;
23
+ kind: "NestedResult";
24
+ };
25
+ mergeAllUserCoins(coinType: string, signerAddress: string): Promise<TransactionBlock | undefined>;
26
+ mergeAllCoinsWithoutFetch(coins: CoinStruct[], coinType: string, txb: TransactionBlock): void;
27
+ getAllUserCoins({ address, type }: {
28
+ type: string;
29
+ address: string;
30
+ }): Promise<CoinStruct[]>;
31
+ getCoinsGreaterThanAmount(amount: bigint, coins: {
32
+ objectId: string;
33
+ balance: bigint;
34
+ }[]): string[];
35
+ getOwnedObjectsByPage(owner: string, query: SuiObjectResponseQuery, paginationArgs?: PaginationArgs): Promise<DataPage<any>>;
36
+ isValidStructTag(value: string): boolean;
37
+ };
38
+ export {};
39
+ //# sourceMappingURL=sui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../../../src/utils/sui.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,UAAU,EAEV,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAK/B,KAAK,QAAQ,CAAC,CAAC,IAAI;IACjB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,KAAK,cAAc,GAAG,KAAK,GAAG,SAAS,CAAC;AAExC,eAAO,MAAM,QAAQ;uBAET,MAAM,GAAG,mBAAmB,OAC/B,gBAAgB,GACpB,mBAAmB;4BAQP,KAAK,CAAC,MAAM,GAAG,mBAAmB,CAAC,OAC3C,gBAAgB,GACpB,mBAAmB,GAAG,SAAS;2BAsBtB,MAAM,cACJ,MAAM,GAAG,mBAAmB,OACnC,gBAAgB,GACpB,mBAAmB;mCAYV,MAAM,SACT;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,UACtC,MAAM,OACT,gBAAgB;;;;;gCAoBW,MAAM,iBAAiB,MAAM;qCAoCtD,UAAU,EAAE,YACT,MAAM,OACX,gBAAgB;uCAsBkB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;sCA8BhE,MAAM,SACP;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE;iCA6BvC,MAAM,SACN,sBAAsB,mBACb,cAAc,GAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;4BAyBD,MAAM;CAO/B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { SuiscanToken } from "../types/token";
2
+ export declare function normalizeTokenType(type: string): string;
3
+ export declare function denormalizeTokenType(type: string): string;
4
+ export declare function checkIsSui(type: string): type is "0x2::sui::SUI" | "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
5
+ export declare function getSuiscanTokenMetadata(type: string): Promise<SuiscanToken>;
6
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../src/utils/token.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,UAE9C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,UAEhD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,4GAEtC;AAED,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,yBASzD"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.formatBalance = formatBalance;
7
+ exports.formatRawBalance = formatRawBalance;
8
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
9
+ function formatBalance(balance, decimals) {
10
+ return new bignumber_js_1.default(balance).dividedBy(new bignumber_js_1.default(10).pow(decimals));
11
+ }
12
+ function formatRawBalance(balance, decimals) {
13
+ const rawBalance = new bignumber_js_1.default(balance).multipliedBy(new bignumber_js_1.default(10).pow(decimals));
14
+ return new bignumber_js_1.default(rawBalance.toFixed(0));
15
+ }
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SuiUtils = void 0;
13
+ const transactions_1 = require("@mysten/sui.js/transactions");
14
+ const utils_1 = require("@mysten/sui.js/utils");
15
+ const token_1 = require("./token");
16
+ const suiClient_1 = require("../suiClient");
17
+ exports.SuiUtils = {
18
+ getSuiCoin(amount, txb) {
19
+ const inputCoinAmount = typeof amount === "bigint" ? txb.pure(amount) : amount;
20
+ const [coin] = txb.splitCoins(txb.gas, [inputCoinAmount]);
21
+ return coin;
22
+ },
23
+ mergeCoins(coinObjects, txb) {
24
+ if (coinObjects.length == 1) {
25
+ return typeof coinObjects[0] == "string"
26
+ ? txb.object(coinObjects[0])
27
+ : coinObjects[0];
28
+ }
29
+ const firstCoin = typeof coinObjects[0] == "string"
30
+ ? txb.object(coinObjects[0])
31
+ : coinObjects[0];
32
+ txb.mergeCoins(
33
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34
+ // @ts-ignore
35
+ firstCoin, coinObjects
36
+ .slice(1)
37
+ .map((coin) => (typeof coin == "string" ? txb.object(coin) : coin)));
38
+ return firstCoin;
39
+ },
40
+ getCoinValue(coinType, coinObject, txb) {
41
+ const inputCoinObject = typeof coinObject == "string" ? txb.object(coinObject) : coinObject;
42
+ const [value] = txb.moveCall({
43
+ target: `0x2::coin::value`,
44
+ typeArguments: [coinType],
45
+ arguments: [inputCoinObject],
46
+ });
47
+ return value;
48
+ },
49
+ getExactCoinByAmount(coinType, coins, amount, txb) {
50
+ if ((0, token_1.checkIsSui)(coinType)) {
51
+ const [coinA] = txb.splitCoins(txb.gas, [txb.pure(amount)]);
52
+ return coinA;
53
+ }
54
+ else {
55
+ const coinsX = exports.SuiUtils.getCoinsGreaterThanAmount(amount, coins);
56
+ if (coinsX.length > 1) {
57
+ txb.mergeCoins(txb.object(coinsX[0]), coinsX.slice(1).map((coin) => txb.object(coin)));
58
+ }
59
+ const [coinA] = txb.splitCoins(txb.object(coinsX[0]), [txb.pure(amount)]);
60
+ return coinA;
61
+ }
62
+ },
63
+ mergeAllUserCoins(coinType, signerAddress) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ try {
66
+ const coins = yield exports.SuiUtils.getAllUserCoins({
67
+ address: signerAddress,
68
+ type: coinType,
69
+ });
70
+ let totalBalance = BigInt(0);
71
+ coins.forEach((coin) => {
72
+ totalBalance += BigInt(coin.balance);
73
+ });
74
+ const txb = new transactions_1.TransactionBlock();
75
+ if ((0, token_1.checkIsSui)(coinType)) {
76
+ totalBalance = totalBalance - BigInt("1000");
77
+ txb.splitCoins(txb.gas, [txb.pure(totalBalance.toString())]);
78
+ }
79
+ const coinObjectsIds = coins.map((coin) => coin.coinObjectId);
80
+ if (coins.length > 1) {
81
+ txb.mergeCoins(txb.object(coinObjectsIds[0]), coinObjectsIds.slice(1).map((coin) => txb.object(coin)));
82
+ }
83
+ return txb;
84
+ }
85
+ catch (error) {
86
+ console.log(error);
87
+ }
88
+ });
89
+ },
90
+ mergeAllCoinsWithoutFetch(coins, coinType, txb) {
91
+ let totalBalance = BigInt(0);
92
+ coins.forEach((coin) => {
93
+ totalBalance += BigInt(coin.balance);
94
+ });
95
+ if ((0, token_1.checkIsSui)(coinType)) {
96
+ totalBalance = totalBalance - BigInt("1000");
97
+ txb.splitCoins(txb.gas, [txb.pure(totalBalance.toString())]);
98
+ }
99
+ const coinObjectsIds = coins.map((coin) => coin.coinObjectId);
100
+ if (coins.length > 1) {
101
+ txb.mergeCoins(txb.object(coinObjectsIds[0]), coinObjectsIds.slice(1).map((coin) => txb.object(coin)));
102
+ }
103
+ },
104
+ getAllUserCoins(_a) {
105
+ return __awaiter(this, arguments, void 0, function* ({ address, type }) {
106
+ let cursor = undefined;
107
+ let coins = [];
108
+ let iter = 0;
109
+ do {
110
+ try {
111
+ const res = yield (0, suiClient_1.getSuiClient)().getCoins({
112
+ owner: address,
113
+ coinType: type,
114
+ cursor: cursor,
115
+ limit: 50,
116
+ });
117
+ coins = coins.concat(res.data);
118
+ cursor = res.nextCursor;
119
+ if (!res.hasNextPage || iter === 8) {
120
+ cursor = null;
121
+ }
122
+ }
123
+ catch (error) {
124
+ console.log(error);
125
+ cursor = null;
126
+ }
127
+ iter++;
128
+ } while (cursor !== null);
129
+ return coins;
130
+ });
131
+ },
132
+ getCoinsGreaterThanAmount(amount, coins) {
133
+ const coinsWithBalance = [];
134
+ let collectedAmount = BigInt(0);
135
+ for (const coin of coins) {
136
+ if (collectedAmount < amount &&
137
+ !coinsWithBalance.includes(coin.objectId)) {
138
+ coinsWithBalance.push(coin.objectId);
139
+ collectedAmount = collectedAmount + coin.balance;
140
+ }
141
+ if (coin.balance === BigInt(0) &&
142
+ !coinsWithBalance.includes(coin.objectId))
143
+ coinsWithBalance.push(coin.objectId);
144
+ }
145
+ if (collectedAmount >= amount) {
146
+ return coinsWithBalance;
147
+ }
148
+ else {
149
+ throw new Error("Insufficient balance");
150
+ }
151
+ },
152
+ getOwnedObjectsByPage(owner_1, query_1) {
153
+ return __awaiter(this, arguments, void 0, function* (owner, query, paginationArgs = "all") {
154
+ let result = [];
155
+ let hasNextPage = true;
156
+ const queryAll = paginationArgs === "all";
157
+ let nextCursor = queryAll ? null : paginationArgs.cursor;
158
+ do {
159
+ const res = yield (0, suiClient_1.getSuiClient)().getOwnedObjects(Object.assign(Object.assign({ owner }, query), { cursor: nextCursor, limit: queryAll ? null : paginationArgs.limit }));
160
+ if (res.data) {
161
+ result = [...result, ...res.data];
162
+ hasNextPage = res.hasNextPage;
163
+ nextCursor = res.nextCursor;
164
+ }
165
+ else {
166
+ hasNextPage = false;
167
+ }
168
+ } while (queryAll && hasNextPage);
169
+ return { data: result, nextCursor, hasNextPage };
170
+ });
171
+ },
172
+ isValidStructTag(value) {
173
+ try {
174
+ return !!(0, utils_1.parseStructTag)(value);
175
+ }
176
+ catch (error) {
177
+ return false;
178
+ }
179
+ },
180
+ };