@suilend/sdk 12.7.0 → 13.0.0-next.g803bba0
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/_generated/_dependencies/pyth-2/price-identifier/structs.d.ts +46 -0
- package/_generated/_dependencies/{source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e → pyth-2}/price-identifier/structs.js +45 -25
- package/_generated/_dependencies/std/ascii/structs.d.ts +100 -0
- package/_generated/_dependencies/{source/0x1 → std}/ascii/structs.js +153 -103
- package/_generated/_dependencies/{source/0x1 → std}/option/structs.d.ts +29 -21
- package/_generated/_dependencies/std/option/structs.js +155 -0
- package/_generated/_dependencies/std/type-name/structs.d.ts +65 -0
- package/_generated/_dependencies/{source/0x1 → std}/type-name/structs.js +49 -22
- package/_generated/_dependencies/sui/bag/structs.d.ts +75 -0
- package/_generated/_dependencies/sui/bag/structs.js +154 -0
- package/_generated/_dependencies/{source/0x2 → sui}/balance/structs.d.ts +80 -60
- package/_generated/_dependencies/sui/balance/structs.js +306 -0
- package/_generated/_dependencies/sui/object/structs.d.ts +104 -0
- package/_generated/_dependencies/{source/0x2 → sui}/object/structs.js +98 -46
- package/_generated/_dependencies/{source/0x2 → sui}/object-table/structs.d.ts +37 -30
- package/_generated/_dependencies/sui/object-table/structs.js +164 -0
- package/_generated/_envs/index.d.ts +3 -0
- package/_generated/_envs/index.js +18 -0
- package/_generated/_envs/mainnet.d.ts +2 -0
- package/_generated/_envs/mainnet.js +490 -0
- package/_generated/_framework/env.d.ts +137 -0
- package/_generated/_framework/env.js +261 -0
- package/_generated/_framework/reified.d.ts +68 -36
- package/_generated/_framework/reified.js +110 -98
- package/_generated/_framework/util.d.ts +4 -4
- package/_generated/_framework/util.js +82 -79
- package/_generated/_framework/vector.d.ts +11 -9
- package/_generated/_framework/vector.js +10 -10
- package/_generated/suilend/cell/structs.d.ts +24 -22
- package/_generated/suilend/cell/structs.js +68 -24
- package/_generated/suilend/decimal/structs.d.ts +28 -24
- package/_generated/suilend/decimal/structs.js +45 -24
- package/_generated/suilend/index.d.ts +5 -6
- package/_generated/suilend/index.js +10 -19
- package/_generated/suilend/lending-market/functions.d.ts +1123 -149
- package/_generated/suilend/lending-market/functions.js +1121 -207
- package/_generated/suilend/lending-market/structs.d.ts +985 -1290
- package/_generated/suilend/lending-market/structs.js +2482 -1282
- package/_generated/suilend/lending-market-registry/functions.d.ts +32 -3
- package/_generated/suilend/lending-market-registry/functions.js +30 -6
- package/_generated/suilend/liquidity-mining/structs.d.ts +200 -333
- package/_generated/suilend/liquidity-mining/structs.js +449 -319
- package/_generated/suilend/obligation/structs.d.ts +406 -918
- package/_generated/suilend/obligation/structs.js +786 -596
- package/_generated/suilend/rate-limiter/functions.d.ts +134 -15
- package/_generated/suilend/rate-limiter/functions.js +139 -21
- package/_generated/suilend/rate-limiter/structs.d.ts +72 -80
- package/_generated/suilend/rate-limiter/structs.js +98 -48
- package/_generated/suilend/reserve/structs.d.ts +611 -904
- package/_generated/suilend/reserve/structs.js +1528 -736
- package/_generated/suilend/reserve-config/functions.d.ts +718 -96
- package/_generated/suilend/reserve-config/functions.js +751 -157
- package/_generated/suilend/reserve-config/structs.d.ts +148 -163
- package/_generated/suilend/reserve-config/structs.js +260 -94
- package/client.d.ts +2 -2
- package/client.js +22 -39
- package/lib/initialize.d.ts +76 -76
- package/lib/initialize.js +10 -10
- package/lib/proCompatible.js +5 -5
- package/package.json +1 -1
- package/parsers/lendingMarket.d.ts +9 -9
- package/parsers/obligation.d.ts +14 -14
- package/parsers/obligation.js +4 -4
- package/parsers/rateLimiter.d.ts +1 -1
- package/parsers/reserve.d.ts +12 -12
- package/parsers/reserve.js +2 -2
- package/strategies.d.ts +14 -14
- package/utils/simulate.d.ts +1 -1
- package/utils/simulate.js +5 -5
- package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +0 -84
- package/_generated/_dependencies/source/0x1/index.d.ts +0 -3
- package/_generated/_dependencies/source/0x1/index.js +0 -3
- package/_generated/_dependencies/source/0x1/option/structs.js +0 -110
- package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +0 -47
- package/_generated/_dependencies/source/0x2/bag/structs.d.ts +0 -52
- package/_generated/_dependencies/source/0x2/bag/structs.js +0 -113
- package/_generated/_dependencies/source/0x2/balance/structs.js +0 -210
- package/_generated/_dependencies/source/0x2/index.d.ts +0 -3
- package/_generated/_dependencies/source/0x2/index.js +0 -3
- package/_generated/_dependencies/source/0x2/object/structs.d.ts +0 -82
- package/_generated/_dependencies/source/0x2/object-table/structs.js +0 -115
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.d.ts +0 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +0 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +0 -46
|
@@ -1,323 +1,901 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { obj, option, pure } from
|
|
4
|
-
import { RateLimiterExemption } from
|
|
5
|
-
export function
|
|
1
|
+
import { ID } from '../../_dependencies/sui/object/structs.js';
|
|
2
|
+
import { getPublishedAt } from '../../_envs/index.js';
|
|
3
|
+
import { obj, option, pure } from '../../_framework/util.js';
|
|
4
|
+
import { RateLimiterExemption } from './structs.js';
|
|
5
|
+
export function init(tx, otw, options) {
|
|
6
6
|
return tx.moveCall({
|
|
7
|
-
target: `${
|
|
8
|
-
|
|
7
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::init`,
|
|
8
|
+
arguments: [obj(tx, otw)],
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new lending market, and sets the fee receivers.
|
|
13
|
+
*
|
|
14
|
+
* The function initializes a `LendingMarket` object with empty reserves
|
|
15
|
+
* and obligations, a default rate limiter, and the sender as the fee receiver.
|
|
16
|
+
*
|
|
17
|
+
* It then calls the `set_fee_receivers` function to set the initial fee receiver to the creator of the market with a weight of 100.
|
|
18
|
+
*
|
|
19
|
+
* # Returns
|
|
20
|
+
*
|
|
21
|
+
* * `LendingMarketOwnerCap<P>` - The ownership capability for the newly created lending market.
|
|
22
|
+
* * `LendingMarket<P>` - The newly created lending market object.
|
|
23
|
+
*
|
|
24
|
+
* # Panics
|
|
25
|
+
*
|
|
26
|
+
* This function calls `set_fee_receivers`, which can panic under the following conditions:
|
|
27
|
+
*
|
|
28
|
+
* * If the `receivers` and `weights` vectors do not have the same length (EInvalidFeeReceivers).
|
|
29
|
+
* * If the `receivers` vector is empty (EInvalidFeeReceivers).
|
|
30
|
+
* * If the sum of `weights` is zero (EInvalidFeeReceivers).
|
|
31
|
+
*/
|
|
32
|
+
export function createLendingMarket(tx, typeArg, options) {
|
|
33
|
+
return tx.moveCall({
|
|
34
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::create_lending_market`,
|
|
35
|
+
typeArguments: [typeArg],
|
|
36
|
+
arguments: [],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Deprecated tombstone — kept only because Sui's upgrade compatibility rules
|
|
41
|
+
* freeze a published function's signature. Pyth froze every legacy on-chain
|
|
42
|
+
* feed at the 2026-08-26 cutover; nothing has written to one since, so this
|
|
43
|
+
* now aborts unconditionally instead of silently refreshing against a
|
|
44
|
+
* permanently-stale price. Use `refresh_reserve_price_pro_compatible`.
|
|
45
|
+
*/
|
|
46
|
+
export function refreshReservePrice(tx, typeArg, args, options) {
|
|
47
|
+
return tx.moveCall({
|
|
48
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::refresh_reserve_price`,
|
|
49
|
+
typeArguments: [typeArg],
|
|
9
50
|
arguments: [
|
|
10
51
|
obj(tx, args.lendingMarket),
|
|
11
|
-
pure(tx, args.
|
|
12
|
-
obj(tx, args.obligationOwnerCap),
|
|
52
|
+
pure(tx, args.u64, `u64`),
|
|
13
53
|
obj(tx, args.clock),
|
|
14
|
-
|
|
54
|
+
obj(tx, args.priceInfoObject),
|
|
15
55
|
],
|
|
16
56
|
});
|
|
17
57
|
}
|
|
18
|
-
|
|
58
|
+
/**
|
|
59
|
+
* `refresh_reserve_price` against the upgraded Pyth package. From the
|
|
60
|
+
* 2026-08-18 cutover this is the only working refresh path; the legacy one
|
|
61
|
+
* above can no longer be supplied with a verifiable `PriceInfoObject`, and
|
|
62
|
+
* is retained only because published signatures are frozen.
|
|
63
|
+
*/
|
|
64
|
+
export function refreshReservePriceProCompatible(tx, typeArg, args, options) {
|
|
19
65
|
return tx.moveCall({
|
|
20
|
-
target: `${
|
|
66
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::refresh_reserve_price_pro_compatible`,
|
|
21
67
|
typeArguments: [typeArg],
|
|
22
68
|
arguments: [
|
|
23
|
-
obj(tx, args.lendingMarketOwnerCap),
|
|
24
69
|
obj(tx, args.lendingMarket),
|
|
70
|
+
pure(tx, args.reserveArrayIndex, `u64`),
|
|
71
|
+
obj(tx, args.clock),
|
|
72
|
+
obj(tx, args.priceInfo),
|
|
25
73
|
],
|
|
26
74
|
});
|
|
27
75
|
}
|
|
28
|
-
|
|
76
|
+
/** Creates a new obligation. */
|
|
77
|
+
export function createObligation(tx, typeArg, lendingMarket, options) {
|
|
29
78
|
return tx.moveCall({
|
|
30
|
-
target: `${
|
|
31
|
-
|
|
79
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::create_obligation`,
|
|
80
|
+
typeArguments: [typeArg],
|
|
81
|
+
arguments: [obj(tx, lendingMarket)],
|
|
32
82
|
});
|
|
33
83
|
}
|
|
34
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Deposits liquidity into a reserve and mints cTokens in return.
|
|
86
|
+
*
|
|
87
|
+
* This function allows a user to deposit a certain amount of a token into a reserve
|
|
88
|
+
* and receive cTokens, which represent their share of the reserve's assets.
|
|
89
|
+
* The amount of cTokens minted is proportional to the amount of liquidity deposited
|
|
90
|
+
* and the current cToken ratio of the reserve.
|
|
91
|
+
*
|
|
92
|
+
* # Arguments
|
|
93
|
+
*
|
|
94
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
95
|
+
* * `reserve_array_index` - The index of the reserve to deposit into.
|
|
96
|
+
* * `clock` - A reference to the `Clock` to compound interest before depositing.
|
|
97
|
+
* * `deposit` - The `Coin` object representing the liquidity to deposit.
|
|
98
|
+
*
|
|
99
|
+
* # Returns
|
|
100
|
+
*
|
|
101
|
+
* * `Coin<CToken<P, T>>` - A `Coin` of cTokens representing the deposited liquidity and accrued interest.
|
|
102
|
+
*
|
|
103
|
+
* # Panics
|
|
104
|
+
*
|
|
105
|
+
* This function will panic if:
|
|
106
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
107
|
+
* * The deposit amount is zero (ETooSmall).
|
|
108
|
+
* * The `coin_type` of the reserve does not match the type of the deposited coin (EWrongType).
|
|
109
|
+
* * The deposit would exceed the reserve's deposit limit (`EDepositLimitExceeded` from the `reserve` module).
|
|
110
|
+
* * If ctokens are outstanding but unclaimed spread fees have consumed the entire total
|
|
111
|
+
* supply, leaving them unbacked (`EReserveInDeficit` from the `reserve` module).
|
|
112
|
+
* * The minted cToken amount is zero (ETooSmall).
|
|
113
|
+
* * `reserve_array_index` is out of bounds.
|
|
114
|
+
*/
|
|
115
|
+
export function depositLiquidityAndMintCtokens(tx, typeArgs, args, options) {
|
|
35
116
|
return tx.moveCall({
|
|
36
|
-
target: `${
|
|
117
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::deposit_liquidity_and_mint_ctokens`,
|
|
37
118
|
typeArguments: typeArgs,
|
|
38
119
|
arguments: [
|
|
39
120
|
obj(tx, args.lendingMarket),
|
|
40
121
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
41
|
-
obj(tx, args.
|
|
122
|
+
obj(tx, args.clock),
|
|
123
|
+
obj(tx, args.deposit),
|
|
42
124
|
],
|
|
43
125
|
});
|
|
44
126
|
}
|
|
45
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Redeems cTokens for the underlying liquidity.
|
|
129
|
+
*
|
|
130
|
+
* This function allows a user to redeem their cTokens for the underlying asset.
|
|
131
|
+
* The amount of the underlying asset received depends on the amount of cTokens redeemed
|
|
132
|
+
* and the current cToken ratio of the reserve.
|
|
133
|
+
*
|
|
134
|
+
* # Arguments
|
|
135
|
+
*
|
|
136
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
137
|
+
* * `reserve_array_index` - The index of the reserve to redeem from.
|
|
138
|
+
* * `clock` - A reference to the `Clock` to compound interest before redeeming.
|
|
139
|
+
* * `ctokens` - The `Coin` of cTokens to redeem.
|
|
140
|
+
* * `rate_limiter_exemption` - An optional exemption from the rate limiter.
|
|
141
|
+
*
|
|
142
|
+
* # Returns
|
|
143
|
+
*
|
|
144
|
+
* * `Coin<T>` - A `Coin` of the underlying asset.
|
|
145
|
+
*
|
|
146
|
+
* # Panics
|
|
147
|
+
*
|
|
148
|
+
* This function will panic if:
|
|
149
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
150
|
+
* * The amount of cTokens to redeem is zero (ETooSmall).
|
|
151
|
+
* * The `coin_type` of the reserve does not match the type of the cTokens (EWrongType).
|
|
152
|
+
* * If ctokens are outstanding but unclaimed spread fees have consumed the entire total
|
|
153
|
+
* supply, leaving them unbacked (`EReserveInDeficit` from the `reserve` module).
|
|
154
|
+
* * The redemption would violate the minimum available amount of the reserve (`EMinAvailableAmountViolated` from the `reserve` module).
|
|
155
|
+
* * The withdrawal amount exceeds the rate limit, and no exemption is provided.
|
|
156
|
+
* * The redemption would floor to zero underlying, i.e. this reserve's ctoken ratio is
|
|
157
|
+
* below one and the amount redeemed is below its reciprocal (ETooSmall). Refused rather
|
|
158
|
+
* than burning the ctokens for nothing, mirroring the deposit-side zero-mint refusal above.
|
|
159
|
+
* * `reserve_array_index` is out of bounds.
|
|
160
|
+
*/
|
|
161
|
+
export function redeemCtokensAndWithdrawLiquidity(tx, typeArgs, args, options) {
|
|
46
162
|
return tx.moveCall({
|
|
47
|
-
target: `${
|
|
163
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::redeem_ctokens_and_withdraw_liquidity`,
|
|
48
164
|
typeArguments: typeArgs,
|
|
49
165
|
arguments: [
|
|
50
|
-
obj(tx, args.lendingMarketOwnerCap),
|
|
51
166
|
obj(tx, args.lendingMarket),
|
|
52
167
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
53
|
-
pure(tx, args.isDepositReward, `bool`),
|
|
54
|
-
obj(tx, args.rewards),
|
|
55
|
-
pure(tx, args.startTimeMs, `u64`),
|
|
56
|
-
pure(tx, args.endTimeMs, `u64`),
|
|
57
168
|
obj(tx, args.clock),
|
|
169
|
+
obj(tx, args.ctokens),
|
|
170
|
+
option(tx, `${RateLimiterExemption.$typeName}<${typeArgs[0]}, ${typeArgs[1]}>`, args.rateLimiterExemption),
|
|
58
171
|
],
|
|
59
172
|
});
|
|
60
173
|
}
|
|
61
|
-
|
|
174
|
+
/**
|
|
175
|
+
* Creates a liquidity request to withdraw liquidity by redeeming cTokens.
|
|
176
|
+
*
|
|
177
|
+
* Initiates the process of redeeming cTokens for the underlying asset.
|
|
178
|
+
* It checks for rate limit exemptions, processes the withdrawal against the rate limiter if necessary,
|
|
179
|
+
* and then creates a `LiquidityRequest` by calling the `redeem_ctokens` function in the `reserve` module.
|
|
180
|
+
*
|
|
181
|
+
* # Arguments
|
|
182
|
+
*
|
|
183
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
184
|
+
* * `reserve_array_index` - The index of the reserve to redeem from.
|
|
185
|
+
* * `clock` - A reference to the `Clock` to compound interest before redeeming.
|
|
186
|
+
* * `ctokens` - The `Coin` of cTokens to redeem.
|
|
187
|
+
* * `rate_limiter_exemption` - An optional exemption from the rate limiter.
|
|
188
|
+
*
|
|
189
|
+
* # Returns
|
|
190
|
+
*
|
|
191
|
+
* * `LiquidityRequest<P, T>` - A request to withdraw liquidity from the reserve.
|
|
192
|
+
*
|
|
193
|
+
* # Panics
|
|
194
|
+
*
|
|
195
|
+
* This function will panic if:
|
|
196
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
197
|
+
* * The amount of cTokens to redeem is zero (ETooSmall).
|
|
198
|
+
* * The `coin_type` of the reserve does not match the type of the cTokens (EWrongType).
|
|
199
|
+
* * If ctokens are outstanding but unclaimed spread fees have consumed the entire total
|
|
200
|
+
* supply, leaving them unbacked (`EReserveInDeficit` from the `reserve` module).
|
|
201
|
+
* * The redemption would violate the minimum available amount of the reserve (`EMinAvailableAmountViolated` from the `reserve` module).
|
|
202
|
+
* * The withdrawal amount exceeds the rate limit, and no exemption is provided.
|
|
203
|
+
* * The redemption would floor to zero underlying, i.e. this reserve's ctoken ratio is
|
|
204
|
+
* below one and the amount redeemed is below its reciprocal (ETooSmall). Refused rather
|
|
205
|
+
* than burning the ctokens for nothing, mirroring the deposit-side zero-mint refusal above.
|
|
206
|
+
* * `reserve_array_index` is out of bounds.
|
|
207
|
+
*/
|
|
208
|
+
export function redeemCtokensAndWithdrawLiquidityRequest(tx, typeArgs, args, options) {
|
|
62
209
|
return tx.moveCall({
|
|
63
|
-
target: `${
|
|
210
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::redeem_ctokens_and_withdraw_liquidity_request`,
|
|
64
211
|
typeArguments: typeArgs,
|
|
65
212
|
arguments: [
|
|
66
|
-
obj(tx, args.lendingMarketOwnerCap),
|
|
67
213
|
obj(tx, args.lendingMarket),
|
|
68
214
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
69
|
-
pure(tx, args.isDepositReward, `bool`),
|
|
70
|
-
pure(tx, args.rewardIndex, `u64`),
|
|
71
215
|
obj(tx, args.clock),
|
|
216
|
+
obj(tx, args.ctokens),
|
|
217
|
+
option(tx, `${RateLimiterExemption.$typeName}<${typeArgs[0]}, ${typeArgs[1]}>`, args.rateLimiterExemption),
|
|
72
218
|
],
|
|
73
219
|
});
|
|
74
220
|
}
|
|
75
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Deposits cTokens into an obligation, which can be used as collateral for borrowing.
|
|
223
|
+
*
|
|
224
|
+
* # Arguments
|
|
225
|
+
*
|
|
226
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
227
|
+
* * `reserve_array_index` - The index of the reserve corresponding to the cTokens being deposited.
|
|
228
|
+
* * `obligation_owner_cap` - The ownership capability for the obligation.
|
|
229
|
+
* * `clock` - A reference to the `Clock`.
|
|
230
|
+
* * `deposit` - The `Coin` of cTokens to deposit.
|
|
231
|
+
*
|
|
232
|
+
* # Panics
|
|
233
|
+
*
|
|
234
|
+
* This function will panic if:
|
|
235
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
236
|
+
* * The deposit amount is zero (ETooSmall).
|
|
237
|
+
* * The `coin_type` of the reserve does not match the type of the deposited cTokens (EWrongType).
|
|
238
|
+
* * `reserve_array_index` is out of bounds.
|
|
239
|
+
* * `obligation_id` is not a valid key in the `obligations` table.
|
|
240
|
+
*/
|
|
241
|
+
export function depositCtokensIntoObligation(tx, typeArgs, args, options) {
|
|
76
242
|
return tx.moveCall({
|
|
77
|
-
target: `${
|
|
243
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::deposit_ctokens_into_obligation`,
|
|
78
244
|
typeArguments: typeArgs,
|
|
79
245
|
arguments: [
|
|
80
246
|
obj(tx, args.lendingMarket),
|
|
81
|
-
|
|
247
|
+
pure(tx, args.reserveArrayIndex, `u64`),
|
|
248
|
+
obj(tx, args.obligationOwnerCap),
|
|
82
249
|
obj(tx, args.clock),
|
|
83
|
-
|
|
84
|
-
pure(tx, args.rewardIndex, `u64`),
|
|
85
|
-
pure(tx, args.isDepositReward, `bool`),
|
|
250
|
+
obj(tx, args.deposit),
|
|
86
251
|
],
|
|
87
252
|
});
|
|
88
253
|
}
|
|
89
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Borrows a specified amount of a token from a reserve. A fee is charged on the borrowed amount.
|
|
256
|
+
*
|
|
257
|
+
* # Arguments
|
|
258
|
+
*
|
|
259
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
260
|
+
* * `reserve_array_index` - The index of the reserve to borrow from.
|
|
261
|
+
* * `obligation_owner_cap` - The ownership capability for the obligation.
|
|
262
|
+
* * `clock` - A reference to the `Clock`.
|
|
263
|
+
* * `amount` - The amount to borrow.
|
|
264
|
+
*
|
|
265
|
+
* # Returns
|
|
266
|
+
*
|
|
267
|
+
* * `Coin<T>` - A `Coin` of the borrowed asset.
|
|
268
|
+
*
|
|
269
|
+
* # Panics
|
|
270
|
+
*
|
|
271
|
+
* This function will panic if:
|
|
272
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
273
|
+
* * The borrow amount is zero (ETooSmall).
|
|
274
|
+
* * The `coin_type` of the reserve does not match the type of the asset being borrowed (EWrongType).
|
|
275
|
+
* * The reserve's price is stale (`EPriceStale` from the `reserve` module).
|
|
276
|
+
* * The borrow would exceed the reserve's borrow limit (`EBorrowLimitExceeded` from the `reserve` module).
|
|
277
|
+
* * The borrow would violate the minimum available amount of the reserve (`EMinAvailableAmountViolated` from the `reserve` module).
|
|
278
|
+
* * The obligation has stale oracle prices.
|
|
279
|
+
* * The borrow amount exceeds the rate limit.
|
|
280
|
+
* * `reserve_array_index` is out of bounds.
|
|
281
|
+
* * `obligation_id` is not a valid key in the `obligations` table.
|
|
282
|
+
*/
|
|
283
|
+
export function borrow(tx, typeArgs, args, options) {
|
|
90
284
|
return tx.moveCall({
|
|
91
|
-
target: `${
|
|
285
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::borrow`,
|
|
92
286
|
typeArguments: typeArgs,
|
|
93
287
|
arguments: [
|
|
94
|
-
obj(tx, args.lendingMarketOwnerCap),
|
|
95
288
|
obj(tx, args.lendingMarket),
|
|
96
289
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
97
|
-
|
|
98
|
-
|
|
290
|
+
obj(tx, args.obligationOwnerCap),
|
|
291
|
+
obj(tx, args.clock),
|
|
292
|
+
pure(tx, args.amount, `u64`),
|
|
293
|
+
],
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
/** Compound interest for reserve of type T */
|
|
297
|
+
export function compoundInterest(tx, typeArg, args, options) {
|
|
298
|
+
return tx.moveCall({
|
|
299
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::compound_interest`,
|
|
300
|
+
typeArguments: [typeArg],
|
|
301
|
+
arguments: [
|
|
302
|
+
obj(tx, args.lendingMarket),
|
|
303
|
+
pure(tx, args.reserveArrayIndex, `u64`),
|
|
304
|
+
obj(tx, args.clock),
|
|
305
|
+
],
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
/** Refresh the obligation's state and assert no stale oracles */
|
|
309
|
+
export function refreshObligation(tx, typeArg, args, options) {
|
|
310
|
+
return tx.moveCall({
|
|
311
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::refresh_obligation`,
|
|
312
|
+
typeArguments: [typeArg],
|
|
313
|
+
arguments: [
|
|
314
|
+
obj(tx, args.lendingMarket),
|
|
315
|
+
pure(tx, args.obligationId, `${ID.$typeName}`),
|
|
99
316
|
obj(tx, args.clock),
|
|
100
317
|
],
|
|
101
318
|
});
|
|
102
319
|
}
|
|
103
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Creates a borrow request for a specified amount of a token from a reserve. A fee is charged
|
|
322
|
+
* on the borrowed amount. The returned `LiquidityRequest` must be fulfilled by calling
|
|
323
|
+
* `fulfill_liquidity_request`.
|
|
324
|
+
*
|
|
325
|
+
* # Arguments
|
|
326
|
+
*
|
|
327
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
328
|
+
* * `reserve_array_index` - The index of the reserve to borrow from.
|
|
329
|
+
* * `obligation_owner_cap` - The ownership capability for the obligation.
|
|
330
|
+
* * `clock` - A reference to the `Clock`.
|
|
331
|
+
* * `amount` - The amount to borrow.
|
|
332
|
+
*
|
|
333
|
+
* # Returns
|
|
334
|
+
*
|
|
335
|
+
* * `LiquidityRequest<P, T>` - A request that must be fulfilled to complete the borrow.
|
|
336
|
+
*
|
|
337
|
+
* # Panics
|
|
338
|
+
*
|
|
339
|
+
* This function will panic if:
|
|
340
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
341
|
+
* * The borrow amount is zero (ETooSmall).
|
|
342
|
+
* * The `coin_type` of the reserve does not match the type of the asset being borrowed (EWrongType).
|
|
343
|
+
* * The reserve's price is stale (`EPriceStale` from the `reserve` module).
|
|
344
|
+
* * The borrow would exceed the reserve's borrow limit (`EBorrowLimitExceeded` from the `reserve` module).
|
|
345
|
+
* * The borrow would violate the minimum available amount of the reserve (`EMinAvailableAmountViolated` from the `reserve` module).
|
|
346
|
+
* * The obligation has stale oracle prices.
|
|
347
|
+
* * The borrow amount exceeds the rate limit.
|
|
348
|
+
* * `reserve_array_index` is out of bounds.
|
|
349
|
+
* * `obligation_id` is not a valid key in the `obligations` table.
|
|
350
|
+
*/
|
|
351
|
+
export function borrowRequest(tx, typeArgs, args, options) {
|
|
104
352
|
return tx.moveCall({
|
|
105
|
-
target: `${
|
|
353
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::borrow_request`,
|
|
106
354
|
typeArguments: typeArgs,
|
|
107
|
-
arguments: [
|
|
355
|
+
arguments: [
|
|
356
|
+
obj(tx, args.lendingMarket),
|
|
357
|
+
pure(tx, args.reserveArrayIndex, `u64`),
|
|
358
|
+
obj(tx, args.obligationOwnerCap),
|
|
359
|
+
obj(tx, args.clock),
|
|
360
|
+
pure(tx, args.amount, `u64`),
|
|
361
|
+
],
|
|
108
362
|
});
|
|
109
363
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
364
|
+
/**
|
|
365
|
+
* Fulfills a liquidity request from a reserve.
|
|
366
|
+
*
|
|
367
|
+
* This function is called after a liquidity request has been created by either
|
|
368
|
+
* `redeem_ctokens_and_withdraw_liquidity_request` or `borrow_request`. It takes the
|
|
369
|
+
* `LiquidityRequest` and processes it, returning the requested amount of the
|
|
370
|
+
* underlying asset as a `Coin`.
|
|
371
|
+
*
|
|
372
|
+
* # Arguments
|
|
373
|
+
*
|
|
374
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
375
|
+
* * `reserve_array_index` - The index of the reserve to fulfill the request from.
|
|
376
|
+
* * `liquidity_request` - The `LiquidityRequest` to be fulfilled.
|
|
377
|
+
*
|
|
378
|
+
* # Returns
|
|
379
|
+
*
|
|
380
|
+
* * `Coin<T>` - A `Coin` of the underlying asset.
|
|
381
|
+
*
|
|
382
|
+
* # Panics
|
|
383
|
+
*
|
|
384
|
+
* This function will panic if:
|
|
385
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
386
|
+
* * The `coin_type` of the reserve does not match the type of the liquidity request (EWrongType).
|
|
387
|
+
* * `reserve_array_index` is out of bounds.
|
|
388
|
+
*/
|
|
389
|
+
export function fulfillLiquidityRequest(tx, typeArgs, args, options) {
|
|
115
390
|
return tx.moveCall({
|
|
116
|
-
target: `${
|
|
391
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::fulfill_liquidity_request`,
|
|
117
392
|
typeArguments: typeArgs,
|
|
118
|
-
arguments: [
|
|
393
|
+
arguments: [
|
|
394
|
+
obj(tx, args.lendingMarket),
|
|
395
|
+
pure(tx, args.reserveArrayIndex, `u64`),
|
|
396
|
+
obj(tx, args.liquidityRequest),
|
|
397
|
+
],
|
|
119
398
|
});
|
|
120
399
|
}
|
|
121
|
-
|
|
400
|
+
/**
|
|
401
|
+
* Withdraws cTokens from an obligation.
|
|
402
|
+
*
|
|
403
|
+
* This function allows a user to withdraw their cTokens from an obligation,
|
|
404
|
+
* making them available for redemption or transfer.
|
|
405
|
+
*
|
|
406
|
+
* # Arguments
|
|
407
|
+
*
|
|
408
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
409
|
+
* * `reserve_array_index` - The index of the reserve corresponding to the cTokens being withdrawn.
|
|
410
|
+
* * `obligation_owner_cap` - The ownership capability for the obligation.
|
|
411
|
+
* * `clock` - A reference to the `Clock`.
|
|
412
|
+
* * `amount` - The amount of cTokens to withdraw. If `U64_MAX` is provided, the maximum possible amount will be withdrawn.
|
|
413
|
+
*
|
|
414
|
+
* # Returns
|
|
415
|
+
*
|
|
416
|
+
* * `Coin<CToken<P, T>>` - A `Coin` of the withdrawn cTokens.
|
|
417
|
+
*
|
|
418
|
+
* # Panics
|
|
419
|
+
*
|
|
420
|
+
* This function will panic if:
|
|
421
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
422
|
+
* * The withdraw amount is zero (ETooSmall).
|
|
423
|
+
* * The `coin_type` of the reserve does not match the type of the cTokens being withdrawn (EWrongType).
|
|
424
|
+
* * The obligation has stale oracle prices.
|
|
425
|
+
* * The withdrawal would leave the obligation in an unhealthy state.
|
|
426
|
+
* * `reserve_array_index` is out of bounds.
|
|
427
|
+
* * `obligation_id` is not a valid key in the `obligations` table.
|
|
428
|
+
*/
|
|
429
|
+
export function withdrawCtokens(tx, typeArgs, args, options) {
|
|
122
430
|
return tx.moveCall({
|
|
123
|
-
target: `${
|
|
124
|
-
typeArguments:
|
|
431
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::withdraw_ctokens`,
|
|
432
|
+
typeArguments: typeArgs,
|
|
125
433
|
arguments: [
|
|
126
434
|
obj(tx, args.lendingMarket),
|
|
127
435
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
436
|
+
obj(tx, args.obligationOwnerCap),
|
|
437
|
+
obj(tx, args.clock),
|
|
438
|
+
pure(tx, args.amount, `u64`),
|
|
439
|
+
],
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Liquidates an unhealthy obligation by repaying a borrow and seizing collateral.
|
|
444
|
+
*
|
|
445
|
+
* This function allows a liquidator to repay a portion of an unhealthy obligation's
|
|
446
|
+
* debt in exchange for a discounted amount of their collateral. Any leftover repay
|
|
447
|
+
* coins are returned to the liquidator.
|
|
448
|
+
*
|
|
449
|
+
* # Arguments
|
|
450
|
+
*
|
|
451
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
452
|
+
* * `obligation_id` - The ID of the obligation to liquidate.
|
|
453
|
+
* * `repay_reserve_array_index` - The index of the reserve to repay the debt to.
|
|
454
|
+
* * `withdraw_reserve_array_index` - The index of the reserve to withdraw collateral from.
|
|
455
|
+
* * `clock` - A reference to the `Clock`.
|
|
456
|
+
* * `repay_coins` - A mutable reference to the `Coin` used to repay the debt.
|
|
457
|
+
*
|
|
458
|
+
* # Returns
|
|
459
|
+
*
|
|
460
|
+
* * `(Coin<CToken<P, Withdraw>>, RateLimiterExemption<P, Withdraw>)` - A tuple containing the withdrawn collateral as cTokens and a rate limiter exemption.
|
|
461
|
+
*
|
|
462
|
+
* # Panics
|
|
463
|
+
*
|
|
464
|
+
* This function will panic if:
|
|
465
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
466
|
+
* * The repay amount is zero (ETooSmall).
|
|
467
|
+
* * The obligation is not unhealthy.
|
|
468
|
+
* * The obligation has stale oracle prices.
|
|
469
|
+
* * The `coin_type` of the repay reserve does not match the type of the repay coin.
|
|
470
|
+
* * The `coin_type` of the withdraw reserve does not match the type of the withdrawn cTokens.
|
|
471
|
+
* * `repay_reserve_array_index` or `withdraw_reserve_array_index` are out of bounds.
|
|
472
|
+
* * `obligation_id` is not a valid key in the `obligations` table.
|
|
473
|
+
*/
|
|
474
|
+
export function liquidate(tx, typeArgs, args, options) {
|
|
475
|
+
return tx.moveCall({
|
|
476
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::liquidate`,
|
|
477
|
+
typeArguments: typeArgs,
|
|
478
|
+
arguments: [
|
|
479
|
+
obj(tx, args.lendingMarket),
|
|
480
|
+
pure(tx, args.obligationId, `${ID.$typeName}`),
|
|
481
|
+
pure(tx, args.repayReserveArrayIndex, `u64`),
|
|
482
|
+
pure(tx, args.withdrawReserveArrayIndex, `u64`),
|
|
128
483
|
obj(tx, args.clock),
|
|
484
|
+
obj(tx, args.repayCoins),
|
|
129
485
|
],
|
|
130
486
|
});
|
|
131
487
|
}
|
|
132
|
-
|
|
488
|
+
/**
|
|
489
|
+
* Repays a borrow, reducing the obligation's debt and increasing the reserve's liquidity.
|
|
490
|
+
*
|
|
491
|
+
* Any leftover repay coins are returned to the caller.
|
|
492
|
+
*
|
|
493
|
+
* # Arguments
|
|
494
|
+
*
|
|
495
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
496
|
+
* * `reserve_array_index` - The index of the reserve to repay the debt to.
|
|
497
|
+
* * `obligation_id` - The ID of the obligation to repay.
|
|
498
|
+
* * `clock` - A reference to the `Clock`.
|
|
499
|
+
* * `max_repay_coins` - A mutable reference to the `Coin` used to repay the debt.
|
|
500
|
+
*
|
|
501
|
+
* # Panics
|
|
502
|
+
*
|
|
503
|
+
* This function will panic if:
|
|
504
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
505
|
+
* * The `coin_type` of the reserve does not match the type of the repay coin (EWrongType).
|
|
506
|
+
* * `reserve_array_index` is out of bounds.
|
|
507
|
+
* * `obligation_id` is not a valid key in the `obligations` table.
|
|
508
|
+
*/
|
|
509
|
+
export function repay(tx, typeArgs, args, options) {
|
|
133
510
|
return tx.moveCall({
|
|
134
|
-
target: `${
|
|
511
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::repay`,
|
|
135
512
|
typeArguments: typeArgs,
|
|
136
513
|
arguments: [
|
|
137
514
|
obj(tx, args.lendingMarket),
|
|
138
515
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
516
|
+
pure(tx, args.obligationId, `${ID.$typeName}`),
|
|
139
517
|
obj(tx, args.clock),
|
|
140
|
-
obj(tx, args.
|
|
518
|
+
obj(tx, args.maxRepayCoins),
|
|
141
519
|
],
|
|
142
520
|
});
|
|
143
521
|
}
|
|
144
|
-
|
|
522
|
+
/**
|
|
523
|
+
* Forgives a debt on an obligation, effectively reducing the borrow amount without requiring repayment.
|
|
524
|
+
*
|
|
525
|
+
* This is an admin-only function that can be used to handle bad debt or other special circumstances.
|
|
526
|
+
* It reduces the borrowed amount for a specific reserve within an obligation.
|
|
527
|
+
*
|
|
528
|
+
* # Arguments
|
|
529
|
+
*
|
|
530
|
+
* * `_` - The `LendingMarketOwnerCap` to authorize the operation.
|
|
531
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
532
|
+
* * `reserve_array_index` - The index of the reserve for which to forgive the debt.
|
|
533
|
+
* * `obligation_id` - The ID of the obligation to forgive the debt for.
|
|
534
|
+
* * `clock` - A reference to the `Clock`.
|
|
535
|
+
* * `max_forgive_amount` - The maximum amount of debt to forgive.
|
|
536
|
+
*
|
|
537
|
+
* # Panics
|
|
538
|
+
*
|
|
539
|
+
* This function will panic if:
|
|
540
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
541
|
+
* * `obligation_id` is not a valid key in the `obligations` table.
|
|
542
|
+
* * The obligation has stale oracle prices.
|
|
543
|
+
* * The `coin_type` of the reserve does not match the type of the debt being forgiven (EWrongType).
|
|
544
|
+
* * `reserve_array_index` is out of bounds.
|
|
545
|
+
* * If the forgiveness would leave the reserve's total supply below its ctoken supply in
|
|
546
|
+
* scaled units (`EForgiveWouldZeroBacking` from the `reserve` module).
|
|
547
|
+
*/
|
|
548
|
+
export function forgive(tx, typeArgs, args, options) {
|
|
145
549
|
return tx.moveCall({
|
|
146
|
-
target: `${
|
|
550
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::forgive`,
|
|
147
551
|
typeArguments: typeArgs,
|
|
148
552
|
arguments: [
|
|
553
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
149
554
|
obj(tx, args.lendingMarket),
|
|
150
555
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
151
|
-
|
|
556
|
+
pure(tx, args.obligationId, `${ID.$typeName}`),
|
|
557
|
+
obj(tx, args.clock),
|
|
558
|
+
pure(tx, args.maxForgiveAmount, `u64`),
|
|
152
559
|
],
|
|
153
560
|
});
|
|
154
561
|
}
|
|
155
|
-
|
|
562
|
+
/**
|
|
563
|
+
* Claims rewards earned by an obligation.
|
|
564
|
+
*
|
|
565
|
+
* This function allows an obligation owner to claim rewards that have accrued
|
|
566
|
+
* from either depositing or borrowing on a reserve.
|
|
567
|
+
*
|
|
568
|
+
* # Arguments
|
|
569
|
+
*
|
|
570
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
571
|
+
* * `cap` - The `ObligationOwnerCap` to authorize the operation.
|
|
572
|
+
* * `clock` - A reference to the `Clock`.
|
|
573
|
+
* * `reserve_id` - The array index of the reserve that is giving out the rewards.
|
|
574
|
+
* * `reward_index` - The index of the reward pool to claim from.
|
|
575
|
+
* * `is_deposit_reward` - A boolean indicating whether to claim deposit rewards (true) or borrow rewards (false).
|
|
576
|
+
*
|
|
577
|
+
* # Returns
|
|
578
|
+
*
|
|
579
|
+
* * `Coin<RewardType>` - A `Coin` containing the claimed rewards.
|
|
580
|
+
*
|
|
581
|
+
* # Panics
|
|
582
|
+
*
|
|
583
|
+
* This function will panic if:
|
|
584
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
585
|
+
* * It will also panic if the underlying `claim_rewards_by_obligation_id` panics.
|
|
586
|
+
*/
|
|
587
|
+
export function claimRewards(tx, typeArgs, args, options) {
|
|
156
588
|
return tx.moveCall({
|
|
157
|
-
target: `${
|
|
589
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::claim_rewards`,
|
|
158
590
|
typeArguments: typeArgs,
|
|
159
591
|
arguments: [
|
|
160
592
|
obj(tx, args.lendingMarket),
|
|
161
|
-
obj(tx, args.
|
|
162
|
-
|
|
163
|
-
|
|
593
|
+
obj(tx, args.cap),
|
|
594
|
+
obj(tx, args.clock),
|
|
595
|
+
pure(tx, args.reserveId, `u64`),
|
|
596
|
+
pure(tx, args.rewardIndex, `u64`),
|
|
597
|
+
pure(tx, args.isDepositReward, `bool`),
|
|
164
598
|
],
|
|
165
599
|
});
|
|
166
600
|
}
|
|
167
|
-
|
|
601
|
+
/**
|
|
602
|
+
* Claims rewards earned by an obligation and deposits them back into the obligation.
|
|
603
|
+
*
|
|
604
|
+
* This is a permissionless function that can be called by anyone to "crank" rewards for a given obligation.
|
|
605
|
+
* It first claims the rewards from the specified reward pool and then, if the obligation has a borrow of the
|
|
606
|
+
* same asset, it repays the borrow. The remaining rewards are deposited as liquidity into the specified
|
|
607
|
+
* reserve and the resulting CTokens are deposited into the obligation to be used as collateral.
|
|
608
|
+
*
|
|
609
|
+
* # Arguments
|
|
610
|
+
*
|
|
611
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
612
|
+
* * `obligation_id` - The ID of the obligation to claim rewards for and deposit into.
|
|
613
|
+
* * `clock` - A reference to the `Clock`.
|
|
614
|
+
* * `reward_reserve_id` - The array index of the reserve that is giving out the rewards.
|
|
615
|
+
* * `reward_index` - The index of the reward pool to claim from.
|
|
616
|
+
* * `is_deposit_reward` - A boolean indicating whether to claim deposit rewards (true) or borrow rewards (false).
|
|
617
|
+
* * `deposit_reserve_id` - The array index of the reserve to deposit the claimed rewards into.
|
|
618
|
+
*
|
|
619
|
+
* # Panics
|
|
620
|
+
*
|
|
621
|
+
* This function will panic if:
|
|
622
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
623
|
+
* * The reward period is not over.
|
|
624
|
+
* * The `coin_type` of the deposit reserve does not match the type of the reward.
|
|
625
|
+
* * It will also panic if the underlying `claim_rewards_by_obligation_id` or `repay` or `deposit_liquidity_and_mint_ctokens` panics.
|
|
626
|
+
* * If ctokens are outstanding but unclaimed spread fees have consumed the entire total
|
|
627
|
+
* supply, leaving them unbacked (`EReserveInDeficit` from the `reserve` module).
|
|
628
|
+
*
|
|
629
|
+
* For expired points campaign types: instead of claiming
|
|
630
|
+
* and depositing, force-closes the UserReward entry on the obligation. The pool reward must
|
|
631
|
+
* have been cancelled and drained first. deposit_reserve_id is ignored.
|
|
632
|
+
*/
|
|
633
|
+
export function claimRewardsAndDeposit(tx, typeArgs, args, options) {
|
|
168
634
|
return tx.moveCall({
|
|
169
|
-
target: `${
|
|
170
|
-
typeArguments:
|
|
635
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::claim_rewards_and_deposit`,
|
|
636
|
+
typeArguments: typeArgs,
|
|
171
637
|
arguments: [
|
|
172
|
-
obj(tx, args.
|
|
173
|
-
|
|
174
|
-
obj(tx, args.reserve),
|
|
638
|
+
obj(tx, args.lendingMarket),
|
|
639
|
+
pure(tx, args.obligationId, `${ID.$typeName}`),
|
|
175
640
|
obj(tx, args.clock),
|
|
641
|
+
pure(tx, args.rewardReserveId, `u64`),
|
|
642
|
+
pure(tx, args.rewardIndex, `u64`),
|
|
643
|
+
pure(tx, args.isDepositReward, `bool`),
|
|
644
|
+
pure(tx, args.depositReserveId, `u64`),
|
|
176
645
|
],
|
|
177
646
|
});
|
|
178
647
|
}
|
|
179
|
-
|
|
648
|
+
/**
|
|
649
|
+
* Initializes a staker for a SUI reserve.
|
|
650
|
+
*
|
|
651
|
+
* This function is used to set up a staker for a SUI reserve, which allows the reserve
|
|
652
|
+
* to participate in staking and earn rewards. It can only be called by the owner of the
|
|
653
|
+
* lending market.
|
|
654
|
+
*
|
|
655
|
+
* # Arguments
|
|
656
|
+
*
|
|
657
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
658
|
+
* * `_` - The `LendingMarketOwnerCap` to authorize the operation.
|
|
659
|
+
* * `sui_reserve_array_index` - The index of the SUI reserve to initialize the staker for.
|
|
660
|
+
* * `treasury_cap` - The `TreasuryCap` for the staker.
|
|
661
|
+
*
|
|
662
|
+
* # Panics
|
|
663
|
+
*
|
|
664
|
+
* This function will panic if:
|
|
665
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
666
|
+
* * The reserve at `sui_reserve_array_index` is not a SUI reserve (EWrongType).
|
|
667
|
+
* * `sui_reserve_array_index` is out of bounds.
|
|
668
|
+
*/
|
|
669
|
+
export function initStaker(tx, typeArgs, args, options) {
|
|
180
670
|
return tx.moveCall({
|
|
181
|
-
target: `${
|
|
182
|
-
typeArguments:
|
|
671
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::init_staker`,
|
|
672
|
+
typeArguments: typeArgs,
|
|
183
673
|
arguments: [
|
|
184
674
|
obj(tx, args.lendingMarket),
|
|
675
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
185
676
|
pure(tx, args.suiReserveArrayIndex, `u64`),
|
|
186
|
-
obj(tx, args.
|
|
677
|
+
obj(tx, args.treasuryCap),
|
|
187
678
|
],
|
|
188
679
|
});
|
|
189
680
|
}
|
|
190
|
-
|
|
681
|
+
/**
|
|
682
|
+
* Rebalances a staker by staking or unstaking SUI to match the target staking amount.
|
|
683
|
+
*
|
|
684
|
+
* This function is a wrapper around `reserve::rebalance_staker`. It ensures that the
|
|
685
|
+
* lending market is on the correct version and that the specified reserve is a SUI
|
|
686
|
+
* reserve before proceeding with the rebalancing.
|
|
687
|
+
*
|
|
688
|
+
* # Arguments
|
|
689
|
+
*
|
|
690
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
691
|
+
* * `sui_reserve_array_index` - The index of the SUI reserve to rebalance.
|
|
692
|
+
* * `system_state` - A mutable reference to the `SuiSystemState`.
|
|
693
|
+
*
|
|
694
|
+
* # Panics
|
|
695
|
+
*
|
|
696
|
+
* This function will panic if:
|
|
697
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
698
|
+
* * The reserve at `sui_reserve_array_index` is not a SUI reserve (EWrongType).
|
|
699
|
+
* * `sui_reserve_array_index` is out of bounds.
|
|
700
|
+
*/
|
|
701
|
+
export function rebalanceStaker(tx, typeArg, args, options) {
|
|
191
702
|
return tx.moveCall({
|
|
192
|
-
target: `${
|
|
703
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::rebalance_staker`,
|
|
193
704
|
typeArguments: [typeArg],
|
|
194
705
|
arguments: [
|
|
195
706
|
obj(tx, args.lendingMarket),
|
|
196
707
|
pure(tx, args.suiReserveArrayIndex, `u64`),
|
|
197
|
-
obj(tx, args.liquidityRequest),
|
|
198
708
|
obj(tx, args.systemState),
|
|
199
709
|
],
|
|
200
710
|
});
|
|
201
711
|
}
|
|
202
|
-
|
|
712
|
+
/**
|
|
713
|
+
* Unstakes SUI from a staker.
|
|
714
|
+
*
|
|
715
|
+
* This function is a wrapper around `reserve::unstake_sui_from_staker`. It ensures that the
|
|
716
|
+
* lending market is on the correct version and that the specified reserve is a SUI
|
|
717
|
+
* reserve before proceeding with the unstaking.
|
|
718
|
+
*
|
|
719
|
+
* # Arguments
|
|
720
|
+
*
|
|
721
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
722
|
+
* * `sui_reserve_array_index` - The index of the SUI reserve to unstake from.
|
|
723
|
+
* * `liquidity_request` - A reference to the `LiquidityRequest` for the unstake.
|
|
724
|
+
* * `system_state` - A mutable reference to the `SuiSystemState`.
|
|
725
|
+
*
|
|
726
|
+
* # Panics
|
|
727
|
+
*
|
|
728
|
+
* This function will panic if:
|
|
729
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
730
|
+
* * `sui_reserve_array_index` is out of bounds.
|
|
731
|
+
*/
|
|
732
|
+
export function unstakeSuiFromStaker(tx, typeArg, args, options) {
|
|
203
733
|
return tx.moveCall({
|
|
204
|
-
target: `${
|
|
205
|
-
typeArguments:
|
|
734
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::unstake_sui_from_staker`,
|
|
735
|
+
typeArguments: [typeArg],
|
|
206
736
|
arguments: [
|
|
207
|
-
obj(tx, args.lendingMarketOwnerCap),
|
|
208
737
|
obj(tx, args.lendingMarket),
|
|
209
|
-
pure(tx, args.
|
|
210
|
-
obj(tx, args.
|
|
738
|
+
pure(tx, args.suiReserveArrayIndex, `u64`),
|
|
739
|
+
obj(tx, args.liquidityRequest),
|
|
740
|
+
obj(tx, args.systemState),
|
|
211
741
|
],
|
|
212
742
|
});
|
|
213
743
|
}
|
|
214
|
-
|
|
744
|
+
/** Get a reference to the lending market's reserves vector. */
|
|
745
|
+
export function reserves(tx, typeArg, lendingMarket, options) {
|
|
215
746
|
return tx.moveCall({
|
|
216
|
-
target: `${
|
|
217
|
-
typeArguments:
|
|
747
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::reserves`,
|
|
748
|
+
typeArguments: [typeArg],
|
|
749
|
+
arguments: [obj(tx, lendingMarket)],
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
export function maxBorrowAmount(tx, typeArg, args, options) {
|
|
753
|
+
return tx.moveCall({
|
|
754
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::max_borrow_amount`,
|
|
755
|
+
typeArguments: [typeArg],
|
|
218
756
|
arguments: [
|
|
219
|
-
obj(tx, args.
|
|
220
|
-
|
|
221
|
-
obj(tx, args.
|
|
757
|
+
obj(tx, args.rateLimiter),
|
|
758
|
+
obj(tx, args.obligation),
|
|
759
|
+
obj(tx, args.reserve),
|
|
222
760
|
obj(tx, args.clock),
|
|
223
|
-
pure(tx, args.amount, `u64`),
|
|
224
761
|
],
|
|
225
762
|
});
|
|
226
763
|
}
|
|
227
|
-
export function
|
|
764
|
+
export function maxWithdrawAmount(tx, typeArg, args, options) {
|
|
228
765
|
return tx.moveCall({
|
|
229
|
-
target: `${
|
|
766
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::max_withdraw_amount`,
|
|
230
767
|
typeArguments: [typeArg],
|
|
231
768
|
arguments: [
|
|
232
|
-
obj(tx, args.
|
|
233
|
-
|
|
769
|
+
obj(tx, args.rateLimiter),
|
|
770
|
+
obj(tx, args.obligation),
|
|
771
|
+
obj(tx, args.reserve),
|
|
772
|
+
obj(tx, args.clock),
|
|
234
773
|
],
|
|
235
774
|
});
|
|
236
775
|
}
|
|
237
|
-
|
|
776
|
+
/** Get the obligation ID from an `ObligationOwnerCap`. */
|
|
777
|
+
export function obligationId(tx, typeArg, cap, options) {
|
|
238
778
|
return tx.moveCall({
|
|
239
|
-
target: `${
|
|
779
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::obligation_id`,
|
|
240
780
|
typeArguments: [typeArg],
|
|
241
|
-
arguments: [obj(tx,
|
|
781
|
+
arguments: [obj(tx, cap)],
|
|
242
782
|
});
|
|
243
783
|
}
|
|
244
|
-
|
|
784
|
+
/**
|
|
785
|
+
* Get the array index of a reserve by its coin type.
|
|
786
|
+
* slow function. use sparingly.
|
|
787
|
+
*/
|
|
788
|
+
export function reserveArrayIndex(tx, typeArgs, lendingMarket, options) {
|
|
245
789
|
return tx.moveCall({
|
|
246
|
-
target: `${
|
|
790
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::reserve_array_index`,
|
|
247
791
|
typeArguments: typeArgs,
|
|
248
792
|
arguments: [obj(tx, lendingMarket)],
|
|
249
793
|
});
|
|
250
794
|
}
|
|
251
|
-
|
|
795
|
+
/** Get a reference to a reserve by its coin type. */
|
|
796
|
+
export function reserve(tx, typeArgs, lendingMarket, options) {
|
|
252
797
|
return tx.moveCall({
|
|
253
|
-
target: `${
|
|
798
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::reserve`,
|
|
254
799
|
typeArguments: typeArgs,
|
|
255
|
-
arguments: [
|
|
256
|
-
obj(tx, args.lendingMarketOwnerCap),
|
|
257
|
-
obj(tx, args.lendingMarket),
|
|
258
|
-
pure(tx, args.reserveArrayIndex, `u64`),
|
|
259
|
-
pure(tx, args.obligationId, `${ID.$typeName}`),
|
|
260
|
-
obj(tx, args.clock),
|
|
261
|
-
pure(tx, args.maxForgiveAmount, `u64`),
|
|
262
|
-
],
|
|
800
|
+
arguments: [obj(tx, lendingMarket)],
|
|
263
801
|
});
|
|
264
802
|
}
|
|
265
|
-
|
|
803
|
+
/**
|
|
804
|
+
* Seeds a `ReserveConfigBuilder` from a reserve's live on-chain config in a
|
|
805
|
+
* single call, so the `&ReserveConfig` `reserve::config` returns never has
|
|
806
|
+
* to cross a PTB command boundary into `reserve_config::from`.
|
|
807
|
+
*/
|
|
808
|
+
export function reserveConfigBuilder(tx, typeArgs, lendingMarket, options) {
|
|
266
809
|
return tx.moveCall({
|
|
267
|
-
target: `${
|
|
810
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::reserve_config_builder`,
|
|
268
811
|
typeArguments: typeArgs,
|
|
812
|
+
arguments: [obj(tx, lendingMarket)],
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
/** Get a reference to an obligation by its ID. */
|
|
816
|
+
export function obligation(tx, typeArg, args, options) {
|
|
817
|
+
return tx.moveCall({
|
|
818
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::obligation`,
|
|
819
|
+
typeArguments: [typeArg],
|
|
269
820
|
arguments: [
|
|
270
821
|
obj(tx, args.lendingMarket),
|
|
271
822
|
pure(tx, args.obligationId, `${ID.$typeName}`),
|
|
272
|
-
pure(tx, args.repayReserveArrayIndex, `u64`),
|
|
273
|
-
pure(tx, args.withdrawReserveArrayIndex, `u64`),
|
|
274
|
-
obj(tx, args.clock),
|
|
275
|
-
obj(tx, args.repayCoins),
|
|
276
823
|
],
|
|
277
824
|
});
|
|
278
825
|
}
|
|
279
|
-
|
|
826
|
+
/** Get the fee receiver address. */
|
|
827
|
+
export function feeReceiver(tx, typeArg, lendingMarket, options) {
|
|
280
828
|
return tx.moveCall({
|
|
281
|
-
target: `${
|
|
829
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::fee_receiver`,
|
|
282
830
|
typeArguments: [typeArg],
|
|
283
831
|
arguments: [obj(tx, lendingMarket)],
|
|
284
832
|
});
|
|
285
833
|
}
|
|
286
|
-
|
|
834
|
+
/** Get the amount of a rate limiter exemption. */
|
|
835
|
+
export function rateLimiterExemptionAmount(tx, typeArgs, exemption, options) {
|
|
836
|
+
return tx.moveCall({
|
|
837
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::rate_limiter_exemption_amount`,
|
|
838
|
+
typeArguments: typeArgs,
|
|
839
|
+
arguments: [obj(tx, exemption)],
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
/** Migrates the lending market to the current version. */
|
|
843
|
+
export function migrate(tx, typeArg, args, options) {
|
|
287
844
|
return tx.moveCall({
|
|
288
|
-
target: `${
|
|
845
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::migrate`,
|
|
289
846
|
typeArguments: [typeArg],
|
|
290
847
|
arguments: [
|
|
291
|
-
obj(tx, args.
|
|
292
|
-
obj(tx, args.
|
|
293
|
-
obj(tx, args.reserve),
|
|
294
|
-
obj(tx, args.clock),
|
|
848
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
849
|
+
obj(tx, args.lendingMarket),
|
|
295
850
|
],
|
|
296
851
|
});
|
|
297
852
|
}
|
|
298
|
-
|
|
853
|
+
/**
|
|
854
|
+
* Deprecated tombstone — kept only because Sui's upgrade compatibility rules
|
|
855
|
+
* freeze a published function's signature. Pyth froze every legacy on-chain
|
|
856
|
+
* feed at the 2026-08-26 cutover; nothing has written to one since, so this
|
|
857
|
+
* now aborts unconditionally instead of creating a reserve seeded from a
|
|
858
|
+
* permanently-stale price. Use `add_reserve_pro_compatible`.
|
|
859
|
+
*/
|
|
860
|
+
export function addReserve(tx, typeArgs, args, options) {
|
|
299
861
|
return tx.moveCall({
|
|
300
|
-
target: `${
|
|
862
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::add_reserve`,
|
|
301
863
|
typeArguments: typeArgs,
|
|
302
864
|
arguments: [
|
|
865
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
303
866
|
obj(tx, args.lendingMarket),
|
|
304
|
-
|
|
305
|
-
|
|
867
|
+
obj(tx, args.priceInfoObject),
|
|
868
|
+
obj(tx, args.reserveConfig),
|
|
869
|
+
obj(tx, args.coinMetadata),
|
|
306
870
|
obj(tx, args.clock),
|
|
307
|
-
obj(tx, args.maxRepayCoins),
|
|
308
871
|
],
|
|
309
872
|
});
|
|
310
873
|
}
|
|
311
|
-
|
|
874
|
+
/**
|
|
875
|
+
* Deprecated tombstone, for the same reason as `add_reserve`. Use
|
|
876
|
+
* `add_reserve_v2_pro_compatible`.
|
|
877
|
+
*/
|
|
878
|
+
export function addReserveV2(tx, typeArgs, args, options) {
|
|
312
879
|
return tx.moveCall({
|
|
313
|
-
target: `${
|
|
314
|
-
typeArguments:
|
|
315
|
-
arguments: [
|
|
880
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::add_reserve_v2`,
|
|
881
|
+
typeArguments: typeArgs,
|
|
882
|
+
arguments: [
|
|
883
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
884
|
+
obj(tx, args.lendingMarket),
|
|
885
|
+
obj(tx, args.priceInfoObject),
|
|
886
|
+
obj(tx, args.reserveConfig),
|
|
887
|
+
obj(tx, args.currency),
|
|
888
|
+
obj(tx, args.clock),
|
|
889
|
+
],
|
|
316
890
|
});
|
|
317
891
|
}
|
|
318
|
-
|
|
892
|
+
/**
|
|
893
|
+
* `add_reserve` against the upgraded Pyth package. Only this path can
|
|
894
|
+
* consume payloads after the 2026-08-18 cutover.
|
|
895
|
+
*/
|
|
896
|
+
export function addReserveProCompatible(tx, typeArgs, args, options) {
|
|
319
897
|
return tx.moveCall({
|
|
320
|
-
target: `${
|
|
898
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::add_reserve_pro_compatible`,
|
|
321
899
|
typeArguments: typeArgs,
|
|
322
900
|
arguments: [
|
|
323
901
|
obj(tx, args.lendingMarketOwnerCap),
|
|
@@ -329,193 +907,529 @@ export function addReserve(tx, typeArgs, args) {
|
|
|
329
907
|
],
|
|
330
908
|
});
|
|
331
909
|
}
|
|
332
|
-
|
|
910
|
+
/**
|
|
911
|
+
* `add_reserve_v2` against the upgraded Pyth package. Only this path can
|
|
912
|
+
* consume payloads after the 2026-08-18 cutover.
|
|
913
|
+
*/
|
|
914
|
+
export function addReserveV2ProCompatible(tx, typeArgs, args, options) {
|
|
333
915
|
return tx.moveCall({
|
|
334
|
-
target: `${
|
|
916
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::add_reserve_v2_pro_compatible`,
|
|
335
917
|
typeArguments: typeArgs,
|
|
336
918
|
arguments: [
|
|
337
919
|
obj(tx, args.lendingMarketOwnerCap),
|
|
338
920
|
obj(tx, args.lendingMarket),
|
|
339
921
|
obj(tx, args.priceInfo),
|
|
340
922
|
obj(tx, args.config),
|
|
341
|
-
obj(tx, args.
|
|
923
|
+
obj(tx, args.currency),
|
|
342
924
|
obj(tx, args.clock),
|
|
343
925
|
],
|
|
344
926
|
});
|
|
345
927
|
}
|
|
346
|
-
|
|
928
|
+
/**
|
|
929
|
+
* Updates the configuration of a reserve.
|
|
930
|
+
*
|
|
931
|
+
* This function allows the owner of the lending market to update the configuration of a specific reserve.
|
|
932
|
+
* It can only be called by the owner of the lending market.
|
|
933
|
+
*
|
|
934
|
+
* # Arguments
|
|
935
|
+
*
|
|
936
|
+
* * `_` - The `LendingMarketOwnerCap` to authorize the operation.
|
|
937
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
938
|
+
* * `reserve_array_index` - The index of the reserve to update.
|
|
939
|
+
* * `config` - The new configuration for the reserve.
|
|
940
|
+
*
|
|
941
|
+
* # Panics
|
|
942
|
+
*
|
|
943
|
+
* This function will panic if:
|
|
944
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
945
|
+
* * `reserve_array_index` is out of bounds.
|
|
946
|
+
* * The `coin_type` of the reserve does not match the type `T` (EWrongType).
|
|
947
|
+
*/
|
|
948
|
+
export function updateReserveConfig(tx, typeArgs, args, options) {
|
|
347
949
|
return tx.moveCall({
|
|
348
|
-
target: `${
|
|
950
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::update_reserve_config`,
|
|
349
951
|
typeArguments: typeArgs,
|
|
350
952
|
arguments: [
|
|
953
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
351
954
|
obj(tx, args.lendingMarket),
|
|
352
955
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
353
|
-
obj(tx, args.
|
|
354
|
-
obj(tx, args.clock),
|
|
355
|
-
pure(tx, args.amount, `u64`),
|
|
956
|
+
obj(tx, args.config),
|
|
356
957
|
],
|
|
357
958
|
});
|
|
358
959
|
}
|
|
359
|
-
|
|
960
|
+
/**
|
|
961
|
+
* Sets a reserve's price guard, bounding how far its price and smoothed price may
|
|
962
|
+
* move per `min_update_interval_s`. Seeds both anchors from the reserve's current
|
|
963
|
+
* prices, so widening the band and refreshing is how the owner admits a genuine move.
|
|
964
|
+
*
|
|
965
|
+
* # Panics
|
|
966
|
+
*
|
|
967
|
+
* This function will panic if:
|
|
968
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
969
|
+
* * `reserve_array_index` is out of bounds.
|
|
970
|
+
* * The `coin_type` of the reserve does not match the type `T` (EWrongType).
|
|
971
|
+
* * The band reaches the reserve's liquidation buffer (EPriceBandAboveLiquidationBuffer).
|
|
972
|
+
*/
|
|
973
|
+
export function setReservePriceGuard(tx, typeArgs, args, options) {
|
|
360
974
|
return tx.moveCall({
|
|
361
|
-
target: `${
|
|
975
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::set_reserve_price_guard`,
|
|
362
976
|
typeArguments: typeArgs,
|
|
363
977
|
arguments: [
|
|
364
978
|
obj(tx, args.lendingMarketOwnerCap),
|
|
365
979
|
obj(tx, args.lendingMarket),
|
|
366
980
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
367
|
-
|
|
981
|
+
pure(tx, args.maxPriceChangeBps, `u64`),
|
|
982
|
+
pure(tx, args.minUpdateIntervalS, `u64`),
|
|
368
983
|
obj(tx, args.clock),
|
|
369
984
|
],
|
|
370
985
|
});
|
|
371
986
|
}
|
|
372
|
-
|
|
987
|
+
/**
|
|
988
|
+
* Deprecated tombstone — kept only because Sui's upgrade compatibility rules
|
|
989
|
+
* freeze a published function's signature. Pyth froze every legacy on-chain
|
|
990
|
+
* feed at the 2026-08-26 cutover; nothing has written to one since, so this
|
|
991
|
+
* now aborts unconditionally instead of repointing a reserve at a
|
|
992
|
+
* permanently-stale feed. Use `change_reserve_price_feed_pro_compatible`.
|
|
993
|
+
*/
|
|
994
|
+
export function changeReservePriceFeed(tx, typeArgs, args, options) {
|
|
373
995
|
return tx.moveCall({
|
|
374
|
-
target: `${
|
|
996
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::change_reserve_price_feed`,
|
|
375
997
|
typeArguments: typeArgs,
|
|
376
998
|
arguments: [
|
|
999
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
377
1000
|
obj(tx, args.lendingMarket),
|
|
378
|
-
pure(tx, args.
|
|
1001
|
+
pure(tx, args.u64, `u64`),
|
|
1002
|
+
obj(tx, args.priceInfoObject),
|
|
379
1003
|
obj(tx, args.clock),
|
|
380
|
-
pure(tx, args.rewardReserveId, `u64`),
|
|
381
|
-
pure(tx, args.rewardIndex, `u64`),
|
|
382
|
-
pure(tx, args.isDepositReward, `bool`),
|
|
383
|
-
pure(tx, args.depositReserveId, `u64`),
|
|
384
1004
|
],
|
|
385
1005
|
});
|
|
386
1006
|
}
|
|
387
|
-
|
|
1007
|
+
/**
|
|
1008
|
+
* `change_reserve_price_feed` against the upgraded Pyth package. Same
|
|
1009
|
+
* owner-cap gate and coin-type check; only the object's package differs.
|
|
1010
|
+
*/
|
|
1011
|
+
export function changeReservePriceFeedProCompatible(tx, typeArgs, args, options) {
|
|
388
1012
|
return tx.moveCall({
|
|
389
|
-
target: `${
|
|
1013
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::change_reserve_price_feed_pro_compatible`,
|
|
390
1014
|
typeArguments: typeArgs,
|
|
391
1015
|
arguments: [
|
|
1016
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
392
1017
|
obj(tx, args.lendingMarket),
|
|
393
|
-
pure(tx, args.
|
|
1018
|
+
pure(tx, args.reserveArrayIndex, `u64`),
|
|
1019
|
+
obj(tx, args.priceInfoObj),
|
|
394
1020
|
obj(tx, args.clock),
|
|
395
|
-
|
|
396
|
-
|
|
1021
|
+
],
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Adds a new reward pool to a reserve for either deposits or borrows.
|
|
1026
|
+
*
|
|
1027
|
+
* This function allows the owner of the lending market to incentivize users by adding rewards
|
|
1028
|
+
* to a specific reserve. The rewards are distributed over a specified time period.
|
|
1029
|
+
*
|
|
1030
|
+
* # Arguments
|
|
1031
|
+
*
|
|
1032
|
+
* * `_` - The `LendingMarketOwnerCap` to authorize the operation.
|
|
1033
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
1034
|
+
* * `reserve_array_index` - The index of the reserve to add the reward pool to.
|
|
1035
|
+
* * `is_deposit_reward` - A boolean indicating whether the reward is for deposits (`true`) or borrows (`false`).
|
|
1036
|
+
* * `rewards` - The `Coin` containing the total amount of rewards to be distributed.
|
|
1037
|
+
* * `start_time_ms` - The timestamp in milliseconds when the reward distribution starts.
|
|
1038
|
+
* * `end_time_ms` - The timestamp in milliseconds when the reward distribution ends.
|
|
1039
|
+
* * `clock` - A reference to the `Clock`.
|
|
1040
|
+
*
|
|
1041
|
+
* # Panics
|
|
1042
|
+
*
|
|
1043
|
+
* This function will panic if:
|
|
1044
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
1045
|
+
* * `reserve_array_index` is out of bounds.
|
|
1046
|
+
* * The underlying `liquidity_mining::add_pool_reward` function panics (e.g., if `start_time_ms` >= `end_time_ms` or reward amount is zero).
|
|
1047
|
+
*/
|
|
1048
|
+
export function addPoolReward(tx, typeArgs, args, options) {
|
|
1049
|
+
return tx.moveCall({
|
|
1050
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::add_pool_reward`,
|
|
1051
|
+
typeArguments: typeArgs,
|
|
1052
|
+
arguments: [
|
|
1053
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
1054
|
+
obj(tx, args.lendingMarket),
|
|
1055
|
+
pure(tx, args.reserveArrayIndex, `u64`),
|
|
397
1056
|
pure(tx, args.isDepositReward, `bool`),
|
|
398
|
-
|
|
1057
|
+
obj(tx, args.rewards),
|
|
1058
|
+
pure(tx, args.startTimeMs, `u64`),
|
|
1059
|
+
pure(tx, args.endTimeMs, `u64`),
|
|
1060
|
+
obj(tx, args.clock),
|
|
399
1061
|
],
|
|
400
1062
|
});
|
|
401
1063
|
}
|
|
402
|
-
|
|
1064
|
+
/**
|
|
1065
|
+
* Cancels a reward pool from a reserve.
|
|
1066
|
+
*
|
|
1067
|
+
* This is an admin-only function that allows the lending market owner to cancel a reward pool
|
|
1068
|
+
* that is currently active. When a reward pool is cancelled, any unallocated rewards are
|
|
1069
|
+
* returned to the owner.
|
|
1070
|
+
*
|
|
1071
|
+
* # Arguments
|
|
1072
|
+
*
|
|
1073
|
+
* * `_` - The `LendingMarketOwnerCap` to authorize the operation.
|
|
1074
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
1075
|
+
* * `reserve_array_index` - The index of the reserve to cancel the reward pool from.
|
|
1076
|
+
* * `is_deposit_reward` - A boolean indicating whether the reward is for deposits (`true`) or borrows (`false`).
|
|
1077
|
+
* * `reward_index` - The index of the reward pool to cancel.
|
|
1078
|
+
* * `clock` - A reference to the `Clock`.
|
|
1079
|
+
*
|
|
1080
|
+
* # Returns
|
|
1081
|
+
*
|
|
1082
|
+
* * `Coin<RewardType>` - A `Coin` containing the unallocated rewards from the cancelled pool.
|
|
1083
|
+
*
|
|
1084
|
+
* # Panics
|
|
1085
|
+
*
|
|
1086
|
+
* This function will panic if:
|
|
1087
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
1088
|
+
* * `reserve_array_index` is out of bounds.
|
|
1089
|
+
* * The underlying `liquidity_mining::cancel_pool_reward` function panics.
|
|
1090
|
+
*/
|
|
1091
|
+
export function cancelPoolReward(tx, typeArgs, args, options) {
|
|
403
1092
|
return tx.moveCall({
|
|
404
|
-
target: `${
|
|
405
|
-
typeArguments:
|
|
406
|
-
arguments: [
|
|
1093
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::cancel_pool_reward`,
|
|
1094
|
+
typeArguments: typeArgs,
|
|
1095
|
+
arguments: [
|
|
1096
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
1097
|
+
obj(tx, args.lendingMarket),
|
|
1098
|
+
pure(tx, args.reserveArrayIndex, `u64`),
|
|
1099
|
+
pure(tx, args.isDepositReward, `bool`),
|
|
1100
|
+
pure(tx, args.rewardIndex, `u64`),
|
|
1101
|
+
obj(tx, args.clock),
|
|
1102
|
+
],
|
|
407
1103
|
});
|
|
408
1104
|
}
|
|
409
|
-
|
|
1105
|
+
/**
|
|
1106
|
+
* Closes a reward pool from a reserve after its distribution period has ended.
|
|
1107
|
+
*
|
|
1108
|
+
* This is an admin-only function that allows the lending market owner to close a reward pool
|
|
1109
|
+
* that has finished distributing rewards. When a reward pool is closed, any unallocated rewards
|
|
1110
|
+
* due to rounding or other factors are returned to the owner. This function can only be called
|
|
1111
|
+
* after the pool's `end_time_ms` has passed.
|
|
1112
|
+
*
|
|
1113
|
+
* # Arguments
|
|
1114
|
+
*
|
|
1115
|
+
* * `_` - The `LendingMarketOwnerCap` to authorize the operation.
|
|
1116
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
1117
|
+
* * `reserve_array_index` - The index of the reserve to close the reward pool from.
|
|
1118
|
+
* * `is_deposit_reward` - A boolean indicating whether the reward is for deposits (`true`) or borrows (`false`).
|
|
1119
|
+
* * `reward_index` - The index of the reward pool to close.
|
|
1120
|
+
* * `clock` - A reference to the `Clock`.
|
|
1121
|
+
*
|
|
1122
|
+
* # Returns
|
|
1123
|
+
*
|
|
1124
|
+
* * `Coin<RewardType>` - A `Coin` containing the unallocated rewards from the closed pool.
|
|
1125
|
+
*
|
|
1126
|
+
* # Panics
|
|
1127
|
+
*
|
|
1128
|
+
* This function will panic if:
|
|
1129
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
1130
|
+
* * `reserve_array_index` is out of bounds.
|
|
1131
|
+
* * The underlying `liquidity_mining::close_pool_reward` function panics (e.g., if the reward period is not over).
|
|
1132
|
+
*/
|
|
1133
|
+
export function closePoolReward(tx, typeArgs, args, options) {
|
|
410
1134
|
return tx.moveCall({
|
|
411
|
-
target: `${
|
|
1135
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::close_pool_reward`,
|
|
412
1136
|
typeArguments: typeArgs,
|
|
413
1137
|
arguments: [
|
|
1138
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
414
1139
|
obj(tx, args.lendingMarket),
|
|
415
1140
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
416
|
-
|
|
1141
|
+
pure(tx, args.isDepositReward, `bool`),
|
|
1142
|
+
pure(tx, args.rewardIndex, `u64`),
|
|
417
1143
|
obj(tx, args.clock),
|
|
418
|
-
obj(tx, args.deposit),
|
|
419
1144
|
],
|
|
420
1145
|
});
|
|
421
1146
|
}
|
|
422
|
-
|
|
1147
|
+
/**
|
|
1148
|
+
* Drains all remaining balance from a Suilend/Steamm points reward after its period has ended.
|
|
1149
|
+
* UserReward entries are cleaned up when users next interact with the protocol.
|
|
1150
|
+
* cancel_pool_reward must be called first to stop accumulation, then drain_points_reward to reclaim the remaining balance.
|
|
1151
|
+
*/
|
|
1152
|
+
export function drainPointsReward(tx, typeArgs, args, options) {
|
|
423
1153
|
return tx.moveCall({
|
|
424
|
-
target: `${
|
|
1154
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::drain_points_reward`,
|
|
425
1155
|
typeArguments: typeArgs,
|
|
426
1156
|
arguments: [
|
|
1157
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
427
1158
|
obj(tx, args.lendingMarket),
|
|
428
1159
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
429
|
-
pure(tx, args.
|
|
1160
|
+
pure(tx, args.isDepositReward, `bool`),
|
|
1161
|
+
pure(tx, args.rewardIndex, `u64`),
|
|
430
1162
|
obj(tx, args.clock),
|
|
431
|
-
obj(tx, args.deposit),
|
|
432
1163
|
],
|
|
433
1164
|
});
|
|
434
1165
|
}
|
|
435
|
-
|
|
1166
|
+
/**
|
|
1167
|
+
* Updates the rate limiter configuration.
|
|
1168
|
+
*
|
|
1169
|
+
* This is an admin-only function that allows the lending market owner to update the rate
|
|
1170
|
+
* limiter configuration. The new configuration will replace the existing one.
|
|
1171
|
+
*
|
|
1172
|
+
* # Arguments
|
|
1173
|
+
*
|
|
1174
|
+
* * `_` - The `LendingMarketOwnerCap` to authorize the operation.
|
|
1175
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
1176
|
+
* * `clock` - A reference to the `Clock` to get the current timestamp.
|
|
1177
|
+
* * `config` - The new `RateLimiterConfig` to apply.
|
|
1178
|
+
*
|
|
1179
|
+
* # Panics
|
|
1180
|
+
*
|
|
1181
|
+
* This function will panic if:
|
|
1182
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
1183
|
+
*/
|
|
1184
|
+
export function updateRateLimiterConfig(tx, typeArg, args, options) {
|
|
436
1185
|
return tx.moveCall({
|
|
437
|
-
target: `${
|
|
1186
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::update_rate_limiter_config`,
|
|
438
1187
|
typeArguments: [typeArg],
|
|
439
|
-
arguments: [
|
|
1188
|
+
arguments: [
|
|
1189
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
1190
|
+
obj(tx, args.lendingMarket),
|
|
1191
|
+
obj(tx, args.clock),
|
|
1192
|
+
obj(tx, args.config),
|
|
1193
|
+
],
|
|
440
1194
|
});
|
|
441
1195
|
}
|
|
442
|
-
|
|
1196
|
+
/**
|
|
1197
|
+
* Sets the fee receivers for the lending market.
|
|
1198
|
+
*
|
|
1199
|
+
* This is an admin-only function that allows the lending market owner to set the fee receivers
|
|
1200
|
+
* and their respective weights for distributing protocol fees. The fees are distributed
|
|
1201
|
+
* proportionally based on these weights.
|
|
1202
|
+
*
|
|
1203
|
+
* # Arguments
|
|
1204
|
+
*
|
|
1205
|
+
* * `_` - The `LendingMarketOwnerCap` to authorize the operation.
|
|
1206
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
1207
|
+
* * `receivers` - A vector of addresses that will receive the fees.
|
|
1208
|
+
* * `weights` - A vector of weights corresponding to each receiver.
|
|
1209
|
+
*
|
|
1210
|
+
* # Panics
|
|
1211
|
+
*
|
|
1212
|
+
* This function will panic if:
|
|
1213
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
1214
|
+
* * The `receivers` and `weights` vectors do not have the same length (EInvalidFeeReceivers).
|
|
1215
|
+
* * The `receivers` vector is empty (EInvalidFeeReceivers).
|
|
1216
|
+
* * The sum of `weights` is zero (EInvalidFeeReceivers).
|
|
1217
|
+
*/
|
|
1218
|
+
export function setFeeReceivers(tx, typeArg, args, options) {
|
|
443
1219
|
return tx.moveCall({
|
|
444
|
-
target: `${
|
|
1220
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::set_fee_receivers`,
|
|
445
1221
|
typeArguments: [typeArg],
|
|
446
1222
|
arguments: [
|
|
447
1223
|
obj(tx, args.lendingMarketOwnerCap),
|
|
448
1224
|
obj(tx, args.lendingMarket),
|
|
449
|
-
pure(tx, args.
|
|
1225
|
+
pure(tx, args.receivers, `vector<address>`),
|
|
1226
|
+
pure(tx, args.weights, `vector<u64>`),
|
|
450
1227
|
],
|
|
451
1228
|
});
|
|
452
1229
|
}
|
|
453
|
-
|
|
1230
|
+
/**
|
|
1231
|
+
* Claims the fees from a reserve and distributes them to the fee receivers.
|
|
1232
|
+
*
|
|
1233
|
+
* This is a permissionless entry function that can be called by anyone to trigger the
|
|
1234
|
+
* distribution of accumulated protocol fees from a specific reserve. The fees, which
|
|
1235
|
+
* can be in both the underlying asset and cTokens, are transferred to the fee receivers
|
|
1236
|
+
* according to the weights configured via `set_fee_receivers`.
|
|
1237
|
+
*
|
|
1238
|
+
* # Arguments
|
|
1239
|
+
*
|
|
1240
|
+
* * `lending_market` - A mutable reference to the `LendingMarket`.
|
|
1241
|
+
* * `reserve_array_index` - The index of the reserve to claim fees from.
|
|
1242
|
+
* * `system_state` - A mutable reference to the `SuiSystemState`, required for claiming staking rewards.
|
|
1243
|
+
*
|
|
1244
|
+
* # Panics
|
|
1245
|
+
*
|
|
1246
|
+
* This function will panic if:
|
|
1247
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
1248
|
+
* * The generic type `T` does not match the coin type of the reserve at `reserve_array_index` (EWrongType).
|
|
1249
|
+
* * `reserve_array_index` is out of bounds.
|
|
1250
|
+
* * The `FeeReceivers` dynamic field has not been set on the lending market.
|
|
1251
|
+
*/
|
|
1252
|
+
export function claimFees(tx, typeArgs, args, options) {
|
|
454
1253
|
return tx.moveCall({
|
|
455
|
-
target: `${
|
|
1254
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::claim_fees`,
|
|
456
1255
|
typeArguments: typeArgs,
|
|
457
|
-
arguments: [
|
|
1256
|
+
arguments: [
|
|
1257
|
+
obj(tx, args.lendingMarket),
|
|
1258
|
+
pure(tx, args.reserveArrayIndex, `u64`),
|
|
1259
|
+
obj(tx, args.systemState),
|
|
1260
|
+
],
|
|
458
1261
|
});
|
|
459
1262
|
}
|
|
460
|
-
|
|
1263
|
+
/**
|
|
1264
|
+
* Creates a new obligation owner cap for an existing obligation.
|
|
1265
|
+
*
|
|
1266
|
+
* This is an admin-only function that allows the lending market owner to create a new
|
|
1267
|
+
* `ObligationOwnerCap` for an obligation that already exists. This can be useful for
|
|
1268
|
+
* recovery purposes or administrative actions where a new capability object is needed.
|
|
1269
|
+
*
|
|
1270
|
+
* # Arguments
|
|
1271
|
+
*
|
|
1272
|
+
* * `_` - The `LendingMarketOwnerCap` to authorize the operation.
|
|
1273
|
+
* * `lending_market` - A reference to the `LendingMarket`.
|
|
1274
|
+
* * `obligation_id` - The ID of the obligation to create a new owner cap for.
|
|
1275
|
+
*
|
|
1276
|
+
* # Returns
|
|
1277
|
+
*
|
|
1278
|
+
* * `ObligationOwnerCap<P>` - The newly created ownership capability for the specified obligation.
|
|
1279
|
+
*
|
|
1280
|
+
* # Panics
|
|
1281
|
+
*
|
|
1282
|
+
* This function will panic if:
|
|
1283
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
1284
|
+
* * The `obligation_id` is not found in the lending market's obligations (EInvalidObligationId).
|
|
1285
|
+
*/
|
|
1286
|
+
export function newObligationOwnerCap(tx, typeArg, args, options) {
|
|
461
1287
|
return tx.moveCall({
|
|
462
|
-
target: `${
|
|
463
|
-
typeArguments:
|
|
1288
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::new_obligation_owner_cap`,
|
|
1289
|
+
typeArguments: [typeArg],
|
|
464
1290
|
arguments: [
|
|
1291
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
465
1292
|
obj(tx, args.lendingMarket),
|
|
466
|
-
pure(tx, args.
|
|
467
|
-
obj(tx, args.clock),
|
|
468
|
-
obj(tx, args.ctokens),
|
|
469
|
-
option(tx, `${RateLimiterExemption.$typeName}<${typeArgs[0]}, ${typeArgs[1]}>`, args.rateLimiterExemption),
|
|
1293
|
+
pure(tx, args.obligationId, `${ID.$typeName}`),
|
|
470
1294
|
],
|
|
471
1295
|
});
|
|
472
1296
|
}
|
|
473
|
-
|
|
1297
|
+
/**
|
|
1298
|
+
* Mints a fresh `EmergencyPauseCap` at the next generation, revoking every
|
|
1299
|
+
* previously-issued cap for this market (their `generation` no longer matches).
|
|
1300
|
+
*
|
|
1301
|
+
* # Panics
|
|
1302
|
+
*
|
|
1303
|
+
* This function will panic if:
|
|
1304
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
1305
|
+
*/
|
|
1306
|
+
export function newPauseCap(tx, typeArg, args, options) {
|
|
474
1307
|
return tx.moveCall({
|
|
475
|
-
target: `${
|
|
476
|
-
typeArguments:
|
|
1308
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::new_pause_cap`,
|
|
1309
|
+
typeArguments: [typeArg],
|
|
477
1310
|
arguments: [
|
|
1311
|
+
obj(tx, args.lendingMarketOwnerCap),
|
|
478
1312
|
obj(tx, args.lendingMarket),
|
|
479
|
-
pure(tx, args.
|
|
480
|
-
obj(tx, args.clock),
|
|
481
|
-
obj(tx, args.ctokens),
|
|
482
|
-
option(tx, `${RateLimiterExemption.$typeName}<${typeArgs[0]}, ${typeArgs[1]}>`, args.rateLimiterExemption),
|
|
1313
|
+
pure(tx, args.recipient, `address`),
|
|
483
1314
|
],
|
|
484
1315
|
});
|
|
485
1316
|
}
|
|
486
|
-
|
|
1317
|
+
/**
|
|
1318
|
+
* Pauses or resumes the entire market. Gated on possession of the
|
|
1319
|
+
* current-generation `EmergencyPauseCap`; a cap from a superseded generation aborts.
|
|
1320
|
+
*
|
|
1321
|
+
* # Panics
|
|
1322
|
+
*
|
|
1323
|
+
* This function will panic if:
|
|
1324
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
1325
|
+
* * `cap` was not minted for this `lending_market` (EWrongLendingMarket).
|
|
1326
|
+
* * `cap`'s generation has been superseded by a later `new_pause_cap` call (EStalePauseCap).
|
|
1327
|
+
*/
|
|
1328
|
+
export function setMarketPaused(tx, typeArg, args, options) {
|
|
487
1329
|
return tx.moveCall({
|
|
488
|
-
target: `${
|
|
1330
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::set_market_paused`,
|
|
489
1331
|
typeArguments: [typeArg],
|
|
490
1332
|
arguments: [
|
|
1333
|
+
obj(tx, args.cap),
|
|
1334
|
+
obj(tx, args.lendingMarket),
|
|
1335
|
+
pure(tx, args.paused, `bool`),
|
|
1336
|
+
],
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* Pauses or resumes a single reserve. Gated on possession of the current-generation
|
|
1341
|
+
* `EmergencyPauseCap`; a cap from a superseded generation aborts.
|
|
1342
|
+
*
|
|
1343
|
+
* # Panics
|
|
1344
|
+
*
|
|
1345
|
+
* This function will panic if:
|
|
1346
|
+
* * The `lending_market` version is not `CURRENT_VERSION` (EIncorrectVersion).
|
|
1347
|
+
* * `cap` was not minted for this `lending_market` (EWrongLendingMarket).
|
|
1348
|
+
* * `cap`'s generation has been superseded by a later `new_pause_cap` call (EStalePauseCap).
|
|
1349
|
+
* * `reserve_array_index` is out of bounds.
|
|
1350
|
+
*/
|
|
1351
|
+
export function setReservePaused(tx, typeArg, args, options) {
|
|
1352
|
+
return tx.moveCall({
|
|
1353
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::set_reserve_paused`,
|
|
1354
|
+
typeArguments: [typeArg],
|
|
1355
|
+
arguments: [
|
|
1356
|
+
obj(tx, args.cap),
|
|
491
1357
|
obj(tx, args.lendingMarket),
|
|
492
1358
|
pure(tx, args.reserveArrayIndex, `u64`),
|
|
493
|
-
|
|
494
|
-
obj(tx, args.priceInfo),
|
|
1359
|
+
pure(tx, args.paused, `bool`),
|
|
495
1360
|
],
|
|
496
1361
|
});
|
|
497
1362
|
}
|
|
498
|
-
|
|
1363
|
+
/**
|
|
1364
|
+
* True if the market has been paused. Absent the dynamic field, the market is
|
|
1365
|
+
* unpaused. Pure: no aborts, no side effects. Public so a UI or bot can check
|
|
1366
|
+
* pause state before building a PTB, instead of discovering it as an abort.
|
|
1367
|
+
*/
|
|
1368
|
+
export function isMarketPaused(tx, typeArg, lendingMarket, options) {
|
|
499
1369
|
return tx.moveCall({
|
|
500
|
-
target: `${
|
|
1370
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::is_market_paused`,
|
|
1371
|
+
typeArguments: [typeArg],
|
|
1372
|
+
arguments: [obj(tx, lendingMarket)],
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
export function assertValidPauseCap(tx, typeArg, args, options) {
|
|
1376
|
+
return tx.moveCall({
|
|
1377
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::assert_valid_pause_cap`,
|
|
501
1378
|
typeArguments: [typeArg],
|
|
502
1379
|
arguments: [
|
|
503
|
-
obj(tx, args.
|
|
1380
|
+
obj(tx, args.cap),
|
|
504
1381
|
obj(tx, args.lendingMarket),
|
|
505
|
-
pure(tx, args.receivers, `vector<address>`),
|
|
506
|
-
pure(tx, args.weights, `vector<u64>`),
|
|
507
1382
|
],
|
|
508
1383
|
});
|
|
509
1384
|
}
|
|
510
|
-
export function
|
|
1385
|
+
export function assertNotPaused(tx, typeArg, args, options) {
|
|
511
1386
|
return tx.moveCall({
|
|
512
|
-
target: `${
|
|
1387
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::assert_not_paused`,
|
|
513
1388
|
typeArguments: [typeArg],
|
|
514
1389
|
arguments: [
|
|
515
|
-
obj(tx, args.lendingMarketOwnerCap),
|
|
516
1390
|
obj(tx, args.lendingMarket),
|
|
1391
|
+
obj(tx, args.reserve),
|
|
1392
|
+
],
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
export function depositCtokensIntoObligationById(tx, typeArgs, args, options) {
|
|
1396
|
+
return tx.moveCall({
|
|
1397
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::deposit_ctokens_into_obligation_by_id`,
|
|
1398
|
+
typeArguments: typeArgs,
|
|
1399
|
+
arguments: [
|
|
1400
|
+
obj(tx, args.lendingMarket),
|
|
1401
|
+
pure(tx, args.reserveArrayIndex, `u64`),
|
|
1402
|
+
pure(tx, args.obligationId, `${ID.$typeName}`),
|
|
1403
|
+
obj(tx, args.clock),
|
|
1404
|
+
obj(tx, args.deposit),
|
|
1405
|
+
],
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
export function claimRewardsByObligationId(tx, typeArgs, args, options) {
|
|
1409
|
+
return tx.moveCall({
|
|
1410
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::claim_rewards_by_obligation_id`,
|
|
1411
|
+
typeArguments: typeArgs,
|
|
1412
|
+
arguments: [
|
|
1413
|
+
obj(tx, args.lendingMarket),
|
|
1414
|
+
pure(tx, args.obligationId, `${ID.$typeName}`),
|
|
517
1415
|
obj(tx, args.clock),
|
|
1416
|
+
pure(tx, args.reserveId, `u64`),
|
|
1417
|
+
pure(tx, args.rewardIndex, `u64`),
|
|
1418
|
+
pure(tx, args.isDepositReward, `bool`),
|
|
1419
|
+
pure(tx, args.failIfRewardPeriodNotOver, `bool`),
|
|
1420
|
+
],
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
export function addReserveInternalProCompatible(tx, typeArgs, args, options) {
|
|
1424
|
+
return tx.moveCall({
|
|
1425
|
+
target: `${getPublishedAt('suilend', options?.env)}::lending_market::add_reserve_internal_pro_compatible`,
|
|
1426
|
+
typeArguments: typeArgs,
|
|
1427
|
+
arguments: [
|
|
1428
|
+
obj(tx, args.lendingMarket),
|
|
1429
|
+
obj(tx, args.priceInfo),
|
|
518
1430
|
obj(tx, args.config),
|
|
1431
|
+
pure(tx, args.decimals, `u8`),
|
|
1432
|
+
obj(tx, args.clock),
|
|
519
1433
|
],
|
|
520
1434
|
});
|
|
521
1435
|
}
|