@cetusprotocol/aggregator-sdk 0.0.0-experimental-20240929131950 → 0.0.0-experimental-20241009201249

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 "0x57cb657a4f6401b07e975a4e4326206e8ba9c585d76e639793d9132e56e26c8b";
6274
+ return "0x764b8132a94d35abc9dfd91b23a0757b2a717d5ecb04c03098794aa2a508db91";
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:
@@ -6566,11 +6597,12 @@ decimal.js/decimal.mjs:
6566
6597
 
6567
6598
  exports.AFSUI = AFSUI;
6568
6599
  exports.AFTERMATH = AFTERMATH;
6569
- exports.AggregatorClient = AggregatorClient6;
6600
+ exports.AggregatorClient = AggregatorClient7;
6570
6601
  exports.BLUEMOVE = BLUEMOVE;
6571
6602
  exports.CETUS = CETUS;
6572
6603
  exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
6573
6604
  exports.DEEPBOOKV2 = DEEPBOOKV2;
6605
+ exports.DEEPBOOKV3 = DEEPBOOKV3;
6574
6606
  exports.Env = Env;
6575
6607
  exports.FLOWXV2 = FLOWXV2;
6576
6608
  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 "0x57cb657a4f6401b07e975a4e4326206e8ba9c585d76e639793d9132e56e26c8b";
6272
+ return "0x764b8132a94d35abc9dfd91b23a0757b2a717d5ecb04c03098794aa2a508db91";
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:
@@ -6562,4 +6593,4 @@ decimal.js/decimal.mjs:
6562
6593
  *)
6563
6594
  */
6564
6595
 
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 };
6596
+ 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.0.0-experimental-20240929131950",
3
+ "version": "0.0.0-experimental-20241009201249",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
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,10 +338,9 @@ export class AggregatorClient {
337
338
 
338
339
  publishedAt(): string {
339
340
  if (this.env === Env.Mainnet) {
340
- // return "0xeffc8ae61f439bb34c9b905ff8f29ec56873dcedf81c7123ff2f1f67c45ec302"
341
- return "0x57cb657a4f6401b07e975a4e4326206e8ba9c585d76e639793d9132e56e26c8b"
341
+ return "0x764b8132a94d35abc9dfd91b23a0757b2a717d5ecb04c03098794aa2a508db91"
342
342
  } else {
343
- return "0x6cbaa3e9fbe902d90191b12f315932bc58079cba422bafbd4b4369f80e61f595"
343
+ return "0xb2db335c85473e7ed952351bb594100eb8f61122703219c6b8dbcdcade2795b3"
344
344
  }
345
345
  }
346
346
 
@@ -373,7 +373,7 @@ export class AggregatorClient {
373
373
  targetCoin = coins[0]
374
374
  }
375
375
 
376
- const res = txb.moveCall({
376
+ txb.moveCall({
377
377
  target: `${this.publishedAt()}::utils::check_coin_threshold`,
378
378
  typeArguments: [coinType],
379
379
  arguments: [targetCoin, txb.pure.u64(amountLimit.toString())],
@@ -387,6 +387,8 @@ export class AggregatorClient {
387
387
  return new Cetus(this.env, partner)
388
388
  case DEEPBOOKV2:
389
389
  return new DeepbookV2(this.env)
390
+ case DEEPBOOKV3:
391
+ return new DeepbookV3(this.env)
390
392
  case KRIYA:
391
393
  return new KriyaV2(this.env)
392
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
+ ]
@@ -137,9 +137,6 @@ describe("router module", () => {
137
137
  const byAmountIn = true
138
138
  const amount = "1000000000"
139
139
 
140
- // const from = M_USDC
141
- // const target = M_SUI
142
-
143
140
  const from = M_SUI
144
141
  // const target =
145
142
  // "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"