@cetusprotocol/sui-clmm-sdk 1.0.0
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/.turbo/turbo-build.log +11100 -0
- package/README.md +108 -0
- package/dist/index.d.mts +2251 -0
- package/dist/index.d.ts +2251 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -0
- package/docs/add_liquidity.md +145 -0
- package/docs/close_position.md +57 -0
- package/docs/collect_fees.md +37 -0
- package/docs/create_clmm_pool.md +228 -0
- package/docs/error_code.md +69 -0
- package/docs/get_clmm_pools.md +92 -0
- package/docs/get_positions.md +70 -0
- package/docs/get_reward.md +53 -0
- package/docs/get_ticks.md +39 -0
- package/docs/migrate_to_version_6.0.md +143 -0
- package/docs/open_position.md +224 -0
- package/docs/partner_swap.md +60 -0
- package/docs/pre_swap.md +136 -0
- package/docs/remove_liquidity.md +124 -0
- package/docs/swap.md +153 -0
- package/docs/utils.md +85 -0
- package/package.json +37 -0
- package/src/config/index.ts +2 -0
- package/src/config/mainnet.ts +41 -0
- package/src/config/testnet.ts +40 -0
- package/src/errors/errors.ts +93 -0
- package/src/errors/index.ts +1 -0
- package/src/index.ts +10 -0
- package/src/math/apr.ts +167 -0
- package/src/math/index.ts +1 -0
- package/src/modules/configModule.ts +540 -0
- package/src/modules/index.ts +5 -0
- package/src/modules/poolModule.ts +1066 -0
- package/src/modules/positionModule.ts +932 -0
- package/src/modules/rewarderModule.ts +430 -0
- package/src/modules/swapModule.ts +389 -0
- package/src/sdk.ts +131 -0
- package/src/types/clmm_type.ts +1002 -0
- package/src/types/clmmpool.ts +366 -0
- package/src/types/config_type.ts +241 -0
- package/src/types/index.ts +8 -0
- package/src/types/sui.ts +124 -0
- package/src/types/token_type.ts +189 -0
- package/src/utils/common.ts +426 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/positionUtils.ts +434 -0
- package/src/utils/swapUtils.ts +499 -0
- package/tests/add_liquidity.test.ts +121 -0
- package/tests/add_liquidity_fix_token.test.ts +182 -0
- package/tests/apr.test.ts +71 -0
- package/tests/cetus_config.test.ts +26 -0
- package/tests/collect_fees.test.ts +11 -0
- package/tests/pool.test.ts +267 -0
- package/tests/position.test.ts +145 -0
- package/tests/remove_liquidity.test.ts +119 -0
- package/tests/rewarder.test.ts +60 -0
- package/tests/sdk_config.test.ts +49 -0
- package/tests/swap.test.ts +254 -0
- package/tests/tsconfig.json +26 -0
- package/tsconfig.json +5 -0
- package/tsup.config.ts +10 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,2251 @@
|
|
|
1
|
+
import { CoinPairType, SuiObjectIdType, SuiAddressType, NFT as NFT$1, Percentage, IModule, SuiResource, PaginationArgs, DataPage, PageQuery, CoinAsset, SdkWrapper, BaseSdkOptions, Package, BuildCoinResult, BaseError } from '@cetusprotocol/common-sdk';
|
|
2
|
+
import { TransactionArgument, Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
3
|
+
import BN from 'bn.js';
|
|
4
|
+
import Decimal from 'decimal.js';
|
|
5
|
+
import { DevInspectResults, SuiObjectResponse, SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
6
|
+
|
|
7
|
+
type BasePath = {
|
|
8
|
+
direction: boolean;
|
|
9
|
+
label: string;
|
|
10
|
+
pool_address: string;
|
|
11
|
+
from_coin: string;
|
|
12
|
+
to_coin: string;
|
|
13
|
+
fee_rate: number;
|
|
14
|
+
output_amount: number;
|
|
15
|
+
input_amount: number;
|
|
16
|
+
current_sqrt_price: BN;
|
|
17
|
+
from_decimal: number;
|
|
18
|
+
to_decimal: number;
|
|
19
|
+
current_price: Decimal;
|
|
20
|
+
};
|
|
21
|
+
type SplitPath = {
|
|
22
|
+
percent: number;
|
|
23
|
+
input_amount: number;
|
|
24
|
+
output_amount: number;
|
|
25
|
+
path_index: number;
|
|
26
|
+
last_quote_output: number;
|
|
27
|
+
base_paths: BasePath[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Represents tick data for a liquidity pool.
|
|
31
|
+
*/
|
|
32
|
+
type TickData = {
|
|
33
|
+
/**
|
|
34
|
+
* The object identifier of the tick data.
|
|
35
|
+
*/
|
|
36
|
+
object_id: string;
|
|
37
|
+
/**
|
|
38
|
+
* The index of the tick.
|
|
39
|
+
*/
|
|
40
|
+
index: number;
|
|
41
|
+
/**
|
|
42
|
+
* The square root price value for the tick.
|
|
43
|
+
*/
|
|
44
|
+
sqrt_price: BN;
|
|
45
|
+
/**
|
|
46
|
+
* The net liquidity value for the tick.
|
|
47
|
+
*/
|
|
48
|
+
liquidity_net: BN;
|
|
49
|
+
/**
|
|
50
|
+
* The gross liquidity value for the tick.
|
|
51
|
+
*/
|
|
52
|
+
liquidity_gross: BN;
|
|
53
|
+
/**
|
|
54
|
+
* The fee growth outside coin A for the tick.
|
|
55
|
+
*/
|
|
56
|
+
fee_growth_outside_a: BN;
|
|
57
|
+
/**
|
|
58
|
+
* The fee growth outside coin B for the tick.
|
|
59
|
+
*/
|
|
60
|
+
fee_growth_outside_b: BN;
|
|
61
|
+
/**
|
|
62
|
+
* An array of rewarders' growth outside values for the tick.
|
|
63
|
+
*/
|
|
64
|
+
rewarders_growth_outside: BN[];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Represents a tick for a liquidity pool.
|
|
68
|
+
*/
|
|
69
|
+
type Tick = {
|
|
70
|
+
/**
|
|
71
|
+
* The index of the tick.
|
|
72
|
+
*/
|
|
73
|
+
index: Bits;
|
|
74
|
+
/**
|
|
75
|
+
* The square root price value for the tick (string representation).
|
|
76
|
+
*/
|
|
77
|
+
sqrt_price: string;
|
|
78
|
+
/**
|
|
79
|
+
* The net liquidity value for the tick (Bits format).
|
|
80
|
+
*/
|
|
81
|
+
liquidity_net: Bits;
|
|
82
|
+
/**
|
|
83
|
+
* The gross liquidity value for the tick (string representation).
|
|
84
|
+
*/
|
|
85
|
+
liquidity_gross: string;
|
|
86
|
+
/**
|
|
87
|
+
* The fee growth outside coin A for the tick (string representation).
|
|
88
|
+
*/
|
|
89
|
+
fee_growth_outside_a: string;
|
|
90
|
+
/**
|
|
91
|
+
* The fee growth outside coin B for the tick (string representation).
|
|
92
|
+
*/
|
|
93
|
+
fee_growth_outside_b: string;
|
|
94
|
+
/**
|
|
95
|
+
* An array of rewarders' growth outside values for the tick (array of string representations).
|
|
96
|
+
*/
|
|
97
|
+
rewarders_growth_outside: string[3];
|
|
98
|
+
};
|
|
99
|
+
type SwapResult = {
|
|
100
|
+
amount_in: BN;
|
|
101
|
+
amount_out: BN;
|
|
102
|
+
fee_amount: BN;
|
|
103
|
+
ref_amount: BN;
|
|
104
|
+
next_sqrt_price: BN;
|
|
105
|
+
cross_tick_num: number;
|
|
106
|
+
};
|
|
107
|
+
type SwapStepResult = {
|
|
108
|
+
amount_in: BN;
|
|
109
|
+
amount_out: BN;
|
|
110
|
+
next_sqrt_price: BN;
|
|
111
|
+
fee_amount: BN;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Represents bits information.
|
|
115
|
+
*/
|
|
116
|
+
type Bits = {
|
|
117
|
+
bits: string;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Creates a Bits object from an index.
|
|
121
|
+
* @param {number | string} index - The index value.
|
|
122
|
+
* @returns {Bits} The created Bits object.
|
|
123
|
+
*/
|
|
124
|
+
declare function newBits(index: number | string): Bits;
|
|
125
|
+
/**
|
|
126
|
+
* Represents data for a liquidity mining pool.
|
|
127
|
+
*/
|
|
128
|
+
type ClmmpoolData = {
|
|
129
|
+
current_sqrt_price: BN;
|
|
130
|
+
current_tick_index: number;
|
|
131
|
+
fee_growth_global_a: BN;
|
|
132
|
+
fee_growth_global_b: BN;
|
|
133
|
+
fee_protocol_coin_a: BN;
|
|
134
|
+
fee_protocol_coin_b: BN;
|
|
135
|
+
fee_rate: BN;
|
|
136
|
+
liquidity: BN;
|
|
137
|
+
tick_indexes: number[];
|
|
138
|
+
tick_spacing: number;
|
|
139
|
+
ticks: Array<TickData>;
|
|
140
|
+
collection_name: string;
|
|
141
|
+
} & CoinPairType;
|
|
142
|
+
/**
|
|
143
|
+
* Transforms a Pool object into ClmmpoolData format.
|
|
144
|
+
* @param {Pool} pool - The liquidity pool object to transform.
|
|
145
|
+
* @returns {ClmmpoolData} The transformed ClmmpoolData object.
|
|
146
|
+
*/
|
|
147
|
+
declare function transClmmpoolDataWithoutTicks(pool: Pool): ClmmpoolData;
|
|
148
|
+
/**
|
|
149
|
+
* Simulate per step of swap on every tick.
|
|
150
|
+
*
|
|
151
|
+
* @param currentSqrtPrice
|
|
152
|
+
* @param targetSqrtPrice
|
|
153
|
+
* @param liquidity
|
|
154
|
+
* @param amount
|
|
155
|
+
* @param feeRate
|
|
156
|
+
* @param byAmountIn
|
|
157
|
+
* @returns
|
|
158
|
+
*/
|
|
159
|
+
declare function computeSwapStep(currentSqrtPrice: BN, targetSqrtPrice: BN, liquidity: BN, amount: BN, feeRate: BN, byAmountIn: boolean): SwapStepResult;
|
|
160
|
+
/**
|
|
161
|
+
* Simulate swap by imput lots of ticks.
|
|
162
|
+
* @param aToB
|
|
163
|
+
* @param byAmountIn
|
|
164
|
+
* @param amount
|
|
165
|
+
* @param poolData
|
|
166
|
+
* @param swapTicks
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
169
|
+
declare function computeSwap(aToB: boolean, byAmountIn: boolean, amount: BN, poolData: ClmmpoolData, swapTicks: Array<TickData>): SwapResult;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Enumerates the possible status values of a position within a liquidity mining module.
|
|
173
|
+
*/
|
|
174
|
+
declare enum ClmmPositionStatus {
|
|
175
|
+
/**
|
|
176
|
+
* The position has been deleted or removed.
|
|
177
|
+
*/
|
|
178
|
+
'Deleted' = "Deleted",
|
|
179
|
+
/**
|
|
180
|
+
* The position exists and is active.
|
|
181
|
+
*/
|
|
182
|
+
'Exists' = "Exists",
|
|
183
|
+
/**
|
|
184
|
+
* The position does not exist or is not active.
|
|
185
|
+
*/
|
|
186
|
+
'NotExists' = "NotExists"
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The Cetus clmmpool's position NFT.
|
|
190
|
+
*/
|
|
191
|
+
type Position = {
|
|
192
|
+
/**
|
|
193
|
+
* The unique identifier of the position object.
|
|
194
|
+
*/
|
|
195
|
+
pos_object_id: SuiObjectIdType;
|
|
196
|
+
/**
|
|
197
|
+
* The owner of the position.
|
|
198
|
+
*/
|
|
199
|
+
owner: SuiObjectIdType;
|
|
200
|
+
/**
|
|
201
|
+
* The liquidity pool associated with the position.
|
|
202
|
+
*/
|
|
203
|
+
pool: SuiObjectIdType;
|
|
204
|
+
/**
|
|
205
|
+
* The type of position represented by an address.
|
|
206
|
+
*/
|
|
207
|
+
type: SuiAddressType;
|
|
208
|
+
/**
|
|
209
|
+
* The index of the position.
|
|
210
|
+
*/
|
|
211
|
+
index: number;
|
|
212
|
+
/**
|
|
213
|
+
* The amount of liquidity held by the position.
|
|
214
|
+
*/
|
|
215
|
+
liquidity: string;
|
|
216
|
+
/**
|
|
217
|
+
* The lower tick index of the position range.
|
|
218
|
+
*/
|
|
219
|
+
tick_lower_index: number;
|
|
220
|
+
/**
|
|
221
|
+
* The upper tick index of the position range.
|
|
222
|
+
*/
|
|
223
|
+
tick_upper_index: number;
|
|
224
|
+
/**
|
|
225
|
+
* The status of the position within the liquidity mining module.
|
|
226
|
+
*/
|
|
227
|
+
position_status: ClmmPositionStatus;
|
|
228
|
+
/**
|
|
229
|
+
* The address type of the first coin in the position.
|
|
230
|
+
*/
|
|
231
|
+
coin_type_a: SuiAddressType;
|
|
232
|
+
/**
|
|
233
|
+
* The address type of the second coin in the position.
|
|
234
|
+
*/
|
|
235
|
+
coin_type_b: SuiAddressType;
|
|
236
|
+
} & NFT$1 & PositionReward;
|
|
237
|
+
/**
|
|
238
|
+
* Represents reward information associated with a liquidity mining position.
|
|
239
|
+
*/
|
|
240
|
+
type PositionReward = {
|
|
241
|
+
/**
|
|
242
|
+
* The unique identifier of the position object.
|
|
243
|
+
*/
|
|
244
|
+
pos_object_id: SuiObjectIdType;
|
|
245
|
+
/**
|
|
246
|
+
* The amount of liquidity held by the position.
|
|
247
|
+
*/
|
|
248
|
+
liquidity: string;
|
|
249
|
+
/**
|
|
250
|
+
* The lower tick index of the position range.
|
|
251
|
+
*/
|
|
252
|
+
tick_lower_index: number;
|
|
253
|
+
/**
|
|
254
|
+
* The upper tick index of the position range.
|
|
255
|
+
*/
|
|
256
|
+
tick_upper_index: number;
|
|
257
|
+
/**
|
|
258
|
+
* The accumulated fee growth inside the first coin of the position.
|
|
259
|
+
*/
|
|
260
|
+
fee_growth_inside_a: string;
|
|
261
|
+
/**
|
|
262
|
+
* The accumulated fee owned in the first coin of the position.
|
|
263
|
+
*/
|
|
264
|
+
fee_owned_a: string;
|
|
265
|
+
/**
|
|
266
|
+
* The accumulated fee growth inside the second coin of the position.
|
|
267
|
+
*/
|
|
268
|
+
fee_growth_inside_b: string;
|
|
269
|
+
/**
|
|
270
|
+
* The accumulated fee owned in the second coin of the position.
|
|
271
|
+
*/
|
|
272
|
+
fee_owned_b: string;
|
|
273
|
+
/**
|
|
274
|
+
* The amount of reward owned in the first reward category.
|
|
275
|
+
*/
|
|
276
|
+
reward_amount_owned_0: string;
|
|
277
|
+
/**
|
|
278
|
+
* The amount of reward owned in the second reward category.
|
|
279
|
+
*/
|
|
280
|
+
reward_amount_owned_1: string;
|
|
281
|
+
/**
|
|
282
|
+
* The amount of reward owned in the third reward category.
|
|
283
|
+
*/
|
|
284
|
+
reward_amount_owned_2: string;
|
|
285
|
+
/**
|
|
286
|
+
* The accumulated reward growth inside the first reward category.
|
|
287
|
+
*/
|
|
288
|
+
reward_growth_inside_0: string;
|
|
289
|
+
/**
|
|
290
|
+
* The accumulated reward growth inside the second reward category.
|
|
291
|
+
*/
|
|
292
|
+
reward_growth_inside_1: string;
|
|
293
|
+
/**
|
|
294
|
+
* The accumulated reward growth inside the third reward category.
|
|
295
|
+
*/
|
|
296
|
+
reward_growth_inside_2: string;
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* Represents immutable properties of a liquidity pool.
|
|
300
|
+
*/
|
|
301
|
+
type PoolImmutables = {
|
|
302
|
+
/**
|
|
303
|
+
* The address of the liquidity pool.
|
|
304
|
+
*/
|
|
305
|
+
id: string;
|
|
306
|
+
/**
|
|
307
|
+
* The tick spacing value used in the pool.
|
|
308
|
+
*/
|
|
309
|
+
tick_spacing: string;
|
|
310
|
+
} & CoinPairType;
|
|
311
|
+
/**
|
|
312
|
+
* "Pool" is the core module of Clmm protocol, which defines the trading pairs of "clmmpool".
|
|
313
|
+
*/
|
|
314
|
+
type Pool = {
|
|
315
|
+
/**
|
|
316
|
+
* Represents the type or category of a liquidity pool.
|
|
317
|
+
*/
|
|
318
|
+
pool_type: string;
|
|
319
|
+
/**
|
|
320
|
+
* The amount of coin a.
|
|
321
|
+
*/
|
|
322
|
+
coin_amount_a: number;
|
|
323
|
+
/**
|
|
324
|
+
* The amount of coin b.
|
|
325
|
+
*/
|
|
326
|
+
coin_amount_b: number;
|
|
327
|
+
/**
|
|
328
|
+
* The current sqrt price
|
|
329
|
+
*/
|
|
330
|
+
current_sqrt_price: number;
|
|
331
|
+
/**
|
|
332
|
+
* The current tick index
|
|
333
|
+
*/
|
|
334
|
+
current_tick_index: number;
|
|
335
|
+
/**
|
|
336
|
+
* The global fee growth of coin a as Q64.64
|
|
337
|
+
*/
|
|
338
|
+
fee_growth_global_b: number;
|
|
339
|
+
/**
|
|
340
|
+
* The global fee growth of coin b as Q64.64
|
|
341
|
+
*/
|
|
342
|
+
fee_growth_global_a: number;
|
|
343
|
+
/**
|
|
344
|
+
* The amounts of coin a owned to protocol
|
|
345
|
+
*/
|
|
346
|
+
fee_protocol_coin_a: number;
|
|
347
|
+
/**
|
|
348
|
+
* The amounts of coin b owned to protocol
|
|
349
|
+
*/
|
|
350
|
+
fee_protocol_coin_b: number;
|
|
351
|
+
/**
|
|
352
|
+
* The numerator of fee rate, the denominator is 1_000_000.
|
|
353
|
+
*/
|
|
354
|
+
fee_rate: number;
|
|
355
|
+
/**
|
|
356
|
+
* is the pool pause
|
|
357
|
+
*/
|
|
358
|
+
is_pause: boolean;
|
|
359
|
+
/**
|
|
360
|
+
* The liquidity of current tick index
|
|
361
|
+
*/
|
|
362
|
+
liquidity: number;
|
|
363
|
+
/**
|
|
364
|
+
* The pool index
|
|
365
|
+
*/
|
|
366
|
+
index: number;
|
|
367
|
+
/**
|
|
368
|
+
* The positions manager
|
|
369
|
+
*/
|
|
370
|
+
position_manager: {
|
|
371
|
+
positions_handle: string;
|
|
372
|
+
size: number;
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* The rewarder manager
|
|
376
|
+
*/
|
|
377
|
+
rewarder_infos: Array<Rewarder>;
|
|
378
|
+
rewarder_last_updated_time: string;
|
|
379
|
+
/**
|
|
380
|
+
* The tick manager handle
|
|
381
|
+
*/
|
|
382
|
+
ticks_handle: string;
|
|
383
|
+
/**
|
|
384
|
+
* The url for pool and position
|
|
385
|
+
*/
|
|
386
|
+
uri: string;
|
|
387
|
+
/**
|
|
388
|
+
* The name for pool
|
|
389
|
+
*/
|
|
390
|
+
name: string;
|
|
391
|
+
} & PoolImmutables;
|
|
392
|
+
type Rewarder = {
|
|
393
|
+
/**
|
|
394
|
+
* The coin address where rewards will be distributed.
|
|
395
|
+
*/
|
|
396
|
+
coin_type: string;
|
|
397
|
+
/**
|
|
398
|
+
* The rate of emissions in coins per second.
|
|
399
|
+
*/
|
|
400
|
+
emissions_per_second: number;
|
|
401
|
+
/**
|
|
402
|
+
* The global growth factor influencing reward emissions.
|
|
403
|
+
*/
|
|
404
|
+
growth_global: number;
|
|
405
|
+
/**
|
|
406
|
+
* The total emissions in coins that occur every day.
|
|
407
|
+
*/
|
|
408
|
+
emissions_every_day: number;
|
|
409
|
+
};
|
|
410
|
+
/**
|
|
411
|
+
* Configuration settings for the Cryptocurrency Liquidity Mining Module (CLMM).
|
|
412
|
+
*/
|
|
413
|
+
type ClmmConfig = {
|
|
414
|
+
/**
|
|
415
|
+
* Identifier of the pools for liquidity mining.
|
|
416
|
+
*/
|
|
417
|
+
pools_id: SuiObjectIdType;
|
|
418
|
+
/**
|
|
419
|
+
* Identifier of the global configuration for the module.
|
|
420
|
+
*/
|
|
421
|
+
global_config_id: SuiObjectIdType;
|
|
422
|
+
/**
|
|
423
|
+
* Identifier of the administrative capacity for the module.
|
|
424
|
+
*/
|
|
425
|
+
admin_cap_id: SuiObjectIdType;
|
|
426
|
+
/**
|
|
427
|
+
* Identifier of the global vault for the module.
|
|
428
|
+
*/
|
|
429
|
+
global_vault_id: SuiObjectIdType;
|
|
430
|
+
/**
|
|
431
|
+
* Optional identifier of partners for the liquidity mining module.
|
|
432
|
+
*/
|
|
433
|
+
partners_id?: SuiObjectIdType;
|
|
434
|
+
};
|
|
435
|
+
/**
|
|
436
|
+
* Represents an event to create a liquidity mining partner.
|
|
437
|
+
*/
|
|
438
|
+
type CreatePartnerEvent = {
|
|
439
|
+
/**
|
|
440
|
+
* The name of the liquidity mining partner.
|
|
441
|
+
*/
|
|
442
|
+
name: string;
|
|
443
|
+
/**
|
|
444
|
+
* The recipient's address for the partner.
|
|
445
|
+
*/
|
|
446
|
+
recipient: SuiAddressType;
|
|
447
|
+
/**
|
|
448
|
+
* Identifier of the partner.
|
|
449
|
+
*/
|
|
450
|
+
partner_id: SuiObjectIdType;
|
|
451
|
+
/**
|
|
452
|
+
* Identifier of the partner's capacity.
|
|
453
|
+
*/
|
|
454
|
+
partner_cap_id: SuiObjectIdType;
|
|
455
|
+
/**
|
|
456
|
+
* The fee rate associated with the partner.
|
|
457
|
+
*/
|
|
458
|
+
fee_rate: string;
|
|
459
|
+
/**
|
|
460
|
+
* The starting epoch of the partnership.
|
|
461
|
+
*/
|
|
462
|
+
start_epoch: string;
|
|
463
|
+
/**
|
|
464
|
+
* The ending epoch of the partnership.
|
|
465
|
+
*/
|
|
466
|
+
end_epoch: string;
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* Represents parameters for creating a liquidity pool.
|
|
470
|
+
*/
|
|
471
|
+
type CreatePoolParams = {
|
|
472
|
+
/**
|
|
473
|
+
* The tick spacing value used for the pool.
|
|
474
|
+
*/
|
|
475
|
+
tick_spacing: number;
|
|
476
|
+
/**
|
|
477
|
+
* The initial square root price value for the pool.
|
|
478
|
+
*/
|
|
479
|
+
initialize_sqrt_price: string;
|
|
480
|
+
/**
|
|
481
|
+
* The Uniform Resource Identifier (URI) associated with the pool.
|
|
482
|
+
*/
|
|
483
|
+
uri: string;
|
|
484
|
+
} & CoinPairType;
|
|
485
|
+
/**
|
|
486
|
+
* Represents parameters for adding liquidity to a created liquidity pool.
|
|
487
|
+
* Extends the CreatePoolParams type.
|
|
488
|
+
*/
|
|
489
|
+
type CreatePoolAddLiquidityParams = CreatePoolParams & {
|
|
490
|
+
/**
|
|
491
|
+
* The amount of the first coin to be added as liquidity.
|
|
492
|
+
* Can be a number or a string.
|
|
493
|
+
*/
|
|
494
|
+
amount_a: number | string;
|
|
495
|
+
/**
|
|
496
|
+
* The amount of the second coin to be added as liquidity.
|
|
497
|
+
* Can be a number or a string.
|
|
498
|
+
*/
|
|
499
|
+
amount_b: number | string;
|
|
500
|
+
/**
|
|
501
|
+
* Indicates whether the amount of the first coin is fixed.
|
|
502
|
+
*/
|
|
503
|
+
fix_amount_a: boolean;
|
|
504
|
+
/**
|
|
505
|
+
* The lower tick index for liquidity provision.
|
|
506
|
+
*/
|
|
507
|
+
tick_lower: number;
|
|
508
|
+
/**
|
|
509
|
+
* The upper tick index for liquidity provision.
|
|
510
|
+
*/
|
|
511
|
+
tick_upper: number;
|
|
512
|
+
metadata_a: SuiObjectIdType;
|
|
513
|
+
metadata_b: SuiObjectIdType;
|
|
514
|
+
};
|
|
515
|
+
type FetchParams = {
|
|
516
|
+
pool_id: SuiObjectIdType;
|
|
517
|
+
} & CoinPairType;
|
|
518
|
+
type CommonParams = {
|
|
519
|
+
/**
|
|
520
|
+
* The object id about which pool you want to operation.
|
|
521
|
+
*/
|
|
522
|
+
pool_id: SuiObjectIdType;
|
|
523
|
+
/**
|
|
524
|
+
* The object id about position.
|
|
525
|
+
*/
|
|
526
|
+
pos_id: SuiObjectIdType;
|
|
527
|
+
};
|
|
528
|
+
type AddLiquidityFixTokenParams = {
|
|
529
|
+
/**
|
|
530
|
+
* If fixed amount A, you must set amount_a, amount_b will be auto calculated by ClmmPoolUtil.estLiquidityAndcoinAmountFromOneAmounts().
|
|
531
|
+
*/
|
|
532
|
+
amount_a: number | string;
|
|
533
|
+
/**
|
|
534
|
+
* If fixed amount B, you must set amount_b, amount_a will be auto calculated by ClmmPoolUtil.estLiquidityAndcoinAmountFromOneAmounts().
|
|
535
|
+
*/
|
|
536
|
+
amount_b: number | string;
|
|
537
|
+
/**
|
|
538
|
+
* Price slippage point.
|
|
539
|
+
*/
|
|
540
|
+
slippage: number;
|
|
541
|
+
/**
|
|
542
|
+
* true means fixed coinA amount, false means fixed coinB amount
|
|
543
|
+
*/
|
|
544
|
+
fix_amount_a: boolean;
|
|
545
|
+
/**
|
|
546
|
+
* control whether or not to create a new position or add liquidity on existed position.
|
|
547
|
+
*/
|
|
548
|
+
is_open: boolean;
|
|
549
|
+
} & AddLiquidityCommonParams;
|
|
550
|
+
type AddLiquidityParams = {
|
|
551
|
+
/**
|
|
552
|
+
* The actual change in liquidity that has been added.
|
|
553
|
+
*/
|
|
554
|
+
delta_liquidity: string;
|
|
555
|
+
/**
|
|
556
|
+
* The max limit about used coin a amount
|
|
557
|
+
*/
|
|
558
|
+
max_amount_a: number | string;
|
|
559
|
+
/**
|
|
560
|
+
* The max limit about used coin b amount.
|
|
561
|
+
*/
|
|
562
|
+
max_amount_b: number | string;
|
|
563
|
+
} & AddLiquidityCommonParams;
|
|
564
|
+
type AddLiquidityCommonParams = {
|
|
565
|
+
/**
|
|
566
|
+
* Represents the index of the lower tick boundary.
|
|
567
|
+
*/
|
|
568
|
+
tick_lower: string | number;
|
|
569
|
+
/**
|
|
570
|
+
* Represents the index of the upper tick boundary.
|
|
571
|
+
*/
|
|
572
|
+
tick_upper: string | number;
|
|
573
|
+
/**
|
|
574
|
+
* If you already has one position, you can select collect fees while adding liquidity.
|
|
575
|
+
*/
|
|
576
|
+
collect_fee: boolean;
|
|
577
|
+
/**
|
|
578
|
+
* If these not empty, it will collect rewarder in this position, if you already open the position.
|
|
579
|
+
*/
|
|
580
|
+
rewarder_coin_types: SuiAddressType[];
|
|
581
|
+
} & CoinPairType & CommonParams;
|
|
582
|
+
/**
|
|
583
|
+
* Parameters for opening a position within a liquidity pool.
|
|
584
|
+
* Extends the CoinPairType type.
|
|
585
|
+
*/
|
|
586
|
+
type OpenPositionParams = CoinPairType & {
|
|
587
|
+
/**
|
|
588
|
+
* The lower tick index for the position.
|
|
589
|
+
*/
|
|
590
|
+
tick_lower: string;
|
|
591
|
+
/**
|
|
592
|
+
* The upper tick index for the position.
|
|
593
|
+
*/
|
|
594
|
+
tick_upper: string;
|
|
595
|
+
/**
|
|
596
|
+
* The object identifier of the liquidity pool.
|
|
597
|
+
*/
|
|
598
|
+
pool_id: SuiObjectIdType;
|
|
599
|
+
};
|
|
600
|
+
/**
|
|
601
|
+
* Parameters for opening a position within a liquidity pool using full range.
|
|
602
|
+
*/
|
|
603
|
+
type FullRangeParams = {
|
|
604
|
+
is_full_range: true;
|
|
605
|
+
};
|
|
606
|
+
type CustomRangeParams = {
|
|
607
|
+
is_full_range: false;
|
|
608
|
+
min_price: string;
|
|
609
|
+
max_price: string;
|
|
610
|
+
coin_decimals_a: number;
|
|
611
|
+
coin_decimals_b: number;
|
|
612
|
+
price_base_coin: 'coin_a' | 'coin_b';
|
|
613
|
+
};
|
|
614
|
+
type CreatePoolCustomRangeParams = {
|
|
615
|
+
is_full_range: false;
|
|
616
|
+
min_price: string;
|
|
617
|
+
max_price: string;
|
|
618
|
+
};
|
|
619
|
+
type CalculateAddLiquidityWithPriceParams = {
|
|
620
|
+
pool_id: SuiObjectIdType;
|
|
621
|
+
liquidity: string;
|
|
622
|
+
slippage: number;
|
|
623
|
+
refresh_pool_price?: boolean;
|
|
624
|
+
add_mode_params: FullRangeParams | CustomRangeParams;
|
|
625
|
+
};
|
|
626
|
+
type CalculateAddLiquidityFixCoinWithPriceParams = {
|
|
627
|
+
pool_id: SuiObjectIdType;
|
|
628
|
+
coin_amount: string;
|
|
629
|
+
fix_amount_a: boolean;
|
|
630
|
+
slippage: number;
|
|
631
|
+
refresh_pool_price?: boolean;
|
|
632
|
+
add_mode_params: FullRangeParams | CustomRangeParams;
|
|
633
|
+
};
|
|
634
|
+
type CalculateAddLiquidityResult = {
|
|
635
|
+
coin_amount_a: string;
|
|
636
|
+
coin_amount_b: string;
|
|
637
|
+
coin_amount_limit_a: string;
|
|
638
|
+
coin_amount_limit_b: string;
|
|
639
|
+
liquidity: string;
|
|
640
|
+
tick_lower: number;
|
|
641
|
+
tick_upper: number;
|
|
642
|
+
fix_amount_a?: boolean;
|
|
643
|
+
};
|
|
644
|
+
type CalculateCreatePoolWithPriceParams = {
|
|
645
|
+
tick_spacing: number;
|
|
646
|
+
current_price: string;
|
|
647
|
+
coin_amount: string;
|
|
648
|
+
fix_amount_a: boolean;
|
|
649
|
+
slippage: number;
|
|
650
|
+
coin_decimals_a: number;
|
|
651
|
+
coin_decimals_b: number;
|
|
652
|
+
price_base_coin: 'coin_a' | 'coin_b';
|
|
653
|
+
add_mode_params: FullRangeParams | CreatePoolCustomRangeParams;
|
|
654
|
+
};
|
|
655
|
+
type CalculateCreatePoolResult = {
|
|
656
|
+
coin_amount_a: string;
|
|
657
|
+
coin_amount_b: string;
|
|
658
|
+
coin_amount_limit_a: string;
|
|
659
|
+
coin_amount_limit_b: string;
|
|
660
|
+
liquidity: string;
|
|
661
|
+
tick_lower: number;
|
|
662
|
+
tick_upper: number;
|
|
663
|
+
initialize_sqrt_price: string;
|
|
664
|
+
fix_amount_a: boolean;
|
|
665
|
+
};
|
|
666
|
+
type CreatePoolAddLiquidityWithPriceParams = {
|
|
667
|
+
tick_spacing: number;
|
|
668
|
+
uri?: string;
|
|
669
|
+
calculate_result: CalculateCreatePoolResult;
|
|
670
|
+
add_mode_params: FullRangeParams | CreatePoolCustomRangeParams;
|
|
671
|
+
} & CoinPairType;
|
|
672
|
+
/**
|
|
673
|
+
* Parameters for adding liquidity to a liquidity pool using price range.
|
|
674
|
+
*/
|
|
675
|
+
type AddLiquidityWithPriceRangeParams = {
|
|
676
|
+
/**
|
|
677
|
+
* The object identifier of the liquidity pool.
|
|
678
|
+
*/
|
|
679
|
+
pool_id: SuiObjectIdType;
|
|
680
|
+
/**
|
|
681
|
+
* The result of calculateAddLiquidityResultWithPrice.
|
|
682
|
+
*/
|
|
683
|
+
calculate_result: CalculateAddLiquidityResult;
|
|
684
|
+
/**
|
|
685
|
+
* The parameters of full range or custom range.
|
|
686
|
+
*/
|
|
687
|
+
add_mode_params: FullRangeParams | CustomRangeParams;
|
|
688
|
+
};
|
|
689
|
+
/**
|
|
690
|
+
* Parameters for opening a position within a liquidity pool using price range.
|
|
691
|
+
* Extends the CoinPairType type.
|
|
692
|
+
*/
|
|
693
|
+
type OpenPositionWithPriceParams = {
|
|
694
|
+
/**
|
|
695
|
+
* The object identifier of the liquidity pool.
|
|
696
|
+
*/
|
|
697
|
+
pool_id: SuiObjectIdType;
|
|
698
|
+
} & (FullRangeParams | CustomRangeParams);
|
|
699
|
+
/**
|
|
700
|
+
* Parameters for removing liquidity from a pool.
|
|
701
|
+
* Extends the CoinPairType and CommonParams types.
|
|
702
|
+
*/
|
|
703
|
+
type RemoveLiquidityParams = CoinPairType & CommonParams & {
|
|
704
|
+
/**
|
|
705
|
+
* The change in liquidity amount to be removed.
|
|
706
|
+
*/
|
|
707
|
+
delta_liquidity: string;
|
|
708
|
+
/**
|
|
709
|
+
* The minimum amount of the first coin to be received.
|
|
710
|
+
*/
|
|
711
|
+
min_amount_a: string;
|
|
712
|
+
/**
|
|
713
|
+
* The minimum amount of the second coin to be received.
|
|
714
|
+
*/
|
|
715
|
+
min_amount_b: string;
|
|
716
|
+
/**
|
|
717
|
+
* Indicates whether to collect fees during the removal.
|
|
718
|
+
*/
|
|
719
|
+
collect_fee: boolean;
|
|
720
|
+
/**
|
|
721
|
+
* Coin types associated with rewarder contracts.
|
|
722
|
+
*/
|
|
723
|
+
rewarder_coin_types: string[];
|
|
724
|
+
};
|
|
725
|
+
/**
|
|
726
|
+
* Parameters for closing a position within a liquidity pool.
|
|
727
|
+
* Extends the CoinPairType, CommonParams, and CommonParams types.
|
|
728
|
+
*/
|
|
729
|
+
type ClosePositionParams = CoinPairType & CommonParams & {
|
|
730
|
+
/**
|
|
731
|
+
* Coin types associated with rewarder contracts.
|
|
732
|
+
*/
|
|
733
|
+
rewarder_coin_types: SuiAddressType[];
|
|
734
|
+
/**
|
|
735
|
+
* The minimum amount of the first coin to be received.
|
|
736
|
+
*/
|
|
737
|
+
min_amount_a: string;
|
|
738
|
+
/**
|
|
739
|
+
* The minimum amount of the second coin to be received.
|
|
740
|
+
*/
|
|
741
|
+
min_amount_b: string;
|
|
742
|
+
/**
|
|
743
|
+
* Indicates whether to collect fees during the closing.
|
|
744
|
+
*/
|
|
745
|
+
collect_fee: boolean;
|
|
746
|
+
} & CoinPairType & CommonParams;
|
|
747
|
+
/**
|
|
748
|
+
* Represents parameters for collecting fees.
|
|
749
|
+
*/
|
|
750
|
+
type CollectFeeParams = CommonParams & CoinPairType;
|
|
751
|
+
/**
|
|
752
|
+
* Represents parameters for collecting rewarder fees.
|
|
753
|
+
*/
|
|
754
|
+
type CollectRewarderParams = {
|
|
755
|
+
/**
|
|
756
|
+
* The identifier of the pool.
|
|
757
|
+
*/
|
|
758
|
+
pool_id: SuiObjectIdType;
|
|
759
|
+
/**
|
|
760
|
+
* The identifier of the position.
|
|
761
|
+
*/
|
|
762
|
+
pos_id: SuiObjectIdType;
|
|
763
|
+
/**
|
|
764
|
+
* Specifies if the fee should be collected.
|
|
765
|
+
*/
|
|
766
|
+
collect_fee: boolean;
|
|
767
|
+
/**
|
|
768
|
+
* An array of rewarder coin types.
|
|
769
|
+
*/
|
|
770
|
+
rewarder_coin_types: SuiAddressType[];
|
|
771
|
+
} & CoinPairType;
|
|
772
|
+
/**
|
|
773
|
+
* Represents the amount owned by a rewarder.
|
|
774
|
+
*/
|
|
775
|
+
type RewarderAmountOwned = {
|
|
776
|
+
/**
|
|
777
|
+
* The amount owed.
|
|
778
|
+
*/
|
|
779
|
+
amount_owned: string;
|
|
780
|
+
/**
|
|
781
|
+
* The address of the coin.
|
|
782
|
+
*/
|
|
783
|
+
coin_type: string;
|
|
784
|
+
};
|
|
785
|
+
type PositionTransactionInfo = {
|
|
786
|
+
index: string;
|
|
787
|
+
tx_digest: string;
|
|
788
|
+
package_id: string;
|
|
789
|
+
transaction_module: string;
|
|
790
|
+
sender: string;
|
|
791
|
+
type: string;
|
|
792
|
+
timestamp_ms: string;
|
|
793
|
+
parsed_json: any;
|
|
794
|
+
};
|
|
795
|
+
type PoolTransactionInfo = {
|
|
796
|
+
index: string;
|
|
797
|
+
tx: string;
|
|
798
|
+
sender: string;
|
|
799
|
+
type: string;
|
|
800
|
+
block_time: string;
|
|
801
|
+
parsed_json: any;
|
|
802
|
+
};
|
|
803
|
+
declare const poolFilterEvenTypes: string[];
|
|
804
|
+
/**
|
|
805
|
+
* @category CollectFeesQuote
|
|
806
|
+
*/
|
|
807
|
+
type CollectFeesQuote = {
|
|
808
|
+
position_id: string;
|
|
809
|
+
fee_owned_a: string;
|
|
810
|
+
fee_owned_b: string;
|
|
811
|
+
};
|
|
812
|
+
type FetchPosRewardParams = {
|
|
813
|
+
pool_id: string;
|
|
814
|
+
position_id: string;
|
|
815
|
+
rewarder_types: string[];
|
|
816
|
+
} & CoinPairType;
|
|
817
|
+
type FetchPosFeeParams = {
|
|
818
|
+
pool_id: string;
|
|
819
|
+
position_id: string;
|
|
820
|
+
} & CoinPairType;
|
|
821
|
+
type PosRewarderResult = {
|
|
822
|
+
pool_id: string;
|
|
823
|
+
position_id: string;
|
|
824
|
+
rewarder_amounts: RewarderAmountOwned[];
|
|
825
|
+
};
|
|
826
|
+
/**
|
|
827
|
+
* If changes in liquidity are required before the swap, then this parameter should be passed.
|
|
828
|
+
*/
|
|
829
|
+
type PreSwapLpChangeParams = {
|
|
830
|
+
/**
|
|
831
|
+
* Unique identifier for the liquidity pool involved in the transaction.
|
|
832
|
+
*/
|
|
833
|
+
pool_id: string;
|
|
834
|
+
/**
|
|
835
|
+
* Lower bound of the liquidity range. In AMM models, like Uniswap V3, liquidity is provided within specific price ranges. This represents the lower limit of that range.
|
|
836
|
+
*/
|
|
837
|
+
tick_lower: number;
|
|
838
|
+
/**
|
|
839
|
+
* Upper bound of the liquidity range, corresponding to the lower bound. This defines the upper limit of the range where liquidity is provided.
|
|
840
|
+
*/
|
|
841
|
+
tick_upper: number;
|
|
842
|
+
/**
|
|
843
|
+
* The change in liquidity, which can be a large number and is thus represented as a string. It can be positive or negative, indicating an increase or decrease in liquidity.
|
|
844
|
+
*/
|
|
845
|
+
delta_liquidity: number;
|
|
846
|
+
/**
|
|
847
|
+
* A boolean value indicating whether the 'delta_liquidity' represents an increase (true) or decrease (false) in liquidity.
|
|
848
|
+
*/
|
|
849
|
+
is_increase: boolean;
|
|
850
|
+
};
|
|
851
|
+
/**
|
|
852
|
+
* Represents parameters for a pre-swap operation with multiple pools.
|
|
853
|
+
*/
|
|
854
|
+
type PreSwapWithMultiPoolParams = {
|
|
855
|
+
/**
|
|
856
|
+
* An array of pool addresses for the pre-swap.
|
|
857
|
+
*/
|
|
858
|
+
pool_ids: string[];
|
|
859
|
+
/**
|
|
860
|
+
* Specifies if the swap is from token A to token B.
|
|
861
|
+
*/
|
|
862
|
+
a2b: boolean;
|
|
863
|
+
/**
|
|
864
|
+
* Specifies if the swap amount is specified in token A.
|
|
865
|
+
*/
|
|
866
|
+
by_amount_in: boolean;
|
|
867
|
+
/**
|
|
868
|
+
* The swap amount.
|
|
869
|
+
*/
|
|
870
|
+
amount: string;
|
|
871
|
+
} & CoinPairType;
|
|
872
|
+
/**
|
|
873
|
+
* Represents parameters for a pre-swap operation.
|
|
874
|
+
*/
|
|
875
|
+
type PreSwapParams = {
|
|
876
|
+
/**
|
|
877
|
+
* The pool information for the pre-swap.
|
|
878
|
+
*/
|
|
879
|
+
pool: Pool;
|
|
880
|
+
/**
|
|
881
|
+
* The current square root price.
|
|
882
|
+
*/
|
|
883
|
+
current_sqrt_price: number;
|
|
884
|
+
/**
|
|
885
|
+
* The number of decimal places for token A.
|
|
886
|
+
*/
|
|
887
|
+
decimals_a: number;
|
|
888
|
+
/**
|
|
889
|
+
* The number of decimal places for token B.
|
|
890
|
+
*/
|
|
891
|
+
decimals_b: number;
|
|
892
|
+
/**
|
|
893
|
+
* Specifies if the swap is from token A to token B.
|
|
894
|
+
*/
|
|
895
|
+
a2b: boolean;
|
|
896
|
+
/**
|
|
897
|
+
* Specifies if the swap amount is specified in token A.
|
|
898
|
+
*/
|
|
899
|
+
by_amount_in: boolean;
|
|
900
|
+
/**
|
|
901
|
+
* The swap amount.
|
|
902
|
+
*/
|
|
903
|
+
amount: string;
|
|
904
|
+
} & CoinPairType;
|
|
905
|
+
/**
|
|
906
|
+
* Represents parameters for a transitional pre-swap operation with multiple pools.
|
|
907
|
+
*/
|
|
908
|
+
type TransPreSwapWithMultiPoolParams = {
|
|
909
|
+
/**
|
|
910
|
+
* The address of the pool for the transitional pre-swap.
|
|
911
|
+
*/
|
|
912
|
+
pool_address: string;
|
|
913
|
+
/**
|
|
914
|
+
* Specifies if the swap is from token A to token B.
|
|
915
|
+
*/
|
|
916
|
+
a2b: boolean;
|
|
917
|
+
/**
|
|
918
|
+
* Specifies if the swap amount is specified in token A.
|
|
919
|
+
*/
|
|
920
|
+
by_amount_in: boolean;
|
|
921
|
+
/**
|
|
922
|
+
* The swap amount.
|
|
923
|
+
*/
|
|
924
|
+
amount: string;
|
|
925
|
+
} & CoinPairType;
|
|
926
|
+
/**
|
|
927
|
+
* Represents parameters for calculating rates in a swap.
|
|
928
|
+
*/
|
|
929
|
+
type CalculateRatesParams = {
|
|
930
|
+
/**
|
|
931
|
+
* The number of decimal places for token A.
|
|
932
|
+
*/
|
|
933
|
+
decimals_a: number;
|
|
934
|
+
/**
|
|
935
|
+
* The number of decimal places for token B.
|
|
936
|
+
*/
|
|
937
|
+
decimals_b: number;
|
|
938
|
+
/**
|
|
939
|
+
* Specifies if the swap is from token A to token B.
|
|
940
|
+
*/
|
|
941
|
+
a2b: boolean;
|
|
942
|
+
/**
|
|
943
|
+
* Specifies if the swap amount is specified in token A.
|
|
944
|
+
*/
|
|
945
|
+
by_amount_in: boolean;
|
|
946
|
+
/**
|
|
947
|
+
* The amount to swap.
|
|
948
|
+
*/
|
|
949
|
+
amount: BN;
|
|
950
|
+
/**
|
|
951
|
+
* An array of tick data for swap ticks.
|
|
952
|
+
*/
|
|
953
|
+
swap_ticks: Array<TickData>;
|
|
954
|
+
/**
|
|
955
|
+
* The current pool information.
|
|
956
|
+
*/
|
|
957
|
+
current_pool: Pool;
|
|
958
|
+
};
|
|
959
|
+
/**
|
|
960
|
+
* Represents the result of calculating rates in a swap.
|
|
961
|
+
*/
|
|
962
|
+
type CalculateRatesResult = {
|
|
963
|
+
/**
|
|
964
|
+
* The estimated amount in token A.
|
|
965
|
+
*/
|
|
966
|
+
estimated_amount_in: BN;
|
|
967
|
+
/**
|
|
968
|
+
* The estimated amount in token B.
|
|
969
|
+
*/
|
|
970
|
+
estimated_amount_out: BN;
|
|
971
|
+
/**
|
|
972
|
+
* The estimated ending square root price.
|
|
973
|
+
*/
|
|
974
|
+
estimated_end_sqrt_price: BN;
|
|
975
|
+
/**
|
|
976
|
+
* The estimated fee amount.
|
|
977
|
+
*/
|
|
978
|
+
estimated_fee_amount: BN;
|
|
979
|
+
/**
|
|
980
|
+
* Indicates if the estimated amount exceeds the limit.
|
|
981
|
+
*/
|
|
982
|
+
is_exceed: boolean;
|
|
983
|
+
/**
|
|
984
|
+
* The extra compute limit.
|
|
985
|
+
*/
|
|
986
|
+
extra_compute_limit: number;
|
|
987
|
+
/**
|
|
988
|
+
* Specifies if the swap is from token A to token B.
|
|
989
|
+
*/
|
|
990
|
+
a2b: boolean;
|
|
991
|
+
/**
|
|
992
|
+
* Specifies if the swap amount is specified in token A.
|
|
993
|
+
*/
|
|
994
|
+
by_amount_in: boolean;
|
|
995
|
+
/**
|
|
996
|
+
* The amount to swap.
|
|
997
|
+
*/
|
|
998
|
+
amount: BN;
|
|
999
|
+
/**
|
|
1000
|
+
* The price impact percentage.
|
|
1001
|
+
*/
|
|
1002
|
+
price_impact_pct: number;
|
|
1003
|
+
};
|
|
1004
|
+
/**
|
|
1005
|
+
* Represents parameters for a swap operation.
|
|
1006
|
+
*/
|
|
1007
|
+
type SwapParams = {
|
|
1008
|
+
/**
|
|
1009
|
+
* The identifier of the pool.
|
|
1010
|
+
*/
|
|
1011
|
+
pool_id: SuiObjectIdType;
|
|
1012
|
+
/**
|
|
1013
|
+
* Specifies if the swap is from token A to token B.
|
|
1014
|
+
*/
|
|
1015
|
+
a2b: boolean;
|
|
1016
|
+
/**
|
|
1017
|
+
* Specifies if the swap amount is specified in token A.
|
|
1018
|
+
*/
|
|
1019
|
+
by_amount_in: boolean;
|
|
1020
|
+
/**
|
|
1021
|
+
* The swap amount.
|
|
1022
|
+
*/
|
|
1023
|
+
amount: string;
|
|
1024
|
+
/**
|
|
1025
|
+
* The amount limit for the swap.
|
|
1026
|
+
*/
|
|
1027
|
+
amount_limit: string;
|
|
1028
|
+
/**
|
|
1029
|
+
* The optional swap partner.
|
|
1030
|
+
*/
|
|
1031
|
+
swap_partner?: string;
|
|
1032
|
+
} & CoinPairType;
|
|
1033
|
+
type SwapGasEstimateArg = {
|
|
1034
|
+
by_amount_in: boolean;
|
|
1035
|
+
slippage: Percentage;
|
|
1036
|
+
decimals_a: number;
|
|
1037
|
+
decimals_b: number;
|
|
1038
|
+
swap_ticks: Array<TickData>;
|
|
1039
|
+
current_pool: Pool;
|
|
1040
|
+
};
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* Represents configurations specific to the Cetus protocol.
|
|
1044
|
+
*/
|
|
1045
|
+
type CetusConfigs = {
|
|
1046
|
+
/**
|
|
1047
|
+
* The object identifier of the coin list.
|
|
1048
|
+
*/
|
|
1049
|
+
coin_list_id: SuiObjectIdType;
|
|
1050
|
+
/**
|
|
1051
|
+
* The object identifier of the coin list handle.
|
|
1052
|
+
*/
|
|
1053
|
+
coin_list_handle: SuiObjectIdType;
|
|
1054
|
+
/**
|
|
1055
|
+
* The object identifier of the launchpad pools.
|
|
1056
|
+
*/
|
|
1057
|
+
launchpad_pools_id: SuiObjectIdType;
|
|
1058
|
+
/**
|
|
1059
|
+
* The object identifier of the launchpad pools handle.
|
|
1060
|
+
*/
|
|
1061
|
+
launchpad_pools_handle: SuiObjectIdType;
|
|
1062
|
+
/**
|
|
1063
|
+
* The object identifier of the CLMM (Cryptocurrency Liquidity Mining Module) pools.
|
|
1064
|
+
*/
|
|
1065
|
+
clmm_pools_id: SuiObjectIdType;
|
|
1066
|
+
/**
|
|
1067
|
+
* The object identifier of the CLMM pools handle.
|
|
1068
|
+
*/
|
|
1069
|
+
clmm_pools_handle: SuiObjectIdType;
|
|
1070
|
+
/**
|
|
1071
|
+
* The object identifier of the admin cap.
|
|
1072
|
+
*/
|
|
1073
|
+
admin_cap_id: SuiObjectIdType;
|
|
1074
|
+
/**
|
|
1075
|
+
* The object identifier of the global configuration.
|
|
1076
|
+
*/
|
|
1077
|
+
global_config_id: SuiObjectIdType;
|
|
1078
|
+
};
|
|
1079
|
+
/**
|
|
1080
|
+
* Represents configuration data for a cryptocurrency coin.
|
|
1081
|
+
*/
|
|
1082
|
+
type CoinConfig = {
|
|
1083
|
+
/**
|
|
1084
|
+
* The unique identifier of the coin.
|
|
1085
|
+
*/
|
|
1086
|
+
id: string;
|
|
1087
|
+
/**
|
|
1088
|
+
* The name of the coin.
|
|
1089
|
+
*/
|
|
1090
|
+
name: string;
|
|
1091
|
+
/**
|
|
1092
|
+
* The symbol of the coin.
|
|
1093
|
+
*/
|
|
1094
|
+
symbol: string;
|
|
1095
|
+
/**
|
|
1096
|
+
* The address associated with the coin.
|
|
1097
|
+
*/
|
|
1098
|
+
address: string;
|
|
1099
|
+
/**
|
|
1100
|
+
* The Pyth identifier of the coin.
|
|
1101
|
+
*/
|
|
1102
|
+
pyth_id: string;
|
|
1103
|
+
/**
|
|
1104
|
+
* The project URL related to the coin.
|
|
1105
|
+
*/
|
|
1106
|
+
project_url: string;
|
|
1107
|
+
/**
|
|
1108
|
+
* The URL to the logo image of the coin.
|
|
1109
|
+
*/
|
|
1110
|
+
logo_url: string;
|
|
1111
|
+
/**
|
|
1112
|
+
* The number of decimal places used for the coin.
|
|
1113
|
+
*/
|
|
1114
|
+
decimals: number;
|
|
1115
|
+
} & Record<string, any>;
|
|
1116
|
+
/**
|
|
1117
|
+
* Represents configuration data for a CLMM pool.
|
|
1118
|
+
*/
|
|
1119
|
+
type ClmmPoolConfig = {
|
|
1120
|
+
/**
|
|
1121
|
+
* The unique identifier of the CLMM pool.
|
|
1122
|
+
*/
|
|
1123
|
+
id: string;
|
|
1124
|
+
/**
|
|
1125
|
+
* Indicates if the CLMM pool is closed.
|
|
1126
|
+
*/
|
|
1127
|
+
is_closed: boolean;
|
|
1128
|
+
/**
|
|
1129
|
+
* Indicates if the rewarder for the CLMM pool is shown.
|
|
1130
|
+
*/
|
|
1131
|
+
is_show_rewarder: boolean;
|
|
1132
|
+
/**
|
|
1133
|
+
* The address of the CLMM pool.
|
|
1134
|
+
*/
|
|
1135
|
+
pool_address: string;
|
|
1136
|
+
/**
|
|
1137
|
+
* The type of the CLMM pool.
|
|
1138
|
+
*/
|
|
1139
|
+
pool_type: string;
|
|
1140
|
+
/**
|
|
1141
|
+
* The project URL related to the CLMM pool.
|
|
1142
|
+
*/
|
|
1143
|
+
project_url: string;
|
|
1144
|
+
/**
|
|
1145
|
+
* Indicates if rewarder 1 is shown for the CLMM pool.
|
|
1146
|
+
*/
|
|
1147
|
+
show_rewarder_1: boolean;
|
|
1148
|
+
/**
|
|
1149
|
+
* Indicates if rewarder 2 is shown for the CLMM pool.
|
|
1150
|
+
*/
|
|
1151
|
+
show_rewarder_2: boolean;
|
|
1152
|
+
/**
|
|
1153
|
+
* Indicates if rewarder 3 is shown for the CLMM pool.
|
|
1154
|
+
*/
|
|
1155
|
+
show_rewarder_3: boolean;
|
|
1156
|
+
} & Record<string, any>;
|
|
1157
|
+
/**
|
|
1158
|
+
* Represents configuration data for a launchpad pool.
|
|
1159
|
+
*/
|
|
1160
|
+
type LaunchpadPoolConfig = {
|
|
1161
|
+
/**
|
|
1162
|
+
* The object identifier of the launchpad pool.
|
|
1163
|
+
*/
|
|
1164
|
+
id: SuiObjectIdType;
|
|
1165
|
+
/**
|
|
1166
|
+
* Indicates if the settlement is shown for the launchpad pool.
|
|
1167
|
+
*/
|
|
1168
|
+
show_settle: boolean;
|
|
1169
|
+
/**
|
|
1170
|
+
* The symbol of the coin associated with the launchpad pool.
|
|
1171
|
+
*/
|
|
1172
|
+
coin_symbol: string;
|
|
1173
|
+
/**
|
|
1174
|
+
* The name of the coin associated with the launchpad pool.
|
|
1175
|
+
*/
|
|
1176
|
+
coin_name: string;
|
|
1177
|
+
/**
|
|
1178
|
+
* The icon of the coin associated with the launchpad pool.
|
|
1179
|
+
*/
|
|
1180
|
+
coin_icon: string;
|
|
1181
|
+
/**
|
|
1182
|
+
* An array of banner URLs for the launchpad pool.
|
|
1183
|
+
*/
|
|
1184
|
+
banners: string[];
|
|
1185
|
+
/**
|
|
1186
|
+
* The introduction text for the launchpad pool.
|
|
1187
|
+
*/
|
|
1188
|
+
introduction: string;
|
|
1189
|
+
/**
|
|
1190
|
+
* Indicates if the launchpad pool is closed.
|
|
1191
|
+
*/
|
|
1192
|
+
is_closed: boolean;
|
|
1193
|
+
/**
|
|
1194
|
+
* The address of the launchpad pool.
|
|
1195
|
+
*/
|
|
1196
|
+
pool_address: string;
|
|
1197
|
+
/**
|
|
1198
|
+
* The project details for the launchpad pool.
|
|
1199
|
+
*/
|
|
1200
|
+
project_details: string;
|
|
1201
|
+
/**
|
|
1202
|
+
* The regulation details for the launchpad pool.
|
|
1203
|
+
*/
|
|
1204
|
+
regulation: string;
|
|
1205
|
+
/**
|
|
1206
|
+
* An array of social media links for the launchpad pool.
|
|
1207
|
+
*/
|
|
1208
|
+
social_media: {
|
|
1209
|
+
name: string;
|
|
1210
|
+
link: string;
|
|
1211
|
+
}[];
|
|
1212
|
+
/**
|
|
1213
|
+
* The terms and conditions for the launchpad pool.
|
|
1214
|
+
*/
|
|
1215
|
+
terms: string;
|
|
1216
|
+
/**
|
|
1217
|
+
* The tokenomics information for the launchpad pool.
|
|
1218
|
+
*/
|
|
1219
|
+
tokenomics: string;
|
|
1220
|
+
/**
|
|
1221
|
+
* The website URL for the launchpad pool.
|
|
1222
|
+
*/
|
|
1223
|
+
website: string;
|
|
1224
|
+
/**
|
|
1225
|
+
* The terms and conditions for the white list of the launchpad pool.
|
|
1226
|
+
*/
|
|
1227
|
+
white_list_terms: string;
|
|
1228
|
+
} & Record<string, any>;
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* Constants for different modules in the CLMM (Cryptocurrency Liquidity Mining Module).
|
|
1232
|
+
*/
|
|
1233
|
+
declare const ClmmPartnerModule = "partner";
|
|
1234
|
+
declare const ClmmIntegratePoolModule = "pool_script";
|
|
1235
|
+
declare const ClmmIntegratePoolV2Module = "pool_script_v2";
|
|
1236
|
+
declare const ClmmIntegratePoolV3Module = "pool_script_v3";
|
|
1237
|
+
declare const ClmmIntegrateRouterModule = "router";
|
|
1238
|
+
declare const ClmmIntegrateRouterWithPartnerModule = "router_with_partner";
|
|
1239
|
+
declare const ClmmFetcherModule = "fetcher_script";
|
|
1240
|
+
declare const ClmmExpectSwapModule = "expect_swap";
|
|
1241
|
+
declare const ClmmIntegrateUtilsModule = "utils";
|
|
1242
|
+
declare const DeepbookCustodianV2Module = "custodian_v2";
|
|
1243
|
+
declare const DeepbookClobV2Module = "clob_v2";
|
|
1244
|
+
declare const DeepbookEndpointsV2Module = "endpoints_v2";
|
|
1245
|
+
/**
|
|
1246
|
+
* Represents a Non-Fungible Token (NFT) with associated metadata.
|
|
1247
|
+
*/
|
|
1248
|
+
type NFT = {
|
|
1249
|
+
/**
|
|
1250
|
+
* The address or identifier of the creator of the NFT.
|
|
1251
|
+
*/
|
|
1252
|
+
creator: string;
|
|
1253
|
+
/**
|
|
1254
|
+
* A description providing additional information about the NFT.
|
|
1255
|
+
*/
|
|
1256
|
+
description: string;
|
|
1257
|
+
/**
|
|
1258
|
+
* The URL to the image representing the NFT visually.
|
|
1259
|
+
*/
|
|
1260
|
+
image_url: string;
|
|
1261
|
+
/**
|
|
1262
|
+
* A link associated with the NFT, providing more details or interactions.
|
|
1263
|
+
*/
|
|
1264
|
+
link: string;
|
|
1265
|
+
/**
|
|
1266
|
+
* The name or title of the NFT.
|
|
1267
|
+
*/
|
|
1268
|
+
name: string;
|
|
1269
|
+
/**
|
|
1270
|
+
* The URL to the project or collection associated with the NFT.
|
|
1271
|
+
*/
|
|
1272
|
+
project_url: string;
|
|
1273
|
+
};
|
|
1274
|
+
/**
|
|
1275
|
+
* Represents a SUI struct tag.
|
|
1276
|
+
*/
|
|
1277
|
+
type SuiStructTag = {
|
|
1278
|
+
/**
|
|
1279
|
+
* The full address of the struct.
|
|
1280
|
+
*/
|
|
1281
|
+
full_address: string;
|
|
1282
|
+
/**
|
|
1283
|
+
* The source address of the struct.
|
|
1284
|
+
*/
|
|
1285
|
+
source_address: string;
|
|
1286
|
+
/**
|
|
1287
|
+
* The address of the struct.
|
|
1288
|
+
*/
|
|
1289
|
+
address: SuiAddressType;
|
|
1290
|
+
/**
|
|
1291
|
+
* The module to which the struct belongs.
|
|
1292
|
+
*/
|
|
1293
|
+
module: string;
|
|
1294
|
+
/**
|
|
1295
|
+
* The name of the struct.
|
|
1296
|
+
*/
|
|
1297
|
+
name: string;
|
|
1298
|
+
/**
|
|
1299
|
+
* An array of type arguments (SUI addresses) for the struct.
|
|
1300
|
+
*/
|
|
1301
|
+
type_arguments: SuiAddressType[];
|
|
1302
|
+
};
|
|
1303
|
+
/**
|
|
1304
|
+
* Represents basic SUI data types.
|
|
1305
|
+
*/
|
|
1306
|
+
type SuiBasicTypes = 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256';
|
|
1307
|
+
/**
|
|
1308
|
+
* Represents a SUI transaction argument, which can be of various types.
|
|
1309
|
+
*/
|
|
1310
|
+
type SuiTxArg = TransactionArgument | string | number | bigint | boolean;
|
|
1311
|
+
/**
|
|
1312
|
+
* Represents input types for SUI data.
|
|
1313
|
+
*/
|
|
1314
|
+
type SuiInputTypes = 'object' | SuiBasicTypes;
|
|
1315
|
+
/**
|
|
1316
|
+
* Gets the default SUI input type based on the provided value.
|
|
1317
|
+
* @param value - The value to determine the default input type for.
|
|
1318
|
+
* @returns The default SUI input type.
|
|
1319
|
+
* @throws Error if the type of the value is unknown.
|
|
1320
|
+
*/
|
|
1321
|
+
declare const getDefaultSuiInputType: (value: any) => SuiInputTypes;
|
|
1322
|
+
|
|
1323
|
+
type BigNumber = Decimal.Value | number | string;
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* Helper class to help interact with clmm pool and coin and launchpad pool config.
|
|
1327
|
+
*/
|
|
1328
|
+
declare class ConfigModule implements IModule<CetusClmmSDK> {
|
|
1329
|
+
protected _sdk: CetusClmmSDK;
|
|
1330
|
+
private readonly _cache;
|
|
1331
|
+
constructor(sdk: CetusClmmSDK);
|
|
1332
|
+
get sdk(): CetusClmmSDK;
|
|
1333
|
+
/**
|
|
1334
|
+
* Set default token list cache.
|
|
1335
|
+
* @param {CoinConfig[]}coin_list
|
|
1336
|
+
*/
|
|
1337
|
+
setTokenListCache(coin_list: CoinConfig[]): void;
|
|
1338
|
+
/**
|
|
1339
|
+
* Get token config list by coin type list.
|
|
1340
|
+
* @param {SuiAddressType[]} coin_types Coin type list.
|
|
1341
|
+
* @returns {Promise<Record<string, CoinConfig>>} Token config map.
|
|
1342
|
+
*/
|
|
1343
|
+
getTokenListByCoinTypes(coin_types: SuiAddressType[]): Promise<Record<string, CoinConfig>>;
|
|
1344
|
+
/**
|
|
1345
|
+
* Get coin config list.
|
|
1346
|
+
* @param {boolean} force_refresh Whether to force a refresh of the cache entry.
|
|
1347
|
+
* @param {boolean} transform_extensions Whether to transform extensions.
|
|
1348
|
+
* @returns {Promise<CoinConfig[]>} Coin config list.
|
|
1349
|
+
*/
|
|
1350
|
+
getCoinConfigs(force_refresh?: boolean, transform_extensions?: boolean): Promise<CoinConfig[]>;
|
|
1351
|
+
/**
|
|
1352
|
+
* Get coin config by coin type.
|
|
1353
|
+
* @param {string} coin_type Coin type.
|
|
1354
|
+
* @param {boolean} force_refresh Whether to force a refresh of the cache entry.
|
|
1355
|
+
* @param {boolean} transform_extensions Whether to transform extensions.
|
|
1356
|
+
* @returns {Promise<CoinConfig>} Coin config.
|
|
1357
|
+
*/
|
|
1358
|
+
getCoinConfig(coin_type: string, force_refresh?: boolean, transform_extensions?: boolean): Promise<CoinConfig>;
|
|
1359
|
+
/**
|
|
1360
|
+
* Build coin config.
|
|
1361
|
+
* @param {SuiObjectResponse} object Coin object.
|
|
1362
|
+
* @param {boolean} transform_extensions Whether to transform extensions.
|
|
1363
|
+
* @returns {CoinConfig} Coin config.
|
|
1364
|
+
*/
|
|
1365
|
+
private buildCoinConfig;
|
|
1366
|
+
/**
|
|
1367
|
+
* Get clmm pool config list.
|
|
1368
|
+
* @param force_refresh
|
|
1369
|
+
* @param transform_extensions
|
|
1370
|
+
* @returns
|
|
1371
|
+
*/
|
|
1372
|
+
getClmmPoolConfigs(force_refresh?: boolean, transform_extensions?: boolean): Promise<ClmmPoolConfig[]>;
|
|
1373
|
+
getClmmPoolConfig(pool_id: string, force_refresh?: boolean, transform_extensions?: boolean): Promise<ClmmPoolConfig>;
|
|
1374
|
+
private buildClmmPoolConfig;
|
|
1375
|
+
/**
|
|
1376
|
+
* Get launchpad pool config list.
|
|
1377
|
+
* @param force_refresh
|
|
1378
|
+
* @returns
|
|
1379
|
+
*/
|
|
1380
|
+
getLaunchpadPoolConfigs(force_refresh?: boolean, transform_extensions?: boolean): Promise<LaunchpadPoolConfig[]>;
|
|
1381
|
+
getLaunchpadPoolConfig(pool_id: string, force_refresh?: boolean, transform_extensions?: boolean): Promise<LaunchpadPoolConfig>;
|
|
1382
|
+
private buildLaunchpadPoolConfig;
|
|
1383
|
+
private transformExtensions;
|
|
1384
|
+
/**
|
|
1385
|
+
* Get the token config event.
|
|
1386
|
+
*
|
|
1387
|
+
* @param force_refresh Whether to force a refresh of the event.
|
|
1388
|
+
* @returns The token config event.
|
|
1389
|
+
*/
|
|
1390
|
+
getCetusConfig(force_refresh?: boolean): Promise<CetusConfigs>;
|
|
1391
|
+
private getCetusConfigHandle;
|
|
1392
|
+
/**
|
|
1393
|
+
* Updates the cache for the given key.
|
|
1394
|
+
* @param key The key of the cache entry to update.
|
|
1395
|
+
* @param data The data to store in the cache.
|
|
1396
|
+
* @param time The time in minutes after which the cache entry should expire.
|
|
1397
|
+
*/
|
|
1398
|
+
updateCache(key: string, data: SuiResource, time?: number): void;
|
|
1399
|
+
/**
|
|
1400
|
+
* Gets the cache entry for the given key.
|
|
1401
|
+
* @param key The key of the cache entry to get.
|
|
1402
|
+
* @param force_refresh Whether to force a refresh of the cache entry.
|
|
1403
|
+
* @returns The cache entry for the given key, or undefined if the cache entry does not exist or is expired.
|
|
1404
|
+
*/
|
|
1405
|
+
getCache<T>(key: string, force_refresh?: boolean): T | undefined;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
type CreatePoolAndAddLiquidityRowResult = {
|
|
1409
|
+
pos_id: TransactionObjectArgument;
|
|
1410
|
+
remain_coin_a: TransactionObjectArgument;
|
|
1411
|
+
remain_coin_b: TransactionObjectArgument;
|
|
1412
|
+
tx: Transaction;
|
|
1413
|
+
remain_coin_type_a: string;
|
|
1414
|
+
remain_coin_type_b: string;
|
|
1415
|
+
};
|
|
1416
|
+
/**
|
|
1417
|
+
* Helper class to help interact with clmm pools with a pool router interface.
|
|
1418
|
+
*/
|
|
1419
|
+
declare class PoolModule implements IModule<CetusClmmSDK> {
|
|
1420
|
+
protected _sdk: CetusClmmSDK;
|
|
1421
|
+
constructor(sdk: CetusClmmSDK);
|
|
1422
|
+
get sdk(): CetusClmmSDK;
|
|
1423
|
+
/**
|
|
1424
|
+
* Gets a list of positions for the given positionHandle.
|
|
1425
|
+
* @param {string} position_handle The handle for the position.
|
|
1426
|
+
* @returns {DataPage<Position>} A promise that resolves to an array of Position objects.
|
|
1427
|
+
*/
|
|
1428
|
+
getPositionList(position_handle: string, pagination_args?: PaginationArgs): Promise<DataPage<Position>>;
|
|
1429
|
+
/**
|
|
1430
|
+
* Gets a list of pool immutables.
|
|
1431
|
+
* @param {PaginationArgs} paginationArgs The cursor and limit to start at.
|
|
1432
|
+
* @returns {Promise<DataPage<PoolImmutables>>} Array of PoolImmutable objects.
|
|
1433
|
+
*/
|
|
1434
|
+
getPoolImmutablesWithPage(pagination_args?: PaginationArgs, force_refresh?: boolean): Promise<DataPage<PoolImmutables>>;
|
|
1435
|
+
/**
|
|
1436
|
+
* Gets a list of pools.
|
|
1437
|
+
* @param {PaginationArgs} pagination_args The cursor and limit to start at.
|
|
1438
|
+
* @param {boolean} force_refresh Whether to force a refresh of the cache.
|
|
1439
|
+
* @returns {Promise<Pool[]>} An array of Pool objects.
|
|
1440
|
+
*/
|
|
1441
|
+
getPoolsWithPage(pagination_args?: PaginationArgs, force_refresh?: boolean): Promise<DataPage<Pool>>;
|
|
1442
|
+
/**
|
|
1443
|
+
* Gets a list of pools.
|
|
1444
|
+
* @param {string[]} assign_pools An array of pool ID to get.
|
|
1445
|
+
* @returns {Promise<Pool[]>} array of Pool objects.
|
|
1446
|
+
*/
|
|
1447
|
+
getAssignPools(assign_pools: string[]): Promise<Pool[]>;
|
|
1448
|
+
/**
|
|
1449
|
+
* Gets a pool by its object ID.
|
|
1450
|
+
* @param {string} pool_id The object ID of the pool to get.
|
|
1451
|
+
* @param {true} force_refresh Whether to force a refresh of the cache.
|
|
1452
|
+
* @returns {Promise<Pool>} A promise that resolves to a Pool object.
|
|
1453
|
+
*/
|
|
1454
|
+
getPool(pool_id: string, force_refresh?: boolean): Promise<Pool>;
|
|
1455
|
+
getPoolByCoins(coins: string[], fee_rate?: number): Promise<Pool[]>;
|
|
1456
|
+
/**
|
|
1457
|
+
* Create a pool of clmmpool protocol. The pool is identified by (CoinTypeA, CoinTypeB, tick_spacing).
|
|
1458
|
+
* @param {CreatePoolParams | CreatePoolAddLiquidityParams} params
|
|
1459
|
+
* @returns {Promise<Transaction>}
|
|
1460
|
+
*/
|
|
1461
|
+
createPoolPayload(params: CreatePoolAddLiquidityParams, tx?: Transaction): Promise<Transaction>;
|
|
1462
|
+
/**
|
|
1463
|
+
* Create pool and add liquidity row. It will call `pool_creator_v2::create_pool_v2` function.
|
|
1464
|
+
* This method will return the position, coin_a, coin_b. User can use these to build own transaction.
|
|
1465
|
+
* @param {CreatePoolAddLiquidityParams}params The parameters for the create and liquidity.
|
|
1466
|
+
* @returns {Promise<CreatePoolAndAddLiquidityRowResult>} A promise that resolves to the transaction payload.
|
|
1467
|
+
*/
|
|
1468
|
+
createPoolRowPayload(params: CreatePoolAddLiquidityParams, tx?: Transaction): Promise<CreatePoolAndAddLiquidityRowResult>;
|
|
1469
|
+
/**
|
|
1470
|
+
* Gets the ClmmConfig object for the given package object ID.
|
|
1471
|
+
* @param {boolean} force_refresh Whether to force a refresh of the cache.
|
|
1472
|
+
* @returns the ClmmConfig object.
|
|
1473
|
+
*/
|
|
1474
|
+
getClmmConfigs(force_refresh?: boolean): Promise<ClmmConfig>;
|
|
1475
|
+
getPoolTransactionList({ pool_id, pagination_args, order, full_rpc_url, }: {
|
|
1476
|
+
pool_id: string;
|
|
1477
|
+
full_rpc_url?: string;
|
|
1478
|
+
pagination_args: PageQuery;
|
|
1479
|
+
order?: 'ascending' | 'descending' | null | undefined;
|
|
1480
|
+
}): Promise<DataPage<PoolTransactionInfo>>;
|
|
1481
|
+
calculateCreatePoolWithPrice(params: CalculateCreatePoolWithPriceParams): Promise<CalculateCreatePoolResult>;
|
|
1482
|
+
/**
|
|
1483
|
+
* Create pool and add liquidity internal. It will call `pool_creator_v2::create_pool_v2` function in cetus integrate contract.
|
|
1484
|
+
* It encapsulates the original create_pool_v2 method from the Cetus CLMM and processes the additional outputs for position and coin within a single move call.
|
|
1485
|
+
* @param {CreatePoolAddLiquidityParams}params The parameters for the create and liquidity.
|
|
1486
|
+
* @returns {Promise<Transaction>} A promise that resolves to the transaction payload.
|
|
1487
|
+
*/
|
|
1488
|
+
private createPoolAndAddLiquidity;
|
|
1489
|
+
/**
|
|
1490
|
+
* Create pool and add liquidity row. It will call `pool_creator_v2::create_pool_v2` function.
|
|
1491
|
+
* This method will return the position, coin_a, coin_b. User can use these to build own transaction.
|
|
1492
|
+
* @param {CreatePoolAddLiquidityParams}params The parameters for the create and liquidity.
|
|
1493
|
+
* @returns {Promise<Transaction>} A promise that resolves to the transaction payload.
|
|
1494
|
+
*/
|
|
1495
|
+
private createPoolAndAddLiquidityRow;
|
|
1496
|
+
createPoolWithPriceReturnPositionPayload(params: CreatePoolAddLiquidityWithPriceParams, tx?: Transaction): Promise<CreatePoolAndAddLiquidityRowResult>;
|
|
1497
|
+
createPoolWithPricePayload(params: CreatePoolAddLiquidityWithPriceParams): Promise<Transaction>;
|
|
1498
|
+
/**
|
|
1499
|
+
* Fetches ticks from the exchange.
|
|
1500
|
+
* @param {FetchParams} params The parameters for the fetch.
|
|
1501
|
+
* @returns {Promise<TickData[]>} A promise that resolves to an array of tick data.
|
|
1502
|
+
*/
|
|
1503
|
+
fetchTicks(params: FetchParams): Promise<TickData[]>;
|
|
1504
|
+
/**
|
|
1505
|
+
* Fetches ticks from the exchange using the simulation exec tx.
|
|
1506
|
+
* @param {GetTickParams} params The parameters for the fetch.
|
|
1507
|
+
* @returns {Promise<TickData[]>} A promise that resolves to an array of tick data.
|
|
1508
|
+
*/
|
|
1509
|
+
private getTicks;
|
|
1510
|
+
/**
|
|
1511
|
+
* Fetches a list of position rewards from the exchange.
|
|
1512
|
+
* @param {FetchParams} params The parameters for the fetch.
|
|
1513
|
+
* @returns {Promise<PositionReward[]>} A promise that resolves to an array of position rewards.
|
|
1514
|
+
*/
|
|
1515
|
+
fetchPositionRewardList(params: FetchParams): Promise<PositionReward[]>;
|
|
1516
|
+
/**
|
|
1517
|
+
* Fetches ticks from the fullnode using the RPC API.
|
|
1518
|
+
* @param {string} tick_handle The handle for the tick. Get tick handle from `sdk.Pool.getPool()`
|
|
1519
|
+
* @returns {Promise<TickData[]>} A promise that resolves to an array of tick data.
|
|
1520
|
+
*/
|
|
1521
|
+
fetchTicksByRpc(tick_handle: string): Promise<TickData[]>;
|
|
1522
|
+
/**
|
|
1523
|
+
* Get ticks by tick object ids.
|
|
1524
|
+
* @param {string} tick_object_id The object ids of the ticks.
|
|
1525
|
+
* @returns {Promise<TickData[]>} A promise that resolves to an array of tick data.
|
|
1526
|
+
*/
|
|
1527
|
+
private getTicksByRpc;
|
|
1528
|
+
/**
|
|
1529
|
+
* Gets the tick data for the given tick index.
|
|
1530
|
+
* @param {string} tick_handle The handle for the tick.
|
|
1531
|
+
* @param {number} tick_index The index of the tick.
|
|
1532
|
+
* @returns {Promise<TickData | null>} A promise that resolves to the tick data.
|
|
1533
|
+
*/
|
|
1534
|
+
getTickDataByIndex(tick_handle: string, tick_index: number): Promise<TickData>;
|
|
1535
|
+
/**
|
|
1536
|
+
* Gets the tick data for the given object ID.
|
|
1537
|
+
* @param {string} tick_id The object ID of the tick.
|
|
1538
|
+
* @returns {Promise<TickData | null>} A promise that resolves to the tick data.
|
|
1539
|
+
*/
|
|
1540
|
+
getTickDataByObjectId(tick_id: string): Promise<TickData | null>;
|
|
1541
|
+
/**
|
|
1542
|
+
* Get partner ref fee amount
|
|
1543
|
+
* @param {string}partner Partner object id
|
|
1544
|
+
* @returns {Promise<CoinAsset[]>} A promise that resolves to an array of coin asset.
|
|
1545
|
+
*/
|
|
1546
|
+
getPartnerRefFeeAmount(partner: string, show_display?: boolean): Promise<CoinAsset[]>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Claim partner ref fee.
|
|
1549
|
+
* @param {string} partner_cap partner cap id.
|
|
1550
|
+
* @param {string} partner partner id.
|
|
1551
|
+
* @param {string} coin_type coin type.
|
|
1552
|
+
* @returns {Promise<Transaction>} A promise that resolves to the transaction payload.
|
|
1553
|
+
*/
|
|
1554
|
+
claimPartnerRefFeePayload(partner_cap: string, partner: string, coin_type: string): Promise<Transaction>;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* Helper class to help interact with clmm position with a position router interface.
|
|
1559
|
+
*/
|
|
1560
|
+
declare class PositionModule implements IModule<CetusClmmSDK> {
|
|
1561
|
+
protected _sdk: CetusClmmSDK;
|
|
1562
|
+
constructor(sdk: CetusClmmSDK);
|
|
1563
|
+
get sdk(): CetusClmmSDK;
|
|
1564
|
+
/**
|
|
1565
|
+
* Builds the full address of the Position type.
|
|
1566
|
+
* @returns The full address of the Position type.
|
|
1567
|
+
*/
|
|
1568
|
+
buildPositionType(): string;
|
|
1569
|
+
/**
|
|
1570
|
+
* Gets a list of position transaction information for the given position ID.
|
|
1571
|
+
* @param {Object} params - The parameters for the position transaction list.
|
|
1572
|
+
* @param {string} params.pos_id - The ID of the position to get transactions for.
|
|
1573
|
+
* @param {PaginationArgs} [params.pagination_args] - The pagination arguments for the transaction list.
|
|
1574
|
+
* @param {string} [params.order] - The order of the transaction list.
|
|
1575
|
+
* @param {string} [params.full_rpc_url] - The full RPC URL for the transaction list.
|
|
1576
|
+
* @param {string} [params.origin_pos_id] - The origin position ID for the transaction list.
|
|
1577
|
+
* @returns {Promise<DataPage<PositionTransactionInfo>>} A promise that resolves to a DataPage object containing the position transaction information.
|
|
1578
|
+
*/
|
|
1579
|
+
getPositionTransactionList({ pos_id, origin_pos_id, full_rpc_url, pagination_args, order, }: {
|
|
1580
|
+
pos_id: string;
|
|
1581
|
+
origin_pos_id?: string;
|
|
1582
|
+
full_rpc_url?: string;
|
|
1583
|
+
pagination_args?: PaginationArgs;
|
|
1584
|
+
order?: 'ascending' | 'descending' | null | undefined;
|
|
1585
|
+
}): Promise<DataPage<PositionTransactionInfo>>;
|
|
1586
|
+
/**
|
|
1587
|
+
* Gets a list of positions for the given account address.
|
|
1588
|
+
* @param account_address The account address to get positions for.
|
|
1589
|
+
* @param assign_pool_ids An array of pool ID to filter the positions by.
|
|
1590
|
+
* @returns array of Position objects.
|
|
1591
|
+
*/
|
|
1592
|
+
getPositionList(account_address: string, assign_pool_ids?: string[], show_display?: boolean): Promise<Position[]>;
|
|
1593
|
+
/**
|
|
1594
|
+
* Gets a position by its handle and ID. But it needs pool info, so it is not recommended to use this method.
|
|
1595
|
+
* if you want to get a position, you can use getPositionById method directly.
|
|
1596
|
+
* @param {string} position_handle The handle of the position to get.
|
|
1597
|
+
* @param {string} position_id The ID of the position to get.
|
|
1598
|
+
* @param {boolean} calculate_rewarder Whether to calculate the rewarder of the position.
|
|
1599
|
+
* @returns {Promise<Position>} Position object.
|
|
1600
|
+
*/
|
|
1601
|
+
getPosition(position_handle: string, position_id: string, calculate_rewarder?: boolean, show_display?: boolean): Promise<Position>;
|
|
1602
|
+
/**
|
|
1603
|
+
* Gets a position by its ID.
|
|
1604
|
+
* @param {string} position_id The ID of the position to get.
|
|
1605
|
+
* @param {boolean} calculate_rewarder Whether to calculate the rewarder of the position.
|
|
1606
|
+
* @param {boolean} show_display When some testnet rpc nodes can't return object's display data, you can set this option to false to avoid returning errors. Default is true.
|
|
1607
|
+
* @returns {Promise<Position>} Position object.
|
|
1608
|
+
*/
|
|
1609
|
+
getPositionById(position_id: string, calculate_rewarder?: boolean, show_display?: boolean): Promise<Position>;
|
|
1610
|
+
/**
|
|
1611
|
+
* Gets a simple position for the given position ID.
|
|
1612
|
+
* @param {string} position_id The ID of the position to get.
|
|
1613
|
+
* @returns {Promise<Position>} Position object.
|
|
1614
|
+
*/
|
|
1615
|
+
getSimplePosition(position_id: string, show_display?: boolean): Promise<Position>;
|
|
1616
|
+
/**
|
|
1617
|
+
* Gets a simple position for the given position ID.
|
|
1618
|
+
* @param {string} position_id Position object id
|
|
1619
|
+
* @returns {Position | undefined} Position object
|
|
1620
|
+
*/
|
|
1621
|
+
private getSimplePositionByCache;
|
|
1622
|
+
/**
|
|
1623
|
+
* Gets a list of simple positions for the given position ID.
|
|
1624
|
+
* @param {SuiObjectIdType[]} position_ids The IDs of the positions to get.
|
|
1625
|
+
* @returns {Promise<Position[]>} A promise that resolves to an array of Position objects.
|
|
1626
|
+
*/
|
|
1627
|
+
getSimplePositionList(position_ids: SuiObjectIdType[], show_display?: boolean): Promise<Position[]>;
|
|
1628
|
+
/**
|
|
1629
|
+
* Updates the rewarders of position
|
|
1630
|
+
* @param {string} position_handle Position handle
|
|
1631
|
+
* @param {Position} position Position object
|
|
1632
|
+
* @returns {Promise<Position>} A promise that resolves to an array of Position objects.
|
|
1633
|
+
*/
|
|
1634
|
+
private updatePositionRewarders;
|
|
1635
|
+
/**
|
|
1636
|
+
* Gets the position rewarders for the given position handle and position object ID.
|
|
1637
|
+
* @param {string} position_handle The handle of the position.
|
|
1638
|
+
* @param {string} position_id The ID of the position object.
|
|
1639
|
+
* @returns {Promise<PositionReward | undefined>} PositionReward object.
|
|
1640
|
+
*/
|
|
1641
|
+
getPositionRewarders(position_handle: string, position_id: string): Promise<PositionReward | undefined>;
|
|
1642
|
+
buildFetchPosFee(params: FetchPosFeeParams, tx: Transaction): void;
|
|
1643
|
+
parsedPosFeeData(simulate_res: DevInspectResults): Record<string, {
|
|
1644
|
+
position_id: string;
|
|
1645
|
+
fee_owned_a: string;
|
|
1646
|
+
fee_owned_b: string;
|
|
1647
|
+
}>;
|
|
1648
|
+
/**
|
|
1649
|
+
* Fetches the Position fee amount for a given list of addresses.
|
|
1650
|
+
* @param {FetchPosFeeParams[]} params An array of FetchPosFeeParams objects containing the target addresses and their corresponding amounts.
|
|
1651
|
+
* @returns {Promise<CollectFeesQuote[]>} A Promise that resolves with the fetched position fee amount for the specified addresses.
|
|
1652
|
+
*/
|
|
1653
|
+
fetchPosFeeAmount(params: FetchPosFeeParams[]): Promise<CollectFeesQuote[]>;
|
|
1654
|
+
/**
|
|
1655
|
+
* Fetches the Position fee amount for a given list of addresses.
|
|
1656
|
+
* @param position_ids An array of position object id.
|
|
1657
|
+
* @returns {Promise<Record<string, CollectFeesQuote>>} A Promise that resolves with the fetched position fee amount for the specified position object ids.
|
|
1658
|
+
*/
|
|
1659
|
+
batchFetchPositionFees(position_ids: string[]): Promise<Record<string, CollectFeesQuote>>;
|
|
1660
|
+
/**
|
|
1661
|
+
* create add liquidity transaction payload with fix token
|
|
1662
|
+
* @param {AddLiquidityFixTokenParams} params
|
|
1663
|
+
* @param gas_estimate_arg : When the fix input amount is SUI, gasEstimateArg can control whether to recalculate the number of SUI to prevent insufficient gas.
|
|
1664
|
+
* If this parameter is not passed, gas estimation is not performed
|
|
1665
|
+
* @returns {Promise<TransactionBlock>}
|
|
1666
|
+
*/
|
|
1667
|
+
createAddLiquidityFixTokenPayload(params: AddLiquidityFixTokenParams, gas_estimate_arg?: {
|
|
1668
|
+
slippage: number;
|
|
1669
|
+
cur_sqrt_price: BN;
|
|
1670
|
+
}, tx?: Transaction, input_coin_a?: TransactionObjectArgument, input_coin_b?: TransactionObjectArgument): Promise<Transaction>;
|
|
1671
|
+
/**
|
|
1672
|
+
* create add liquidity transaction payload
|
|
1673
|
+
* @param {AddLiquidityParams} params
|
|
1674
|
+
* @returns {Promise<TransactionBlock>}
|
|
1675
|
+
*/
|
|
1676
|
+
createAddLiquidityPayload(params: AddLiquidityParams, tx?: Transaction, input_coin_a?: TransactionObjectArgument, input_coin_b?: TransactionObjectArgument): Promise<Transaction>;
|
|
1677
|
+
/**
|
|
1678
|
+
* Remove liquidity from a position.
|
|
1679
|
+
* @param {RemoveLiquidityParams} params
|
|
1680
|
+
* @returns {TransactionBlock}
|
|
1681
|
+
*/
|
|
1682
|
+
removeLiquidityPayload(params: RemoveLiquidityParams, tx?: Transaction): Promise<Transaction>;
|
|
1683
|
+
/**
|
|
1684
|
+
* Close position and remove all liquidity and collect_reward
|
|
1685
|
+
* @param {ClosePositionParams} params
|
|
1686
|
+
* @returns {TransactionBlock}
|
|
1687
|
+
*/
|
|
1688
|
+
closePositionPayload(params: ClosePositionParams, tx?: Transaction): Promise<Transaction>;
|
|
1689
|
+
/**
|
|
1690
|
+
* Open position in clmmpool.
|
|
1691
|
+
* @param {OpenPositionParams} params
|
|
1692
|
+
* @returns {TransactionBlock}
|
|
1693
|
+
*/
|
|
1694
|
+
openPositionPayload(params: OpenPositionParams, tx?: Transaction): Transaction;
|
|
1695
|
+
/**
|
|
1696
|
+
* Open position with price range in clmmpool.
|
|
1697
|
+
* @param {OpenPositionWithPriceParams} params
|
|
1698
|
+
* @returns {TransactionBlock}
|
|
1699
|
+
*/
|
|
1700
|
+
openPositionWithPricePayload(params: OpenPositionWithPriceParams, tx?: Transaction): Promise<Transaction>;
|
|
1701
|
+
/**
|
|
1702
|
+
* Collect LP fee from Position.
|
|
1703
|
+
* @param {CollectFeeParams} params
|
|
1704
|
+
* @param {TransactionBlock} tx
|
|
1705
|
+
* @returns {TransactionBlock}
|
|
1706
|
+
*/
|
|
1707
|
+
collectFeePayload(params: CollectFeeParams, tx?: Transaction, input_coin_a?: TransactionObjectArgument, input_coin_b?: TransactionObjectArgument): Promise<Transaction>;
|
|
1708
|
+
createCollectFeePayload(params: CollectFeeParams, tx: Transaction, primary_coin_a_input: TransactionObjectArgument, primary_coin_b_input: TransactionObjectArgument): Transaction;
|
|
1709
|
+
/**
|
|
1710
|
+
* Calculate the result of add liquidity with price.
|
|
1711
|
+
* @param {CalculateAddLiquidityWithPriceParams} params
|
|
1712
|
+
* @returns {Promise<CalculateAddLiquidityResult>}
|
|
1713
|
+
*/
|
|
1714
|
+
calculateAddLiquidityResultWithPrice(params: CalculateAddLiquidityWithPriceParams | CalculateAddLiquidityFixCoinWithPriceParams): Promise<CalculateAddLiquidityResult>;
|
|
1715
|
+
/**
|
|
1716
|
+
* Add liquidity with price range.
|
|
1717
|
+
* @param {AddLiquidityWithPriceRangeParams} params
|
|
1718
|
+
* @param {TransactionBlock} tx
|
|
1719
|
+
* @returns {TransactionBlock}
|
|
1720
|
+
*/
|
|
1721
|
+
addLiquidityWithPricePayload(params: AddLiquidityWithPriceRangeParams, tx?: Transaction, input_coin_a?: TransactionObjectArgument, input_coin_b?: TransactionObjectArgument): Promise<Transaction>;
|
|
1722
|
+
/**
|
|
1723
|
+
* Add liquidity with price range.
|
|
1724
|
+
* @param {AddLiquidityWithPriceRangeParams} params
|
|
1725
|
+
* @param {TransactionBlock} tx
|
|
1726
|
+
* @returns {TransactionBlock}
|
|
1727
|
+
*/
|
|
1728
|
+
createAddLiquidityFixCoinWithPricePayload(params: AddLiquidityWithPriceRangeParams, tx?: Transaction, input_coin_a?: TransactionObjectArgument, input_coin_b?: TransactionObjectArgument): Promise<Transaction>;
|
|
1729
|
+
createCollectFeeNoSendPayload(params: CollectFeeParams, tx: Transaction, primary_coin_a_input: TransactionObjectArgument, primary_coin_b_input: TransactionObjectArgument): Transaction;
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
/**
|
|
1733
|
+
* Helper class to help interact with clmm position rewaeder with a rewaeder router interface.
|
|
1734
|
+
*/
|
|
1735
|
+
declare class RewarderModule implements IModule<CetusClmmSDK> {
|
|
1736
|
+
protected _sdk: CetusClmmSDK;
|
|
1737
|
+
private growthGlobal;
|
|
1738
|
+
constructor(sdk: CetusClmmSDK);
|
|
1739
|
+
get sdk(): CetusClmmSDK;
|
|
1740
|
+
/**
|
|
1741
|
+
* Gets the emissions for the given pool every day.
|
|
1742
|
+
*
|
|
1743
|
+
* @param {string} pool_id The object ID of the pool.
|
|
1744
|
+
* @returns {Promise<Array<{emissions: number, coinAddress: string}>>} A promise that resolves to an array of objects with the emissions and coin address for each rewarder.
|
|
1745
|
+
*/
|
|
1746
|
+
emissionsEveryDay(pool_id: string): Promise<{
|
|
1747
|
+
emissions: number;
|
|
1748
|
+
coin_type: string;
|
|
1749
|
+
}[] | null>;
|
|
1750
|
+
/**
|
|
1751
|
+
* Fetches the Position reward amount for a given list of addresses.
|
|
1752
|
+
* @param {string[]}position_ids An array of position object id.
|
|
1753
|
+
* @returns {Promise<Record<string, RewarderAmountOwned[]>>} A Promise that resolves with the fetched position reward amount for the specified position object ids.
|
|
1754
|
+
*/
|
|
1755
|
+
batchFetchPositionRewarders(position_ids: string[]): Promise<Record<string, RewarderAmountOwned[]>>;
|
|
1756
|
+
/**
|
|
1757
|
+
* Fetch the position rewards for a given pool.
|
|
1758
|
+
* @param {Pool}pool Pool object
|
|
1759
|
+
* @param {string}position_id Position object id
|
|
1760
|
+
* @returns {Promise<RewarderAmountOwned[]>} A Promise that resolves with the fetched position reward amount for the specified position object id.
|
|
1761
|
+
*/
|
|
1762
|
+
fetchPositionRewarders(pool: Pool, position_id: string): Promise<RewarderAmountOwned[]>;
|
|
1763
|
+
/**
|
|
1764
|
+
* Fetches the Position fee amount for a given list of addresses.
|
|
1765
|
+
* @param position_ids An array of position object id.
|
|
1766
|
+
* @returns {Promise<Record<string, CollectFeesQuote>>} A Promise that resolves with the fetched position fee amount for the specified position object ids.
|
|
1767
|
+
* @deprecated This method is deprecated and may be removed in future versions. Use alternative methods if available.
|
|
1768
|
+
*/
|
|
1769
|
+
batchFetchPositionFees(position_ids: string[]): Promise<Record<string, CollectFeesQuote>>;
|
|
1770
|
+
/**
|
|
1771
|
+
* Fetches the Position fee amount for a given list of addresses.
|
|
1772
|
+
* @param params An array of FetchPosFeeParams objects containing the target addresses and their corresponding amounts.
|
|
1773
|
+
* @returns
|
|
1774
|
+
*/
|
|
1775
|
+
fetchPosFeeAmount(params: FetchPosFeeParams[]): Promise<CollectFeesQuote[]>;
|
|
1776
|
+
buildFetchPosReward(params: FetchPosRewardParams, tx: Transaction): void;
|
|
1777
|
+
/**
|
|
1778
|
+
* Fetches the Position reward amount for a given list of addresses.
|
|
1779
|
+
* @param params An array of FetchPosRewardParams objects containing the target addresses and their corresponding amounts.
|
|
1780
|
+
* @returns
|
|
1781
|
+
*/
|
|
1782
|
+
fetchPosRewardersAmount(params: FetchPosRewardParams[]): Promise<PosRewarderResult[]>;
|
|
1783
|
+
parsedPosRewardData(simulate_res: DevInspectResults): Record<string, {
|
|
1784
|
+
position_id: string;
|
|
1785
|
+
rewarder_amount: string[];
|
|
1786
|
+
}>;
|
|
1787
|
+
/**
|
|
1788
|
+
* Fetches the pool reward amount for a given account and pool object id.
|
|
1789
|
+
* @param {string} account - The target account.
|
|
1790
|
+
* @param {string} pool_object_id - The target pool object id.
|
|
1791
|
+
* @returns {Promise<number|null>} - A Promise that resolves with the fetched pool reward amount for the specified account and pool, or null if the fetch is unsuccessful.
|
|
1792
|
+
*/
|
|
1793
|
+
fetchPoolRewardersAmount(account: string, pool_object_id: string): Promise<BN[]>;
|
|
1794
|
+
private getPoolLowerAndUpperTicks;
|
|
1795
|
+
/**
|
|
1796
|
+
* Collect rewards from Position.
|
|
1797
|
+
* @param params
|
|
1798
|
+
* @returns
|
|
1799
|
+
*/
|
|
1800
|
+
collectRewarderPayload(params: CollectRewarderParams): Promise<Transaction>;
|
|
1801
|
+
/**
|
|
1802
|
+
* batch Collect rewards from Position.
|
|
1803
|
+
* @param params
|
|
1804
|
+
* @param tx
|
|
1805
|
+
* @param input_coin_a
|
|
1806
|
+
* @param input_coin_b
|
|
1807
|
+
* @returns
|
|
1808
|
+
*/
|
|
1809
|
+
batchCollectRewardsPayload(params: CollectRewarderParams[], tx?: Transaction, input_coin_a?: TransactionObjectArgument, input_coin_b?: TransactionObjectArgument): Promise<Transaction>;
|
|
1810
|
+
createCollectRewarderPayload(params: CollectRewarderParams, tx: Transaction, primary_coin_inputs: TransactionArgument[]): Transaction;
|
|
1811
|
+
createCollectRewarderNoSendPayload(params: CollectRewarderParams, tx: Transaction, primary_coin_inputs: TransactionArgument[]): Transaction;
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
declare const AMM_SWAP_MODULE = "amm_swap";
|
|
1815
|
+
declare const POOL_STRUCT = "Pool";
|
|
1816
|
+
/**
|
|
1817
|
+
* Helper class to help interact with clmm pool swap with a swap router interface.
|
|
1818
|
+
*/
|
|
1819
|
+
declare class SwapModule implements IModule<CetusClmmSDK> {
|
|
1820
|
+
protected _sdk: CetusClmmSDK;
|
|
1821
|
+
constructor(sdk: CetusClmmSDK);
|
|
1822
|
+
get sdk(): CetusClmmSDK;
|
|
1823
|
+
calculateSwapFee(paths: SplitPath[]): string;
|
|
1824
|
+
calculateSwapPriceImpact(paths: SplitPath[]): string;
|
|
1825
|
+
private calculateSingleImpact;
|
|
1826
|
+
/**
|
|
1827
|
+
* Performs a pre-swap with multiple pools.
|
|
1828
|
+
*
|
|
1829
|
+
* @param {PreSwapWithMultiPoolParams} params The parameters for the pre-swap.
|
|
1830
|
+
* @returns {Promise<SwapWithMultiPoolData>} A promise that resolves to the swap data.
|
|
1831
|
+
*/
|
|
1832
|
+
preSwapWithMultiPool(params: PreSwapWithMultiPoolParams): Promise<{
|
|
1833
|
+
pool_address: string;
|
|
1834
|
+
estimated_amount_in: string;
|
|
1835
|
+
estimated_amount_out: any;
|
|
1836
|
+
estimated_end_sqrt_price: any;
|
|
1837
|
+
estimated_start_sqrt_price: any;
|
|
1838
|
+
estimated_fee_amount: any;
|
|
1839
|
+
is_exceed: any;
|
|
1840
|
+
amount: string;
|
|
1841
|
+
a2b: boolean;
|
|
1842
|
+
by_amount_in: boolean;
|
|
1843
|
+
} | null>;
|
|
1844
|
+
/**
|
|
1845
|
+
* Performs a pre-swap.
|
|
1846
|
+
*
|
|
1847
|
+
* @param {PreSwapParams} params The parameters for the pre-swap.
|
|
1848
|
+
* @returns {Promise<PreSwapParams>} A promise that resolves to the swap data.
|
|
1849
|
+
*/
|
|
1850
|
+
preSwap(params: PreSwapParams): Promise<{
|
|
1851
|
+
pool_address: string;
|
|
1852
|
+
current_sqrt_price: number;
|
|
1853
|
+
estimated_amount_in: string;
|
|
1854
|
+
estimated_amount_out: any;
|
|
1855
|
+
estimated_end_sqrt_price: any;
|
|
1856
|
+
estimated_fee_amount: any;
|
|
1857
|
+
is_exceed: any;
|
|
1858
|
+
amount: string;
|
|
1859
|
+
a2b: boolean;
|
|
1860
|
+
by_amount_in: boolean;
|
|
1861
|
+
}>;
|
|
1862
|
+
private transformSwapData;
|
|
1863
|
+
private transformSwapWithMultiPoolData;
|
|
1864
|
+
/**
|
|
1865
|
+
* Calculates the rates for a swap.
|
|
1866
|
+
* @param {CalculateRatesParams} params The parameters for the calculation.
|
|
1867
|
+
* @returns {CalculateRatesResult} The results of the calculation.
|
|
1868
|
+
*/
|
|
1869
|
+
calculateRates(params: CalculateRatesParams): CalculateRatesResult;
|
|
1870
|
+
/**
|
|
1871
|
+
* create swap transaction payload
|
|
1872
|
+
* @param params
|
|
1873
|
+
* @param gas_estimate_arg When the fix input amount is SUI, gasEstimateArg can control whether to recalculate the number of SUI to prevent insufficient gas.
|
|
1874
|
+
* If this parameter is not passed, gas estimation is not performed
|
|
1875
|
+
* @returns
|
|
1876
|
+
*/
|
|
1877
|
+
createSwapPayload(params: SwapParams, gas_estimate_arg?: SwapGasEstimateArg): Promise<Transaction>;
|
|
1878
|
+
/**
|
|
1879
|
+
* create swap transaction without transfer coins payload
|
|
1880
|
+
* @param params
|
|
1881
|
+
* @param gas_estimate_arg When the fix input amount is SUI, gasEstimateArg can control whether to recalculate the number of SUI to prevent insufficient gas.
|
|
1882
|
+
* If this parameter is not passed, gas estimation is not performed
|
|
1883
|
+
* @returns tx and coin ABs
|
|
1884
|
+
*/
|
|
1885
|
+
createSwapWithoutTransferCoinsPayload(params: SwapParams, gas_estimate_arg?: SwapGasEstimateArg): Promise<{
|
|
1886
|
+
tx: Transaction;
|
|
1887
|
+
coin_ab_s: TransactionObjectArgument[];
|
|
1888
|
+
}>;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
/**
|
|
1892
|
+
* Represents options and configurations for an SDK.
|
|
1893
|
+
*/
|
|
1894
|
+
interface SdkOptions extends BaseSdkOptions {
|
|
1895
|
+
/**
|
|
1896
|
+
* Package containing Cetus protocol configurations.
|
|
1897
|
+
*/
|
|
1898
|
+
cetus_config: Package<CetusConfigs>;
|
|
1899
|
+
/**
|
|
1900
|
+
* Package containing Cryptocurrency Liquidity Mining Module (CLMM) pool configurations.
|
|
1901
|
+
*/
|
|
1902
|
+
clmm_pool: Package<ClmmConfig>;
|
|
1903
|
+
/**
|
|
1904
|
+
* Package containing integration-related configurations.
|
|
1905
|
+
*/
|
|
1906
|
+
integrate: Package;
|
|
1907
|
+
/**
|
|
1908
|
+
* The URL for the swap count
|
|
1909
|
+
*/
|
|
1910
|
+
stats_pools_url?: string;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* The entry class of CetusClmmSDK, which is almost responsible for all interactions with CLMM.
|
|
1914
|
+
*/
|
|
1915
|
+
declare class CetusClmmSDK extends SdkWrapper<SdkOptions> {
|
|
1916
|
+
/**
|
|
1917
|
+
* Provide interact with clmm pools with a pool router interface.
|
|
1918
|
+
*/
|
|
1919
|
+
protected _pool: PoolModule;
|
|
1920
|
+
/**
|
|
1921
|
+
* Provide interact with a position rewarder interface.
|
|
1922
|
+
*/
|
|
1923
|
+
protected _rewarder: RewarderModule;
|
|
1924
|
+
/**
|
|
1925
|
+
* Provide interact with a pool swap router interface.
|
|
1926
|
+
*/
|
|
1927
|
+
protected _swap: SwapModule;
|
|
1928
|
+
/**
|
|
1929
|
+
* Provide interact with clmm position with a position router interface.
|
|
1930
|
+
*/
|
|
1931
|
+
protected _position: PositionModule;
|
|
1932
|
+
/**
|
|
1933
|
+
* Provide interact with clmm pool and coin and launchpad pool config
|
|
1934
|
+
*/
|
|
1935
|
+
protected _config: ConfigModule;
|
|
1936
|
+
constructor(options: SdkOptions);
|
|
1937
|
+
/**
|
|
1938
|
+
* Getter for the Pool property.
|
|
1939
|
+
* @returns {PoolModule} The Pool property value.
|
|
1940
|
+
*/
|
|
1941
|
+
get Pool(): PoolModule;
|
|
1942
|
+
/**
|
|
1943
|
+
* Getter for the Position property.
|
|
1944
|
+
* @returns {PositionModule} The Position property value.
|
|
1945
|
+
*/
|
|
1946
|
+
get Position(): PositionModule;
|
|
1947
|
+
/**
|
|
1948
|
+
* Getter for the CetusConfig property.
|
|
1949
|
+
* @returns {ConfigModule} The CetusConfig property value.
|
|
1950
|
+
*/
|
|
1951
|
+
get CetusConfig(): ConfigModule;
|
|
1952
|
+
/**
|
|
1953
|
+
* Getter for the Rewarder property.
|
|
1954
|
+
* @returns {RewarderModule} The Rewarder property value.
|
|
1955
|
+
*/
|
|
1956
|
+
get Rewarder(): RewarderModule;
|
|
1957
|
+
/**
|
|
1958
|
+
* Getter for the Swap property.
|
|
1959
|
+
* @returns {SwapModule} The Swap property value.
|
|
1960
|
+
*/
|
|
1961
|
+
get Swap(): SwapModule;
|
|
1962
|
+
static createSDK(options: BaseSdkOptions): CetusClmmSDK;
|
|
1963
|
+
/**
|
|
1964
|
+
* Create a custom SDK instance with the given options
|
|
1965
|
+
* @param options The options for the SDK
|
|
1966
|
+
* @returns An instance of CetusBurnSDK
|
|
1967
|
+
*/
|
|
1968
|
+
static createCustomSDK<T extends BaseSdkOptions>(options: T & SdkOptions): CetusClmmSDK;
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
/**
|
|
1972
|
+
* Builds a Pool object based on a SuiObjectResponse.
|
|
1973
|
+
* @param {SuiObjectResponse} objects - The SuiObjectResponse containing information about the pool.
|
|
1974
|
+
* @returns {Pool} - The built Pool object.
|
|
1975
|
+
*/
|
|
1976
|
+
declare function buildPool(objects: SuiObjectResponse): Pool;
|
|
1977
|
+
/** Builds a Position object based on a SuiObjectResponse.
|
|
1978
|
+
* @param {SuiObjectResponse} object - The SuiObjectResponse containing information about the position.
|
|
1979
|
+
* @returns {Position} - The built Position object.
|
|
1980
|
+
*/
|
|
1981
|
+
declare function buildPosition(object: SuiObjectResponse): Position;
|
|
1982
|
+
/**
|
|
1983
|
+
* Builds a PositionReward object based on a response containing information about the reward.
|
|
1984
|
+
* @param {any} fields - The response containing information about the reward.
|
|
1985
|
+
* @returns {PositionReward} - The built PositionReward object.
|
|
1986
|
+
*/
|
|
1987
|
+
declare function buildPositionReward(fields: any): PositionReward;
|
|
1988
|
+
/**
|
|
1989
|
+
* Builds a TickData object based on a response containing information about tick data.
|
|
1990
|
+
* It must check if the response contains the required fields.
|
|
1991
|
+
* @param {SuiObjectResponse} objects - The response containing information about tick data.
|
|
1992
|
+
* @returns {TickData} - The built TickData object.
|
|
1993
|
+
*/
|
|
1994
|
+
declare function buildTickData(objects: SuiObjectResponse): TickData;
|
|
1995
|
+
/**
|
|
1996
|
+
* Builds a TickData object based on a given event's fields.
|
|
1997
|
+
* @param {any} fields - The fields of an event.
|
|
1998
|
+
* @returns {TickData} - The built TickData object.
|
|
1999
|
+
* @throws {Error} If any required field is missing.
|
|
2000
|
+
*/
|
|
2001
|
+
declare function buildTickDataByEvent(fields: any): TickData;
|
|
2002
|
+
declare function buildClmmPositionName(pool_index: number, position_index: number): string;
|
|
2003
|
+
declare function buildPositionTransactionInfo(data: SuiTransactionBlockResponse, txIndex: number, filterIds: string[]): PositionTransactionInfo[];
|
|
2004
|
+
declare function buildPoolTransactionInfo(data: SuiTransactionBlockResponse, txIndex: number, package_id: string, pool_id: string): PoolTransactionInfo[];
|
|
2005
|
+
declare function buildTransferCoinToSender(sdk: CetusClmmSDK, tx: Transaction, coin: TransactionObjectArgument, coinType: string): void;
|
|
2006
|
+
declare function buildTransferCoin(sdk: CetusClmmSDK, tx: Transaction, coin: TransactionObjectArgument, coinType: string, recipient?: string): void;
|
|
2007
|
+
|
|
2008
|
+
type AdjustResult = {
|
|
2009
|
+
is_adjust_coin_a: boolean;
|
|
2010
|
+
is_adjust_coin_b: boolean;
|
|
2011
|
+
};
|
|
2012
|
+
/**
|
|
2013
|
+
* Adjust coinpair is sui
|
|
2014
|
+
* @param {CoinPairType} coinPair
|
|
2015
|
+
* @returns
|
|
2016
|
+
*/
|
|
2017
|
+
declare function findAdjustCoin(coinPair: CoinPairType): AdjustResult;
|
|
2018
|
+
declare class PositionUtils {
|
|
2019
|
+
static createCollectRewarderAndFeeParams(sdk: CetusClmmSDK, tx: Transaction, params: CollectRewarderParams, all_coin_asset: CoinAsset[], all_coin_asset_a?: CoinAsset[], all_coin_asset_b?: CoinAsset[]): Transaction;
|
|
2020
|
+
/**
|
|
2021
|
+
* adjust transaction for gas
|
|
2022
|
+
* @param sdk
|
|
2023
|
+
* @param amount
|
|
2024
|
+
* @param tx
|
|
2025
|
+
* @returns
|
|
2026
|
+
*/
|
|
2027
|
+
static adjustTransactionForGas(sdk: CetusClmmSDK, all_coins: CoinAsset[], amount: bigint, tx: Transaction): Promise<{
|
|
2028
|
+
fixAmount: bigint;
|
|
2029
|
+
newTx?: Transaction;
|
|
2030
|
+
}>;
|
|
2031
|
+
/**
|
|
2032
|
+
* build add liquidity transaction
|
|
2033
|
+
* @param params
|
|
2034
|
+
* @param slippage
|
|
2035
|
+
* @param curSqrtPrice
|
|
2036
|
+
* @returns
|
|
2037
|
+
*/
|
|
2038
|
+
static buildAddLiquidityFixTokenForGas(sdk: CetusClmmSDK, all_coins: CoinAsset[], params: AddLiquidityFixTokenParams, gas_estimate_arg: {
|
|
2039
|
+
slippage: number;
|
|
2040
|
+
cur_sqrt_price: BN;
|
|
2041
|
+
}, tx?: Transaction, input_coin_a?: TransactionObjectArgument, input_coin_b?: TransactionObjectArgument): Promise<Transaction>;
|
|
2042
|
+
/**
|
|
2043
|
+
* build add liquidity transaction
|
|
2044
|
+
* @param params
|
|
2045
|
+
* @param packageId
|
|
2046
|
+
* @returns
|
|
2047
|
+
*/
|
|
2048
|
+
static buildAddLiquidityFixToken(sdk: CetusClmmSDK, all_coins: CoinAsset[], params: AddLiquidityFixTokenParams, tx?: Transaction, input_coin_a?: TransactionObjectArgument, input_coin_b?: TransactionObjectArgument): Promise<Transaction>;
|
|
2049
|
+
static buildAddLiquidityFixTokenCoinInput(tx: Transaction, need_interval_amount: boolean, amount: number | string, slippage: number, coin_type: string, all_coins: CoinAsset[], build_vector?: boolean, fix_amount?: boolean): BuildCoinResult;
|
|
2050
|
+
/**
|
|
2051
|
+
* fix add liquidity fix token for coin amount
|
|
2052
|
+
* @param params
|
|
2053
|
+
* @param slippage
|
|
2054
|
+
* @param curSqrtPrice
|
|
2055
|
+
* @returns
|
|
2056
|
+
*/
|
|
2057
|
+
static fixAddLiquidityFixTokenParams(params: AddLiquidityFixTokenParams, slippage: number, curSqrtPrice: BN): AddLiquidityFixTokenParams;
|
|
2058
|
+
private static buildAddLiquidityFixTokenArgs;
|
|
2059
|
+
static checkCoinThreshold(sdk: CetusClmmSDK, by_amount_in: boolean, tx: Transaction, coin: TransactionObjectArgument, amount_limit: number, coin_type: string): void;
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
declare class SwapUtils {
|
|
2063
|
+
/**
|
|
2064
|
+
* Get the default sqrt price limit for a swap.
|
|
2065
|
+
*
|
|
2066
|
+
* @param a2b - true if the swap is A to B, false if the swap is B to A.
|
|
2067
|
+
* @returns The default sqrt price limit for the swap.
|
|
2068
|
+
*/
|
|
2069
|
+
static getDefaultSqrtPriceLimit(a2b: boolean): BN;
|
|
2070
|
+
/**
|
|
2071
|
+
* Get the default values for the otherAmountThreshold in a swap.
|
|
2072
|
+
*
|
|
2073
|
+
* @param amount_specified_is_input - The direction of a swap
|
|
2074
|
+
* @returns The default values for the otherAmountThreshold parameter in a swap.
|
|
2075
|
+
*/
|
|
2076
|
+
static getDefaultOtherAmountThreshold(amount_specified_is_input: boolean): BN;
|
|
2077
|
+
/**
|
|
2078
|
+
* build add liquidity transaction
|
|
2079
|
+
* @param params
|
|
2080
|
+
* @param slippage
|
|
2081
|
+
* @param curSqrtPrice
|
|
2082
|
+
* @returns
|
|
2083
|
+
*/
|
|
2084
|
+
static buildSwapTransactionForGas(sdk: CetusClmmSDK, params: SwapParams, all_coin_asset: CoinAsset[], gas_estimate_arg: SwapGasEstimateArg): Promise<Transaction>;
|
|
2085
|
+
/**
|
|
2086
|
+
* build swap transaction
|
|
2087
|
+
* @param params
|
|
2088
|
+
* @param packageId
|
|
2089
|
+
* @returns
|
|
2090
|
+
*/
|
|
2091
|
+
static buildSwapTransactionArgs(tx: Transaction, params: SwapParams, sdk_options: SdkOptions, primary_coin_input_a: BuildCoinResult, primary_coin_input_b: BuildCoinResult): Transaction;
|
|
2092
|
+
/**
|
|
2093
|
+
* adjust transaction for gas
|
|
2094
|
+
* @param sdk
|
|
2095
|
+
* @param amount
|
|
2096
|
+
* @param tx
|
|
2097
|
+
* @returns
|
|
2098
|
+
*/
|
|
2099
|
+
static adjustTransactionForGas(sdk: CetusClmmSDK, all_coins: CoinAsset[], amount: bigint, tx: Transaction): Promise<{
|
|
2100
|
+
fixAmount: bigint;
|
|
2101
|
+
newTx?: Transaction;
|
|
2102
|
+
}>;
|
|
2103
|
+
/**
|
|
2104
|
+
* build swap transaction
|
|
2105
|
+
* @param params
|
|
2106
|
+
* @param packageId
|
|
2107
|
+
* @returns
|
|
2108
|
+
*/
|
|
2109
|
+
static buildSwapTransaction(sdk: CetusClmmSDK, params: SwapParams, all_coin_asset: CoinAsset[]): Transaction;
|
|
2110
|
+
static fixSwapParams(sdk: CetusClmmSDK, params: SwapParams, gasEstimateArg: SwapGasEstimateArg): Promise<SwapParams>;
|
|
2111
|
+
static buildSwapTransactionWithoutTransferCoinsForGas(sdk: CetusClmmSDK, params: SwapParams, all_coin_asset: CoinAsset[], gas_estimate_arg: SwapGasEstimateArg): Promise<{
|
|
2112
|
+
tx: Transaction;
|
|
2113
|
+
coin_ab_s: TransactionObjectArgument[];
|
|
2114
|
+
}>;
|
|
2115
|
+
/**
|
|
2116
|
+
* build swap transaction and return swapped coin
|
|
2117
|
+
* @param params
|
|
2118
|
+
* @param packageId
|
|
2119
|
+
* @returns
|
|
2120
|
+
*/
|
|
2121
|
+
static buildSwapTransactionWithoutTransferCoins(sdk: CetusClmmSDK, params: SwapParams, all_coin_asset: CoinAsset[]): {
|
|
2122
|
+
tx: Transaction;
|
|
2123
|
+
coin_ab_s: TransactionObjectArgument[];
|
|
2124
|
+
};
|
|
2125
|
+
/**
|
|
2126
|
+
* build swap transaction
|
|
2127
|
+
* @param params
|
|
2128
|
+
* @param packageId
|
|
2129
|
+
* @returns
|
|
2130
|
+
*/
|
|
2131
|
+
static buildSwapTransactionWithoutTransferCoinArgs(sdk: CetusClmmSDK, tx: Transaction, params: SwapParams, sdk_options: SdkOptions, primary_coin_input_a: BuildCoinResult, primary_coin_input_b: BuildCoinResult): {
|
|
2132
|
+
tx: Transaction;
|
|
2133
|
+
txRes: TransactionObjectArgument[];
|
|
2134
|
+
};
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* Get lower sqrt price from token A.
|
|
2138
|
+
*
|
|
2139
|
+
* @param amount - The amount of tokens the user wanted to swap from.
|
|
2140
|
+
* @param liquidity - The liquidity of the pool.
|
|
2141
|
+
* @param sqrt_price_x64 - The sqrt price of the pool.
|
|
2142
|
+
* @returns LowerSqrtPriceX64
|
|
2143
|
+
*/
|
|
2144
|
+
declare function getLowerSqrtPriceFromCoinA(amount: BN, liquidity: BN, sqrt_price_x64: BN): BN;
|
|
2145
|
+
/**
|
|
2146
|
+
* Get upper sqrt price from token A.
|
|
2147
|
+
*
|
|
2148
|
+
* @param amount - The amount of tokens the user wanted to swap from.
|
|
2149
|
+
* @param liquidity - The liquidity of the pool.
|
|
2150
|
+
* @param sqrt_price_x64 - The sqrt price of the pool.
|
|
2151
|
+
* @returns LowerSqrtPriceX64
|
|
2152
|
+
*/
|
|
2153
|
+
declare function getUpperSqrtPriceFromCoinA(amount: BN, liquidity: BN, sqrt_price_x64: BN): BN;
|
|
2154
|
+
/**
|
|
2155
|
+
* Get lower sqrt price from coin B.
|
|
2156
|
+
*
|
|
2157
|
+
* @param amount - The amount of coins the user wanted to swap from.
|
|
2158
|
+
* @param liquidity - The liquidity of the pool.
|
|
2159
|
+
* @param sqrt_price_x64 - The sqrt price of the pool.
|
|
2160
|
+
* @returns LowerSqrtPriceX64
|
|
2161
|
+
*/
|
|
2162
|
+
declare function getLowerSqrtPriceFromCoinB(amount: BN, liquidity: BN, sqrt_price_x64: BN): BN;
|
|
2163
|
+
/**
|
|
2164
|
+
* Get upper sqrt price from coin B.
|
|
2165
|
+
*
|
|
2166
|
+
* @param amount - The amount of coins the user wanted to swap from.
|
|
2167
|
+
* @param liquidity - The liquidity of the pool.
|
|
2168
|
+
* @param sqrtPriceX64 - The sqrt price of the pool.
|
|
2169
|
+
* @returns LowerSqrtPriceX64
|
|
2170
|
+
*/
|
|
2171
|
+
declare function getUpperSqrtPriceFromCoinB(amount: BN, liquidity: BN, sqrt_price_x64: BN): BN;
|
|
2172
|
+
|
|
2173
|
+
declare function estPoolAPR(pre_block_reward: BN, reward_price: BN, total_trading_fee: BN, total_liquidity_value: BN): BN;
|
|
2174
|
+
type estPosAPRResult = {
|
|
2175
|
+
fee_apr: Decimal;
|
|
2176
|
+
pos_rewarder_0_apr: Decimal;
|
|
2177
|
+
pos_rewarder_1_apr: Decimal;
|
|
2178
|
+
pos_rewarder_2_apr: Decimal;
|
|
2179
|
+
};
|
|
2180
|
+
declare function estPositionAPRWithDeltaMethod(current_tick_index: number, lower_tick_index: number, upper_tick_index: number, current_sqrt_price_x64: BN, pool_liquidity: BN, decimals_a: number, decimals_b: number, decimals_rewarder_0: number, decimals_rewarder_1: number, decimals_rewarder_2: number, fee_rate: number, amount_a_str: string, amount_b_str: string, pool_amount_a: BN, pool_amount_b: BN, swap_volume_str: string, pool_rewarders_0_str: string, pool_rewarders_1_str: string, pool_rewarders_2_str: string, coin_a_price_str: string, coin_b_price_str: string, rewarder_0_price_str: string, rewarder_1_price_str: string, rewarder_2_price_str: string): estPosAPRResult;
|
|
2181
|
+
declare function estPositionAPRWithMultiMethod(lower_user_price: number, upper_user_price: number, lower_hist_price: number, upper_hist_price: number): Decimal;
|
|
2182
|
+
|
|
2183
|
+
declare const clmmMainnet: SdkOptions;
|
|
2184
|
+
|
|
2185
|
+
declare const clmmTestnet: SdkOptions;
|
|
2186
|
+
|
|
2187
|
+
declare enum SwapErrorCode {
|
|
2188
|
+
InvalidSqrtPriceLimitDirection = "InvalidSqrtPriceLimitDirection",
|
|
2189
|
+
ZeroTradableAmount = "ZeroTradableAmount",
|
|
2190
|
+
AmountOutBelowMinimum = "AmountOutBelowMinimum",
|
|
2191
|
+
AmountInAboveMaximum = "AmountInAboveMaximum",
|
|
2192
|
+
NextTickNotFound = "NextTickNotFound",
|
|
2193
|
+
TickArraySequenceInvalid = "TickArraySequenceInvalid",
|
|
2194
|
+
TickArrayCrossingAboveMax = "TickArrayCrossingAboveMax",
|
|
2195
|
+
TickArrayIndexNotInitialized = "TickArrayIndexNotInitialized",
|
|
2196
|
+
ParamsLengthNotEqual = "ParamsLengthNotEqual"
|
|
2197
|
+
}
|
|
2198
|
+
declare enum PositionErrorCode {
|
|
2199
|
+
InvalidTickEvent = "InvalidTickEvent",
|
|
2200
|
+
InvalidPositionObject = "InvalidPositionObject",
|
|
2201
|
+
InvalidPositionRewardObject = "InvalidPositionRewardObject",
|
|
2202
|
+
InvalidParams = "InvalidParams"
|
|
2203
|
+
}
|
|
2204
|
+
declare enum PoolErrorCode {
|
|
2205
|
+
InvalidCoinTypeSequence = "InvalidCoinTypeSequence",
|
|
2206
|
+
InvalidTickIndex = "InvalidTickIndex",
|
|
2207
|
+
InvalidPoolObject = "InvalidPoolObject",
|
|
2208
|
+
InvalidTickObjectId = "InvalidTickObjectId",
|
|
2209
|
+
InvalidTickObject = "InvalidTickObject",
|
|
2210
|
+
InvalidTickFields = "InvalidTickFields",
|
|
2211
|
+
PoolsNotFound = "PoolsNotFound",
|
|
2212
|
+
StatsPoolsUrlNotSet = "StatsPoolsUrlNotSet",
|
|
2213
|
+
FetchError = "FetchError"
|
|
2214
|
+
}
|
|
2215
|
+
declare enum PartnerErrorCode {
|
|
2216
|
+
NotFoundPartnerObject = "NotFoundPartnerObject",
|
|
2217
|
+
InvalidPartnerRefFeeFields = "InvalidPartnerRefFeeFields"
|
|
2218
|
+
}
|
|
2219
|
+
declare enum ConfigErrorCode {
|
|
2220
|
+
InvalidConfig = "InvalidConfig",
|
|
2221
|
+
InvalidConfigHandle = "InvalidConfigHandle",
|
|
2222
|
+
InvalidSimulateAccount = "InvalidSimulateAccount"
|
|
2223
|
+
}
|
|
2224
|
+
declare enum UtilsErrorCode {
|
|
2225
|
+
InvalidSendAddress = "InvalidSendAddress",
|
|
2226
|
+
InvalidRecipientAddress = "InvalidRecipientAddress",
|
|
2227
|
+
InvalidRecipientAndAmountLength = "InvalidRecipientAndAmountLength",
|
|
2228
|
+
InsufficientBalance = "InsufficientBalance",
|
|
2229
|
+
InvalidTarget = "InvalidTarget",
|
|
2230
|
+
InvalidTransactionBuilder = "InvalidTransactionBuilder"
|
|
2231
|
+
}
|
|
2232
|
+
declare enum RouterErrorCode {
|
|
2233
|
+
InvalidCoin = "InvalidCoin",
|
|
2234
|
+
NotFoundPath = "NotFoundPath",
|
|
2235
|
+
NoDowngradeNeedParams = "NoDowngradeNeedParams",
|
|
2236
|
+
InvalidSwapCountUrl = "InvalidSwapCountUrl",
|
|
2237
|
+
InvalidTransactionBuilder = "InvalidTransactionBuilder",
|
|
2238
|
+
InvalidServerResponse = "InvalidServerResponse"
|
|
2239
|
+
}
|
|
2240
|
+
declare enum TypesErrorCode {
|
|
2241
|
+
InvalidType = "InvalidType"
|
|
2242
|
+
}
|
|
2243
|
+
type ClmmErrorCode = SwapErrorCode | PoolErrorCode | PositionErrorCode | PartnerErrorCode | ConfigErrorCode | UtilsErrorCode | RouterErrorCode | TypesErrorCode;
|
|
2244
|
+
declare class ClmmError extends BaseError {
|
|
2245
|
+
constructor(message: string, errorCode?: ClmmErrorCode, details?: Record<string, any>);
|
|
2246
|
+
static isVaultsErrorCode(e: any, code: ClmmErrorCode): boolean;
|
|
2247
|
+
}
|
|
2248
|
+
declare const handleError: (code: ClmmErrorCode, error: Error, details?: Record<string, any>) => never;
|
|
2249
|
+
declare const handleMessageError: (code: ClmmErrorCode, message: string, details?: Record<string, any>) => never;
|
|
2250
|
+
|
|
2251
|
+
export { AMM_SWAP_MODULE, type AddLiquidityCommonParams, type AddLiquidityFixTokenParams, type AddLiquidityParams, type AddLiquidityWithPriceRangeParams, type AdjustResult, type BasePath, type BigNumber, type Bits, type CalculateAddLiquidityFixCoinWithPriceParams, type CalculateAddLiquidityResult, type CalculateAddLiquidityWithPriceParams, type CalculateCreatePoolResult, type CalculateCreatePoolWithPriceParams, type CalculateRatesParams, type CalculateRatesResult, CetusClmmSDK, type CetusConfigs, type ClmmConfig, ClmmError, type ClmmErrorCode, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegratePoolV3Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, ClmmPartnerModule, type ClmmPoolConfig, ClmmPositionStatus, type ClmmpoolData, type ClosePositionParams, type CoinConfig, type CollectFeeParams, type CollectFeesQuote, type CollectRewarderParams, ConfigErrorCode, ConfigModule, type CreatePartnerEvent, type CreatePoolAddLiquidityParams, type CreatePoolAddLiquidityWithPriceParams, type CreatePoolAndAddLiquidityRowResult, type CreatePoolCustomRangeParams, type CreatePoolParams, type CustomRangeParams, DeepbookClobV2Module, DeepbookCustodianV2Module, DeepbookEndpointsV2Module, type FetchParams, type FetchPosFeeParams, type FetchPosRewardParams, type FullRangeParams, type LaunchpadPoolConfig, type NFT, type OpenPositionParams, type OpenPositionWithPriceParams, POOL_STRUCT, PartnerErrorCode, type Pool, PoolErrorCode, type PoolImmutables, PoolModule, type PoolTransactionInfo, type PosRewarderResult, type Position, PositionErrorCode, PositionModule, type PositionReward, type PositionTransactionInfo, PositionUtils, type PreSwapLpChangeParams, type PreSwapParams, type PreSwapWithMultiPoolParams, type RemoveLiquidityParams, type Rewarder, type RewarderAmountOwned, RewarderModule, RouterErrorCode, type SdkOptions, type SplitPath, type SuiBasicTypes, type SuiInputTypes, type SuiStructTag, type SuiTxArg, SwapErrorCode, type SwapGasEstimateArg, SwapModule, type SwapParams, type SwapResult, type SwapStepResult, SwapUtils, type Tick, type TickData, type TransPreSwapWithMultiPoolParams, TypesErrorCode, UtilsErrorCode, buildClmmPositionName, buildPool, buildPoolTransactionInfo, buildPosition, buildPositionReward, buildPositionTransactionInfo, buildTickData, buildTickDataByEvent, buildTransferCoin, buildTransferCoinToSender, clmmMainnet, clmmTestnet, computeSwap, computeSwapStep, CetusClmmSDK as default, estPoolAPR, type estPosAPRResult, estPositionAPRWithDeltaMethod, estPositionAPRWithMultiMethod, findAdjustCoin, getDefaultSuiInputType, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, handleError, handleMessageError, newBits, poolFilterEvenTypes, transClmmpoolDataWithoutTicks };
|