@7kprotocol/sdk-ts 2.4.0 → 2.4.2-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 (207) hide show
  1. package/README.md +30 -3
  2. package/lib/cjs/config/fetchClient.js +11 -19
  3. package/lib/cjs/config/index.js +22 -0
  4. package/lib/cjs/constants/_7k.js +6 -3
  5. package/lib/cjs/features/limitDca/cancelDcaOrder.js +7 -18
  6. package/lib/cjs/features/limitDca/cancelLimitOrder.js +7 -18
  7. package/lib/cjs/features/limitDca/claimExpiredLimitOrder.js +7 -18
  8. package/lib/cjs/features/limitDca/constants.js +1 -5
  9. package/lib/cjs/features/limitDca/getClosedDcaOrders.js +16 -27
  10. package/lib/cjs/features/limitDca/getClosedLimitOrders.js +15 -26
  11. package/lib/cjs/features/limitDca/getDcaOrderExecutions.js +16 -27
  12. package/lib/cjs/features/limitDca/getOpenDcaOrders.js +15 -26
  13. package/lib/cjs/features/limitDca/getOpenLimitOrders.js +15 -26
  14. package/lib/cjs/features/limitDca/placeDcaOrder.js +25 -36
  15. package/lib/cjs/features/limitDca/placeLimitOrder.js +14 -25
  16. package/lib/cjs/features/prices/index.js +47 -64
  17. package/lib/cjs/features/swap/buildTx.js +88 -39
  18. package/lib/cjs/features/swap/config.js +32 -32
  19. package/lib/cjs/features/swap/estimateGasFee.js +36 -46
  20. package/lib/cjs/features/swap/executeTx.js +52 -0
  21. package/lib/cjs/features/swap/getQuote.js +41 -31
  22. package/lib/cjs/features/swap/getSwapHistory.js +14 -25
  23. package/lib/cjs/features/swap/index.js +1 -0
  24. package/lib/cjs/index.js +16 -9
  25. package/lib/cjs/libs/getCoinOjectIdsByAmount.js +15 -24
  26. package/lib/cjs/libs/getSplitCoinForTx.js +8 -15
  27. package/lib/cjs/libs/groupSwapRoutes.js +10 -12
  28. package/lib/cjs/libs/protocols/aftermath/index.js +25 -36
  29. package/lib/cjs/libs/protocols/base.js +10 -3
  30. package/lib/cjs/libs/protocols/bluefin/index.js +26 -43
  31. package/lib/cjs/libs/protocols/bluefinx/client.js +35 -0
  32. package/lib/cjs/libs/protocols/bluefinx/index.js +48 -0
  33. package/lib/cjs/libs/protocols/bluefinx/types.js +10 -0
  34. package/lib/cjs/libs/protocols/bluemove/index.js +14 -25
  35. package/lib/cjs/libs/protocols/cetus/index.js +32 -43
  36. package/lib/cjs/libs/protocols/deepbookV3/sponsored.js +19 -30
  37. package/lib/cjs/libs/protocols/flowx/index.js +9 -20
  38. package/lib/cjs/libs/protocols/flowxV3/index.js +25 -39
  39. package/lib/cjs/libs/protocols/haedal_pmm/index.js +33 -0
  40. package/lib/cjs/libs/protocols/index.js +7 -2
  41. package/lib/cjs/libs/protocols/kriya/index.js +20 -31
  42. package/lib/cjs/libs/protocols/kriyaV3/index.js +54 -65
  43. package/lib/cjs/libs/protocols/magma/index.js +28 -40
  44. package/lib/cjs/libs/protocols/momentum/index.js +49 -0
  45. package/lib/cjs/libs/protocols/obric/index.js +20 -31
  46. package/lib/cjs/libs/protocols/springsui/index.js +14 -25
  47. package/lib/cjs/libs/protocols/steamm/index.js +57 -58
  48. package/lib/cjs/libs/protocols/stsui/index.js +14 -25
  49. package/lib/cjs/libs/protocols/suiswap/index.js +23 -34
  50. package/lib/cjs/libs/protocols/turbos/index.js +23 -38
  51. package/lib/cjs/libs/protocols/utils.js +1 -5
  52. package/lib/cjs/libs/swapWithRoute.js +17 -27
  53. package/lib/cjs/types/aggregator.js +17 -0
  54. package/lib/cjs/types/config/index.d.ts +9 -0
  55. package/lib/cjs/types/config/index.d.ts.map +1 -1
  56. package/lib/cjs/types/constants/_7k.d.ts +3 -3
  57. package/lib/cjs/types/constants/_7k.d.ts.map +1 -1
  58. package/lib/cjs/types/features/limitDca/constants.d.ts +1 -2
  59. package/lib/cjs/types/features/limitDca/constants.d.ts.map +1 -1
  60. package/lib/cjs/types/features/swap/buildTx.d.ts +2 -5
  61. package/lib/cjs/types/features/swap/buildTx.d.ts.map +1 -1
  62. package/lib/cjs/types/features/swap/config.d.ts.map +1 -1
  63. package/lib/cjs/types/features/swap/estimateGasFee.d.ts.map +1 -1
  64. package/lib/cjs/types/features/swap/executeTx.d.ts +24 -0
  65. package/lib/cjs/types/features/swap/executeTx.d.ts.map +1 -0
  66. package/lib/cjs/types/features/swap/getQuote.d.ts +8 -1
  67. package/lib/cjs/types/features/swap/getQuote.d.ts.map +1 -1
  68. package/lib/cjs/types/features/swap/index.d.ts +1 -0
  69. package/lib/cjs/types/features/swap/index.d.ts.map +1 -1
  70. package/lib/cjs/types/index.d.ts +13 -8
  71. package/lib/cjs/types/index.d.ts.map +1 -1
  72. package/lib/cjs/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -1
  73. package/lib/cjs/types/libs/getSplitCoinForTx.d.ts +1 -1
  74. package/lib/cjs/types/libs/getSplitCoinForTx.d.ts.map +1 -1
  75. package/lib/cjs/types/libs/groupSwapRoutes.d.ts.map +1 -1
  76. package/lib/cjs/types/libs/protocols/base.d.ts +6 -2
  77. package/lib/cjs/types/libs/protocols/base.d.ts.map +1 -1
  78. package/lib/cjs/types/libs/protocols/bluefin/index.d.ts.map +1 -1
  79. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts +13 -0
  80. package/lib/cjs/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
  81. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts +17 -0
  82. package/lib/cjs/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
  83. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts +34 -0
  84. package/lib/cjs/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
  85. package/lib/cjs/types/libs/protocols/cetus/index.d.ts.map +1 -1
  86. package/lib/cjs/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
  87. package/lib/cjs/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
  88. package/lib/{esm/types/libs/protocols/deepbook → cjs/types/libs/protocols/haedal_pmm}/index.d.ts +1 -3
  89. package/lib/cjs/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
  90. package/lib/cjs/types/libs/protocols/index.d.ts +7 -2
  91. package/lib/cjs/types/libs/protocols/index.d.ts.map +1 -1
  92. package/lib/cjs/types/libs/protocols/magma/index.d.ts.map +1 -1
  93. package/lib/cjs/types/libs/protocols/{deepbook → momentum}/index.d.ts +1 -3
  94. package/lib/cjs/types/libs/protocols/momentum/index.d.ts.map +1 -0
  95. package/lib/cjs/types/libs/protocols/steamm/index.d.ts +13 -2
  96. package/lib/cjs/types/libs/protocols/steamm/index.d.ts.map +1 -1
  97. package/lib/cjs/types/libs/protocols/suiswap/index.d.ts.map +1 -1
  98. package/lib/cjs/types/libs/protocols/turbos/index.d.ts.map +1 -1
  99. package/lib/cjs/types/libs/protocols/utils.d.ts +1 -2
  100. package/lib/cjs/types/libs/protocols/utils.d.ts.map +1 -1
  101. package/lib/cjs/types/libs/swapWithRoute.d.ts +3 -1
  102. package/lib/cjs/types/libs/swapWithRoute.d.ts.map +1 -1
  103. package/lib/cjs/types/types/aggregator.d.ts +36 -2
  104. package/lib/cjs/types/types/aggregator.d.ts.map +1 -1
  105. package/lib/cjs/types/types/tx.d.ts +36 -2
  106. package/lib/cjs/types/types/tx.d.ts.map +1 -1
  107. package/lib/cjs/types/utils/number.d.ts +1 -3
  108. package/lib/cjs/types/utils/number.d.ts.map +1 -1
  109. package/lib/cjs/types/utils/sui.d.ts +1 -1
  110. package/lib/cjs/types/utils/sui.d.ts.map +1 -1
  111. package/lib/cjs/utils/number.js +4 -10
  112. package/lib/cjs/utils/sui.js +71 -80
  113. package/lib/esm/config/index.js +22 -0
  114. package/lib/esm/constants/_7k.js +6 -3
  115. package/lib/esm/features/limitDca/constants.js +1 -2
  116. package/lib/esm/features/swap/buildTx.js +81 -20
  117. package/lib/esm/features/swap/config.js +19 -8
  118. package/lib/esm/features/swap/estimateGasFee.js +13 -9
  119. package/lib/esm/features/swap/executeTx.js +48 -0
  120. package/lib/esm/features/swap/getQuote.js +24 -3
  121. package/lib/esm/features/swap/index.js +1 -0
  122. package/lib/esm/index.mjs +8 -4
  123. package/lib/esm/libs/getCoinOjectIdsByAmount.js +7 -7
  124. package/lib/esm/libs/getSplitCoinForTx.js +5 -3
  125. package/lib/esm/libs/groupSwapRoutes.js +1 -2
  126. package/lib/esm/libs/protocols/base.js +10 -1
  127. package/lib/esm/libs/protocols/bluefin/index.js +2 -5
  128. package/lib/esm/libs/protocols/bluefinx/client.js +30 -0
  129. package/lib/esm/libs/protocols/bluefinx/index.js +44 -0
  130. package/lib/esm/libs/protocols/bluefinx/types.js +8 -0
  131. package/lib/esm/libs/protocols/cetus/index.js +1 -1
  132. package/lib/esm/libs/protocols/deepbookV3/sponsored.js +1 -1
  133. package/lib/esm/libs/protocols/flowxV3/index.js +1 -4
  134. package/lib/esm/libs/protocols/haedal_pmm/index.js +29 -0
  135. package/lib/esm/libs/protocols/index.js +7 -2
  136. package/lib/esm/libs/protocols/magma/index.js +1 -2
  137. package/lib/esm/libs/protocols/momentum/index.js +45 -0
  138. package/lib/esm/libs/protocols/steamm/index.js +58 -48
  139. package/lib/esm/libs/protocols/suiswap/index.js +1 -1
  140. package/lib/esm/libs/protocols/turbos/index.js +2 -6
  141. package/lib/esm/libs/protocols/utils.js +1 -2
  142. package/lib/esm/libs/swapWithRoute.js +2 -1
  143. package/lib/esm/types/aggregator.js +14 -1
  144. package/lib/esm/types/config/index.d.ts +9 -0
  145. package/lib/esm/types/config/index.d.ts.map +1 -1
  146. package/lib/esm/types/constants/_7k.d.ts +3 -3
  147. package/lib/esm/types/constants/_7k.d.ts.map +1 -1
  148. package/lib/esm/types/features/limitDca/constants.d.ts +1 -2
  149. package/lib/esm/types/features/limitDca/constants.d.ts.map +1 -1
  150. package/lib/esm/types/features/swap/buildTx.d.ts +2 -5
  151. package/lib/esm/types/features/swap/buildTx.d.ts.map +1 -1
  152. package/lib/esm/types/features/swap/config.d.ts.map +1 -1
  153. package/lib/esm/types/features/swap/estimateGasFee.d.ts.map +1 -1
  154. package/lib/esm/types/features/swap/executeTx.d.ts +24 -0
  155. package/lib/esm/types/features/swap/executeTx.d.ts.map +1 -0
  156. package/lib/esm/types/features/swap/getQuote.d.ts +8 -1
  157. package/lib/esm/types/features/swap/getQuote.d.ts.map +1 -1
  158. package/lib/esm/types/features/swap/index.d.ts +1 -0
  159. package/lib/esm/types/features/swap/index.d.ts.map +1 -1
  160. package/lib/esm/types/index.d.ts +13 -8
  161. package/lib/esm/types/index.d.ts.map +1 -1
  162. package/lib/esm/types/libs/getCoinOjectIdsByAmount.d.ts.map +1 -1
  163. package/lib/esm/types/libs/getSplitCoinForTx.d.ts +1 -1
  164. package/lib/esm/types/libs/getSplitCoinForTx.d.ts.map +1 -1
  165. package/lib/esm/types/libs/groupSwapRoutes.d.ts.map +1 -1
  166. package/lib/esm/types/libs/protocols/base.d.ts +6 -2
  167. package/lib/esm/types/libs/protocols/base.d.ts.map +1 -1
  168. package/lib/esm/types/libs/protocols/bluefin/index.d.ts.map +1 -1
  169. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts +13 -0
  170. package/lib/esm/types/libs/protocols/bluefinx/client.d.ts.map +1 -0
  171. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts +17 -0
  172. package/lib/esm/types/libs/protocols/bluefinx/index.d.ts.map +1 -0
  173. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts +34 -0
  174. package/lib/esm/types/libs/protocols/bluefinx/types.d.ts.map +1 -0
  175. package/lib/esm/types/libs/protocols/cetus/index.d.ts.map +1 -1
  176. package/lib/esm/types/libs/protocols/deepbookV3/sponsored.d.ts.map +1 -1
  177. package/lib/esm/types/libs/protocols/flowxV3/index.d.ts.map +1 -1
  178. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts +9 -0
  179. package/lib/esm/types/libs/protocols/haedal_pmm/index.d.ts.map +1 -0
  180. package/lib/esm/types/libs/protocols/index.d.ts +7 -2
  181. package/lib/esm/types/libs/protocols/index.d.ts.map +1 -1
  182. package/lib/esm/types/libs/protocols/magma/index.d.ts.map +1 -1
  183. package/lib/esm/types/libs/protocols/momentum/index.d.ts +9 -0
  184. package/lib/esm/types/libs/protocols/momentum/index.d.ts.map +1 -0
  185. package/lib/esm/types/libs/protocols/steamm/index.d.ts +13 -2
  186. package/lib/esm/types/libs/protocols/steamm/index.d.ts.map +1 -1
  187. package/lib/esm/types/libs/protocols/suiswap/index.d.ts.map +1 -1
  188. package/lib/esm/types/libs/protocols/turbos/index.d.ts.map +1 -1
  189. package/lib/esm/types/libs/protocols/utils.d.ts +1 -2
  190. package/lib/esm/types/libs/protocols/utils.d.ts.map +1 -1
  191. package/lib/esm/types/libs/swapWithRoute.d.ts +3 -1
  192. package/lib/esm/types/libs/swapWithRoute.d.ts.map +1 -1
  193. package/lib/esm/types/types/aggregator.d.ts +36 -2
  194. package/lib/esm/types/types/aggregator.d.ts.map +1 -1
  195. package/lib/esm/types/types/tx.d.ts +36 -2
  196. package/lib/esm/types/types/tx.d.ts.map +1 -1
  197. package/lib/esm/types/utils/number.d.ts +1 -3
  198. package/lib/esm/types/utils/number.d.ts.map +1 -1
  199. package/lib/esm/types/utils/sui.d.ts +1 -1
  200. package/lib/esm/types/utils/sui.d.ts.map +1 -1
  201. package/lib/esm/utils/number.js +4 -6
  202. package/lib/esm/utils/sui.js +4 -3
  203. package/package.json +14 -15
  204. package/lib/cjs/libs/protocols/deepbook/index.js +0 -96
  205. package/lib/cjs/types/libs/protocols/deepbook/index.d.ts.map +0 -1
  206. package/lib/esm/libs/protocols/deepbook/index.js +0 -80
  207. package/lib/esm/types/libs/protocols/deepbook/index.d.ts.map +0 -1
