@cetusprotocol/aggregator-sdk 0.3.17 → 0.3.19
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 +34 -11
- package/dist/index.d.ts +34 -11
- package/dist/index.js +209 -88
- package/dist/index.mjs +203 -88
- package/dist/src/api.d.ts +2 -0
- package/dist/src/client.d.ts +26 -9
- package/dist/src/transaction/afsui.d.ts +1 -1
- package/dist/src/transaction/aftermath.d.ts +1 -1
- package/dist/src/transaction/alphafi.d.ts +7 -0
- package/dist/src/transaction/bluefin.d.ts +1 -1
- package/dist/src/transaction/bluemove.d.ts +1 -1
- package/dist/src/transaction/cetus.d.ts +3 -3
- package/dist/src/transaction/deepbook_v2.d.ts +1 -1
- package/dist/src/transaction/deepbook_v3.d.ts +1 -1
- package/dist/src/transaction/flowx_v2.d.ts +1 -1
- package/dist/src/transaction/flowx_v3.d.ts +1 -1
- package/dist/src/transaction/haedal.d.ts +1 -1
- package/dist/src/transaction/haedal_pmm.d.ts +1 -1
- package/dist/src/transaction/index.d.ts +5 -1
- package/dist/src/transaction/kriya_v2.d.ts +1 -1
- package/dist/src/transaction/kriya_v3.d.ts +1 -1
- package/dist/src/transaction/scallop.d.ts +1 -1
- package/dist/src/transaction/suilend.d.ts +1 -2
- package/dist/src/transaction/turbos.d.ts +1 -1
- package/dist/src/transaction/volo.d.ts +1 -1
- package/example/package.json +17 -0
- package/example/swap.ts +21 -0
- package/example/tsconfig.json +12 -0
- package/package.json +1 -1
- package/src/api.ts +7 -3
- package/src/client.ts +132 -42
- package/src/transaction/afsui.ts +6 -3
- package/src/transaction/aftermath.ts +6 -3
- package/src/transaction/alphafi.ts +50 -0
- package/src/transaction/bluefin.ts +6 -3
- package/src/transaction/bluemove.ts +5 -4
- package/src/transaction/cetus.ts +13 -7
- package/src/transaction/deepbook_v2.ts +5 -4
- package/src/transaction/deepbook_v3.ts +5 -3
- package/src/transaction/flowx_v2.ts +5 -4
- package/src/transaction/flowx_v3.ts +5 -3
- package/src/transaction/haedal.ts +5 -3
- package/src/transaction/haedal_pmm.ts +5 -3
- package/src/transaction/index.ts +20 -1
- package/src/transaction/kriya_v2.ts +5 -4
- package/src/transaction/kriya_v3.ts +5 -4
- package/src/transaction/scallop.ts +5 -4
- package/src/transaction/suilend.ts +6 -10
- package/src/transaction/swap.ts +1 -0
- package/src/transaction/turbos.ts +5 -4
- package/src/transaction/volo.ts +5 -3
- package/src/utils/coin.ts +15 -7
- package/tests/router.test.ts +12 -19
package/dist/index.d.mts
CHANGED
|
@@ -77,6 +77,8 @@ declare const SCALLOP = "SCALLOP";
|
|
|
77
77
|
declare const SUILEND = "SUILEND";
|
|
78
78
|
declare const BLUEFIN = "BLUEFIN";
|
|
79
79
|
declare const HAEDALPMM = "HAEDALPMM";
|
|
80
|
+
declare const ALPHAFI = "ALPHAFI";
|
|
81
|
+
declare const SPRINGSUI = "SPRINGSUI";
|
|
80
82
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
81
83
|
type BuildRouterSwapParams = {
|
|
82
84
|
routers: Router[];
|
|
@@ -93,7 +95,22 @@ type BuildFastRouterSwapParams = {
|
|
|
93
95
|
slippage: number;
|
|
94
96
|
txb: Transaction;
|
|
95
97
|
partner?: string;
|
|
96
|
-
|
|
98
|
+
refreshAllCoins?: boolean;
|
|
99
|
+
payDeepFeeAmount?: number;
|
|
100
|
+
};
|
|
101
|
+
type BuildRouterSwapParamsV2 = {
|
|
102
|
+
routers: RouterData;
|
|
103
|
+
inputCoin: TransactionObjectArgument;
|
|
104
|
+
slippage: number;
|
|
105
|
+
txb: Transaction;
|
|
106
|
+
partner?: string;
|
|
107
|
+
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
108
|
+
};
|
|
109
|
+
type BuildFastRouterSwapParamsV2 = {
|
|
110
|
+
routers: RouterData;
|
|
111
|
+
slippage: number;
|
|
112
|
+
txb: Transaction;
|
|
113
|
+
partner?: string;
|
|
97
114
|
refreshAllCoins?: boolean;
|
|
98
115
|
payDeepFeeAmount?: number;
|
|
99
116
|
};
|
|
@@ -117,27 +134,31 @@ declare class AggregatorClient {
|
|
|
117
134
|
constructor(endpoint?: string, signer?: string, client?: SuiClient, env?: Env);
|
|
118
135
|
getCoins(coinType: string, refresh?: boolean): Promise<CoinAsset[]>;
|
|
119
136
|
findRouters(params: FindRouterParams): Promise<RouterData | null>;
|
|
120
|
-
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
121
|
-
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
|
|
137
|
+
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
138
|
+
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
122
139
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
123
|
-
routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
|
|
124
|
-
fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
|
|
125
|
-
publishedAt(): string;
|
|
140
|
+
routerSwap(params: BuildRouterSwapParams | BuildRouterSwapParamsV2): Promise<TransactionObjectArgument>;
|
|
141
|
+
fastRouterSwap(params: BuildFastRouterSwapParams | BuildFastRouterSwapParamsV2): Promise<void>;
|
|
126
142
|
publishedAtV2(): string;
|
|
143
|
+
publishedAtV2Extend(): string;
|
|
127
144
|
deepbookv3DeepFeeType(): string;
|
|
128
|
-
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
129
|
-
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
|
|
145
|
+
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string, aggregatorV2PublishedAt: string): void;
|
|
146
|
+
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN, aggregatorV2PublishedAt: string): TransactionObjectArgument;
|
|
130
147
|
newDex(provider: string, partner?: string): Dex;
|
|
131
148
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
132
149
|
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
133
150
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
134
151
|
getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
|
|
135
152
|
}
|
|
136
|
-
declare function parseRouterResponse(data: any): RouterData;
|
|
153
|
+
declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData;
|
|
137
154
|
|
|
138
155
|
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
156
|
+
declare const AGGREGATOR_V2 = "aggregator_v2";
|
|
157
|
+
declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
158
|
+
declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
159
|
+
declare function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
139
160
|
interface Dex {
|
|
140
|
-
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
161
|
+
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
141
162
|
}
|
|
142
163
|
|
|
143
164
|
declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
|
|
@@ -235,8 +256,10 @@ type RouterError = {
|
|
|
235
256
|
type RouterData = {
|
|
236
257
|
amountIn: BN;
|
|
237
258
|
amountOut: BN;
|
|
259
|
+
byAmountIn: boolean;
|
|
238
260
|
routes: Router[];
|
|
239
261
|
insufficientLiquidity: boolean;
|
|
262
|
+
packages?: Map<string, string>;
|
|
240
263
|
totalDeepFee?: number;
|
|
241
264
|
error?: RouterError;
|
|
242
265
|
};
|
|
@@ -270,4 +293,4 @@ declare enum Env {
|
|
|
270
293
|
Testnet = 1
|
|
271
294
|
}
|
|
272
295
|
|
|
273
|
-
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SUILEND, 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 };
|
|
296
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, SUILEND, 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, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -77,6 +77,8 @@ declare const SCALLOP = "SCALLOP";
|
|
|
77
77
|
declare const SUILEND = "SUILEND";
|
|
78
78
|
declare const BLUEFIN = "BLUEFIN";
|
|
79
79
|
declare const HAEDALPMM = "HAEDALPMM";
|
|
80
|
+
declare const ALPHAFI = "ALPHAFI";
|
|
81
|
+
declare const SPRINGSUI = "SPRINGSUI";
|
|
80
82
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
81
83
|
type BuildRouterSwapParams = {
|
|
82
84
|
routers: Router[];
|
|
@@ -93,7 +95,22 @@ type BuildFastRouterSwapParams = {
|
|
|
93
95
|
slippage: number;
|
|
94
96
|
txb: Transaction;
|
|
95
97
|
partner?: string;
|
|
96
|
-
|
|
98
|
+
refreshAllCoins?: boolean;
|
|
99
|
+
payDeepFeeAmount?: number;
|
|
100
|
+
};
|
|
101
|
+
type BuildRouterSwapParamsV2 = {
|
|
102
|
+
routers: RouterData;
|
|
103
|
+
inputCoin: TransactionObjectArgument;
|
|
104
|
+
slippage: number;
|
|
105
|
+
txb: Transaction;
|
|
106
|
+
partner?: string;
|
|
107
|
+
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
108
|
+
};
|
|
109
|
+
type BuildFastRouterSwapParamsV2 = {
|
|
110
|
+
routers: RouterData;
|
|
111
|
+
slippage: number;
|
|
112
|
+
txb: Transaction;
|
|
113
|
+
partner?: string;
|
|
97
114
|
refreshAllCoins?: boolean;
|
|
98
115
|
payDeepFeeAmount?: number;
|
|
99
116
|
};
|
|
@@ -117,27 +134,31 @@ declare class AggregatorClient {
|
|
|
117
134
|
constructor(endpoint?: string, signer?: string, client?: SuiClient, env?: Env);
|
|
118
135
|
getCoins(coinType: string, refresh?: boolean): Promise<CoinAsset[]>;
|
|
119
136
|
findRouters(params: FindRouterParams): Promise<RouterData | null>;
|
|
120
|
-
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
121
|
-
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
|
|
137
|
+
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
138
|
+
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
122
139
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
123
|
-
routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
|
|
124
|
-
fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
|
|
125
|
-
publishedAt(): string;
|
|
140
|
+
routerSwap(params: BuildRouterSwapParams | BuildRouterSwapParamsV2): Promise<TransactionObjectArgument>;
|
|
141
|
+
fastRouterSwap(params: BuildFastRouterSwapParams | BuildFastRouterSwapParamsV2): Promise<void>;
|
|
126
142
|
publishedAtV2(): string;
|
|
143
|
+
publishedAtV2Extend(): string;
|
|
127
144
|
deepbookv3DeepFeeType(): string;
|
|
128
|
-
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
129
|
-
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
|
|
145
|
+
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string, aggregatorV2PublishedAt: string): void;
|
|
146
|
+
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN, aggregatorV2PublishedAt: string): TransactionObjectArgument;
|
|
130
147
|
newDex(provider: string, partner?: string): Dex;
|
|
131
148
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
132
149
|
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
133
150
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
134
151
|
getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
|
|
135
152
|
}
|
|
136
|
-
declare function parseRouterResponse(data: any): RouterData;
|
|
153
|
+
declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData;
|
|
137
154
|
|
|
138
155
|
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
156
|
+
declare const AGGREGATOR_V2 = "aggregator_v2";
|
|
157
|
+
declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
158
|
+
declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
159
|
+
declare function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
139
160
|
interface Dex {
|
|
140
|
-
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
161
|
+
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
141
162
|
}
|
|
142
163
|
|
|
143
164
|
declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
|
|
@@ -235,8 +256,10 @@ type RouterError = {
|
|
|
235
256
|
type RouterData = {
|
|
236
257
|
amountIn: BN;
|
|
237
258
|
amountOut: BN;
|
|
259
|
+
byAmountIn: boolean;
|
|
238
260
|
routes: Router[];
|
|
239
261
|
insufficientLiquidity: boolean;
|
|
262
|
+
packages?: Map<string, string>;
|
|
240
263
|
totalDeepFee?: number;
|
|
241
264
|
error?: RouterError;
|
|
242
265
|
};
|
|
@@ -270,4 +293,4 @@ declare enum Env {
|
|
|
270
293
|
Testnet = 1
|
|
271
294
|
}
|
|
272
295
|
|
|
273
|
-
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SUILEND, 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 };
|
|
296
|
+
export { AFSUI, AFTERMATH, AGGREGATOR_V2, AGGREGATOR_V2_EXTEND, ALPHAFI, AggregatorClient, type AggregatorResponse, BLUEFIN, BLUEMOVE, type BuildCoinResult, type BuildFastRouterSwapParams, type BuildFastRouterSwapParamsV2, type BuildRouterSwapParams, type BuildRouterSwapParamsV2, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, DEEPBOOKV3, DEFAULT_ENDPOINT, type DeepbookV3Config, type DeepbookV3ConfigResponse, type Dex, Env, type ExtendedDetails, FLOWXV2, FLOWXV3, type FindRouterParams, HAEDAL, HAEDALPMM, KRIYA, KRIYAV3, ONE, type Path, type PreSwapLpChangeParams, type Router, type RouterData, type RouterError, SCALLOP, SPRINGSUI, SUILEND, 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, getAggregatorV2ExtendPublishedAt, getAggregatorV2PublishedAt, getDeepbookV3Config, getRouterResult, isSortedSymbols, mintZeroCoin, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId, printTransaction, processEndpoint, restituteMsafeFastRouterSwapParams };
|