lll-sdk 0.0.0-experimental-20250821111532 → 0.0.0-experimental-20250902104154
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +523 -17
- package/dist/index.d.ts +523 -17
- package/dist/index.js +178 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +178 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SdkWrapper, BaseSdkOptions, Package } from '@cetusprotocol/common-sdk';
|
|
2
2
|
import * as _mysten_sui_dist_cjs_transactions from '@mysten/sui/dist/cjs/transactions';
|
|
3
3
|
import { Transaction } from '@mysten/sui/dist/cjs/transactions';
|
|
4
|
+
import { SuilendClient as SuilendClient$1 } from '@suilend/sdk/client';
|
|
4
5
|
import { SuilendClient, ParsedLendingMarket, ParsedReserve } from '@suilend/sdk';
|
|
5
6
|
import { CoinMetadata } from '@mysten/sui/client';
|
|
6
7
|
import { Reserve } from '@suilend/sdk/_generated/suilend/reserve/structs';
|
|
@@ -9,7 +10,15 @@ import Decimal from 'decimal.js';
|
|
|
9
10
|
import BigNumber$1 from 'bignumber.js';
|
|
10
11
|
import * as _cetusprotocol_aggregator_sdk from '@cetusprotocol/aggregator-sdk';
|
|
11
12
|
import { AggregatorClient } from '@cetusprotocol/aggregator-sdk';
|
|
13
|
+
import * as _suilend_sdk__generated_suilend_liquidity_mining_structs from '@suilend/sdk/_generated/suilend/liquidity-mining/structs';
|
|
14
|
+
import * as _suilend_sdk__generated_suilend_decimal_structs from '@suilend/sdk/_generated/suilend/decimal/structs';
|
|
15
|
+
import * as _suilend_sdk__generated__framework_vector from '@suilend/sdk/_generated/_framework/vector';
|
|
16
|
+
import * as _suilend_sdk__generated_suilend_obligation_structs from '@suilend/sdk/_generated/suilend/obligation/structs';
|
|
17
|
+
import * as _suilend_sdk__generated__framework_reified from '@suilend/sdk/_generated/_framework/reified';
|
|
18
|
+
import * as _suilend_sdk__generated__dependencies_source_0x2_object_structs from '@suilend/sdk/_generated/_dependencies/source/0x2/object/structs';
|
|
19
|
+
import { Transaction as Transaction$1 } from '@mysten/sui/transactions';
|
|
12
20
|
import { CetusClmmSDK } from '@cetusprotocol/sui-clmm-sdk';
|
|
21
|
+
import { SuiPriceServiceConnection } from '@pythnetwork/pyth-sui-js';
|
|
13
22
|
|
|
14
23
|
interface LeverageConfig {
|
|
15
24
|
global_config_id: string;
|
|
@@ -46,28 +55,116 @@ interface AllAppData {
|
|
|
46
55
|
allLendingMarketData: Record<string, AppData>;
|
|
47
56
|
lstAprPercentMap: Record<string, BigNumber>;
|
|
48
57
|
}
|
|
49
|
-
interface
|
|
50
|
-
isQuote: boolean;
|
|
58
|
+
interface OpenPositionParams {
|
|
51
59
|
marketId: string;
|
|
52
|
-
|
|
60
|
+
isLong: boolean;
|
|
61
|
+
isQuote: boolean;
|
|
62
|
+
depositAmount: Decimal;
|
|
63
|
+
leverage: number;
|
|
53
64
|
clmmPool: string;
|
|
54
65
|
slippage: number;
|
|
55
66
|
}
|
|
56
|
-
interface
|
|
67
|
+
interface FlashLoanParams {
|
|
57
68
|
amount: Decimal;
|
|
58
69
|
clmmPool: string;
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
clmmPoolCoinTypeA: string;
|
|
71
|
+
clmmPoolCoinTypeB: string;
|
|
72
|
+
flashLoanCoin: string;
|
|
61
73
|
tx: Transaction;
|
|
62
74
|
}
|
|
63
75
|
interface RepayFlashSwapParams {
|
|
64
76
|
clmmPool: string;
|
|
65
|
-
coinA: string;
|
|
66
|
-
coinB: string;
|
|
67
77
|
tx: Transaction;
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
repayBase: any;
|
|
79
|
+
repayQuote: any;
|
|
80
|
+
clmmPoolCoinTypeA: string;
|
|
81
|
+
clmmPoolCoinTypeB: string;
|
|
82
|
+
receipt: any;
|
|
70
83
|
}
|
|
84
|
+
type Price = {
|
|
85
|
+
coin_type: string;
|
|
86
|
+
price: string;
|
|
87
|
+
oracle_price: bigint;
|
|
88
|
+
last_update_time: number;
|
|
89
|
+
};
|
|
90
|
+
type PositionManageSizeDepositParams = {
|
|
91
|
+
marketId: string;
|
|
92
|
+
positionId: string;
|
|
93
|
+
isLong: boolean;
|
|
94
|
+
isQuote: boolean;
|
|
95
|
+
depositAmount: Decimal;
|
|
96
|
+
clmmPool: string;
|
|
97
|
+
slippage: number;
|
|
98
|
+
leverage: number;
|
|
99
|
+
txb?: Transaction;
|
|
100
|
+
};
|
|
101
|
+
type PositionManageSizeWithdrawParams = {
|
|
102
|
+
marketId: string;
|
|
103
|
+
positionId: string;
|
|
104
|
+
withdrawAmount: Decimal;
|
|
105
|
+
isQuote: boolean;
|
|
106
|
+
clmmPool: string;
|
|
107
|
+
isLong: boolean;
|
|
108
|
+
slippage: number;
|
|
109
|
+
leverage: number;
|
|
110
|
+
txb?: Transaction;
|
|
111
|
+
};
|
|
112
|
+
type RepayParams = {
|
|
113
|
+
txb?: Transaction;
|
|
114
|
+
positionId: string;
|
|
115
|
+
repayAmount: Decimal;
|
|
116
|
+
repayCoinType: string;
|
|
117
|
+
repayCoin?: any;
|
|
118
|
+
repayReserveArrayIndex: string;
|
|
119
|
+
};
|
|
120
|
+
type RouterSwapParams = {
|
|
121
|
+
slippage: number;
|
|
122
|
+
inputCoin: any;
|
|
123
|
+
router: any;
|
|
124
|
+
txb?: Transaction;
|
|
125
|
+
};
|
|
126
|
+
type BorrowAssetParams = {
|
|
127
|
+
position?: any;
|
|
128
|
+
positionId?: string;
|
|
129
|
+
reserveArrayIndex: string;
|
|
130
|
+
borrowAmount: Decimal;
|
|
131
|
+
baseToken: string;
|
|
132
|
+
quoteToken: string;
|
|
133
|
+
isLong: boolean;
|
|
134
|
+
lendingMarketId: string;
|
|
135
|
+
};
|
|
136
|
+
type WithdrawAssetParams = {
|
|
137
|
+
marketId: string;
|
|
138
|
+
positionId: string;
|
|
139
|
+
withdrawAmount: Decimal;
|
|
140
|
+
withdrawReserveArrayIndex: string;
|
|
141
|
+
withdrawCoinType: string;
|
|
142
|
+
baseToken: string;
|
|
143
|
+
quoteToken: string;
|
|
144
|
+
priceObjectId: string;
|
|
145
|
+
};
|
|
146
|
+
type PositionCloseParams = {
|
|
147
|
+
marketId: string;
|
|
148
|
+
positionId: string;
|
|
149
|
+
};
|
|
150
|
+
type CalculateOpenPositionParams = {
|
|
151
|
+
marketId: string;
|
|
152
|
+
isLong: boolean;
|
|
153
|
+
isQuote: boolean;
|
|
154
|
+
depositAmount: Decimal;
|
|
155
|
+
leverage: number;
|
|
156
|
+
clmmPool: string;
|
|
157
|
+
slippage: number;
|
|
158
|
+
};
|
|
159
|
+
type PositionManageLeverageParams = {
|
|
160
|
+
marketId: string;
|
|
161
|
+
positionId: string;
|
|
162
|
+
isLong: boolean;
|
|
163
|
+
clmmPool: string;
|
|
164
|
+
currentLeverage: number;
|
|
165
|
+
targetLeverage: number;
|
|
166
|
+
slippage: number;
|
|
167
|
+
};
|
|
71
168
|
|
|
72
169
|
declare class SuiLendModule {
|
|
73
170
|
private sdk;
|
|
@@ -80,7 +177,7 @@ declare class SuiLendModule {
|
|
|
80
177
|
* @param lendingMarketId 借贷市场ID
|
|
81
178
|
* @param lendingMarketType 借贷市场类型
|
|
82
179
|
*/
|
|
83
|
-
|
|
180
|
+
getSuilendClient(lendingMarketId: string, lendingMarketType: string): Promise<SuilendClient$1>;
|
|
84
181
|
/**
|
|
85
182
|
* 获取借贷市场数据(缓存)
|
|
86
183
|
* @param forceRefresh 是否强制刷新
|
|
@@ -117,16 +214,362 @@ declare class SuiLendModule {
|
|
|
117
214
|
rewardMap: any;
|
|
118
215
|
} | undefined>;
|
|
119
216
|
createObligation: (transaction: Transaction) => Promise<_mysten_sui_dist_cjs_transactions.TransactionResult>;
|
|
217
|
+
refreshReservePrices: (tx: Transaction, priceObjectId: string, reserveArrayIndex: bigint) => Promise<void>;
|
|
218
|
+
getLatestPriceFeeds: (reserves: Reserve<string>[]) => Promise<Record<string, Price>>;
|
|
219
|
+
priceCheck(price: Price, age?: number): Price | undefined;
|
|
220
|
+
getSuiLendReserveInfo: (baseToken: string, quoteToken: string) => Promise<{
|
|
221
|
+
baseReserveArrayIndex: string;
|
|
222
|
+
quoteReserveArrayIndex: string;
|
|
223
|
+
reserve: Reserve<string>[];
|
|
224
|
+
}>;
|
|
120
225
|
}
|
|
121
226
|
|
|
122
227
|
declare class LeverageModules {
|
|
123
228
|
protected _sdk: CetusLeverageSDK;
|
|
124
229
|
constructor(sdk: CetusLeverageSDK);
|
|
230
|
+
/**
|
|
231
|
+
* 获取合约config信息 包含是否禁用做多、做空
|
|
232
|
+
*/
|
|
125
233
|
getLeverageConfig: () => Promise<any>;
|
|
126
|
-
|
|
234
|
+
/**
|
|
235
|
+
* 获取杠杆市场列表
|
|
236
|
+
*/
|
|
237
|
+
getLeverageMarketsList: (force_refresh?: boolean) => Promise<any[]>;
|
|
238
|
+
/**
|
|
239
|
+
* 获取杠杆市场信息
|
|
240
|
+
*/
|
|
127
241
|
getLeverageMarketInfo: (marketId: string) => Promise<any>;
|
|
128
|
-
|
|
129
|
-
|
|
242
|
+
/**
|
|
243
|
+
* 获取杠杆仓位列表
|
|
244
|
+
*/
|
|
245
|
+
getLeveragePositionList: () => Promise<{
|
|
246
|
+
__StructClass: true;
|
|
247
|
+
$typeName: string;
|
|
248
|
+
$fullTypeName: `${string}::obligation::Obligation<${string}>`;
|
|
249
|
+
$typeArgs: [string];
|
|
250
|
+
$isPhantom: readonly [true];
|
|
251
|
+
id: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated__dependencies_source_0x2_object_structs.UID>;
|
|
252
|
+
lendingMarketId: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated__dependencies_source_0x2_object_structs.ID>;
|
|
253
|
+
deposits: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated__framework_vector.Vector<_suilend_sdk__generated_suilend_obligation_structs.Deposit>>;
|
|
254
|
+
borrows: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated__framework_vector.Vector<_suilend_sdk__generated_suilend_obligation_structs.Borrow>>;
|
|
255
|
+
depositedValueUsd: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated_suilend_decimal_structs.Decimal>;
|
|
256
|
+
allowedBorrowValueUsd: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated_suilend_decimal_structs.Decimal>;
|
|
257
|
+
unhealthyBorrowValueUsd: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated_suilend_decimal_structs.Decimal>;
|
|
258
|
+
superUnhealthyBorrowValueUsd: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated_suilend_decimal_structs.Decimal>;
|
|
259
|
+
unweightedBorrowedValueUsd: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated_suilend_decimal_structs.Decimal>;
|
|
260
|
+
weightedBorrowedValueUsd: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated_suilend_decimal_structs.Decimal>;
|
|
261
|
+
weightedBorrowedValueUpperBoundUsd: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated_suilend_decimal_structs.Decimal>;
|
|
262
|
+
borrowingIsolatedAsset: _suilend_sdk__generated__framework_reified.ToField<"bool">;
|
|
263
|
+
userRewardManagers: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated__framework_vector.Vector<_suilend_sdk__generated_suilend_liquidity_mining_structs.UserRewardManager>>;
|
|
264
|
+
badDebtUsd: _suilend_sdk__generated__framework_reified.ToField<_suilend_sdk__generated_suilend_decimal_structs.Decimal>;
|
|
265
|
+
closable: _suilend_sdk__generated__framework_reified.ToField<"bool">;
|
|
266
|
+
createdAt: any;
|
|
267
|
+
initDepositAmount: any;
|
|
268
|
+
isLong: any;
|
|
269
|
+
obligationOwnerCap: any;
|
|
270
|
+
}[]>;
|
|
271
|
+
/**
|
|
272
|
+
* 获取杠杆仓位详情
|
|
273
|
+
*/
|
|
274
|
+
getLeveragePosition: (positionId: string) => Promise<{
|
|
275
|
+
createdAt: any;
|
|
276
|
+
id: any;
|
|
277
|
+
initDepositAmount: any;
|
|
278
|
+
isLong: any;
|
|
279
|
+
lendingMarketId: any;
|
|
280
|
+
obligationOwnerCap: any;
|
|
281
|
+
depositedAmountUsd: BigNumber;
|
|
282
|
+
borrowedAmountUsd: BigNumber;
|
|
283
|
+
netValueUsd: BigNumber;
|
|
284
|
+
weightedBorrowsUsd: BigNumber;
|
|
285
|
+
maxPriceWeightedBorrowsUsd: BigNumber;
|
|
286
|
+
borrowLimitUsd: BigNumber;
|
|
287
|
+
minPriceBorrowLimitUsd: BigNumber;
|
|
288
|
+
unhealthyBorrowValueUsd: BigNumber;
|
|
289
|
+
depositPositionCount: number;
|
|
290
|
+
borrowPositionCount: number;
|
|
291
|
+
positionCount: number;
|
|
292
|
+
deposits: {
|
|
293
|
+
coinType: string;
|
|
294
|
+
reserveArrayIndex: bigint;
|
|
295
|
+
userRewardManagerIndex: number;
|
|
296
|
+
userRewardManager: _suilend_sdk__generated_suilend_liquidity_mining_structs.UserRewardManager;
|
|
297
|
+
depositedAmount: BigNumber;
|
|
298
|
+
depositedAmountUsd: BigNumber;
|
|
299
|
+
depositedCtokenAmount: BigNumber;
|
|
300
|
+
reserve: {
|
|
301
|
+
config: {
|
|
302
|
+
$typeName: string;
|
|
303
|
+
openLtvPct: number;
|
|
304
|
+
closeLtvPct: number;
|
|
305
|
+
maxCloseLtvPct: number;
|
|
306
|
+
borrowWeightBps: BigNumber;
|
|
307
|
+
depositLimit: BigNumber;
|
|
308
|
+
borrowLimit: BigNumber;
|
|
309
|
+
liquidationBonusBps: number;
|
|
310
|
+
maxLiquidationBonusBps: number;
|
|
311
|
+
depositLimitUsd: BigNumber;
|
|
312
|
+
borrowLimitUsd: BigNumber;
|
|
313
|
+
borrowFeeBps: number;
|
|
314
|
+
spreadFeeBps: number;
|
|
315
|
+
protocolLiquidationFeeBps: number;
|
|
316
|
+
isolated: boolean;
|
|
317
|
+
openAttributedBorrowLimitUsd: number;
|
|
318
|
+
closeAttributedBorrowLimitUsd: number;
|
|
319
|
+
interestRate: {
|
|
320
|
+
id: string;
|
|
321
|
+
utilPercent: BigNumber;
|
|
322
|
+
aprPercent: BigNumber;
|
|
323
|
+
}[];
|
|
324
|
+
};
|
|
325
|
+
$typeName: string;
|
|
326
|
+
id: string;
|
|
327
|
+
arrayIndex: bigint;
|
|
328
|
+
coinType: string;
|
|
329
|
+
mintDecimals: number;
|
|
330
|
+
priceIdentifier: string;
|
|
331
|
+
price: BigNumber;
|
|
332
|
+
smoothedPrice: BigNumber;
|
|
333
|
+
minPrice: BigNumber;
|
|
334
|
+
maxPrice: BigNumber;
|
|
335
|
+
priceLastUpdateTimestampS: bigint;
|
|
336
|
+
availableAmount: BigNumber;
|
|
337
|
+
ctokenSupply: BigNumber;
|
|
338
|
+
borrowedAmount: BigNumber;
|
|
339
|
+
cumulativeBorrowRate: BigNumber;
|
|
340
|
+
interestLastUpdateTimestampS: bigint;
|
|
341
|
+
unclaimedSpreadFees: BigNumber;
|
|
342
|
+
attributedBorrowValue: BigNumber;
|
|
343
|
+
depositsPoolRewardManager: {
|
|
344
|
+
$typeName: string;
|
|
345
|
+
id: string;
|
|
346
|
+
totalShares: bigint;
|
|
347
|
+
poolRewards: {
|
|
348
|
+
$typeName: string;
|
|
349
|
+
id: string;
|
|
350
|
+
poolRewardManagerId: string;
|
|
351
|
+
coinType: string;
|
|
352
|
+
startTimeMs: number;
|
|
353
|
+
endTimeMs: number;
|
|
354
|
+
totalRewards: BigNumber;
|
|
355
|
+
allocatedRewards: BigNumber;
|
|
356
|
+
cumulativeRewardsPerShare: BigNumber;
|
|
357
|
+
numUserRewardManagers: bigint;
|
|
358
|
+
rewardIndex: number;
|
|
359
|
+
symbol: string;
|
|
360
|
+
mintDecimals: number;
|
|
361
|
+
}[];
|
|
362
|
+
lastUpdateTimeMs: bigint;
|
|
363
|
+
};
|
|
364
|
+
borrowsPoolRewardManager: {
|
|
365
|
+
$typeName: string;
|
|
366
|
+
id: string;
|
|
367
|
+
totalShares: bigint;
|
|
368
|
+
poolRewards: {
|
|
369
|
+
$typeName: string;
|
|
370
|
+
id: string;
|
|
371
|
+
poolRewardManagerId: string;
|
|
372
|
+
coinType: string;
|
|
373
|
+
startTimeMs: number;
|
|
374
|
+
endTimeMs: number;
|
|
375
|
+
totalRewards: BigNumber;
|
|
376
|
+
allocatedRewards: BigNumber;
|
|
377
|
+
cumulativeRewardsPerShare: BigNumber;
|
|
378
|
+
numUserRewardManagers: bigint;
|
|
379
|
+
rewardIndex: number;
|
|
380
|
+
symbol: string;
|
|
381
|
+
mintDecimals: number;
|
|
382
|
+
}[];
|
|
383
|
+
lastUpdateTimeMs: bigint;
|
|
384
|
+
};
|
|
385
|
+
availableAmountUsd: BigNumber;
|
|
386
|
+
borrowedAmountUsd: BigNumber;
|
|
387
|
+
depositedAmount: BigNumber;
|
|
388
|
+
depositedAmountUsd: BigNumber;
|
|
389
|
+
cTokenExchangeRate: BigNumber;
|
|
390
|
+
borrowAprPercent: BigNumber;
|
|
391
|
+
depositAprPercent: BigNumber;
|
|
392
|
+
utilizationPercent: BigNumber;
|
|
393
|
+
token: {
|
|
394
|
+
decimals: number;
|
|
395
|
+
description: string;
|
|
396
|
+
iconUrl?: string | null;
|
|
397
|
+
id?: string | null;
|
|
398
|
+
name: string;
|
|
399
|
+
symbol: string;
|
|
400
|
+
coinType: string;
|
|
401
|
+
};
|
|
402
|
+
symbol: string;
|
|
403
|
+
name: string;
|
|
404
|
+
iconUrl: string | null | undefined;
|
|
405
|
+
description: string;
|
|
406
|
+
totalDeposits: BigNumber;
|
|
407
|
+
};
|
|
408
|
+
original: _suilend_sdk__generated_suilend_obligation_structs.Obligation<string>;
|
|
409
|
+
}[];
|
|
410
|
+
borrows: {
|
|
411
|
+
coinType: string;
|
|
412
|
+
reserveArrayIndex: bigint;
|
|
413
|
+
userRewardManagerIndex: number;
|
|
414
|
+
userRewardManager: _suilend_sdk__generated_suilend_liquidity_mining_structs.UserRewardManager;
|
|
415
|
+
borrowedAmount: BigNumber;
|
|
416
|
+
borrowedAmountUsd: BigNumber;
|
|
417
|
+
reserve: {
|
|
418
|
+
config: {
|
|
419
|
+
$typeName: string;
|
|
420
|
+
openLtvPct: number;
|
|
421
|
+
closeLtvPct: number;
|
|
422
|
+
maxCloseLtvPct: number;
|
|
423
|
+
borrowWeightBps: BigNumber;
|
|
424
|
+
depositLimit: BigNumber;
|
|
425
|
+
borrowLimit: BigNumber;
|
|
426
|
+
liquidationBonusBps: number;
|
|
427
|
+
maxLiquidationBonusBps: number;
|
|
428
|
+
depositLimitUsd: BigNumber;
|
|
429
|
+
borrowLimitUsd: BigNumber;
|
|
430
|
+
borrowFeeBps: number;
|
|
431
|
+
spreadFeeBps: number;
|
|
432
|
+
protocolLiquidationFeeBps: number;
|
|
433
|
+
isolated: boolean;
|
|
434
|
+
openAttributedBorrowLimitUsd: number;
|
|
435
|
+
closeAttributedBorrowLimitUsd: number;
|
|
436
|
+
interestRate: {
|
|
437
|
+
id: string;
|
|
438
|
+
utilPercent: BigNumber;
|
|
439
|
+
aprPercent: BigNumber;
|
|
440
|
+
}[];
|
|
441
|
+
};
|
|
442
|
+
$typeName: string;
|
|
443
|
+
id: string;
|
|
444
|
+
arrayIndex: bigint;
|
|
445
|
+
coinType: string;
|
|
446
|
+
mintDecimals: number;
|
|
447
|
+
priceIdentifier: string;
|
|
448
|
+
price: BigNumber;
|
|
449
|
+
smoothedPrice: BigNumber;
|
|
450
|
+
minPrice: BigNumber;
|
|
451
|
+
maxPrice: BigNumber;
|
|
452
|
+
priceLastUpdateTimestampS: bigint;
|
|
453
|
+
availableAmount: BigNumber;
|
|
454
|
+
ctokenSupply: BigNumber;
|
|
455
|
+
borrowedAmount: BigNumber;
|
|
456
|
+
cumulativeBorrowRate: BigNumber;
|
|
457
|
+
interestLastUpdateTimestampS: bigint;
|
|
458
|
+
unclaimedSpreadFees: BigNumber;
|
|
459
|
+
attributedBorrowValue: BigNumber;
|
|
460
|
+
depositsPoolRewardManager: {
|
|
461
|
+
$typeName: string;
|
|
462
|
+
id: string;
|
|
463
|
+
totalShares: bigint;
|
|
464
|
+
poolRewards: {
|
|
465
|
+
$typeName: string;
|
|
466
|
+
id: string;
|
|
467
|
+
poolRewardManagerId: string;
|
|
468
|
+
coinType: string;
|
|
469
|
+
startTimeMs: number;
|
|
470
|
+
endTimeMs: number;
|
|
471
|
+
totalRewards: BigNumber;
|
|
472
|
+
allocatedRewards: BigNumber;
|
|
473
|
+
cumulativeRewardsPerShare: BigNumber;
|
|
474
|
+
numUserRewardManagers: bigint;
|
|
475
|
+
rewardIndex: number;
|
|
476
|
+
symbol: string;
|
|
477
|
+
mintDecimals: number;
|
|
478
|
+
}[];
|
|
479
|
+
lastUpdateTimeMs: bigint;
|
|
480
|
+
};
|
|
481
|
+
borrowsPoolRewardManager: {
|
|
482
|
+
$typeName: string;
|
|
483
|
+
id: string;
|
|
484
|
+
totalShares: bigint;
|
|
485
|
+
poolRewards: {
|
|
486
|
+
$typeName: string;
|
|
487
|
+
id: string;
|
|
488
|
+
poolRewardManagerId: string;
|
|
489
|
+
coinType: string;
|
|
490
|
+
startTimeMs: number;
|
|
491
|
+
endTimeMs: number;
|
|
492
|
+
totalRewards: BigNumber;
|
|
493
|
+
allocatedRewards: BigNumber;
|
|
494
|
+
cumulativeRewardsPerShare: BigNumber;
|
|
495
|
+
numUserRewardManagers: bigint;
|
|
496
|
+
rewardIndex: number;
|
|
497
|
+
symbol: string;
|
|
498
|
+
mintDecimals: number;
|
|
499
|
+
}[];
|
|
500
|
+
lastUpdateTimeMs: bigint;
|
|
501
|
+
};
|
|
502
|
+
availableAmountUsd: BigNumber;
|
|
503
|
+
borrowedAmountUsd: BigNumber;
|
|
504
|
+
depositedAmount: BigNumber;
|
|
505
|
+
depositedAmountUsd: BigNumber;
|
|
506
|
+
cTokenExchangeRate: BigNumber;
|
|
507
|
+
borrowAprPercent: BigNumber;
|
|
508
|
+
depositAprPercent: BigNumber;
|
|
509
|
+
utilizationPercent: BigNumber;
|
|
510
|
+
token: {
|
|
511
|
+
decimals: number;
|
|
512
|
+
description: string;
|
|
513
|
+
iconUrl?: string | null;
|
|
514
|
+
id?: string | null;
|
|
515
|
+
name: string;
|
|
516
|
+
symbol: string;
|
|
517
|
+
coinType: string;
|
|
518
|
+
};
|
|
519
|
+
symbol: string;
|
|
520
|
+
name: string;
|
|
521
|
+
iconUrl: string | null | undefined;
|
|
522
|
+
description: string;
|
|
523
|
+
totalDeposits: BigNumber;
|
|
524
|
+
};
|
|
525
|
+
original: _suilend_sdk__generated_suilend_obligation_structs.Obligation<string>;
|
|
526
|
+
}[];
|
|
527
|
+
weightedConservativeBorrowUtilizationPercent: BigNumber;
|
|
528
|
+
original: _suilend_sdk__generated_suilend_obligation_structs.Obligation<string>;
|
|
529
|
+
totalSupplyUsd: BigNumber;
|
|
530
|
+
totalBorrowUsd: BigNumber;
|
|
531
|
+
totalWeightedBorrowUsd: BigNumber;
|
|
532
|
+
maxPriceTotalWeightedBorrowUsd: BigNumber;
|
|
533
|
+
borrowLimit: BigNumber;
|
|
534
|
+
minPriceBorrowLimit: BigNumber;
|
|
535
|
+
}>;
|
|
536
|
+
/**
|
|
537
|
+
* 获取CLMM池子信息
|
|
538
|
+
*/
|
|
539
|
+
getClmmPoolInfo: (clmmPool: string) => Promise<{
|
|
540
|
+
clmmFeeTier: number;
|
|
541
|
+
clmmPoolCoinTypeA: string;
|
|
542
|
+
clmmPoolCoinTypeB: string;
|
|
543
|
+
}>;
|
|
544
|
+
/**
|
|
545
|
+
* 开杠杆仓位
|
|
546
|
+
*/
|
|
547
|
+
openLeveragePosition: (params: OpenPositionParams) => Promise<Transaction$1>;
|
|
548
|
+
/**
|
|
549
|
+
* 杠杆仓位加仓
|
|
550
|
+
*/
|
|
551
|
+
positionManageSizeDeposit: (params: PositionManageSizeDepositParams) => Promise<Transaction$1>;
|
|
552
|
+
/**
|
|
553
|
+
* 杠杆仓位减仓
|
|
554
|
+
*/
|
|
555
|
+
positionManageSizeWithdraw: (params: PositionManageSizeWithdrawParams) => Promise<Transaction$1>;
|
|
556
|
+
/**}
|
|
557
|
+
* 仓位升杠杆
|
|
558
|
+
*/
|
|
559
|
+
positionManageLeverageIncrease: (params: PositionManageLeverageParams) => Promise<Transaction$1>;
|
|
560
|
+
positionManageLeverageDecrease: (params: PositionManageLeverageParams) => Promise<Transaction$1>;
|
|
561
|
+
/**
|
|
562
|
+
* 杠杆仓位平仓
|
|
563
|
+
*/
|
|
564
|
+
leveragePositionClose: (params: PositionCloseParams, txb?: Transaction$1) => Promise<Transaction$1>;
|
|
565
|
+
/**
|
|
566
|
+
* 计算闪电贷参数
|
|
567
|
+
*/
|
|
568
|
+
private calculateFlashLoanParams;
|
|
569
|
+
/**
|
|
570
|
+
* 执行闪电贷
|
|
571
|
+
*/
|
|
572
|
+
flashLoan: (params: FlashLoanParams) => {
|
|
130
573
|
balanceA: {
|
|
131
574
|
$kind: "NestedResult";
|
|
132
575
|
NestedResult: [number, number];
|
|
@@ -140,14 +583,74 @@ declare class LeverageModules {
|
|
|
140
583
|
NestedResult: [number, number];
|
|
141
584
|
};
|
|
142
585
|
};
|
|
143
|
-
|
|
586
|
+
/**
|
|
587
|
+
* 偿还闪电贷
|
|
588
|
+
*/
|
|
589
|
+
repayFlashLoan: (params: RepayFlashSwapParams) => Transaction$1;
|
|
590
|
+
/**
|
|
591
|
+
* 创建杠杆仓位
|
|
592
|
+
*/
|
|
593
|
+
private createLeveragePosition;
|
|
594
|
+
/**
|
|
595
|
+
* 抵押资产到杠杆仓位
|
|
596
|
+
*/
|
|
597
|
+
private depositToLeveragePosition;
|
|
598
|
+
/**
|
|
599
|
+
* 借出资产(SUI和非SUI统一处理)
|
|
600
|
+
*/
|
|
601
|
+
borrowAsset: (params: BorrowAssetParams, tx: Transaction$1) => _mysten_sui_dist_cjs_transactions.TransactionResult;
|
|
602
|
+
/**
|
|
603
|
+
* 提取资产(SUI和非SUI统一处理)
|
|
604
|
+
*/
|
|
605
|
+
withdrawAsset: (params: WithdrawAssetParams, tx: Transaction$1) => _mysten_sui_dist_cjs_transactions.TransactionResult;
|
|
606
|
+
/**
|
|
607
|
+
* 还款
|
|
608
|
+
*/
|
|
609
|
+
repay: (params: RepayParams) => void;
|
|
610
|
+
/**
|
|
611
|
+
* 查找路由
|
|
612
|
+
*/
|
|
144
613
|
findRouters(coin_type_a: string, coin_type_b: string, amount: Decimal, by_amount_in: boolean, pools: string[]): Promise<{
|
|
145
614
|
is_exceed: boolean;
|
|
615
|
+
quoteID?: string;
|
|
616
|
+
amountIn: BN;
|
|
617
|
+
amountOut: BN;
|
|
618
|
+
byAmountIn: boolean;
|
|
619
|
+
paths: _cetusprotocol_aggregator_sdk.Path[];
|
|
620
|
+
insufficientLiquidity: boolean;
|
|
621
|
+
deviationRatio?: number;
|
|
622
|
+
packages?: Map<string, string>;
|
|
623
|
+
totalDeepFee?: number;
|
|
624
|
+
error?: _cetusprotocol_aggregator_sdk.RouterError;
|
|
625
|
+
overlayFee?: number;
|
|
626
|
+
amount_in?: undefined;
|
|
627
|
+
amount_out?: undefined;
|
|
628
|
+
route_obj?: undefined;
|
|
629
|
+
originRes?: undefined;
|
|
630
|
+
} | {
|
|
631
|
+
amount_in: any;
|
|
632
|
+
amount_out: any;
|
|
633
|
+
is_exceed: any;
|
|
634
|
+
route_obj: any;
|
|
635
|
+
byAmountIn: boolean;
|
|
636
|
+
originRes: any;
|
|
637
|
+
} | null>;
|
|
638
|
+
/**
|
|
639
|
+
* 执行路由Swap
|
|
640
|
+
*/
|
|
641
|
+
routerSwap: (params: RouterSwapParams) => Promise<_mysten_sui_dist_cjs_transactions.TransactionObjectArgument | undefined>;
|
|
642
|
+
/**
|
|
643
|
+
* 开仓预计算
|
|
644
|
+
*/
|
|
645
|
+
calculateOpenPosition: (params: CalculateOpenPositionParams) => Promise<{
|
|
646
|
+
is_exceed: boolean;
|
|
647
|
+
quoteID?: string;
|
|
146
648
|
amountIn: BN;
|
|
147
649
|
amountOut: BN;
|
|
148
650
|
byAmountIn: boolean;
|
|
149
|
-
|
|
651
|
+
paths: _cetusprotocol_aggregator_sdk.Path[];
|
|
150
652
|
insufficientLiquidity: boolean;
|
|
653
|
+
deviationRatio?: number;
|
|
151
654
|
packages?: Map<string, string>;
|
|
152
655
|
totalDeepFee?: number;
|
|
153
656
|
error?: _cetusprotocol_aggregator_sdk.RouterError;
|
|
@@ -167,8 +670,9 @@ declare class LeverageModules {
|
|
|
167
670
|
}
|
|
168
671
|
|
|
169
672
|
interface SdkOptions extends BaseSdkOptions {
|
|
673
|
+
full_rpc_url: string;
|
|
170
674
|
leverage: Package<LeverageConfig>;
|
|
171
|
-
suilend: SuiLendConfig
|
|
675
|
+
suilend: Package<SuiLendConfig>;
|
|
172
676
|
aggregator_url: string;
|
|
173
677
|
providers: string[];
|
|
174
678
|
pyth_urls?: string[];
|
|
@@ -179,12 +683,14 @@ declare class CetusLeverageSDK extends SdkWrapper<SdkOptions> {
|
|
|
179
683
|
protected _leverageModules: LeverageModules;
|
|
180
684
|
protected _aggregatorClient: AggregatorClient;
|
|
181
685
|
protected _clmmSDK: CetusClmmSDK;
|
|
686
|
+
protected _pythConnection: SuiPriceServiceConnection;
|
|
182
687
|
senderAddress: string | undefined;
|
|
183
688
|
constructor(options: SdkOptions, clmmSDK?: CetusClmmSDK);
|
|
184
689
|
get SuiLendModule(): SuiLendModule;
|
|
185
690
|
get LeverageModules(): LeverageModules;
|
|
186
691
|
get AggregatorClient(): AggregatorClient;
|
|
187
692
|
get ClmmSDK(): CetusClmmSDK;
|
|
693
|
+
get PythConnection(): SuiPriceServiceConnection;
|
|
188
694
|
static createSDK(options: BaseSdkOptions): CetusLeverageSDK;
|
|
189
695
|
static createCustomSDK<T extends BaseSdkOptions>(options: T & SdkOptions): CetusLeverageSDK;
|
|
190
696
|
}
|