@@ -0,0 +1,48 @@
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;
@@ -0,0 +1,10 @@
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,35 +1,24 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.BluemoveContract = void 0;
13
4
  const base_1 = require("../base");
14
5
  const sui_1 = require("../../../utils/sui");
15
6
  class BluemoveContract extends base_1.BaseContract {
16
- swap(tx) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- const config = this.config.bluemove;
19
- const [coinOut] = tx.moveCall({
20
- target: `${config.package}::router::swap_exact_input_`,
21
- typeArguments: [this.swapInfo.assetIn, this.swapInfo.assetOut],
22
- arguments: [
23
- sui_1.SuiUtils.getCoinValue(this.swapInfo.swapXtoY
24
- ? this.swapInfo.coinX.type
25
- : this.swapInfo.coinY.type, this.inputCoinObject, tx), // input amount
26
- this.inputCoinObject, // input coin
27
- tx.pure.u64(0), // min output amount
28
- tx.object(config.dexInfo),
29
- ],
30
- });
31
- return coinOut;
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
+ ],
32
20
  });
21
+ return coinOut;
33
22
  }
34
23
  }
35
24
  exports.BluemoveContract = BluemoveContract;
@@ -1,13 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.CetusContract = void 0;
13
4
  const base_1 = require("../base");
@@ -15,41 +6,39 @@ const utils_1 = require("@mysten/sui/utils");
15
6
  const utils_2 = require("../utils");
