@cetusprotocol/aggregator-sdk 0.0.8 → 0.1.1
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 +98 -161
- package/dist/index.d.ts +98 -161
- package/dist/index.js +1128 -1550
- package/dist/index.mjs +1116 -1488
- package/dist/src/api.d.ts +53 -0
- package/dist/src/client.d.ts +38 -65
- package/dist/src/const.d.ts +0 -68
- package/dist/src/index.d.ts +9 -5
- package/dist/src/transaction/afsui.d.ts +10 -0
- package/dist/src/transaction/aftermath.d.ts +13 -24
- package/dist/src/transaction/cetus.d.ts +9 -33
- package/dist/src/transaction/deepbook_v2.d.ts +14 -0
- package/dist/src/transaction/flowx_v2.d.ts +7 -0
- package/dist/src/transaction/haedal.d.ts +6 -0
- package/dist/src/transaction/index.d.ts +6 -1
- package/dist/src/transaction/kriya_v2.d.ts +6 -0
- package/dist/src/transaction/kriya_v3.d.ts +7 -0
- package/dist/src/transaction/swap.d.ts +1 -2
- package/dist/src/transaction/turbos.d.ts +7 -22
- package/dist/src/transaction/volo.d.ts +8 -0
- package/dist/src/utils/coin.d.ts +9 -0
- package/dist/{src → tests}/test_data.test.d.ts +1 -0
- package/package.json +2 -2
- package/src/api.ts +144 -0
- package/src/client.ts +295 -239
- package/src/const.ts +0 -113
- package/src/index.ts +10 -5
- package/src/transaction/afsui.ts +60 -0
- package/src/transaction/aftermath.ts +71 -124
- package/src/transaction/cetus.ts +87 -258
- package/src/transaction/deepbook_v2.ts +122 -0
- package/src/transaction/flowx_v2.ts +42 -0
- package/src/transaction/haedal.ts +41 -0
- package/src/transaction/index.ts +17 -1
- package/src/transaction/kriya_v2.ts +38 -0
- package/src/transaction/kriya_v3.ts +46 -0
- package/src/transaction/swap.ts +17 -24
- package/src/transaction/turbos.ts +40 -99
- package/src/transaction/volo.ts +52 -0
- package/src/utils/coin.ts +91 -6
- package/src/utils/transaction.ts +1 -1
- package/tests/router.test.ts +123 -73
- package/{src → tests}/test_data.test.ts +2 -0
- package/dist/src/config.d.ts +0 -26
- package/dist/src/transaction/common.d.ts +0 -12
- package/dist/src/transaction/deepbook.d.ts +0 -21
- package/dist/src/transaction/flowx.d.ts +0 -20
- package/dist/src/transaction/kriya.d.ts +0 -21
- package/dist/src/transaction/router.d.ts +0 -6
- package/dist/src/utils/account_cap.d.ts +0 -7
- package/src/config.ts +0 -65
- package/src/transaction/common.ts +0 -169
- package/src/transaction/deepbook.ts +0 -126
- package/src/transaction/flowx.ts +0 -97
- package/src/transaction/kriya.ts +0 -77
- package/src/transaction/router.ts +0 -339
- package/src/utils/account_cap.ts +0 -62
package/dist/index.d.mts
CHANGED
|
@@ -1,36 +1,9 @@
|
|
|
1
1
|
import * as _mysten_sui_client from '@mysten/sui/client';
|
|
2
2
|
import { SuiClient } from '@mysten/sui/client';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { Signer } from '@mysten/sui/dist/cjs/cryptography';
|
|
3
|
+
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
4
|
+
import { Signer } from '@mysten/sui/cryptography';
|
|
6
5
|
import BN from 'bn.js';
|
|
7
|
-
|
|
8
|
-
type Package = {
|
|
9
|
-
packageName: string;
|
|
10
|
-
packageId: string;
|
|
11
|
-
publishedAt: string;
|
|
12
|
-
};
|
|
13
|
-
declare enum ENV {
|
|
14
|
-
MAINNET = 0,
|
|
15
|
-
TESTNET = 1
|
|
16
|
-
}
|
|
17
|
-
declare class AggregatorConfig {
|
|
18
|
-
private aggregatorUrl;
|
|
19
|
-
private fullNodeUrl;
|
|
20
|
-
private wallet;
|
|
21
|
-
private packages;
|
|
22
|
-
private env;
|
|
23
|
-
constructor(aggregatorUrl: string, fullNodeUrl: string, wallet: string, packages: Package[], env: ENV);
|
|
24
|
-
getAggregatorUrl(): string;
|
|
25
|
-
getFullNodeUrl(): string;
|
|
26
|
-
getWallet(): string;
|
|
27
|
-
getENV(): ENV;
|
|
28
|
-
getPackages(): Package[];
|
|
29
|
-
getPackage(packageName: string): Package | undefined;
|
|
30
|
-
addPackage(newPackage: Package): void;
|
|
31
|
-
removePackageById(packageId: string): void;
|
|
32
|
-
findPackageById(packageId: string): Package | undefined;
|
|
33
|
-
}
|
|
6
|
+
import Decimal from 'decimal.js';
|
|
34
7
|
|
|
35
8
|
/**
|
|
36
9
|
* Represents a SUI address, which is a string.
|
|
@@ -87,68 +60,33 @@ type CoinAsset = {
|
|
|
87
60
|
balance: bigint;
|
|
88
61
|
};
|
|
89
62
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
target: string;
|
|
101
|
-
feeRate: number;
|
|
102
|
-
amountIn: number;
|
|
103
|
-
amountOut: number;
|
|
104
|
-
extendedDetails?: ExtendedDetails;
|
|
105
|
-
version?: string;
|
|
106
|
-
};
|
|
107
|
-
type Router = {
|
|
108
|
-
path: Path[];
|
|
109
|
-
amountIn: BN;
|
|
110
|
-
amountOut: BN;
|
|
111
|
-
initialPrice: Decimal;
|
|
112
|
-
};
|
|
113
|
-
type RouterError = {
|
|
114
|
-
code: number;
|
|
115
|
-
msg: string;
|
|
116
|
-
};
|
|
117
|
-
type RouterData = {
|
|
118
|
-
amountIn: BN;
|
|
119
|
-
amountOut: BN;
|
|
120
|
-
routes: Router[];
|
|
121
|
-
insufficientLiquidity: boolean;
|
|
122
|
-
error?: RouterError;
|
|
123
|
-
};
|
|
124
|
-
type AggregatorResponse = {
|
|
125
|
-
code: number;
|
|
126
|
-
msg: string;
|
|
127
|
-
data: RouterData;
|
|
128
|
-
};
|
|
63
|
+
declare const CETUS = "CETUS";
|
|
64
|
+
declare const DEEPBOOKV2 = "DEEPBOOK";
|
|
65
|
+
declare const KRIYA = "KRIYA";
|
|
66
|
+
declare const FLOWXV2 = "FLOWX";
|
|
67
|
+
declare const KRIYAV3 = "KRIYAV3";
|
|
68
|
+
declare const TURBOS = "TURBOS";
|
|
69
|
+
declare const AFTERMATH = "AFTERMATH";
|
|
70
|
+
declare const HAEDAL = "HAEDAL";
|
|
71
|
+
declare const VOLO = "VOLO";
|
|
72
|
+
declare const AFSUI = "AFSUI";
|
|
129
73
|
type BuildRouterSwapParams = {
|
|
130
74
|
routers: Router[];
|
|
131
|
-
|
|
132
|
-
|
|
75
|
+
byAmountIn: boolean;
|
|
76
|
+
inputCoin: TransactionObjectArgument;
|
|
77
|
+
slippage: number;
|
|
78
|
+
txb: Transaction;
|
|
79
|
+
partner?: string;
|
|
80
|
+
};
|
|
81
|
+
type BuildFastRouterSwapParams = {
|
|
82
|
+
routers: Router[];
|
|
133
83
|
byAmountIn: boolean;
|
|
134
84
|
slippage: number;
|
|
135
|
-
|
|
136
|
-
targetCoinType: string;
|
|
85
|
+
txb: Transaction;
|
|
137
86
|
partner?: string;
|
|
138
87
|
isMergeTragetCoin?: boolean;
|
|
139
88
|
refreshAllCoins?: boolean;
|
|
140
89
|
};
|
|
141
|
-
interface FindRouterParams {
|
|
142
|
-
from: string;
|
|
143
|
-
target: string;
|
|
144
|
-
amount: BN;
|
|
145
|
-
byAmountIn: boolean;
|
|
146
|
-
depth: number | null;
|
|
147
|
-
splitAlgorithm: string | null;
|
|
148
|
-
splitFactor: number | null;
|
|
149
|
-
splitCount: number | null;
|
|
150
|
-
providers: string[] | null;
|
|
151
|
-
}
|
|
152
90
|
interface SwapInPoolsParams {
|
|
153
91
|
from: string;
|
|
154
92
|
target: string;
|
|
@@ -161,23 +99,33 @@ interface SwapInPoolsResult {
|
|
|
161
99
|
routeData?: RouterData;
|
|
162
100
|
}
|
|
163
101
|
declare class AggregatorClient {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
102
|
+
endpoint: string;
|
|
103
|
+
signer: string;
|
|
104
|
+
client: SuiClient;
|
|
105
|
+
env: Env;
|
|
167
106
|
private allCoins;
|
|
168
|
-
constructor(
|
|
107
|
+
constructor(endpoint: string, signer: string, client: SuiClient, env: Env);
|
|
169
108
|
getAllCoins(): Promise<CoinAsset[]>;
|
|
170
|
-
|
|
109
|
+
findRouters(params: FindRouterParams): Promise<RouterData | null>;
|
|
110
|
+
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string): Promise<TransactionObjectArgument>;
|
|
111
|
+
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
|
|
171
112
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
172
|
-
routerSwap(params: BuildRouterSwapParams): Promise<
|
|
113
|
+
routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
|
|
114
|
+
fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
|
|
115
|
+
publishedAt(): string;
|
|
116
|
+
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
117
|
+
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
|
|
118
|
+
newDex(provider: string, partner?: string): Dex;
|
|
173
119
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
174
120
|
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
175
121
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
176
122
|
}
|
|
177
123
|
declare function parseRouterResponse(data: any): RouterData;
|
|
178
124
|
|
|
179
|
-
declare
|
|
180
|
-
|
|
125
|
+
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
126
|
+
interface Dex {
|
|
127
|
+
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
128
|
+
}
|
|
181
129
|
|
|
182
130
|
declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
|
|
183
131
|
declare function composeType(address: string, generics: SuiAddress[]): SuiAddress;
|
|
@@ -195,61 +143,6 @@ declare function fixSuiObjectId(value: string): string;
|
|
|
195
143
|
declare function patchFixSuiObjectId(data: any): void;
|
|
196
144
|
declare function createTarget(packageName: string, moduleName: string, functionName: string): `${string}::${string}::${string}`;
|
|
197
145
|
|
|
198
|
-
/**
|
|
199
|
-
* The address representing the clock in the system.
|
|
200
|
-
*/
|
|
201
|
-
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
202
|
-
/**
|
|
203
|
-
* The address for CoinInfo module.
|
|
204
|
-
*/
|
|
205
|
-
declare const CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
206
|
-
/**
|
|
207
|
-
* The address for CoinStore module.
|
|
208
|
-
*/
|
|
209
|
-
declare const CoinStoreAddress = "0x1::coin::CoinStore";
|
|
210
|
-
declare const SuiZeroCoinFn = "0x2::coin::zero";
|
|
211
|
-
declare const AGGREGATOR = "aggregator";
|
|
212
|
-
declare const CETUS_DEX = "CETUS";
|
|
213
|
-
declare const DEEPBOOK_DEX = "DEEPBOOK";
|
|
214
|
-
declare const KRIYA_DEX = "KRIYA";
|
|
215
|
-
declare const FLOWX_AMM = "FLOWX";
|
|
216
|
-
declare const TURBOS_DEX = "TURBOS";
|
|
217
|
-
declare const AFTERMATH_AMM = "AFTERMATH";
|
|
218
|
-
declare const INTEGRATE = "integrate";
|
|
219
|
-
declare const CETUS_MODULE = "cetus";
|
|
220
|
-
declare const DEEPBOOK_MODULE = "deepbook";
|
|
221
|
-
declare const KRIYA_MODULE = "kriya";
|
|
222
|
-
declare const UTILS_MODULE = "utils";
|
|
223
|
-
declare const POOL_MODULT = "pool";
|
|
224
|
-
declare const PAY_MODULE = "pay";
|
|
225
|
-
declare const FLOWX_AMM_MODULE = "flowx_amm";
|
|
226
|
-
declare const TURBOS_MODULE = "turbos";
|
|
227
|
-
declare const AFTERMATH_MODULE = "aftermath";
|
|
228
|
-
declare const DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2";
|
|
229
|
-
declare const DEEPBOOK_CLOB_V2_MODULE = "clob_v2";
|
|
230
|
-
declare const FlashSwapFunc = "flash_swap";
|
|
231
|
-
declare const FlashSwapWithPartnerFunc = "flash_swap_with_partner";
|
|
232
|
-
declare const RepayFalshSwapFunc = "repay_flash_swap";
|
|
233
|
-
declare const RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner";
|
|
234
|
-
declare const FlashSwapA2BFunc = "flash_swap_a2b";
|
|
235
|
-
declare const FlashSwapB2AFunc = "flash_swap_b2a";
|
|
236
|
-
declare const FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b";
|
|
237
|
-
declare const FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a";
|
|
238
|
-
declare const REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b";
|
|
239
|
-
declare const REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a";
|
|
240
|
-
declare const REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC = "repay_flash_swap_with_partner_a2b";
|
|
241
|
-
declare const REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC = "repay_flash_swap_with_partner_b2a";
|
|
242
|
-
declare const SWAP_A2B_FUNC = "swap_a2b";
|
|
243
|
-
declare const SWAP_B2A_FUNC = "swap_b2a";
|
|
244
|
-
declare const TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin";
|
|
245
|
-
declare const CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold";
|
|
246
|
-
declare const JOIN_FUNC = "join_vec";
|
|
247
|
-
declare const TRANSFER_ACCOUNT_CAP = "transfer_account_cap";
|
|
248
|
-
declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
249
|
-
declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
250
|
-
declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
251
|
-
declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
252
|
-
declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
253
146
|
declare const ZERO: BN;
|
|
254
147
|
declare const ONE: BN;
|
|
255
148
|
declare const TWO: BN;
|
|
@@ -257,18 +150,62 @@ declare const U128: BN;
|
|
|
257
150
|
declare const U64_MAX_BN: BN;
|
|
258
151
|
declare const U64_MAX = "18446744073709551615";
|
|
259
152
|
declare const TEN_POW_NINE = 1000000000;
|
|
260
|
-
declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
261
|
-
declare const TESTNET_FLOWX_AMM_CONTAINER_ID = "";
|
|
262
|
-
declare const TURBOS_VERSIONED = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
|
|
263
|
-
declare const MAINNET_AFTERMATH_REGISTRY_ID = "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae";
|
|
264
|
-
declare const TESTNET_AFTERMATH_REGISTRY_ID = "";
|
|
265
|
-
declare const MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4";
|
|
266
|
-
declare const TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "";
|
|
267
|
-
declare const MAINNET_AFTERMATH_TREASURY_ID = "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce";
|
|
268
|
-
declare const TESTNET_AFTERMATH_TREASURY_ID = "";
|
|
269
|
-
declare const MAINNET_AFTERMATH_INSURANCE_FUND_ID = "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b";
|
|
270
|
-
declare const TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
|
|
271
|
-
declare const MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
|
|
272
|
-
declare const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
|
|
273
153
|
|
|
274
|
-
|
|
154
|
+
interface FindRouterParams {
|
|
155
|
+
from: string;
|
|
156
|
+
target: string;
|
|
157
|
+
amount: BN;
|
|
158
|
+
byAmountIn: boolean;
|
|
159
|
+
depth?: number;
|
|
160
|
+
splitAlgorithm?: string;
|
|
161
|
+
splitFactor?: number;
|
|
162
|
+
splitCount?: number;
|
|
163
|
+
providers?: string[];
|
|
164
|
+
}
|
|
165
|
+
type ExtendedDetails = {
|
|
166
|
+
aftermathPoolFlatness?: number;
|
|
167
|
+
aftermathLpSupplyType?: string;
|
|
168
|
+
turbosFeeType?: string;
|
|
169
|
+
};
|
|
170
|
+
type Path = {
|
|
171
|
+
id: string;
|
|
172
|
+
direction: boolean;
|
|
173
|
+
provider: string;
|
|
174
|
+
from: string;
|
|
175
|
+
target: string;
|
|
176
|
+
feeRate: number;
|
|
177
|
+
amountIn: number;
|
|
178
|
+
amountOut: number;
|
|
179
|
+
extendedDetails?: ExtendedDetails;
|
|
180
|
+
version?: string;
|
|
181
|
+
};
|
|
182
|
+
type Router = {
|
|
183
|
+
path: Path[];
|
|
184
|
+
amountIn: BN;
|
|
185
|
+
amountOut: BN;
|
|
186
|
+
initialPrice: Decimal;
|
|
187
|
+
};
|
|
188
|
+
type RouterError = {
|
|
189
|
+
code: number;
|
|
190
|
+
msg: string;
|
|
191
|
+
};
|
|
192
|
+
type RouterData = {
|
|
193
|
+
amountIn: BN;
|
|
194
|
+
amountOut: BN;
|
|
195
|
+
routes: Router[];
|
|
196
|
+
insufficientLiquidity: boolean;
|
|
197
|
+
error?: RouterError;
|
|
198
|
+
};
|
|
199
|
+
type AggregatorResponse = {
|
|
200
|
+
code: number;
|
|
201
|
+
msg: string;
|
|
202
|
+
data: RouterData;
|
|
203
|
+
};
|
|
204
|
+
declare function getRouterResult(endpoint: string, params: FindRouterParams): Promise<RouterData | null>;
|
|
205
|
+
|
|
206
|
+
declare enum Env {
|
|
207
|
+
Mainnet = 0,
|
|
208
|
+
Testnet = 1
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, 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, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,9 @@
|
|
|
1
1
|
import * as _mysten_sui_client from '@mysten/sui/client';
|
|
2
2
|
import { SuiClient } from '@mysten/sui/client';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { Signer } from '@mysten/sui/dist/cjs/cryptography';
|
|
3
|
+
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
4
|
+
import { Signer } from '@mysten/sui/cryptography';
|
|
6
5
|
import BN from 'bn.js';
|
|
7
|
-
|
|
8
|
-
type Package = {
|
|
9
|
-
packageName: string;
|
|
10
|
-
packageId: string;
|
|
11
|
-
publishedAt: string;
|
|
12
|
-
};
|
|
13
|
-
declare enum ENV {
|
|
14
|
-
MAINNET = 0,
|
|
15
|
-
TESTNET = 1
|
|
16
|
-
}
|
|
17
|
-
declare class AggregatorConfig {
|
|
18
|
-
private aggregatorUrl;
|
|
19
|
-
private fullNodeUrl;
|
|
20
|
-
private wallet;
|
|
21
|
-
private packages;
|
|
22
|
-
private env;
|
|
23
|
-
constructor(aggregatorUrl: string, fullNodeUrl: string, wallet: string, packages: Package[], env: ENV);
|
|
24
|
-
getAggregatorUrl(): string;
|
|
25
|
-
getFullNodeUrl(): string;
|
|
26
|
-
getWallet(): string;
|
|
27
|
-
getENV(): ENV;
|
|
28
|
-
getPackages(): Package[];
|
|
29
|
-
getPackage(packageName: string): Package | undefined;
|
|
30
|
-
addPackage(newPackage: Package): void;
|
|
31
|
-
removePackageById(packageId: string): void;
|
|
32
|
-
findPackageById(packageId: string): Package | undefined;
|
|
33
|
-
}
|
|
6
|
+
import Decimal from 'decimal.js';
|
|
34
7
|
|
|
35
8
|
/**
|
|
36
9
|
* Represents a SUI address, which is a string.
|
|
@@ -87,68 +60,33 @@ type CoinAsset = {
|
|
|
87
60
|
balance: bigint;
|
|
88
61
|
};
|
|
89
62
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
target: string;
|
|
101
|
-
feeRate: number;
|
|
102
|
-
amountIn: number;
|
|
103
|
-
amountOut: number;
|
|
104
|
-
extendedDetails?: ExtendedDetails;
|
|
105
|
-
version?: string;
|
|
106
|
-
};
|
|
107
|
-
type Router = {
|
|
108
|
-
path: Path[];
|
|
109
|
-
amountIn: BN;
|
|
110
|
-
amountOut: BN;
|
|
111
|
-
initialPrice: Decimal;
|
|
112
|
-
};
|
|
113
|
-
type RouterError = {
|
|
114
|
-
code: number;
|
|
115
|
-
msg: string;
|
|
116
|
-
};
|
|
117
|
-
type RouterData = {
|
|
118
|
-
amountIn: BN;
|
|
119
|
-
amountOut: BN;
|
|
120
|
-
routes: Router[];
|
|
121
|
-
insufficientLiquidity: boolean;
|
|
122
|
-
error?: RouterError;
|
|
123
|
-
};
|
|
124
|
-
type AggregatorResponse = {
|
|
125
|
-
code: number;
|
|
126
|
-
msg: string;
|
|
127
|
-
data: RouterData;
|
|
128
|
-
};
|
|
63
|
+
declare const CETUS = "CETUS";
|
|
64
|
+
declare const DEEPBOOKV2 = "DEEPBOOK";
|
|
65
|
+
declare const KRIYA = "KRIYA";
|
|
66
|
+
declare const FLOWXV2 = "FLOWX";
|
|
67
|
+
declare const KRIYAV3 = "KRIYAV3";
|
|
68
|
+
declare const TURBOS = "TURBOS";
|
|
69
|
+
declare const AFTERMATH = "AFTERMATH";
|
|
70
|
+
declare const HAEDAL = "HAEDAL";
|
|
71
|
+
declare const VOLO = "VOLO";
|
|
72
|
+
declare const AFSUI = "AFSUI";
|
|
129
73
|
type BuildRouterSwapParams = {
|
|
130
74
|
routers: Router[];
|
|
131
|
-
|
|
132
|
-
|
|
75
|
+
byAmountIn: boolean;
|
|
76
|
+
inputCoin: TransactionObjectArgument;
|
|
77
|
+
slippage: number;
|
|
78
|
+
txb: Transaction;
|
|
79
|
+
partner?: string;
|
|
80
|
+
};
|
|
81
|
+
type BuildFastRouterSwapParams = {
|
|
82
|
+
routers: Router[];
|
|
133
83
|
byAmountIn: boolean;
|
|
134
84
|
slippage: number;
|
|
135
|
-
|
|
136
|
-
targetCoinType: string;
|
|
85
|
+
txb: Transaction;
|
|
137
86
|
partner?: string;
|
|
138
87
|
isMergeTragetCoin?: boolean;
|
|
139
88
|
refreshAllCoins?: boolean;
|
|
140
89
|
};
|
|
141
|
-
interface FindRouterParams {
|
|
142
|
-
from: string;
|
|
143
|
-
target: string;
|
|
144
|
-
amount: BN;
|
|
145
|
-
byAmountIn: boolean;
|
|
146
|
-
depth: number | null;
|
|
147
|
-
splitAlgorithm: string | null;
|
|
148
|
-
splitFactor: number | null;
|
|
149
|
-
splitCount: number | null;
|
|
150
|
-
providers: string[] | null;
|
|
151
|
-
}
|
|
152
90
|
interface SwapInPoolsParams {
|
|
153
91
|
from: string;
|
|
154
92
|
target: string;
|
|
@@ -161,23 +99,33 @@ interface SwapInPoolsResult {
|
|
|
161
99
|
routeData?: RouterData;
|
|
162
100
|
}
|
|
163
101
|
declare class AggregatorClient {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
102
|
+
endpoint: string;
|
|
103
|
+
signer: string;
|
|
104
|
+
client: SuiClient;
|
|
105
|
+
env: Env;
|
|
167
106
|
private allCoins;
|
|
168
|
-
constructor(
|
|
107
|
+
constructor(endpoint: string, signer: string, client: SuiClient, env: Env);
|
|
169
108
|
getAllCoins(): Promise<CoinAsset[]>;
|
|
170
|
-
|
|
109
|
+
findRouters(params: FindRouterParams): Promise<RouterData | null>;
|
|
110
|
+
expectInputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], amountOutLimit: BN, partner?: string): Promise<TransactionObjectArgument>;
|
|
111
|
+
expectOutputSwap(txb: Transaction, inputCoin: TransactionObjectArgument, routers: Router[], partner?: string): Promise<TransactionObjectArgument>;
|
|
171
112
|
swapInPools(params: SwapInPoolsParams): Promise<SwapInPoolsResult | null>;
|
|
172
|
-
routerSwap(params: BuildRouterSwapParams): Promise<
|
|
113
|
+
routerSwap(params: BuildRouterSwapParams): Promise<TransactionObjectArgument>;
|
|
114
|
+
fastRouterSwap(params: BuildFastRouterSwapParams): Promise<void>;
|
|
115
|
+
publishedAt(): string;
|
|
116
|
+
transferOrDestoryCoin(txb: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
117
|
+
checkCoinThresholdAndMergeCoin(txb: Transaction, coins: TransactionObjectArgument[], coinType: string, amountLimit: BN): TransactionObjectArgument;
|
|
118
|
+
newDex(provider: string, partner?: string): Dex;
|
|
173
119
|
signAndExecuteTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
174
120
|
devInspectTransactionBlock(txb: Transaction): Promise<_mysten_sui_client.DevInspectResults>;
|
|
175
121
|
sendTransaction(txb: Transaction, signer: Signer): Promise<_mysten_sui_client.SuiTransactionBlockResponse>;
|
|
176
122
|
}
|
|
177
123
|
declare function parseRouterResponse(data: any): RouterData;
|
|
178
124
|
|
|
179
|
-
declare
|
|
180
|
-
|
|
125
|
+
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
126
|
+
interface Dex {
|
|
127
|
+
swap(client: AggregatorClient, ptb: Transaction, path: Path, inputCoin: TransactionObjectArgument): Promise<TransactionObjectArgument>;
|
|
128
|
+
}
|
|
181
129
|
|
|
182
130
|
declare function isSortedSymbols(symbolX: string, symbolY: string): boolean;
|
|
183
131
|
declare function composeType(address: string, generics: SuiAddress[]): SuiAddress;
|
|
@@ -195,61 +143,6 @@ declare function fixSuiObjectId(value: string): string;
|
|
|
195
143
|
declare function patchFixSuiObjectId(data: any): void;
|
|
196
144
|
declare function createTarget(packageName: string, moduleName: string, functionName: string): `${string}::${string}::${string}`;
|
|
197
145
|
|
|
198
|
-
/**
|
|
199
|
-
* The address representing the clock in the system.
|
|
200
|
-
*/
|
|
201
|
-
declare const CLOCK_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000006";
|
|
202
|
-
/**
|
|
203
|
-
* The address for CoinInfo module.
|
|
204
|
-
*/
|
|
205
|
-
declare const CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
206
|
-
/**
|
|
207
|
-
* The address for CoinStore module.
|
|
208
|
-
*/
|
|
209
|
-
declare const CoinStoreAddress = "0x1::coin::CoinStore";
|
|
210
|
-
declare const SuiZeroCoinFn = "0x2::coin::zero";
|
|
211
|
-
declare const AGGREGATOR = "aggregator";
|
|
212
|
-
declare const CETUS_DEX = "CETUS";
|
|
213
|
-
declare const DEEPBOOK_DEX = "DEEPBOOK";
|
|
214
|
-
declare const KRIYA_DEX = "KRIYA";
|
|
215
|
-
declare const FLOWX_AMM = "FLOWX";
|
|
216
|
-
declare const TURBOS_DEX = "TURBOS";
|
|
217
|
-
declare const AFTERMATH_AMM = "AFTERMATH";
|
|
218
|
-
declare const INTEGRATE = "integrate";
|
|
219
|
-
declare const CETUS_MODULE = "cetus";
|
|
220
|
-
declare const DEEPBOOK_MODULE = "deepbook";
|
|
221
|
-
declare const KRIYA_MODULE = "kriya";
|
|
222
|
-
declare const UTILS_MODULE = "utils";
|
|
223
|
-
declare const POOL_MODULT = "pool";
|
|
224
|
-
declare const PAY_MODULE = "pay";
|
|
225
|
-
declare const FLOWX_AMM_MODULE = "flowx_amm";
|
|
226
|
-
declare const TURBOS_MODULE = "turbos";
|
|
227
|
-
declare const AFTERMATH_MODULE = "aftermath";
|
|
228
|
-
declare const DEEPBOOK_CUSTODIAN_V2_MODULE = "custodian_v2";
|
|
229
|
-
declare const DEEPBOOK_CLOB_V2_MODULE = "clob_v2";
|
|
230
|
-
declare const FlashSwapFunc = "flash_swap";
|
|
231
|
-
declare const FlashSwapWithPartnerFunc = "flash_swap_with_partner";
|
|
232
|
-
declare const RepayFalshSwapFunc = "repay_flash_swap";
|
|
233
|
-
declare const RepayFlashSwapWithPartnerFunc = "repay_flash_swap_with_partner";
|
|
234
|
-
declare const FlashSwapA2BFunc = "flash_swap_a2b";
|
|
235
|
-
declare const FlashSwapB2AFunc = "flash_swap_b2a";
|
|
236
|
-
declare const FlashSwapWithPartnerA2BFunc = "flash_swap_with_partner_a2b";
|
|
237
|
-
declare const FlashSwapWithPartnerB2AFunc = "flash_swap_with_partner_b2a";
|
|
238
|
-
declare const REPAY_FLASH_SWAP_A2B_FUNC = "repay_flash_swap_a2b";
|
|
239
|
-
declare const REPAY_FLASH_SWAP_B2A_FUNC = "repay_flash_swap_b2a";
|
|
240
|
-
declare const REPAY_FLASH_SWAP_WITH_PARTNER_A2B_FUNC = "repay_flash_swap_with_partner_a2b";
|
|
241
|
-
declare const REPAY_FLASH_SWAP_WITH_PARTNER_B2A_FUNC = "repay_flash_swap_with_partner_b2a";
|
|
242
|
-
declare const SWAP_A2B_FUNC = "swap_a2b";
|
|
243
|
-
declare const SWAP_B2A_FUNC = "swap_b2a";
|
|
244
|
-
declare const TRANSFER_OR_DESTORY_COIN_FUNC = "transfer_or_destroy_coin";
|
|
245
|
-
declare const CHECK_COINS_THRESHOLD_FUNC = "check_coins_threshold";
|
|
246
|
-
declare const JOIN_FUNC = "join_vec";
|
|
247
|
-
declare const TRANSFER_ACCOUNT_CAP = "transfer_account_cap";
|
|
248
|
-
declare const DEEPBOOK_PACKAGE_ID = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
249
|
-
declare const DEEPBOOK_PUBLISHED_AT = "0x000000000000000000000000000000000000000000000000000000000000dee9";
|
|
250
|
-
declare const CETUS_PUBLISHED_AT = "0x70968826ad1b4ba895753f634b0aea68d0672908ca1075a2abdf0fc9e0b2fc6a";
|
|
251
|
-
declare const MAINNET_CETUS_GLOBAL_CONFIG_ID = "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
252
|
-
declare const TESTNET_CETUS_GLOBAL_CONFIG_ID = "0x6f4149091a5aea0e818e7243a13adcfb403842d670b9a2089de058512620687a";
|
|
253
146
|
declare const ZERO: BN;
|
|
254
147
|
declare const ONE: BN;
|
|
255
148
|
declare const TWO: BN;
|
|
@@ -257,18 +150,62 @@ declare const U128: BN;
|
|
|
257
150
|
declare const U64_MAX_BN: BN;
|
|
258
151
|
declare const U64_MAX = "18446744073709551615";
|
|
259
152
|
declare const TEN_POW_NINE = 1000000000;
|
|
260
|
-
declare const MAINNET_FLOWX_AMM_CONTAINER_ID = "0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511";
|
|
261
|
-
declare const TESTNET_FLOWX_AMM_CONTAINER_ID = "";
|
|
262
|
-
declare const TURBOS_VERSIONED = "0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f";
|
|
263
|
-
declare const MAINNET_AFTERMATH_REGISTRY_ID = "0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae";
|
|
264
|
-
declare const TESTNET_AFTERMATH_REGISTRY_ID = "";
|
|
265
|
-
declare const MAINNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4";
|
|
266
|
-
declare const TESTNET_AFTERMATH_PROTOCOL_FEE_VAULT_ID = "";
|
|
267
|
-
declare const MAINNET_AFTERMATH_TREASURY_ID = "0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce";
|
|
268
|
-
declare const TESTNET_AFTERMATH_TREASURY_ID = "";
|
|
269
|
-
declare const MAINNET_AFTERMATH_INSURANCE_FUND_ID = "0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b";
|
|
270
|
-
declare const TESTNET_AFTERMATH_INSURANCE_FUND_ID = "";
|
|
271
|
-
declare const MAINNET_AFTERMATH_REFERRAL_VAULT_ID = "0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278";
|
|
272
|
-
declare const TESTNET_AFTERMATH_REFERRAL_VAULT_ID = "";
|
|
273
153
|
|
|
274
|
-
|
|
154
|
+
interface FindRouterParams {
|
|
155
|
+
from: string;
|
|
156
|
+
target: string;
|
|
157
|
+
amount: BN;
|
|
158
|
+
byAmountIn: boolean;
|
|
159
|
+
depth?: number;
|
|
160
|
+
splitAlgorithm?: string;
|
|
161
|
+
splitFactor?: number;
|
|
162
|
+
splitCount?: number;
|
|
163
|
+
providers?: string[];
|
|
164
|
+
}
|
|
165
|
+
type ExtendedDetails = {
|
|
166
|
+
aftermathPoolFlatness?: number;
|
|
167
|
+
aftermathLpSupplyType?: string;
|
|
168
|
+
turbosFeeType?: string;
|
|
169
|
+
};
|
|
170
|
+
type Path = {
|
|
171
|
+
id: string;
|
|
172
|
+
direction: boolean;
|
|
173
|
+
provider: string;
|
|
174
|
+
from: string;
|
|
175
|
+
target: string;
|
|
176
|
+
feeRate: number;
|
|
177
|
+
amountIn: number;
|
|
178
|
+
amountOut: number;
|
|
179
|
+
extendedDetails?: ExtendedDetails;
|
|
180
|
+
version?: string;
|
|
181
|
+
};
|
|
182
|
+
type Router = {
|
|
183
|
+
path: Path[];
|
|
184
|
+
amountIn: BN;
|
|
185
|
+
amountOut: BN;
|
|
186
|
+
initialPrice: Decimal;
|
|
187
|
+
};
|
|
188
|
+
type RouterError = {
|
|
189
|
+
code: number;
|
|
190
|
+
msg: string;
|
|
191
|
+
};
|
|
192
|
+
type RouterData = {
|
|
193
|
+
amountIn: BN;
|
|
194
|
+
amountOut: BN;
|
|
195
|
+
routes: Router[];
|
|
196
|
+
insufficientLiquidity: boolean;
|
|
197
|
+
error?: RouterError;
|
|
198
|
+
};
|
|
199
|
+
type AggregatorResponse = {
|
|
200
|
+
code: number;
|
|
201
|
+
msg: string;
|
|
202
|
+
data: RouterData;
|
|
203
|
+
};
|
|
204
|
+
declare function getRouterResult(endpoint: string, params: FindRouterParams): Promise<RouterData | null>;
|
|
205
|
+
|
|
206
|
+
declare enum Env {
|
|
207
|
+
Mainnet = 0,
|
|
208
|
+
Testnet = 1
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export { AFSUI, AFTERMATH, AggregatorClient, type AggregatorResponse, type BuildFastRouterSwapParams, type BuildRouterSwapParams, CETUS, CLOCK_ADDRESS, DEEPBOOKV2, type Dex, Env, type ExtendedDetails, FLOWXV2, type FindRouterParams, HAEDAL, KRIYA, KRIYAV3, ONE, type Path, 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, extractAddressFromType, extractStructTagFromType, fixSuiObjectId, getRouterResult, isSortedSymbols, normalizeCoinType, parseRouterResponse, patchFixSuiObjectId };
|