@cetusprotocol/aggregator-sdk 0.3.16 → 0.3.18

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 (51) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.mts +33 -11
  3. package/dist/index.d.ts +33 -11
  4. package/dist/index.js +209 -89
  5. package/dist/index.mjs +204 -89
  6. package/dist/src/api.d.ts +2 -0
  7. package/dist/src/client.d.ts +25 -9
  8. package/dist/src/transaction/afsui.d.ts +1 -1
  9. package/dist/src/transaction/aftermath.d.ts +1 -1
  10. package/dist/src/transaction/alphafi.d.ts +7 -0
  11. package/dist/src/transaction/bluefin.d.ts +1 -1
  12. package/dist/src/transaction/bluemove.d.ts +1 -1
  13. package/dist/src/transaction/cetus.d.ts +3 -3
  14. package/dist/src/transaction/deepbook_v2.d.ts +1 -1
  15. package/dist/src/transaction/deepbook_v3.d.ts +1 -1
  16. package/dist/src/transaction/flowx_v2.d.ts +1 -1
  17. package/dist/src/transaction/flowx_v3.d.ts +1 -1
  18. package/dist/src/transaction/haedal.d.ts +1 -1
  19. package/dist/src/transaction/haedal_pmm.d.ts +1 -1
  20. package/dist/src/transaction/index.d.ts +5 -1
  21. package/dist/src/transaction/kriya_v2.d.ts +1 -1
  22. package/dist/src/transaction/kriya_v3.d.ts +1 -1
  23. package/dist/src/transaction/scallop.d.ts +1 -1
  24. package/dist/src/transaction/suilend.d.ts +1 -2
  25. package/dist/src/transaction/turbos.d.ts +1 -1
  26. package/dist/src/transaction/volo.d.ts +1 -1
  27. package/package.json +1 -1
  28. package/src/api.ts +7 -3
  29. package/src/client.ts +129 -42
  30. package/src/transaction/afsui.ts +6 -3
  31. package/src/transaction/aftermath.ts +6 -3
  32. package/src/transaction/alphafi.ts +50 -0
  33. package/src/transaction/bluefin.ts +6 -3
  34. package/src/transaction/bluemove.ts +5 -4
  35. package/src/transaction/cetus.ts +13 -7
  36. package/src/transaction/deepbook_v2.ts +5 -4
  37. package/src/transaction/deepbook_v3.ts +5 -3
  38. package/src/transaction/flowx_v2.ts +5 -4
  39. package/src/transaction/flowx_v3.ts +5 -3
  40. package/src/transaction/haedal.ts +5 -3
  41. package/src/transaction/haedal_pmm.ts +5 -3
  42. package/src/transaction/index.ts +20 -1
  43. package/src/transaction/kriya_v2.ts +5 -4
  44. package/src/transaction/kriya_v3.ts +5 -4
  45. package/src/transaction/scallop.ts +5 -4
  46. package/src/transaction/suilend.ts +6 -10
  47. package/src/transaction/swap.ts +1 -0
  48. package/src/transaction/turbos.ts +5 -4
  49. package/src/transaction/volo.ts +5 -3
  50. package/src/utils/coin.ts +20 -8
  51. package/tests/router.test.ts +15 -22
@@ -3,7 +3,7 @@ import {
3
3
  TransactionArgument,
4
4
  TransactionObjectArgument,
5
5
  } from "@mysten/sui/transactions"
6
- import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
6
+ import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2ExtendPublishedAt, Path } from ".."
7
7
  import { mintZeroCoin } from "~/utils/coin"
8
8
 
