@cetusprotocol/aggregator-sdk 0.1.1 → 0.2.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.
package/dist/index.d.mts CHANGED
@@ -64,6 +64,7 @@ declare const CETUS = "CETUS";
64
64
  declare const DEEPBOOKV2 = "DEEPBOOK";
65
65
  declare const KRIYA = "KRIYA";
66
66
  declare const FLOWXV2 = "FLOWX";
67
+ declare const FLOWXV3 = "FLOWXV3";
67
68
  declare const KRIYAV3 = "KRIYAV3";
68
69
  declare const TURBOS = "TURBOS";
69
70
  declare const AFTERMATH = "AFTERMATH";
@@ -208,4 +209,4 @@ declare enum Env {
208
209
  Testnet = 1
209
210
  }
210
211
 
211
- export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type Router, type RouterData, type RouterError, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
212
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type Router, type RouterData, type RouterError, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
package/dist/index.d.ts CHANGED
@@ -64,6 +64,7 @@ declare const CETUS = "CETUS";
64
64
  declare const DEEPBOOKV2 = "DEEPBOOK";
65
65
  declare const KRIYA = "KRIYA";
66
66
  declare const FLOWXV2 = "FLOWX";
67
+ declare const FLOWXV3 = "FLOWXV3";
67
68
  declare const KRIYAV3 = "KRIYAV3";
68
69
  declare const TURBOS = "TURBOS";
69
70
  declare const AFTERMATH = "AFTERMATH";
@@ -208,4 +209,4 @@ declare enum Env {
208
209
  Testnet = 1
209
210
  }
210
211
 
211
- export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type Router, type RouterData, type RouterError, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
212
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type Router, type RouterData, type RouterError, type SwapInPoolsParams, type SwapInPoolsResult, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
package/dist/index.js CHANGED
@@ -5857,7 +5857,6 @@ var Haedal = class {
5857
5857
  throw new Error("Haedal not support b2a swap");
5858
5858
  }
5859
5859
  const func = "swap_a2b";
5860
- console.log("haedal path id", path.id);
5861
5860
  const args = [txb.object(path.id), txb.object("0x5"), inputCoin];
