llll-sdk 0.0.0-experimental-20260115163234
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/dist/index.d.mts +1190 -0
- package/dist/index.d.ts +1190 -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 +47 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1190 @@
|
|
|
1
|
+
import { SuiPriceServiceConnection } from '@pythnetwork/pyth-sui-js';
|
|
2
|
+
import { SdkWrapper, BaseSdkOptions, Package } from '@cetusprotocol/common-sdk';
|
|
3
|
+
import { CetusClmmSDK } from '@cetusprotocol/sui-clmm-sdk';
|
|
4
|
+
import * as _cetusprotocol_aggregator_sdk from '@cetusprotocol/aggregator-sdk';
|
|
5
|
+
import { AggregatorClient } from '@cetusprotocol/aggregator-sdk';
|
|
6
|
+
import { RewardSummary, ParsedObligation, SuilendClient, ParsedLendingMarket, ParsedReserve, Side, PerDayRewardSummary, AprRewardSummary } from '@suilend/sdk';
|
|
7
|
+
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
8
|
+
import * as _suilend_sdk__generated_suilend_reserve_structs from '@suilend/sdk/_generated/suilend/reserve/structs';
|
|
9
|
+
import { Reserve } from '@suilend/sdk/_generated/suilend/reserve/structs';
|
|
10
|
+
import * as bn_js from 'bn.js';
|
|
11
|
+
import bn_js__default from 'bn.js';
|
|
12
|
+
import * as _mysten_sui_dist_cjs_transactions from '@mysten/sui/dist/cjs/transactions';
|
|
13
|
+
import { Obligation } from '@suilend/sdk/_generated/suilend/obligation/structs';
|
|
14
|
+
import Decimal from 'decimal.js';
|
|
15
|
+
import { SuilendClient as SuilendClient$1 } from '@suilend/sdk/client';
|
|
16
|
+
import { CoinMetadata } from '@mysten/sui/client';
|
|
17
|
+
import BigNumber$1 from 'bignumber.js';
|
|
18
|
+
|
|
19
|
+
type MarginTradingConfig = {
|
|
20
|
+
package_id: string;
|
|
21
|
+
published_at: string;
|
|
22
|
+
version: number;
|
|
23
|
+
config: MarginTradingConfigs;
|
|
24
|
+
};
|
|
25
|
+
type MarginTradingConfigs = {
|
|
26
|
+
versioned_id: string;
|
|
27
|
+
admin_cap_id: string;
|
|
28
|
+
global_config_id: string;
|
|
29
|
+
markets: string;
|
|
30
|
+
markets_table_id: string;
|
|
31
|
+
};
|
|
32
|
+
type SuiLendConfigs = {
|
|
33
|
+
lending_market: LendingMarket[];
|
|
34
|
+
lending_market_id: string;
|
|
35
|
+
lending_market_type: string;
|
|
36
|
+
api_url: string;
|
|
37
|
+
};
|
|
38
|
+
type LendingMarket = {
|
|
39
|
+
name: string;
|
|
40
|
+
slug: string;
|
|
41
|
+
id: string;
|
|
42
|
+
type: string;
|
|
43
|
+
owner_cap_id: string;
|
|
44
|
+
is_hidden?: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type Market = {
|
|
48
|
+
market_id: string;
|
|
49
|
+
base_token: string;
|
|
50
|
+
quote_token: string;
|
|
51
|
+
max_long_leverage: string;
|
|
52
|
+
max_short_leverage: string;
|
|
53
|
+
open_fee_rate: string;
|
|
54
|
+
close_fee_rate: string;
|
|
55
|
+
open_permissions_pause: boolean;
|
|
56
|
+
close_permissions_pause: boolean;
|
|
57
|
+
deposit_permissions_pause: boolean;
|
|
58
|
+
withdraw_permissions_pause: boolean;
|
|
59
|
+
borrow_permissions_pause: boolean;
|
|
60
|
+
repay_permissions_pause: boolean;
|
|
61
|
+
};
|
|
62
|
+
type MarketSuilendInfo = {
|
|
63
|
+
long_liquidity: string;
|
|
64
|
+
short_liquidity: string;
|
|
65
|
+
base_total_deposit_apr_percent: string;
|
|
66
|
+
base_total_borrow_apr_percent: string;
|
|
67
|
+
quote_total_deposit_apr_percent: string;
|
|
68
|
+
quote_total_borrow_apr_percent: string;
|
|
69
|
+
base_token_available_deposit_amount: string;
|
|
70
|
+
base_token_available_borrow_amount: string;
|
|
71
|
+
quote_token_available_deposit_amount: string;
|
|
72
|
+
quote_token_available_borrow_amount: string;
|
|
73
|
+
base_deposit_rewards: RewardSummary[];
|
|
74
|
+
quote_deposit_rewards: RewardSummary[];
|
|
75
|
+
base_borrow_rewards: RewardSummary[];
|
|
76
|
+
quote_borrow_rewards: RewardSummary[];
|
|
77
|
+
base_deposit_apr_percent: string;
|
|
78
|
+
base_borrow_apr_percent: string;
|
|
79
|
+
quote_deposit_apr_percent: string;
|
|
80
|
+
quote_borrow_apr_percent: string;
|
|
81
|
+
} & Record<string, any>;
|
|
82
|
+
type CreateMarketParams = {
|
|
83
|
+
base_token: string;
|
|
84
|
+
quote_token: string;
|
|
85
|
+
open_fee_rate: string;
|
|
86
|
+
close_fee_rate: string;
|
|
87
|
+
};
|
|
88
|
+
type UpdateMarketMaxLeverageParams = {
|
|
89
|
+
market_id: string;
|
|
90
|
+
max_long_leverage: string;
|
|
91
|
+
max_short_leverage: string;
|
|
92
|
+
};
|
|
93
|
+
type UpdateMarketFeeRateParams = {
|
|
94
|
+
market_id: string;
|
|
95
|
+
open_fee_rate: string;
|
|
96
|
+
close_fee_rate: string;
|
|
97
|
+
};
|
|
98
|
+
type ClaimMarketFeeParams = {
|
|
99
|
+
market_id: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type Position = {
|
|
103
|
+
position_id: string;
|
|
104
|
+
position_cap_id: string;
|
|
105
|
+
created_at: string;
|
|
106
|
+
init_deposit_amount: string;
|
|
107
|
+
is_long: boolean;
|
|
108
|
+
lending_market_id: string;
|
|
109
|
+
obligation_owner_cap: string;
|
|
110
|
+
market_id: string;
|
|
111
|
+
deposits: any[];
|
|
112
|
+
borrows: any[];
|
|
113
|
+
original: ParsedObligation;
|
|
114
|
+
origin_obligation: Obligation<string>;
|
|
115
|
+
claimable_rewards: any[];
|
|
116
|
+
};
|
|
117
|
+
interface OpenPositionParams {
|
|
118
|
+
market_id: string;
|
|
119
|
+
is_long: boolean;
|
|
120
|
+
is_quote: boolean;
|
|
121
|
+
amount: string;
|
|
122
|
+
leverage: number;
|
|
123
|
+
slippage: number;
|
|
124
|
+
swap_clmm_pool?: string;
|
|
125
|
+
}
|
|
126
|
+
interface BorrowSuiParams {
|
|
127
|
+
tx: Transaction;
|
|
128
|
+
lending_market_id: string;
|
|
129
|
+
position?: any;
|
|
130
|
+
position_id?: string;
|
|
131
|
+
reserve_array_index: string;
|
|
132
|
+
borrow_amount: string;
|
|
133
|
+
}
|
|
134
|
+
interface BorrowNotSuiParams {
|
|
135
|
+
tx: Transaction;
|
|
136
|
+
lending_market_id: string;
|
|
137
|
+
position?: any;
|
|
138
|
+
position_id?: string;
|
|
139
|
+
reserve_array_index: string;
|
|
140
|
+
borrow_amount: string;
|
|
141
|
+
base_token: string;
|
|
142
|
+
quote_token: string;
|
|
143
|
+
is_long: boolean;
|
|
144
|
+
}
|
|
145
|
+
type PositionDepositParams = {
|
|
146
|
+
margin_trading_context: TransactionObjectArgument;
|
|
147
|
+
market_id: string;
|
|
148
|
+
is_long: boolean;
|
|
149
|
+
position_cap_id?: string;
|
|
150
|
+
position_cap?: any;
|
|
151
|
+
deposit_reserve_array_index: string;
|
|
152
|
+
input_coin: any;
|
|
153
|
+
txb?: Transaction;
|
|
154
|
+
base_token: string;
|
|
155
|
+
quote_token: string;
|
|
156
|
+
};
|
|
157
|
+
type PositionManageSizeDepositParams = {
|
|
158
|
+
position_id: string;
|
|
159
|
+
is_quote: boolean;
|
|
160
|
+
amount: string;
|
|
161
|
+
slippage: number;
|
|
162
|
+
swap_clmm_pool?: string;
|
|
163
|
+
leverage: number;
|
|
164
|
+
txb?: Transaction;
|
|
165
|
+
};
|
|
166
|
+
type PositionManageSizeWithdrawParams = {
|
|
167
|
+
position_id: string;
|
|
168
|
+
amount: string;
|
|
169
|
+
is_quote: boolean;
|
|
170
|
+
swap_clmm_pool?: string;
|
|
171
|
+
slippage: number;
|
|
172
|
+
leverage: number;
|
|
173
|
+
txb?: Transaction;
|
|
174
|
+
};
|
|
175
|
+
type WithdrawParams = {
|
|
176
|
+
market_id: string;
|
|
177
|
+
position_id: string;
|
|
178
|
+
withdraw_amount: string;
|
|
179
|
+
withdraw_reserve_array_index: string;
|
|
180
|
+
withdraw_coin_type: string;
|
|
181
|
+
base_token: string;
|
|
182
|
+
quote_token: string;
|
|
183
|
+
price_object_id: string;
|
|
184
|
+
txb?: Transaction;
|
|
185
|
+
};
|
|
186
|
+
type RepayParams = {
|
|
187
|
+
margin_trading_context: TransactionObjectArgument;
|
|
188
|
+
txb?: Transaction;
|
|
189
|
+
position_cap_id: string;
|
|
190
|
+
repay_amount: string;
|
|
191
|
+
repay_coin_type: string;
|
|
192
|
+
repay_coin?: any;
|
|
193
|
+
repay_reserve_array_index: string;
|
|
194
|
+
market_id: string;
|
|
195
|
+
};
|
|
196
|
+
type CreateLeveragePositionParams = {
|
|
197
|
+
leverage: number;
|
|
198
|
+
market_id: string;
|
|
199
|
+
base_token: string;
|
|
200
|
+
quote_token: string;
|
|
201
|
+
is_long: boolean;
|
|
202
|
+
init_deposit_amount: string;
|
|
203
|
+
init_coin_type: string;
|
|
204
|
+
tx: Transaction;
|
|
205
|
+
};
|
|
206
|
+
type BorrowAssetParams = {
|
|
207
|
+
margin_trading_context: TransactionObjectArgument;
|
|
208
|
+
position_cap_id?: string;
|
|
209
|
+
position_cap?: any;
|
|
210
|
+
reserve_array_index: string;
|
|
211
|
+
borrow_amount: string;
|
|
212
|
+
base_token: string;
|
|
213
|
+
quote_token: string;
|
|
214
|
+
is_long: boolean;
|
|
215
|
+
lending_market_id: string;
|
|
216
|
+
market_id: string;
|
|
217
|
+
};
|
|
218
|
+
type WithdrawAssetParams = {
|
|
219
|
+
margin_trading_context: TransactionObjectArgument;
|
|
220
|
+
market_id: string;
|
|
221
|
+
position_cap_id: string;
|
|
222
|
+
withdraw_amount: string;
|
|
223
|
+
withdraw_reserve_array_index: string;
|
|
224
|
+
withdraw_coin_type: string;
|
|
225
|
+
};
|
|
226
|
+
type PositionCloseParams = {
|
|
227
|
+
margin_trading_context: TransactionObjectArgument;
|
|
228
|
+
market_id: string;
|
|
229
|
+
position_cap_id: string;
|
|
230
|
+
};
|
|
231
|
+
type CalculatePositionDepositParams = {
|
|
232
|
+
market_id: string;
|
|
233
|
+
is_long: boolean;
|
|
234
|
+
is_quote: boolean;
|
|
235
|
+
amount: string;
|
|
236
|
+
leverage: number;
|
|
237
|
+
swap_clmm_pool?: string;
|
|
238
|
+
slippage: number;
|
|
239
|
+
by_amount_in?: boolean;
|
|
240
|
+
base_token: string;
|
|
241
|
+
quote_token: string;
|
|
242
|
+
is_submit?: boolean;
|
|
243
|
+
is_open?: boolean;
|
|
244
|
+
position_id?: string;
|
|
245
|
+
};
|
|
246
|
+
type CalculatePositionWithdrawParams = {
|
|
247
|
+
position_id: string;
|
|
248
|
+
is_quote: boolean;
|
|
249
|
+
swap_clmm_pool?: string;
|
|
250
|
+
leverage: number;
|
|
251
|
+
amount: string;
|
|
252
|
+
slippage: number;
|
|
253
|
+
withdraw_max?: boolean;
|
|
254
|
+
};
|
|
255
|
+
type PositionManageLeverageParams = {
|
|
256
|
+
position_id: string;
|
|
257
|
+
swap_clmm_pool?: string;
|
|
258
|
+
current_leverage: number;
|
|
259
|
+
target_leverage: number;
|
|
260
|
+
slippage: number;
|
|
261
|
+
};
|
|
262
|
+
type PositionRepayParams = {
|
|
263
|
+
position_id: string;
|
|
264
|
+
amount: string;
|
|
265
|
+
is_quote: boolean;
|
|
266
|
+
slippage: number;
|
|
267
|
+
};
|
|
268
|
+
type positionTopUpCTokenParams = {
|
|
269
|
+
position_id: string;
|
|
270
|
+
amount: string;
|
|
271
|
+
is_quote: boolean;
|
|
272
|
+
swap_clmm_pool?: string;
|
|
273
|
+
slippage: number;
|
|
274
|
+
};
|
|
275
|
+
type positionWithdrawCTokenParams = {
|
|
276
|
+
position_id: string;
|
|
277
|
+
amount: string;
|
|
278
|
+
is_quote: boolean;
|
|
279
|
+
swap_clmm_pool?: string;
|
|
280
|
+
slippage: number;
|
|
281
|
+
};
|
|
282
|
+
type CalculatePositionLeverageParams = {
|
|
283
|
+
position_id: string;
|
|
284
|
+
current_leverage: number;
|
|
285
|
+
target_leverage: number;
|
|
286
|
+
swap_clmm_pool?: string;
|
|
287
|
+
slippage: number;
|
|
288
|
+
};
|
|
289
|
+
type PositionCloseWithCoinParams = {
|
|
290
|
+
position_id: string;
|
|
291
|
+
is_quote: boolean;
|
|
292
|
+
leverage: number;
|
|
293
|
+
slippage: number;
|
|
294
|
+
swap_clmm_pool?: string;
|
|
295
|
+
};
|
|
296
|
+
type CreateMarginTradingContextParams = {
|
|
297
|
+
market_id: string;
|
|
298
|
+
position_cap_id: string;
|
|
299
|
+
action: string;
|
|
300
|
+
coin_type: string;
|
|
301
|
+
amount: string;
|
|
302
|
+
};
|
|
303
|
+
type CalculatePositionRepayParams = {
|
|
304
|
+
position_id: string;
|
|
305
|
+
amount: string;
|
|
306
|
+
is_quote: boolean;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
type CalculateFlashLoanParams = {
|
|
310
|
+
is_long: boolean;
|
|
311
|
+
leverage: number;
|
|
312
|
+
base_token: string;
|
|
313
|
+
quote_token: string;
|
|
314
|
+
deposit_amount: string;
|
|
315
|
+
reserve: any[];
|
|
316
|
+
base_token_decimal: number;
|
|
317
|
+
quote_token_decimal: number;
|
|
318
|
+
};
|
|
319
|
+
interface FlashLoanParams {
|
|
320
|
+
amount: string;
|
|
321
|
+
clmm_pool: string;
|
|
322
|
+
clmm_pool_coin_type_a: string;
|
|
323
|
+
clmm_pool_coin_type_b: string;
|
|
324
|
+
flash_loan_coin: string;
|
|
325
|
+
tx: Transaction;
|
|
326
|
+
}
|
|
327
|
+
interface RepayFlashSwapParams {
|
|
328
|
+
clmm_pool: string;
|
|
329
|
+
tx: Transaction;
|
|
330
|
+
repay_base: any;
|
|
331
|
+
repay_quote: any;
|
|
332
|
+
clmm_pool_coin_type_a: string;
|
|
333
|
+
clmm_pool_coin_type_b: string;
|
|
334
|
+
receipt: any;
|
|
335
|
+
}
|
|
336
|
+
type RouterSwapParams = {
|
|
337
|
+
slippage: number;
|
|
338
|
+
input_coin: any;
|
|
339
|
+
router: any;
|
|
340
|
+
txb?: Transaction;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
type Price = {
|
|
344
|
+
coin_type: string;
|
|
345
|
+
price: string;
|
|
346
|
+
oracle_price: bigint;
|
|
347
|
+
last_update_time: number;
|
|
348
|
+
};
|
|
349
|
+
type FeedInfo = {
|
|
350
|
+
coin_type: string;
|
|
351
|
+
price_feed_id: string;
|
|
352
|
+
coin_decimals: number;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
interface AppData {
|
|
356
|
+
suilendClient: SuilendClient;
|
|
357
|
+
lendingMarket: ParsedLendingMarket;
|
|
358
|
+
coinMetadataMap: Record<string, CoinMetadata>;
|
|
359
|
+
refreshedRawReserves: Reserve<string>[];
|
|
360
|
+
reserveMap: Record<string, ParsedReserve>;
|
|
361
|
+
reserveCoinTypes: string[];
|
|
362
|
+
reserveCoinMetadataMap: Record<string, CoinMetadata>;
|
|
363
|
+
rewardPriceMap: Record<string, bn_js__default | undefined>;
|
|
364
|
+
rewardCoinTypes: string[];
|
|
365
|
+
activeRewardCoinTypes: string[];
|
|
366
|
+
rewardCoinMetadataMap: Record<string, CoinMetadata>;
|
|
367
|
+
}
|
|
368
|
+
interface AllAppData {
|
|
369
|
+
allLendingMarketData: Record<string, AppData>;
|
|
370
|
+
lstAprPercentMap: Record<string, BigNumber>;
|
|
371
|
+
}
|
|
372
|
+
interface SuiLendCoinAprResult {
|
|
373
|
+
new_total_apr_percent: string | undefined;
|
|
374
|
+
total_apr_percent: string;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
declare class MarketModules {
|
|
378
|
+
protected _sdk: CetusMarginTradingSDK;
|
|
379
|
+
constructor(sdk: CetusMarginTradingSDK);
|
|
380
|
+
createMarket: (params: CreateMarketParams) => Promise<Transaction>;
|
|
381
|
+
updateMarketFeeRate: (params: UpdateMarketFeeRateParams) => Promise<Transaction>;
|
|
382
|
+
claimMarketFees: (market_id: string, txb?: Transaction) => Promise<Transaction>;
|
|
383
|
+
claimAllMarketFees: (market_ids: string[]) => Promise<Transaction>;
|
|
384
|
+
/**
|
|
385
|
+
* Get margin trading contract config information
|
|
386
|
+
*/
|
|
387
|
+
getMarginTradingConfig: () => Promise<MarginTradingConfigs>;
|
|
388
|
+
/**
|
|
389
|
+
* Get margin trading market list
|
|
390
|
+
*/
|
|
391
|
+
getMarketList: (force_refresh?: boolean) => Promise<Market[]>;
|
|
392
|
+
/**
|
|
393
|
+
* Get margin trading market information
|
|
394
|
+
*/
|
|
395
|
+
getMarketInfo: (market_id: string, force_refresh?: boolean) => Promise<Market>;
|
|
396
|
+
/** Get margin trading market Suilend information */
|
|
397
|
+
getMarketSuilendInfo: (market_id: string) => Promise<MarketSuilendInfo>;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
declare class PermissionModules {
|
|
401
|
+
protected _sdk: CetusMarginTradingSDK;
|
|
402
|
+
constructor(sdk: CetusMarginTradingSDK);
|
|
403
|
+
queryGlobalPermissions: () => Promise<{
|
|
404
|
+
open_permissions_pause: boolean;
|
|
405
|
+
close_permissions_pause: boolean;
|
|
406
|
+
deposit_permissions_pause: boolean;
|
|
407
|
+
withdraw_permissions_pause: boolean;
|
|
408
|
+
borrow_permissions_pause: boolean;
|
|
409
|
+
repay_permissions_pause: boolean;
|
|
410
|
+
} | undefined>;
|
|
411
|
+
updateGlobalPermissions: (pause: boolean) => Promise<Transaction>;
|
|
412
|
+
updateGlobalOpenPositionPermissions: (pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
413
|
+
updateGlobalClosePositionPermissions: (pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
414
|
+
updateGlobalDepositPermissions: (pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
415
|
+
updateGlobalBorrowPermissions: (pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
416
|
+
updateGlobalWithdrawPermissions: (pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
417
|
+
updateGlobalRepayPermissions: (pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
418
|
+
updateMarketCreatePositionPermissions: (market_id: string, pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
419
|
+
updateMarketClosePositionPermissions: (market_id: string, pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
420
|
+
updateMarketDepositPermissions: (market_id: string, pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
421
|
+
updateMarketWithdrawPermissions: (market_id: string, pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
422
|
+
updateMarketBorrowPermissions: (market_id: string, pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
423
|
+
updateMarketRepayPermissions: (market_id: string, pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
424
|
+
updateMarketPermissions: (market_id: string, pause: boolean, txb?: Transaction) => Promise<Transaction>;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
declare class PositionModules {
|
|
428
|
+
protected _sdk: CetusMarginTradingSDK;
|
|
429
|
+
constructor(sdk: CetusMarginTradingSDK);
|
|
430
|
+
/**
|
|
431
|
+
* Get leverage position list
|
|
432
|
+
*/
|
|
433
|
+
getPositionList: (wallet_address?: string, force_refresh?: boolean) => Promise<Position[]>;
|
|
434
|
+
/**
|
|
435
|
+
* Get leverage position details
|
|
436
|
+
*/
|
|
437
|
+
getPositionInfo: (position_id: string, wallet_address?: string, force_refresh?: boolean) => Promise<Position>;
|
|
438
|
+
private getObligationRewardsInfo;
|
|
439
|
+
/**
|
|
440
|
+
* Get capId from mapping by positionId
|
|
441
|
+
* @param position_id Position ID
|
|
442
|
+
* @param wallet_address Wallet address
|
|
443
|
+
* @returns capId or undefined
|
|
444
|
+
*/
|
|
445
|
+
private getCapIdByPositionId;
|
|
446
|
+
/**
|
|
447
|
+
* Create leverage position
|
|
448
|
+
*/
|
|
449
|
+
private createLeveragePosition;
|
|
450
|
+
/**
|
|
451
|
+
* Deposit asset to leverage position
|
|
452
|
+
*/
|
|
453
|
+
private depositToLeveragePosition;
|
|
454
|
+
/**
|
|
455
|
+
* Repay
|
|
456
|
+
*/
|
|
457
|
+
repay: (params: RepayParams) => void;
|
|
458
|
+
/**
|
|
459
|
+
* Withdraw asset (unified handling for SUI and non-SUI)
|
|
460
|
+
*/
|
|
461
|
+
withdrawAsset: (params: WithdrawAssetParams, tx: Transaction) => _mysten_sui_dist_cjs_transactions.TransactionResult;
|
|
462
|
+
/**
|
|
463
|
+
* Borrow asset (unified handling for SUI and non-SUI)
|
|
464
|
+
*/
|
|
465
|
+
borrowAsset: (params: BorrowAssetParams, tx: Transaction) => _mysten_sui_dist_cjs_transactions.TransactionResult;
|
|
466
|
+
/**
|
|
467
|
+
* Extract other token types from deposits and borrows excluding baseToken and quoteToken
|
|
468
|
+
* @param deposits Deposit list
|
|
469
|
+
* @param borrows Borrow list
|
|
470
|
+
* @param baseToken Base token type
|
|
471
|
+
* @param quoteToken Quote token type
|
|
472
|
+
* @returns Array of other token types
|
|
473
|
+
*/
|
|
474
|
+
private extractOtherTokenTypes;
|
|
475
|
+
createMarginTradingContext: (params: CreateMarginTradingContextParams, tx: Transaction) => _mysten_sui_dist_cjs_transactions.TransactionResult;
|
|
476
|
+
marginTradingContextConfirm: (marginTradingContext: TransactionObjectArgument, tx: Transaction) => Transaction;
|
|
477
|
+
/**
|
|
478
|
+
* Open position
|
|
479
|
+
*/
|
|
480
|
+
openPosition: (params: OpenPositionParams) => Promise<Transaction>;
|
|
481
|
+
/**
|
|
482
|
+
* Increase position size
|
|
483
|
+
*/
|
|
484
|
+
positionDeposit: (params: PositionManageSizeDepositParams) => Promise<Transaction>;
|
|
485
|
+
/**
|
|
486
|
+
* Decrease position size
|
|
487
|
+
*/
|
|
488
|
+
positionWithdraw: (params: PositionManageSizeWithdrawParams) => Promise<Transaction>;
|
|
489
|
+
/**
|
|
490
|
+
* Close position
|
|
491
|
+
*/
|
|
492
|
+
positionClose: (params: PositionCloseWithCoinParams) => Promise<Transaction>;
|
|
493
|
+
/**
|
|
494
|
+
* Increase position leverage
|
|
495
|
+
*/
|
|
496
|
+
positionLeverageIncrease: (params: PositionManageLeverageParams) => Promise<Transaction>;
|
|
497
|
+
/**
|
|
498
|
+
* Decrease position leverage
|
|
499
|
+
*/
|
|
500
|
+
positionLeverageDecrease: (params: PositionManageLeverageParams) => Promise<Transaction>;
|
|
501
|
+
/**
|
|
502
|
+
* Leverage position repay
|
|
503
|
+
*/
|
|
504
|
+
positionRepay: (params: PositionRepayParams) => Promise<Transaction>;
|
|
505
|
+
/**
|
|
506
|
+
* Top up collateral for leverage position
|
|
507
|
+
*/
|
|
508
|
+
positionTopUpCToken: (params: positionTopUpCTokenParams) => Promise<Transaction>;
|
|
509
|
+
/**
|
|
510
|
+
* Withdraw ctoken for leverage position
|
|
511
|
+
*/
|
|
512
|
+
positionWithdrawCToken: (params: positionWithdrawCTokenParams) => Promise<Transaction>;
|
|
513
|
+
positionClaim: (position_id: string) => Promise<Transaction>;
|
|
514
|
+
/**
|
|
515
|
+
* Pre-calculate for opening position
|
|
516
|
+
*/
|
|
517
|
+
calculatePositionDeposit: (params: CalculatePositionDepositParams) => Promise<{
|
|
518
|
+
routers: {
|
|
519
|
+
is_exceed: boolean;
|
|
520
|
+
quoteID?: string;
|
|
521
|
+
amountIn: bn_js;
|
|
522
|
+
amountOut: bn_js;
|
|
523
|
+
byAmountIn: boolean;
|
|
524
|
+
paths: _cetusprotocol_aggregator_sdk.Path[];
|
|
525
|
+
insufficientLiquidity: boolean;
|
|
526
|
+
deviationRatio?: number;
|
|
527
|
+
packages?: Map<string, string>;
|
|
528
|
+
totalDeepFee?: number;
|
|
529
|
+
error?: _cetusprotocol_aggregator_sdk.RouterError;
|
|
530
|
+
overlayFee?: number;
|
|
531
|
+
amount_in?: undefined;
|
|
532
|
+
amount_out?: undefined;
|
|
533
|
+
route_obj?: undefined;
|
|
534
|
+
by_amount_in?: undefined;
|
|
535
|
+
origin_res?: undefined;
|
|
536
|
+
} | {
|
|
537
|
+
amount_in: any;
|
|
538
|
+
amount_out: any;
|
|
539
|
+
is_exceed: any;
|
|
540
|
+
route_obj: any;
|
|
541
|
+
by_amount_in: boolean;
|
|
542
|
+
origin_res: any;
|
|
543
|
+
} | null;
|
|
544
|
+
leverage_deposit_amount: string;
|
|
545
|
+
quote_price: string;
|
|
546
|
+
base_price: string;
|
|
547
|
+
clmm_fee_tier: string;
|
|
548
|
+
flash_loan_fee: string;
|
|
549
|
+
flash_loan_coin: string;
|
|
550
|
+
deposit_amount: string;
|
|
551
|
+
borrow_amount: string;
|
|
552
|
+
deposit_amount_usd: string;
|
|
553
|
+
borrow_amount_usd: string;
|
|
554
|
+
after_borrow_amount: string;
|
|
555
|
+
after_borrow_amount_usd: string;
|
|
556
|
+
after_deposit_amount: string;
|
|
557
|
+
after_deposit_amount_usd: string;
|
|
558
|
+
flash_amount: string;
|
|
559
|
+
is_flash_a: boolean;
|
|
560
|
+
init_deposit_amount: string;
|
|
561
|
+
clmm_pool_coin_type_a: any;
|
|
562
|
+
clmm_pool_coin_type_b: any;
|
|
563
|
+
clmm_pool: any;
|
|
564
|
+
base_reserve_array_index: string;
|
|
565
|
+
quote_reserve_array_index: string;
|
|
566
|
+
reserve: _suilend_sdk__generated_suilend_reserve_structs.Reserve<string>[];
|
|
567
|
+
has_swap: boolean;
|
|
568
|
+
}>;
|
|
569
|
+
calculatePositionWithdraw: (params: CalculatePositionWithdrawParams) => Promise<{
|
|
570
|
+
amount_in: string;
|
|
571
|
+
amount_out: string;
|
|
572
|
+
from: any;
|
|
573
|
+
to: string;
|
|
574
|
+
after_borrow_amount: string;
|
|
575
|
+
after_borrow_amount_usd: string;
|
|
576
|
+
after_deposit_amount: string;
|
|
577
|
+
after_deposit_amount_usd: string;
|
|
578
|
+
flash_loan_fee: string | undefined;
|
|
579
|
+
clmm_fee_tier: string | number | undefined;
|
|
580
|
+
withdraw_amount: string;
|
|
581
|
+
withdraw_ctoken_amount: string;
|
|
582
|
+
repay_amount: string;
|
|
583
|
+
ratio: Decimal;
|
|
584
|
+
is_close: boolean;
|
|
585
|
+
is_long: boolean;
|
|
586
|
+
deposits: any[];
|
|
587
|
+
borrows: any[];
|
|
588
|
+
reserve: _suilend_sdk__generated_suilend_reserve_structs.Reserve<string>[];
|
|
589
|
+
base_token: string;
|
|
590
|
+
quote_token: string;
|
|
591
|
+
clmm_pool: any;
|
|
592
|
+
clmm_pool_coin_type_a: any;
|
|
593
|
+
clmm_pool_coin_type_b: any;
|
|
594
|
+
position_cap_id: string;
|
|
595
|
+
market_id: string;
|
|
596
|
+
swap_convert_all: boolean;
|
|
597
|
+
flash_loan_amount: string;
|
|
598
|
+
routers: any;
|
|
599
|
+
repay_flash_loan_amount: string | undefined;
|
|
600
|
+
partial_amount_in: string | undefined;
|
|
601
|
+
has_flash_loan: boolean;
|
|
602
|
+
}>;
|
|
603
|
+
calculatePositionLeverage: (params: CalculatePositionLeverageParams) => Promise<{
|
|
604
|
+
amount_in: any;
|
|
605
|
+
amount_out: any;
|
|
606
|
+
flash_loan_fee: string | undefined;
|
|
607
|
+
deposit_amount: string;
|
|
608
|
+
borrow_amount: string;
|
|
609
|
+
deposit_amount_usd: string;
|
|
610
|
+
borrow_amount_usd: string;
|
|
611
|
+
flash_loan_amount: Decimal;
|
|
612
|
+
base_token: string;
|
|
613
|
+
quote_token: string;
|
|
614
|
+
reserve: _suilend_sdk__generated_suilend_reserve_structs.Reserve<string>[];
|
|
615
|
+
deposits: any[];
|
|
616
|
+
borrows: any[];
|
|
617
|
+
clmm_fee_tier: string | undefined;
|
|
618
|
+
is_flash_loan: boolean;
|
|
619
|
+
is_loan_a: boolean | undefined;
|
|
620
|
+
clmm_pool_coin_type_a: any;
|
|
621
|
+
clmm_pool_coin_type_b: any;
|
|
622
|
+
after_deposit_amount: string;
|
|
623
|
+
after_borrow_amount: string;
|
|
624
|
+
after_deposit_amount_usd: string;
|
|
625
|
+
after_borrow_amount_usd: string;
|
|
626
|
+
position_cap_id: string;
|
|
627
|
+
market_id: string;
|
|
628
|
+
is_long: boolean;
|
|
629
|
+
routers: {
|
|
630
|
+
is_exceed: boolean;
|
|
631
|
+
quoteID?: string;
|
|
632
|
+
amountIn: bn_js;
|
|
633
|
+
amountOut: bn_js;
|
|
634
|
+
byAmountIn: boolean;
|
|
635
|
+
paths: _cetusprotocol_aggregator_sdk.Path[];
|
|
636
|
+
insufficientLiquidity: boolean;
|
|
637
|
+
deviationRatio?: number;
|
|
638
|
+
packages?: Map<string, string>;
|
|
639
|
+
totalDeepFee?: number;
|
|
640
|
+
error?: _cetusprotocol_aggregator_sdk.RouterError;
|
|
641
|
+
overlayFee?: number;
|
|
642
|
+
amount_in?: undefined;
|
|
643
|
+
amount_out?: undefined;
|
|
644
|
+
route_obj?: undefined;
|
|
645
|
+
by_amount_in?: undefined;
|
|
646
|
+
origin_res?: undefined;
|
|
647
|
+
} | {
|
|
648
|
+
amount_in: any;
|
|
649
|
+
amount_out: any;
|
|
650
|
+
is_exceed: any;
|
|
651
|
+
route_obj: any;
|
|
652
|
+
by_amount_in: boolean;
|
|
653
|
+
origin_res: any;
|
|
654
|
+
} | null;
|
|
655
|
+
withdraw_ctoken_amount?: undefined;
|
|
656
|
+
} | {
|
|
657
|
+
amount_in: any;
|
|
658
|
+
amount_out: any;
|
|
659
|
+
deposit_amount: any;
|
|
660
|
+
borrow_amount: string;
|
|
661
|
+
deposit_amount_usd: string;
|
|
662
|
+
borrow_amount_usd: string;
|
|
663
|
+
base_token: string;
|
|
664
|
+
quote_token: string;
|
|
665
|
+
reserve: _suilend_sdk__generated_suilend_reserve_structs.Reserve<string>[];
|
|
666
|
+
deposits: any[];
|
|
667
|
+
borrows: any[];
|
|
668
|
+
clmm_fee_tier: string | undefined;
|
|
669
|
+
withdraw_ctoken_amount: any;
|
|
670
|
+
is_flash_loan: boolean;
|
|
671
|
+
clmm_pool_coin_type_a: string;
|
|
672
|
+
clmm_pool_coin_type_b: string;
|
|
673
|
+
after_deposit_amount: string;
|
|
674
|
+
after_borrow_amount: string;
|
|
675
|
+
after_deposit_amount_usd: string;
|
|
676
|
+
after_borrow_amount_usd: string;
|
|
677
|
+
position_cap_id: string;
|
|
678
|
+
market_id: string;
|
|
679
|
+
is_long: boolean;
|
|
680
|
+
routers: {
|
|
681
|
+
is_exceed: boolean;
|
|
682
|
+
quoteID?: string;
|
|
683
|
+
amountIn: bn_js;
|
|
684
|
+
amountOut: bn_js;
|
|
685
|
+
byAmountIn: boolean;
|
|
686
|
+
paths: _cetusprotocol_aggregator_sdk.Path[];
|
|
687
|
+
insufficientLiquidity: boolean;
|
|
688
|
+
deviationRatio?: number;
|
|
689
|
+
packages?: Map<string, string>;
|
|
690
|
+
totalDeepFee?: number;
|
|
691
|
+
error?: _cetusprotocol_aggregator_sdk.RouterError;
|
|
692
|
+
overlayFee?: number;
|
|
693
|
+
amount_in?: undefined;
|
|
694
|
+
amount_out?: undefined;
|
|
695
|
+
route_obj?: undefined;
|
|
696
|
+
by_amount_in?: undefined;
|
|
697
|
+
origin_res?: undefined;
|
|
698
|
+
} | {
|
|
699
|
+
amount_in: any;
|
|
700
|
+
amount_out: any;
|
|
701
|
+
is_exceed: any;
|
|
702
|
+
route_obj: any;
|
|
703
|
+
by_amount_in: boolean;
|
|
704
|
+
origin_res: any;
|
|
705
|
+
} | null;
|
|
706
|
+
flash_loan_fee?: undefined;
|
|
707
|
+
flash_loan_amount?: undefined;
|
|
708
|
+
is_loan_a?: undefined;
|
|
709
|
+
}>;
|
|
710
|
+
calculatePositionRepay: (params: CalculatePositionRepayParams) => Promise<{
|
|
711
|
+
routers: any;
|
|
712
|
+
repay_coin_type: any;
|
|
713
|
+
base_token: any;
|
|
714
|
+
quote_token: any;
|
|
715
|
+
is_long: boolean;
|
|
716
|
+
borrows: any[];
|
|
717
|
+
deposits: any[];
|
|
718
|
+
market_id: string;
|
|
719
|
+
position_cap_id: string;
|
|
720
|
+
has_swap: boolean;
|
|
721
|
+
}>;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
declare class SuiLendModule {
|
|
725
|
+
private sdk;
|
|
726
|
+
lendingMarketCache?: AllAppData;
|
|
727
|
+
obligationsCache?: Record<string, any>;
|
|
728
|
+
private suilendClientCache?;
|
|
729
|
+
constructor(sdk: CetusMarginTradingSDK);
|
|
730
|
+
/**
|
|
731
|
+
* Get or initialize SuilendClient
|
|
732
|
+
* @param lending_market_id Lending market ID
|
|
733
|
+
* @param lending_market_type Lending market type
|
|
734
|
+
*/
|
|
735
|
+
getSuilendClient(lending_market_id: string, lending_market_type: string): Promise<SuilendClient$1>;
|
|
736
|
+
/**
|
|
737
|
+
* Get lending market data (cached)
|
|
738
|
+
* @param force_refresh Whether to force refresh
|
|
739
|
+
*/
|
|
740
|
+
getLendingMarketData(force_refresh?: boolean): Promise<AllAppData>;
|
|
741
|
+
/**
|
|
742
|
+
* Get obligations data (cached)
|
|
743
|
+
* @param all_app_data Lending market data (optional)
|
|
744
|
+
* @param force_refresh Whether to force refresh
|
|
745
|
+
*/
|
|
746
|
+
getInitializeObligations(all_app_data?: AllAppData, force_refresh?: boolean): Promise<any>;
|
|
747
|
+
getCoinAprByAmount: (coin_type: string, amount: Decimal, side: Side) => Promise<SuiLendCoinAprResult>;
|
|
748
|
+
/**
|
|
749
|
+
* Get user lending data
|
|
750
|
+
* @param obligation_id Obligation ID (optional)
|
|
751
|
+
* @param force_refresh Whether to force refresh
|
|
752
|
+
*/
|
|
753
|
+
getSuiLendUserData(obligation_id: string, force_refresh?: boolean): Promise<{
|
|
754
|
+
obligation: any;
|
|
755
|
+
netAprPercent: BigNumber$1;
|
|
756
|
+
deposits: any;
|
|
757
|
+
borrowedAmount: any;
|
|
758
|
+
depositedAmount: any;
|
|
759
|
+
netValueUsd: any;
|
|
760
|
+
rewardMap: any;
|
|
761
|
+
}>;
|
|
762
|
+
refreshReservePrice: (tx: Transaction, price_object_id: string, reserve_array_index: bigint) => Promise<void>;
|
|
763
|
+
getLatestPriceFeeds: (reserves: Reserve<string>[], force_refresh?: boolean) => Promise<Record<string, Price>>;
|
|
764
|
+
getLatestPriceFeedsByCoinTypes: (coin_types: string[], force_refresh?: boolean) => Promise<Record<string, Price> | undefined>;
|
|
765
|
+
priceCheck(price: Price, age?: number): Price | undefined;
|
|
766
|
+
getSuiLendReserveInfo: (base_token: string, quote_token: string, all_lending_market_data?: AllAppData["allLendingMarketData"], other_token?: string[]) => Promise<{
|
|
767
|
+
base_reserve_array_index: string;
|
|
768
|
+
quote_reserve_array_index: string;
|
|
769
|
+
reserve: Reserve<string>[];
|
|
770
|
+
base_reserve_map_info: {
|
|
771
|
+
config: {
|
|
772
|
+
$typeName: string;
|
|
773
|
+
openLtvPct: number;
|
|
774
|
+
closeLtvPct: number;
|
|
775
|
+
maxCloseLtvPct: number;
|
|
776
|
+
borrowWeightBps: BigNumber$1;
|
|
777
|
+
depositLimit: BigNumber$1;
|
|
778
|
+
borrowLimit: BigNumber$1;
|
|
779
|
+
liquidationBonusBps: number;
|
|
780
|
+
maxLiquidationBonusBps: number;
|
|
781
|
+
depositLimitUsd: BigNumber$1;
|
|
782
|
+
borrowLimitUsd: BigNumber$1;
|
|
783
|
+
borrowFeeBps: number;
|
|
784
|
+
spreadFeeBps: number;
|
|
785
|
+
protocolLiquidationFeeBps: number;
|
|
786
|
+
isolated: boolean;
|
|
787
|
+
openAttributedBorrowLimitUsd: number;
|
|
788
|
+
closeAttributedBorrowLimitUsd: number;
|
|
789
|
+
interestRate: {
|
|
790
|
+
id: string;
|
|
791
|
+
utilPercent: BigNumber$1;
|
|
792
|
+
aprPercent: BigNumber$1;
|
|
793
|
+
}[];
|
|
794
|
+
};
|
|
795
|
+
$typeName: string;
|
|
796
|
+
id: string;
|
|
797
|
+
arrayIndex: bigint;
|
|
798
|
+
coinType: string;
|
|
799
|
+
mintDecimals: number;
|
|
800
|
+
priceIdentifier: string;
|
|
801
|
+
price: BigNumber$1;
|
|
802
|
+
smoothedPrice: BigNumber$1;
|
|
803
|
+
minPrice: BigNumber$1;
|
|
804
|
+
maxPrice: BigNumber$1;
|
|
805
|
+
priceLastUpdateTimestampS: bigint;
|
|
806
|
+
availableAmount: BigNumber$1;
|
|
807
|
+
ctokenSupply: BigNumber$1;
|
|
808
|
+
borrowedAmount: BigNumber$1;
|
|
809
|
+
cumulativeBorrowRate: BigNumber$1;
|
|
810
|
+
interestLastUpdateTimestampS: bigint;
|
|
811
|
+
unclaimedSpreadFees: BigNumber$1;
|
|
812
|
+
attributedBorrowValue: BigNumber$1;
|
|
813
|
+
depositsPoolRewardManager: {
|
|
814
|
+
$typeName: string;
|
|
815
|
+
id: string;
|
|
816
|
+
totalShares: bigint;
|
|
817
|
+
poolRewards: {
|
|
818
|
+
$typeName: string;
|
|
819
|
+
id: string;
|
|
820
|
+
poolRewardManagerId: string;
|
|
821
|
+
coinType: string;
|
|
822
|
+
startTimeMs: number;
|
|
823
|
+
endTimeMs: number;
|
|
824
|
+
totalRewards: BigNumber$1;
|
|
825
|
+
allocatedRewards: BigNumber$1;
|
|
826
|
+
cumulativeRewardsPerShare: BigNumber$1;
|
|
827
|
+
numUserRewardManagers: bigint;
|
|
828
|
+
rewardIndex: number;
|
|
829
|
+
symbol: string;
|
|
830
|
+
mintDecimals: number;
|
|
831
|
+
}[];
|
|
832
|
+
lastUpdateTimeMs: bigint;
|
|
833
|
+
};
|
|
834
|
+
borrowsPoolRewardManager: {
|
|
835
|
+
$typeName: string;
|
|
836
|
+
id: string;
|
|
837
|
+
totalShares: bigint;
|
|
838
|
+
poolRewards: {
|
|
839
|
+
$typeName: string;
|
|
840
|
+
id: string;
|
|
841
|
+
poolRewardManagerId: string;
|
|
842
|
+
coinType: string;
|
|
843
|
+
startTimeMs: number;
|
|
844
|
+
endTimeMs: number;
|
|
845
|
+
totalRewards: BigNumber$1;
|
|
846
|
+
allocatedRewards: BigNumber$1;
|
|
847
|
+
cumulativeRewardsPerShare: BigNumber$1;
|
|
848
|
+
numUserRewardManagers: bigint;
|
|
849
|
+
rewardIndex: number;
|
|
850
|
+
symbol: string;
|
|
851
|
+
mintDecimals: number;
|
|
852
|
+
}[];
|
|
853
|
+
lastUpdateTimeMs: bigint;
|
|
854
|
+
};
|
|
855
|
+
availableAmountUsd: BigNumber$1;
|
|
856
|
+
borrowedAmountUsd: BigNumber$1;
|
|
857
|
+
depositedAmount: BigNumber$1;
|
|
858
|
+
depositedAmountUsd: BigNumber$1;
|
|
859
|
+
cTokenExchangeRate: BigNumber$1;
|
|
860
|
+
borrowAprPercent: BigNumber$1;
|
|
861
|
+
depositAprPercent: BigNumber$1;
|
|
862
|
+
utilizationPercent: BigNumber$1;
|
|
863
|
+
token: {
|
|
864
|
+
decimals: number;
|
|
865
|
+
description: string;
|
|
866
|
+
iconUrl?: string | null;
|
|
867
|
+
id?: string | null;
|
|
868
|
+
name: string;
|
|
869
|
+
symbol: string;
|
|
870
|
+
coinType: string;
|
|
871
|
+
};
|
|
872
|
+
symbol: string;
|
|
873
|
+
name: string;
|
|
874
|
+
iconUrl: string | null | undefined;
|
|
875
|
+
description: string;
|
|
876
|
+
totalDeposits: BigNumber$1;
|
|
877
|
+
};
|
|
878
|
+
quote_reserve_map_info: {
|
|
879
|
+
config: {
|
|
880
|
+
$typeName: string;
|
|
881
|
+
openLtvPct: number;
|
|
882
|
+
closeLtvPct: number;
|
|
883
|
+
maxCloseLtvPct: number;
|
|
884
|
+
borrowWeightBps: BigNumber$1;
|
|
885
|
+
depositLimit: BigNumber$1;
|
|
886
|
+
borrowLimit: BigNumber$1;
|
|
887
|
+
liquidationBonusBps: number;
|
|
888
|
+
maxLiquidationBonusBps: number;
|
|
889
|
+
depositLimitUsd: BigNumber$1;
|
|
890
|
+
borrowLimitUsd: BigNumber$1;
|
|
891
|
+
borrowFeeBps: number;
|
|
892
|
+
spreadFeeBps: number;
|
|
893
|
+
protocolLiquidationFeeBps: number;
|
|
894
|
+
isolated: boolean;
|
|
895
|
+
openAttributedBorrowLimitUsd: number;
|
|
896
|
+
closeAttributedBorrowLimitUsd: number;
|
|
897
|
+
interestRate: {
|
|
898
|
+
id: string;
|
|
899
|
+
utilPercent: BigNumber$1;
|
|
900
|
+
aprPercent: BigNumber$1;
|
|
901
|
+
}[];
|
|
902
|
+
};
|
|
903
|
+
$typeName: string;
|
|
904
|
+
id: string;
|
|
905
|
+
arrayIndex: bigint;
|
|
906
|
+
coinType: string;
|
|
907
|
+
mintDecimals: number;
|
|
908
|
+
priceIdentifier: string;
|
|
909
|
+
price: BigNumber$1;
|
|
910
|
+
smoothedPrice: BigNumber$1;
|
|
911
|
+
minPrice: BigNumber$1;
|
|
912
|
+
maxPrice: BigNumber$1;
|
|
913
|
+
priceLastUpdateTimestampS: bigint;
|
|
914
|
+
availableAmount: BigNumber$1;
|
|
915
|
+
ctokenSupply: BigNumber$1;
|
|
916
|
+
borrowedAmount: BigNumber$1;
|
|
917
|
+
cumulativeBorrowRate: BigNumber$1;
|
|
918
|
+
interestLastUpdateTimestampS: bigint;
|
|
919
|
+
unclaimedSpreadFees: BigNumber$1;
|
|
920
|
+
attributedBorrowValue: BigNumber$1;
|
|
921
|
+
depositsPoolRewardManager: {
|
|
922
|
+
$typeName: string;
|
|
923
|
+
id: string;
|
|
924
|
+
totalShares: bigint;
|
|
925
|
+
poolRewards: {
|
|
926
|
+
$typeName: string;
|
|
927
|
+
id: string;
|
|
928
|
+
poolRewardManagerId: string;
|
|
929
|
+
coinType: string;
|
|
930
|
+
startTimeMs: number;
|
|
931
|
+
endTimeMs: number;
|
|
932
|
+
totalRewards: BigNumber$1;
|
|
933
|
+
allocatedRewards: BigNumber$1;
|
|
934
|
+
cumulativeRewardsPerShare: BigNumber$1;
|
|
935
|
+
numUserRewardManagers: bigint;
|
|
936
|
+
rewardIndex: number;
|
|
937
|
+
symbol: string;
|
|
938
|
+
mintDecimals: number;
|
|
939
|
+
}[];
|
|
940
|
+
lastUpdateTimeMs: bigint;
|
|
941
|
+
};
|
|
942
|
+
borrowsPoolRewardManager: {
|
|
943
|
+
$typeName: string;
|
|
944
|
+
id: string;
|
|
945
|
+
totalShares: bigint;
|
|
946
|
+
poolRewards: {
|
|
947
|
+
$typeName: string;
|
|
948
|
+
id: string;
|
|
949
|
+
poolRewardManagerId: string;
|
|
950
|
+
coinType: string;
|
|
951
|
+
startTimeMs: number;
|
|
952
|
+
endTimeMs: number;
|
|
953
|
+
totalRewards: BigNumber$1;
|
|
954
|
+
allocatedRewards: BigNumber$1;
|
|
955
|
+
cumulativeRewardsPerShare: BigNumber$1;
|
|
956
|
+
numUserRewardManagers: bigint;
|
|
957
|
+
rewardIndex: number;
|
|
958
|
+
symbol: string;
|
|
959
|
+
mintDecimals: number;
|
|
960
|
+
}[];
|
|
961
|
+
lastUpdateTimeMs: bigint;
|
|
962
|
+
};
|
|
963
|
+
availableAmountUsd: BigNumber$1;
|
|
964
|
+
borrowedAmountUsd: BigNumber$1;
|
|
965
|
+
depositedAmount: BigNumber$1;
|
|
966
|
+
depositedAmountUsd: BigNumber$1;
|
|
967
|
+
cTokenExchangeRate: BigNumber$1;
|
|
968
|
+
borrowAprPercent: BigNumber$1;
|
|
969
|
+
depositAprPercent: BigNumber$1;
|
|
970
|
+
utilizationPercent: BigNumber$1;
|
|
971
|
+
token: {
|
|
972
|
+
decimals: number;
|
|
973
|
+
description: string;
|
|
974
|
+
iconUrl?: string | null;
|
|
975
|
+
id?: string | null;
|
|
976
|
+
name: string;
|
|
977
|
+
symbol: string;
|
|
978
|
+
coinType: string;
|
|
979
|
+
};
|
|
980
|
+
symbol: string;
|
|
981
|
+
name: string;
|
|
982
|
+
iconUrl: string | null | undefined;
|
|
983
|
+
description: string;
|
|
984
|
+
totalDeposits: BigNumber$1;
|
|
985
|
+
};
|
|
986
|
+
}>;
|
|
987
|
+
refreshReservePrices: (tx: Transaction, reserve: Reserve<string>[]) => Promise<void>;
|
|
988
|
+
refreshReservePricesV2: (tx: Transaction, reserve: Reserve<string>[]) => Promise<void>;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
declare class SwapModules {
|
|
992
|
+
protected _sdk: CetusMarginTradingSDK;
|
|
993
|
+
constructor(sdk: CetusMarginTradingSDK);
|
|
994
|
+
/**
|
|
995
|
+
* Find router
|
|
996
|
+
*/
|
|
997
|
+
findRouters(coin_type_a: string, coin_type_b: string, amount: string, by_amount_in: boolean, pools: string[]): Promise<{
|
|
998
|
+
is_exceed: boolean;
|
|
999
|
+
quoteID?: string;
|
|
1000
|
+
amountIn: bn_js__default;
|
|
1001
|
+
amountOut: bn_js__default;
|
|
1002
|
+
byAmountIn: boolean;
|
|
1003
|
+
paths: _cetusprotocol_aggregator_sdk.Path[];
|
|
1004
|
+
insufficientLiquidity: boolean;
|
|
1005
|
+
deviationRatio?: number;
|
|
1006
|
+
packages?: Map<string, string>;
|
|
1007
|
+
totalDeepFee?: number;
|
|
1008
|
+
error?: _cetusprotocol_aggregator_sdk.RouterError;
|
|
1009
|
+
overlayFee?: number;
|
|
1010
|
+
amount_in?: undefined;
|
|
1011
|
+
amount_out?: undefined;
|
|
1012
|
+
route_obj?: undefined;
|
|
1013
|
+
by_amount_in?: undefined;
|
|
1014
|
+
origin_res?: undefined;
|
|
1015
|
+
} | {
|
|
1016
|
+
amount_in: any;
|
|
1017
|
+
amount_out: any;
|
|
1018
|
+
is_exceed: any;
|
|
1019
|
+
route_obj: any;
|
|
1020
|
+
by_amount_in: boolean;
|
|
1021
|
+
origin_res: any;
|
|
1022
|
+
} | null>;
|
|
1023
|
+
/**
|
|
1024
|
+
* Execute router swap
|
|
1025
|
+
*/
|
|
1026
|
+
routerSwap: (params: RouterSwapParams) => Promise<TransactionObjectArgument | undefined>;
|
|
1027
|
+
/**
|
|
1028
|
+
* Check if swap is needed and handle swap logic
|
|
1029
|
+
* @param params Parameter object
|
|
1030
|
+
* @returns Swap result
|
|
1031
|
+
*/
|
|
1032
|
+
handleSwapLogic(params: {
|
|
1033
|
+
is_long: boolean;
|
|
1034
|
+
is_quote: boolean;
|
|
1035
|
+
amount: string;
|
|
1036
|
+
base_token: string;
|
|
1037
|
+
quote_token: string;
|
|
1038
|
+
swap_clmm_pool: string;
|
|
1039
|
+
slippage: number;
|
|
1040
|
+
tx: Transaction;
|
|
1041
|
+
}): Promise<{
|
|
1042
|
+
has_swap: boolean;
|
|
1043
|
+
input_coin: any;
|
|
1044
|
+
init_deposit_amount: string;
|
|
1045
|
+
}>;
|
|
1046
|
+
handleSwap(params: {
|
|
1047
|
+
from: string;
|
|
1048
|
+
to: string;
|
|
1049
|
+
amount: string;
|
|
1050
|
+
input_coin?: TransactionObjectArgument;
|
|
1051
|
+
swap_clmm_pool: string;
|
|
1052
|
+
slippage: number;
|
|
1053
|
+
tx: Transaction;
|
|
1054
|
+
}): Promise<{
|
|
1055
|
+
swap_out_coin: TransactionObjectArgument | undefined;
|
|
1056
|
+
amount_out: any;
|
|
1057
|
+
}>;
|
|
1058
|
+
/**
|
|
1059
|
+
* Execute flash loan
|
|
1060
|
+
*/
|
|
1061
|
+
flashLoan: (params: FlashLoanParams) => {
|
|
1062
|
+
balance_a: {
|
|
1063
|
+
$kind: "NestedResult";
|
|
1064
|
+
NestedResult: [number, number];
|
|
1065
|
+
};
|
|
1066
|
+
balance_b: {
|
|
1067
|
+
$kind: "NestedResult";
|
|
1068
|
+
NestedResult: [number, number];
|
|
1069
|
+
};
|
|
1070
|
+
receipt: {
|
|
1071
|
+
$kind: "NestedResult";
|
|
1072
|
+
NestedResult: [number, number];
|
|
1073
|
+
};
|
|
1074
|
+
is_loan_a: boolean;
|
|
1075
|
+
loan_coin_type: string;
|
|
1076
|
+
};
|
|
1077
|
+
/** Get flash loan pool */
|
|
1078
|
+
getFlashLoanPool: (flash_loan_coin: string, flash_amount: string) => Promise<{
|
|
1079
|
+
clmm_pool_coin_type_a: any;
|
|
1080
|
+
clmm_pool_coin_type_b: any;
|
|
1081
|
+
clmm_pool: any;
|
|
1082
|
+
clmm_fee_tier: string;
|
|
1083
|
+
}>;
|
|
1084
|
+
/**
|
|
1085
|
+
* Repay flash loan
|
|
1086
|
+
*/
|
|
1087
|
+
repayFlashLoan: (params: RepayFlashSwapParams) => Transaction;
|
|
1088
|
+
/**
|
|
1089
|
+
* Calculate flash loan
|
|
1090
|
+
*/
|
|
1091
|
+
calculateFlashLoan(params: CalculateFlashLoanParams): Promise<{
|
|
1092
|
+
flash_amount: string;
|
|
1093
|
+
rate: string;
|
|
1094
|
+
quote_price: string;
|
|
1095
|
+
base_price: string;
|
|
1096
|
+
flash_loan_coin: string;
|
|
1097
|
+
is_flash_a: boolean;
|
|
1098
|
+
flash_loan_fee: string;
|
|
1099
|
+
clmm_pool: any;
|
|
1100
|
+
clmm_pool_coin_type_a: any;
|
|
1101
|
+
clmm_pool_coin_type_b: any;
|
|
1102
|
+
clmm_fee_tier: string;
|
|
1103
|
+
}>;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
interface SdkOptions extends BaseSdkOptions {
|
|
1107
|
+
full_rpc_url: string;
|
|
1108
|
+
env: 'mainnet' | 'testnet';
|
|
1109
|
+
aggregator_url: string;
|
|
1110
|
+
margin_trading: Package<MarginTradingConfigs>;
|
|
1111
|
+
suilend: Package<SuiLendConfigs>;
|
|
1112
|
+
}
|
|
1113
|
+
declare class CetusMarginTradingSDK extends SdkWrapper<SdkOptions> {
|
|
1114
|
+
protected _marketModules: MarketModules;
|
|
1115
|
+
protected _permissionModules: PermissionModules;
|
|
1116
|
+
protected _positionModules: PositionModules;
|
|
1117
|
+
protected _suilendModule: SuiLendModule;
|
|
1118
|
+
protected _swapModules: SwapModules;
|
|
1119
|
+
protected _aggregatorClient: AggregatorClient;
|
|
1120
|
+
protected _clmmSDK: CetusClmmSDK;
|
|
1121
|
+
protected _pythConnection: SuiPriceServiceConnection;
|
|
1122
|
+
senderAddress: string | undefined;
|
|
1123
|
+
constructor(options: SdkOptions, clmmSDK?: CetusClmmSDK);
|
|
1124
|
+
get SuiLendModule(): SuiLendModule;
|
|
1125
|
+
get PermissionModules(): PermissionModules;
|
|
1126
|
+
get MarketModules(): MarketModules;
|
|
1127
|
+
get PositionModules(): PositionModules;
|
|
1128
|
+
get SwapModules(): SwapModules;
|
|
1129
|
+
get AggregatorClient(): AggregatorClient;
|
|
1130
|
+
get ClmmSDK(): CetusClmmSDK;
|
|
1131
|
+
get PythConnection(): SuiPriceServiceConnection;
|
|
1132
|
+
static createSDK(options: BaseSdkOptions): CetusMarginTradingSDK;
|
|
1133
|
+
static createCustomSDK<T extends BaseSdkOptions>(options: T & SdkOptions): CetusMarginTradingSDK;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
declare const margin_trading_mainnet: SdkOptions;
|
|
1137
|
+
|
|
1138
|
+
declare const wrapMarketInfo: (info: any) => {
|
|
1139
|
+
market_id: any;
|
|
1140
|
+
base_token: string;
|
|
1141
|
+
quote_token: string;
|
|
1142
|
+
max_long_leverage: string;
|
|
1143
|
+
max_short_leverage: string;
|
|
1144
|
+
open_fee_rate: string;
|
|
1145
|
+
close_fee_rate: string;
|
|
1146
|
+
open_permissions_pause: boolean;
|
|
1147
|
+
close_permissions_pause: boolean;
|
|
1148
|
+
deposit_permissions_pause: boolean;
|
|
1149
|
+
withdraw_permissions_pause: boolean;
|
|
1150
|
+
borrow_permissions_pause: boolean;
|
|
1151
|
+
repay_permissions_pause: boolean;
|
|
1152
|
+
};
|
|
1153
|
+
declare const wrapPosition: (position: any, position_cap_id: string) => {
|
|
1154
|
+
created_at: any;
|
|
1155
|
+
position_id: any;
|
|
1156
|
+
init_deposit_amount: any;
|
|
1157
|
+
is_long: any;
|
|
1158
|
+
lending_market_id: any;
|
|
1159
|
+
obligation_owner_cap: any;
|
|
1160
|
+
market_id: any;
|
|
1161
|
+
position_cap_id: string;
|
|
1162
|
+
};
|
|
1163
|
+
declare const mergePositionData: (position: any, obligation: any, reserve_map: any, lst_apr_percent_map: any, reward_map: any) => any;
|
|
1164
|
+
declare const wrapMarketPermissions: (permissions: string) => {
|
|
1165
|
+
open_permissions_pause: boolean;
|
|
1166
|
+
close_permissions_pause: boolean;
|
|
1167
|
+
deposit_permissions_pause: boolean;
|
|
1168
|
+
withdraw_permissions_pause: boolean;
|
|
1169
|
+
borrow_permissions_pause: boolean;
|
|
1170
|
+
repay_permissions_pause: boolean;
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
declare const oraclePriceMultiplierDecimal = 10n;
|
|
1174
|
+
declare function calculateUtilizationPercent(reserve: ParsedReserve): BigNumber$1;
|
|
1175
|
+
declare function calculateBorrowAprPercent(reserve: ParsedReserve): BigNumber$1 | undefined;
|
|
1176
|
+
declare function calculateDepositAprPercent(reserve: ParsedReserve): BigNumber$1 | undefined;
|
|
1177
|
+
declare function appendExtraRewards(side: Side, reserve: ParsedReserve, filteredRewards: any[], sdk: CetusMarginTradingSDK): void;
|
|
1178
|
+
declare function getUpdatedReserve(reserve: ParsedReserve, side: Side, changeAmount: BigNumber$1): ParsedReserve;
|
|
1179
|
+
declare function getRewardsAprMultiplier(side: Side, reserve: ParsedReserve, newReserve: ParsedReserve): {
|
|
1180
|
+
multiplier: BigNumber$1;
|
|
1181
|
+
isValid: boolean;
|
|
1182
|
+
};
|
|
1183
|
+
declare function updateRewardsWithMultiplier(perDayRewards: PerDayRewardSummary[], aprRewards: AprRewardSummary[], multiplier: BigNumber$1, isValid: boolean): {
|
|
1184
|
+
newPerDayRewards: PerDayRewardSummary[];
|
|
1185
|
+
newAprRewards: AprRewardSummary[];
|
|
1186
|
+
};
|
|
1187
|
+
declare function getPriceWithFormattedDecimals(pythPrice: bigint, expo: bigint): bigint;
|
|
1188
|
+
declare function formatLtvPercentValue(value: string): string;
|
|
1189
|
+
|
|
1190
|
+
export { type AllAppData, type AppData, type BorrowAssetParams, type BorrowNotSuiParams, type BorrowSuiParams, type CalculateFlashLoanParams, type CalculatePositionDepositParams, type CalculatePositionLeverageParams, type CalculatePositionRepayParams, type CalculatePositionWithdrawParams, CetusMarginTradingSDK, type ClaimMarketFeeParams, type CreateLeveragePositionParams, type CreateMarginTradingContextParams, type CreateMarketParams, type FeedInfo, type FlashLoanParams, type LendingMarket, type MarginTradingConfig, type MarginTradingConfigs, type Market, type MarketSuilendInfo, type OpenPositionParams, type Position, type PositionCloseParams, type PositionCloseWithCoinParams, type PositionDepositParams, type PositionManageLeverageParams, type PositionManageSizeDepositParams, type PositionManageSizeWithdrawParams, type PositionRepayParams, type Price, type RepayFlashSwapParams, type RepayParams, type RouterSwapParams, type SdkOptions, type SuiLendCoinAprResult, type SuiLendConfigs, type UpdateMarketFeeRateParams, type UpdateMarketMaxLeverageParams, type WithdrawAssetParams, type WithdrawParams, appendExtraRewards, calculateBorrowAprPercent, calculateDepositAprPercent, calculateUtilizationPercent, CetusMarginTradingSDK as default, formatLtvPercentValue, getPriceWithFormattedDecimals, getRewardsAprMultiplier, getUpdatedReserve, margin_trading_mainnet, mergePositionData, oraclePriceMultiplierDecimal, type positionTopUpCTokenParams, type positionWithdrawCTokenParams, updateRewardsWithMultiplier, wrapMarketInfo, wrapMarketPermissions, wrapPosition };
|