@cetusprotocol/aggregator-sdk 0.0.7 → 0.0.8

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.
package/dist/index.js CHANGED
@@ -5364,17 +5364,14 @@ function buildInputCoin(txb, allCoins, amount, coinType) {
5364
5364
  targetCoinAmount: 0
5365
5365
  };
5366
5366
  }
5367
- console.log("used coin asests", usedCoinAsests);
5368
5367
  let totalCoinBalance = CoinUtils.calculateTotalBalance(usedCoinAsests);
5369
- console.log("totalCoinBalance", totalCoinBalance);
5370
- console.log("amount", amount);
5371
5368
  if (totalCoinBalance < amount) {
5372
5369
  throw new AggregateError(
5373
5370
  "Insufficient balance when build merge coin",
5374
5371
  "InsufficientBalance" /* InsufficientBalance */
5375
5372
  );
5376
5373
  }
5377
- if (CoinUtils.isSuiCoin(coinType) && amount <= BigInt(95e10)) {
5374
+ if (CoinUtils.isSuiCoin(coinType)) {
5378
5375
  const resultCoin = txb.splitCoins(txb.gas, [
5379
5376
  txb.pure.u64(amount.toString())
5380
5377
  ]);
@@ -5933,7 +5930,7 @@ function flowxAmmSwapMovecall(swapParams, txb, config2) {
5933
5930
  }
5934
5931
 
5935
5932
  // src/transaction/turbos.ts
5936
- function turbosSwapMovecall(swapParams, txb, config2) {
5933
+ function turbosClmmSwapMovecall(swapParams, txb, config2) {
5937
5934
  return __async(this, null, function* () {
5938
5935
  const aggregatorPackage = config2.getPackage(AGGREGATOR);
5939
5936
  if (aggregatorPackage == null) {
@@ -6093,7 +6090,6 @@ function expectInputRouterSwap(client, params, txb, fromCoin, config2, partner)
6093
6090
  coinAType: path.a2b ? path.from : path.target,
6094
6091
  coinBType: path.a2b ? path.target : path.from
6095
6092
  };
6096
- firstPathPool && router.path.length > 1;
6097
6093
  const swapResult = yield cetusSwapWithOutLimit(
6098
6094
  swapParams,
6099
6095
  nextFromCoin,
@@ -6198,7 +6194,7 @@ function expectInputRouterSwap(client, params, txb, fromCoin, config2, partner)
6198
6194
  coinBType: path.a2b ? path.target : path.from,
6199
6195
  feeType
6200
6196
  };
6201
- const swapResult = yield turbosSwapMovecall(swapParams, txb, config2);
6197
+ const swapResult = yield turbosClmmSwapMovecall(swapParams, txb, config2);
6202
6198
  intermediateTargetCoin = swapResult.targetCoin;
6203
6199
  nextFromCoin = intermediateTargetCoin;
6204
6200
  nextFlashAmount = swapResult.amountOut;
package/dist/index.mjs CHANGED
@@ -5362,17 +5362,14 @@ function buildInputCoin(txb, allCoins, amount, coinType) {
5362
5362
  targetCoinAmount: 0
5363
5363
  };
5364
5364
  }
5365
- console.log("used coin asests", usedCoinAsests);
5366
5365
  let totalCoinBalance = CoinUtils.calculateTotalBalance(usedCoinAsests);
5367
- console.log("totalCoinBalance", totalCoinBalance);
5368
- console.log("amount", amount);
5369
5366
  if (totalCoinBalance < amount) {
5370
5367
  throw new AggregateError(
5371
5368
  "Insufficient balance when build merge coin",
5372
5369
  "InsufficientBalance" /* InsufficientBalance */
5373
5370
  );
5374
5371
  }
5375
- if (CoinUtils.isSuiCoin(coinType) && amount <= BigInt(95e10)) {
5372
+ if (CoinUtils.isSuiCoin(coinType)) {
5376
5373
  const resultCoin = txb.splitCoins(txb.gas, [
5377
5374
  txb.pure.u64(amount.toString())
5378
5375
  ]);
@@ -5931,7 +5928,7 @@ function flowxAmmSwapMovecall(swapParams, txb, config2) {
5931
5928
  }
5932
5929
 
5933
5930
  // src/transaction/turbos.ts
5934
- function turbosSwapMovecall(swapParams, txb, config2) {
5931
+ function turbosClmmSwapMovecall(swapParams, txb, config2) {
5935
5932
  return __async(this, null, function* () {
5936
5933
  const aggregatorPackage = config2.getPackage(AGGREGATOR);
5937
5934
  if (aggregatorPackage == null) {
@@ -6091,7 +6088,6 @@ function expectInputRouterSwap(client, params, txb, fromCoin, config2, partner)
6091
6088
  coinAType: path.a2b ? path.from : path.target,
6092
6089
  coinBType: path.a2b ? path.target : path.from
6093
6090
  };
6094
- firstPathPool && router.path.length > 1;
6095
6091
  const swapResult = yield cetusSwapWithOutLimit(
6096
6092
  swapParams,
6097
6093
  nextFromCoin,
@@ -6196,7 +6192,7 @@ function expectInputRouterSwap(client, params, txb, fromCoin, config2, partner)
6196
6192
  coinBType: path.a2b ? path.target : path.from,
6197
6193
  feeType
6198
6194
  };
6199
- const swapResult = yield turbosSwapMovecall(swapParams, txb, config2);
6195
+ const swapResult = yield turbosClmmSwapMovecall(swapParams, txb, config2);
6200
6196
  intermediateTargetCoin = swapResult.targetCoin;
6201
6197
  nextFromCoin = intermediateTargetCoin;
6202
6198
  nextFlashAmount = swapResult.amountOut;
@@ -19,4 +19,4 @@ export type TurbosSwapResult = {
19
19
  amountOut: TransactionArgument;
20
20
  txb: Transaction;
21
21
  };
22
- export declare function turbosSwapMovecall(swapParams: TurbosSwapParams, txb: Transaction, config: AggregatorConfig): Promise<TurbosSwapResult>;
22
+ export declare function turbosClmmSwapMovecall(swapParams: TurbosSwapParams, txb: Transaction, config: AggregatorConfig): Promise<TurbosSwapResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -51,12 +51,7 @@ export function buildInputCoin(
51
51
  }
52
52
  }
53
53
 
54
- console.log("used coin asests", usedCoinAsests)
55
-
56
54
  let totalCoinBalance = CoinUtils.calculateTotalBalance(usedCoinAsests)
57
-
58
- console.log("totalCoinBalance", totalCoinBalance)
59
- console.log("amount", amount)
60
55
  if (totalCoinBalance < amount) {
61
56
  throw new AggregateError(
62
57
  "Insufficient balance when build merge coin",
@@ -64,7 +59,7 @@ export function buildInputCoin(
64
59
  )
65
60
  }
66
61
 
67
- if (CoinUtils.isSuiCoin(coinType) && amount <= BigInt(950000000000)) {
62
+ if (CoinUtils.isSuiCoin(coinType)) {
68
63
  const resultCoin = txb.splitCoins(txb.gas, [
69
64
  txb.pure.u64(amount.toString()),
70
65
  ])
@@ -25,7 +25,7 @@ import {
25
25
  import { transferOrDestoryCoin } from "./common"
26
26
  import { GetDefaultSqrtPriceLimit } from "../math"
27
27
  import { flowxAmmSwapMovecall } from "./flowx"
28
- import { turbosSwapMovecall } from "./turbos"
28
+ import { turbosClmmSwapMovecall } from "./turbos"
29
29
  import { AftermathAmmSwapMovecall } from "./aftermath"
30
30
  import { TransactionErrorCode } from "~/errors"
31
31
 
@@ -47,7 +47,6 @@ export async function expectInputRouterSwap(
47
47
  const router = params.routers[i]
48
48
  let intermediateTargetCoin: TransactionObjectArgument
49
49
  let nextFromCoin = fromCoins[i] as TransactionObjectArgument
50
-
51
50
  let nextFlashAmount: TransactionArgument = txb.pure.u64(splitAmounts[i])
52
51
 
53
52
  for (let j = 0; j < router.path.length; j++) {
@@ -67,7 +66,6 @@ export async function expectInputRouterSwap(
67
66
  coinBType: path.a2b ? path.target : path.from,
68
67
  }
69
68
 
70
- const returnPayAmount = firstPathPool && router.path.length > 1
71
69
  const swapResult = await cetusSwapWithOutLimit(
72
70
  swapParams,
73
71
  nextFromCoin,
@@ -192,7 +190,7 @@ export async function expectInputRouterSwap(
192
190
  feeType,
193
191
  }
194
192
 
195
- const swapResult = await turbosSwapMovecall(swapParams, txb, config)
193
+ const swapResult = await turbosClmmSwapMovecall(swapParams, txb, config)
196
194
 
197
195
  intermediateTargetCoin = swapResult.targetCoin
198
196
  nextFromCoin = intermediateTargetCoin
@@ -2,14 +2,7 @@ import { Transaction } from "@mysten/sui/transactions"
2
2
  import { SwapInPoolsParams } from "~/client"
3
3
  import { AggregatorConfig } from "~/config"
4
4
  import { compareCoins, completionCoin } from "~/utils/coin"
5
- import {
6
- CETUS_DEX,
7
- INTEGRATE,
8
- RouterData,
9
- SwapInPoolsResult,
10
- U64_MAX_BN,
11
- ZERO,
12
- } from ".."
5
+ import { CETUS_DEX, INTEGRATE, SwapInPoolsResult, U64_MAX_BN, ZERO } from ".."
13
6
  import { ConfigErrorCode, TransactionErrorCode } from "~/errors"
14
7
  import { checkInvalidSuiAddress } from "~/utils/transaction"
15
8
  import { SuiClient } from "@mysten/sui/client"
@@ -36,7 +36,7 @@ export type TurbosSwapResult = {
36
36
  txb: Transaction
37
37
  }
38
38
 
39
- export async function turbosSwapMovecall(
39
+ export async function turbosClmmSwapMovecall(
40
40
  swapParams: TurbosSwapParams,
41
41
  txb: Transaction,
42
42
  config: AggregatorConfig
@@ -2,15 +2,7 @@ import { describe, expect, test } from "@jest/globals"
2
2
  import dotenv from "dotenv"
3
3
  import { AggregatorClient } from "~/client"
4
4
  import { AggregatorConfig, ENV } from "~/config"
5
- import {
6
- M_CETUS,
7
- M_HASUI,
8
- M_NAVI,
9
- M_SUI,
10
- M_USDC,
11
- M_VAPOR,
12
- M_VSUI,
13
- } from "../src/test_data.test"
5
+ import { M_CETUS, M_HASUI, M_NAVI, M_SUI, M_USDC } from "../src/test_data.test"
14
6
  import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"
15
7
  import { printTransaction } from "~/utils/transaction"
16
8
  import BN from "bn.js"
@@ -42,15 +34,19 @@ describe("router module", () => {
42
34
  // : buildTestAccount()
43
35
  const byte = Buffer.from(secret, "base64")
44
36
  const u8Array = new Uint8Array(byte)
37
+ const secretKey = fromB64(secret)
38
+ console.log("secret key", secretKey.toString())
45
39
 
46
- // keypair = Ed25519Keypair.fromSecretKey(fromB64(secret).slice(1, 33))
40
+ keypair = Ed25519Keypair.fromSecretKey(fromB64(secret).slice(1, 33))
47
41
 
48
42
  // const wallet = keypair.getPublicKey().toSuiAddress()
49
- // console.log("wallet", wallet)
50
43
 
44
+ // console.log("wallet", wallet, "\n", wallet.toString())
45
+
46
+ // const wallet =
47
+ // "0xfba94aa36e93ccc7d84a6a57040fc51983223f1b522a8d0be3c3bf2c98977ebb"
51
48
  const wallet =
52
- "0xfba94aa36e93ccc7d84a6a57040fc51983223f1b522a8d0be3c3bf2c98977ebb"
53
- // const wallet = "0xaabf2fedcb36146db164bec930b74a47969c4df98216e049342a3c49b6d11580"
49
+ "0xaabf2fedcb36146db164bec930b74a47969c4df98216e049342a3c49b6d11580"
54
50
  // const wallet = "0x410456cfc689666936b6bf80fbec958b69499b9f7183ecba07de577c17248a44"
55
51
  // const wallet = "0xca171941521153181ff729d53489eaae7e99c3f4692884afd7cca61154e4cec4"
56
52
  // console.log("wallet: ", wallet)
@@ -135,10 +131,10 @@ describe("router module", () => {
135
131
 
136
132
  test("Build router tx", async () => {
137
133
  const byAmountIn = true
138
- const amount = "1000000"
134
+ const amount = "3000000000000"
139
135
 
140
- const from = M_USDC
141
- const target = M_SUI
136
+ const from = M_SUI
137
+ const target = M_USDC
142
138
 
143
139
  const res = await client.findRouter({
144
140
  from,