16
7
  const sui_1 = require("../../../utils/sui");
17
8
  class CetusContract extends base_1.BaseContract {
18
- swap(tx) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- const sqrtPriceLimit = (0, utils_2.getDefaultSqrtPriceLimit)(this.swapInfo.swapXtoY);
21
- const typeArguments = [this.swapInfo.coinX.type, this.swapInfo.coinY.type];
22
- const [zeroOut] = tx.moveCall({
23
- target: "0x2::coin::zero",
24
- typeArguments: [
25
- this.swapInfo.swapXtoY
26
- ? this.swapInfo.coinY.type
27
- : this.swapInfo.coinX.type,
28
- ],
29
- });
30
- const amountIn = sui_1.SuiUtils.getCoinValue(this.swapInfo.swapXtoY
31
- ? this.swapInfo.coinX.type
32
- : this.swapInfo.coinY.type, this.inputCoinObject, tx);
33
- const config = this.config.cetus;
34
- const [receiveA, receiveB] = tx.moveCall({
35
- target: `${config.package}::router::swap`,
36
- typeArguments,
37
- arguments: [
38
- tx.object(config.globalConfig),
39
- tx.object(this.swapInfo.poolId),
40
- this.swapInfo.swapXtoY ? this.inputCoinObject : zeroOut, // coin A
41
- this.swapInfo.swapXtoY ? zeroOut : this.inputCoinObject, // coin B
42
- tx.pure.bool(this.swapInfo.swapXtoY), // a to b or b to a
43
- tx.pure.bool(true), // exact in or out
44
- amountIn, // swap amount
45
- tx.pure.u128(sqrtPriceLimit.toString()), // sqrt price limit
46
- tx.pure.bool(false),
47
- tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
48
- ],
49
- });
50
- sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, this.swapInfo.swapXtoY ? receiveA : receiveB, this.currentAccount);
51
- return this.swapInfo.swapXtoY ? receiveB : receiveA;
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
+ ],
52
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;
53
42
  }
