@cetusprotocol/aggregator-sdk 0.0.0-experimental-20241010160019 → 0.0.0-experimental-20241011180351

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
@@ -90,7 +90,7 @@ type BuildFastRouterSwapParams = {
90
90
  partner?: string;
91
91
  isMergeTragetCoin?: boolean;
92
92
  refreshAllCoins?: boolean;
93
- deepbookv3DeepFee?: TransactionObjectArgument;
93
+ payDeepFeeAmount?: number;
94
94
  };
95
95
  interface SwapInPoolsParams {
96
96
  from: string;
@@ -155,6 +155,19 @@ declare const restituteMsafeFastRouterSwapParams: (data: any) => any;
155
155
 
156
156
  declare function processEndpoint(endpoint: string): string;
157
157
 
158
+ declare function completionCoin(s: string): string;
159
+ declare function compareCoins(coinA: string, coinB: string): boolean;
160
+ declare function mintZeroCoin(txb: Transaction, coinType: string): TransactionObjectArgument;
161
+ type BuildCoinResult = {
162
+ targetCoin: TransactionObjectArgument;
163
+ isMintZeroCoin: boolean;
164
+ targetCoinAmount: number;
165
+ };
166
+ declare function buildInputCoin(txb: Transaction, allCoins: CoinAsset[], amount: bigint, coinType: string): BuildCoinResult;
167
+
168
+ declare function printTransaction(tx: Transaction, isPrint?: boolean): Promise<void>;
169
+ declare function checkInvalidSuiAddress(address: string): boolean;
170
+
158
171
  declare const ZERO: BN;
159
172
  declare const ONE: BN;
160
173
  declare const TWO: BN;
@@ -215,6 +228,7 @@ type RouterData = {
215
228
  amountOut: BN;
216
229
  routes: Router[];
217
230
  insufficientLiquidity: boolean;
231
+ totalDeepFee?: number;
218
232
  error?: RouterError;
219
233
  };
220
234
  type AggregatorResponse = {
@@ -243,4 +257,4 @@ declare enum Env {
243
257
  Testnet = 1
244
258
  }
245
259
 
246
- export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, type DeepbookV3Config, type DeepbookV3ConfigResponse, 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, getDeepbookV3Config, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, processEndpoint, restituteMsafeFastRouterSwapParams };
260
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, type DeepbookV3Config, type DeepbookV3ConfigResponse, 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, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
package/dist/index.d.ts CHANGED
@@ -90,7 +90,7 @@ type BuildFastRouterSwapParams = {
90
90
  partner?: string;
91
91
  isMergeTragetCoin?: boolean;
92
92
  refreshAllCoins?: boolean;
93
- deepbookv3DeepFee?: TransactionObjectArgument;
93
+ payDeepFeeAmount?: number;
94
94
  };
95
95
  interface SwapInPoolsParams {
96
96
  from: string;
@@ -155,6 +155,19 @@ declare const restituteMsafeFastRouterSwapParams: (data: any) => any;
155
155
 
156
156
  declare function processEndpoint(endpoint: string): string;
157
157
 
158
+ declare function completionCoin(s: string): string;
159
+ declare function compareCoins(coinA: string, coinB: string): boolean;
160
+ declare function mintZeroCoin(txb: Transaction, coinType: string): TransactionObjectArgument;
161
+ type BuildCoinResult = {
162
+ targetCoin: TransactionObjectArgument;
163
+ isMintZeroCoin: boolean;
164
+ targetCoinAmount: number;
165
+ };
166
+ declare function buildInputCoin(txb: Transaction, allCoins: CoinAsset[], amount: bigint, coinType: string): BuildCoinResult;
167
+
168
+ declare function printTransaction(tx: Transaction, isPrint?: boolean): Promise<void>;
169
+ declare function checkInvalidSuiAddress(address: string): boolean;
170
+
158
171
  declare const ZERO: BN;
159
172
  declare const ONE: BN;
160
173
  declare const TWO: BN;
@@ -215,6 +228,7 @@ type RouterData = {
215
228
  amountOut: BN;
216
229
  routes: Router[];
217
230
  insufficientLiquidity: boolean;
231
+ totalDeepFee?: number;
218
232
  error?: RouterError;
219
233
  };
220
234
  type AggregatorResponse = {
@@ -243,4 +257,4 @@ declare enum Env {
243
257
  Testnet = 1
244
258
  }
245
259
 
246
- export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, type DeepbookV3Config, type DeepbookV3ConfigResponse, 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, getDeepbookV3Config, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, processEndpoint, restituteMsafeFastRouterSwapParams };
260
+ export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, type DeepbookV3Config, type DeepbookV3ConfigResponse, 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, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
package/dist/index.js CHANGED
@@ -5714,6 +5714,16 @@ function buildInputCoin(txb, allCoins, amount, coinType) {
5714
5714
  }
5715
5715
 
5716
5716
  // src/utils/transaction.ts
5717
+ function printTransaction(tx, isPrint = true) {
5718
+ return __async(this, null, function* () {
5719
+ console.log(`inputs`, tx.getData().inputs);
5720
+ tx.getData().commands.forEach((item, index) => {
5721
+ if (isPrint) {
5722
+ console.log(`transaction ${index}: `, JSON.stringify(item, null, 2));
5723
+ }
5724
+ });
5725
+ });
5726
+ }
5717
5727
  function checkInvalidSuiAddress(address) {
5718
5728
  if (!address.startsWith("0x") || address.length !== 66) {
5719
5729
  return false;
@@ -6230,7 +6240,7 @@ var AggregatorClient7 = class {
6230
6240
  partner,
6231
6241
  isMergeTragetCoin,
6232
6242
  refreshAllCoins,
6233
- deepbookv3DeepFee
6243
+ payDeepFeeAmount
6234
6244
  } = params;
6235
6245
  if (refreshAllCoins || this.allCoins.length === 0) {
6236
6246
  this.allCoins = yield this.getAllCoins();
@@ -6257,6 +6267,22 @@ var AggregatorClient7 = class {
6257
6267
  BigInt(amount.toString()),
6258
6268
  fromCoinType
6259
6269
  );
6270
+ let buildDeepFeeCoinRes;
6271
+ if (payDeepFeeAmount && payDeepFeeAmount > 0) {
6272
+ buildDeepFeeCoinRes = buildInputCoin(
6273
+ txb,
6274
+ this.allCoins,
6275
+ BigInt(payDeepFeeAmount),
6276
+ this.deepbookv3DeepFeeType()
6277
+ );
6278
+ } else {
6279
+ buildDeepFeeCoinRes = buildInputCoin(
6280
+ txb,
6281
+ this.allCoins,
6282
+ BigInt(0),
6283
+ this.deepbookv3DeepFeeType()
6284
+ );
6285
+ }
6260
6286
  const targetCoin = yield this.routerSwap({
6261
6287
  routers,
6262
6288
  inputCoin: buildFromCoinRes.targetCoin,
@@ -6264,7 +6290,7 @@ var AggregatorClient7 = class {
6264
6290
  byAmountIn,
6265
6291
  txb,
6266
6292
  partner,
6267
- deepbookv3DeepFee
6293
+ deepbookv3DeepFee: buildDeepFeeCoinRes.targetCoin
6268
6294
  });
6269
6295
  if (isMergeTragetCoin) {
6270
6296
  const targetCoinRes = buildInputCoin(
@@ -6401,7 +6427,15 @@ var AggregatorClient7 = class {
6401
6427
  }
6402
6428
  };
6403
6429
  function parseRouterResponse(data) {
6404
- return {
6430
+ let totalDeepFee = 0;
6431
+ for (const route of data.routes) {
6432
+ for (const path of route.path) {
6433
+ if (path.extended_details && path.extended_details.deepbookv3_deep_fee) {
6434
+ totalDeepFee += Number(path.extended_details.deepbookv3_deep_fee);
6435
+ }
6436
+ }
6437
+ }
6438
+ let routerData = {
6405
6439
  amountIn: new import_bn5.default(data.amount_in.toString()),
6406
6440
  amountOut: new import_bn5.default(data.amount_out.toString()),
6407
6441
  insufficientLiquidity: false,
@@ -6439,8 +6473,10 @@ function parseRouterResponse(data) {
6439
6473
  amountOut: new import_bn5.default(route.amount_out.toString()),
6440
6474
  initialPrice: new decimal_default(route.initial_price.toString())
6441
6475
  };
6442
- })
6476
+ }),
6477
+ totalDeepFee
6443
6478
  };
6479
+ return routerData;
6444
6480
  }
6445
6481
 
6446
6482
  // src/transaction/index.ts
@@ -6671,6 +6707,10 @@ exports.U64_MAX = U64_MAX;
6671
6707
  exports.U64_MAX_BN = U64_MAX_BN;
6672
6708
  exports.VOLO = VOLO;
6673
6709
  exports.ZERO = ZERO;
6710
+ exports.buildInputCoin = buildInputCoin;
6711
+ exports.checkInvalidSuiAddress = checkInvalidSuiAddress;
6712
+ exports.compareCoins = compareCoins;
6713
+ exports.completionCoin = completionCoin;
6674
6714
  exports.composeType = composeType;
6675
6715
  exports.createTarget = createTarget;
6676
6716
  exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMsafe;
@@ -6680,8 +6720,10 @@ exports.fixSuiObjectId = fixSuiObjectId;
6680
6720
  exports.getDeepbookV3Config = getDeepbookV3Config;
6681
6721
  exports.getRouterResult = getRouterResult;
6682
6722
  exports.isSortedSymbols = isSortedSymbols;
6723
+ exports.mintZeroCoin = mintZeroCoin;
6683
6724
  exports.normalizeCoinType = normalizeCoinType;
6684
6725
  exports.parseRouterResponse = parseRouterResponse;
6685
6726
  exports.patchFixSuiObjectId = patchFixSuiObjectId;
6727
+ exports.printTransaction = printTransaction;
6686
6728
  exports.processEndpoint = processEndpoint;
6687
6729
  exports.restituteMsafeFastRouterSwapParams = restituteMsafeFastRouterSwapParams;
package/dist/index.mjs CHANGED
@@ -5712,6 +5712,16 @@ function buildInputCoin(txb, allCoins, amount, coinType) {
5712
5712
  }
5713
5713
 
5714
5714
  // src/utils/transaction.ts
5715
+ function printTransaction(tx, isPrint = true) {
5716
+ return __async(this, null, function* () {
5717
+ console.log(`inputs`, tx.getData().inputs);
5718
+ tx.getData().commands.forEach((item, index) => {
5719
+ if (isPrint) {
5720
+ console.log(`transaction ${index}: `, JSON.stringify(item, null, 2));
5721
+ }
5722
+ });
5723
+ });
5724
+ }
5715
5725
  function checkInvalidSuiAddress(address) {
5716
5726
  if (!address.startsWith("0x") || address.length !== 66) {
5717
5727
  return false;
@@ -6228,7 +6238,7 @@ var AggregatorClient7 = class {
6228
6238
  partner,
6229
6239
  isMergeTragetCoin,
6230
6240
  refreshAllCoins,
6231
- deepbookv3DeepFee
6241
+ payDeepFeeAmount
6232
6242
  } = params;
6233
6243
  if (refreshAllCoins || this.allCoins.length === 0) {
6234
6244
  this.allCoins = yield this.getAllCoins();
@@ -6255,6 +6265,22 @@ var AggregatorClient7 = class {
6255
6265
  BigInt(amount.toString()),
6256
6266
  fromCoinType
6257
6267
  );
6268
+ let buildDeepFeeCoinRes;
6269
+ if (payDeepFeeAmount && payDeepFeeAmount > 0) {
6270
+ buildDeepFeeCoinRes = buildInputCoin(
6271
+ txb,
6272
+ this.allCoins,
6273
+ BigInt(payDeepFeeAmount),
6274
+ this.deepbookv3DeepFeeType()
6275
+ );
6276
+ } else {
6277
+ buildDeepFeeCoinRes = buildInputCoin(
6278
+ txb,
6279
+ this.allCoins,
6280
+ BigInt(0),
6281
+ this.deepbookv3DeepFeeType()
6282
+ );
6283
+ }
6258
6284
  const targetCoin = yield this.routerSwap({
6259
6285
  routers,
6260
6286
  inputCoin: buildFromCoinRes.targetCoin,
@@ -6262,7 +6288,7 @@ var AggregatorClient7 = class {
6262
6288
  byAmountIn,
6263
6289
  txb,
6264
6290
  partner,
6265
- deepbookv3DeepFee
6291
+ deepbookv3DeepFee: buildDeepFeeCoinRes.targetCoin
6266
6292
  });
6267
6293
  if (isMergeTragetCoin) {
6268
6294
  const targetCoinRes = buildInputCoin(
@@ -6399,7 +6425,15 @@ var AggregatorClient7 = class {
6399
6425
  }
6400
6426
  };
6401
6427
  function parseRouterResponse(data) {
6402
- return {
6428
+ let totalDeepFee = 0;
6429
+ for (const route of data.routes) {
6430
+ for (const path of route.path) {
6431
+ if (path.extended_details && path.extended_details.deepbookv3_deep_fee) {
6432
+ totalDeepFee += Number(path.extended_details.deepbookv3_deep_fee);
6433
+ }
6434
+ }
6435
+ }
6436
+ let routerData = {
6403
6437
  amountIn: new import_bn5.default(data.amount_in.toString()),
6404
6438
  amountOut: new import_bn5.default(data.amount_out.toString()),
6405
6439
  insufficientLiquidity: false,
@@ -6437,8 +6471,10 @@ function parseRouterResponse(data) {
6437
6471
  amountOut: new import_bn5.default(route.amount_out.toString()),
6438
6472
  initialPrice: new decimal_default(route.initial_price.toString())
6439
6473
  };
6440
- })
6474
+ }),
6475
+ totalDeepFee
6441
6476
  };
6477
+ return routerData;
6442
6478
  }
6443
6479
 
6444
6480
  // src/transaction/index.ts
@@ -6646,4 +6682,4 @@ decimal.js/decimal.mjs:
6646
6682
  *)
6647
6683
  */
6648
6684
 
6649
- 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, getDeepbookV3Config, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, processEndpoint, restituteMsafeFastRouterSwapParams };
6685
+ 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, buildInputCoin, checkInvalidSuiAddress, compareCoins, completionCoin, composeType, createTarget, dealWithFastRouterSwapParamsForMsafe, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
package/dist/src/api.d.ts CHANGED
@@ -52,6 +52,7 @@ export type RouterData = {
52
52
  amountOut: BN;
53
53
  routes: Router[];
54
54
  insufficientLiquidity: boolean;
55
+ totalDeepFee?: number;
55
56
  error?: RouterError;
56
57
  };
57
58
  export type AggregatorResponse = {
@@ -34,7 +34,7 @@ export type BuildFastRouterSwapParams = {
34
34
  partner?: string;
35
35
  isMergeTragetCoin?: boolean;
36
36
  refreshAllCoins?: boolean;
37
- deepbookv3DeepFee?: TransactionObjectArgument;
37
+ payDeepFeeAmount?: number;
38
38
  };
39
39
  export interface SwapInPoolsParams {
40
40
  from: string;
@@ -1,3 +1,5 @@
1
1
  export * from './contracts';
2
2
  export * from './msafe';
3
3
  export * from './api';
4
+ export * from './coin';
5
+ export * from './transaction';
@@ -1,5 +1,7 @@
1
1
  export declare const T_USDC = "";
2
2
  export declare const T_DEEP = "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
3
+ export declare const T_DBUSDC = "0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7::DBUSDC::DBUSDC";
4
+ export declare const T_DBUSDT = "0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7::DBUSDT::DBUSDT";
3
5
  export declare const M_USDC = "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN";
4
6
  export declare const M_CETUS = "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS";
5
7
  export declare const M_NAVI = "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cetusprotocol/aggregator-sdk",
3
- "version": "0.0.0-experimental-20241010160019",
3
+ "version": "0.0.0-experimental-20241011180351",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/api.ts CHANGED
@@ -66,6 +66,7 @@ export type RouterData = {
66
66
  amountOut: BN
67
67
  routes: Router[]
68
68
  insufficientLiquidity: boolean
69
+ totalDeepFee?: number
69
70
  error?: RouterError
70
71
  }
71
72
 
package/src/client.ts CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  DeepbookV3ConfigResponse,
20
20
  processEndpoint,
21
21
  DeepbookV3Config,
22
+ ZERO,
22
23
  } from "."
23
24
  import { Aftermath } from "./transaction/aftermath"
24
25
  import { DeepbookV2 } from "./transaction/deepbook_v2"
@@ -59,7 +60,9 @@ export type BuildRouterSwapParams = {
59
60
  slippage: number
60
61
  txb: Transaction
61
62
  partner?: string
62
- deepbookv3DeepFee?: TransactionObjectArgument
63
+ // This parameter is used to pass the Deep token object. When using the DeepBook V3 provider,
64
+ // users must pay fees with Deep tokens in non-whitelisted pools.
65
+ deepbookv3DeepFee?: TransactionObjectArgument
63
66
  }
64
67
 
65
68
  export type BuildFastRouterSwapParams = {
@@ -70,7 +73,7 @@ export type BuildFastRouterSwapParams = {
70
73
  partner?: string
71
74
  isMergeTragetCoin?: boolean
72
75
  refreshAllCoins?: boolean
73
- deepbookv3DeepFee?: TransactionObjectArgument
76
+ payDeepFeeAmount?: number
74
77
  }
75
78
 
76
79
  export interface SwapInPoolsParams {
@@ -293,7 +296,7 @@ export class AggregatorClient {
293
296
  partner,
294
297
  isMergeTragetCoin,
295
298
  refreshAllCoins,
296
- deepbookv3DeepFee,
299
+ payDeepFeeAmount,
297
300
  } = params
298
301
  if (refreshAllCoins || this.allCoins.length === 0) {
299
302
  this.allCoins = await this.getAllCoins()
@@ -320,6 +323,24 @@ export class AggregatorClient {
320
323
  BigInt(amount.toString()),
321
324
  fromCoinType
322
325
  )
326
+
327
+ let buildDeepFeeCoinRes
328
+ if (payDeepFeeAmount && payDeepFeeAmount > 0) {
329
+ buildDeepFeeCoinRes = buildInputCoin(
330
+ txb,
331
+ this.allCoins,
332
+ BigInt(payDeepFeeAmount),
333
+ this.deepbookv3DeepFeeType()
334
+ )
335
+ } else {
336
+ buildDeepFeeCoinRes = buildInputCoin(
337
+ txb,
338
+ this.allCoins,
339
+ BigInt(0),
340
+ this.deepbookv3DeepFeeType()
341
+ )
342
+ }
343
+
323
344
  const targetCoin = await this.routerSwap({
324
345
  routers,
325
346
  inputCoin: buildFromCoinRes.targetCoin,
@@ -327,7 +348,7 @@ export class AggregatorClient {
327
348
  byAmountIn,
328
349
  txb,
329
350
  partner,
330
- deepbookv3DeepFee,
351
+ deepbookv3DeepFee: buildDeepFeeCoinRes.targetCoin,
331
352
  })
332
353
 
333
354
  if (isMergeTragetCoin) {
@@ -477,7 +498,16 @@ export class AggregatorClient {
477
498
  }
478
499
 
479
500
  export function parseRouterResponse(data: any): RouterData {
480
- return {
501
+ let totalDeepFee = 0
502
+ for (const route of data.routes) {
503
+ for (const path of route.path) {
504
+ if (path.extended_details && path.extended_details.deepbookv3_deep_fee) {
505
+ totalDeepFee += Number(path.extended_details.deepbookv3_deep_fee)
506
+ }
507
+ }
508
+ }
509
+
510
+ let routerData: RouterData = {
481
511
  amountIn: new BN(data.amount_in.toString()),
482
512
  amountOut: new BN(data.amount_out.toString()),
483
513
  insufficientLiquidity: false,
@@ -524,5 +554,8 @@ export function parseRouterResponse(data: any): RouterData {
524
554
  initialPrice: new Decimal(route.initial_price.toString()),
525
555
  }
526
556
  }),
557
+ totalDeepFee: totalDeepFee,
527
558
  }
559
+
560
+ return routerData
528
561
  }
@@ -1,3 +1,5 @@
1
1
  export * from './contracts'
2
2
  export * from './msafe'
3
3
  export * from './api'
4
+ export * from './coin'
5
+ export * from './transaction'
@@ -8,6 +8,8 @@ import {
8
8
  M_SSWP,
9
9
  M_SUI,
10
10
  M_USDC,
11
+ T_DBUSDC,
12
+ T_DBUSDT,
11
13
  T_DEEP,
12
14
  } from "./test_data.test"
13
15
  import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"
@@ -73,7 +75,7 @@ describe("router module", () => {
73
75
  // const endpoint =
74
76
  // "https://api-sui-cloudfront.cetus.zone/router_v2/find_routes"
75
77
  const endpoint =
76
- "http://localhost:8080/router_v2/find_routes"
78
+ "https://api-sui.devcetus.com/router_v2/find_routes"
77
79
 
78
80
  const suiClient = new SuiClient({
79
81
  url: "https://fullnode.testnet.sui.io:443",
@@ -140,8 +142,8 @@ describe("router module", () => {
140
142
  test("Build router tx", async () => {
141
143
  const byAmountIn = true
142
144
  const amount = "20000000000"
143
- const from = M_SUI
144
- const target = T_DEEP
145
+ const from = T_DBUSDC
146
+ const target = T_DBUSDT
145
147
 
146
148
  const res = await client.findRouters({
147
149
  from,
@@ -151,13 +153,13 @@ describe("router module", () => {
151
153
  depth: 3,
152
154
  providers: [
153
155
  "CETUS",
156
+ "DEEPBOOKV3",
154
157
  // "DEEPBOOK",
155
158
  // "AFTERMATH",
156
159
  // "FLOWX",
157
160
  // "KRIYA",
158
161
  // "KRIYAV3",
159
162
  // "TURBOS",
160
- "DEEPBOOKV3",
161
163
  ],
162
164
  })
163
165
 
@@ -1,6 +1,8 @@
1
1
  // Testnet
2
2
  export const T_USDC = ""
3
3
  export const T_DEEP = "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP"
4
+ export const T_DBUSDC = "0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7::DBUSDC::DBUSDC"
5
+ export const T_DBUSDT = "0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7::DBUSDT::DBUSDT"
4
6
 
5
7
  // Mainnet
6
8
  export const M_USDC =