lll-sdk 0.0.0-experimental-20250820102523
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 +194 -0
- package/dist/index.d.ts +194 -0
- package/dist/index.js +162 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +162 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
File without changes
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { SdkWrapper, BaseSdkOptions, Package } from '@cetusprotocol/common-sdk';
|
|
2
|
+
import * as _mysten_sui_dist_cjs_transactions from '@mysten/sui/dist/cjs/transactions';
|
|
3
|
+
import { Transaction } from '@mysten/sui/dist/cjs/transactions';
|
|
4
|
+
import { SuilendClient, ParsedLendingMarket, ParsedReserve } from '@suilend/sdk';
|
|
5
|
+
import { CoinMetadata } from '@mysten/sui/client';
|
|
6
|
+
import { Reserve } from '@suilend/sdk/_generated/suilend/reserve/structs';
|
|
7
|
+
import BN from 'bn.js';
|
|
8
|
+
import Decimal from 'decimal.js';
|
|
9
|
+
import BigNumber$1 from 'bignumber.js';
|
|
10
|
+
import * as _cetusprotocol_aggregator_sdk from '@cetusprotocol/aggregator-sdk';
|
|
11
|
+
import { AggregatorClient } from '@cetusprotocol/aggregator-sdk';
|
|
12
|
+
import { CetusClmmSDK } from '@cetusprotocol/sui-clmm-sdk';
|
|
13
|
+
|
|
14
|
+
interface LeverageConfig {
|
|
15
|
+
global_config_id: string;
|
|
16
|
+
markets_table_id: string;
|
|
17
|
+
}
|
|
18
|
+
type LendingMarket = {
|
|
19
|
+
name: string;
|
|
20
|
+
slug: string;
|
|
21
|
+
id: string;
|
|
22
|
+
type: string;
|
|
23
|
+
ownerCapId: string;
|
|
24
|
+
isHidden?: boolean;
|
|
25
|
+
};
|
|
26
|
+
interface SuiLendConfig {
|
|
27
|
+
lendingMarket: LendingMarket[];
|
|
28
|
+
lendingMarketId: string;
|
|
29
|
+
lendingMarketType: string;
|
|
30
|
+
apiUrl: string;
|
|
31
|
+
}
|
|
32
|
+
interface AppData {
|
|
33
|
+
suilendClient: SuilendClient;
|
|
34
|
+
lendingMarket: ParsedLendingMarket;
|
|
35
|
+
coinMetadataMap: Record<string, CoinMetadata>;
|
|
36
|
+
refreshedRawReserves: Reserve<string>[];
|
|
37
|
+
reserveMap: Record<string, ParsedReserve>;
|
|
38
|
+
reserveCoinTypes: string[];
|
|
39
|
+
reserveCoinMetadataMap: Record<string, CoinMetadata>;
|
|
40
|
+
rewardPriceMap: Record<string, BN | undefined>;
|
|
41
|
+
rewardCoinTypes: string[];
|
|
42
|
+
activeRewardCoinTypes: string[];
|
|
43
|
+
rewardCoinMetadataMap: Record<string, CoinMetadata>;
|
|
44
|
+
}
|
|
45
|
+
interface AllAppData {
|
|
46
|
+
allLendingMarketData: Record<string, AppData>;
|
|
47
|
+
lstAprPercentMap: Record<string, BigNumber>;
|
|
48
|
+
}
|
|
49
|
+
interface OpenShortParams {
|
|
50
|
+
isQuote: boolean;
|
|
51
|
+
marketId: string;
|
|
52
|
+
amount: Decimal;
|
|
53
|
+
clmmPool: string;
|
|
54
|
+
slippage: number;
|
|
55
|
+
}
|
|
56
|
+
interface FlashSwapParams {
|
|
57
|
+
amount: Decimal;
|
|
58
|
+
clmmPool: string;
|
|
59
|
+
baseCoinType: string;
|
|
60
|
+
quoteCoinType: string;
|
|
61
|
+
tx: Transaction;
|
|
62
|
+
}
|
|
63
|
+
interface RepayFlashSwapParams {
|
|
64
|
+
clmmPool: string;
|
|
65
|
+
coinA: string;
|
|
66
|
+
coinB: string;
|
|
67
|
+
tx: Transaction;
|
|
68
|
+
baseCoinType: string;
|
|
69
|
+
quoteCoinType: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare class SuiLendModule {
|
|
73
|
+
private sdk;
|
|
74
|
+
lendingMarketCache?: AllAppData;
|
|
75
|
+
obligationsCache?: Record<string, any>;
|
|
76
|
+
private suilendClientCache?;
|
|
77
|
+
constructor(sdk: CetusLeverageSDK);
|
|
78
|
+
/**
|
|
79
|
+
* 获取或初始化 SuilendClient
|
|
80
|
+
* @param lendingMarketId 借贷市场ID
|
|
81
|
+
* @param lendingMarketType 借贷市场类型
|
|
82
|
+
*/
|
|
83
|
+
private getSuilendClient;
|
|
84
|
+
/**
|
|
85
|
+
* 获取借贷市场数据(缓存)
|
|
86
|
+
* @param forceRefresh 是否强制刷新
|
|
87
|
+
*/
|
|
88
|
+
getLendingMarketData(forceRefresh?: boolean): Promise<AllAppData>;
|
|
89
|
+
/**
|
|
90
|
+
* 获取 obligations 数据(缓存)
|
|
91
|
+
* @param allAppData 借贷市场数据(可选)
|
|
92
|
+
* @param forceRefresh 是否强制刷新
|
|
93
|
+
*/
|
|
94
|
+
getInitializeObligations(allAppData?: AllAppData, forceRefresh?: boolean): Promise<any>;
|
|
95
|
+
getSuiLendCoinInfo: (coinType: string, changeAmount: BigNumber$1) => {
|
|
96
|
+
borrowLimit: any;
|
|
97
|
+
borrowedAmount: any;
|
|
98
|
+
remainingBorrowLimit: string;
|
|
99
|
+
depositAprPercent: any;
|
|
100
|
+
totalAprPercent: string;
|
|
101
|
+
borrowInterest: any;
|
|
102
|
+
stakingYieldAprPercent: string | undefined;
|
|
103
|
+
rewardAprPercent: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* 获取用户借贷数据
|
|
107
|
+
* @param obligationId 借贷头寸ID(可选)
|
|
108
|
+
* @param forceRefresh 是否强制刷新
|
|
109
|
+
*/
|
|
110
|
+
getSuiLendUserData(obligationId: string, forceRefresh?: boolean): Promise<{
|
|
111
|
+
obligation: any;
|
|
112
|
+
netAprPercent: BigNumber$1;
|
|
113
|
+
deposits: any;
|
|
114
|
+
borrowedAmount: any;
|
|
115
|
+
depositedAmount: any;
|
|
116
|
+
netValueUsd: any;
|
|
117
|
+
rewardMap: any;
|
|
118
|
+
} | undefined>;
|
|
119
|
+
createObligation: (transaction: Transaction) => Promise<_mysten_sui_dist_cjs_transactions.TransactionResult>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare class LeverageModules {
|
|
123
|
+
protected _sdk: CetusLeverageSDK;
|
|
124
|
+
constructor(sdk: CetusLeverageSDK);
|
|
125
|
+
getLeverageConfig: () => Promise<any>;
|
|
126
|
+
getLeverageMarketsList: (force_refresh?: boolean) => Promise<any>;
|
|
127
|
+
getLeverageMarketInfo: (marketId: string) => Promise<any>;
|
|
128
|
+
openShort: (params: OpenShortParams) => Promise<void>;
|
|
129
|
+
flashSwap: (params: FlashSwapParams) => {
|
|
130
|
+
balanceA: {
|
|
131
|
+
$kind: "NestedResult";
|
|
132
|
+
NestedResult: [number, number];
|
|
133
|
+
};
|
|
134
|
+
balanceB: {
|
|
135
|
+
$kind: "NestedResult";
|
|
136
|
+
NestedResult: [number, number];
|
|
137
|
+
};
|
|
138
|
+
receipt: {
|
|
139
|
+
$kind: "NestedResult";
|
|
140
|
+
NestedResult: [number, number];
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
repayFlashSwap: (params: RepayFlashSwapParams) => void;
|
|
144
|
+
findRouters(coin_type_a: string, coin_type_b: string, amount: Decimal, by_amount_in: boolean, pools: string[]): Promise<{
|
|
145
|
+
is_exceed: boolean;
|
|
146
|
+
amountIn: BN;
|
|
147
|
+
amountOut: BN;
|
|
148
|
+
byAmountIn: boolean;
|
|
149
|
+
routes: _cetusprotocol_aggregator_sdk.Router[];
|
|
150
|
+
insufficientLiquidity: boolean;
|
|
151
|
+
packages?: Map<string, string>;
|
|
152
|
+
totalDeepFee?: number;
|
|
153
|
+
error?: _cetusprotocol_aggregator_sdk.RouterError;
|
|
154
|
+
overlayFee?: number;
|
|
155
|
+
amount_in?: undefined;
|
|
156
|
+
amount_out?: undefined;
|
|
157
|
+
route_obj?: undefined;
|
|
158
|
+
originRes?: undefined;
|
|
159
|
+
} | {
|
|
160
|
+
amount_in: any;
|
|
161
|
+
amount_out: any;
|
|
162
|
+
is_exceed: any;
|
|
163
|
+
route_obj: any;
|
|
164
|
+
byAmountIn: boolean;
|
|
165
|
+
originRes: any;
|
|
166
|
+
} | null>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
interface SdkOptions extends BaseSdkOptions {
|
|
170
|
+
leverage: Package<LeverageConfig>;
|
|
171
|
+
suilend: SuiLendConfig;
|
|
172
|
+
aggregator_url: string;
|
|
173
|
+
providers: string[];
|
|
174
|
+
pyth_urls?: string[];
|
|
175
|
+
env: 'mainnet' | 'testnet';
|
|
176
|
+
}
|
|
177
|
+
declare class CetusLeverageSDK extends SdkWrapper<SdkOptions> {
|
|
178
|
+
protected _suilendModule: SuiLendModule;
|
|
179
|
+
protected _leverageModules: LeverageModules;
|
|
180
|
+
protected _aggregatorClient: AggregatorClient;
|
|
181
|
+
protected _clmmSDK: CetusClmmSDK;
|
|
182
|
+
senderAddress: string | undefined;
|
|
183
|
+
constructor(options: SdkOptions, clmmSDK?: CetusClmmSDK);
|
|
184
|
+
get SuiLendModule(): SuiLendModule;
|
|
185
|
+
get LeverageModules(): LeverageModules;
|
|
186
|
+
get AggregatorClient(): AggregatorClient;
|
|
187
|
+
get ClmmSDK(): CetusClmmSDK;
|
|
188
|
+
static createSDK(options: BaseSdkOptions): CetusLeverageSDK;
|
|
189
|
+
static createCustomSDK<T extends BaseSdkOptions>(options: T & SdkOptions): CetusLeverageSDK;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare const leverage_mainnet: SdkOptions;
|
|
193
|
+
|
|
194
|
+
export { CetusLeverageSDK, type SdkOptions, CetusLeverageSDK as default, leverage_mainnet };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { SdkWrapper, BaseSdkOptions, Package } from '@cetusprotocol/common-sdk';
|
|
2
|
+
import * as _mysten_sui_dist_cjs_transactions from '@mysten/sui/dist/cjs/transactions';
|
|
3
|
+
import { Transaction } from '@mysten/sui/dist/cjs/transactions';
|
|
4
|
+
import { SuilendClient, ParsedLendingMarket, ParsedReserve } from '@suilend/sdk';
|
|
5
|
+
import { CoinMetadata } from '@mysten/sui/client';
|
|
6
|
+
import { Reserve } from '@suilend/sdk/_generated/suilend/reserve/structs';
|
|
7
|
+
import BN from 'bn.js';
|
|
8
|
+
import Decimal from 'decimal.js';
|
|
9
|
+
import BigNumber$1 from 'bignumber.js';
|
|
10
|
+
import * as _cetusprotocol_aggregator_sdk from '@cetusprotocol/aggregator-sdk';
|
|
11
|
+
import { AggregatorClient } from '@cetusprotocol/aggregator-sdk';
|
|
12
|
+
import { CetusClmmSDK } from '@cetusprotocol/sui-clmm-sdk';
|
|
13
|
+
|
|
14
|
+
interface LeverageConfig {
|
|
15
|
+
global_config_id: string;
|
|
16
|
+
markets_table_id: string;
|
|
17
|
+
}
|
|
18
|
+
type LendingMarket = {
|
|
19
|
+
name: string;
|
|
20
|
+
slug: string;
|
|
21
|
+
id: string;
|
|
22
|
+
type: string;
|
|
23
|
+
ownerCapId: string;
|
|
24
|
+
isHidden?: boolean;
|
|
25
|
+
};
|
|
26
|
+
interface SuiLendConfig {
|
|
27
|
+
lendingMarket: LendingMarket[];
|
|
28
|
+
lendingMarketId: string;
|
|
29
|
+
lendingMarketType: string;
|
|
30
|
+
apiUrl: string;
|
|
31
|
+
}
|
|
32
|
+
interface AppData {
|
|
33
|
+
suilendClient: SuilendClient;
|
|
34
|
+
lendingMarket: ParsedLendingMarket;
|
|
35
|
+
coinMetadataMap: Record<string, CoinMetadata>;
|
|
36
|
+
refreshedRawReserves: Reserve<string>[];
|
|
37
|
+
reserveMap: Record<string, ParsedReserve>;
|
|
38
|
+
reserveCoinTypes: string[];
|
|
39
|
+
reserveCoinMetadataMap: Record<string, CoinMetadata>;
|
|
40
|
+
rewardPriceMap: Record<string, BN | undefined>;
|
|
41
|
+
rewardCoinTypes: string[];
|
|
42
|
+
activeRewardCoinTypes: string[];
|
|
43
|
+
rewardCoinMetadataMap: Record<string, CoinMetadata>;
|
|
44
|
+
}
|
|
45
|
+
interface AllAppData {
|
|
46
|
+
allLendingMarketData: Record<string, AppData>;
|
|
47
|
+
lstAprPercentMap: Record<string, BigNumber>;
|
|
48
|
+
}
|
|
49
|
+
interface OpenShortParams {
|
|
50
|
+
isQuote: boolean;
|
|
51
|
+
marketId: string;
|
|
52
|
+
amount: Decimal;
|
|
53
|
+
clmmPool: string;
|
|
54
|
+
slippage: number;
|
|
55
|
+
}
|
|
56
|
+
interface FlashSwapParams {
|
|
57
|
+
amount: Decimal;
|
|
58
|
+
clmmPool: string;
|
|
59
|
+
baseCoinType: string;
|
|
60
|
+
quoteCoinType: string;
|
|
61
|
+
tx: Transaction;
|
|
62
|
+
}
|
|
63
|
+
interface RepayFlashSwapParams {
|
|
64
|
+
clmmPool: string;
|
|
65
|
+
coinA: string;
|
|
66
|
+
coinB: string;
|
|
67
|
+
tx: Transaction;
|
|
68
|
+
baseCoinType: string;
|
|
69
|
+
quoteCoinType: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare class SuiLendModule {
|
|
73
|
+
private sdk;
|
|
74
|
+
lendingMarketCache?: AllAppData;
|
|
75
|
+
obligationsCache?: Record<string, any>;
|
|
76
|
+
private suilendClientCache?;
|
|
77
|
+
constructor(sdk: CetusLeverageSDK);
|
|
78
|
+
/**
|
|
79
|
+
* 获取或初始化 SuilendClient
|
|
80
|
+
* @param lendingMarketId 借贷市场ID
|
|
81
|
+
* @param lendingMarketType 借贷市场类型
|
|
82
|
+
*/
|
|
83
|
+
private getSuilendClient;
|
|
84
|
+
/**
|
|
85
|
+
* 获取借贷市场数据(缓存)
|
|
86
|
+
* @param forceRefresh 是否强制刷新
|
|
87
|
+
*/
|
|
88
|
+
getLendingMarketData(forceRefresh?: boolean): Promise<AllAppData>;
|
|
89
|
+
/**
|
|
90
|
+
* 获取 obligations 数据(缓存)
|
|
91
|
+
* @param allAppData 借贷市场数据(可选)
|
|
92
|
+
* @param forceRefresh 是否强制刷新
|
|
93
|
+
*/
|
|
94
|
+
getInitializeObligations(allAppData?: AllAppData, forceRefresh?: boolean): Promise<any>;
|
|
95
|
+
getSuiLendCoinInfo: (coinType: string, changeAmount: BigNumber$1) => {
|
|
96
|
+
borrowLimit: any;
|
|
97
|
+
borrowedAmount: any;
|
|
98
|
+
remainingBorrowLimit: string;
|
|
99
|
+
depositAprPercent: any;
|
|
100
|
+
totalAprPercent: string;
|
|
101
|
+
borrowInterest: any;
|
|
102
|
+
stakingYieldAprPercent: string | undefined;
|
|
103
|
+
rewardAprPercent: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* 获取用户借贷数据
|
|
107
|
+
* @param obligationId 借贷头寸ID(可选)
|
|
108
|
+
* @param forceRefresh 是否强制刷新
|
|
109
|
+
*/
|
|
110
|
+
getSuiLendUserData(obligationId: string, forceRefresh?: boolean): Promise<{
|
|
111
|
+
obligation: any;
|
|
112
|
+
netAprPercent: BigNumber$1;
|
|
113
|
+
deposits: any;
|
|
114
|
+
borrowedAmount: any;
|
|
115
|
+
depositedAmount: any;
|
|
116
|
+
netValueUsd: any;
|
|
117
|
+
rewardMap: any;
|
|
118
|
+
} | undefined>;
|
|
119
|
+
createObligation: (transaction: Transaction) => Promise<_mysten_sui_dist_cjs_transactions.TransactionResult>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare class LeverageModules {
|
|
123
|
+
protected _sdk: CetusLeverageSDK;
|
|
124
|
+
constructor(sdk: CetusLeverageSDK);
|
|
125
|
+
getLeverageConfig: () => Promise<any>;
|
|
126
|
+
getLeverageMarketsList: (force_refresh?: boolean) => Promise<any>;
|
|
127
|
+
getLeverageMarketInfo: (marketId: string) => Promise<any>;
|
|
128
|
+
openShort: (params: OpenShortParams) => Promise<void>;
|
|
129
|
+
flashSwap: (params: FlashSwapParams) => {
|
|
130
|
+
balanceA: {
|
|
131
|
+
$kind: "NestedResult";
|
|
132
|
+
NestedResult: [number, number];
|
|
133
|
+
};
|
|
134
|
+
balanceB: {
|
|
135
|
+
$kind: "NestedResult";
|
|
136
|
+
NestedResult: [number, number];
|
|
137
|
+
};
|
|
138
|
+
receipt: {
|
|
139
|
+
$kind: "NestedResult";
|
|
140
|
+
NestedResult: [number, number];
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
repayFlashSwap: (params: RepayFlashSwapParams) => void;
|
|
144
|
+
findRouters(coin_type_a: string, coin_type_b: string, amount: Decimal, by_amount_in: boolean, pools: string[]): Promise<{
|
|
145
|
+
is_exceed: boolean;
|
|
146
|
+
amountIn: BN;
|
|
147
|
+
amountOut: BN;
|
|
148
|
+
byAmountIn: boolean;
|
|
149
|
+
routes: _cetusprotocol_aggregator_sdk.Router[];
|
|
150
|
+
insufficientLiquidity: boolean;
|
|
151
|
+
packages?: Map<string, string>;
|
|
152
|
+
totalDeepFee?: number;
|
|
153
|
+
error?: _cetusprotocol_aggregator_sdk.RouterError;
|
|
154
|
+
overlayFee?: number;
|
|
155
|
+
amount_in?: undefined;
|
|
156
|
+
amount_out?: undefined;
|
|
157
|
+
route_obj?: undefined;
|
|
158
|
+
originRes?: undefined;
|
|
159
|
+
} | {
|
|
160
|
+
amount_in: any;
|
|
161
|
+
amount_out: any;
|
|
162
|
+
is_exceed: any;
|
|
163
|
+
route_obj: any;
|
|
164
|
+
byAmountIn: boolean;
|
|
165
|
+
originRes: any;
|
|
166
|
+
} | null>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
interface SdkOptions extends BaseSdkOptions {
|
|
170
|
+
leverage: Package<LeverageConfig>;
|
|
171
|
+
suilend: SuiLendConfig;
|
|
172
|
+
aggregator_url: string;
|
|
173
|
+
providers: string[];
|
|
174
|
+
pyth_urls?: string[];
|
|
175
|
+
env: 'mainnet' | 'testnet';
|
|
176
|
+
}
|
|
177
|
+
declare class CetusLeverageSDK extends SdkWrapper<SdkOptions> {
|
|
178
|
+
protected _suilendModule: SuiLendModule;
|
|
179
|
+
protected _leverageModules: LeverageModules;
|
|
180
|
+
protected _aggregatorClient: AggregatorClient;
|
|
181
|
+
protected _clmmSDK: CetusClmmSDK;
|
|
182
|
+
senderAddress: string | undefined;
|
|
183
|
+
constructor(options: SdkOptions, clmmSDK?: CetusClmmSDK);
|
|
184
|
+
get SuiLendModule(): SuiLendModule;
|
|
185
|
+
get LeverageModules(): LeverageModules;
|
|
186
|
+
get AggregatorClient(): AggregatorClient;
|
|
187
|
+
get ClmmSDK(): CetusClmmSDK;
|
|
188
|
+
static createSDK(options: BaseSdkOptions): CetusLeverageSDK;
|
|
189
|
+
static createCustomSDK<T extends BaseSdkOptions>(options: T & SdkOptions): CetusLeverageSDK;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare const leverage_mainnet: SdkOptions;
|
|
193
|
+
|
|
194
|
+
export { CetusLeverageSDK, type SdkOptions, CetusLeverageSDK as default, leverage_mainnet };
|