@cetusprotocol/aggregator-sdk 0.3.16 → 0.3.18
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/README.md +1 -1
- package/dist/index.d.mts +33 -11
- package/dist/index.d.ts +33 -11
- package/dist/index.js +209 -89
- package/dist/index.mjs +204 -89
- package/dist/src/api.d.ts +2 -0
- package/dist/src/client.d.ts +25 -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/package.json +1 -1
- package/src/api.ts +7 -3
- package/src/client.ts +129 -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 +20 -8
- package/tests/router.test.ts +15 -22
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -77,6 +77,7 @@ 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";
|
|
80
81
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
81
82
|
type BuildRouterSwapParams = {
|
|
82
83
|
routers: Router[];
|
|
@@ -93,7 +94,22 @@ type BuildFastRouterSwapParams = {
|
|
|
93
94
|
slippage: number;
|
|
94
95
|
txb: Transaction;
|
|
95
96
|
partner?: string;
|
|
96
|
-
|
|
97
|
+
refreshAllCoins?: boolean;
|
|
98
|
+
payDeepFeeAmount?: number;
|
|
99
|
+
};
|
|
100
|
+
type BuildRouterSwapParamsV2 = {
|
|
101
|
+
routers: RouterData;
|
|
102
|
+
inputCoin: TransactionObjectArgument;
|
|
103
|
+
slippage: number;
|
|
104
|
+
txb: Transaction;
|
|
105
|
+
partner?: string;
|
|
106
|
+
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
107
|
+
};
|
|
108
|
+
type BuildFastRouterSwapParamsV2 = {
|
|
109
|
+
routers: RouterData;
|
|
110
|
+
slippage: number;
|
|
111
|
+
txb: Transaction;
|
|
112
|
+
partner?: string;
|
|
97
113
|
refreshAllCoins?: boolean;
|
|
98
114
|
payDeepFeeAmount?: number;
|
|
99
115
|
};
|
|
@@ -117,27 +133,31 @@ declare class AggregatorClient {
|
|
|
117
133
|
constructor(endpoint?: string, signer?: string, client?: SuiClient, env?: Env);
|
|
118
134
|
getCoins(coinType: string, refresh?: boolean): Promise<CoinAsset[]>;
|
|
119
135
|
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>;
|
|
136
|
+
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
137
|
+
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
122
138
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
123
|
-
routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
|
|
124
|
-
fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
|
|
125
|
-
publishedAt(): string;
|
|
139
|
+
routerSwap(params: BuildRouterSwapParams | BuildRouterSwapParamsV2): Promise<TransactionObjectArgument>;
|
|
140
|
+
fastRouterSwap(params: BuildFastRouterSwapParams | BuildFastRouterSwapParamsV2): Promise<void>;
|
|
126
141
|
publishedAtV2(): string;
|
|
142
|
+
publishedAtV2Extend(): string;
|
|
127
143
|
deepbookv3DeepFeeType(): string;
|
|
128
|
-
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
129
|
-
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
|
|
144
|
+
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string, aggregatorV2PublishedAt: string): void;
|
|
145
|
+
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN, aggregatorV2PublishedAt: string): TransactionObjectArgument;
|
|
130
146
|
newDex(provider: string, partner?: string): Dex;
|
|
131
147
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
132
148
|
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
133
149
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
134
150
|
getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
|
|
135
151
|
}
|
|
136
|
-
declare function parseRouterResponse(data: any): RouterData;
|
|
152
|
+
declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData;
|
|
137
153
|
|
|
138
154
|
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
155
|
+
declare const AGGREGATOR_V2 = "aggregator_v2";
|
|
156
|
+
declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
157
|
+
declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
158
|
+
declare function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
139
159
|
interface Dex {
|
|
140
|
-
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
160
|
+
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
141
161
|
}
|
|
142
162
|
|
|
143
163
|
declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
|
|
@@ -235,8 +255,10 @@ type RouterError = {
|
|
|
235
255
|
type RouterData = {
|
|
236
256
|
amountIn: BN;
|
|
237
257
|
amountOut: BN;
|
|
258
|
+
byAmountIn: boolean;
|
|
238
259
|
routes: Router[];
|
|
239
260
|
insufficientLiquidity: boolean;
|
|
261
|
+
packages?: Map<string, string>;
|
|
240
262
|
totalDeepFee?: number;
|
|
241
263
|
error?: RouterError;
|
|
242
264
|
};
|
|
@@ -270,4 +292,4 @@ declare enum Env {
|
|
|
270
292
|
Testnet = 1
|
|
271
293
|
}
|
|
272
294
|
|
|
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 };
|
|
295
|
+
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, 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,7 @@ 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";
|
|
80
81
|
declare const DEFAULT_ENDPOINT = "https://api-sui.cetus.zone/router_v2";
|
|
81
82
|
type BuildRouterSwapParams = {
|
|
82
83
|
routers: Router[];
|
|
@@ -93,7 +94,22 @@ type BuildFastRouterSwapParams = {
|
|
|
93
94
|
slippage: number;
|
|
94
95
|
txb: Transaction;
|
|
95
96
|
partner?: string;
|
|
96
|
-
|
|
97
|
+
refreshAllCoins?: boolean;
|
|
98
|
+
payDeepFeeAmount?: number;
|
|
99
|
+
};
|
|
100
|
+
type BuildRouterSwapParamsV2 = {
|
|
101
|
+
routers: RouterData;
|
|
102
|
+
inputCoin: TransactionObjectArgument;
|
|
103
|
+
slippage: number;
|
|
104
|
+
txb: Transaction;
|
|
105
|
+
partner?: string;
|
|
106
|
+
deepbookv3DeepFee?: TransactionObjectArgument;
|
|
107
|
+
};
|
|
108
|
+
type BuildFastRouterSwapParamsV2 = {
|
|
109
|
+
routers: RouterData;
|
|
110
|
+
slippage: number;
|
|
111
|
+
txb: Transaction;
|
|
112
|
+
partner?: string;
|
|
97
113
|
refreshAllCoins?: boolean;
|
|
98
114
|
payDeepFeeAmount?: number;
|
|
99
115
|
};
|
|
@@ -117,27 +133,31 @@ declare class AggregatorClient {
|
|
|
117
133
|
constructor(endpoint?: string, signer?: string, client?: SuiClient, env?: Env);
|
|
118
134
|
getCoins(coinType: string, refresh?: boolean): Promise<CoinAsset[]>;
|
|
119
135
|
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>;
|
|
136
|
+
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string, deepbookv3DeepFee?: TransactionObjectArgument, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
137
|
+
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string, packages?: Map<string, string>): Promise<TransactionObjectArgument>;
|
|
122
138
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
123
|
-
routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
|
|
124
|
-
fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
|
|
125
|
-
publishedAt(): string;
|
|
139
|
+
routerSwap(params: BuildRouterSwapParams | BuildRouterSwapParamsV2): Promise<TransactionObjectArgument>;
|
|
140
|
+
fastRouterSwap(params: BuildFastRouterSwapParams | BuildFastRouterSwapParamsV2): Promise<void>;
|
|
126
141
|
publishedAtV2(): string;
|
|
142
|
+
publishedAtV2Extend(): string;
|
|
127
143
|
deepbookv3DeepFeeType(): string;
|
|
128
|
-
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
129
|
-
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
|
|
144
|
+
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string, aggregatorV2PublishedAt: string): void;
|
|
145
|
+
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN, aggregatorV2PublishedAt: string): TransactionObjectArgument;
|
|
130
146
|
newDex(provider: string, partner?: string): Dex;
|
|
131
147
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
132
148
|
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
133
149
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
134
150
|
getDeepbookV3Config(): Promise<DeepbookV3Config | null>;
|
|
135
151
|
}
|
|
136
|
-
declare function parseRouterResponse(data: any): RouterData;
|
|
152
|
+
declare function parseRouterResponse(data: any, byAmountIn: boolean): RouterData;
|
|
137
153
|
|
|
138
154
|
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
155
|
+
declare const AGGREGATOR_V2 = "aggregator_v2";
|
|
156
|
+
declare const AGGREGATOR_V2_EXTEND = "aggregator_v2_extend";
|
|
157
|
+
declare function getAggregatorV2PublishedAt(aggregatorV2PublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
158
|
+
declare function getAggregatorV2ExtendPublishedAt(aggregatorV2ExtendPublishedAt: string, packages?: Map<string, string> | Record<string, string>): string;
|
|
139
159
|
interface Dex {
|
|
140
|
-
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
160
|
+
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument, packages?: Map<string, string>, deepbookv3DeepFee?: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
141
161
|
}
|
|
142
162
|
|
|
143
163
|
declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
|
|
@@ -235,8 +255,10 @@ type RouterError = {
|
|
|
235
255
|
type RouterData = {
|
|
236
256
|
amountIn: BN;
|
|
237
257
|
amountOut: BN;
|
|
258
|
+
byAmountIn: boolean;
|
|
238
259
|
routes: Router[];
|
|
239
260
|
insufficientLiquidity: boolean;
|
|
261
|
+
packages?: Map<string, string>;
|
|
240
262
|
totalDeepFee?: number;
|
|
241
263
|
error?: RouterError;
|
|
242
264
|
};
|
|
@@ -270,4 +292,4 @@ declare enum Env {
|
|
|
270
292
|
Testnet = 1
|
|
271
293
|
}
|
|
272
294
|
|
|
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 };
|
|
295
|
+
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, 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 };
|