@suilend/sdk 2.0.2 → 2.0.3
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/api/events.js +2 -1
- package/client.d.ts +1 -0
- package/lib/initialize.js +4 -2
- package/lib/liquidityMining.d.ts +2 -2
- package/lib/liquidityMining.js +7 -5
- package/margin/index.d.ts +6 -0
- package/margin/index.js +6 -0
- package/margin/margin/admin_cap.d.ts +10 -0
- package/margin/margin/admin_cap.js +12 -0
- package/margin/margin/deps/std/type_name.d.ts +17 -0
- package/margin/margin/deps/std/type_name.js +19 -0
- package/margin/margin/deps/sui/vec_set.d.ts +20 -0
- package/margin/margin/deps/sui/vec_set.js +19 -0
- package/margin/margin/deps/suilend/lending_market.d.ts +8 -0
- package/margin/margin/deps/suilend/lending_market.js +10 -0
- package/margin/margin/market.d.ts +248 -0
- package/margin/margin/market.js +220 -0
- package/margin/margin/permissions.d.ts +56 -0
- package/margin/margin/permissions.js +77 -0
- package/margin/margin/position.d.ts +153 -0
- package/margin/margin/position.js +149 -0
- package/margin/margin/router.d.ts +204 -0
- package/margin/margin/router.js +176 -0
- package/margin/margin/version.d.ts +5 -0
- package/margin/margin/version.js +7 -0
- package/margin/utils/index.d.ts +30 -0
- package/margin/utils/index.js +171 -0
- package/package.json +1 -1
- package/strategies.js +1 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct, type RawTransactionArgument } from '../utils/index.js';
|
|
5
|
+
import { type Transaction } from '@mysten/sui/transactions';
|
|
6
|
+
export declare const FeeCollectedEvent: MoveStruct<{
|
|
7
|
+
market_id: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
8
|
+
is_open: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
9
|
+
fee_amount: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
10
|
+
fee_coin_type: MoveStruct<{
|
|
11
|
+
name: import("@mysten/bcs").BcsType<string, string, "string">;
|
|
12
|
+
}, "std::type_name::TypeName">;
|
|
13
|
+
recipient: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
14
|
+
}, "0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53::router::FeeCollectedEvent">;
|
|
15
|
+
export interface OpenPositionArguments {
|
|
16
|
+
market: RawTransactionArgument<string>;
|
|
17
|
+
lendingMarket: RawTransactionArgument<string>;
|
|
18
|
+
isLong: RawTransactionArgument<boolean>;
|
|
19
|
+
}
|
|
20
|
+
export interface OpenPositionOptions {
|
|
21
|
+
package?: string;
|
|
22
|
+
arguments: OpenPositionArguments | [
|
|
23
|
+
market: RawTransactionArgument<string>,
|
|
24
|
+
lendingMarket: RawTransactionArgument<string>,
|
|
25
|
+
isLong: RawTransactionArgument<boolean>
|
|
26
|
+
];
|
|
27
|
+
typeArguments: [
|
|
28
|
+
string,
|
|
29
|
+
string,
|
|
30
|
+
string
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
export declare function openPosition(options: OpenPositionOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
34
|
+
export interface ClosePositionArguments {
|
|
35
|
+
lendingMarket: RawTransactionArgument<string>;
|
|
36
|
+
market: RawTransactionArgument<string>;
|
|
37
|
+
positionCap: RawTransactionArgument<string>;
|
|
38
|
+
position: RawTransactionArgument<string>;
|
|
39
|
+
}
|
|
40
|
+
export interface ClosePositionOptions {
|
|
41
|
+
package?: string;
|
|
42
|
+
arguments: ClosePositionArguments | [
|
|
43
|
+
lendingMarket: RawTransactionArgument<string>,
|
|
44
|
+
market: RawTransactionArgument<string>,
|
|
45
|
+
positionCap: RawTransactionArgument<string>,
|
|
46
|
+
position: RawTransactionArgument<string>
|
|
47
|
+
];
|
|
48
|
+
typeArguments: [
|
|
49
|
+
string,
|
|
50
|
+
string,
|
|
51
|
+
string
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
/** Close position */
|
|
55
|
+
export declare function closePosition(options: ClosePositionOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
56
|
+
export interface BorrowArguments {
|
|
57
|
+
lendingMarket: RawTransactionArgument<string>;
|
|
58
|
+
market: RawTransactionArgument<string>;
|
|
59
|
+
positionCap: RawTransactionArgument<string>;
|
|
60
|
+
position: RawTransactionArgument<string>;
|
|
61
|
+
amount: RawTransactionArgument<number | bigint>;
|
|
62
|
+
}
|
|
63
|
+
export interface BorrowOptions {
|
|
64
|
+
package?: string;
|
|
65
|
+
arguments: BorrowArguments | [
|
|
66
|
+
lendingMarket: RawTransactionArgument<string>,
|
|
67
|
+
market: RawTransactionArgument<string>,
|
|
68
|
+
positionCap: RawTransactionArgument<string>,
|
|
69
|
+
position: RawTransactionArgument<string>,
|
|
70
|
+
amount: RawTransactionArgument<number | bigint>
|
|
71
|
+
];
|
|
72
|
+
typeArguments: [
|
|
73
|
+
string,
|
|
74
|
+
string,
|
|
75
|
+
string,
|
|
76
|
+
string
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
export declare function borrow(options: BorrowOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
80
|
+
export interface RepayArguments {
|
|
81
|
+
lendingMarket: RawTransactionArgument<string>;
|
|
82
|
+
market: RawTransactionArgument<string>;
|
|
83
|
+
positionCap: RawTransactionArgument<string>;
|
|
84
|
+
position: RawTransactionArgument<string>;
|
|
85
|
+
repayCoin: RawTransactionArgument<string>;
|
|
86
|
+
}
|
|
87
|
+
export interface RepayOptions {
|
|
88
|
+
package?: string;
|
|
89
|
+
arguments: RepayArguments | [
|
|
90
|
+
lendingMarket: RawTransactionArgument<string>,
|
|
91
|
+
market: RawTransactionArgument<string>,
|
|
92
|
+
positionCap: RawTransactionArgument<string>,
|
|
93
|
+
position: RawTransactionArgument<string>,
|
|
94
|
+
repayCoin: RawTransactionArgument<string>
|
|
95
|
+
];
|
|
96
|
+
typeArguments: [
|
|
97
|
+
string,
|
|
98
|
+
string,
|
|
99
|
+
string,
|
|
100
|
+
string
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
export declare function repay(options: RepayOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
104
|
+
export interface WithdrawArguments {
|
|
105
|
+
lendingMarket: RawTransactionArgument<string>;
|
|
106
|
+
market: RawTransactionArgument<string>;
|
|
107
|
+
positionCap: RawTransactionArgument<string>;
|
|
108
|
+
position: RawTransactionArgument<string>;
|
|
109
|
+
rateLimiterExemption: RawTransactionArgument<string | null>;
|
|
110
|
+
amount: RawTransactionArgument<number | bigint>;
|
|
111
|
+
}
|
|
112
|
+
export interface WithdrawOptions {
|
|
113
|
+
package?: string;
|
|
114
|
+
arguments: WithdrawArguments | [
|
|
115
|
+
lendingMarket: RawTransactionArgument<string>,
|
|
116
|
+
market: RawTransactionArgument<string>,
|
|
117
|
+
positionCap: RawTransactionArgument<string>,
|
|
118
|
+
position: RawTransactionArgument<string>,
|
|
119
|
+
rateLimiterExemption: RawTransactionArgument<string | null>,
|
|
120
|
+
amount: RawTransactionArgument<number | bigint>
|
|
121
|
+
];
|
|
122
|
+
typeArguments: [
|
|
123
|
+
string,
|
|
124
|
+
string,
|
|
125
|
+
string,
|
|
126
|
+
string
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
export declare function withdraw(options: WithdrawOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
130
|
+
export interface DepositArguments {
|
|
131
|
+
lendingMarket: RawTransactionArgument<string>;
|
|
132
|
+
market: RawTransactionArgument<string>;
|
|
133
|
+
positionCap: RawTransactionArgument<string>;
|
|
134
|
+
position: RawTransactionArgument<string>;
|
|
135
|
+
depositCoin: RawTransactionArgument<string>;
|
|
136
|
+
}
|
|
137
|
+
export interface DepositOptions {
|
|
138
|
+
package?: string;
|
|
139
|
+
arguments: DepositArguments | [
|
|
140
|
+
lendingMarket: RawTransactionArgument<string>,
|
|
141
|
+
market: RawTransactionArgument<string>,
|
|
142
|
+
positionCap: RawTransactionArgument<string>,
|
|
143
|
+
position: RawTransactionArgument<string>,
|
|
144
|
+
depositCoin: RawTransactionArgument<string>
|
|
145
|
+
];
|
|
146
|
+
typeArguments: [
|
|
147
|
+
string,
|
|
148
|
+
string,
|
|
149
|
+
string,
|
|
150
|
+
string
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
export declare function deposit(options: DepositOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
154
|
+
export interface ClaimRewardsArguments {
|
|
155
|
+
lendingMarket: RawTransactionArgument<string>;
|
|
156
|
+
market: RawTransactionArgument<string>;
|
|
157
|
+
positionCap: RawTransactionArgument<string>;
|
|
158
|
+
position: RawTransactionArgument<string>;
|
|
159
|
+
reserveId: RawTransactionArgument<number | bigint>;
|
|
160
|
+
rewardIndex: RawTransactionArgument<number | bigint>;
|
|
161
|
+
isDepositReward: RawTransactionArgument<boolean>;
|
|
162
|
+
}
|
|
163
|
+
export interface ClaimRewardsOptions {
|
|
164
|
+
package?: string;
|
|
165
|
+
arguments: ClaimRewardsArguments | [
|
|
166
|
+
lendingMarket: RawTransactionArgument<string>,
|
|
167
|
+
market: RawTransactionArgument<string>,
|
|
168
|
+
positionCap: RawTransactionArgument<string>,
|
|
169
|
+
position: RawTransactionArgument<string>,
|
|
170
|
+
reserveId: RawTransactionArgument<number | bigint>,
|
|
171
|
+
rewardIndex: RawTransactionArgument<number | bigint>,
|
|
172
|
+
isDepositReward: RawTransactionArgument<boolean>
|
|
173
|
+
];
|
|
174
|
+
typeArguments: [
|
|
175
|
+
string,
|
|
176
|
+
string,
|
|
177
|
+
string,
|
|
178
|
+
string
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
export declare function claimRewards(options: ClaimRewardsOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
182
|
+
export interface CompoundDebtArguments {
|
|
183
|
+
lendingMarket: RawTransactionArgument<string>;
|
|
184
|
+
market: RawTransactionArgument<string>;
|
|
185
|
+
positionCap: RawTransactionArgument<string>;
|
|
186
|
+
position: RawTransactionArgument<string>;
|
|
187
|
+
borrowIndex: RawTransactionArgument<number | bigint>;
|
|
188
|
+
}
|
|
189
|
+
export interface CompoundDebtOptions {
|
|
190
|
+
package?: string;
|
|
191
|
+
arguments: CompoundDebtArguments | [
|
|
192
|
+
lendingMarket: RawTransactionArgument<string>,
|
|
193
|
+
market: RawTransactionArgument<string>,
|
|
194
|
+
positionCap: RawTransactionArgument<string>,
|
|
195
|
+
position: RawTransactionArgument<string>,
|
|
196
|
+
borrowIndex: RawTransactionArgument<number | bigint>
|
|
197
|
+
];
|
|
198
|
+
typeArguments: [
|
|
199
|
+
string,
|
|
200
|
+
string,
|
|
201
|
+
string
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
export declare function compoundDebt(options: CompoundDebtOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct, normalizeMoveArguments } from '../utils/index.js';
|
|
5
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
6
|
+
import * as type_name from './deps/std/type_name.js';
|
|
7
|
+
const $moduleName = '0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53::router';
|
|
8
|
+
export const FeeCollectedEvent = new MoveStruct({ name: `${$moduleName}::FeeCollectedEvent`, fields: {
|
|
9
|
+
market_id: bcs.Address,
|
|
10
|
+
is_open: bcs.bool(),
|
|
11
|
+
fee_amount: bcs.u64(),
|
|
12
|
+
fee_coin_type: type_name.TypeName,
|
|
13
|
+
recipient: bcs.Address
|
|
14
|
+
} });
|
|
15
|
+
export function openPosition(options) {
|
|
16
|
+
var _a;
|
|
17
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53';
|
|
18
|
+
const argumentsTypes = [
|
|
19
|
+
null,
|
|
20
|
+
null,
|
|
21
|
+
'bool',
|
|
22
|
+
'0x2::clock::Clock'
|
|
23
|
+
];
|
|
24
|
+
const parameterNames = ["market", "lendingMarket", "isLong"];
|
|
25
|
+
return (tx) => tx.moveCall({
|
|
26
|
+
package: packageAddress,
|
|
27
|
+
module: 'router',
|
|
28
|
+
function: 'open_position',
|
|
29
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
30
|
+
typeArguments: options.typeArguments
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Close position */
|
|
34
|
+
export function closePosition(options) {
|
|
35
|
+
var _a;
|
|
36
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53';
|
|
37
|
+
const argumentsTypes = [
|
|
38
|
+
null,
|
|
39
|
+
null,
|
|
40
|
+
null,
|
|
41
|
+
null,
|
|
42
|
+
'0x2::clock::Clock'
|
|
43
|
+
];
|
|
44
|
+
const parameterNames = ["lendingMarket", "market", "positionCap", "position"];
|
|
45
|
+
return (tx) => tx.moveCall({
|
|
46
|
+
package: packageAddress,
|
|
47
|
+
module: 'router',
|
|
48
|
+
function: 'close_position',
|
|
49
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
50
|
+
typeArguments: options.typeArguments
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export function borrow(options) {
|
|
54
|
+
var _a;
|
|
55
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53';
|
|
56
|
+
const argumentsTypes = [
|
|
57
|
+
null,
|
|
58
|
+
null,
|
|
59
|
+
null,
|
|
60
|
+
null,
|
|
61
|
+
'u64',
|
|
62
|
+
'0x3::sui_system::SuiSystemState',
|
|
63
|
+
'0x2::clock::Clock'
|
|
64
|
+
];
|
|
65
|
+
const parameterNames = ["lendingMarket", "market", "positionCap", "position", "amount"];
|
|
66
|
+
return (tx) => tx.moveCall({
|
|
67
|
+
package: packageAddress,
|
|
68
|
+
module: 'router',
|
|
69
|
+
function: 'borrow',
|
|
70
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
71
|
+
typeArguments: options.typeArguments
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export function repay(options) {
|
|
75
|
+
var _a;
|
|
76
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53';
|
|
77
|
+
const argumentsTypes = [
|
|
78
|
+
null,
|
|
79
|
+
null,
|
|
80
|
+
null,
|
|
81
|
+
null,
|
|
82
|
+
null,
|
|
83
|
+
'0x2::clock::Clock'
|
|
84
|
+
];
|
|
85
|
+
const parameterNames = ["lendingMarket", "market", "positionCap", "position", "repayCoin"];
|
|
86
|
+
return (tx) => tx.moveCall({
|
|
87
|
+
package: packageAddress,
|
|
88
|
+
module: 'router',
|
|
89
|
+
function: 'repay',
|
|
90
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
91
|
+
typeArguments: options.typeArguments
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export function withdraw(options) {
|
|
95
|
+
var _a;
|
|
96
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53';
|
|
97
|
+
const argumentsTypes = [
|
|
98
|
+
null,
|
|
99
|
+
null,
|
|
100
|
+
null,
|
|
101
|
+
null,
|
|
102
|
+
'0x1::option::Option<null>',
|
|
103
|
+
'u64',
|
|
104
|
+
'0x3::sui_system::SuiSystemState',
|
|
105
|
+
'0x2::clock::Clock'
|
|
106
|
+
];
|
|
107
|
+
const parameterNames = ["lendingMarket", "market", "positionCap", "position", "rateLimiterExemption", "amount"];
|
|
108
|
+
return (tx) => tx.moveCall({
|
|
109
|
+
package: packageAddress,
|
|
110
|
+
module: 'router',
|
|
111
|
+
function: 'withdraw',
|
|
112
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
113
|
+
typeArguments: options.typeArguments
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export function deposit(options) {
|
|
117
|
+
var _a;
|
|
118
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53';
|
|
119
|
+
const argumentsTypes = [
|
|
120
|
+
null,
|
|
121
|
+
null,
|
|
122
|
+
null,
|
|
123
|
+
null,
|
|
124
|
+
null,
|
|
125
|
+
'0x2::clock::Clock'
|
|
126
|
+
];
|
|
127
|
+
const parameterNames = ["lendingMarket", "market", "positionCap", "position", "depositCoin"];
|
|
128
|
+
return (tx) => tx.moveCall({
|
|
129
|
+
package: packageAddress,
|
|
130
|
+
module: 'router',
|
|
131
|
+
function: 'deposit',
|
|
132
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
133
|
+
typeArguments: options.typeArguments
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
export function claimRewards(options) {
|
|
137
|
+
var _a;
|
|
138
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53';
|
|
139
|
+
const argumentsTypes = [
|
|
140
|
+
null,
|
|
141
|
+
null,
|
|
142
|
+
null,
|
|
143
|
+
null,
|
|
144
|
+
'u64',
|
|
145
|
+
'u64',
|
|
146
|
+
'bool',
|
|
147
|
+
'0x2::clock::Clock'
|
|
148
|
+
];
|
|
149
|
+
const parameterNames = ["lendingMarket", "market", "positionCap", "position", "reserveId", "rewardIndex", "isDepositReward"];
|
|
150
|
+
return (tx) => tx.moveCall({
|
|
151
|
+
package: packageAddress,
|
|
152
|
+
module: 'router',
|
|
153
|
+
function: 'claim_rewards',
|
|
154
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
155
|
+
typeArguments: options.typeArguments
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
export function compoundDebt(options) {
|
|
159
|
+
var _a;
|
|
160
|
+
const packageAddress = (_a = options.package) !== null && _a !== void 0 ? _a : '0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53';
|
|
161
|
+
const argumentsTypes = [
|
|
162
|
+
null,
|
|
163
|
+
null,
|
|
164
|
+
null,
|
|
165
|
+
null,
|
|
166
|
+
'u64'
|
|
167
|
+
];
|
|
168
|
+
const parameterNames = ["lendingMarket", "market", "positionCap", "position", "borrowIndex"];
|
|
169
|
+
return (tx) => tx.moveCall({
|
|
170
|
+
package: packageAddress,
|
|
171
|
+
module: 'router',
|
|
172
|
+
function: 'compound_debt',
|
|
173
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
174
|
+
typeArguments: options.typeArguments
|
|
175
|
+
});
|
|
176
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveTuple } from '../utils/index.js';
|
|
5
|
+
export declare const Version: MoveTuple<readonly [import("@mysten/bcs").BcsType<number, number, "u16">], "0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53::version::Version">;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveTuple } from '../utils/index.js';
|
|
5
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
6
|
+
const $moduleName = '0xd5f3054404ec9275b50985851a5b515728f131a3bdd9c9a5f738a9326b738d53::version';
|
|
7
|
+
export const Version = new MoveTuple({ name: `${$moduleName}::Version`, fields: [bcs.u16()] });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BcsType, TypeTag, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';
|
|
2
|
+
import { TransactionArgument } from '@mysten/sui/transactions';
|
|
3
|
+
import { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';
|
|
4
|
+
export type RawTransactionArgument<T> = T | TransactionArgument;
|
|
5
|
+
export interface GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> extends SuiClientTypes.GetObjectOptions<Include> {
|
|
6
|
+
client: ClientWithCoreApi;
|
|
7
|
+
}
|
|
8
|
+
export interface GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> extends SuiClientTypes.GetObjectsOptions<Include> {
|
|
9
|
+
client: ClientWithCoreApi;
|
|
10
|
+
}
|
|
11
|
+
export declare function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null;
|
|
12
|
+
export declare function normalizeMoveArguments(args: unknown[] | object, argTypes: readonly (string | null)[], parameterNames?: string[]): TransactionArgument[];
|
|
13
|
+
export declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
|
|
14
|
+
get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({ objectId, ...options }: GetOptions<Include>): Promise<SuiClientTypes.Object<Include & {
|
|
15
|
+
content: true;
|
|
16
|
+
json: true;
|
|
17
|
+
}> & {
|
|
18
|
+
json: BcsStruct<T>['$inferType'];
|
|
19
|
+
}>;
|
|
20
|
+
getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({ client, ...options }: GetManyOptions<Include>): Promise<Array<SuiClientTypes.Object<Include & {
|
|
21
|
+
content: true;
|
|
22
|
+
json: true;
|
|
23
|
+
}> & {
|
|
24
|
+
json: BcsStruct<T>['$inferType'];
|
|
25
|
+
}>>;
|
|
26
|
+
}
|
|
27
|
+
export declare class MoveEnum<T extends Record<string, BcsType<any> | null>, const Name extends string> extends BcsEnum<T, Name> {
|
|
28
|
+
}
|
|
29
|
+
export declare class MoveTuple<const T extends readonly BcsType<any>[], const Name extends string> extends BcsTuple<T, Name> {
|
|
30
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import { bcs, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple, } from '@mysten/sui/bcs';
|
|
22
|
+
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
23
|
+
import { isArgument } from '@mysten/sui/transactions';
|
|
24
|
+
const MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');
|
|
25
|
+
const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');
|
|
26
|
+
export function getPureBcsSchema(typeTag) {
|
|
27
|
+
const parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;
|
|
28
|
+
if ('u8' in parsedTag) {
|
|
29
|
+
return bcs.U8;
|
|
30
|
+
}
|
|
31
|
+
else if ('u16' in parsedTag) {
|
|
32
|
+
return bcs.U16;
|
|
33
|
+
}
|
|
34
|
+
else if ('u32' in parsedTag) {
|
|
35
|
+
return bcs.U32;
|
|
36
|
+
}
|
|
37
|
+
else if ('u64' in parsedTag) {
|
|
38
|
+
return bcs.U64;
|
|
39
|
+
}
|
|
40
|
+
else if ('u128' in parsedTag) {
|
|
41
|
+
return bcs.U128;
|
|
42
|
+
}
|
|
43
|
+
else if ('u256' in parsedTag) {
|
|
44
|
+
return bcs.U256;
|
|
45
|
+
}
|
|
46
|
+
else if ('address' in parsedTag) {
|
|
47
|
+
return bcs.Address;
|
|
48
|
+
}
|
|
49
|
+
else if ('bool' in parsedTag) {
|
|
50
|
+
return bcs.Bool;
|
|
51
|
+
}
|
|
52
|
+
else if ('vector' in parsedTag) {
|
|
53
|
+
const type = getPureBcsSchema(parsedTag.vector);
|
|
54
|
+
return type ? bcs.vector(type) : null;
|
|
55
|
+
}
|
|
56
|
+
else if ('struct' in parsedTag) {
|
|
57
|
+
const structTag = parsedTag.struct;
|
|
58
|
+
const pkg = normalizeSuiAddress(structTag.address);
|
|
59
|
+
if (pkg === MOVE_STDLIB_ADDRESS) {
|
|
60
|
+
if ((structTag.module === 'ascii' || structTag.module === 'string') &&
|
|
61
|
+
structTag.name === 'String') {
|
|
62
|
+
return bcs.String;
|
|
63
|
+
}
|
|
64
|
+
if (structTag.module === 'option' && structTag.name === 'Option') {
|
|
65
|
+
const type = getPureBcsSchema(structTag.typeParams[0]);
|
|
66
|
+
return type ? bcs.option(type) : null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (pkg === SUI_FRAMEWORK_ADDRESS &&
|
|
70
|
+
structTag.module === 'object' &&
|
|
71
|
+
(structTag.name === 'ID' || structTag.name === 'UID')) {
|
|
72
|
+
return bcs.Address;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
export function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
78
|
+
const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
|
|
79
|
+
if (parameterNames && argLen !== parameterNames.length) {
|
|
80
|
+
throw new Error(`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`);
|
|
81
|
+
}
|
|
82
|
+
const normalizedArgs = [];
|
|
83
|
+
let index = 0;
|
|
84
|
+
for (const [i, argType] of argTypes.entries()) {
|
|
85
|
+
if (argType === '0x2::clock::Clock') {
|
|
86
|
+
normalizedArgs.push((tx) => tx.object.clock());
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (argType === '0x2::random::Random') {
|
|
90
|
+
normalizedArgs.push((tx) => tx.object.random());
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (argType === '0x2::deny_list::DenyList') {
|
|
94
|
+
normalizedArgs.push((tx) => tx.object.denyList());
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (argType === '0x3::sui_system::SuiSystemState') {
|
|
98
|
+
normalizedArgs.push((tx) => tx.object.system());
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
let arg;
|
|
102
|
+
if (Array.isArray(args)) {
|
|
103
|
+
if (index >= args.length) {
|
|
104
|
+
throw new Error(`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`);
|
|
105
|
+
}
|
|
106
|
+
arg = args[index];
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
if (!parameterNames) {
|
|
110
|
+
throw new Error(`Expected arguments to be passed as an array`);
|
|
111
|
+
}
|
|
112
|
+
const name = parameterNames[index];
|
|
113
|
+
arg = args[name];
|
|
114
|
+
if (arg === undefined) {
|
|
115
|
+
throw new Error(`Parameter ${name} is required`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
index += 1;
|
|
119
|
+
if (typeof arg === 'function' || isArgument(arg)) {
|
|
120
|
+
normalizedArgs.push(arg);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const type = argTypes[i];
|
|
124
|
+
const bcsType = type === null ? null : getPureBcsSchema(type);
|
|
125
|
+
if (bcsType) {
|
|
126
|
+
const bytes = bcsType.serialize(arg);
|
|
127
|
+
normalizedArgs.push((tx) => tx.pure(bytes));
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
else if (typeof arg === 'string') {
|
|
131
|
+
normalizedArgs.push((tx) => tx.object(arg));
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
|
|
135
|
+
}
|
|
136
|
+
return normalizedArgs;
|
|
137
|
+
}
|
|
138
|
+
export class MoveStruct extends BcsStruct {
|
|
139
|
+
get(_a) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
var { objectId } = _a, options = __rest(_a, ["objectId"]);
|
|
142
|
+
const [res] = yield this.getMany(Object.assign(Object.assign({}, options), { objectIds: [objectId] }));
|
|
143
|
+
return res;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
getMany(_a) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
var { client } = _a, options = __rest(_a, ["client"]);
|
|
149
|
+
const response = (yield client.core.getObjects(Object.assign(Object.assign({}, options), { include: Object.assign(Object.assign({}, options.include), { content: true }) })));
|
|
150
|
+
return response.objects.map((obj) => {
|
|
151
|
+
if (obj instanceof Error) {
|
|
152
|
+
throw obj;
|
|
153
|
+
}
|
|
154
|
+
return Object.assign(Object.assign({}, obj), { json: this.parse(obj.content) });
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export class MoveEnum extends BcsEnum {
|
|
160
|
+
}
|
|
161
|
+
export class MoveTuple extends BcsTuple {
|
|
162
|
+
}
|
|
163
|
+
function stringify(val) {
|
|
164
|
+
if (typeof val === 'object') {
|
|
165
|
+
return JSON.stringify(val, (val) => val);
|
|
166
|
+
}
|
|
167
|
+
if (typeof val === 'bigint') {
|
|
168
|
+
return val.toString();
|
|
169
|
+
}
|
|
170
|
+
return val;
|
|
171
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"2.0.
|
|
1
|
+
{"name":"@suilend/sdk","version":"2.0.3","private":false,"description":"A TypeScript SDK for interacting with the Suilend program","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./client":"./client.js","./mmt":"./mmt.js","./strategies":"./strategies.js","./parsers/apiReserveAssetDataEvent":"./parsers/apiReserveAssetDataEvent.js","./parsers/obligation":"./parsers/obligation.js","./parsers":"./parsers/index.js","./parsers/lendingMarket":"./parsers/lendingMarket.js","./parsers/rateLimiter":"./parsers/rateLimiter.js","./parsers/reserve":"./parsers/reserve.js","./swap/transaction":"./swap/transaction.js","./swap/quote":"./swap/quote.js","./swap":"./swap/index.js","./utils/simulate":"./utils/simulate.js","./utils/events":"./utils/events.js","./utils/obligation":"./utils/obligation.js","./utils":"./utils/index.js","./lib/constants":"./lib/constants.js","./lib/transactions":"./lib/transactions.js","./lib/types":"./lib/types.js","./lib/initialize":"./lib/initialize.js","./lib":"./lib/index.js","./lib/liquidityMining":"./lib/liquidityMining.js","./lib/strategyOwnerCap":"./lib/strategyOwnerCap.js","./lib/pyth":"./lib/pyth.js","./api/events":"./api/events.js","./api":"./api/index.js","./margin":"./margin/index.js","./margin/utils":"./margin/utils/index.js","./margin/margin/market":"./margin/margin/market.js","./margin/margin/version":"./margin/margin/version.js","./margin/margin/router":"./margin/margin/router.js","./margin/margin/admin_cap":"./margin/margin/admin_cap.js","./margin/margin/permissions":"./margin/margin/permissions.js","./margin/margin/position":"./margin/margin/position.js","./_generated/suilend":"./_generated/suilend/index.js","./_generated/_framework/util":"./_generated/_framework/util.js","./_generated/_framework/reified":"./_generated/_framework/reified.js","./_generated/_framework/vector":"./_generated/_framework/vector.js","./_generated/suilend/obligation/structs":"./_generated/suilend/obligation/structs.js","./_generated/suilend/decimal/structs":"./_generated/suilend/decimal/structs.js","./_generated/suilend/lending-market/functions":"./_generated/suilend/lending-market/functions.js","./_generated/suilend/lending-market/structs":"./_generated/suilend/lending-market/structs.js","./_generated/suilend/reserve-config/functions":"./_generated/suilend/reserve-config/functions.js","./_generated/suilend/reserve-config/structs":"./_generated/suilend/reserve-config/structs.js","./_generated/suilend/liquidity-mining/structs":"./_generated/suilend/liquidity-mining/structs.js","./_generated/suilend/cell/structs":"./_generated/suilend/cell/structs.js","./_generated/suilend/rate-limiter/functions":"./_generated/suilend/rate-limiter/functions.js","./_generated/suilend/rate-limiter/structs":"./_generated/suilend/rate-limiter/structs.js","./_generated/suilend/reserve/structs":"./_generated/suilend/reserve/structs.js","./_generated/suilend/lending-market-registry/functions":"./_generated/suilend/lending-market-registry/functions.js","./margin/margin/deps/sui/vec_set":"./margin/margin/deps/sui/vec_set.js","./margin/margin/deps/std/type_name":"./margin/margin/deps/std/type_name.js","./margin/margin/deps/suilend/lending_market":"./margin/margin/deps/suilend/lending_market.js","./_generated/_dependencies/source/0x2":"./_generated/_dependencies/source/0x2/index.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js","./_generated/_dependencies/source/0x1":"./_generated/_dependencies/source/0x1/index.js","./_generated/_dependencies/source/0x2/object-table/structs":"./_generated/_dependencies/source/0x2/object-table/structs.js","./_generated/_dependencies/source/0x2/balance/structs":"./_generated/_dependencies/source/0x2/balance/structs.js","./_generated/_dependencies/source/0x2/object/structs":"./_generated/_dependencies/source/0x2/object/structs.js","./_generated/_dependencies/source/0x2/bag/structs":"./_generated/_dependencies/source/0x2/bag/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js","./_generated/_dependencies/source/0x1/ascii/structs":"./_generated/_dependencies/source/0x1/ascii/structs.js","./_generated/_dependencies/source/0x1/option/structs":"./_generated/_dependencies/source/0x1/option/structs.js","./_generated/_dependencies/source/0x1/type-name/structs":"./_generated/_dependencies/source/0x1/type-name/structs.js"},"types":"./index.js","scripts":{"build":"rm -rf ./dist && bun tsc","eslint":"eslint --fix src/","prettier":"prettier --write src/","lint":"bun eslint && bun prettier && bun tsc --noEmit","release":"bun run build && bun ./release.js && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/suilend/suilend-fe-public.git"},"bugs":{"url":"https://github.com/suilend/suilend-fe-public/issues"},"dependencies":{"@bluefin-exchange/bluefin7k-aggregator-sdk":"^5.4.1","@cetusprotocol/aggregator-sdk":"^1.4.5","@flowx-finance/sdk":"^1.15.0","@suilend/springsui-sdk":"^2.0.1","aftermath-ts-sdk":"^1.3.28","bignumber.js":"^9.1.2","bn.js":"^5.2.2","crypto-js":"^4.2.0","lodash":"^4.17.21","p-limit":"3.1.0","uuid":"^11.0.3"},"devDependencies":{"@types/bn.js":"^5.2.0","@types/lodash":"^4.17.20","ts-node":"^10.9.2"},"peerDependencies":{"@mysten/bcs":"2.0.1","@mysten/sui":"2.3.1","@suilend/sui-fe":"^2.0.10","@pythnetwork/pyth-sui-js":"2.2.0"},"overrides":{"chalk":"5.3.0","strip-ansi":"7.1.0","color-convert":"2.0.1","color-name":"1.1.4","is-core-module":"2.13.1","error-ex":"1.3.2","has-ansi":"5.0.1","axios":"<=1.11.0"}}
|
package/strategies.js
CHANGED
|
@@ -747,6 +747,7 @@ lstMap, strategyType, obligation, exposure) => {
|
|
|
747
747
|
}
|
|
748
748
|
return getNetAprPercent(_obligation, rewardMap, lstStatsMap, undefined, // sdeUsdAprPercent
|
|
749
749
|
undefined, // eThirdAprPercent
|
|
750
|
+
undefined, // eEarnAprPercent
|
|
750
751
|
!obligation ||
|
|
751
752
|
!hasStrategyPosition(obligation) ||
|
|
752
753
|
obligation.deposits.some((d) => !d.userRewardManager));
|