54
43
  }
55
44
  exports.CetusContract = CetusContract;
@@ -1,41 +1,30 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.SponsoredDeepBookV3Contract = void 0;
13
4
  const base_1 = require("../base");
14
5
  const utils_1 = require("@mysten/sui/utils");
15
6
  const sui_1 = require("../../../utils/sui");
16
7
  class SponsoredDeepBookV3Contract extends base_1.BaseContract {
17
- swap(tx) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- const [coinX] = this.swapInfo.pool.allTokens;
20
- const swapXtoY = (0, utils_1.normalizeStructTag)(coinX.address) ===
21
- (0, utils_1.normalizeStructTag)(this.swapInfo.assetIn);
22
- const config = this.config.deepbook_v3;
23
- const [base, quote] = tx.moveCall({
24
- target: `${config.sponsor}::sponsored::${swapXtoY ? "swap_exact_base_for_quote" : "swap_exact_quote_for_base"}`,
25
- typeArguments: this.getTypeParams(),
26
- arguments: [
27
- tx.object(config.sponsorFund),
28
- tx.object(this.swapInfo.poolId),
29
- this.inputCoinObject,
30
- tx.pure.u64(0),
31
- tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
32
- ],
33
- });
34
- const coinIn = swapXtoY ? base : quote;
35
- const coinOut = swapXtoY ? quote : base;
36
- sui_1.SuiUtils.transferOrDestroyZeroCoin(tx, this.swapInfo.assetIn, coinIn, this.currentAccount);
37
- return coinOut;
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
+ ],
38
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;
39
28
  }
