@cetusprotocol/aggregator-sdk 0.3.0 → 0.3.1

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
@@ -72,6 +72,7 @@ declare const HAEDAL = "HAEDAL";
72
72
  declare const VOLO = "VOLO";
73
73
  declare const AFSUI = "AFSUI";
74
74
  declare const BLUEMOVE = "BLUEMOVE";
75
+ declare const DEEPBOOKV3 = "DEEPBOOKV3";
75
76
  type BuildRouterSwapParams = {
76
77
  routers: Router[];
77
78
  byAmountIn: boolean;
@@ -221,4 +222,4 @@ declare enum Env {
221
222
  Testnet = 1
222
223
  }
223
224
 
224
- export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, 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, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
225
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, 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, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
package/dist/index.d.ts CHANGED
@@ -72,6 +72,7 @@ declare const HAEDAL = "HAEDAL";
72
72
  declare const VOLO = "VOLO";
73
73
  declare const AFSUI = "AFSUI";
74
74
  declare const BLUEMOVE = "BLUEMOVE";
75
+ declare const DEEPBOOKV3 = "DEEPBOOKV3";
75
76
  type BuildRouterSwapParams = {
76
77
  routers: Router[];
77
78
  byAmountIn: boolean;
@@ -221,4 +222,4 @@ declare enum Env {
221
222
  Testnet = 1
222
223
  }
223
224
 
224
- export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, 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, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
225
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, 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, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
package/dist/index.js CHANGED
@@ -5992,6 +5992,34 @@ var Bluemove = class {
5992
5992
  }
5993
5993
  };
5994
5994
 
5995
+ // src/transaction/deepbook_v3.ts
5996
+ var DeepbookV3 = class {
5997
+ constructor(env) {
5998
+ this.deepbookV3Config = env === 0 /* Mainnet */ ? "0x0" : "0x77018927a5d7ed7b4c49312b71581f5f12ba52ba7e1219a15181ffc3d459f527";
5999
+ this.deepCoinType = env === 0 /* Mainnet */ ? "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP" : "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
6000
+ }
6001
+ swap(client, txb, path, inputCoin) {
6002
+ return __async(this, null, function* () {
6003
+ const { direction, from, target } = path;
6004
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6005
+ const zeroDeep = mintZeroCoin(txb, this.deepCoinType);
6006
+ const args = [
6007
+ txb.object(this.deepbookV3Config),
6008
+ txb.object(path.id),
6009
+ inputCoin,
6010
+ zeroDeep,
6011
+ txb.object(CLOCK_ADDRESS)
6012
+ ];
6013
+ const res = txb.moveCall({
6014
+ target: `${client.publishedAt()}::deepbookv3::${func}`,
6015
+ typeArguments: [coinAType, coinBType],
6016
+ arguments: args
6017
+ });
6018
+ return res;
6019
+ });
6020
+ }
6021
+ };
6022
+
5995
6023
  // src/client.ts
5996
6024
  var CETUS = "CETUS";
5997
6025
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6005,7 +6033,8 @@ var HAEDAL = "HAEDAL";
6005
6033
  var VOLO = "VOLO";
6006
6034
  var AFSUI = "AFSUI";
6007
6035
  var BLUEMOVE = "BLUEMOVE";
6008
- var AggregatorClient6 = class {
6036
+ var DEEPBOOKV3 = "DEEPBOOKV3";
6037
+ var AggregatorClient7 = class {
6009
6038
  constructor(endpoint, signer, client, env) {
6010
6039
  this.endpoint = endpoint;
6011
6040
  this.client = client;
@@ -6242,9 +6271,9 @@ var AggregatorClient6 = class {
6242
6271
  }
6243
6272
  publishedAt() {
6244
6273
  if (this.env === 0 /* Mainnet */) {
6245
- return "0x764b8132a94d35abc9dfd91b23a0757b2a717d5ecb04c03098794aa2a508db91";
6274
+ return "0xf98ed029af555e4a103febf26243dc33ac09a7ea1b2da7e414c728b25b729086";
6246
6275
  } else {
6247
- return "0x6cbaa3e9fbe902d90191b12f315932bc58079cba422bafbd4b4369f80e61f595";
6276
+ return "0xb2db335c85473e7ed952351bb594100eb8f61122703219c6b8dbcdcade2795b3";
6248
6277
  }
6249
6278
  }
6250
6279
  transferOrDestoryCoin(txb, coin, coinType) {
@@ -6278,6 +6307,8 @@ var AggregatorClient6 = class {
6278
6307
  return new Cetus(this.env, partner);
6279
6308
  case DEEPBOOKV2:
6280
6309
  return new DeepbookV2(this.env);
6310
+ case DEEPBOOKV3:
6311
+ return new DeepbookV3(this.env);
6281
6312
  case KRIYA:
6282
6313
  return new KriyaV2(this.env);
6283
6314
  case KRIYAV3:
@@ -6486,6 +6517,7 @@ function getRouter(endpoint, params) {
6486
6517
  url += `&providers=${providers.join(",")}`;
6487
6518
  }
6488
6519
  }
6520
+ url += "&v=1000301";
6489
6521
  const response = yield fetch(url);
6490
6522
  return response;
6491
6523
  } catch (error) {
@@ -6566,11 +6598,12 @@ decimal.js/decimal.mjs:
6566
6598
 
6567
6599
  exports.AFSUI = AFSUI;
6568
6600
  exports.AFTERMATH = AFTERMATH;
6569
- exports.AggregatorClient = AggregatorClient6;
6601
+ exports.AggregatorClient = AggregatorClient7;
6570
6602
  exports.BLUEMOVE = BLUEMOVE;
6571
6603
  exports.CETUS = CETUS;
6572
6604
  exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
6573
6605
  exports.DEEPBOOKV2 = DEEPBOOKV2;
6606
+ exports.DEEPBOOKV3 = DEEPBOOKV3;
6574
6607
  exports.Env = Env;
6575
6608
  exports.FLOWXV2 = FLOWXV2;
6576
6609
  exports.FLOWXV3 = FLOWXV3;
package/dist/index.mjs CHANGED
@@ -5990,6 +5990,34 @@ var Bluemove = class {
5990
5990
  }
5991
5991
  };
5992
5992
 
5993
+ // src/transaction/deepbook_v3.ts
5994
+ var DeepbookV3 = class {
5995
+ constructor(env) {
5996
+ this.deepbookV3Config = env === 0 /* Mainnet */ ? "0x0" : "0x77018927a5d7ed7b4c49312b71581f5f12ba52ba7e1219a15181ffc3d459f527";
5997
+ this.deepCoinType = env === 0 /* Mainnet */ ? "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP" : "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
5998
+ }
5999
+ swap(client, txb, path, inputCoin) {
6000
+ return __async(this, null, function* () {
6001
+ const { direction, from, target } = path;
6002
+ const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6003
+ const zeroDeep = mintZeroCoin(txb, this.deepCoinType);
6004
+ const args = [
6005
+ txb.object(this.deepbookV3Config),
6006
+ txb.object(path.id),
6007
+ inputCoin,
6008
+ zeroDeep,
6009
+ txb.object(CLOCK_ADDRESS)
6010
+ ];
6011
+ const res = txb.moveCall({
6012
+ target: `${client.publishedAt()}::deepbookv3::${func}`,
6013
+ typeArguments: [coinAType, coinBType],
6014
+ arguments: args
6015
+ });
6016
+ return res;
6017
+ });
6018
+ }
6019
+ };
6020
+
5993
6021
  // src/client.ts
5994
6022
  var CETUS = "CETUS";
5995
6023
  var DEEPBOOKV2 = "DEEPBOOK";
@@ -6003,7 +6031,8 @@ var HAEDAL = "HAEDAL";
6003
6031
  var VOLO = "VOLO";
6004
6032
  var AFSUI = "AFSUI";
6005
6033
  var BLUEMOVE = "BLUEMOVE";
6006
- var AggregatorClient6 = class {
6034
+ var DEEPBOOKV3 = "DEEPBOOKV3";
6035
+ var AggregatorClient7 = class {
6007
6036
  constructor(endpoint, signer, client, env) {
6008
6037
  this.endpoint = endpoint;
6009
6038
  this.client = client;
@@ -6240,9 +6269,9 @@ var AggregatorClient6 = class {
6240
6269
  }
6241
6270
  publishedAt() {
6242
6271
  if (this.env === 0 /* Mainnet */) {
6243
- return "0x764b8132a94d35abc9dfd91b23a0757b2a717d5ecb04c03098794aa2a508db91";
6272
+ return "0xf98ed029af555e4a103febf26243dc33ac09a7ea1b2da7e414c728b25b729086";
6244
6273
  } else {
6245
- return "0x6cbaa3e9fbe902d90191b12f315932bc58079cba422bafbd4b4369f80e61f595";
6274
+ return "0xb2db335c85473e7ed952351bb594100eb8f61122703219c6b8dbcdcade2795b3";
6246
6275
  }
6247
6276
  }
6248
6277
  transferOrDestoryCoin(txb, coin, coinType) {
@@ -6276,6 +6305,8 @@ var AggregatorClient6 = class {
6276
6305
  return new Cetus(this.env, partner);
6277
6306
  case DEEPBOOKV2:
6278
6307
  return new DeepbookV2(this.env);
6308
+ case DEEPBOOKV3:
6309
+ return new DeepbookV3(this.env);
6279
6310
  case KRIYA:
6280
6311
  return new KriyaV2(this.env);
6281
6312
  case KRIYAV3:
@@ -6484,6 +6515,7 @@ function getRouter(endpoint, params) {
6484
6515
  url += `&providers=${providers.join(",")}`;
6485
6516
  }
6486
6517
  }
6518
+ url += "&v=1000301";
6487
6519
  const response = yield fetch(url);
6488
6520
  return response;
6489
6521
  } catch (error) {
@@ -6562,4 +6594,4 @@ decimal.js/decimal.mjs:
6562
6594
  *)
6563
6595
  */
6564
6596
 
6565
- export { AFSUI, AFTERMATH, AggregatorClient6 as AggregatorClient, BLUEMOVE, 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, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
6597
+ export { AFSUI, AFTERMATH, AggregatorClient7 as AggregatorClient, BLUEMOVE, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, Env, FLOWXV2, FLOWXV3, HAEDAL, KRIYA, KRIYAV3, ONE, TEN_POW_NINE, TURBOS, TWO, U128, U64_MAX, U64_MAX_BN, VOLO, ZERO, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, restituteMsafeFastRouterSwapParams };
@@ -16,6 +16,7 @@ export declare const HAEDAL = "HAEDAL";
16
16
  export declare const VOLO = "VOLO";
17
17
  export declare const AFSUI = "AFSUI";
18
18
  export declare const BLUEMOVE = "BLUEMOVE";
19
+ export declare const DEEPBOOKV3 = "DEEPBOOKV3";
19
20
  export type BuildRouterSwapParams = {
20
21
  routers: Router[];
21
22
  byAmountIn: boolean;
@@ -0,0 +1,13 @@
1
+ import { Transaction, TransactionArgument, TransactionObjectArgument } from "@mysten/sui/transactions";
2
+ import { AggregatorClient, Dex, Env, Path } from "..";
3
+ export type CetusFlashSwapResult = {
4
+ targetCoin: TransactionObjectArgument;
5
+ flashReceipt: TransactionObjectArgument;
6
+ payAmount: TransactionArgument;
7
+ };
8
+ export declare class DeepbookV3 implements Dex {
9
+ private deepbookV3Config;
10
+ private deepCoinType;
11
+ constructor(env: Env);
12
+ swap(client: AggregatorClient, txb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/api.ts CHANGED
@@ -164,6 +164,9 @@ async function getRouter(endpoint: string, params: FindRouterParams) {
164
164
  }
165
165
  }
166
166
 
167
+ // set newest sdk version
168
+ url += "&v=1000301"
169
+
167
170
  const response = await fetch(url)
168
171
  return response
169
172
  } catch (error) {
package/src/client.ts CHANGED
@@ -32,6 +32,7 @@ import { Volo } from "./transaction/volo"
32
32
  import { Bluemove } from "./transaction/bluemove"
33
33
  import { CoinAsset } from "./types/sui"
34
34
  import { buildInputCoin } from "./utils/coin"
35
+ import { DeepbookV3 } from "./transaction/deepbook_v3"
35
36
 
36
37
  export const CETUS = "CETUS"
37
38
  export const DEEPBOOKV2 = "DEEPBOOK"
@@ -45,7 +46,7 @@ export const HAEDAL = "HAEDAL"
45
46
  export const VOLO = "VOLO"
46
47
  export const AFSUI = "AFSUI"
47
48
  export const BLUEMOVE = "BLUEMOVE"
48
-
49
+ export const DEEPBOOKV3 = "DEEPBOOKV3"
49
50
  export type BuildRouterSwapParams = {
50
51
  routers: Router[]
51
52
  byAmountIn: boolean
@@ -337,9 +338,9 @@ export class AggregatorClient {
337
338
 
338
339
  publishedAt(): string {
339
340
  if (this.env === Env.Mainnet) {
340
- return "0x764b8132a94d35abc9dfd91b23a0757b2a717d5ecb04c03098794aa2a508db91"
341
+ return "0xf98ed029af555e4a103febf26243dc33ac09a7ea1b2da7e414c728b25b729086"
341
342
  } else {
342
- return "0x6cbaa3e9fbe902d90191b12f315932bc58079cba422bafbd4b4369f80e61f595"
343
+ return "0xb2db335c85473e7ed952351bb594100eb8f61122703219c6b8dbcdcade2795b3"
343
344
  }
344
345
  }
345
346
 
@@ -372,7 +373,7 @@ export class AggregatorClient {
372
373
  targetCoin = coins[0]
373
374
  }
374
375
 
375
- const res = txb.moveCall({
376
+ txb.moveCall({
376
377
  target: `${this.publishedAt()}::utils::check_coin_threshold`,
377
378
  typeArguments: [coinType],
378
379
  arguments: [targetCoin, txb.pure.u64(amountLimit.toString())],
@@ -386,6 +387,8 @@ export class AggregatorClient {
386
387
  return new Cetus(this.env, partner)
387
388
  case DEEPBOOKV2:
388
389
  return new DeepbookV2(this.env)
390
+ case DEEPBOOKV3:
391
+ return new DeepbookV3(this.env)
389
392
  case KRIYA:
390
393
  return new KriyaV2(this.env)
391
394
  case KRIYAV3:
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  Transaction,
3
- TransactionArgument,
4
3
  TransactionObjectArgument,
5
4
  } from "@mysten/sui/transactions"
6
5
  import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
@@ -0,0 +1,56 @@
1
+ import {
2
+ Transaction,
3
+ TransactionArgument,
4
+ TransactionObjectArgument,
5
+ } from "@mysten/sui/transactions"
6
+ import { AggregatorClient, CLOCK_ADDRESS, Dex, Env, Path } from ".."
7
+ import { mintZeroCoin } from "~/utils/coin"
8
+
9
+ export type CetusFlashSwapResult = {
10
+ targetCoin: TransactionObjectArgument
11
+ flashReceipt: TransactionObjectArgument
12
+ payAmount: TransactionArgument
13
+ }
14
+
15
+ export class DeepbookV3 implements Dex {
16
+ private deepbookV3Config: string
17
+ private deepCoinType: string
18
+
19
+ constructor(env: Env) {
20
+ this.deepbookV3Config =
21
+ env === Env.Mainnet
22
+ ? "0x0"
23
+ : "0x77018927a5d7ed7b4c49312b71581f5f12ba52ba7e1219a15181ffc3d459f527"
24
+ this.deepCoinType =
25
+ env === Env.Mainnet
26
+ ? "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP"
27
+ : "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP"
28
+ }
29
+
30
+ async swap(
31
+ client: AggregatorClient,
32
+ txb: Transaction,
33
+ path: Path,
34
+ inputCoin: TransactionObjectArgument
35
+ ): Promise<TransactionObjectArgument> {
36
+ const { direction, from, target } = path
37
+ const [func, coinAType, coinBType] = direction
38
+ ? ["swap_a2b", from, target]
39
+ : ["swap_b2a", target, from]
40
+
41
+ const zeroDeep = mintZeroCoin(txb, this.deepCoinType)
42
+ const args = [
43
+ txb.object(this.deepbookV3Config),
44
+ txb.object(path.id),
45
+ inputCoin,
46
+ zeroDeep,
47
+ txb.object(CLOCK_ADDRESS),
48
+ ]
49
+ const res = txb.moveCall({
50
+ target: `${client.publishedAt()}::deepbookv3::${func}`,
51
+ typeArguments: [coinAType, coinBType],
52
+ arguments: args,
53
+ }) as TransactionArgument
54
+ return res
55
+ }
56
+ }
package/test.json ADDED
@@ -0,0 +1,5 @@
1
+ [
2
+ [Path { id: "0x0d1b1746d220bd5ebac5231c7685480a16f1c707a46306095a4c67dc7ce4dcae", edge_id: "0x0d1b1746d220bd5ebac5231c7685480a16f1c707a46306095a4c67dc7ce4dcae", provider: "DEEPBOOKV3", from: "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP", target: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI", direction: true, fee_rate: Decimal(0), lot_size: 1000000, amount_in: 0, amount_out: 0, max_depth: 3, extended_details: None, allow_bidirection: true
3
+ }
4
+ ]
5
+ ]
@@ -45,7 +45,7 @@ describe("router module", () => {
45
45
  // console.log("wallet", wallet, "\n", wallet.toString())
46
46
 
47
47
  const wallet =
48
- "0xfba94aa36e93ccc7d84a6a57040fc51983223f1b522a8d0be3c3bf2c98977ebb"
48
+ "0xf7b8d77dd06a6bb51c37ad3ce69e0a44c6f1064f52ac54606ef47763c8a71be6"
49
49
  // const wallet =
50
50
  // "0xa459702162b73204eed77420d93d9453b7a7b893a0edea1e268607cf7fa76e03"
51
51
  // const wallet =