9
9
  export type CetusFlashSwapResult = {
@@ -27,7 +27,8 @@ export class DeepbookV3 implements Dex {
27
27
  txb: Transaction,
28
28
  path: Path,
29
29
  inputCoin: TransactionObjectArgument,
30
- deepbookv3DeepFee?: TransactionObjectArgument
30
+ packages?: Map<string, string>,
31
+ deepbookv3DeepFee?: TransactionObjectArgument,
31
32
  ): Promise<TransactionObjectArgument> {
32
33
  const { direction, from, target } = path
33
34
  const [func, coinAType, coinBType] = direction
@@ -48,8 +49,9 @@ export class DeepbookV3 implements Dex {
48
49
  deepFee,
49
50
  txb.object(CLOCK_ADDRESS),
50
51
  ]
52
+ const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages)
51
53
  const res = txb.moveCall({
52
- target: `${client.publishedAtV2()}::deepbookv3::${func}`,
54
+ target: `${publishedAt}::deepbookv3::${func}`,
53
55
  typeArguments: [coinAType, coinBType],
54
56
  arguments: args,
55
57
  }) as TransactionArgument
@@ -3,7 +3,7 @@ import {
3
3
  TransactionArgument,
4
4
  TransactionObjectArgument,
5
5
  } from "@mysten/sui/transactions"
6
- import { AggregatorClient, Dex, Env, Path } from ".."
6
+ import { AggregatorClient, Dex, Env, getAggregatorV2PublishedAt, Path } from ".."
7
7
 
8
8
  export class FlowxV2 implements Dex {
9
9
  private container: string
@@ -21,7 +21,8 @@ export class FlowxV2 implements Dex {
21
21
  client: AggregatorClient,
22
22
  txb: Transaction,
23
23
  path: Path,
24
- inputCoin: TransactionObjectArgument
24
+ inputCoin: TransactionObjectArgument,
25
+ packages?: Map<string, string>
25
26
  ): Promise<TransactionObjectArgument> {
26
27
  const { direction, from, target } = path
27
28
 
@@ -30,9 +31,9 @@ export class FlowxV2 implements Dex {
30
31
  : ["swap_b2a", target, from]
31
32
 
32
33
  const args = [txb.object(this.container), inputCoin]
33
-
34
+ const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages)
34
35
  const res = txb.moveCall({
35
- target: `${client.publishedAt()}::flowx_amm::${func}`,
36
+ target: `${publishedAt}::flowx_amm::${func}`,
36
37
  typeArguments: [coinAType, coinBType],
37
38
  arguments: args,
38
39
  }) as TransactionObjectArgument
@@ -2,7 +2,7 @@ import {
2
2
  Transaction,
3
3
  TransactionObjectArgument,
4
4
  } from "@mysten/sui/transactions"
5
- import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
5
+ import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2PublishedAt, Path } from ".."
6
6
 
7
7
  export class FlowxV3 implements Dex {
8
8
  private versioned: string
@@ -23,7 +23,8 @@ export class FlowxV3 implements Dex {
23
23
  client: AggregatorClient,
24
24
  txb: Transaction,
25
25
  path: Path,
26
- inputCoin: TransactionObjectArgument
26
+ inputCoin: TransactionObjectArgument,
27
+ packages?: Map<string, string>
27
28
  ): Promise<TransactionObjectArgument> {
28
29
  const { direction, from, target } = path
29
30
 
@@ -39,8 +40,9 @@ export class FlowxV3 implements Dex {
39
40
  txb.object(CLOCK_ADDRESS),
40
41
  ]
41
42
 
43
+ const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages)
42
44
  const res = txb.moveCall({
43
- target: `${client.publishedAt()}::flowx_clmm::${func}`,
45
+ target: `${publishedAt}::flowx_clmm::${func}`,
44
46
  typeArguments: [coinAType, coinBType],
45
47
  arguments: args,
46
48
  }) as TransactionObjectArgument
@@ -2,7 +2,7 @@ import {
2
2
  Transaction,
3
3
  TransactionObjectArgument,
4
4
  } from "@mysten/sui/transactions"
5
- import { AggregatorClient, Dex, Env, Path } from ".."
5
+ import { AggregatorClient, Dex, Env, getAggregatorV2PublishedAt, Path } from ".."
6
6
 
7
7
  export class Haedal implements Dex {
8
8
  constructor(env: Env) {
@@ -15,7 +15,8 @@ export class Haedal implements Dex {
15
15
  client: AggregatorClient,
16
16
  txb: Transaction,
17
17
  path: Path,
18
- inputCoin: TransactionObjectArgument
18
+ inputCoin: TransactionObjectArgument,
19
+ packages?: Map<string, string>
19
20
  ): Promise<TransactionObjectArgument> {
20
21
  const { direction } = path
21
22
  if (!direction) {
@@ -23,8 +24,9 @@ export class Haedal implements Dex {
23
24
  }
24
25
  const func = "swap_a2b"
25
26
  const args = [txb.object(path.id), txb.object("0x5"), inputCoin]
27
+ const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages)
26
28
  const res = txb.moveCall({
27
- target: `${client.publishedAt()}::haedal::${func}`,
29
+ target: `${publishedAt}::haedal::${func}`,
28
30
  typeArguments: [],
29
31
  arguments: args,
30
32
  }) as TransactionObjectArgument
@@ -3,7 +3,7 @@ import {
3
3
  TransactionArgument,
4
4
  TransactionObjectArgument,
5
5
  } from "@mysten/sui/transactions"
6
- import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
6
+ import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2ExtendPublishedAt, Path } from ".."
7
7
  import { SuiPriceServiceConnection, SuiPythClient } from "@pythnetwork/pyth-sui-js"
8
8
  import { SuiClient } from "@mysten/sui/client"
9
9
 
@@ -29,7 +29,8 @@ export class HaedalPmm implements Dex {
29
29
  client: AggregatorClient,
30
30
  txb: Transaction,
31
31
  path: Path,
32
- inputCoin: TransactionObjectArgument
32
+ inputCoin: TransactionObjectArgument,
33
+ packages?: Map<string, string>
33
34
  ): Promise<TransactionObjectArgument> {
34
35
  const { direction, from, target } = path
35
36
  const [func, coinAType, coinBType] = direction
@@ -59,8 +60,9 @@ export class HaedalPmm implements Dex {
59
60
  inputCoin,
60
61
  txb.object(CLOCK_ADDRESS),
61
62
  ]
63
+ const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages)
62
64
  const res = txb.moveCall({
63
- target: `${client.publishedAtV2()}::haedalpmm::${func}`,
65
+ target: `${publishedAt}::haedalpmm::${func}`,
64
66
  typeArguments: [coinAType, coinBType],
65
67
  arguments: args,
66
68
  }) as TransactionArgument
@@ -7,12 +7,31 @@ import { AggregatorClient, Path } from ".."
7
7
  export const CLOCK_ADDRESS =
8
8
  "0x0000000000000000000000000000000000000000000000000000000000000006"
9
9
 
10
+ export const AGGREGATOR_V2 = "aggregator_v2"
11
+ export const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend"
12
+
13
+ export function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>) {
14
+ if (packages instanceof Map) {
15
+ return packages.get(AGGREGATOR_V2) ?? aggregatorV2PublishedAt
16
+ }
17
+ return aggregatorV2PublishedAt
18
+ }
19
+
20
+ export function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt: string, packages?: Map<string, string> | Record<string, string>) {
21
+ if (packages instanceof Map) {
22
+ return packages.get(AGGREGATOR_V2_EXTEND) ?? aggregatorV2ExtendPublishedAt
23
+ }
24
+ return aggregatorV2ExtendPublishedAt
25
+ }
26
+
10
27
  export interface Dex {
11
28
  swap(
12
29
  client: AggregatorClient,
13
30
  ptb: Transaction,
14
31
  path: Path,
15
32
  inputCoin: TransactionObjectArgument,
16
- deepbookv3DeepFee?: TransactionObjectArgument
33
+ packages?: Map<string, string>,
34
+ deepbookv3DeepFee?: TransactionObjectArgument,
17
35
  ): Promise<TransactionObjectArgument>
18
36
  }
37
+
@@ -2,7 +2,7 @@ import {
2
2
  Transaction,
3
3
  TransactionObjectArgument,
4
4
  } from "@mysten/sui/transactions"
5
- import { AggregatorClient, Dex, Env, Path } from ".."
5
+ import { AggregatorClient, Dex, Env, getAggregatorV2PublishedAt, Path } from ".."
6
6
 
7
7
  export class KriyaV2 implements Dex {
8
8
  constructor(env: Env) {
@@ -15,7 +15,8 @@ export class KriyaV2 implements Dex {
15
15
  client: AggregatorClient,
16
16
  txb: Transaction,
17
17
  path: Path,
18
- inputCoin: TransactionObjectArgument
18
+ inputCoin: TransactionObjectArgument,
19
+ packages?: Map<string, string>
19
20
  ): Promise<TransactionObjectArgument> {
20
21
  const { direction, from, target } = path
21
22
 
@@ -24,9 +25,9 @@ export class KriyaV2 implements Dex {
24
25
  : ["swap_b2a", target, from]
25
26
 
26
27
  const args = [txb.object(path.id), inputCoin]
27
-
28
+ const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages)
28
29
  const res = txb.moveCall({
29
- target: `${client.publishedAt()}::kriya_amm::${func}`,
30
+ target: `${publishedAt}::kriya_amm::${func}`,
30
31
  typeArguments: [coinAType, coinBType],
31
32
  arguments: args,
32
33
  }) as TransactionObjectArgument
@@ -2,7 +2,7 @@ import {
2
2
  Transaction,
3
3
  TransactionObjectArgument,
4
4
  } from "@mysten/sui/transactions"
5
- import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
5
+ import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2PublishedAt, Path } from ".."
6
6
 
7
7
  export class KriyaV3 implements Dex {
8
8
  private version: string
@@ -20,7 +20,8 @@ export class KriyaV3 implements Dex {
20
20
  client: AggregatorClient,
21
21
  txb: Transaction,
22
22
  path: Path,
23
- inputCoin: TransactionObjectArgument
23
+ inputCoin: TransactionObjectArgument,
24
+ packages?: Map<string, string>
24
25
  ): Promise<TransactionObjectArgument> {
25
26
  const { direction, from, target } = path
26
27
 
@@ -34,9 +35,9 @@ export class KriyaV3 implements Dex {
34
35
  txb.object(this.version),
35
36
  txb.object(CLOCK_ADDRESS),
36
37
  ]
37
-
38
+ const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages)
38
39
  const res = txb.moveCall({
39
- target: `${client.publishedAt()}::kriya_clmm::${func}`,
40
+ target: `${publishedAt}::kriya_clmm::${func}`,
40
41
  typeArguments: [coinAType, coinBType],
41
42
  arguments: args,
42
43
  }) as TransactionObjectArgument
@@ -2,7 +2,7 @@ import {
2
2
  Transaction,
3
3
  TransactionObjectArgument,
4
4
  } from "@mysten/sui/transactions"
5
- import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
5
+ import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2ExtendPublishedAt, Path } from ".."
6
6
 
7
7
  export class Scallop implements Dex {
8
8
  private version: string
@@ -27,7 +27,8 @@ export class Scallop implements Dex {
27
27
  client: AggregatorClient,
28
28
  txb: Transaction,
29
29
  path: Path,
30
- inputCoin: TransactionObjectArgument
30
+ inputCoin: TransactionObjectArgument,
31
+ packages?: Map<string, string>
31
32
  ): Promise<TransactionObjectArgument> {
32
33
  const { direction, from, target } = path
33
34
 
@@ -51,9 +52,9 @@ export class Scallop implements Dex {
51
52
  inputCoin,
52
53
  txb.object(CLOCK_ADDRESS),
53
54
  ]
54
-
55
+ const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages)
55
56
  const res = txb.moveCall({
56
- target: `${client.publishedAtV2()}::scallop::${func}`,
57
+ target: `${publishedAt}::scallop::${func}`,
57
58
  typeArguments: [coinAType, coinBType],
58
59
  arguments: args,
59
60
  }) as TransactionObjectArgument
@@ -2,10 +2,9 @@ import {
2
2
  Transaction,
3
3
  TransactionObjectArgument,
4
4
  } from "@mysten/sui/transactions"
5
- import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
5
+ import { AggregatorClient, Dex, Env, getAggregatorV2ExtendPublishedAt, Path } from ".."
6
6
 
7
7
  export class Suilend implements Dex {
8
- private liquid_staking_pool: string
9
8
  private sui_system_state: string
10
9
 
11
10
  constructor(env: Env) {
@@ -13,10 +12,6 @@ export class Suilend implements Dex {
13
12
  throw new Error("Suilend only supported on mainnet")
14
13
  }
15
14
 
16
- this.liquid_staking_pool = env === Env.Mainnet
17
- ? "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b"
18
- : "0x0"
19
-
20
15
  this.sui_system_state =
21
16
  env === Env.Mainnet
22
17
  ? "0x0000000000000000000000000000000000000000000000000000000000000005"
@@ -27,7 +22,8 @@ export class Suilend implements Dex {
27
22
  client: AggregatorClient,
28
23
  txb: Transaction,
29
24
  path: Path,
30
- inputCoin: TransactionObjectArgument
25
+ inputCoin: TransactionObjectArgument,
26
+ packages?: Map<string, string>
31
27
  ): Promise<TransactionObjectArgument> {
32
28
  const { direction, from, target } = path
33
29
 
@@ -36,13 +32,13 @@ export class Suilend implements Dex {
36
32
  : ["swap_b2a", from]
37
33
 
38
34
  const args = [
39
- txb.object(this.liquid_staking_pool),
35
+ txb.object(path.id),
40
36
  txb.object(this.sui_system_state),
41
37
  inputCoin,
42
38
  ]
43
-
39
+ const publishedAt = getAggregatorV2ExtendPublishedAt(client.publishedAtV2Extend(), packages)
44
40
  const res = txb.moveCall({
45
- target: `${client.publishedAtV2()}::suilend::${func}`,
41
+ target: `${publishedAt}::suilend::${func}`,
46
42
  typeArguments: [springCoinType],
47
43
  arguments: args,
48
44
  }) as TransactionObjectArgument
@@ -155,6 +155,7 @@ export async function swapInPools(
155
155
  },
156
156
  ],
157
157
  insufficientLiquidity: false,
158
+ byAmountIn: params.byAmountIn,
158
159
  }
159
160
 
160
161
  const result = {
@@ -3,7 +3,7 @@ import {
3
3
  TransactionArgument,
4
4
  TransactionObjectArgument,
5
5
  } from "@mysten/sui/transactions"
6
- import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
6
+ import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, getAggregatorV2PublishedAt, Path } from ".."
7
7
 
8
8
  export class Turbos implements Dex {
9
9
  private versioned: string
@@ -21,7 +21,8 @@ export class Turbos implements Dex {
21
21
  client: AggregatorClient,
22
22
  txb: Transaction,
23
23
  path: Path,
24
- inputCoin: TransactionObjectArgument
24
+ inputCoin: TransactionObjectArgument,
25
+ packages?: Map<string, string>
25
26
  ): Promise<TransactionObjectArgument> {
26
27
  const { direction, from, target } = path
27
28
 
@@ -43,9 +44,9 @@ export class Turbos implements Dex {
43
44
  txb.object(CLOCK_ADDRESS),
44
45
  txb.object(this.versioned),
45
46
  ]
46
-
47
+ const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages)
47
48
  const res = txb.moveCall({
48
- target: `${client.publishedAt()}::turbos::${func}`,
49
+ target: `${publishedAt}::turbos::${func}`,
49
50
  typeArguments: [coinAType, coinBType, path.extendedDetails.turbosFeeType],
50
51
  arguments: args,
51
52
  }) as TransactionObjectArgument
@@ -2,7 +2,7 @@ import {
2
2
  Transaction,
3
3
  TransactionObjectArgument,
4
4
  } from "@mysten/sui/transactions"
5
- import { AggregatorClient, Dex, Env, Path } from ".."
5
+ import { AggregatorClient, Dex, Env, getAggregatorV2PublishedAt, Path } from ".."
6
6
 
7
7
  export class Volo implements Dex {
8
8
  private nativePool: string
@@ -23,7 +23,8 @@ export class Volo implements Dex {
23
23
  client: AggregatorClient,
24
24
  txb: Transaction,
25
25
  path: Path,
26
- inputCoin: TransactionObjectArgument
26
+ inputCoin: TransactionObjectArgument,
27
+ packages?: Map<string, string>
27
28
  ): Promise<TransactionObjectArgument> {
28
29
  const { direction } = path
29
30
 
@@ -40,8 +41,9 @@ export class Volo implements Dex {
40
41
  inputCoin,
41
42
  ]
42
43
 
44
+ const publishedAt = getAggregatorV2PublishedAt(client.publishedAtV2(), packages)
43
45
  const res = txb.moveCall({
44
- target: `${client.publishedAt()}::volo::${func}`,
46
+ target: `${publishedAt}::volo::${func}`,
45
47
  typeArguments: [],
46
48
  arguments: args,
47
49
  }) as TransactionObjectArgument
package/src/utils/coin.ts CHANGED
@@ -61,15 +61,23 @@ export function buildInputCoin(
61
61
  txb: Transaction,
62
62
  allCoins: CoinAsset[],
63
63
  amount: bigint,
64
- coinType: string
64
+ coinType: string,
65
65
  ): BuildCoinResult {
66
66
  const usedCoinAsests = CoinUtils.getCoinAssets(coinType, allCoins)
67
- if (amount === BigInt(0) && usedCoinAsests.length === 0) {
68
- const zeroCoin = mintZeroCoin(txb, coinType)
69
- return {
70
- targetCoin: zeroCoin,
71
- isMintZeroCoin: true,
72
- targetCoinAmount: 0,
67
+ if (amount === BigInt(0)) {
68
+ if (CoinUtils.isSuiCoin(coinType) || usedCoinAsests.length === 0 && !CoinUtils.isSuiCoin(coinType)) {
69
+ const zeroCoin = mintZeroCoin(txb, coinType)
70
+ return {
71
+ targetCoin: zeroCoin,
72
+ isMintZeroCoin: true,
73
+ targetCoinAmount: 0,
74
+ }
75
+ } else {
76
+ return {
77
+ targetCoin: txb.object(usedCoinAsests[0].coinObjectId),
78
+ isMintZeroCoin: false,
79
+ targetCoinAmount: Number(usedCoinAsests[0].balance.toString()),
80
+ }
73
81
  }
74
82
  }
75
83
 
@@ -116,8 +124,12 @@ export function buildInputCoin(
116
124
  )
117
125
  }
118
126
 
127
+ const targetCoin = txb.splitCoins(txb.object(masterCoin), [
128
+ txb.pure.u64(amount.toString()),
129
+ ])
130
+
119
131
  return {
120
- targetCoin: txb.object(masterCoin),
132
+ targetCoin,
121
133
  isMintZeroCoin: false,
122
134
  targetCoinAmount: Number(amount.toString()),
123
135
  }
@@ -33,9 +33,9 @@ describe("router module", () => {
33
33
  keypair = buildTestAccount()
34
34
  }
35
35
 
36
- // const wallet = keypair.getPublicKey().toSuiAddress()
37
- // console.log("wallet: ", wallet)
38
- const wallet = "0x0005e9b405ab0424b6494b64d3d5b79b6715d06d284585faffe1ee1a873ba8a3"
36
+ const wallet = keypair.getPublicKey().toSuiAddress()
37
+ console.log("wallet: ", wallet)
38
+ // const wallet = "0x02e39bddb06f617112595378fef741f523fbf22ea188cca99ecb61a9904dda2a"
39
39
 
40
40
  const endpoint = aggregatorURL
41
41
 
@@ -78,7 +78,6 @@ describe("router module", () => {
78
78
  byAmountIn,
79
79
  txb,
80
80
  slippage: 0.01,
81
- isMergeTragetCoin: false,
82
81
  refreshAllCoins: true,
83
82
  })
84
83
 
@@ -110,9 +109,9 @@ describe("router module", () => {
110
109
 
111
110
  test("Build router tx", async () => {
112
111
  const byAmountIn = true
113
- const amount = "746028139919"
114
- const target = "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT"
115
- const from = "0x2::sui::SUI"
112
+ const amount = "10000"
113
+ const from = "0x83556891f4a0f233ce7b05cfe7f957d4020492a34f5405b2cb9377d060bef4bf::spring_sui::SPRING_SUI"
114
+ const target = "0x2::sui::SUI"
116
115
 
117
116
  const res = await client.findRouters({
118
117
  from,
@@ -120,7 +119,7 @@ describe("router module", () => {
120
119
  amount: new BN(amount),
121
120
  byAmountIn,
122
121
  depth: 3,
123
- // providers: ["HAEDAL"],
122
+ providers: ["SUILEND"],
124
123
  })
125
124
 
126
125
  if (res != null) {
@@ -135,12 +134,9 @@ describe("router module", () => {
135
134
  if (res != null) {
136
135
  console.log(JSON.stringify(res, null, 2))
137
136
  await client.fastRouterSwap({
138
- routers: res.routes,
139
- byAmountIn,
137
+ routers: res,
140
138
  txb,
141
139
  slippage: 0.01,
142
- isMergeTragetCoin: false,
143
- // partner: "0x1f5fa5c820f40d43fc47815ad06d95e40a1942ff72a732a92e8ef4aa8cde70a5",
144
140
  refreshAllCoins: true,
145
141
  payDeepFeeAmount: 0,
146
142
  })
@@ -153,13 +149,13 @@ describe("router module", () => {
153
149
  console.log("event", JSON.stringify(event, null, 2))
154
150
  }
155
151
 
156
- // if (result.effects.status.status === "success") {
157
- // // console.log("Sim exec transaction success")
158
- // const result = await client.signAndExecuteTransaction(txb, keypair)
159
- // console.log("result", result)
160
- // } else {
161
- // console.log("result", result)
162
- // }
152
+ if (result.effects.status.status === "success") {
153
+ // console.log("Sim exec transaction success")
154
+ const result = await client.signAndExecuteTransaction(txb, keypair)
155
+ console.log("result", result)
156
+ } else {
157
+ console.log("result", result)
158
+ }
163
159
  }
164
160
  }, 600000)
165
161
 
@@ -190,7 +186,6 @@ describe("router module", () => {
190
186
  byAmountIn,
191
187
  txb,
192
188
  slippage: 0.02,
193
- isMergeTragetCoin: false,
194
189
  refreshAllCoins: true,
195
190
  })
196
191
 
@@ -240,7 +235,6 @@ describe("router module", () => {
240
235
  byAmountIn,
241
236
  slippage: 0.01,
242
237
  txb,
243
- isMergeTragetCoin: false,
244
238
  })
245
239
 
246
240
  let result = await client.devInspectTransactionBlock(txb)
@@ -322,7 +316,6 @@ describe("router module", () => {
322
316
  byAmountIn,
323
317
  txb,
324
318
  slippage: 0.01,
325
- isMergeTragetCoin: false,
326
319
  refreshAllCoins: true,
327
320
  })
328
321