40
29
  }
41
30
  exports.SponsoredDeepBookV3Contract = SponsoredDeepBookV3Contract;
@@ -1,29 +1,18 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.FlowXContract = void 0;
13
4
  const base_1 = require("../base");
14
5
  class FlowXContract extends base_1.BaseContract {
15
- swap(tx) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- const coinInType = this.swapInfo.assetIn;
18
- const coinOutType = this.swapInfo.assetOut;
19
- const config = this.config.flowx;
20
- const [tokenOut] = tx.moveCall({
21
- target: `${config.package}::router::swap_exact_input_direct`,
22
- typeArguments: [coinInType, coinOutType],
23
- arguments: [tx.object(config.container), this.inputCoinObject],
24
- });
25
- return tokenOut;
6
+ async swap(tx) {
7
+ const coinInType = this.swapInfo.assetIn;
8
+ const coinOutType = this.swapInfo.assetOut;
9
+ const config = this.config.flowx;
10
+ const [tokenOut] = tx.moveCall({
11
+ target: `${config.package}::router::swap_exact_input_direct`,
12
+ typeArguments: [coinInType, coinOutType],
13
+ arguments: [tx.object(config.container), this.inputCoinObject],
26
14
  });
15
+ return tokenOut;
27
16
  }
28
17
  }
29
18
  exports.FlowXContract = FlowXContract;
@@ -1,50 +1,36 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.FlowxV3Contract = void 0;
13
4
  const utils_1 = require("@mysten/sui/utils");
14
5
  const base_1 = require("../base");
15
6
  const utils_2 = require("../utils");
