@cetusprotocol/aggregator-sdk 0.0.0-experimental-20240929164543 → 0.0.0-experimental-20241010160019
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 +25 -3
- package/dist/index.d.ts +25 -3
- package/dist/index.js +103 -16
- package/dist/index.mjs +100 -16
- package/dist/src/api.d.ts +15 -0
- package/dist/src/client.d.ts +7 -2
- package/dist/src/transaction/deepbook_v3.d.ts +13 -0
- package/dist/src/transaction/index.d.ts +1 -1
- package/dist/src/utils/api.d.ts +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/tests/test_data.test.d.ts +1 -0
- package/package.json +1 -1
- package/src/api.ts +32 -7
- package/src/client.ts +43 -8
- package/src/transaction/afsui.ts +0 -1
- package/src/transaction/aftermath.ts +0 -2
- package/src/transaction/deepbook_v2.ts +0 -1
- package/src/transaction/deepbook_v3.ts +68 -0
- package/src/transaction/index.ts +2 -1
- package/src/utils/api.ts +6 -0
- package/src/utils/index.ts +1 -0
- package/test.json +5 -0
- package/tests/router.test.ts +26 -26
- package/tests/test_data.test.ts +1 -0
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;
|
|
@@ -79,6 +80,7 @@ type BuildRouterSwapParams = {
|
|
|
79
80
|
slippage: number;
|
|
80
81
|
txb: Transaction;
|
|
81
82
|
partner?: string;
|
|
83
|
+
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
82
84
|
};
|
|
83
85
|
type BuildFastRouterSwapParams = {
|
|
84
86
|
routers: Router[];
|
|
@@ -88,6 +90,7 @@ type BuildFastRouterSwapParams = {
|
|
|
88
90
|
partner?: string;
|
|
89
91
|
isMergeTragetCoin?: boolean;
|
|
90
92
|
refreshAllCoins?: boolean;
|
|
93
|
+
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
91
94
|
};
|
|
92
95
|
interface SwapInPoolsParams {
|
|
93
96
|
from: string;
|
|
@@ -109,24 +112,26 @@ declare class AggregatorClient {
|
|
|
109
112
|
constructor(endpoint: string, signer: string, client: SuiClient, env: Env);
|
|
110
113
|
getAllCoins(): Promise<CoinAsset[]>;
|
|
111
114
|
findRouters(params: FindRouterParams): Promise<RouterData | null>;
|
|
112
|
-
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>;
|
|
113
116
|
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
|
|
114
117
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
115
118
|
routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
|
|
116
119
|
fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
|
|
117
120
|
publishedAt(): string;
|
|
121
|
+
deepbookv3DeepFeeType(): string;
|
|
118
122
|
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
119
123
|
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
|
|
120
124
|
newDex(provider: string, partner?: string): Dex;
|
|
121
125
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
122
126
|
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
123
127
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
128
|
+
getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
|
|
124
129
|
}
|
|
125
130
|
declare function parseRouterResponse(data: any): RouterData;
|
|
126
131
|
|
|
127
132
|
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
128
133
|
interface Dex {
|
|
129
|
-
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>;
|
|
130
135
|
}
|
|
131
136
|
|
|
132
137
|
declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
|
|
@@ -148,6 +153,8 @@ declare function createTarget(packageName: string, moduleName: string, functionN
|
|
|
148
153
|
declare const dealWithFastRouterSwapParamsForMsafe: (data: any) => any;
|
|
149
154
|
declare const restituteMsafeFastRouterSwapParams: (data: any) => any;
|
|
150
155
|
|
|
156
|
+
declare function processEndpoint(endpoint: string): string;
|
|
157
|
+
|
|
151
158
|
declare const ZERO: BN;
|
|
152
159
|
declare const ONE: BN;
|
|
153
160
|
declare const TWO: BN;
|
|
@@ -179,6 +186,7 @@ type ExtendedDetails = {
|
|
|
179
186
|
aftermathLpSupplyType?: string;
|
|
180
187
|
turbosFeeType?: string;
|
|
181
188
|
afterSqrtPrice?: string;
|
|
189
|
+
deepbookv3DeepFee?: number;
|
|
182
190
|
};
|
|
183
191
|
type Path = {
|
|
184
192
|
id: string;
|
|
@@ -215,10 +223,24 @@ type AggregatorResponse = {
|
|
|
215
223
|
data: RouterData;
|
|
216
224
|
};
|
|
217
225
|
declare function getRouterResult(endpoint: string, params: FindRouterParams): Promise<RouterData | null>;
|
|
226
|
+
type DeepbookV3Config = {
|
|
227
|
+
id: string;
|
|
228
|
+
is_alternative_payment: boolean;
|
|
229
|
+
deep_fee_vault: number;
|
|
230
|
+
whitelist: number;
|
|
231
|
+
whitelist_pools: string[];
|
|
232
|
+
last_updated_time: number;
|
|
233
|
+
};
|
|
234
|
+
type DeepbookV3ConfigResponse = {
|
|
235
|
+
code: number;
|
|
236
|
+
msg: string;
|
|
237
|
+
data: DeepbookV3Config;
|
|
238
|
+
};
|
|
239
|
+
declare function getDeepbookV3Config(endpoint: string): Promise<DeepbookV3ConfigResponse | null>;
|
|
218
240
|
|
|
219
241
|
declare enum Env {
|
|
220
242
|
Mainnet = 0,
|
|
221
243
|
Testnet = 1
|
|
222
244
|
}
|
|
223
245
|
|
|
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 };
|
|
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 };
|
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;
|
|
@@ -79,6 +80,7 @@ type BuildRouterSwapParams = {
|
|
|
79
80
|
slippage: number;
|
|
80
81
|
txb: Transaction;
|
|
81
82
|
partner?: string;
|
|
83
|
+
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
82
84
|
};
|
|
83
85
|
type BuildFastRouterSwapParams = {
|
|
84
86
|
routers: Router[];
|
|
@@ -88,6 +90,7 @@ type BuildFastRouterSwapParams = {
|
|
|
88
90
|
partner?: string;
|
|
89
91
|
isMergeTragetCoin?: boolean;
|
|
90
92
|
refreshAllCoins?: boolean;
|
|
93
|
+
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
91
94
|
};
|
|
92
95
|
interface SwapInPoolsParams {
|
|
93
96
|
from: string;
|
|
@@ -109,24 +112,26 @@ declare class AggregatorClient {
|
|
|
109
112
|
constructor(endpoint: string, signer: string, client: SuiClient, env: Env);
|
|
110
113
|
getAllCoins(): Promise<CoinAsset[]>;
|
|
111
114
|
findRouters(params: FindRouterParams): Promise<RouterData | null>;
|
|
112
|
-
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>;
|
|
113
116
|
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
|
|
114
117
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
115
118
|
routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
|
|
116
119
|
fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
|
|
117
120
|
publishedAt(): string;
|
|
121
|
+
deepbookv3DeepFeeType(): string;
|
|
118
122
|
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
119
123
|
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
|
|
120
124
|
newDex(provider: string, partner?: string): Dex;
|
|
121
125
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
122
126
|
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
123
127
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
128
|
+
getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
|
|
124
129
|
}
|
|
125
130
|
declare function parseRouterResponse(data: any): RouterData;
|
|
126
131
|
|
|
127
132
|
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
128
133
|
interface Dex {
|
|
129
|
-
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>;
|
|
130
135
|
}
|
|
131
136
|
|
|
132
137
|
declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
|
|
@@ -148,6 +153,8 @@ declare function createTarget(packageName: string, moduleName: string, functionN
|
|
|
148
153
|
declare const dealWithFastRouterSwapParamsForMsafe: (data: any) => any;
|
|
149
154
|
declare const restituteMsafeFastRouterSwapParams: (data: any) => any;
|
|
150
155
|
|
|
156
|
+
declare function processEndpoint(endpoint: string): string;
|
|
157
|
+
|
|
151
158
|
declare const ZERO: BN;
|
|
152
159
|
declare const ONE: BN;
|
|
153
160
|
declare const TWO: BN;
|
|
@@ -179,6 +186,7 @@ type ExtendedDetails = {
|
|
|
179
186
|
aftermathLpSupplyType?: string;
|
|
180
187
|
turbosFeeType?: string;
|
|
181
188
|
afterSqrtPrice?: string;
|
|
189
|
+
deepbookv3DeepFee?: number;
|
|
182
190
|
};
|
|
183
191
|
type Path = {
|
|
184
192
|
id: string;
|
|
@@ -215,10 +223,24 @@ type AggregatorResponse = {
|
|
|
215
223
|
data: RouterData;
|
|
216
224
|
};
|
|
217
225
|
declare function getRouterResult(endpoint: string, params: FindRouterParams): Promise<RouterData | null>;
|
|
226
|
+
type DeepbookV3Config = {
|
|
227
|
+
id: string;
|
|
228
|
+
is_alternative_payment: boolean;
|
|
229
|
+
deep_fee_vault: number;
|
|
230
|
+
whitelist: number;
|
|
231
|
+
whitelist_pools: string[];
|
|
232
|
+
last_updated_time: number;
|
|
233
|
+
};
|
|
234
|
+
type DeepbookV3ConfigResponse = {
|
|
235
|
+
code: number;
|
|
236
|
+
msg: string;
|
|
237
|
+
data: DeepbookV3Config;
|
|
238
|
+
};
|
|
239
|
+
declare function getDeepbookV3Config(endpoint: string): Promise<DeepbookV3ConfigResponse | null>;
|
|
218
240
|
|
|
219
241
|
declare enum Env {
|
|
220
242
|
Mainnet = 0,
|
|
221
243
|
Testnet = 1
|
|
222
244
|
}
|
|
223
245
|
|
|
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -5992,6 +5992,45 @@ 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" : "0xe19b5d072346cae83a037d4e3c8492068a74410a74e5830b3a68012db38296aa";
|
|
5999
|
+
this.deepCoinType = env === 0 /* Mainnet */ ? "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP" : "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
6000
|
+
}
|
|
6001
|
+
swap(client, txb, path, inputCoin, deepbookv3DeepFee) {
|
|
6002
|
+
return __async(this, null, function* () {
|
|
6003
|
+
var _a, _b, _c;
|
|
6004
|
+
const { direction, from, target } = path;
|
|
6005
|
+
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
6006
|
+
let deepFee;
|
|
6007
|
+
if (deepbookv3DeepFee) {
|
|
6008
|
+
if (((_a = path.extendedDetails) == null ? void 0 : _a.deepbookv3DeepFee) && ((_b = path.extendedDetails) == null ? void 0 : _b.deepbookv3DeepFee) > 0) {
|
|
6009
|
+
const splitAmounts = [(_c = path.extendedDetails) == null ? void 0 : _c.deepbookv3DeepFee];
|
|
6010
|
+
deepFee = txb.splitCoins(deepbookv3DeepFee, splitAmounts)[0];
|
|
6011
|
+
} else {
|
|
6012
|
+
deepFee = mintZeroCoin(txb, this.deepCoinType);
|
|
6013
|
+
}
|
|
6014
|
+
} else {
|
|
6015
|
+
deepFee = mintZeroCoin(txb, this.deepCoinType);
|
|
6016
|
+
}
|
|
6017
|
+
const args = [
|
|
6018
|
+
txb.object(this.deepbookV3Config),
|
|
6019
|
+
txb.object(path.id),
|
|
6020
|
+
inputCoin,
|
|
6021
|
+
deepFee,
|
|
6022
|
+
txb.object(CLOCK_ADDRESS)
|
|
6023
|
+
];
|
|
6024
|
+
const res = txb.moveCall({
|
|
6025
|
+
target: `${client.publishedAt()}::deepbookv3::${func}`,
|
|
6026
|
+
typeArguments: [coinAType, coinBType],
|
|
6027
|
+
arguments: args
|
|
6028
|
+
});
|
|
6029
|
+
return res;
|
|
6030
|
+
});
|
|
6031
|
+
}
|
|
6032
|
+
};
|
|
6033
|
+
|
|
5995
6034
|
// src/client.ts
|
|
5996
6035
|
var CETUS = "CETUS";
|
|
5997
6036
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6005,9 +6044,10 @@ var HAEDAL = "HAEDAL";
|
|
|
6005
6044
|
var VOLO = "VOLO";
|
|
6006
6045
|
var AFSUI = "AFSUI";
|
|
6007
6046
|
var BLUEMOVE = "BLUEMOVE";
|
|
6008
|
-
var
|
|
6047
|
+
var DEEPBOOKV3 = "DEEPBOOKV3";
|
|
6048
|
+
var AggregatorClient7 = class {
|
|
6009
6049
|
constructor(endpoint, signer, client, env) {
|
|
6010
|
-
this.endpoint = endpoint;
|
|
6050
|
+
this.endpoint = processEndpoint(endpoint);
|
|
6011
6051
|
this.client = client;
|
|
6012
6052
|
this.signer = signer;
|
|
6013
6053
|
this.env = env;
|
|
@@ -6044,7 +6084,7 @@ var AggregatorClient6 = class {
|
|
|
6044
6084
|
return getRouterResult(this.endpoint, params);
|
|
6045
6085
|
});
|
|
6046
6086
|
}
|
|
6047
|
-
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner) {
|
|
6087
|
+
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner, deepbookv3DeepFee) {
|
|
6048
6088
|
return __async(this, null, function* () {
|
|
6049
6089
|
if (routers.length === 0) {
|
|
6050
6090
|
throw new Error("No router found");
|
|
@@ -6061,11 +6101,14 @@ var AggregatorClient6 = class {
|
|
|
6061
6101
|
let nextCoin = inputCoins[i];
|
|
6062
6102
|
for (const path of routers[i].path) {
|
|
6063
6103
|
const dex = this.newDex(path.provider, partner);
|
|
6064
|
-
nextCoin = yield dex.swap(this, txb, path, nextCoin);
|
|
6104
|
+
nextCoin = yield dex.swap(this, txb, path, nextCoin, deepbookv3DeepFee);
|
|
6065
6105
|
}
|
|
6066
6106
|
outputCoins.push(nextCoin);
|
|
6067
6107
|
}
|
|
6068
6108
|
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType);
|
|
6109
|
+
if (deepbookv3DeepFee) {
|
|
6110
|
+
this.transferOrDestoryCoin(txb, deepbookv3DeepFee, this.deepbookv3DeepFeeType());
|
|
6111
|
+
}
|
|
6069
6112
|
const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
|
|
6070
6113
|
txb,
|
|
6071
6114
|
outputCoins,
|
|
@@ -6137,7 +6180,7 @@ var AggregatorClient6 = class {
|
|
|
6137
6180
|
}
|
|
6138
6181
|
routerSwap(params) {
|
|
6139
6182
|
return __async(this, null, function* () {
|
|
6140
|
-
const { routers, inputCoin, slippage, byAmountIn, txb, partner } = params;
|
|
6183
|
+
const { routers, inputCoin, slippage, byAmountIn, txb, partner, deepbookv3DeepFee } = params;
|
|
6141
6184
|
const amountIn = routers.reduce(
|
|
6142
6185
|
(acc, router) => acc.add(router.amountIn),
|
|
6143
6186
|
new import_bn5.default(0)
|
|
@@ -6157,7 +6200,8 @@ var AggregatorClient6 = class {
|
|
|
6157
6200
|
inputCoin,
|
|
6158
6201
|
routers,
|
|
6159
6202
|
new import_bn5.default(amountLimit),
|
|
6160
|
-
partner
|
|
6203
|
+
partner,
|
|
6204
|
+
deepbookv3DeepFee
|
|
6161
6205
|
);
|
|
6162
6206
|
return targetCoin2;
|
|
6163
6207
|
}
|
|
@@ -6185,7 +6229,8 @@ var AggregatorClient6 = class {
|
|
|
6185
6229
|
txb,
|
|
6186
6230
|
partner,
|
|
6187
6231
|
isMergeTragetCoin,
|
|
6188
|
-
refreshAllCoins
|
|
6232
|
+
refreshAllCoins,
|
|
6233
|
+
deepbookv3DeepFee
|
|
6189
6234
|
} = params;
|
|
6190
6235
|
if (refreshAllCoins || this.allCoins.length === 0) {
|
|
6191
6236
|
this.allCoins = yield this.getAllCoins();
|
|
@@ -6218,7 +6263,8 @@ var AggregatorClient6 = class {
|
|
|
6218
6263
|
slippage,
|
|
6219
6264
|
byAmountIn,
|
|
6220
6265
|
txb,
|
|
6221
|
-
partner
|
|
6266
|
+
partner,
|
|
6267
|
+
deepbookv3DeepFee
|
|
6222
6268
|
});
|
|
6223
6269
|
if (isMergeTragetCoin) {
|
|
6224
6270
|
const targetCoinRes = buildInputCoin(
|
|
@@ -6244,7 +6290,14 @@ var AggregatorClient6 = class {
|
|
|
6244
6290
|
if (this.env === 0 /* Mainnet */) {
|
|
6245
6291
|
return "0x764b8132a94d35abc9dfd91b23a0757b2a717d5ecb04c03098794aa2a508db91";
|
|
6246
6292
|
} else {
|
|
6247
|
-
return "
|
|
6293
|
+
return "0xf92cdec6c2d73a12d8afa8dd41199b3e95b621272bbc655996539cd30de6a462";
|
|
6294
|
+
}
|
|
6295
|
+
}
|
|
6296
|
+
deepbookv3DeepFeeType() {
|
|
6297
|
+
if (this.env === 0 /* Mainnet */) {
|
|
6298
|
+
return "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
6299
|
+
} else {
|
|
6300
|
+
return "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP";
|
|
6248
6301
|
}
|
|
6249
6302
|
}
|
|
6250
6303
|
transferOrDestoryCoin(txb, coin, coinType) {
|
|
@@ -6278,6 +6331,8 @@ var AggregatorClient6 = class {
|
|
|
6278
6331
|
return new Cetus(this.env, partner);
|
|
6279
6332
|
case DEEPBOOKV2:
|
|
6280
6333
|
return new DeepbookV2(this.env);
|
|
6334
|
+
case DEEPBOOKV3:
|
|
6335
|
+
return new DeepbookV3(this.env);
|
|
6281
6336
|
case KRIYA:
|
|
6282
6337
|
return new KriyaV2(this.env);
|
|
6283
6338
|
case KRIYAV3:
|
|
@@ -6335,6 +6390,15 @@ var AggregatorClient6 = class {
|
|
|
6335
6390
|
return res;
|
|
6336
6391
|
});
|
|
6337
6392
|
}
|
|
6393
|
+
getDeepbookV3Config() {
|
|
6394
|
+
return __async(this, null, function* () {
|
|
6395
|
+
const res = yield getDeepbookV3Config(this.endpoint);
|
|
6396
|
+
if (res) {
|
|
6397
|
+
return res.data;
|
|
6398
|
+
}
|
|
6399
|
+
return null;
|
|
6400
|
+
});
|
|
6401
|
+
}
|
|
6338
6402
|
};
|
|
6339
6403
|
function parseRouterResponse(data) {
|
|
6340
6404
|
return {
|
|
@@ -6344,17 +6408,18 @@ function parseRouterResponse(data) {
|
|
|
6344
6408
|
routes: data.routes.map((route) => {
|
|
6345
6409
|
return {
|
|
6346
6410
|
path: route.path.map((path) => {
|
|
6347
|
-
var _a, _b, _c;
|
|
6411
|
+
var _a, _b, _c, _d;
|
|
6348
6412
|
let version;
|
|
6349
6413
|
if (path.provider === AFTERMATH) {
|
|
6350
6414
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
6351
6415
|
}
|
|
6352
6416
|
let extendedDetails;
|
|
6353
|
-
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS) {
|
|
6417
|
+
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS || path.provider === DEEPBOOKV3) {
|
|
6354
6418
|
extendedDetails = {
|
|
6355
6419
|
aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
|
|
6356
6420
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
6357
|
-
afterSqrtPrice: (_c = path.extended_details) == null ? void 0 : _c.after_sqrt_price
|
|
6421
|
+
afterSqrtPrice: (_c = path.extended_details) == null ? void 0 : _c.after_sqrt_price,
|
|
6422
|
+
deepbookv3DeepFee: (_d = path.extended_details) == null ? void 0 : _d.deepbookv3_deep_fee
|
|
6358
6423
|
};
|
|
6359
6424
|
}
|
|
6360
6425
|
return {
|
|
@@ -6406,6 +6471,14 @@ var restituteMsafeFastRouterSwapParams = (data) => {
|
|
|
6406
6471
|
return result;
|
|
6407
6472
|
};
|
|
6408
6473
|
|
|
6474
|
+
// src/utils/api.ts
|
|
6475
|
+
function processEndpoint(endpoint) {
|
|
6476
|
+
if (endpoint.endsWith("/find_routes")) {
|
|
6477
|
+
return endpoint.replace("/find_routes", "");
|
|
6478
|
+
}
|
|
6479
|
+
return endpoint;
|
|
6480
|
+
}
|
|
6481
|
+
|
|
6409
6482
|
// src/api.ts
|
|
6410
6483
|
function getRouterResult(endpoint, params) {
|
|
6411
6484
|
return __async(this, null, function* () {
|
|
@@ -6468,7 +6541,7 @@ function getRouter(endpoint, params) {
|
|
|
6468
6541
|
} = params;
|
|
6469
6542
|
const fromCoin = completionCoin(from);
|
|
6470
6543
|
const targetCoin = completionCoin(target);
|
|
6471
|
-
let url = `${endpoint}?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`;
|
|
6544
|
+
let url = `${endpoint}/find_routes?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`;
|
|
6472
6545
|
if (depth) {
|
|
6473
6546
|
url += `&depth=${depth}`;
|
|
6474
6547
|
}
|
|
@@ -6510,7 +6583,7 @@ function postRouterWithLiquidityChanges(endpoint, params) {
|
|
|
6510
6583
|
} = params;
|
|
6511
6584
|
const fromCoin = completionCoin(from);
|
|
6512
6585
|
const targetCoin = completionCoin(target);
|
|
6513
|
-
const url = `${endpoint}`;
|
|
6586
|
+
const url = `${endpoint}/find_routes`;
|
|
6514
6587
|
const providersStr = providers == null ? void 0 : providers.join(",");
|
|
6515
6588
|
const requestData = {
|
|
6516
6589
|
from: fromCoin,
|
|
@@ -6529,7 +6602,6 @@ function postRouterWithLiquidityChanges(endpoint, params) {
|
|
|
6529
6602
|
delta_liquidity: change.deltaLiquidity
|
|
6530
6603
|
}))
|
|
6531
6604
|
};
|
|
6532
|
-
console.log("requestData", JSON.stringify(requestData, null, 2));
|
|
6533
6605
|
try {
|
|
6534
6606
|
const response = yield fetch(url, {
|
|
6535
6607
|
method: "POST",
|
|
@@ -6545,6 +6617,18 @@ function postRouterWithLiquidityChanges(endpoint, params) {
|
|
|
6545
6617
|
}
|
|
6546
6618
|
});
|
|
6547
6619
|
}
|
|
6620
|
+
function getDeepbookV3Config(endpoint) {
|
|
6621
|
+
return __async(this, null, function* () {
|
|
6622
|
+
const url = `${endpoint}/deepbookv3_config`;
|
|
6623
|
+
try {
|
|
6624
|
+
const response = yield fetch(url);
|
|
6625
|
+
return response.json();
|
|
6626
|
+
} catch (error) {
|
|
6627
|
+
console.error("Error:", error);
|
|
6628
|
+
return null;
|
|
6629
|
+
}
|
|
6630
|
+
});
|
|
6631
|
+
}
|
|
6548
6632
|
|
|
6549
6633
|
// src/index.ts
|
|
6550
6634
|
var Env = /* @__PURE__ */ ((Env2) => {
|
|
@@ -6566,11 +6650,12 @@ decimal.js/decimal.mjs:
|
|
|
6566
6650
|
|
|
6567
6651
|
exports.AFSUI = AFSUI;
|
|
6568
6652
|
exports.AFTERMATH = AFTERMATH;
|
|
6569
|
-
exports.AggregatorClient =
|
|
6653
|
+
exports.AggregatorClient = AggregatorClient7;
|
|
6570
6654
|
exports.BLUEMOVE = BLUEMOVE;
|
|
6571
6655
|
exports.CETUS = CETUS;
|
|
6572
6656
|
exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
|
|
6573
6657
|
exports.DEEPBOOKV2 = DEEPBOOKV2;
|
|
6658
|
+
exports.DEEPBOOKV3 = DEEPBOOKV3;
|
|
6574
6659
|
exports.Env = Env;
|
|
6575
6660
|
exports.FLOWXV2 = FLOWXV2;
|
|
6576
6661
|
exports.FLOWXV3 = FLOWXV3;
|
|
@@ -6592,9 +6677,11 @@ exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMs
|
|
|
6592
6677
|
exports.extractAddressFromType = extractAddressFromType;
|
|
6593
6678
|
exports.extractStructTagFromType = extractStructTagFromType;
|
|
6594
6679
|
exports.fixSuiObjectId = fixSuiObjectId;
|
|
6680
|
+
exports.getDeepbookV3Config = getDeepbookV3Config;
|
|
6595
6681
|
exports.getRouterResult = getRouterResult;
|
|
6596
6682
|
exports.isSortedSymbols = isSortedSymbols;
|
|
6597
6683
|
exports.normalizeCoinType = normalizeCoinType;
|
|
6598
6684
|
exports.parseRouterResponse = parseRouterResponse;
|
|
6599
6685
|
exports.patchFixSuiObjectId = patchFixSuiObjectId;
|
|
6686
|
+
exports.processEndpoint = processEndpoint;
|
|
6600
6687
|
exports.restituteMsafeFastRouterSwapParams = restituteMsafeFastRouterSwapParams;
|