@cetusprotocol/dlmm-sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10423 -0
- package/README.md +646 -0
- package/dist/index.d.mts +1015 -0
- package/dist/index.d.ts +1015 -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/package.json +35 -0
- package/src/config/index.ts +2 -0
- package/src/config/mainnet.ts +25 -0
- package/src/config/testnet.ts +30 -0
- package/src/errors/errors.ts +40 -0
- package/src/index.ts +8 -0
- package/src/modules/configModule.ts +184 -0
- package/src/modules/index.ts +1 -0
- package/src/modules/partnerModule.ts +302 -0
- package/src/modules/poolModule.ts +578 -0
- package/src/modules/positionModule.ts +888 -0
- package/src/modules/rewardModule.ts +175 -0
- package/src/modules/swapModule.ts +129 -0
- package/src/sdk.ts +88 -0
- package/src/types/constants.ts +23 -0
- package/src/types/dlmm.ts +445 -0
- package/src/types/index.ts +2 -0
- package/src/utils/binUtils.ts +552 -0
- package/src/utils/feeUtils.ts +92 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/parseData.ts +519 -0
- package/src/utils/strategyUtils.ts +121 -0
- package/src/utils/weightUtils.ts +510 -0
- package/tests/add_liquidity_bidask.test.ts +180 -0
- package/tests/add_liquidity_curve.test.ts +244 -0
- package/tests/add_liquidity_spot.test.ts +262 -0
- package/tests/bin.test.ts +80 -0
- package/tests/config.test.ts +51 -0
- package/tests/partner.test.ts +74 -0
- package/tests/pool.test.ts +174 -0
- package/tests/position.test.ts +76 -0
- package/tests/remove_liquidity.test.ts +137 -0
- package/tests/swap.test.ts +96 -0
- package/tests/tsconfig.json +26 -0
- package/tsconfig.json +5 -0
- package/tsup.config.ts +9 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1015 @@
|
|
|
1
|
+
import { CoinPairType, TableHandle, IModule, PaginationArgs, DataPage, PageQuery, SdkWrapper, BaseSdkOptions, Package } from '@cetusprotocol/common-sdk';
|
|
2
|
+
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
3
|
+
import { SuiEvent, SuiObjectResponse, DevInspectResults, SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
4
|
+
import Decimal from 'decimal.js';
|
|
5
|
+
import BN from 'bn.js';
|
|
6
|
+
|
|
7
|
+
type DlmmConfigs = {
|
|
8
|
+
registry_id: string;
|
|
9
|
+
pools_id: string;
|
|
10
|
+
partners_id: string;
|
|
11
|
+
global_config_id: string;
|
|
12
|
+
versioned_id: string;
|
|
13
|
+
admin_cap_id: string;
|
|
14
|
+
};
|
|
15
|
+
type BinStepConfig = {
|
|
16
|
+
bin_step: number;
|
|
17
|
+
base_factor: number;
|
|
18
|
+
filter_period: number;
|
|
19
|
+
decay_period: number;
|
|
20
|
+
reduction_factor: number;
|
|
21
|
+
variable_fee_control: string;
|
|
22
|
+
max_volatility_accumulator: string;
|
|
23
|
+
protocol_fee_rate: string;
|
|
24
|
+
};
|
|
25
|
+
type BinManager = {
|
|
26
|
+
bin_step: number;
|
|
27
|
+
bin_manager_handle: string;
|
|
28
|
+
size: string;
|
|
29
|
+
};
|
|
30
|
+
type VariableParameters = {
|
|
31
|
+
volatility_accumulator: string;
|
|
32
|
+
volatility_reference: string;
|
|
33
|
+
index_reference: number;
|
|
34
|
+
last_update_timestamp: string;
|
|
35
|
+
bin_step_config: BinStepConfig;
|
|
36
|
+
};
|
|
37
|
+
type Reward = {
|
|
38
|
+
reward_coin: string;
|
|
39
|
+
emissions_per_second: string;
|
|
40
|
+
emissions_per_day: string;
|
|
41
|
+
period_emission_rates: TableHandle;
|
|
42
|
+
};
|
|
43
|
+
type RewardManager = {
|
|
44
|
+
is_public: boolean;
|
|
45
|
+
vault: TableHandle;
|
|
46
|
+
rewards: Reward[];
|
|
47
|
+
emergency_reward_pause: boolean;
|
|
48
|
+
last_updated_time: string;
|
|
49
|
+
};
|
|
50
|
+
type PositionManager = {
|
|
51
|
+
bin_step: number;
|
|
52
|
+
position_index: number;
|
|
53
|
+
position_handle: string;
|
|
54
|
+
size: number;
|
|
55
|
+
};
|
|
56
|
+
type DlmmBasePool = {
|
|
57
|
+
id: string;
|
|
58
|
+
bin_step: number;
|
|
59
|
+
} & CoinPairType;
|
|
60
|
+
type PoolPermissions = {
|
|
61
|
+
disable_add: boolean;
|
|
62
|
+
disable_remove: boolean;
|
|
63
|
+
disable_swap: boolean;
|
|
64
|
+
disable_collect_fee: boolean;
|
|
65
|
+
disable_collect_reward: boolean;
|
|
66
|
+
disable_add_reward: boolean;
|
|
67
|
+
};
|
|
68
|
+
type DlmmPool = {
|
|
69
|
+
pool_type: string;
|
|
70
|
+
index: number;
|
|
71
|
+
bin_manager: BinManager;
|
|
72
|
+
variable_parameters: VariableParameters;
|
|
73
|
+
active_id: number;
|
|
74
|
+
permissions: PoolPermissions;
|
|
75
|
+
balance_a: string;
|
|
76
|
+
balance_b: string;
|
|
77
|
+
base_fee_rate: string;
|
|
78
|
+
protocol_fee_a: string;
|
|
79
|
+
protocol_fee_b: string;
|
|
80
|
+
url: string;
|
|
81
|
+
reward_manager: RewardManager;
|
|
82
|
+
position_manager: PositionManager;
|
|
83
|
+
} & DlmmBasePool;
|
|
84
|
+
type DlmmPosition = {
|
|
85
|
+
id: string;
|
|
86
|
+
pool_id: string;
|
|
87
|
+
index: number;
|
|
88
|
+
description: string;
|
|
89
|
+
uri: string;
|
|
90
|
+
liquidity_shares: string[];
|
|
91
|
+
lower_bin_id: number;
|
|
92
|
+
upper_bin_id: number;
|
|
93
|
+
name: string;
|
|
94
|
+
} & CoinPairType;
|
|
95
|
+
type BinWeight = {
|
|
96
|
+
bin_id: number;
|
|
97
|
+
weight: number;
|
|
98
|
+
};
|
|
99
|
+
type BinAmount = {
|
|
100
|
+
bin_id: number;
|
|
101
|
+
amount_a: string;
|
|
102
|
+
amount_b: string;
|
|
103
|
+
liquidity?: string;
|
|
104
|
+
price_per_lamport: string;
|
|
105
|
+
};
|
|
106
|
+
type BinLiquidityInfo = {
|
|
107
|
+
bins: BinAmount[];
|
|
108
|
+
amount_a: string;
|
|
109
|
+
amount_b: string;
|
|
110
|
+
};
|
|
111
|
+
declare enum StrategyType {
|
|
112
|
+
Spot = 0,
|
|
113
|
+
Curve = 1,
|
|
114
|
+
BidAsk = 2
|
|
115
|
+
}
|
|
116
|
+
type ClosePositionOption = {
|
|
117
|
+
pool_id: string;
|
|
118
|
+
position_id: string;
|
|
119
|
+
reward_coins: string[];
|
|
120
|
+
} & CoinPairType;
|
|
121
|
+
type BaseCreatePoolOption = {
|
|
122
|
+
bin_step: number;
|
|
123
|
+
base_factor: number;
|
|
124
|
+
url?: string;
|
|
125
|
+
} & CoinPairType;
|
|
126
|
+
type BaseCreatePoolAndAddOption = {
|
|
127
|
+
bin_infos: BinLiquidityInfo;
|
|
128
|
+
strategy_type: StrategyType;
|
|
129
|
+
use_bin_infos?: boolean;
|
|
130
|
+
} & BaseCreatePoolOption;
|
|
131
|
+
type CreatePoolAndAddOption = {
|
|
132
|
+
active_id: number;
|
|
133
|
+
lower_bin_id: number;
|
|
134
|
+
upper_bin_id: number;
|
|
135
|
+
} & BaseCreatePoolAndAddOption;
|
|
136
|
+
type CreatePoolOption = {
|
|
137
|
+
active_id: number;
|
|
138
|
+
} & BaseCreatePoolOption;
|
|
139
|
+
type CreatePoolAndAddWithPriceOption = {
|
|
140
|
+
price_base_coin: 'coin_a' | 'coin_b';
|
|
141
|
+
price: string;
|
|
142
|
+
lower_price: string;
|
|
143
|
+
upper_price: string;
|
|
144
|
+
strategy_type: StrategyType;
|
|
145
|
+
decimals_a: number;
|
|
146
|
+
decimals_b: number;
|
|
147
|
+
} & BaseCreatePoolAndAddOption;
|
|
148
|
+
type BaseAddLiquidityOption = {
|
|
149
|
+
pool_id: string | TransactionObjectArgument;
|
|
150
|
+
bin_infos: BinLiquidityInfo;
|
|
151
|
+
strategy_type: StrategyType;
|
|
152
|
+
max_price_slippage: number;
|
|
153
|
+
active_id: number;
|
|
154
|
+
bin_step: number;
|
|
155
|
+
/**
|
|
156
|
+
* Controls whether to use pre-calculated bin_infos or let the contract calculate based on strategy_type.
|
|
157
|
+
* - true: Use bin_infos to add liquidity to each bin
|
|
158
|
+
* - false: Pass strategy_type to contract for automatic liquidity distribution calculation
|
|
159
|
+
*/
|
|
160
|
+
use_bin_infos?: boolean;
|
|
161
|
+
} & CoinPairType;
|
|
162
|
+
type BaseCalculateAddLiquidityOption = {
|
|
163
|
+
active_id: number;
|
|
164
|
+
bin_step: number;
|
|
165
|
+
lower_bin_id: number;
|
|
166
|
+
upper_bin_id: number;
|
|
167
|
+
amount_a_in_active_bin: string;
|
|
168
|
+
amount_b_in_active_bin: string;
|
|
169
|
+
strategy_type: StrategyType;
|
|
170
|
+
};
|
|
171
|
+
type CalculateAddLiquidityOption = {
|
|
172
|
+
amount_a: string;
|
|
173
|
+
amount_b: string;
|
|
174
|
+
} & BaseCalculateAddLiquidityOption;
|
|
175
|
+
type CalculateAddLiquidityAutoFillOption = {
|
|
176
|
+
coin_amount: string;
|
|
177
|
+
fix_amount_a: boolean;
|
|
178
|
+
} & BaseCalculateAddLiquidityOption;
|
|
179
|
+
type AddLiquidityOption = BaseAddLiquidityOption & {
|
|
180
|
+
position_id: string;
|
|
181
|
+
collect_fee: boolean;
|
|
182
|
+
reward_coins: string[];
|
|
183
|
+
};
|
|
184
|
+
type OpenAndAddLiquidityOption = BaseAddLiquidityOption & {
|
|
185
|
+
lower_bin_id: number;
|
|
186
|
+
upper_bin_id: number;
|
|
187
|
+
};
|
|
188
|
+
type OpenAndAddLiquidityWithPriceOption = BaseAddLiquidityOption & {
|
|
189
|
+
price_base_coin: 'coin_a' | 'coin_b';
|
|
190
|
+
price: string;
|
|
191
|
+
lower_price: string;
|
|
192
|
+
upper_price: string;
|
|
193
|
+
amount_a_in_active_bin: string;
|
|
194
|
+
amount_b_in_active_bin: string;
|
|
195
|
+
strategy_type: StrategyType;
|
|
196
|
+
decimals_a: number;
|
|
197
|
+
decimals_b: number;
|
|
198
|
+
max_price_slippage: number;
|
|
199
|
+
};
|
|
200
|
+
type OpenPositionOption = {
|
|
201
|
+
pool_id: string;
|
|
202
|
+
lower_bin_id: number;
|
|
203
|
+
upper_bin_id: number;
|
|
204
|
+
} & CoinPairType;
|
|
205
|
+
type CalculateRemoveLiquidityBothOption = {
|
|
206
|
+
bins: BinAmount[];
|
|
207
|
+
active_id: number;
|
|
208
|
+
fix_amount_a: boolean;
|
|
209
|
+
coin_amount: string;
|
|
210
|
+
};
|
|
211
|
+
type CalculateRemoveLiquidityOnlyOption = {
|
|
212
|
+
bins: BinAmount[];
|
|
213
|
+
active_id: number;
|
|
214
|
+
is_only_a: boolean;
|
|
215
|
+
coin_amount: string;
|
|
216
|
+
};
|
|
217
|
+
type RemoveLiquidityOption = {
|
|
218
|
+
pool_id: string;
|
|
219
|
+
position_id: string;
|
|
220
|
+
active_id: number;
|
|
221
|
+
bin_step: number;
|
|
222
|
+
bin_infos: BinLiquidityInfo;
|
|
223
|
+
slippage: number;
|
|
224
|
+
reward_coins: string[];
|
|
225
|
+
collect_fee: boolean;
|
|
226
|
+
remove_percent?: number;
|
|
227
|
+
} & CoinPairType;
|
|
228
|
+
type CollectRewardOption = {
|
|
229
|
+
pool_id: string;
|
|
230
|
+
position_id: string;
|
|
231
|
+
reward_coins: string[];
|
|
232
|
+
} & CoinPairType;
|
|
233
|
+
type CollectFeeOption = {
|
|
234
|
+
pool_id: string;
|
|
235
|
+
position_id: string;
|
|
236
|
+
} & CoinPairType;
|
|
237
|
+
type CollectRewardAndFeeOption = {
|
|
238
|
+
pool_id: string;
|
|
239
|
+
position_id: string;
|
|
240
|
+
reward_coins: string[];
|
|
241
|
+
} & CoinPairType;
|
|
242
|
+
type BinSwap = {
|
|
243
|
+
bin_id: number;
|
|
244
|
+
in_amount: string;
|
|
245
|
+
out_amount: string;
|
|
246
|
+
fee: string;
|
|
247
|
+
var_fee_rate: string;
|
|
248
|
+
};
|
|
249
|
+
type PreSwapQuote = {
|
|
250
|
+
pool_id: string;
|
|
251
|
+
a2b: boolean;
|
|
252
|
+
in_amount: string;
|
|
253
|
+
out_amount: string;
|
|
254
|
+
ref_fee_amount: string;
|
|
255
|
+
fee_amount: string;
|
|
256
|
+
partner: string;
|
|
257
|
+
from_coin_type: string;
|
|
258
|
+
to_coin_type: string;
|
|
259
|
+
bin_swaps: BinSwap[];
|
|
260
|
+
};
|
|
261
|
+
type PreSwapOption = {
|
|
262
|
+
pool_id: string;
|
|
263
|
+
a2b: boolean;
|
|
264
|
+
by_amount_in: boolean;
|
|
265
|
+
in_amount: string;
|
|
266
|
+
} & CoinPairType;
|
|
267
|
+
type SwapOption = {
|
|
268
|
+
quote_obj: PreSwapQuote;
|
|
269
|
+
by_amount_in: boolean;
|
|
270
|
+
partner?: string;
|
|
271
|
+
slippage: number;
|
|
272
|
+
} & CoinPairType;
|
|
273
|
+
type PositionFee = {
|
|
274
|
+
position_id: string;
|
|
275
|
+
fee_owned_a: string;
|
|
276
|
+
fee_owned_b: string;
|
|
277
|
+
};
|
|
278
|
+
type RewardInfo = {
|
|
279
|
+
coin_type: string;
|
|
280
|
+
reward_owned: string;
|
|
281
|
+
};
|
|
282
|
+
type PositionReward = {
|
|
283
|
+
position_id: string;
|
|
284
|
+
rewards: RewardInfo[];
|
|
285
|
+
};
|
|
286
|
+
type CreatePartnerOption = {
|
|
287
|
+
name: string;
|
|
288
|
+
ref_fee_rate: number;
|
|
289
|
+
start_time: number;
|
|
290
|
+
end_time: number;
|
|
291
|
+
recipient: string;
|
|
292
|
+
};
|
|
293
|
+
type UpdateRefFeeRateOption = {
|
|
294
|
+
partner_id: string;
|
|
295
|
+
ref_fee_rate: number;
|
|
296
|
+
};
|
|
297
|
+
type UpdateTimeRangeOption = {
|
|
298
|
+
partner_id: string;
|
|
299
|
+
start_time: number;
|
|
300
|
+
end_time: number;
|
|
301
|
+
};
|
|
302
|
+
type ClaimRefFeeOption = {
|
|
303
|
+
partner_id: string;
|
|
304
|
+
partner_cap_id?: string;
|
|
305
|
+
fee_coin_types: string[];
|
|
306
|
+
};
|
|
307
|
+
type Partner = {
|
|
308
|
+
id: string;
|
|
309
|
+
name: string;
|
|
310
|
+
ref_fee_rate: number;
|
|
311
|
+
start_time: number;
|
|
312
|
+
end_time: number;
|
|
313
|
+
balances: TableHandle;
|
|
314
|
+
type: string;
|
|
315
|
+
};
|
|
316
|
+
type PoolTransactionInfo = {
|
|
317
|
+
index: string;
|
|
318
|
+
tx: string;
|
|
319
|
+
sender: string;
|
|
320
|
+
type: string;
|
|
321
|
+
block_time: string;
|
|
322
|
+
parsed_json: any;
|
|
323
|
+
};
|
|
324
|
+
type AddRewardOption = {
|
|
325
|
+
pool_id: string;
|
|
326
|
+
reward_coin_type: string;
|
|
327
|
+
reward_amount: string;
|
|
328
|
+
start_time_seconds?: number;
|
|
329
|
+
end_time_seconds: number;
|
|
330
|
+
} & CoinPairType;
|
|
331
|
+
type InitRewardOption = {
|
|
332
|
+
pool_id: string;
|
|
333
|
+
reward_coin_types: string[];
|
|
334
|
+
} & CoinPairType;
|
|
335
|
+
type RewardWhiteListOption = {
|
|
336
|
+
reward_coin_types: string[];
|
|
337
|
+
type: 'add' | 'remove';
|
|
338
|
+
};
|
|
339
|
+
type RewardAccessOption = {
|
|
340
|
+
pool_id: string;
|
|
341
|
+
type: 'to_public' | 'to_private';
|
|
342
|
+
} & CoinPairType;
|
|
343
|
+
type ValidateActiveIdSlippageOption = {
|
|
344
|
+
pool_id: string | TransactionObjectArgument;
|
|
345
|
+
active_id: number;
|
|
346
|
+
bin_step: number;
|
|
347
|
+
max_price_slippage: number;
|
|
348
|
+
} & CoinPairType;
|
|
349
|
+
type DlmmGlobalConfig = {
|
|
350
|
+
id: string;
|
|
351
|
+
acl: TableHandle;
|
|
352
|
+
allowed_list: TableHandle;
|
|
353
|
+
denied_list: TableHandle;
|
|
354
|
+
bin_steps: TableHandle;
|
|
355
|
+
reward_white_list: string[];
|
|
356
|
+
blocked_position: TableHandle;
|
|
357
|
+
blocked_user: TableHandle;
|
|
358
|
+
min_reward_duration: number;
|
|
359
|
+
non_manager_initialize_reward_cap: number;
|
|
360
|
+
reward_public: boolean;
|
|
361
|
+
};
|
|
362
|
+
type UpdatePositionFeeAndRewardsOption = {
|
|
363
|
+
pool_id: string;
|
|
364
|
+
position_id: string;
|
|
365
|
+
} & CoinPairType;
|
|
366
|
+
type RewardPeriodEmission = {
|
|
367
|
+
emissions_per_second: string;
|
|
368
|
+
emissions_per_day: string;
|
|
369
|
+
emissions_per: string;
|
|
370
|
+
time: string;
|
|
371
|
+
visualized_time: string;
|
|
372
|
+
};
|
|
373
|
+
type RewardPeriodEmissionFormat = {
|
|
374
|
+
emissions_per_second: string;
|
|
375
|
+
emissions_per_day: string;
|
|
376
|
+
time: string;
|
|
377
|
+
visualized_time: string;
|
|
378
|
+
};
|
|
379
|
+
type GetPoolBinInfoOption = {
|
|
380
|
+
pool_id: string;
|
|
381
|
+
} & CoinPairType;
|
|
382
|
+
type GetTotalFeeRateOption = {
|
|
383
|
+
pool_id: string;
|
|
384
|
+
} & CoinPairType;
|
|
385
|
+
type FeeRate = {
|
|
386
|
+
base_fee_rate: string;
|
|
387
|
+
var_fee_rate: string;
|
|
388
|
+
total_fee_rate: string;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
declare class PoolModule implements IModule<CetusDlmmSDK> {
|
|
392
|
+
protected _sdk: CetusDlmmSDK;
|
|
393
|
+
constructor(sdk: CetusDlmmSDK);
|
|
394
|
+
get sdk(): CetusDlmmSDK;
|
|
395
|
+
/**
|
|
396
|
+
* Get the list of DLMM base pools
|
|
397
|
+
* @param pagination_args - The pagination arguments
|
|
398
|
+
* @returns The list of DLMM base pools
|
|
399
|
+
*/
|
|
400
|
+
getBasePoolList(pagination_args?: PaginationArgs, force_refresh?: boolean): Promise<DataPage<DlmmBasePool>>;
|
|
401
|
+
/**
|
|
402
|
+
* Get the list of DLMM pools
|
|
403
|
+
* @param pagination_args - The pagination arguments
|
|
404
|
+
* @returns The list of DLMM pools
|
|
405
|
+
*/
|
|
406
|
+
getPools(pagination_args?: PaginationArgs, force_refresh?: boolean): Promise<DataPage<DlmmPool>>;
|
|
407
|
+
/**
|
|
408
|
+
* Get the bin info by bin id
|
|
409
|
+
* @param bin_manager_handle - The bin manager handle
|
|
410
|
+
* @param bin_id - The bin id
|
|
411
|
+
* @param bin_step - The bin step
|
|
412
|
+
* @param force_refresh - Whether to force a refresh of the cache
|
|
413
|
+
* @returns The bin info
|
|
414
|
+
*/
|
|
415
|
+
getBinInfo(bin_manager_handle: string, bin_id: number, bin_step: number, force_refresh?: boolean): Promise<BinAmount>;
|
|
416
|
+
getTotalFeeRate(option: GetTotalFeeRateOption): Promise<FeeRate>;
|
|
417
|
+
getPoolBinInfo(option: GetPoolBinInfoOption): Promise<BinAmount[]>;
|
|
418
|
+
getPoolTransactionList({ pool_id, pagination_args, order, full_rpc_url, }: {
|
|
419
|
+
pool_id: string;
|
|
420
|
+
full_rpc_url?: string;
|
|
421
|
+
pagination_args: PageQuery;
|
|
422
|
+
order?: 'ascending' | 'descending' | null | undefined;
|
|
423
|
+
}): Promise<DataPage<PoolTransactionInfo>>;
|
|
424
|
+
/**
|
|
425
|
+
* Get the bin info by range (TODO: need to optimize this method)
|
|
426
|
+
* @param bin_manager_handle - The bin manager handle
|
|
427
|
+
* @param lower_bin_id - The lower bin id
|
|
428
|
+
* @param upper_bin_id - The upper bin id
|
|
429
|
+
* @param bin_step - The bin step
|
|
430
|
+
* @returns The bin info by range
|
|
431
|
+
*/
|
|
432
|
+
getRangeBinInfo(bin_manager_handle: string, lower_bin_id: number, upper_bin_id: number, bin_step: number): Promise<BinAmount[]>;
|
|
433
|
+
/**
|
|
434
|
+
* Get the list of DLMM pools by assign pool ids
|
|
435
|
+
* @param assign_pool_ids - The assign pool ids
|
|
436
|
+
* @returns The list of DLMM pools
|
|
437
|
+
*/
|
|
438
|
+
getAssignPoolList(assign_pool_ids: string[]): Promise<DlmmPool[]>;
|
|
439
|
+
/**
|
|
440
|
+
* Get a DLMM pool by its object ID.
|
|
441
|
+
* @param {string} pool_id The object ID of the pool to get.
|
|
442
|
+
* @param {true} force_refresh Whether to force a refresh of the cache.
|
|
443
|
+
* @returns {Promise<DlmmPool>} A promise that resolves to a DlmmPool object.
|
|
444
|
+
*/
|
|
445
|
+
getPool(pool_id: string, force_refresh?: boolean): Promise<DlmmPool>;
|
|
446
|
+
/**
|
|
447
|
+
* Create a pool and add liquidity with a given price
|
|
448
|
+
* @param option - The option for creating a pool and adding liquidity with a given price
|
|
449
|
+
* @returns The transaction for creating a pool and adding liquidity with a given price
|
|
450
|
+
*/
|
|
451
|
+
createPoolAndAddWithPricePayload(option: CreatePoolAndAddWithPriceOption): Promise<Transaction>;
|
|
452
|
+
/**
|
|
453
|
+
* Create a pool
|
|
454
|
+
* @param option - The option for creating a pool
|
|
455
|
+
* @param tx - The transaction object
|
|
456
|
+
* @returns The transaction object
|
|
457
|
+
*/
|
|
458
|
+
createPoolPayload(option: CreatePoolOption, tx: Transaction): Promise<TransactionObjectArgument>;
|
|
459
|
+
/**
|
|
460
|
+
* Create a pool and add liquidity
|
|
461
|
+
* @param option - The option for creating a pool and adding liquidity
|
|
462
|
+
* @returns The transaction for creating a pool and adding liquidity
|
|
463
|
+
*/
|
|
464
|
+
createPoolAndAddLiquidityPayload(option: CreatePoolAndAddOption): Promise<Transaction>;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
declare class PositionModule implements IModule<CetusDlmmSDK> {
|
|
468
|
+
protected _sdk: CetusDlmmSDK;
|
|
469
|
+
constructor(sdk: CetusDlmmSDK);
|
|
470
|
+
get sdk(): CetusDlmmSDK;
|
|
471
|
+
buildPositionType(): string;
|
|
472
|
+
getOwnerPositionList(owner: string): Promise<DlmmPosition[]>;
|
|
473
|
+
getPosition(position_id: string): Promise<DlmmPosition>;
|
|
474
|
+
/**
|
|
475
|
+
* Collect fee
|
|
476
|
+
* @param option - The option for collecting fee
|
|
477
|
+
* @param tx - The transaction object
|
|
478
|
+
* @returns The transaction object
|
|
479
|
+
*/
|
|
480
|
+
collectFeePayload(option: CollectFeeOption, tx?: Transaction): Transaction;
|
|
481
|
+
/**
|
|
482
|
+
* Update the fee and rewards of the position
|
|
483
|
+
* @param option - The option for updating the fee and rewards of the position
|
|
484
|
+
* @param tx - The transaction object
|
|
485
|
+
* @returns The transaction object
|
|
486
|
+
*/
|
|
487
|
+
updatePositionFeeAndRewards(option: UpdatePositionFeeAndRewardsOption, tx: Transaction): Transaction;
|
|
488
|
+
/**
|
|
489
|
+
* Collect reward
|
|
490
|
+
* @param options - The option for collecting reward
|
|
491
|
+
* @param tx - The transaction object
|
|
492
|
+
* @returns The transaction object
|
|
493
|
+
*/
|
|
494
|
+
collectRewardPayload(options: CollectRewardOption[], tx?: Transaction): Transaction;
|
|
495
|
+
collectRewardAndFeePayload(options: CollectRewardAndFeeOption[], tx?: Transaction): Transaction;
|
|
496
|
+
/**
|
|
497
|
+
* Validate the active id slippage
|
|
498
|
+
* @param options - The option for validating the active id slippage
|
|
499
|
+
* @param tx - The transaction object
|
|
500
|
+
* @returns The transaction object
|
|
501
|
+
*/
|
|
502
|
+
validateActiveIdSlippage(options: ValidateActiveIdSlippageOption, tx: Transaction): Transaction;
|
|
503
|
+
/**
|
|
504
|
+
* Close a position
|
|
505
|
+
* @param option - The option for closing a position
|
|
506
|
+
* @returns The transaction object
|
|
507
|
+
*/
|
|
508
|
+
closePositionPayload(option: ClosePositionOption, tx?: Transaction): Transaction;
|
|
509
|
+
/**
|
|
510
|
+
* Get the amounts in the active bin if in range
|
|
511
|
+
* @param bin_manager_handle - The bin manager handle
|
|
512
|
+
* @param lower_bin_id - The lower bin id
|
|
513
|
+
* @param upper_bin_id - The upper bin id
|
|
514
|
+
* @param active_id - The active id
|
|
515
|
+
* @returns The amounts in the active bin if in range
|
|
516
|
+
*/
|
|
517
|
+
getActiveBinIfInRange(bin_manager_handle: string, lower_bin_id: number, upper_bin_id: number, active_id: number, bin_step: number, force_refresh?: boolean): Promise<BinAmount | undefined>;
|
|
518
|
+
/**
|
|
519
|
+
* Calculate the result of removing liquidity
|
|
520
|
+
* @param option - The option for calculating the result of removing liquidity
|
|
521
|
+
* @returns The result of removing liquidity
|
|
522
|
+
*/
|
|
523
|
+
calculateRemoveLiquidityInfo(option: CalculateRemoveLiquidityBothOption | CalculateRemoveLiquidityOnlyOption): BinLiquidityInfo;
|
|
524
|
+
/**
|
|
525
|
+
* Calculate the result of adding liquidity
|
|
526
|
+
* @param option - The option for calculating the result of adding liquidity
|
|
527
|
+
* @returns The result of adding liquidity
|
|
528
|
+
*/
|
|
529
|
+
calculateAddLiquidityInfo(option: CalculateAddLiquidityOption | CalculateAddLiquidityAutoFillOption): BinLiquidityInfo;
|
|
530
|
+
/**
|
|
531
|
+
* Remove liquidity
|
|
532
|
+
* @param option - The option for removing liquidity
|
|
533
|
+
* @returns The transaction
|
|
534
|
+
*/
|
|
535
|
+
removeLiquidityPayload(option: RemoveLiquidityOption): Transaction;
|
|
536
|
+
/**
|
|
537
|
+
* Add liquidity with price
|
|
538
|
+
* @param option - The option for adding liquidity with price
|
|
539
|
+
* @returns The transaction
|
|
540
|
+
*/
|
|
541
|
+
addLiquidityWithPricePayload(option: OpenAndAddLiquidityWithPriceOption): Transaction;
|
|
542
|
+
/**
|
|
543
|
+
* Add liquidity
|
|
544
|
+
* @param option - The option for adding liquidity
|
|
545
|
+
* @returns The transaction object
|
|
546
|
+
*/
|
|
547
|
+
addLiquidityPayload(option: AddLiquidityOption | OpenAndAddLiquidityOption, tx?: Transaction): Transaction;
|
|
548
|
+
private addLiquidityStrategyInternal;
|
|
549
|
+
private addLiquidityInternal;
|
|
550
|
+
/**
|
|
551
|
+
* Fetch the fee and reward of the position
|
|
552
|
+
* @param options - The option for fetching the fee and reward of the position
|
|
553
|
+
* @returns The fee and reward of the position
|
|
554
|
+
*/
|
|
555
|
+
fetchPositionFeeAndReward(options: CollectRewardAndFeeOption[]): Promise<{
|
|
556
|
+
feeData: Record<string, PositionFee>;
|
|
557
|
+
rewardData: Record<string, PositionReward>;
|
|
558
|
+
}>;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
declare class SwapModule implements IModule<CetusDlmmSDK> {
|
|
562
|
+
protected _sdk: CetusDlmmSDK;
|
|
563
|
+
constructor(sdk: CetusDlmmSDK);
|
|
564
|
+
get sdk(): CetusDlmmSDK;
|
|
565
|
+
preSwapQuote(option: PreSwapOption): Promise<PreSwapQuote>;
|
|
566
|
+
swapPayload(option: SwapOption): Transaction;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
declare class PartnerModule implements IModule<CetusDlmmSDK> {
|
|
570
|
+
protected _sdk: CetusDlmmSDK;
|
|
571
|
+
constructor(sdk: CetusDlmmSDK);
|
|
572
|
+
get sdk(): CetusDlmmSDK;
|
|
573
|
+
/**
|
|
574
|
+
* Get a list of partners.
|
|
575
|
+
* @returns {Promise<Partner[]>} A promise that resolves to an array of Partner objects.
|
|
576
|
+
*/
|
|
577
|
+
getPartnerList(): Promise<Partner[]>;
|
|
578
|
+
/**
|
|
579
|
+
* Get the partner cap ID for a given owner and partner ID.
|
|
580
|
+
* @param owner - The owner of the partner.
|
|
581
|
+
* @param partner_id - The ID of the partner.
|
|
582
|
+
* @returns A promise that resolves to the partner cap ID or undefined if not found.
|
|
583
|
+
*/
|
|
584
|
+
getPartnerCapId(owner: string, partner_id: string): Promise<string>;
|
|
585
|
+
/**
|
|
586
|
+
* Get the balance of a partner
|
|
587
|
+
* @param partner_balance_handle - The handle of the partner balance
|
|
588
|
+
* @returns A promise that resolves to an array of { coin_type: string; balance: string } objects.
|
|
589
|
+
*/
|
|
590
|
+
getPartnerBalance(partner_balance_handle: string): Promise<{
|
|
591
|
+
coin_type: string;
|
|
592
|
+
balance: string;
|
|
593
|
+
}[]>;
|
|
594
|
+
/**
|
|
595
|
+
* Get a partner by its object ID.
|
|
596
|
+
* @param {string} partner_id The object ID of the partner to get.
|
|
597
|
+
* @returns {Promise<Partner>} A promise that resolves to a Partner object.
|
|
598
|
+
*/
|
|
599
|
+
getPartner(partner_id: string): Promise<Partner>;
|
|
600
|
+
/**
|
|
601
|
+
* Update the ref fee rate of a partner
|
|
602
|
+
* @param option - The option for updating the ref fee rate
|
|
603
|
+
* @returns The transaction for updating the ref fee rate
|
|
604
|
+
*/
|
|
605
|
+
updateRefFeeRatePayload(option: UpdateRefFeeRateOption, tx?: Transaction): Transaction;
|
|
606
|
+
/**
|
|
607
|
+
* Create a claim ref fee payload
|
|
608
|
+
* @param option - The option for claiming ref fee
|
|
609
|
+
* @returns The transaction for claiming ref fee
|
|
610
|
+
*/
|
|
611
|
+
claimRefFeePayload(option: ClaimRefFeeOption): Promise<Transaction>;
|
|
612
|
+
updateTimeRangePayload(option: UpdateTimeRangeOption, tx?: Transaction): Transaction;
|
|
613
|
+
/**
|
|
614
|
+
* Create a partner
|
|
615
|
+
* @param option - The option for creating a partner
|
|
616
|
+
* @returns The transaction for creating a partner
|
|
617
|
+
*/
|
|
618
|
+
createPartnerPayload(option: CreatePartnerOption): Transaction;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
declare class RewardModule implements IModule<CetusDlmmSDK> {
|
|
622
|
+
protected _sdk: CetusDlmmSDK;
|
|
623
|
+
constructor(sdk: CetusDlmmSDK);
|
|
624
|
+
get sdk(): CetusDlmmSDK;
|
|
625
|
+
getRewardPeriodEmission(period_emission_handle: string, curr_emission_per_second: string, last_updated_time: number): Promise<RewardPeriodEmission[]>;
|
|
626
|
+
/**
|
|
627
|
+
* Add reward to a pool
|
|
628
|
+
* @param options - The options for adding reward
|
|
629
|
+
* @returns The transaction for adding reward
|
|
630
|
+
*/
|
|
631
|
+
addRewardPayload(option: AddRewardOption, tx?: Transaction): Transaction;
|
|
632
|
+
/**
|
|
633
|
+
* Initialize reward for a pool
|
|
634
|
+
* @param option - The option for initializing reward
|
|
635
|
+
* @param tx - The transaction to add the reward to
|
|
636
|
+
* @returns The transaction for initializing reward
|
|
637
|
+
*/
|
|
638
|
+
initRewardPayload(option: InitRewardOption, tx?: Transaction): Transaction;
|
|
639
|
+
/**
|
|
640
|
+
* Build the payload for making reward public or private
|
|
641
|
+
* @param option - The option for making reward public or private
|
|
642
|
+
* @param tx - The transaction to make the reward public or private
|
|
643
|
+
* @returns The transaction for making reward public or private
|
|
644
|
+
*/
|
|
645
|
+
buildRewardAccessPayload(option: RewardAccessOption, tx?: Transaction): Transaction;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
declare class ConfigModule implements IModule<CetusDlmmSDK> {
|
|
649
|
+
protected _sdk: CetusDlmmSDK;
|
|
650
|
+
constructor(sdk: CetusDlmmSDK);
|
|
651
|
+
get sdk(): CetusDlmmSDK;
|
|
652
|
+
/**
|
|
653
|
+
* Build the payload for adding or removing reward white list
|
|
654
|
+
* @param option - The option for adding or removing reward white list
|
|
655
|
+
* @param tx - The transaction to add the reward white list to
|
|
656
|
+
* @returns The transaction for adding or removing reward white list
|
|
657
|
+
*/
|
|
658
|
+
buildRewardWhiteListPayload(option: RewardWhiteListOption, tx?: Transaction): Transaction;
|
|
659
|
+
getBinStepConfigList(bin_steps_handle: string): Promise<BinStepConfig[]>;
|
|
660
|
+
/**
|
|
661
|
+
* Get the list of bin step configs
|
|
662
|
+
* @returns The list of bin step configs
|
|
663
|
+
*/
|
|
664
|
+
getDlmmGlobalConfig(): Promise<DlmmGlobalConfig>;
|
|
665
|
+
/**
|
|
666
|
+
* Fetch the configs of the dlmm SDK
|
|
667
|
+
* @returns The configs of the dlmm
|
|
668
|
+
*/
|
|
669
|
+
fetchDlmmSdkConfigs(): Promise<DlmmConfigs>;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Represents options and configurations for an SDK.
|
|
674
|
+
*/
|
|
675
|
+
interface SdkOptions extends BaseSdkOptions {
|
|
676
|
+
dlmm_pool: Package<DlmmConfigs>;
|
|
677
|
+
dlmm_router: Package;
|
|
678
|
+
faucet?: Package;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* The entry class of CetusDcaSDK, which is almost responsible for all interactions with dca.
|
|
682
|
+
*/
|
|
683
|
+
declare class CetusDlmmSDK extends SdkWrapper<SdkOptions> {
|
|
684
|
+
protected _pool: PoolModule;
|
|
685
|
+
protected _position: PositionModule;
|
|
686
|
+
protected _swap: SwapModule;
|
|
687
|
+
protected _partner: PartnerModule;
|
|
688
|
+
protected _reward: RewardModule;
|
|
689
|
+
protected _config: ConfigModule;
|
|
690
|
+
constructor(options: SdkOptions);
|
|
691
|
+
get Pool(): PoolModule;
|
|
692
|
+
get Position(): PositionModule;
|
|
693
|
+
get Swap(): SwapModule;
|
|
694
|
+
get Partner(): PartnerModule;
|
|
695
|
+
get Reward(): RewardModule;
|
|
696
|
+
get Config(): ConfigModule;
|
|
697
|
+
/**
|
|
698
|
+
* Static factory method to initialize the SDK
|
|
699
|
+
* @param options SDK initialization options
|
|
700
|
+
* @returns An instance of CetusBurnDK
|
|
701
|
+
*/
|
|
702
|
+
static createSDK(options: BaseSdkOptions): CetusDlmmSDK;
|
|
703
|
+
/**
|
|
704
|
+
* Create a custom SDK instance with the given options
|
|
705
|
+
* @param options The options for the SDK
|
|
706
|
+
* @returns An instance of CetusBurnSDK
|
|
707
|
+
*/
|
|
708
|
+
static createCustomSDK<T extends BaseSdkOptions>(options: T & SdkOptions): CetusDlmmSDK;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Parse the DLMM base pool data
|
|
713
|
+
* @param data - The DLMM base pool data
|
|
714
|
+
* @returns The DLMM base pool
|
|
715
|
+
*/
|
|
716
|
+
declare function parseDlmmBasePool(data: SuiEvent): DlmmBasePool;
|
|
717
|
+
/**
|
|
718
|
+
* Parse the DLMM pool data
|
|
719
|
+
* @param data - The DLMM pool data
|
|
720
|
+
* @returns The DLMM pool
|
|
721
|
+
*/
|
|
722
|
+
declare function parseDlmmPool(data: SuiObjectResponse): DlmmPool;
|
|
723
|
+
declare function parsePartner(data: SuiObjectResponse): Partner;
|
|
724
|
+
declare function parseDlmmPosition(data: SuiObjectResponse): DlmmPosition;
|
|
725
|
+
declare function parseLiquidityShares(liquidity_shares: string[], bin_step: number, lower_bin_id: number, active_bin: BinAmount): BinLiquidityInfo;
|
|
726
|
+
declare function parseBinInfoList(res: DevInspectResults): BinAmount[];
|
|
727
|
+
declare function parseBinInfo(fields: any): BinAmount;
|
|
728
|
+
declare function parsedDlmmPosFeeData(simulate_res: DevInspectResults): Record<string, PositionFee>;
|
|
729
|
+
declare function parsedDlmmPosRewardData(simulate_res: DevInspectResults): Record<string, PositionReward>;
|
|
730
|
+
declare function parsedSwapQuoteData(simulate_res: DevInspectResults, a2b: boolean): PreSwapQuote | undefined;
|
|
731
|
+
declare function parseStrategyType(strategy_type: StrategyType): number;
|
|
732
|
+
declare const poolFilterEvenTypes: string[];
|
|
733
|
+
declare function parsePoolTransactionInfo(data: SuiTransactionBlockResponse, txIndex: number, package_id: string, pool_id: string): PoolTransactionInfo[];
|
|
734
|
+
declare function generateRewardSchedule(baseTime: number, maxIntervals: number, timeInterval: number): number[];
|
|
735
|
+
declare function parseRewardPeriodEmission(periodEmissionList: RewardPeriodEmission[], startTimeInSeconds: number, endTimeInSeconds: number, durationSeconds: number): RewardPeriodEmissionFormat[];
|
|
736
|
+
declare function parseCurrentRewardPeriodEmission(periodEmissionList: RewardPeriodEmission[]): RewardPeriodEmission | undefined;
|
|
737
|
+
declare function safeMulAmount(amount: Decimal, rate: Decimal): Decimal;
|
|
738
|
+
declare function getRouterModule(strategy_type: StrategyType): "spot" | "curve" | "bid_ask";
|
|
739
|
+
|
|
740
|
+
declare const SCALE_OFFSET = 64;
|
|
741
|
+
declare const ONE: BN;
|
|
742
|
+
declare class BinUtils {
|
|
743
|
+
/**
|
|
744
|
+
* Split bins into multiple smaller positions based on MAX_BIN_PER_POSITION
|
|
745
|
+
* @param bins - The bins to split
|
|
746
|
+
* @param lower_bin_id - The lower bin id
|
|
747
|
+
* @param upper_bin_id - The upper bin id
|
|
748
|
+
* @returns Array of bin info objects for each position
|
|
749
|
+
*/
|
|
750
|
+
static splitBinLiquidityInfo(liquidity_bins: BinLiquidityInfo, lower_bin_id: number, upper_bin_id: number): BinLiquidityInfo[];
|
|
751
|
+
/**
|
|
752
|
+
* Process bins by rate
|
|
753
|
+
* @param bins - The bins to be processed
|
|
754
|
+
* @param rate - The rate to be applied
|
|
755
|
+
* @returns The processed bins
|
|
756
|
+
*/
|
|
757
|
+
static processBinsByRate(bins: BinAmount[], rate: string): {
|
|
758
|
+
bins: BinLiquidityInfo;
|
|
759
|
+
has_invalid_amount: boolean;
|
|
760
|
+
};
|
|
761
|
+
/**
|
|
762
|
+
* Calculate the amount of token A and token B to be removed from a bin
|
|
763
|
+
* @param bin - The bin information
|
|
764
|
+
* @param remove_liquidity - The amount of liquidity to be removed
|
|
765
|
+
* @returns The amount of token A and token B to be removed
|
|
766
|
+
*/
|
|
767
|
+
static calculateOutByShare(bin: BinAmount, remove_liquidity: string): {
|
|
768
|
+
amount_a: string;
|
|
769
|
+
amount_b: string;
|
|
770
|
+
};
|
|
771
|
+
/**
|
|
772
|
+
* Get the number of positions in a range of bin ids
|
|
773
|
+
* @param lower_bin_id - The lower bin id
|
|
774
|
+
* @param upper_bin_id - The upper bin id
|
|
775
|
+
* @returns The number of positions
|
|
776
|
+
*/
|
|
777
|
+
static getPositionCount(lower_bin_id: number, upper_bin_id: number): number;
|
|
778
|
+
/**
|
|
779
|
+
* Calculate the amount of liquidity following the constant sum formula `L = price * x + y`
|
|
780
|
+
* @param amount_a
|
|
781
|
+
* @param amount_b
|
|
782
|
+
* @param qPrice Price is in Q64x64
|
|
783
|
+
* @returns
|
|
784
|
+
*/
|
|
785
|
+
static getLiquidity(amount_a: string, amount_b: string, qPrice: string): string;
|
|
786
|
+
/**
|
|
787
|
+
* Calculate amount_a from liquidity when all liquidity is in token A
|
|
788
|
+
* @param liquidity - The liquidity amount
|
|
789
|
+
* @param qPrice - Price in Q64x64 format
|
|
790
|
+
* @returns The amount of token A
|
|
791
|
+
*/
|
|
792
|
+
static getAmountAFromLiquidity(liquidity: string, qPrice: string): string;
|
|
793
|
+
/**
|
|
794
|
+
* Calculate amount_b from liquidity when all liquidity is in token B
|
|
795
|
+
* @param liquidity - The liquidity amount
|
|
796
|
+
* @returns The amount of token B
|
|
797
|
+
*/
|
|
798
|
+
static getAmountBFromLiquidity(liquidity: string): string;
|
|
799
|
+
/**
|
|
800
|
+
* Calculate amounts from liquidity using the same logic as Move code
|
|
801
|
+
* @param amount_a - Current amount of token A in the bin
|
|
802
|
+
* @param amount_b - Current amount of token B in the bin
|
|
803
|
+
* @param delta_liquidity - The liquidity delta to calculate amounts for
|
|
804
|
+
* @param liquidity_supply - Total liquidity supply in the bin
|
|
805
|
+
* @returns [amount_a_out, amount_b_out]
|
|
806
|
+
*/
|
|
807
|
+
static getAmountsFromLiquidity(amount_a: string, amount_b: string, delta_liquidity: string, liquidity_supply: string): [string, string];
|
|
808
|
+
/**
|
|
809
|
+
* Get the price of a bin by bin id
|
|
810
|
+
* @param bin_id - The bin id
|
|
811
|
+
* @param bin_step - The bin step
|
|
812
|
+
* @param decimal_a - The decimal of the token a
|
|
813
|
+
* @param decimal_b - The decimal of the token b
|
|
814
|
+
* @returns The price of the bin
|
|
815
|
+
*/
|
|
816
|
+
static getPriceFromBinId(bin_id: number, bin_step: number, decimal_a: number, decimal_b: number): string;
|
|
817
|
+
/**
|
|
818
|
+
* Get the price per lamport of a bin by bin id
|
|
819
|
+
* @param bin_id - The bin id
|
|
820
|
+
* @param bin_step - The bin step
|
|
821
|
+
* @returns The price per lamport of the bin
|
|
822
|
+
*/
|
|
823
|
+
static getPricePerLamportFromBinId(bin_id: number, bin_step: number): string;
|
|
824
|
+
/**
|
|
825
|
+
* Get the bin id from a price
|
|
826
|
+
* @param price - The price
|
|
827
|
+
* @param binStep - The bin step
|
|
828
|
+
* @param min - Whether to use the minimum or maximum bin id
|
|
829
|
+
* @param decimal_a - The decimal of the token a
|
|
830
|
+
* @param decimal_b - The decimal of the token b
|
|
831
|
+
* @returns The bin id
|
|
832
|
+
*/
|
|
833
|
+
static getBinIdFromPrice(price: string, binStep: number, min: boolean, decimal_a: number, decimal_b: number): number;
|
|
834
|
+
/**
|
|
835
|
+
* Get the bin id from a price per lamport
|
|
836
|
+
* @param pricePerLamport - The price per lamport
|
|
837
|
+
* @param binStep - The bin step
|
|
838
|
+
* @param min - Whether to use the minimum or maximum bin id
|
|
839
|
+
* @returns The bin id
|
|
840
|
+
*/
|
|
841
|
+
static getBinIdFromLamportPrice(pricePerLamport: string, binStep: number, min: boolean): number;
|
|
842
|
+
/**
|
|
843
|
+
* Get the price per lamport
|
|
844
|
+
* @param decimal_a - The decimal of the token a
|
|
845
|
+
* @param decimal_b - The decimal of the token b
|
|
846
|
+
* @param price - The price
|
|
847
|
+
* @returns The price per lamport
|
|
848
|
+
*/
|
|
849
|
+
static getPricePerLamport(decimal_a: number, decimal_b: number, price: string): string;
|
|
850
|
+
/**
|
|
851
|
+
* Convert price per lamport back to original price
|
|
852
|
+
* @param decimal_a - The decimal of the token a
|
|
853
|
+
* @param decimal_b - The decimal of the token b
|
|
854
|
+
* @param pricePerLamport - The price per lamport
|
|
855
|
+
* @returns The original price
|
|
856
|
+
*/
|
|
857
|
+
static getPriceFromLamport(decimal_a: number, decimal_b: number, pricePerLamport: string): string;
|
|
858
|
+
/**
|
|
859
|
+
* Get the reverse price
|
|
860
|
+
* @param price - The price
|
|
861
|
+
* @returns The reverse price
|
|
862
|
+
*/
|
|
863
|
+
static getReversePrice(price: string): string;
|
|
864
|
+
/**
|
|
865
|
+
* Get the price of a bin by bin id
|
|
866
|
+
* @param binId - The bin id
|
|
867
|
+
* @param binStep - The bin step
|
|
868
|
+
* @returns The price of the bin
|
|
869
|
+
*/
|
|
870
|
+
static getQPriceFromId(binId: number, binStep: number): string;
|
|
871
|
+
/**
|
|
872
|
+
* Convert QPrice (Q64x64 format) to actual price
|
|
873
|
+
* @param qPrice - The price in Q64x64 format
|
|
874
|
+
* @returns The actual price
|
|
875
|
+
*/
|
|
876
|
+
static getPricePerLamportFromQPrice(qPrice: string): string;
|
|
877
|
+
static pow(base: BN, exp: BN): BN;
|
|
878
|
+
/**
|
|
879
|
+
* Converts a bin ID to a score by adding the bin bound and validating the range
|
|
880
|
+
* @param binId - The bin ID to convert
|
|
881
|
+
* @returns The calculated bin score
|
|
882
|
+
* @throws Error if the bin ID is invalid
|
|
883
|
+
*/
|
|
884
|
+
static binScore(binId: number): string;
|
|
885
|
+
/**
|
|
886
|
+
* Converts a score back to bin ID by subtracting the bin bound
|
|
887
|
+
* @param score - The score to convert
|
|
888
|
+
* @returns The calculated bin ID
|
|
889
|
+
* @throws Error if the score is invalid
|
|
890
|
+
*/
|
|
891
|
+
static scoreToBinId(score: string): number;
|
|
892
|
+
/**
|
|
893
|
+
* Resolves the bin position from a score.
|
|
894
|
+
*
|
|
895
|
+
* @param score - The score to resolve
|
|
896
|
+
* @returns Tuple of [group index, offset in group]
|
|
897
|
+
*/
|
|
898
|
+
static resolveBinPosition(score: string): [string, number];
|
|
899
|
+
static findMinMaxBinId(binStep: number): {
|
|
900
|
+
minBinId: number;
|
|
901
|
+
maxBinId: number;
|
|
902
|
+
};
|
|
903
|
+
static getBinShift(active_id: number, bin_step: number, max_price_slippage: number): number;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
declare class WeightUtils {
|
|
907
|
+
static toWeightSpotBalanced(min_bin_id: number, max_bin_id: number): BinWeight[];
|
|
908
|
+
static toWeightDescendingOrder(min_bin_id: number, max_bin_id: number): BinWeight[];
|
|
909
|
+
static toWeightAscendingOrder(min_bin_id: number, max_bin_id: number): BinWeight[];
|
|
910
|
+
static toWeightCurve(min_bin_id: number, max_bin_id: number, active_id: number): BinWeight[];
|
|
911
|
+
static toWeightBidAsk(min_bin_id: number, max_bin_id: number, active_id: number): BinWeight[];
|
|
912
|
+
/**
|
|
913
|
+
* Distribute totalAmount to all bid side bins according to given distributions.
|
|
914
|
+
* @param active_id - active bin id
|
|
915
|
+
* @param amount_b - total amount of coin b to be distributed
|
|
916
|
+
* @param distributions - weight distribution of each bin
|
|
917
|
+
* @returns array of {binId, amount} where amount is the amount of coin b in each bin
|
|
918
|
+
*/
|
|
919
|
+
static toAmountBidSide(active_id: number, amount_b: string, bin_step: number, distributions: BinWeight[], contain_active_bin?: boolean): BinLiquidityInfo;
|
|
920
|
+
/**
|
|
921
|
+
* Distribute totalAmount to all ask side bins according to given distributions.
|
|
922
|
+
* @param active_id active bin id
|
|
923
|
+
* @param amount_a total amount of coin a to be distributed
|
|
924
|
+
* @param distributions weight distribution of each bin
|
|
925
|
+
* @returns array of {binId, amount} where amount is the amount of coin a in each bin
|
|
926
|
+
*/
|
|
927
|
+
static toAmountAskSide(active_id: number, bin_step: number, amount_a: string, distributions: BinWeight[], contain_active_bin?: boolean): BinLiquidityInfo;
|
|
928
|
+
/**
|
|
929
|
+
* Distributes the given amounts of tokens X and Y to both bid and ask side bins
|
|
930
|
+
* based on the provided weight distributions.
|
|
931
|
+
*
|
|
932
|
+
* @param activeId - The id of the active bin.
|
|
933
|
+
* @param binStep - The step interval between bin ids.
|
|
934
|
+
* @param amountX - Total amount of token X to distribute.
|
|
935
|
+
* @param amountY - Total amount of token Y to distribute.
|
|
936
|
+
* @param amountXInActiveBin - Amount of token X already in the active bin.
|
|
937
|
+
* @param amountYInActiveBin - Amount of token Y already in the active bin.
|
|
938
|
+
* @param distributions - Array of bins with their respective weight distributions.
|
|
939
|
+
* @param mintX - Mint information for token X. Get from DLMM instance.
|
|
940
|
+
* @param mintY - Mint information for token Y. Get from DLMM instance.
|
|
941
|
+
* @param clock - Clock instance. Get from DLMM instance.
|
|
942
|
+
* @returns An array of objects containing binId, amountX, and amountY for each bin.
|
|
943
|
+
*/
|
|
944
|
+
static toAmountBothSide(active_id: number, bin_step: number, amount_a: string, amount_b: string, amount_a_in_active_bin: string, amount_b_in_active_bin: string, distributions: BinWeight[]): BinLiquidityInfo;
|
|
945
|
+
/**
|
|
946
|
+
* Distributes the given amount of coin B to both bid and ask side bins
|
|
947
|
+
* based on the provided weight distributions.
|
|
948
|
+
*
|
|
949
|
+
* @param active_id - The id of the active bin.
|
|
950
|
+
* @param bin_step - The step interval between bin ids.
|
|
951
|
+
* @param amount_a - Total amount of coin A to distribute.
|
|
952
|
+
* @param amount_a_in_active_bin - Amount of coin A already in the active bin.
|
|
953
|
+
* @param amount_b_in_active_bin - Amount of coin B already in the active bin.
|
|
954
|
+
* @param distributions - Array of bins with their respective weight distributions.
|
|
955
|
+
* @returns An array of objects containing binId, amountA, and amountB for each bin.
|
|
956
|
+
*/
|
|
957
|
+
static autoFillCoinByWeight(active_id: number, bin_step: number, amount: string, fix_amount_a: boolean, amount_a_in_active_bin: string, amount_b_in_active_bin: string, distributions: BinWeight[]): BinLiquidityInfo;
|
|
958
|
+
static calculateTotalWeights(bin_step: number, distributions: BinWeight[], active_id: number, activeBin?: BinWeight, amount_a_in_active_bin?: string, amount_b_in_active_bin?: string, is_only_amount?: 'a' | 'b'): {
|
|
959
|
+
totalWeightA: Decimal;
|
|
960
|
+
totalWeightB: Decimal;
|
|
961
|
+
activeWeightA: Decimal;
|
|
962
|
+
activeWeightB: Decimal;
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
declare class StrategyUtils {
|
|
967
|
+
/**
|
|
968
|
+
* Given a strategy type and amounts of X and Y, returns the distribution of liquidity.
|
|
969
|
+
* @param active_id The bin id of the active bin.
|
|
970
|
+
* @param bin_step The step size of each bin.
|
|
971
|
+
* @param min_bin_id The min bin id.
|
|
972
|
+
* @param max_bin_id The max bin id.
|
|
973
|
+
* @param amount_a The amount of X token to deposit.
|
|
974
|
+
* @param amount_b The amount of Y token to deposit.
|
|
975
|
+
* @param amount_a_in_active_bin The amount of X token in the active bin.
|
|
976
|
+
* @param amount_b_in_active_bin The amount of Y token in the active bin.
|
|
977
|
+
* @param strategy_type The strategy type.
|
|
978
|
+
* @returns The distribution of liquidity.
|
|
979
|
+
*/
|
|
980
|
+
static toAmountsBothSideByStrategy(active_id: number, bin_step: number, min_bin_id: number, max_bin_id: number, amount_a: string, amount_b: string, amount_a_in_active_bin: string, amount_b_in_active_bin: string, strategy_type: StrategyType): BinLiquidityInfo;
|
|
981
|
+
static autoFillCoinByStrategy(active_id: number, bin_step: number, amount: string, fix_amount_a: boolean, amount_a_in_active_bin: string, amount_b_in_active_bin: string, min_bin_id: number, max_bin_id: number, strategy_type: StrategyType): BinLiquidityInfo;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
declare class FeeUtils {
|
|
985
|
+
static getVariableFee(variableParameters: VariableParameters): string;
|
|
986
|
+
static calculateCompositionFee(amount: string, total_fee_rate: string): string;
|
|
987
|
+
static calculateProtocolFee(fee_amount: string, protocol_fee_rate: string): string;
|
|
988
|
+
static getProtocolFees(fee_a: string, fee_b: string, protocol_fee_rate: string): {
|
|
989
|
+
protocol_fee_a: string;
|
|
990
|
+
protocol_fee_b: string;
|
|
991
|
+
};
|
|
992
|
+
static getCompositionFees(active_bin: BinAmount, used_bin: BinAmount, binStepConfig: BinStepConfig, variableParameters: VariableParameters): {
|
|
993
|
+
fees_a: string;
|
|
994
|
+
fees_b: string;
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
declare const MAX_BIN_PER_POSITION = 1000;
|
|
999
|
+
declare const MIN_BIN_ID = -443636;
|
|
1000
|
+
declare const MAX_BIN_ID = 443636;
|
|
1001
|
+
declare const BASIS_POINT_MAX = 10000;
|
|
1002
|
+
declare const DEFAULT_MAX_WEIGHT = 2000;
|
|
1003
|
+
declare const DEFAULT_MIN_WEIGHT = 200;
|
|
1004
|
+
declare const BIN_BOUND = 443636n;
|
|
1005
|
+
declare const MAX_FEE_RATE = 100000000;
|
|
1006
|
+
declare const FEE_PRECISION = 1000000000;
|
|
1007
|
+
declare const BASIS_POINT = 10000;
|
|
1008
|
+
declare const REWARD_PERIOD: number;
|
|
1009
|
+
declare const REWARD_PERIOD_START_AT = 1747627200;
|
|
1010
|
+
|
|
1011
|
+
declare const dlmmMainnet: SdkOptions;
|
|
1012
|
+
|
|
1013
|
+
declare const dlmmTestnet: SdkOptions;
|
|
1014
|
+
|
|
1015
|
+
export { type AddLiquidityOption, type AddRewardOption, BASIS_POINT, BASIS_POINT_MAX, BIN_BOUND, type BaseAddLiquidityOption, type BaseCalculateAddLiquidityOption, type BaseCreatePoolAndAddOption, type BaseCreatePoolOption, type BinAmount, type BinLiquidityInfo, type BinManager, type BinStepConfig, type BinSwap, BinUtils, type BinWeight, type CalculateAddLiquidityAutoFillOption, type CalculateAddLiquidityOption, type CalculateRemoveLiquidityBothOption, type CalculateRemoveLiquidityOnlyOption, CetusDlmmSDK, type ClaimRefFeeOption, type ClosePositionOption, type CollectFeeOption, type CollectRewardAndFeeOption, type CollectRewardOption, type CreatePartnerOption, type CreatePoolAndAddOption, type CreatePoolAndAddWithPriceOption, type CreatePoolOption, DEFAULT_MAX_WEIGHT, DEFAULT_MIN_WEIGHT, type DlmmBasePool, type DlmmConfigs, type DlmmGlobalConfig, type DlmmPool, type DlmmPosition, FEE_PRECISION, type FeeRate, FeeUtils, type GetPoolBinInfoOption, type GetTotalFeeRateOption, type InitRewardOption, MAX_BIN_ID, MAX_BIN_PER_POSITION, MAX_FEE_RATE, MIN_BIN_ID, ONE, type OpenAndAddLiquidityOption, type OpenAndAddLiquidityWithPriceOption, type OpenPositionOption, type Partner, PoolModule, type PoolPermissions, type PoolTransactionInfo, type PositionFee, type PositionManager, type PositionReward, type PreSwapOption, type PreSwapQuote, REWARD_PERIOD, REWARD_PERIOD_START_AT, type RemoveLiquidityOption, type Reward, type RewardAccessOption, type RewardInfo, type RewardManager, type RewardPeriodEmission, type RewardPeriodEmissionFormat, type RewardWhiteListOption, SCALE_OFFSET, type SdkOptions, StrategyType, StrategyUtils, type SwapOption, type UpdatePositionFeeAndRewardsOption, type UpdateRefFeeRateOption, type UpdateTimeRangeOption, type ValidateActiveIdSlippageOption, type VariableParameters, WeightUtils, CetusDlmmSDK as default, dlmmMainnet, dlmmTestnet, generateRewardSchedule, getRouterModule, parseBinInfo, parseBinInfoList, parseCurrentRewardPeriodEmission, parseDlmmBasePool, parseDlmmPool, parseDlmmPosition, parseLiquidityShares, parsePartner, parsePoolTransactionInfo, parseRewardPeriodEmission, parseStrategyType, parsedDlmmPosFeeData, parsedDlmmPosRewardData, parsedSwapQuoteData, poolFilterEvenTypes, safeMulAmount };
|