16
- const bn_js_1 = require("bn.js");
17
7
  class FlowxV3Contract extends base_1.BaseContract {
18
- swap(tx) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- const [coinX, coinY] = this.swapInfo.pool.allTokens;
21
- const swapXtoY = this.swapInfo.swapXtoY;
22
- const swapFeeRate = this.swapInfo.extra.swapFeeRate;
23
- if (!swapFeeRate) {
24
- throw new Error("swapFeeRate is required");
25
- }
26
- const config = this.config.flowx_v3;
27
- const [coinOut] = tx.moveCall({
28
- target: `${config.package}::swap_router::swap_exact_input`,
29
- typeArguments: [
30
- swapXtoY ? coinX.address : coinY.address,
31
- swapXtoY ? coinY.address : coinX.address,
32
- ],
33
- arguments: [
34
- tx.object(config.registry),
35
- tx.pure.u64(swapFeeRate), // swap fee rate to lookup pool in the registry
36
- this.inputCoinObject,
37
- tx.pure.u64(0), // min amount out
38
- tx.pure.u128((0, utils_2.getDefaultSqrtPriceLimit)(swapXtoY)
39
- .add(swapXtoY ? new bn_js_1.BN(1) : new bn_js_1.BN(-1))
40
- .toString(10)), // sqrt price limit
41
- tx.pure.u64("18446744073709551615"), // u64 max value
42
- tx.object(config.version),
43
- tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
44
- ],
45
- });
46
- return coinOut;
8
+ async swap(tx) {
9
+ const [coinX, coinY] = this.swapInfo.pool.allTokens;
10
+ const swapXtoY = this.swapInfo.swapXtoY;
11
+ const swapFeeRate = this.swapInfo.extra.swapFeeRate;
12
+ if (!swapFeeRate) {
13
+ throw new Error("swapFeeRate is required");
14
+ }
15
+ const config = this.config.flowx_v3;
16
+ const [coinOut] = tx.moveCall({
17
+ target: `${config.package}::swap_router::swap_exact_input`,
18
+ typeArguments: [
19
+ swapXtoY ? coinX.address : coinY.address,
20
+ swapXtoY ? coinY.address : coinX.address,
21
+ ],
22
+ arguments: [
23
+ tx.object(config.registry),
24
+ tx.pure.u64(swapFeeRate), // swap fee rate to lookup pool in the registry
25
+ this.inputCoinObject,
26
+ tx.pure.u64(0), // min amount out
27
+ tx.pure.u128((0, utils_2.getDefaultSqrtPriceLimit)(swapXtoY) + (swapXtoY ? 1n : -1n)), // sqrt price limit
28
+ tx.pure.u64("18446744073709551615"), // u64 max value
29
+ tx.object(config.version),
30
+ tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
31
+ ],
47
32
  });
33
+ return coinOut;
48
34
  }
49
35
  }
50
36
  exports.FlowxV3Contract = FlowxV3Contract;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HaedalPMMContract = void 0;
4
+ const utils_1 = require("@mysten/sui/utils");
5
+ const base_1 = require("../base");
6
+ const sui_1 = require("../../../utils/sui");
7
+ class HaedalPMMContract extends base_1.BaseContract {
8
+ async swap(tx) {
9
+ const [coinX, coinY] = this.swapInfo.pool.allTokens;
10
+ const xToY = this.swapInfo.swapXtoY;
11
+ const { x_price_id, y_price_id } = this.swapInfo.extra || {};
12
+ if (!x_price_id || !y_price_id) {
13
+ throw new Error("x_price_id and y_price_id are required");
14
+ }
15
+ const config = this.config.haedal_pmm;
16
+ const [coinOut] = tx.moveCall({
17
+ target: `${config.package}::trader::${xToY ? "sell_base_coin" : "sell_quote_coin"}`,
18
+ typeArguments: [coinX.address, coinY.address],
19
+ arguments: [
20
+ tx.object(this.swapInfo.poolId),
21
+ tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
22
+ tx.object(x_price_id), // pyth pricefeed for x
23
+ tx.object(y_price_id), // pyth pricefeed for y
24
+ this.inputCoinObject, // mutable coin
25
+ this.getInputCoinValue(tx), // swap amount
26
+ tx.pure.u64(0), // min output amount
27
+ ],
28
+ });
29
+ sui_1.SuiUtils.collectDust(tx, this.swapInfo.assetIn, this.inputCoinObject);
30
+ return coinOut;
31
+ }
32
+ }
33
+ exports.HaedalPMMContract = HaedalPMMContract;
@@ -4,7 +4,6 @@ exports.ProtocolContract = void 0;
4
4
  const flowx_1 = require("./flowx");
5
5
  const aftermath_1 = require("./aftermath");
6
6
  const cetus_1 = require("./cetus");
7
- const deepbook_1 = require("./deepbook");
8
7
  const kriya_1 = require("./kriya");
9
8
  const turbos_1 = require("./turbos");
10
9
  const suiswap_1 = require("./suiswap");
@@ -18,6 +17,9 @@ const stsui_1 = require("./stsui");
18
17
  const flowxV3_1 = require("./flowxV3");
19
18
  const steamm_1 = require("./steamm");
20
19
  const magma_1 = require("./magma");
