@cetusprotocol/aggregator-sdk 0.0.0-experimental-20241011180351 → 0.0.0-experimental-20241011205228
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 +3 -39
- package/dist/index.d.ts +3 -39
- package/dist/index.js +19 -148
- package/dist/index.mjs +19 -139
- package/dist/src/api.d.ts +0 -16
- package/dist/src/client.d.ts +2 -7
- package/dist/src/transaction/index.d.ts +1 -1
- package/dist/src/utils/index.d.ts +0 -3
- package/dist/tests/test_data.test.d.ts +0 -3
- package/package.json +1 -1
- package/src/api.ts +7 -33
- package/src/client.ts +11 -78
- package/src/transaction/afsui.ts +1 -0
- package/src/transaction/aftermath.ts +2 -0
- package/src/transaction/deepbook_v2.ts +1 -0
- package/src/transaction/index.ts +1 -2
- package/src/utils/index.ts +0 -3
- package/tests/router.test.ts +27 -29
- package/tests/test_data.test.ts +0 -3
- package/dist/src/transaction/deepbook_v3.d.ts +0 -13
- package/dist/src/utils/api.d.ts +0 -1
- package/src/transaction/deepbook_v3.ts +0 -68
- package/src/utils/api.ts +0 -6
- package/test.json +0 -5
package/dist/index.d.mts
CHANGED
|
@@ -72,7 +72,6 @@ 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";
|
|
76
75
|
type BuildRouterSwapParams = {
|
|
77
76
|
routers: Router[];
|
|
78
77
|
byAmountIn: boolean;
|
|
@@ -80,7 +79,6 @@ type BuildRouterSwapParams = {
|
|
|
80
79
|
slippage: number;
|
|
81
80
|
txb: Transaction;
|
|
82
81
|
partner?: string;
|
|
83
|
-
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
84
82
|
};
|
|
85
83
|
type BuildFastRouterSwapParams = {
|
|
86
84
|
routers: Router[];
|
|
@@ -90,7 +88,6 @@ type BuildFastRouterSwapParams = {
|
|
|
90
88
|
partner?: string;
|
|
91
89
|
isMergeTragetCoin?: boolean;
|
|
92
90
|
refreshAllCoins?: boolean;
|
|
93
|
-
payDeepFeeAmount?: number;
|
|
94
91
|
};
|
|
95
92
|
interface SwapInPoolsParams {
|
|
96
93
|
from: string;
|
|
@@ -112,26 +109,24 @@ declare class AggregatorClient {
|
|
|
112
109
|
constructor(endpoint: string, signer: string, client: SuiClient, env: Env);
|
|
113
110
|
getAllCoins(): Promise<CoinAsset[]>;
|
|
114
111
|
findRouters(params: FindRouterParams): Promise<RouterData | null>;
|
|
115
|
-
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string
|
|
112
|
+
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string): Promise<TransactionObjectArgument>;
|
|
116
113
|
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
|
|
117
114
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
118
115
|
routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
|
|
119
116
|
fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
|
|
120
117
|
publishedAt(): string;
|
|
121
|
-
deepbookv3DeepFeeType(): string;
|
|
122
118
|
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
123
119
|
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
|
|
124
120
|
newDex(provider: string, partner?: string): Dex;
|
|
125
121
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
126
122
|
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
127
123
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
128
|
-
getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
|
|
129
124
|
}
|
|
130
125
|
declare function parseRouterResponse(data: any): RouterData;
|
|
131
126
|
|
|
132
127
|
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
133
128
|
interface Dex {
|
|
134
|
-
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument
|
|
129
|
+
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
135
130
|
}
|
|
136
131
|
|
|
137
132
|
declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
|
|
@@ -153,21 +148,6 @@ declare function createTarget(packageName: string, moduleName: string, functionN
|
|
|
153
148
|
declare const dealWithFastRouterSwapParamsForMsafe: (data: any) => any;
|
|
154
149
|
declare const restituteMsafeFastRouterSwapParams: (data: any) => any;
|
|
155
150
|
|
|
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
|
-
|
|
171
151
|
declare const ZERO: BN;
|
|
172
152
|
declare const ONE: BN;
|
|
173
153
|
declare const TWO: BN;
|
|
@@ -199,7 +179,6 @@ type ExtendedDetails = {
|
|
|
199
179
|
aftermathLpSupplyType?: string;
|
|
200
180
|
turbosFeeType?: string;
|
|
201
181
|
afterSqrtPrice?: string;
|
|
202
|
-
deepbookv3DeepFee?: number;
|
|
203
182
|
};
|
|
204
183
|
type Path = {
|
|
205
184
|
id: string;
|
|
@@ -228,7 +207,6 @@ type RouterData = {
|
|
|
228
207
|
amountOut: BN;
|
|
229
208
|
routes: Router[];
|
|
230
209
|
insufficientLiquidity: boolean;
|
|
231
|
-
totalDeepFee?: number;
|
|
232
210
|
error?: RouterError;
|
|
233
211
|
};
|
|
234
212
|
type AggregatorResponse = {
|
|
@@ -237,24 +215,10 @@ type AggregatorResponse = {
|
|
|
237
215
|
data: RouterData;
|
|
238
216
|
};
|
|
239
217
|
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>;
|
|
254
218
|
|
|
255
219
|
declare enum Env {
|
|
256
220
|
Mainnet = 0,
|
|
257
221
|
Testnet = 1
|
|
258
222
|
}
|
|
259
223
|
|
|
260
|
-
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -72,7 +72,6 @@ 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";
|
|
76
75
|
type BuildRouterSwapParams = {
|
|
77
76
|
routers: Router[];
|
|
78
77
|
byAmountIn: boolean;
|
|
@@ -80,7 +79,6 @@ type BuildRouterSwapParams = {
|
|
|
80
79
|
slippage: number;
|
|
81
80
|
txb: Transaction;
|
|
82
81
|
partner?: string;
|
|
83
|
-
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
84
82
|
};
|
|
85
83
|
type BuildFastRouterSwapParams = {
|
|
86
84
|
routers: Router[];
|
|
@@ -90,7 +88,6 @@ type BuildFastRouterSwapParams = {
|
|
|
90
88
|
partner?: string;
|
|
91
89
|
isMergeTragetCoin?: boolean;
|
|
92
90
|
refreshAllCoins?: boolean;
|
|
93
|
-
payDeepFeeAmount?: number;
|
|
94
91
|
};
|
|
95
92
|
interface SwapInPoolsParams {
|
|
96
93
|
from: string;
|
|
@@ -112,26 +109,24 @@ declare class AggregatorClient {
|
|
|
112
109
|
constructor(endpoint: string, signer: string, client: SuiClient, env: Env);
|
|
113
110
|
getAllCoins(): Promise<CoinAsset[]>;
|
|
114
111
|
findRouters(params: FindRouterParams): Promise<RouterData | null>;
|
|
115
|
-
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string
|
|
112
|
+
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string): Promise<TransactionObjectArgument>;
|
|
116
113
|
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
|
|
117
114
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
118
115
|
routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
|
|
119
116
|
fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
|
|
120
117
|
publishedAt(): string;
|
|
121
|
-
deepbookv3DeepFeeType(): string;
|
|
122
118
|
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
123
119
|
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
|
|
124
120
|
newDex(provider: string, partner?: string): Dex;
|
|
125
121
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
126
122
|
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
127
123
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
128
|
-
getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
|
|
129
124
|
}
|
|
130
125
|
declare function parseRouterResponse(data: any): RouterData;
|
|
131
126
|
|
|
132
127
|
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
133
128
|
interface Dex {
|
|
134
|
-
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument
|
|
129
|
+
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
135
130
|
}
|
|
136
131
|
|
|
137
132
|
declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
|
|
@@ -153,21 +148,6 @@ declare function createTarget(packageName: string, moduleName: string, functionN
|
|
|
153
148
|
declare const dealWithFastRouterSwapParamsForMsafe: (data: any) => any;
|
|
154
149
|
declare const restituteMsafeFastRouterSwapParams: (data: any) => any;
|
|
155
150
|
|
|
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
|
-
|
|
171
151
|
declare const ZERO: BN;
|
|
172
152
|
declare const ONE: BN;
|
|
173
153
|
declare const TWO: BN;
|
|
@@ -199,7 +179,6 @@ type ExtendedDetails = {
|
|
|
199
179
|
aftermathLpSupplyType?: string;
|
|
200
180
|
turbosFeeType?: string;
|
|
201
181
|
afterSqrtPrice?: string;
|
|
202
|
-
deepbookv3DeepFee?: number;
|
|
203
182
|
};
|
|
204
183
|
type Path = {
|
|
205
184
|
id: string;
|
|
@@ -228,7 +207,6 @@ type RouterData = {
|
|
|
228
207
|
amountOut: BN;
|
|
229
208
|
routes: Router[];
|
|
230
209
|
insufficientLiquidity: boolean;
|
|
231
|
-
totalDeepFee?: number;
|
|
232
210
|
error?: RouterError;
|
|
233
211
|
};
|
|
234
212
|
type AggregatorResponse = {
|
|
@@ -237,24 +215,10 @@ type AggregatorResponse = {
|
|
|
237
215
|
data: RouterData;
|
|
238
216
|
};
|
|
239
217
|
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>;
|
|
254
218
|
|
|
255
219
|
declare enum Env {
|
|
256
220
|
Mainnet = 0,
|
|
257
221
|
Testnet = 1
|
|
258
222
|
}
|
|
259
223
|
|
|
260
|
-
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEMOVE, type
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -5714,16 +5714,6 @@ 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
|
-
}
|
|
5727
5717
|
function checkInvalidSuiAddress(address) {
|
|
5728
5718
|
if (!address.startsWith("0x") || address.length !== 66) {
|
|
5729
5719
|
return false;
|
|
@@ -6002,45 +5992,6 @@ var Bluemove = class {
|
|
|
6002
5992
|
}
|
|
6003
5993
|
};
|
|
6004
5994
|
|
|
6005
|
-
// src/transaction/deepbook_v3.ts
|
|
6006
|
-
var DeepbookV3 = class {
|
|
6007
|
-
constructor(env) {
|
|
6008
|
-
this.deepbookV3Config = env === 0 /* Mainnet */ ? "0x0" : "0xe19b5d072346cae83a037d4e3c8492068a74410a74e5830b3a68012db38296aa";
|
|
6009
|
-
this.deepCoinType = env === 0 /* Mainnet */ ? "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP" : "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
6010
|
-
}
|
|
6011
|
-
swap(client, txb, path, inputCoin, deepbookv3DeepFee) {
|
|
6012
|
-
return __async(this, null, function* () {
|
|
6013
|
-
var _a, _b, _c;
|
|
6014
|
-
const { direction, from, target } = path;
|
|
6015
|
-
const [func, coinAType, coinBType] = direction ? ["swap_a2b", from, target] : ["swap_b2a", target, from];
|
|
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
|
-
}
|
|
6027
|
-
const args = [
|
|
6028
|
-
txb.object(this.deepbookV3Config),
|
|
6029
|
-
txb.object(path.id),
|
|
6030
|
-
inputCoin,
|
|
6031
|
-
deepFee,
|
|
6032
|
-
txb.object(CLOCK_ADDRESS)
|
|
6033
|
-
];
|
|
6034
|
-
const res = txb.moveCall({
|
|
6035
|
-
target: `${client.publishedAt()}::deepbookv3::${func}`,
|
|
6036
|
-
typeArguments: [coinAType, coinBType],
|
|
6037
|
-
arguments: args
|
|
6038
|
-
});
|
|
6039
|
-
return res;
|
|
6040
|
-
});
|
|
6041
|
-
}
|
|
6042
|
-
};
|
|
6043
|
-
|
|
6044
5995
|
// src/client.ts
|
|
6045
5996
|
var CETUS = "CETUS";
|
|
6046
5997
|
var DEEPBOOKV2 = "DEEPBOOK";
|
|
@@ -6054,10 +6005,9 @@ var HAEDAL = "HAEDAL";
|
|
|
6054
6005
|
var VOLO = "VOLO";
|
|
6055
6006
|
var AFSUI = "AFSUI";
|
|
6056
6007
|
var BLUEMOVE = "BLUEMOVE";
|
|
6057
|
-
var
|
|
6058
|
-
var AggregatorClient7 = class {
|
|
6008
|
+
var AggregatorClient6 = class {
|
|
6059
6009
|
constructor(endpoint, signer, client, env) {
|
|
6060
|
-
this.endpoint =
|
|
6010
|
+
this.endpoint = endpoint;
|
|
6061
6011
|
this.client = client;
|
|
6062
6012
|
this.signer = signer;
|
|
6063
6013
|
this.env = env;
|
|
@@ -6094,7 +6044,7 @@ var AggregatorClient7 = class {
|
|
|
6094
6044
|
return getRouterResult(this.endpoint, params);
|
|
6095
6045
|
});
|
|
6096
6046
|
}
|
|
6097
|
-
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner
|
|
6047
|
+
expectInputSwap(txb, inputCoin, routers, amountOutLimit, partner) {
|
|
6098
6048
|
return __async(this, null, function* () {
|
|
6099
6049
|
if (routers.length === 0) {
|
|
6100
6050
|
throw new Error("No router found");
|
|
@@ -6111,14 +6061,11 @@ var AggregatorClient7 = class {
|
|
|
6111
6061
|
let nextCoin = inputCoins[i];
|
|
6112
6062
|
for (const path of routers[i].path) {
|
|
6113
6063
|
const dex = this.newDex(path.provider, partner);
|
|
6114
|
-
nextCoin = yield dex.swap(this, txb, path, nextCoin
|
|
6064
|
+
nextCoin = yield dex.swap(this, txb, path, nextCoin);
|
|
6115
6065
|
}
|
|
6116
6066
|
outputCoins.push(nextCoin);
|
|
6117
6067
|
}
|
|
6118
6068
|
this.transferOrDestoryCoin(txb, inputCoin, inputCoinType);
|
|
6119
|
-
if (deepbookv3DeepFee) {
|
|
6120
|
-
this.transferOrDestoryCoin(txb, deepbookv3DeepFee, this.deepbookv3DeepFeeType());
|
|
6121
|
-
}
|
|
6122
6069
|
const mergedTargetCointhis = this.checkCoinThresholdAndMergeCoin(
|
|
6123
6070
|
txb,
|
|
6124
6071
|
outputCoins,
|
|
@@ -6190,7 +6137,7 @@ var AggregatorClient7 = class {
|
|
|
6190
6137
|
}
|
|
6191
6138
|
routerSwap(params) {
|
|
6192
6139
|
return __async(this, null, function* () {
|
|
6193
|
-
const { routers, inputCoin, slippage, byAmountIn, txb, partner
|
|
6140
|
+
const { routers, inputCoin, slippage, byAmountIn, txb, partner } = params;
|
|
6194
6141
|
const amountIn = routers.reduce(
|
|
6195
6142
|
(acc, router) => acc.add(router.amountIn),
|
|
6196
6143
|
new import_bn5.default(0)
|
|
@@ -6210,8 +6157,7 @@ var AggregatorClient7 = class {
|
|
|
6210
6157
|
inputCoin,
|
|
6211
6158
|
routers,
|
|
6212
6159
|
new import_bn5.default(amountLimit),
|
|
6213
|
-
partner
|
|
6214
|
-
deepbookv3DeepFee
|
|
6160
|
+
partner
|
|
6215
6161
|
);
|
|
6216
6162
|
return targetCoin2;
|
|
6217
6163
|
}
|
|
@@ -6239,8 +6185,7 @@ var AggregatorClient7 = class {
|
|
|
6239
6185
|
txb,
|
|
6240
6186
|
partner,
|
|
6241
6187
|
isMergeTragetCoin,
|
|
6242
|
-
refreshAllCoins
|
|
6243
|
-
payDeepFeeAmount
|
|
6188
|
+
refreshAllCoins
|
|
6244
6189
|
} = params;
|
|
6245
6190
|
if (refreshAllCoins || this.allCoins.length === 0) {
|
|
6246
6191
|
this.allCoins = yield this.getAllCoins();
|
|
@@ -6267,30 +6212,13 @@ var AggregatorClient7 = class {
|
|
|
6267
6212
|
BigInt(amount.toString()),
|
|
6268
6213
|
fromCoinType
|
|
6269
6214
|
);
|
|
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
|
-
}
|
|
6286
6215
|
const targetCoin = yield this.routerSwap({
|
|
6287
6216
|
routers,
|
|
6288
6217
|
inputCoin: buildFromCoinRes.targetCoin,
|
|
6289
6218
|
slippage,
|
|
6290
6219
|
byAmountIn,
|
|
6291
6220
|
txb,
|
|
6292
|
-
partner
|
|
6293
|
-
deepbookv3DeepFee: buildDeepFeeCoinRes.targetCoin
|
|
6221
|
+
partner
|
|
6294
6222
|
});
|
|
6295
6223
|
if (isMergeTragetCoin) {
|
|
6296
6224
|
const targetCoinRes = buildInputCoin(
|
|
@@ -6314,16 +6242,9 @@ var AggregatorClient7 = class {
|
|
|
6314
6242
|
}
|
|
6315
6243
|
publishedAt() {
|
|
6316
6244
|
if (this.env === 0 /* Mainnet */) {
|
|
6317
|
-
return "
|
|
6318
|
-
} else {
|
|
6319
|
-
return "0xf92cdec6c2d73a12d8afa8dd41199b3e95b621272bbc655996539cd30de6a462";
|
|
6320
|
-
}
|
|
6321
|
-
}
|
|
6322
|
-
deepbookv3DeepFeeType() {
|
|
6323
|
-
if (this.env === 0 /* Mainnet */) {
|
|
6324
|
-
return "0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP";
|
|
6245
|
+
return "0x7eb2f30d541c06fa7bcf26444845df56361647df0e778b82e5707fb26754c398";
|
|
6325
6246
|
} else {
|
|
6326
|
-
return "
|
|
6247
|
+
return "0x6cbaa3e9fbe902d90191b12f315932bc58079cba422bafbd4b4369f80e61f595";
|
|
6327
6248
|
}
|
|
6328
6249
|
}
|
|
6329
6250
|
transferOrDestoryCoin(txb, coin, coinType) {
|
|
@@ -6357,8 +6278,6 @@ var AggregatorClient7 = class {
|
|
|
6357
6278
|
return new Cetus(this.env, partner);
|
|
6358
6279
|
case DEEPBOOKV2:
|
|
6359
6280
|
return new DeepbookV2(this.env);
|
|
6360
|
-
case DEEPBOOKV3:
|
|
6361
|
-
return new DeepbookV3(this.env);
|
|
6362
6281
|
case KRIYA:
|
|
6363
6282
|
return new KriyaV2(this.env);
|
|
6364
6283
|
case KRIYAV3:
|
|
@@ -6416,44 +6335,26 @@ var AggregatorClient7 = class {
|
|
|
6416
6335
|
return res;
|
|
6417
6336
|
});
|
|
6418
6337
|
}
|
|
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
|
-
}
|
|
6428
6338
|
};
|
|
6429
6339
|
function parseRouterResponse(data) {
|
|
6430
|
-
|
|
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 = {
|
|
6340
|
+
return {
|
|
6439
6341
|
amountIn: new import_bn5.default(data.amount_in.toString()),
|
|
6440
6342
|
amountOut: new import_bn5.default(data.amount_out.toString()),
|
|
6441
6343
|
insufficientLiquidity: false,
|
|
6442
6344
|
routes: data.routes.map((route) => {
|
|
6443
6345
|
return {
|
|
6444
6346
|
path: route.path.map((path) => {
|
|
6445
|
-
var _a, _b, _c
|
|
6347
|
+
var _a, _b, _c;
|
|
6446
6348
|
let version;
|
|
6447
6349
|
if (path.provider === AFTERMATH) {
|
|
6448
6350
|
version = path.extended_details.aftermath_pool_flatness === 0 ? "v2" : "v3";
|
|
6449
6351
|
}
|
|
6450
6352
|
let extendedDetails;
|
|
6451
|
-
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS
|
|
6353
|
+
if (path.provider === TURBOS || path.provider === AFTERMATH || path.provider === CETUS) {
|
|
6452
6354
|
extendedDetails = {
|
|
6453
6355
|
aftermathLpSupplyType: (_a = path.extended_details) == null ? void 0 : _a.aftermath_lp_supply_type,
|
|
6454
6356
|
turbosFeeType: (_b = path.extended_details) == null ? void 0 : _b.turbos_fee_type,
|
|
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
|
|
6357
|
+
afterSqrtPrice: (_c = path.extended_details) == null ? void 0 : _c.after_sqrt_price
|
|
6457
6358
|
};
|
|
6458
6359
|
}
|
|
6459
6360
|
return {
|
|
@@ -6473,10 +6374,8 @@ function parseRouterResponse(data) {
|
|
|
6473
6374
|
amountOut: new import_bn5.default(route.amount_out.toString()),
|
|
6474
6375
|
initialPrice: new decimal_default(route.initial_price.toString())
|
|
6475
6376
|
};
|
|
6476
|
-
})
|
|
6477
|
-
totalDeepFee
|
|
6377
|
+
})
|
|
6478
6378
|
};
|
|
6479
|
-
return routerData;
|
|
6480
6379
|
}
|
|
6481
6380
|
|
|
6482
6381
|
// src/transaction/index.ts
|
|
@@ -6507,14 +6406,6 @@ var restituteMsafeFastRouterSwapParams = (data) => {
|
|
|
6507
6406
|
return result;
|
|
6508
6407
|
};
|
|
6509
6408
|
|
|
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
|
-
|
|
6518
6409
|
// src/api.ts
|
|
6519
6410
|
function getRouterResult(endpoint, params) {
|
|
6520
6411
|
return __async(this, null, function* () {
|
|
@@ -6577,7 +6468,7 @@ function getRouter(endpoint, params) {
|
|
|
6577
6468
|
} = params;
|
|
6578
6469
|
const fromCoin = completionCoin(from);
|
|
6579
6470
|
const targetCoin = completionCoin(target);
|
|
6580
|
-
let url = `${endpoint}
|
|
6471
|
+
let url = `${endpoint}?from=${fromCoin}&target=${targetCoin}&amount=${amount.toString()}&by_amount_in=${byAmountIn}`;
|
|
6581
6472
|
if (depth) {
|
|
6582
6473
|
url += `&depth=${depth}`;
|
|
6583
6474
|
}
|
|
@@ -6619,7 +6510,7 @@ function postRouterWithLiquidityChanges(endpoint, params) {
|
|
|
6619
6510
|
} = params;
|
|
6620
6511
|
const fromCoin = completionCoin(from);
|
|
6621
6512
|
const targetCoin = completionCoin(target);
|
|
6622
|
-
const url = `${endpoint}
|
|
6513
|
+
const url = `${endpoint}`;
|
|
6623
6514
|
const providersStr = providers == null ? void 0 : providers.join(",");
|
|
6624
6515
|
const requestData = {
|
|
6625
6516
|
from: fromCoin,
|
|
@@ -6638,6 +6529,7 @@ function postRouterWithLiquidityChanges(endpoint, params) {
|
|
|
6638
6529
|
delta_liquidity: change.deltaLiquidity
|
|
6639
6530
|
}))
|
|
6640
6531
|
};
|
|
6532
|
+
console.log("requestData", JSON.stringify(requestData, null, 2));
|
|
6641
6533
|
try {
|
|
6642
6534
|
const response = yield fetch(url, {
|
|
6643
6535
|
method: "POST",
|
|
@@ -6653,18 +6545,6 @@ function postRouterWithLiquidityChanges(endpoint, params) {
|
|
|
6653
6545
|
}
|
|
6654
6546
|
});
|
|
6655
6547
|
}
|
|
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
|
-
}
|
|
6668
6548
|
|
|
6669
6549
|
// src/index.ts
|
|
6670
6550
|
var Env = /* @__PURE__ */ ((Env2) => {
|
|
@@ -6686,12 +6566,11 @@ decimal.js/decimal.mjs:
|
|
|
6686
6566
|
|
|
6687
6567
|
exports.AFSUI = AFSUI;
|
|
6688
6568
|
exports.AFTERMATH = AFTERMATH;
|
|
6689
|
-
exports.AggregatorClient =
|
|
6569
|
+
exports.AggregatorClient = AggregatorClient6;
|
|
6690
6570
|
exports.BLUEMOVE = BLUEMOVE;
|
|
6691
6571
|
exports.CETUS = CETUS;
|
|
6692
6572
|
exports.CLOCK_ADDRESS = CLOCK_ADDRESS;
|
|
6693
6573
|
exports.DEEPBOOKV2 = DEEPBOOKV2;
|
|
6694
|
-
exports.DEEPBOOKV3 = DEEPBOOKV3;
|
|
6695
6574
|
exports.Env = Env;
|
|
6696
6575
|
exports.FLOWXV2 = FLOWXV2;
|
|
6697
6576
|
exports.FLOWXV3 = FLOWXV3;
|
|
@@ -6707,23 +6586,15 @@ exports.U64_MAX = U64_MAX;
|
|
|
6707
6586
|
exports.U64_MAX_BN = U64_MAX_BN;
|
|
6708
6587
|
exports.VOLO = VOLO;
|
|
6709
6588
|
exports.ZERO = ZERO;
|
|
6710
|
-
exports.buildInputCoin = buildInputCoin;
|
|
6711
|
-
exports.checkInvalidSuiAddress = checkInvalidSuiAddress;
|
|
6712
|
-
exports.compareCoins = compareCoins;
|
|
6713
|
-
exports.completionCoin = completionCoin;
|
|
6714
6589
|
exports.composeType = composeType;
|
|
6715
6590
|
exports.createTarget = createTarget;
|
|
6716
6591
|
exports.dealWithFastRouterSwapParamsForMsafe = dealWithFastRouterSwapParamsForMsafe;
|
|
6717
6592
|
exports.extractAddressFromType = extractAddressFromType;
|
|
6718
6593
|
exports.extractStructTagFromType = extractStructTagFromType;
|
|
6719
6594
|
exports.fixSuiObjectId = fixSuiObjectId;
|
|
6720
|
-
exports.getDeepbookV3Config = getDeepbookV3Config;
|
|
6721
6595
|
exports.getRouterResult = getRouterResult;
|
|
6722
6596
|
exports.isSortedSymbols = isSortedSymbols;
|
|
6723
|
-
exports.mintZeroCoin = mintZeroCoin;
|
|
6724
6597
|
exports.normalizeCoinType = normalizeCoinType;
|
|
6725
6598
|
exports.parseRouterResponse = parseRouterResponse;
|
|
6726
6599
|
exports.patchFixSuiObjectId = patchFixSuiObjectId;
|
|
6727
|
-
exports.printTransaction = printTransaction;
|
|
6728
|
-
exports.processEndpoint = processEndpoint;
|
|
6729
6600
|
exports.restituteMsafeFastRouterSwapParams = restituteMsafeFastRouterSwapParams;
|