@cetusprotocol/aggregator-sdk 0.0.3 → 0.0.4
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -10
- package/dist/index.mjs +12 -10
- package/dist/src/client.d.ts +1 -1
- package/dist/src/utils/coin.d.ts +0 -2
- package/package.json +1 -1
- package/src/client.ts +6 -3
- package/src/math.ts +14 -8
- package/src/transaction/common.ts +9 -9
- package/src/utils/coin.ts +0 -21
- package/tests/math.test.ts +13 -0
- package/tests/router.test.ts +18 -28
- package/src/utils/coin.spec.ts +0 -10
- /package/dist/{src/utils/coin.spec.d.ts → tests/math.test.d.ts} +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -166,7 +166,7 @@ declare class AggregatorClient {
|
|
|
166
166
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
167
167
|
routerSwap(params: BuildRouterSwapParams): Promise<Transaction>;
|
|
168
168
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
169
|
-
devInspectTransactionBlock(txb: Transaction
|
|
169
|
+
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
170
170
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
171
171
|
}
|
|
172
172
|
|
package/dist/index.d.ts
CHANGED
|
@@ -166,7 +166,7 @@ declare class AggregatorClient {
|
|
|
166
166
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
167
167
|
routerSwap(params: BuildRouterSwapParams): Promise<Transaction>;
|
|
168
168
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
169
|
-
devInspectTransactionBlock(txb: Transaction
|
|
169
|
+
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
170
170
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
171
171
|
}
|
|
172
172
|
|
package/dist/index.js
CHANGED
|
@@ -5347,7 +5347,14 @@ function buildInputCoin(txb, allCoins, amount, coinType) {
|
|
|
5347
5347
|
targetCoinAmount: 0
|
|
5348
5348
|
};
|
|
5349
5349
|
}
|
|
5350
|
-
|
|
5350
|
+
let totalCoinBalance = CoinUtils.calculateTotalBalance(usedCoinAsests);
|
|
5351
|
+
if (totalCoinBalance < amount) {
|
|
5352
|
+
throw new AggregateError(
|
|
5353
|
+
"Insufficient balance when build merge coin",
|
|
5354
|
+
"InsufficientBalance" /* InsufficientBalance */
|
|
5355
|
+
);
|
|
5356
|
+
}
|
|
5357
|
+
if (CoinUtils.isSuiCoin(coinType) && amount <= BigInt(95e10)) {
|
|
5351
5358
|
const resultCoin = txb.splitCoins(txb.gas, [
|
|
5352
5359
|
txb.pure.u64(amount.toString())
|
|
5353
5360
|
]);
|
|
@@ -5357,13 +5364,6 @@ function buildInputCoin(txb, allCoins, amount, coinType) {
|
|
|
5357
5364
|
targetCoinAmount: Number(amount.toString())
|
|
5358
5365
|
};
|
|
5359
5366
|
}
|
|
5360
|
-
let totalCoinBalance = CoinUtils.calculateTotalBalance(usedCoinAsests);
|
|
5361
|
-
if (totalCoinBalance < amount) {
|
|
5362
|
-
throw new AggregateError(
|
|
5363
|
-
"Insufficient balance when build merge coin",
|
|
5364
|
-
"InsufficientBalance" /* InsufficientBalance */
|
|
5365
|
-
);
|
|
5366
|
-
}
|
|
5367
5367
|
let sortCoinAssets = CoinUtils.sortByBalance(usedCoinAsests);
|
|
5368
5368
|
let totalThreeCoinBalance = sortCoinAssets.slice(0, 3).reduce((acc, coin) => acc + coin.balance, BigInt(0));
|
|
5369
5369
|
if (totalThreeCoinBalance < BigInt(amount)) {
|
|
@@ -6558,6 +6558,7 @@ var AggregatorClient = class {
|
|
|
6558
6558
|
try {
|
|
6559
6559
|
result = yield swapInPools(this.client, params, this.config);
|
|
6560
6560
|
} catch (e) {
|
|
6561
|
+
console.error("swapInPools error:", e);
|
|
6561
6562
|
return null;
|
|
6562
6563
|
}
|
|
6563
6564
|
return result;
|
|
@@ -6673,11 +6674,12 @@ var AggregatorClient = class {
|
|
|
6673
6674
|
return res;
|
|
6674
6675
|
});
|
|
6675
6676
|
}
|
|
6676
|
-
devInspectTransactionBlock(txb
|
|
6677
|
+
devInspectTransactionBlock(txb) {
|
|
6677
6678
|
return __async(this, null, function* () {
|
|
6679
|
+
console.log(this.wallet);
|
|
6678
6680
|
const res = yield this.client.devInspectTransactionBlock({
|
|
6679
6681
|
transactionBlock: txb,
|
|
6680
|
-
sender:
|
|
6682
|
+
sender: this.wallet
|
|
6681
6683
|
});
|
|
6682
6684
|
return res;
|
|
6683
6685
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -5345,7 +5345,14 @@ function buildInputCoin(txb, allCoins, amount, coinType) {
|
|
|
5345
5345
|
targetCoinAmount: 0
|
|
5346
5346
|
};
|
|
5347
5347
|
}
|
|
5348
|
-
|
|
5348
|
+
let totalCoinBalance = CoinUtils.calculateTotalBalance(usedCoinAsests);
|
|
5349
|
+
if (totalCoinBalance < amount) {
|
|
5350
|
+
throw new AggregateError(
|
|
5351
|
+
"Insufficient balance when build merge coin",
|
|
5352
|
+
"InsufficientBalance" /* InsufficientBalance */
|
|
5353
|
+
);
|
|
5354
|
+
}
|
|
5355
|
+
if (CoinUtils.isSuiCoin(coinType) && amount <= BigInt(95e10)) {
|
|
5349
5356
|
const resultCoin = txb.splitCoins(txb.gas, [
|
|
5350
5357
|
txb.pure.u64(amount.toString())
|
|
5351
5358
|
]);
|
|
@@ -5355,13 +5362,6 @@ function buildInputCoin(txb, allCoins, amount, coinType) {
|
|
|
5355
5362
|
targetCoinAmount: Number(amount.toString())
|
|
5356
5363
|
};
|
|
5357
5364
|
}
|
|
5358
|
-
let totalCoinBalance = CoinUtils.calculateTotalBalance(usedCoinAsests);
|
|
5359
|
-
if (totalCoinBalance < amount) {
|
|
5360
|
-
throw new AggregateError(
|
|
5361
|
-
"Insufficient balance when build merge coin",
|
|
5362
|
-
"InsufficientBalance" /* InsufficientBalance */
|
|
5363
|
-
);
|
|
5364
|
-
}
|
|
5365
5365
|
let sortCoinAssets = CoinUtils.sortByBalance(usedCoinAsests);
|
|
5366
5366
|
let totalThreeCoinBalance = sortCoinAssets.slice(0, 3).reduce((acc, coin) => acc + coin.balance, BigInt(0));
|
|
5367
5367
|
if (totalThreeCoinBalance < BigInt(amount)) {
|
|
@@ -6556,6 +6556,7 @@ var AggregatorClient = class {
|
|
|
6556
6556
|
try {
|
|
6557
6557
|
result = yield swapInPools(this.client, params, this.config);
|
|
6558
6558
|
} catch (e) {
|
|
6559
|
+
console.error("swapInPools error:", e);
|
|
6559
6560
|
return null;
|
|
6560
6561
|
}
|
|
6561
6562
|
return result;
|
|
@@ -6671,11 +6672,12 @@ var AggregatorClient = class {
|
|
|
6671
6672
|
return res;
|
|
6672
6673
|
});
|
|
6673
6674
|
}
|
|
6674
|
-
devInspectTransactionBlock(txb
|
|
6675
|
+
devInspectTransactionBlock(txb) {
|
|
6675
6676
|
return __async(this, null, function* () {
|
|
6677
|
+
console.log(this.wallet);
|
|
6676
6678
|
const res = yield this.client.devInspectTransactionBlock({
|
|
6677
6679
|
transactionBlock: txb,
|
|
6678
|
-
sender:
|
|
6680
|
+
sender: this.wallet
|
|
6679
6681
|
});
|
|
6680
6682
|
return res;
|
|
6681
6683
|
});
|
package/dist/src/client.d.ts
CHANGED
|
@@ -83,6 +83,6 @@ export declare class AggregatorClient {
|
|
|
83
83
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
84
84
|
routerSwap(params: BuildRouterSwapParams): Promise<Transaction>;
|
|
85
85
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<import("@mysten/sui/client").SuiTransactionBlockResponse>;
|
|
86
|
-
devInspectTransactionBlock(txb: Transaction
|
|
86
|
+
devInspectTransactionBlock(txb: Transaction): Promise<import("@mysten/sui/client").DevInspectResults>;
|
|
87
87
|
sendTransaction(txb: Transaction, signer: Signer): Promise<import("@mysten/sui/client").SuiTransactionBlockResponse>;
|
|
88
88
|
}
|
package/dist/src/utils/coin.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export declare function completionCoin(s: string): string;
|
|
2
2
|
export declare function compareCoins(coinA: string, coinB: string): boolean;
|
|
3
|
-
export declare function parseTurbosPoolFeeType(typeData: string): string | null;
|
|
4
|
-
export declare function parseAftermathFeeType(typeData: string): string | undefined;
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AggregatorConfig } from "./config"
|
|
2
2
|
import Decimal from "decimal.js"
|
|
3
3
|
import { SuiClient } from "@mysten/sui/client"
|
|
4
|
-
import { CoinAsset } from "./types/sui"
|
|
4
|
+
import { CoinAsset, SuiAddress } from "./types/sui"
|
|
5
5
|
import { createTarget, extractStructTagFromType } from "./utils"
|
|
6
6
|
import { Transaction } from "@mysten/sui/transactions"
|
|
7
7
|
import {
|
|
@@ -209,6 +209,7 @@ export class AggregatorClient {
|
|
|
209
209
|
try {
|
|
210
210
|
result = await swapInPools(this.client, params, this.config)
|
|
211
211
|
} catch (e) {
|
|
212
|
+
console.error("swapInPools error:", e)
|
|
212
213
|
return null
|
|
213
214
|
}
|
|
214
215
|
|
|
@@ -235,6 +236,7 @@ export class AggregatorClient {
|
|
|
235
236
|
)
|
|
236
237
|
|
|
237
238
|
const txb = new Transaction()
|
|
239
|
+
// txb.setGasBudget(42392686100000000)
|
|
238
240
|
|
|
239
241
|
if (refreshAllCoins || this.allCoins.length === 0) {
|
|
240
242
|
this.allCoins = await this.getAllCoins()
|
|
@@ -329,10 +331,11 @@ export class AggregatorClient {
|
|
|
329
331
|
return res
|
|
330
332
|
}
|
|
331
333
|
|
|
332
|
-
async devInspectTransactionBlock(txb: Transaction
|
|
334
|
+
async devInspectTransactionBlock(txb: Transaction) {
|
|
335
|
+
console.log(this.wallet)
|
|
333
336
|
const res = await this.client.devInspectTransactionBlock({
|
|
334
337
|
transactionBlock: txb,
|
|
335
|
-
sender:
|
|
338
|
+
sender: this.wallet,
|
|
336
339
|
})
|
|
337
340
|
|
|
338
341
|
return res
|
package/src/math.ts
CHANGED
|
@@ -7,7 +7,11 @@ import { ZERO } from "./const"
|
|
|
7
7
|
import Decimal from "decimal.js"
|
|
8
8
|
|
|
9
9
|
// `slippage` is a percentage, for example, 0.01 means 1%.
|
|
10
|
-
export function CalculateAmountLimit(
|
|
10
|
+
export function CalculateAmountLimit(
|
|
11
|
+
expectAmount: BN,
|
|
12
|
+
byAmountIn: boolean,
|
|
13
|
+
slippage: number
|
|
14
|
+
): number {
|
|
11
15
|
let amountLimit = ZERO
|
|
12
16
|
if (byAmountIn) {
|
|
13
17
|
amountLimit = expectAmount.muln(1 - slippage)
|
|
@@ -18,20 +22,22 @@ export function CalculateAmountLimit(expectAmount: BN, byAmountIn: boolean, slip
|
|
|
18
22
|
return Number(amountLimit.toString())
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
const MAX_SQER_PRICE_X64 =
|
|
22
|
-
const MIN_SQER_PRICE_X64 =
|
|
25
|
+
const MAX_SQER_PRICE_X64 = "79226673515401279992447579055"
|
|
26
|
+
const MIN_SQER_PRICE_X64 = "4295048016"
|
|
23
27
|
|
|
24
28
|
export function GetDefaultSqrtPriceLimit(a2b: boolean): BN {
|
|
25
29
|
if (a2b) {
|
|
26
30
|
return new BN(MIN_SQER_PRICE_X64)
|
|
27
31
|
} else {
|
|
28
|
-
|
|
32
|
+
return new BN(MAX_SQER_PRICE_X64)
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
export function sqrtPriceX64ToPrice(
|
|
36
|
+
export function sqrtPriceX64ToPrice(
|
|
37
|
+
sqrtPriceStr: string,
|
|
38
|
+
decimalsA: number,
|
|
39
|
+
decimalsB: number
|
|
40
|
+
): Decimal {
|
|
33
41
|
const sqrtPriceX64 = new Decimal(sqrtPriceStr).mul(Decimal.pow(2, -64))
|
|
34
|
-
return sqrtPriceX64
|
|
35
|
-
.pow(2)
|
|
36
|
-
.mul(Decimal.pow(10, decimalsA - decimalsB))
|
|
42
|
+
return sqrtPriceX64.pow(2).mul(Decimal.pow(10, decimalsA - decimalsB))
|
|
37
43
|
}
|
|
@@ -51,7 +51,15 @@ export function buildInputCoin(
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
let totalCoinBalance = CoinUtils.calculateTotalBalance(usedCoinAsests)
|
|
55
|
+
if (totalCoinBalance < amount) {
|
|
56
|
+
throw new AggregateError(
|
|
57
|
+
"Insufficient balance when build merge coin",
|
|
58
|
+
TransactionErrorCode.InsufficientBalance
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (CoinUtils.isSuiCoin(coinType) && amount <= BigInt(950000000000)) {
|
|
55
63
|
const resultCoin = txb.splitCoins(txb.gas, [
|
|
56
64
|
txb.pure.u64(amount.toString()),
|
|
57
65
|
])
|
|
@@ -62,14 +70,6 @@ export function buildInputCoin(
|
|
|
62
70
|
}
|
|
63
71
|
}
|
|
64
72
|
|
|
65
|
-
let totalCoinBalance = CoinUtils.calculateTotalBalance(usedCoinAsests)
|
|
66
|
-
if (totalCoinBalance < amount) {
|
|
67
|
-
throw new AggregateError(
|
|
68
|
-
"Insufficient balance when build merge coin",
|
|
69
|
-
TransactionErrorCode.InsufficientBalance
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
73
|
// sort used coin by amount, asc
|
|
74
74
|
let sortCoinAssets = CoinUtils.sortByBalance(usedCoinAsests)
|
|
75
75
|
|
package/src/utils/coin.ts
CHANGED
|
@@ -38,24 +38,3 @@ export function compareCoins(coinA: string, coinB: string): boolean {
|
|
|
38
38
|
// If both strings are the same length and all characters are equal
|
|
39
39
|
return true // or coinB, they are equal
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
export function parseTurbosPoolFeeType(typeData: string) {
|
|
43
|
-
// "0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1::pool::Pool<0xc91acfb75009c5ff2fd57c54f3caaee12ad1fbe997681334adc0b574fc277a07::icorgi::ICORGI, 0x2::sui::SUI, 0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1::fee10000bps::FEE10000BPS>"
|
|
44
|
-
const regex = /,([^,>]*>)/g
|
|
45
|
-
const matches = [...typeData.matchAll(regex)]
|
|
46
|
-
if (matches.length > 0) {
|
|
47
|
-
const lastMatch = matches[matches.length - 1][1]
|
|
48
|
-
return lastMatch.substring(0, lastMatch.length - 1).trim()
|
|
49
|
-
}
|
|
50
|
-
return null
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function parseAftermathFeeType(typeData: string) {
|
|
54
|
-
// 0xefe170ec0be4d762196bedecd7a065816576198a6527c99282a2551aaa7da38c::pool::Pool<0xf66c5ba62888cd0694677bbfbd2332d08ead3b8a4332c40006c474e83b1a6786::af_lp::AF_LP>
|
|
55
|
-
// get 0xf66c5ba62888cd0694677bbfbd2332d08ead3b8a4332c40006c474e83b1a6786::af_lp::AF_LP
|
|
56
|
-
const regex = /<([^>]*)>/
|
|
57
|
-
const matches = typeData.match(regex)
|
|
58
|
-
if (matches) {
|
|
59
|
-
return matches[1]
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"
|
|
2
|
+
import { sqrtPriceX64ToPrice } from "~/math"
|
|
3
|
+
|
|
4
|
+
describe("test math functions", () => {
|
|
5
|
+
test("test sqrt price x64 to price", () => {
|
|
6
|
+
const sqrtPriceStr = "1312674575678912631"
|
|
7
|
+
const decimalsA = 9
|
|
8
|
+
const decimalsB = 6
|
|
9
|
+
|
|
10
|
+
const price = sqrtPriceX64ToPrice(sqrtPriceStr, decimalsA, decimalsB)
|
|
11
|
+
console.log("price", price.toFixed(9))
|
|
12
|
+
})
|
|
13
|
+
})
|
package/tests/router.test.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"
|
|
|
15
15
|
import { printTransaction } from "~/utils/transaction"
|
|
16
16
|
import BN from "bn.js"
|
|
17
17
|
import { fromHEX } from "@mysten/bcs"
|
|
18
|
+
import { fromB64 } from "@mysten/sui/utils"
|
|
18
19
|
|
|
19
20
|
dotenv.config()
|
|
20
21
|
|
|
@@ -35,16 +36,17 @@ describe("router module", () => {
|
|
|
35
36
|
const secret = process.env.SUI_WALLET_SECRET!
|
|
36
37
|
|
|
37
38
|
// const byte = Buffer.from(secret, "hex")
|
|
38
|
-
const byte = Buffer.from(secret, "base64")
|
|
39
|
-
const u8Array = new Uint8Array(byte)
|
|
40
39
|
// keypair = secret
|
|
41
40
|
// ? Ed25519Keypair.fromSecretKey(u8Array.slice(1, 33))
|
|
42
41
|
// : buildTestAccount()
|
|
42
|
+
const byte = Buffer.from(secret, "base64")
|
|
43
|
+
const u8Array = new Uint8Array(byte)
|
|
43
44
|
|
|
44
|
-
keypair = Ed25519Keypair.fromSecretKey(
|
|
45
|
+
keypair = Ed25519Keypair.fromSecretKey(fromB64(secret).slice(1, 33))
|
|
45
46
|
|
|
46
47
|
const wallet = keypair.getPublicKey().toSuiAddress()
|
|
47
48
|
console.log("wallet", wallet)
|
|
49
|
+
|
|
48
50
|
// const wallet =
|
|
49
51
|
// "0x1d30e55c730f92a02a33dbdf6b052cd178e5d924aa58c5e2350a24852250ae58"
|
|
50
52
|
// const wallet = "0xaabf2fedcb36146db164bec930b74a47969c4df98216e049342a3c49b6d11580"
|
|
@@ -93,12 +95,12 @@ describe("router module", () => {
|
|
|
93
95
|
const amount = 1000000
|
|
94
96
|
|
|
95
97
|
const res = await client.swapInPools({
|
|
96
|
-
from:
|
|
98
|
+
from: M_USDC,
|
|
97
99
|
target: M_SUI,
|
|
98
100
|
amount: new BN(amount),
|
|
99
|
-
byAmountIn:
|
|
101
|
+
byAmountIn: true,
|
|
100
102
|
pools: [
|
|
101
|
-
"
|
|
103
|
+
"0xcf994611fd4c48e277ce3ffd4d4364c914af2c3cbb05f7bf6facd371de688630",
|
|
102
104
|
],
|
|
103
105
|
})
|
|
104
106
|
|
|
@@ -108,26 +110,18 @@ describe("router module", () => {
|
|
|
108
110
|
})
|
|
109
111
|
|
|
110
112
|
test("Find router", async () => {
|
|
111
|
-
const amount = "
|
|
113
|
+
const amount = "42392676100000000"
|
|
112
114
|
|
|
113
115
|
const res = await client.findRouter({
|
|
114
116
|
from: M_SUI,
|
|
115
117
|
target: M_USDC,
|
|
116
118
|
amount: new BN(amount),
|
|
117
119
|
byAmountIn: true,
|
|
118
|
-
depth:
|
|
120
|
+
depth: 3,
|
|
119
121
|
splitAlgorithm: null,
|
|
120
122
|
splitFactor: null,
|
|
121
123
|
splitCount: 1,
|
|
122
|
-
providers: [
|
|
123
|
-
// "AFTERMATH",
|
|
124
|
-
// "CETUS",
|
|
125
|
-
"DEEPBOOK",
|
|
126
|
-
// "KRIYA",
|
|
127
|
-
// "FLOWX",
|
|
128
|
-
// "AFTERMATH",
|
|
129
|
-
// "TRUBOS",
|
|
130
|
-
],
|
|
124
|
+
providers: ["CETUS"],
|
|
131
125
|
})
|
|
132
126
|
|
|
133
127
|
if (res != null) {
|
|
@@ -140,10 +134,10 @@ describe("router module", () => {
|
|
|
140
134
|
|
|
141
135
|
test("Build router tx", async () => {
|
|
142
136
|
const byAmountIn = true
|
|
143
|
-
const amount =
|
|
137
|
+
const amount = "42392676100000000"
|
|
144
138
|
|
|
145
139
|
const from = M_SUI
|
|
146
|
-
const target =
|
|
140
|
+
const target = M_USDC
|
|
147
141
|
|
|
148
142
|
const res = await client.findRouter({
|
|
149
143
|
from,
|
|
@@ -154,7 +148,7 @@ describe("router module", () => {
|
|
|
154
148
|
splitAlgorithm: null,
|
|
155
149
|
splitFactor: null,
|
|
156
150
|
splitCount: null,
|
|
157
|
-
providers: ["CETUS"
|
|
151
|
+
providers: ["CETUS"],
|
|
158
152
|
})
|
|
159
153
|
|
|
160
154
|
if (res != null) {
|
|
@@ -175,12 +169,11 @@ describe("router module", () => {
|
|
|
175
169
|
fromCoinType: from,
|
|
176
170
|
targetCoinType: target,
|
|
177
171
|
partner: undefined,
|
|
178
|
-
isMergeTragetCoin:
|
|
172
|
+
isMergeTragetCoin: false,
|
|
173
|
+
refreshAllCoins: true,
|
|
179
174
|
})
|
|
180
175
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
let result = await client.devInspectTransactionBlock(routerTx, keypair)
|
|
176
|
+
let result = await client.devInspectTransactionBlock(routerTx)
|
|
184
177
|
|
|
185
178
|
if (result.effects.status.status === "success") {
|
|
186
179
|
console.log("Sim exec transaction success")
|
|
@@ -233,10 +226,7 @@ describe("router module", () => {
|
|
|
233
226
|
isMergeTragetCoin: false,
|
|
234
227
|
})
|
|
235
228
|
|
|
236
|
-
let result = await client.devInspectTransactionBlock(
|
|
237
|
-
routerTx,
|
|
238
|
-
keypair
|
|
239
|
-
)
|
|
229
|
+
let result = await client.devInspectTransactionBlock(routerTx)
|
|
240
230
|
// console.log('result', result)
|
|
241
231
|
|
|
242
232
|
if (result.effects.status.status === "success") {
|
package/src/utils/coin.spec.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { parseTurbosPoolFeeType } from "./coin"
|
|
2
|
-
|
|
3
|
-
describe("Coin Utils", () => {
|
|
4
|
-
it("should fetch token infos by URL and return data", async () => {
|
|
5
|
-
const typeDate =
|
|
6
|
-
"0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1::pool::Pool<0xc91acfb75009c5ff2fd57c54f3caaee12ad1fbe997681334adc0b574fc277a07::icorgi::ICORGI, 0x2::sui::SUI, 0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1::fee10000bps::FEE10000BPS>"
|
|
7
|
-
const result = parseTurbosPoolFeeType(typeDate)
|
|
8
|
-
console.log("parse turbos pool type", result)
|
|
9
|
-
})
|
|
10
|
-
})
|
|
File without changes
|