@cetusprotocol/aggregator-sdk 0.0.0-experimental-20241009201249 → 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
@@ -80,6 +80,7 @@ type BuildRouterSwapParams = {
80
80
  slippage: number;
81
81
  txb: Transaction;
82
82
  partner?: string;
83
+ deepbookv3DeepFee?: TransactionObjectArgument;
83
84
  };
84
85
  type BuildFastRouterSwapParams = {
85
86
  routers: Router[];
@@ -89,6 +90,7 @@ type BuildFastRouterSwapParams = {
89
90
  partner?: string;
90
91
  isMergeTragetCoin?: boolean;
91
92
  refreshAllCoins?: boolean;
93
+ payDeepFeeAmount?: number;
92
94
  };
93
95
  interface SwapInPoolsParams {
94
96
  from: string;
@@ -110,24 +112,26 @@ declare class AggregatorClient {
110
112
  constructor(endpoint: string, signer: string, client: SuiClient, env: Env);
111
113
  getAllCoins(): Promise<CoinAsset[]>;
112
114
  findRouters(params: FindRouterParams): Promise<RouterData | null>;
113
- expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string): Promise<TransactionObjectArgument>;
115
+ expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
114
116
  expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
115
117
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
116
118
  routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
117
119
  fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
118
120
  publishedAt(): string;
121
+ deepbookv3DeepFeeType(): string;
119
122
  transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
120
123
  checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
121
124
  newDex(provider: string, partner?: string): Dex;
122
125
  signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
123
126
  devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
124
127
  sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
128
+ getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
125
129
  }
126
130
  declare function parseRouterResponse(data: any): RouterData;
127
131
 
128
132
  declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
129
133
  interface Dex {
130
- swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
134
+ swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
131
135
  }
132
136
 
133
137
  declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
@@ -149,6 +153,21 @@ declare function createTarget(packageName: string, moduleName: string, functionN
149
153
  declare const dealWithFastRouterSwapParamsForMsafe: (data: any) => any;
150
154
  declare const restituteMsafeFastRouterSwapParams: (data: any) => any;
151
155
 
156
+ declare function processEndpoint(endpoint: string): string;
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
+
152
171
  declare const ZERO: BN;
153
172
  declare const ONE: BN;
154
173
  declare const TWO: BN;
@@ -180,6 +199,7 @@ type ExtendedDetails = {
180
199
  aftermathLpSupplyType?: string;
181
200
  turbosFeeType?: string;
182
201
  afterSqrtPrice?: string;
202
+ deepbookv3DeepFee?: number;
183
203
  };
184
204
  type Path = {
185
205
  id: string;
@@ -208,6 +228,7 @@ type RouterData = {
208
228
  amountOut: BN;
209
229
  routes: Router[];
210
230
  insufficientLiquidity: boolean;
231
+ totalDeepFee?: number;
211
232
  error?: RouterError;
212
233
  };
213
234
  type AggregatorResponse = {
@@ -216,10 +237,24 @@ type AggregatorResponse = {
216
237
  data: RouterData;
217
238
  };
218
239
  declare function getRouterResult(endpoint: string, params: FindRouterParams): Promise<RouterData | null>;
240
+ type DeepbookV3Config = {
241
+ id: string;
242
+ is_alternative_payment: boolean;
243
+ deep_fee_vault: number;
244
+ whitelist: number;
245
+ whitelist_pools: string[];
246
+ last_updated_time: number;
247
+ };
248
+ type DeepbookV3ConfigResponse = {
249
+ code: number;
250
+ msg: string;
251
+ data: DeepbookV3Config;
252
+ };
253
+ declare function getDeepbookV3Config(endpoint: string): Promise<DeepbookV3ConfigResponse | null>;
219
254
 
220
255
  declare enum Env {
221
256
  Mainnet = 0,
222
257
  Testnet = 1
223
258
  }
224
259
 
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 };
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
@@ -80,6 +80,7 @@ type BuildRouterSwapParams = {
80
80
  slippage: number;
81
81
  txb: Transaction;
82
82
  partner?: string;
83
+ deepbookv3DeepFee?: TransactionObjectArgument;
83
84
  };
84
85
  type BuildFastRouterSwapParams = {
85
86
  routers: Router[];
@@ -89,6 +90,7 @@ type BuildFastRouterSwapParams = {
89
90
  partner?: string;
90
91
  isMergeTragetCoin?: boolean;
91
92
  refreshAllCoins?: boolean;
93
+ payDeepFeeAmount?: number;
92
94
  };
93
95
  interface SwapInPoolsParams {
94
96
  from: string;
@@ -110,24 +112,26 @@ declare class AggregatorClient {
110
112
  constructor(endpoint: string, signer: string, client: SuiClient, env: Env);
111
113
  getAllCoins(): Promise<CoinAsset[]>;
112
114
  findRouters(params: FindRouterParams): Promise<RouterData | null>;
113
- expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string): Promise<TransactionObjectArgument>;
115
+ expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
114
116
  expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
115
117
  swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
116
118
  routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
117
119
  fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
118
120
  publishedAt(): string;
121
+ deepbookv3DeepFeeType(): string;
119
122
  transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
120
123
  checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
121
124
  newDex(provider: string, partner?: string): Dex;
122
125
  signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
123
126
  devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
124
127
  sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
128
+ getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
125
129
  }
126
130
  declare function parseRouterResponse(data: any): RouterData;
127
131
 
128
132
  declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
129
133
  interface Dex {
130
- swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
134
+ swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
131
135
  }
132
136
 
133
137
  declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
@@ -149,6 +153,21 @@ declare function createTarget(packageName: string, moduleName: string, functionN
149
153
  declare const dealWithFastRouterSwapParamsForMsafe: (data: any) => any;
150
154
  declare const restituteMsafeFastRouterSwapParams: (data: any) => any;
151
155
 
156
+ declare function processEndpoint(endpoint: string): string;
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
+
152
171
  declare const ZERO: BN;
153
172
  declare const ONE: BN;
154
173
  declare const TWO: BN;
@@ -180,6 +199,7 @@ type ExtendedDetails = {
180
199
  aftermathLpSupplyType?: string;
181
200
  turbosFeeType?: string;
182
201
  afterSqrtPrice?: string;
202
+ deepbookv3DeepFee?: number;
183
203
  };
184
204
  type Path = {
185
205
  id: string;
@@ -208,6 +228,7 @@ type RouterData = {
208
228
  amountOut: BN;
209
229
  routes: Router[];
210
230
  insufficientLiquidity: boolean;
231
+ totalDeepFee?: number;
211
232
  error?: RouterError;
212
233
  };
213
234
  type AggregatorResponse = {
@@ -216,10 +237,24 @@ type AggregatorResponse = {
216
237
  data: RouterData;
217
238
  };
218
239
  declare function getRouterResult(endpoint: string, params: FindRouterParams): Promise<RouterData | null>;
240
+ type DeepbookV3Config = {
241
+ id: string;
242
+ is_alternative_payment: boolean;
243
+ deep_fee_vault: number;
244
+ whitelist: number;
245
+ whitelist_pools: string[];
246
+ last_updated_time: number;
247
+ };
248
+ type DeepbookV3ConfigResponse = {
249
+ code: number;
250
+ msg: string;
251
+ data: DeepbookV3Config;
252
+ };
253
+ declare function getDeepbookV3Config(endpoint: string): Promise<DeepbookV3ConfigResponse | null>;
219
254
 
220
255
  declare enum Env {
221
256
  Mainnet = 0,
222
257
  Testnet = 1
223
258
  }
224
259
 
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 };
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;
@@ -5995,19 +6005,30 @@ var Bluemove = class {
5995
6005
  // src/transaction/deepbook_v3.ts
5996
6006
  var DeepbookV3 = class {
5997
6007
  constructor(env) {
5998
- this.deepbookV3Config = env === 0 /* Mainnet */ ? "0x0" : "0x77018927a5d7ed7b4c49312b71581f5f12ba52ba7e1219a15181ffc3d459f527";
6008
+ this.deepbookV3Config = env === 0 /* Mainnet */ ? "0x0" : "0xe19b5d072346cae83a037d4e3c8492068a74410a74e5830b3a68012db38296aa";
5999
6009
  this.deepCoinType = env === 0 /* Mainnet */ ? "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP" : "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
6000
6010
  }
6001
- swap(client, txb, path, inputCoin) {
6011
+ swap(client, txb, path, inputCoin, deepbookv3DeepFee) {
6002
6012
  return __async(this, null, function* () {
6013
+ var _a, _b, _c;
6003
6014
  const { direction, from, target } = path;
6004
6015
  const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
6005
- const zeroDeep = mintZeroCoin(txb, this.deepCoinType);
6016
+ let deepFee;
6017
+ if (deepbookv3DeepFee) {
6018
+ if (((_a = path.extendedDetails) == null ? void 0 : _a.deepbookv3DeepFee) && ((_b = path.extendedDetails) == null ? void 0 : _b.deepbookv3DeepFee) > 0) {
6019
+ const splitAmounts = [(_c = path.extendedDetails) == null ? void 0 : _c.deepbookv3DeepFee];
6020
+ deepFee = txb.splitCoins(deepbookv3DeepFee, splitAmounts)[0];
6021
+ } else {
6022
+ deepFee = mintZeroCoin(txb, this.deepCoinType);
6023
+ }
6024
+ } else {
6025
+ deepFee = mintZeroCoin(txb, this.deepCoinType);
6026
+ }
6006
6027
  const args = [
6007
6028
  txb.object(this.deepbookV3Config),
6008
6029
  txb.object(path.id),
6009
6030
  inputCoin,
6010
- zeroDeep,
6031
+ deepFee,
6011
6032
  txb.object(CLOCK_ADDRESS)
6012
6033
  ];
6013
6034
  const res = txb.moveCall({
@@ -6036,7 +6057,7 @@ var BLUEMOVE = "BLUEMOVE";
6036
6057
  var DEEPBOOKV3 = "DEEPBOOKV3";
6037
6058
  var AggregatorClient7 = class {
6038
6059
  constructor(endpoint, signer, client, env) {
6039
- this.endpoint = endpoint;
6060
+ this.endpoint = processEndpoint(endpoint);
6040
6061
  this.client = client;
6041
6062
  this.signer = signer;
6042
6063
  this.env = env;
@@ -6073,7 +6094,7 @@ var AggregatorClient7 = class {
6073
6094
  return getRouterResult(this.endpoint, params);
6074
6095
  });
6075
6096
  }
6076
- expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner) {
6097
+ expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee) {
6077
6098
  return __async(this, null, function* () {
6078
6099
  if (routers.length === 0) {
6079
6100
  throw new Error("No router found");
@@ -6090,11 +6111,14 @@ var AggregatorClient7 = class {
6090
6111
  let nextCoin = inputCoins[i];
6091
6112
  for (const path of routers[i].path) {
6092
6113
  const dex = this.newDex(path.provider, partner);
6093
- nextCoin = yield dex.swap(this, txb, path, nextCoin);
6114
+ nextCoin = yield dex.swap(this, txb, path, nextCoin, deepbookv3DeepFee);
6094
6115
  }
6095
6116
  outputCoins.push(nextCoin);
6096
6117
  }
6097
6118
  this.transferOrDestoryCoin(txb, inputCoin, inputCoinType);
6119
+ if (deepbookv3DeepFee) {
6120
+ this.transferOrDestoryCoin(txb, deepbookv3DeepFee, this.deepbookv3DeepFeeType());
6121
+ }
6098
6122
  const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
6099
6123
  txb,
6100
6124
  outputCoins,
@@ -6166,7 +6190,7 @@ var AggregatorClient7 = class {
6166
6190
  }
6167
6191
  routerSwap(params) {
6168
6192
  return __async(this, null, function* () {
6169
- const { routers, inputCoin, slippage, byAmountIn, txb, partner } = params;
6193
+ const { routers, inputCoin, slippage, byAmountIn, txb, partner, deepbookv3DeepFee } = params;
6170
6194
  const amountIn = routers.reduce(
6171
6195
  (acc, router) => acc.add(router.amountIn),
6172
6196
  new import_bn5.default(0)
@@ -6186,7 +6210,8 @@ var AggregatorClient7 = class {
6186
6210
  inputCoin,
6187
6211
  routers,
6188
6212
  new import_bn5.default(amountLimit),
6189
- partner
6213
+ partner,
6214
+ deepbookv3DeepFee
6190
6215
  );
6191
6216
  return targetCoin2;
6192
6217
  }
@@ -6214,7 +6239,8 @@ var AggregatorClient7 = class {
6214
6239
  txb,
6215
6240
  partner,
6216
6241
  isMergeTragetCoin,
6217
- refreshAllCoins
6242
+ refreshAllCoins,
6243
+ payDeepFeeAmount
6218
6244
  } = params;
6219
6245
  if (refreshAllCoins || this.allCoins.length === 0) {
6220
6246
  this.allCoins = yield this.getAllCoins();
@@ -6241,13 +6267,30 @@ var AggregatorClient7 = class {
6241
6267
  BigInt(amount.toString()),
6242
6268
  fromCoinType
6243
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
+ }
6244
6286
  const targetCoin = yield this.routerSwap({
6245
6287
  routers,
6246
6288
  inputCoin: buildFromCoinRes.targetCoin,
6247
6289
  slippage,
6248
6290
  byAmountIn,
6249
6291
  txb,
6250
- partner
6292
+ partner,
6293
+ deepbookv3DeepFee: buildDeepFeeCoinRes.targetCoin
6251
6294
  });
6252
6295
  if (isMergeTragetCoin) {
6253
6296
  const targetCoinRes = buildInputCoin(
@@ -6273,7 +6316,14 @@ var AggregatorClient7 = class {
6273
6316
  if (this.env === 0 /* Mainnet */) {
6274
6317
  return "0x764b8132a94d35abc9dfd91b23a0757b2a717d5ecb04c03098794aa2a508db91";
6275
6318
  } else {
6276
- return "0xb2db335c85473e7ed952351bb594100eb8f61122703219c6b8dbcdcade2795b3";
6319
+ return "0xf92cdec6c2d73a12d8afa8dd41199b3e95b621272bbc655996539cd30de6a462";
6320
+ }
6321
+ }
6322
+ deepbookv3DeepFeeType() {
6323
+ if (this.env === 0 /* Mainnet */) {
6324
+ return "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
6325
+ } else {
6326
+ return "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP";
6277
6327
  }
6278
6328
  }
6279
6329
  transferOrDestoryCoin(txb, coin, coinType) {
@@ -6366,26 +6416,44 @@ var AggregatorClient7 = class {
6366
6416
  return res;
6367
6417
  });
6368
6418
  }
6419
+ getDeepbookV3Config() {
6420
+ return __async(this, null, function* () {
6421
+ const res = yield getDeepbookV3Config(this.endpoint);
6422
+ if (res) {
6423
+ return res.data;
6424
+ }
6425
+ return null;
6426
+ });
6427
+ }
6369
6428
  };
6370
6429
  function parseRouterResponse(data) {
6371
- 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 = {
6372
6439
  amountIn: new import_bn5.default(data.amount_in.toString()),
6373
6440
  amountOut: new import_bn5.default(data.amount_out.toString()),
6374
6441
  insufficientLiquidity: false,
6375
6442
  routes: data.routes.map((route) => {
6376
6443
  return {
6377
6444
  path: route.path.map((path) => {
6378
- var _a, _b, _c;
6445
+ var _a, _b, _c, _d;
6379
6446
  let version;
6380
6447
  if (path.provider === AFTERMATH) {
6381
6448
  version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
6382
6449
  }
6383
6450
  let extendedDetails;
6384
- if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS) {
6451
+ if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3) {
6385
6452
  extendedDetails = {
6386
6453
  aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
6387
6454
  turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
6388
- afterSqrtPrice: (_c = path.extended_details) == null ? void 0 : _c.after_sqrt_price
6455
+ afterSqrtPrice: (_c = path.extended_details) == null ? void 0 : _c.after_sqrt_price,
6456
+ deepbookv3DeepFee: (_d = path.extended_details) == null ? void 0 : _d.deepbookv3_deep_fee
6389
6457
  };
6390
6458
  }
6391
6459
  return {
@@ -6405,8 +6473,10 @@ function parseRouterResponse(data) {
6405
6473
  amountOut: new import_bn5.default(route.amount_out.toString()),
6406
6474
  initialPrice: new decimal_default(route.initial_price.toString())
6407
6475
  };
6408
- })
6476
+ }),
6477
+ totalDeepFee
6409
6478
  };
6479
+ return routerData;
6410
6480
  }
6411
6481
 
6412
6482
  // src/transaction/index.ts
@@ -6437,6 +6507,14 @@ var restituteMsafeFastRouterSwapParams = (data) => {
6437
6507
  return result;
6438
6508
  };
6439
6509
 
6510
+ // src/utils/api.ts
6511
+ function processEndpoint(endpoint) {
6512
+ if (endpoint.endsWith("/find_routes")) {
6513
+ return endpoint.replace("/find_routes", "");
6514
+ }
6515
+ return endpoint;
6516
+ }
6517
+
6440
6518
  // src/api.ts
6441
6519
  function getRouterResult(endpoint, params) {
6442
6520
  return __async(this, null, function* () {
@@ -6499,7 +6577,7 @@ function getRouter(endpoint, params) {
6499
6577
  } = params;
6500
6578
  const fromCoin = completionCoin(from);
6501
6579
  const targetCoin = completionCoin(target);
6502
- let url = `${endpoint}?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`;
6580
+ let url = `${endpoint}/find_routes?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`;
6503
6581
  if (depth) {
6504
6582
  url += `&depth=${depth}`;
6505
6583
  }
@@ -6541,7 +6619,7 @@ function postRouterWithLiquidityChanges(endpoint, params) {
6541
6619
  } = params;
6542
6620
  const fromCoin = completionCoin(from);
6543
6621
  const targetCoin = completionCoin(target);
6544
- const url = `${endpoint}`;
6622
+ const url = `${endpoint}/find_routes`;
6545
6623
  const providersStr = providers == null ? void 0 : providers.join(",");
6546
6624
  const requestData = {
6547
6625
  from: fromCoin,
@@ -6560,7 +6638,6 @@ function postRouterWithLiquidityChanges(endpoint, params) {
6560
6638
  delta_liquidity: change.deltaLiquidity
6561
6639
  }))
6562
6640
  };
6563
- console.log("requestData", JSON.stringify(requestData, null, 2));
6564
6641
  try {
6565
6642
  const response = yield fetch(url, {
6566
6643
  method: "POST",
@@ -6576,6 +6653,18 @@ function postRouterWithLiquidityChanges(endpoint, params) {
6576
6653
  }
6577
6654
  });
6578
6655
  }
6656
+ function getDeepbookV3Config(endpoint) {
6657
+ return __async(this, null, function* () {
6658
+ const url = `${endpoint}/deepbookv3_config`;
6659
+ try {
6660
+ const response = yield fetch(url);
6661
+ return response.json();
6662
+ } catch (error) {
6663
+ console.error("Error:", error);
6664
+ return null;
6665
+ }
6666
+ });
6667
+ }
6579
6668
 
6580
6669
  // src/index.ts
6581
6670
  var Env = /* @__PURE__ */ ((Env2) => {
@@ -6618,15 +6707,23 @@ exports.U64_MAX = U64_MAX;
6618
6707
  exports.U64_MAX_BN = U64_MAX_BN;
6619
6708
  exports.VOLO = VOLO;
6620
6709
  exports.ZERO = ZERO;
6710
+ exports.buildInputCoin = buildInputCoin;
6711
+ exports.checkInvalidSuiAddress = checkInvalidSuiAddress;
6712
+ exports.compareCoins = compareCoins;
6713
+ exports.completionCoin = completionCoin;
6621
6714
  exports.composeType = composeType;
6622
6715
  exports.createTarget = createTarget;
6623
6716
  exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMsafe;
6624
6717
  exports.extractAddressFromType = extractAddressFromType;
6625
6718
  exports.extractStructTagFromType = extractStructTagFromType;
6626
6719
  exports.fixSuiObjectId = fixSuiObjectId;
6720
+ exports.getDeepbookV3Config = getDeepbookV3Config;
6627
6721
  exports.getRouterResult = getRouterResult;
6628
6722
  exports.isSortedSymbols = isSortedSymbols;
6723
+ exports.mintZeroCoin = mintZeroCoin;
6629
6724
  exports.normalizeCoinType = normalizeCoinType;
6630
6725
  exports.parseRouterResponse = parseRouterResponse;
6631
6726
  exports.patchFixSuiObjectId = patchFixSuiObjectId;
6727
+ exports.printTransaction = printTransaction;
6728
+ exports.processEndpoint = processEndpoint;
6632
6729
  exports.restituteMsafeFastRouterSwapParams = restituteMsafeFastRouterSwapParams;