20
+ const haedal_pmm_1 = require("./haedal_pmm");
21
+ const momentum_1 = require("./momentum");
22
+ const bluefinx_1 = require("./bluefinx");
21
23
  exports.ProtocolContract = {
22
24
  cetus: cetus_1.CetusContract,
23
25
  turbos: turbos_1.TurbosContract,
@@ -25,7 +27,6 @@ exports.ProtocolContract = {
25
27
  kriya: kriya_1.KriyaContract,
26
28
  suiswap: suiswap_1.SuiswapContract,
27
29
  aftermath: aftermath_1.AfterMathContract,
28
- deepbook: deepbook_1.DeepBookContract,
29
30
  deepbook_v3: sponsored_1.SponsoredDeepBookV3Contract,
30
31
  flowx: flowx_1.FlowXContract,
31
32
  flowx_v3: flowxV3_1.FlowxV3Contract,
@@ -35,5 +36,9 @@ exports.ProtocolContract = {
35
36
  obric: obric_1.ObricContract,
36
37
  stsui: stsui_1.StSuiContract,
37
38
  steamm: steamm_1.SteammContract,
39
+ steamm_oracle_quoter: steamm_1.SteammContract,
38
40
  magma: magma_1.MagmaContract,
41
+ haedal_pmm: haedal_pmm_1.HaedalPMMContract,
42
+ momentum: momentum_1.MomentumContract,
43
+ bluefinx: bluefinx_1.BluefinXContract,
39
44
  };
@@ -1,41 +1,30 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.KriyaContract = void 0;
13
4
  const base_1 = require("../base");
14
5
  const token_1 = require("../../../utils/token");
15
6
  class KriyaContract extends base_1.BaseContract {
16
- swap(tx) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- const swapXtoY = this.swapInfo.swapXtoY;
19
- const coinInType = (0, token_1.normalizeTokenType)(this.swapInfo.assetIn);
20
- const coinOutType = (0, token_1.normalizeTokenType)(this.swapInfo.assetOut);
21
- const poolId = this.swapInfo.poolId;
22
- const inputCoinObject = this.inputCoinObject;
23
- const config = this.config.kriya;
24
- const [tokenOut] = tx.moveCall({
25
- target: `${config.package}::spot_dex::${swapXtoY ? "swap_token_x" : "swap_token_y"}`,
26
- typeArguments: [
27
- swapXtoY ? coinInType : coinOutType,
28
- swapXtoY ? coinOutType : coinInType,
29
- ],
30
- arguments: [
31
- tx.object(poolId),
32
- inputCoinObject,
33
- this.getInputCoinValue(tx),
34
- tx.pure.u64(0),
35
- ],
36
- });
37
- return tokenOut;
7
+ async swap(tx) {
8
+ const swapXtoY = this.swapInfo.swapXtoY;
9
+ const coinInType = (0, token_1.normalizeTokenType)(this.swapInfo.assetIn);
10
+ const coinOutType = (0, token_1.normalizeTokenType)(this.swapInfo.assetOut);
11
+ const poolId = this.swapInfo.poolId;
12
+ const inputCoinObject = this.inputCoinObject;
13
+ const config = this.config.kriya;
14
+ const [tokenOut] = tx.moveCall({
15
+ target: `${config.package}::spot_dex::${swapXtoY ? "swap_token_x" : "swap_token_y"}`,
16
+ typeArguments: [
17
+ swapXtoY ? coinInType : coinOutType,
18
+ swapXtoY ? coinOutType : coinInType,
19
+ ],
20
+ arguments: [
21
+ tx.object(poolId),
22
+ inputCoinObject,
23
+ this.getInputCoinValue(tx),
24
+ tx.pure.u64(0),
25
+ ],
38
26
  });
27
+ return tokenOut;
39
28
  }
40
29
  }
41
30
  exports.KriyaContract = KriyaContract;
@@ -1,76 +1,65 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.KriyaV3Contract = void 0;
13
4
  const base_1 = require("../base");
14
5
  const utils_1 = require("@mysten/sui/utils");
15
6
  const token_1 = require("../../../utils/token");
16
7
  class KriyaV3Contract extends base_1.BaseContract {
17
- swap(tx) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- const swapXtoY = this.swapInfo.swapXtoY;
20
- const coinInType = (0, token_1.normalizeTokenType)(this.swapInfo.assetIn);
21
- const coinOutType = (0, token_1.normalizeTokenType)(this.swapInfo.assetOut);
22
- const poolId = this.swapInfo.poolId;
23
- const LowLimitPrice = 4295048017;
24
- const limitPrice = BigInt("79226673515401279992447579050");
25
- const { package: PACKAGE_ID, version: VERSION_ID } = this.config.kriya_v3;
26
- const [receive_a, receive_b, flash_receipt] = tx.moveCall({
27
- target: `${PACKAGE_ID}::trade::flash_swap`,
28
- typeArguments: this.getTypeParams(),
29
- arguments: [
30
- tx.object(poolId),
31
- tx.pure.bool(swapXtoY),
32
- tx.pure.bool(true),
33
- this.getInputCoinValue(tx),
34
- tx.pure.u128(swapXtoY ? LowLimitPrice : limitPrice),
35
- tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
36
- tx.object(VERSION_ID),
37
- ],
38
- });
39
- tx.moveCall({
40
- target: `0x2::balance::destroy_zero`,
41
- arguments: [swapXtoY ? receive_a : receive_b],
42
- typeArguments: [coinInType],
43
- });
44
- const [zeroOutCoin] = tx.moveCall({
45
- target: `0x2::balance::zero`,
46
- arguments: [],
47
- typeArguments: [coinOutType],
48
- });
49
- const inputCoinBalance = tx.moveCall({
50
- target: `0x2::coin::into_balance`,
51
- typeArguments: [coinInType],
52
- arguments: [this.inputCoinObject],
53
- });
54
- const pay_coin_a = swapXtoY ? inputCoinBalance : zeroOutCoin;
55
- const pay_coin_b = swapXtoY ? zeroOutCoin : inputCoinBalance;
56
- tx.moveCall({
57
- target: `${PACKAGE_ID}::trade::repay_flash_swap`,
58
- typeArguments: this.getTypeParams(),
59
- arguments: [
60
- tx.object(poolId),
61
- flash_receipt,
62
- pay_coin_a,
63
- pay_coin_b,
64
- tx.object(VERSION_ID),
65
- ],
66
- });
67
- const [tokenOut] = tx.moveCall({
68
- target: `0x2::coin::from_balance`,
69
- typeArguments: [coinOutType],
70
- arguments: [swapXtoY ? receive_b : receive_a],
71
- });
72
- return tokenOut;
8
+ async swap(tx) {
9
+ const swapXtoY = this.swapInfo.swapXtoY;
10
+ const coinInType = (0, token_1.normalizeTokenType)(this.swapInfo.assetIn);
11
+ const coinOutType = (0, token_1.normalizeTokenType)(this.swapInfo.assetOut);
12
+ const poolId = this.swapInfo.poolId;
13
+ const LowLimitPrice = 4295048017;
14
+ const limitPrice = BigInt("79226673515401279992447579050");
15
+ const { package: PACKAGE_ID, version: VERSION_ID } = this.config.kriya_v3;
16
+ const [receive_a, receive_b, flash_receipt] = tx.moveCall({
17
+ target: `${PACKAGE_ID}::trade::flash_swap`,
18
+ typeArguments: this.getTypeParams(),
19
+ arguments: [
20
+ tx.object(poolId),
21
+ tx.pure.bool(swapXtoY),
22
+ tx.pure.bool(true),
23
+ this.getInputCoinValue(tx),
24
+ tx.pure.u128(swapXtoY ? LowLimitPrice : limitPrice),
25
+ tx.object(utils_1.SUI_CLOCK_OBJECT_ID),
26
+ tx.object(VERSION_ID),
27
+ ],
73
28
  });
29
+ tx.moveCall({
30
+ target: `0x2::balance::destroy_zero`,
31
+ arguments: [swapXtoY ? receive_a : receive_b],
32
+ typeArguments: [coinInType],
33
+ });
34
+ const [zeroOutCoin] = tx.moveCall({
35
+ target: `0x2::balance::zero`,
36
+ arguments: [],
37
+ typeArguments: [coinOutType],
38
+ });
39
+ const inputCoinBalance = tx.moveCall({
40
+ target: `0x2::coin::into_balance`,
41
+ typeArguments: [coinInType],
42
+ arguments: [this.inputCoinObject],
43
+ });
44
+ const pay_coin_a = swapXtoY ? inputCoinBalance : zeroOutCoin;
45
+ const pay_coin_b = swapXtoY ? zeroOutCoin : inputCoinBalance;
46
+ tx.moveCall({
47
+ target: `${PACKAGE_ID}::trade::repay_flash_swap`,
48
+ typeArguments: this.getTypeParams(),
49
+ arguments: [
50
+ tx.object(poolId),
51
+ flash_receipt,
52
+ pay_coin_a,
53
+ pay_coin_b,
54
+ tx.object(VERSION_ID),
55
+ ],
56
+ });
57
+ const [tokenOut] = tx.moveCall({
58
+ target: `0x2::coin::from_balance`,
59
+ typeArguments: [coinOutType],
60
+ arguments: [swapXtoY ? receive_b : receive_a],
61
+ });
62
+ return tokenOut;
74
63
  }
75
64
  }
76
65
  exports.KriyaV3Contract = KriyaV3Contract;