5862
5861
  const res = txb.moveCall({
5863
5862
  target: `${client.publishedAt()}::haedal::${func}`,
@@ -5937,18 +5936,49 @@ var Volo = class {
5937
5936
  }
5938
5937
  };
5939
5938
 
5939
+ // src/transaction/flowx_v3.ts
5940
+ var FlowxV3 = class {
5941
+ constructor(env) {
5942
+ if (env !== 0 /* Mainnet */) {
5943
+ throw new Error("Flowx clmm only supported on mainnet");
5944
+ }
5945
+ this.versioned = "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656";
5946
+ this.poolRegistry = "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc";
5947
+ }
5948
+ swap(client, txb, path, inputCoin) {
5949
+ return __async(this, null, function* () {
5950
+ const { direction, from, target } = path;
5951
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
5952
+ const args = [
5953
+ txb.object(this.poolRegistry),
5954
+ txb.pure.u64(path.feeRate * 1e6),
5955
+ inputCoin,
5956
+ txb.object(this.versioned),
5957
+ txb.object(CLOCK_ADDRESS)
5958
+ ];
5959
+ const res = txb.moveCall({
5960
+ target: `${client.publishedAt()}::flowx_clmm::${func}`,
5961
+ typeArguments: [coinAType, coinBType],
5962
+ arguments: args
5963
+ });
5964
+ return res;
5965
+ });
5966
+ }
5967
+ };
5968
+
5940
5969
  // src/client.ts
5941
5970
  var CETUS = "CETUS";
5942
5971
  var DEEPBOOKV2 = "DEEPBOOK";
5943
5972
  var KRIYA = "KRIYA";
5944
5973
  var FLOWXV2 = "FLOWX";
5974
+ var FLOWXV3 = "FLOWXV3";
5945
5975
  var KRIYAV3 = "KRIYAV3";
5946
5976
  var TURBOS = "TURBOS";
5947
5977
  var AFTERMATH = "AFTERMATH";
5948
5978
  var HAEDAL = "HAEDAL";
5949
5979
  var VOLO = "VOLO";
5950
5980
  var AFSUI = "AFSUI";
5951
- var AggregatorClient5 = class {
5981
+ var AggregatorClient6 = class {
5952
5982
  constructor(endpoint, signer, client, env) {
5953
5983
  this.endpoint = endpoint;
5954
5984
  this.client = client;
@@ -6185,7 +6215,7 @@ var AggregatorClient5 = class {
6185
6215
  }
6186
6216
  publishedAt() {
6187
6217
  if (this.env === 0 /* Mainnet */) {
6188
- return "0x9fd702cf1a8db5a2e99be20be6750d22ec75c30d57e3d9ccbc37c9b4ad7bef21";
6218
+ return "0xeffc8ae61f439bb34c9b905ff8f29ec56873dcedf81c7123ff2f1f67c45ec302";
6189
6219
  } else {
6190
6220
  return "0x0";
6191
6221
  }
@@ -6227,6 +6257,8 @@ var AggregatorClient5 = class {
6227
6257
  return new KriyaV3(this.env);
6228
6258
  case FLOWXV2:
6229
6259
  return new FlowxV2(this.env);
6260
+ case FLOWXV3:
6261
+ return new FlowxV3(this.env);
6230
6262
  case TURBOS:
6231
6263
  return new Turbos(this.env);
6232
6264
  case AFTERMATH:
@@ -6409,12 +6441,13 @@ decimal.js/decimal.mjs:
6409
6441
 
6410
6442
  exports.AFSUI = AFSUI;
6411
6443
  exports.AFTERMATH = AFTERMATH;
6412
- exports.AggregatorClient = AggregatorClient5;
6444
+ exports.AggregatorClient = AggregatorClient6;
6413
6445
  exports.CETUS = CETUS;
6414
6446
  exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
6415
6447
  exports.DEEPBOOKV2 = DEEPBOOKV2;
6416
6448
  exports.Env = Env;
6417
6449
  exports.FLOWXV2 = FLOWXV2;
6450
+ exports.FLOWXV3 = FLOWXV3;
6418
6451
  exports.HAEDAL = HAEDAL;
6419
6452
  exports.KRIYA = KRIYA;
6420
6453
  exports.KRIYAV3 = KRIYAV3;
package/dist/index.mjs CHANGED
@@ -5855,7 +5855,6 @@ var Haedal = class {
5855
5855
  throw new Error("Haedal not support b2a swap");
5856
5856
  }
5857
5857
  const func = "swap_a2b";
5858
- console.log("haedal path id", path.id);
5859
5858
  const args = [txb.object(path.id), txb.object("0x5"), inputCoin];
5860
5859
  const res = txb.moveCall({
5861
5860
  target: `${client.publishedAt()}::haedal::${func}`,
@@ -5935,18 +5934,49 @@ var Volo = class {
5935
5934
  }
5936
5935
  };
5937
5936
 
5937
+ // src/transaction/flowx_v3.ts
5938
+ var FlowxV3 = class {
5939
+ constructor(env) {
5940
+ if (env !== 0 /* Mainnet */) {
5941
+ throw new Error("Flowx clmm only supported on mainnet");
5942
+ }
5943
+ this.versioned = "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656";
5944
+ this.poolRegistry = "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc";
5945
+ }
5946
+ swap(client, txb, path, inputCoin) {
5947
+ return __async(this, null, function* () {
5948
+ const { direction, from, target } = path;
5949
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
5950
+ const args = [
5951
+ txb.object(this.poolRegistry),
5952
+ txb.pure.u64(path.feeRate * 1e6),
5953
+ inputCoin,
5954
+ txb.object(this.versioned),
5955
+ txb.object(CLOCK_ADDRESS)
5956
+ ];
5957
+ const res = txb.moveCall({
5958
+ target: `${client.publishedAt()}::flowx_clmm::${func}`,
5959
+ typeArguments: [coinAType, coinBType],
5960
+ arguments: args
5961
+ });
5962
+ return res;
5963
+ });
5964
+ }
5965
+ };
5966
+
5938
5967
  // src/client.ts
5939
5968
  var CETUS = "CETUS";
5940
5969
  var DEEPBOOKV2 = "DEEPBOOK";
5941
5970
  var KRIYA = "KRIYA";
5942
5971
  var FLOWXV2 = "FLOWX";
5972
+ var FLOWXV3 = "FLOWXV3";
5943
5973
  var KRIYAV3 = "KRIYAV3";
5944
5974
  var TURBOS = "TURBOS";
5945
5975
  var AFTERMATH = "AFTERMATH";
5946
5976
  var HAEDAL = "HAEDAL";
5947
5977
  var VOLO = "VOLO";
5948
5978
  var AFSUI = "AFSUI";
5949
- var AggregatorClient5 = class {
5979
+ var AggregatorClient6 = class {
5950
5980
  constructor(endpoint, signer, client, env) {
5951
5981
  this.endpoint = endpoint;
5952
5982
  this.client = client;
@@ -6183,7 +6213,7 @@ var AggregatorClient5 = class {
6183
6213
  }
6184
6214
  publishedAt() {
6185
6215
  if (this.env === 0 /* Mainnet */) {
6186
- return "0x9fd702cf1a8db5a2e99be20be6750d22ec75c30d57e3d9ccbc37c9b4ad7bef21";
6216
+ return "0xeffc8ae61f439bb34c9b905ff8f29ec56873dcedf81c7123ff2f1f67c45ec302";
6187
6217
  } else {
6188
6218
  return "0x0";
6189
6219
  }
@@ -6225,6 +6255,8 @@ var AggregatorClient5 = class {
6225
6255
  return new KriyaV3(this.env);
6226
6256
  case FLOWXV2:
6227
6257
  return new FlowxV2(this.env);
6258
+ case FLOWXV3:
6259
+ return new FlowxV3(this.env);
6228
6260
  case TURBOS:
6229
6261
  return new Turbos(this.env);
6230
6262
  case AFTERMATH:
@@ -6405,4 +6437,4 @@ decimal.js/decimal.mjs:
6405
6437
  *)
6406
6438
  */
6407
6439
 
6408
- export { AFSUI, AFTERMATH, AggregatorClient5 as AggregatorClient, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, Env, FLOWXV2, HAEDAL, KRIYA, KRIYAV3, ONE, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
6440
+ export { AFSUI, AFTERMATH, AggregatorClient6 as AggregatorClient, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, Env, FLOWXV2, FLOWXV3, HAEDAL, KRIYA, KRIYAV3, ONE, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
@@ -8,6 +8,7 @@ export declare const CETUS = "CETUS";
8
8
  export declare const DEEPBOOKV2 = "DEEPBOOK";
9
9
  export declare const KRIYA = "KRIYA";
10
10
  export declare const FLOWXV2 = "FLOWX";
11
+ export declare const FLOWXV3 = "FLOWXV3";
11
12
  export declare const KRIYAV3 = "KRIYAV3";
12
13
  export declare const TURBOS = "TURBOS";
13
14
  export declare const AFTERMATH = "AFTERMATH";
@@ -0,0 +1,8 @@
1
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { AggregatorClient, Dex, Env, Path } from "..";
3
+ export declare class FlowxV3 implements Dex {
4
+ private versioned;
5
+ private poolRegistry;
6
+ constructor(env: Env);
7
+ swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/client.ts CHANGED
@@ -30,11 +30,13 @@ import { KriyaV3 } from "./transaction/kriya_v3"
30
30
  import { Haedal } from "./transaction/haedal"
31
31
  import { Afsui } from "./transaction/afsui"
32
32
  import { Volo } from "./transaction/volo"
33
+ import { FlowxV3 } from "./transaction/flowx_v3"
33
34
 
34
35
  export const CETUS = "CETUS"
35
36
  export const DEEPBOOKV2 = "DEEPBOOK"
36
37
  export const KRIYA = "KRIYA"
37
38
  export const FLOWXV2 = "FLOWX"
39
+ export const FLOWXV3 = "FLOWXV3"
38
40
  export const KRIYAV3 = "KRIYAV3"
39
41
  export const TURBOS = "TURBOS"
40
42
  export const AFTERMATH = "AFTERMATH"
@@ -333,7 +335,7 @@ export class AggregatorClient {
333
335
 
334
336
  publishedAt(): string {
335
337
  if (this.env === Env.Mainnet) {
336
- return "0x9fd702cf1a8db5a2e99be20be6750d22ec75c30d57e3d9ccbc37c9b4ad7bef21"
338
+ return "0xeffc8ae61f439bb34c9b905ff8f29ec56873dcedf81c7123ff2f1f67c45ec302"
337
339
  } else {
338
340
  return "0x0"
339
341
  }
@@ -388,6 +390,8 @@ export class AggregatorClient {
388
390
  return new KriyaV3(this.env)
389
391
  case FLOWXV2:
390
392
  return new FlowxV2(this.env)
393
+ case FLOWXV3:
394
+ return new FlowxV3(this.env)
391
395
  case TURBOS:
392
396
  return new Turbos(this.env)
393
397
  case AFTERMATH:
@@ -0,0 +1,50 @@
1
+ import {
2
+ Transaction,
3
+ TransactionObjectArgument,
4
+ } from "@mysten/sui/transactions"
5
+ import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
6
+
7
+ export class FlowxV3 implements Dex {
8
+ private versioned: string
9
+ private poolRegistry: string
10
+
11
+ constructor(env: Env) {
12
+ if (env !== Env.Mainnet) {
13
+ throw new Error("Flowx clmm only supported on mainnet")
14
+ }
15
+
16
+ this.versioned =
17
+ "0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656"
18
+ this.poolRegistry =
19
+ "0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc"
20
+ }
21
+
22
+ async swap(
23
+ client: AggregatorClient,
24
+ txb: Transaction,
25
+ path: Path,
26
+ inputCoin: TransactionObjectArgument
27
+ ): Promise<TransactionObjectArgument> {
28
+ const { direction, from, target } = path
29
+
30
+ const [func, coinAType, coinBType] = direction
31
+ ? ["swap_a2b", from, target]
32
+ : ["swap_b2a", target, from]
33
+
34
+ const args = [
35
+ txb.object(this.poolRegistry),
36
+ txb.pure.u64(path.feeRate * 1000000),
37
+ inputCoin,
38
+ txb.object(this.versioned),
39
+ txb.object(CLOCK_ADDRESS),
40
+ ]
41
+
42
+ const res = txb.moveCall({
43
+ target: `${client.publishedAt()}::flowx_clmm::${func}`,
44
+ typeArguments: [coinAType, coinBType],
45
+ arguments: args,
46
+ }) as TransactionObjectArgument
47
+
48
+ return res
49
+ }
50
+ }
@@ -3,7 +3,6 @@ import {
3
3
  TransactionObjectArgument,
4
4
  } from "@mysten/sui/transactions"
5
5
  import { AggregatorClient, Dex, Env, Path } from ".."
6
- import { SUI_SYSTEM_ADDRESS } from "@mysten/sui/utils"
7
6
 
8
7
  export class Haedal implements Dex {
9
8
  constructor(env: Env) {
@@ -19,17 +18,11 @@ export class Haedal implements Dex {
19
18
  inputCoin: TransactionObjectArgument
20
19
  ): Promise<TransactionObjectArgument> {
21
20
  const { direction } = path
22
-
23
21
  if (!direction) {
24
22
  throw new Error("Haedal not support b2a swap")
25
23
  }
26
-
27
24
  const func = "swap_a2b"
28
-
29
- console.log("haedal path id", path.id)
30
-
31
25
  const args = [txb.object(path.id), txb.object("0x5"), inputCoin]
32
-
33
26
  const res = txb.moveCall({
34
27
  target: `${client.publishedAt()}::haedal::${func}`,
35
28
  typeArguments: [],
package/src/utils/coin.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { SuiZeroCoinFn } from "../const"
2
1
  import { CoinAsset } from "../types/sui"
3
2
  import { CoinUtils } from "../types/CoinAssist"
4
3
  import { TransactionErrorCode } from "../errors"
@@ -33,14 +33,14 @@ describe("router module", () => {
33
33
  keypair = buildTestAccount()
34
34
  }
35
35
 
36
- const wallet = keypair.getPublicKey().toSuiAddress()
36
+ // const wallet = keypair.getPublicKey().toSuiAddress()
37
37
 
38
38
  // console.log("wallet", wallet, "\n", wallet.toString())
39
39
 
40
+ const wallet =
41
+ "0xfba94aa36e93ccc7d84a6a57040fc51983223f1b522a8d0be3c3bf2c98977ebb"
40
42
  // const wallet =
41
- // "0xfba94aa36e93ccc7d84a6a57040fc51983223f1b522a8d0be3c3bf2c98977ebb"
42
- // const wallet =
43
- // "0xa459702162b73204eed77420d93d9453b7a7b893a0edea1e268607cf7fa76e03"
43
+ // "0xa459702162b73204eed77420d93d9453b7a7b893a0edea1e268607cf7fa76e03"
44
44
  // const wallet =
45
45
  // "0xaabf2fedcb36146db164bec930b74a47969c4df98216e049342a3c49b6d11580"
46
46
  // const wallet = "0x410456cfc689666936b6bf80fbec958b69499b9f7183ecba07de577c17248a44"
@@ -77,7 +77,7 @@ describe("router module", () => {
77
77
  })
78
78
 
79
79
  test("Downgrade swap in route", async () => {
80
- const amount = 1000000
80
+ const amount = 100000
81
81
  const byAmountIn = false
82
82
 
83
83
  const res: any = await client.swapInPools({
@@ -139,8 +139,7 @@ describe("router module", () => {
139
139
  // const target =
140
140
  // "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI"
141
141
 
142
- const target =
143
- "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
142
+ const target = M_USDC
144
143
 
145
144
  const res = await client.findRouters({
146
145
  from,
@@ -156,7 +155,7 @@ describe("router module", () => {
156
155
  // "KRIYA",
157
156
  // "KRIYAV3",
158
157
  // "TURBOS",
159
- "VOLO",
158
+ "FLOWXV3",
160
159
  ],
161
160
  })
162
161