@kamino-finance/klend-sdk 7.4.0-beta.0 → 7.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@codegen/klend/accounts/LendingMarket.d.ts +3 -51
- package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/LendingMarket.js +6 -39
- package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.d.ts +15 -24
- package/dist/@codegen/klend/accounts/Obligation.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/Obligation.js +21 -24
- package/dist/@codegen/klend/accounts/Obligation.js.map +1 -1
- package/dist/@codegen/klend/accounts/Reserve.js +1 -1
- package/dist/@codegen/klend/accounts/UserState.d.ts +75 -0
- package/dist/@codegen/klend/accounts/UserState.d.ts.map +1 -1
- package/dist/@codegen/klend/accounts/UserState.js +25 -0
- package/dist/@codegen/klend/accounts/UserState.js.map +1 -1
- package/dist/@codegen/klend/errors/custom.d.ts +1 -89
- package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
- package/dist/@codegen/klend/errors/custom.js +1 -155
- package/dist/@codegen/klend/errors/custom.js.map +1 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts +1 -0
- package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/idlMissingTypes.js +2 -0
- package/dist/@codegen/klend/instructions/idlMissingTypes.js.map +1 -1
- package/dist/@codegen/klend/instructions/index.d.ts +0 -4
- package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
- package/dist/@codegen/klend/instructions/index.js +1 -6
- package/dist/@codegen/klend/instructions/index.js.map +1 -1
- package/dist/@codegen/klend/types/AssetTier.d.ts +45 -0
- package/dist/@codegen/klend/types/AssetTier.d.ts.map +1 -0
- package/dist/@codegen/klend/types/AssetTier.js +132 -0
- package/dist/@codegen/klend/types/AssetTier.js.map +1 -0
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts +5 -35
- package/dist/@codegen/klend/types/ObligationLiquidity.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ObligationLiquidity.js +7 -17
- package/dist/@codegen/klend/types/ObligationLiquidity.js.map +1 -1
- package/dist/@codegen/klend/types/ObligationOrder.d.ts +4 -4
- package/dist/@codegen/klend/types/ObligationOrder.js +2 -2
- package/dist/@codegen/klend/types/ReserveConfig.d.ts +5 -60
- package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
- package/dist/@codegen/klend/types/ReserveConfig.js +7 -36
- package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +7 -33
- package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateConfigMode.js +13 -61
- package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +0 -52
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +1 -97
- package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/@codegen/klend/types/index.d.ts +8 -8
- package/dist/@codegen/klend/types/index.d.ts.map +1 -1
- package/dist/@codegen/klend/types/index.js +3 -5
- package/dist/@codegen/klend/types/index.js.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts +5 -8
- package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/@codegen/klend/zero_padding/ObligationZP.js +14 -17
- package/dist/@codegen/klend/zero_padding/ObligationZP.js.map +1 -1
- package/dist/classes/action.d.ts +21 -91
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +141 -119
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/actionTypes.d.ts +310 -0
- package/dist/classes/actionTypes.d.ts.map +1 -0
- package/dist/classes/actionTypes.js +3 -0
- package/dist/classes/actionTypes.js.map +1 -0
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +0 -4
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +5 -11
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +29 -21
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +9 -9
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +49 -51
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/obligationOrder.d.ts.map +1 -1
- package/dist/classes/obligationOrder.js +6 -3
- package/dist/classes/obligationOrder.js.map +1 -1
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +1 -3
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +1 -0
- package/dist/classes/shared.d.ts.map +1 -1
- package/dist/client/commands/borrow.d.ts +1 -1
- package/dist/client/commands/borrow.d.ts.map +1 -1
- package/dist/client/commands/borrow.js +11 -2
- package/dist/client/commands/borrow.js.map +1 -1
- package/dist/client/commands/deposit.d.ts +1 -1
- package/dist/client/commands/deposit.d.ts.map +1 -1
- package/dist/client/commands/deposit.js +11 -2
- package/dist/client/commands/deposit.js.map +1 -1
- package/dist/client/commands/printReserve.d.ts +1 -1
- package/dist/client/commands/printReserve.d.ts.map +1 -1
- package/dist/client/commands/printReserve.js +2 -4
- package/dist/client/commands/printReserve.js.map +1 -1
- package/dist/client/commands/repay.d.ts +1 -1
- package/dist/client/commands/repay.d.ts.map +1 -1
- package/dist/client/commands/repay.js +12 -2
- package/dist/client/commands/repay.js.map +1 -1
- package/dist/client/commands/withdraw.d.ts +1 -1
- package/dist/client/commands/withdraw.d.ts.map +1 -1
- package/dist/client/commands/withdraw.js +11 -2
- package/dist/client/commands/withdraw.js.map +1 -1
- package/dist/idl/klend.json +54 -581
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.js +2 -2
- package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +4 -4
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +43 -10
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +4 -4
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +40 -21
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/operations.d.ts +6 -6
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +167 -52
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +2 -2
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/manager/client_kamino_manager.js +6 -12
- package/dist/manager/client_kamino_manager.js.map +1 -1
- package/dist/obligation_orders/price_based.js +1 -0
- package/dist/obligation_orders/price_based.js.map +1 -1
- package/dist/utils/ObligationType.d.ts +33 -1
- package/dist/utils/ObligationType.d.ts.map +1 -1
- package/dist/utils/ObligationType.js +81 -2
- package/dist/utils/ObligationType.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +1 -3
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/userMetadata.d.ts +2 -2
- package/dist/utils/userMetadata.d.ts.map +1 -1
- package/dist/utils/userMetadata.js +49 -25
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +1 -1
- package/src/@codegen/klend/accounts/LendingMarket.ts +8 -79
- package/src/@codegen/klend/accounts/Obligation.ts +31 -42
- package/src/@codegen/klend/accounts/Reserve.ts +1 -1
- package/src/@codegen/klend/accounts/UserState.ts +75 -0
- package/src/@codegen/klend/errors/custom.ts +0 -172
- package/src/@codegen/klend/instructions/idlMissingTypes.ts +3 -0
- package/src/@codegen/klend/instructions/index.ts +0 -7
- package/src/@codegen/klend/types/AssetTier.ts +119 -0
- package/src/@codegen/klend/types/ObligationLiquidity.ts +9 -39
- package/src/@codegen/klend/types/ObligationOrder.ts +4 -4
- package/src/@codegen/klend/types/ReserveConfig.ts +9 -72
- package/src/@codegen/klend/types/UpdateConfigMode.ts +13 -73
- package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +0 -120
- package/src/@codegen/klend/types/index.ts +14 -21
- package/src/@codegen/klend/zero_padding/ObligationZP.ts +14 -17
- package/src/classes/action.ts +321 -347
- package/src/classes/actionTypes.ts +295 -0
- package/src/classes/manager.ts +0 -5
- package/src/classes/market.ts +42 -32
- package/src/classes/obligation.ts +55 -54
- package/src/classes/obligationOrder.ts +6 -3
- package/src/classes/reserve.ts +1 -3
- package/src/classes/shared.ts +2 -0
- package/src/client/client.ts +17 -18
- package/src/client/commands/borrow.ts +10 -9
- package/src/client/commands/deposit.ts +10 -9
- package/src/client/commands/printReserve.ts +2 -4
- package/src/client/commands/repay.ts +11 -10
- package/src/client/commands/withdraw.ts +15 -9
- package/src/idl/klend.json +54 -581
- package/src/lending_operations/repay_with_collateral_calcs.ts +3 -4
- package/src/lending_operations/repay_with_collateral_operations.ts +40 -38
- package/src/lending_operations/swap_collateral_operations.ts +47 -41
- package/src/leverage/operations.ts +168 -129
- package/src/leverage/types.ts +2 -2
- package/src/manager/client_kamino_manager.ts +6 -12
- package/src/obligation_orders/price_based.ts +1 -0
- package/src/utils/ObligationType.ts +92 -1
- package/src/utils/managerTypes.ts +1 -3
- package/src/utils/userMetadata.ts +64 -30
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts +0 -36
- package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js +0 -49
- package/dist/@codegen/klend/instructions/fillBorrowOrder.js.map +0 -1
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts +0 -33
- package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts.map +0 -1
- package/dist/@codegen/klend/instructions/setBorrowOrder.js +0 -66
- package/dist/@codegen/klend/instructions/setBorrowOrder.js.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrder.d.ts +0 -192
- package/dist/@codegen/klend/types/BorrowOrder.d.ts.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrder.js +0 -194
- package/dist/@codegen/klend/types/BorrowOrder.js.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts +0 -39
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts.map +0 -1
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js +0 -100
- package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js.map +0 -1
- package/src/@codegen/klend/instructions/fillBorrowOrder.ts +0 -96
- package/src/@codegen/klend/instructions/setBorrowOrder.ts +0 -81
- package/src/@codegen/klend/types/BorrowOrder.ts +0 -267
- package/src/@codegen/klend/types/BorrowOrderConfigArgs.ts +0 -87
|
@@ -41,7 +41,9 @@ export interface ObligationFields {
|
|
|
41
41
|
/** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */
|
|
42
42
|
unhealthyBorrowValueSf: BN
|
|
43
43
|
/** The asset tier of the deposits */
|
|
44
|
-
|
|
44
|
+
depositsAssetTiers: Array<number>
|
|
45
|
+
/** The asset tier of the borrows */
|
|
46
|
+
borrowsAssetTiers: Array<number>
|
|
45
47
|
/** The elevation group id the obligation opted into. */
|
|
46
48
|
elevationGroup: number
|
|
47
49
|
/** The number of obsolete reserves the obligation has a deposit in */
|
|
@@ -69,15 +71,10 @@ export interface ObligationFields {
|
|
|
69
71
|
*/
|
|
70
72
|
autodeleverageMarginCallStartedTimestamp: BN
|
|
71
73
|
/**
|
|
72
|
-
* Owner-defined,
|
|
74
|
+
* Owner-defined, liquidator-executed orders applicable to this obligation.
|
|
73
75
|
* Typical use-cases would be a stop-loss and a take-profit (possibly co-existing).
|
|
74
76
|
*/
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Owner-defined, permissionlessly-executed borrow order applicable to this obligation.
|
|
78
|
-
* Non-zeroed only on a newly-initialized fixed-rate, fixed-term obligation.
|
|
79
|
-
*/
|
|
80
|
-
borrowOrder: types.BorrowOrderFields
|
|
77
|
+
orders: Array<types.ObligationOrderFields>
|
|
81
78
|
padding3: Array<BN>
|
|
82
79
|
}
|
|
83
80
|
|
|
@@ -107,7 +104,9 @@ export interface ObligationJSON {
|
|
|
107
104
|
/** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */
|
|
108
105
|
unhealthyBorrowValueSf: string
|
|
109
106
|
/** The asset tier of the deposits */
|
|
110
|
-
|
|
107
|
+
depositsAssetTiers: Array<number>
|
|
108
|
+
/** The asset tier of the borrows */
|
|
109
|
+
borrowsAssetTiers: Array<number>
|
|
111
110
|
/** The elevation group id the obligation opted into. */
|
|
112
111
|
elevationGroup: number
|
|
113
112
|
/** The number of obsolete reserves the obligation has a deposit in */
|
|
@@ -135,15 +134,10 @@ export interface ObligationJSON {
|
|
|
135
134
|
*/
|
|
136
135
|
autodeleverageMarginCallStartedTimestamp: string
|
|
137
136
|
/**
|
|
138
|
-
* Owner-defined,
|
|
137
|
+
* Owner-defined, liquidator-executed orders applicable to this obligation.
|
|
139
138
|
* Typical use-cases would be a stop-loss and a take-profit (possibly co-existing).
|
|
140
139
|
*/
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Owner-defined, permissionlessly-executed borrow order applicable to this obligation.
|
|
144
|
-
* Non-zeroed only on a newly-initialized fixed-rate, fixed-term obligation.
|
|
145
|
-
*/
|
|
146
|
-
borrowOrder: types.BorrowOrderJSON
|
|
140
|
+
orders: Array<types.ObligationOrderJSON>
|
|
147
141
|
padding3: Array<string>
|
|
148
142
|
}
|
|
149
143
|
|
|
@@ -174,7 +168,9 @@ export class Obligation {
|
|
|
174
168
|
/** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */
|
|
175
169
|
readonly unhealthyBorrowValueSf: BN
|
|
176
170
|
/** The asset tier of the deposits */
|
|
177
|
-
readonly
|
|
171
|
+
readonly depositsAssetTiers: Array<number>
|
|
172
|
+
/** The asset tier of the borrows */
|
|
173
|
+
readonly borrowsAssetTiers: Array<number>
|
|
178
174
|
/** The elevation group id the obligation opted into. */
|
|
179
175
|
readonly elevationGroup: number
|
|
180
176
|
/** The number of obsolete reserves the obligation has a deposit in */
|
|
@@ -202,15 +198,10 @@ export class Obligation {
|
|
|
202
198
|
*/
|
|
203
199
|
readonly autodeleverageMarginCallStartedTimestamp: BN
|
|
204
200
|
/**
|
|
205
|
-
* Owner-defined,
|
|
201
|
+
* Owner-defined, liquidator-executed orders applicable to this obligation.
|
|
206
202
|
* Typical use-cases would be a stop-loss and a take-profit (possibly co-existing).
|
|
207
203
|
*/
|
|
208
|
-
readonly
|
|
209
|
-
/**
|
|
210
|
-
* Owner-defined, permissionlessly-executed borrow order applicable to this obligation.
|
|
211
|
-
* Non-zeroed only on a newly-initialized fixed-rate, fixed-term obligation.
|
|
212
|
-
*/
|
|
213
|
-
readonly borrowOrder: types.BorrowOrder
|
|
204
|
+
readonly orders: Array<types.ObligationOrder>
|
|
214
205
|
readonly padding3: Array<BN>
|
|
215
206
|
|
|
216
207
|
static readonly discriminator = Buffer.from([
|
|
@@ -230,7 +221,8 @@ export class Obligation {
|
|
|
230
221
|
borsh.u128("borrowedAssetsMarketValueSf"),
|
|
231
222
|
borsh.u128("allowedBorrowValueSf"),
|
|
232
223
|
borsh.u128("unhealthyBorrowValueSf"),
|
|
233
|
-
borsh.array(borsh.u8(),
|
|
224
|
+
borsh.array(borsh.u8(), 8, "depositsAssetTiers"),
|
|
225
|
+
borsh.array(borsh.u8(), 5, "borrowsAssetTiers"),
|
|
234
226
|
borsh.u8("elevationGroup"),
|
|
235
227
|
borsh.u8("numOfObsoleteDepositReserves"),
|
|
236
228
|
borsh.u8("hasDebt"),
|
|
@@ -242,9 +234,8 @@ export class Obligation {
|
|
|
242
234
|
borsh.array(borsh.u8(), 4, "reserved"),
|
|
243
235
|
borsh.u64("highestBorrowFactorPct"),
|
|
244
236
|
borsh.u64("autodeleverageMarginCallStartedTimestamp"),
|
|
245
|
-
borsh.array(types.ObligationOrder.layout(), 2, "
|
|
246
|
-
|
|
247
|
-
borsh.array(borsh.u64(), 73, "padding3"),
|
|
237
|
+
borsh.array(types.ObligationOrder.layout(), 2, "orders"),
|
|
238
|
+
borsh.array(borsh.u64(), 93, "padding3"),
|
|
248
239
|
])
|
|
249
240
|
|
|
250
241
|
constructor(fields: ObligationFields) {
|
|
@@ -266,7 +257,8 @@ export class Obligation {
|
|
|
266
257
|
this.borrowedAssetsMarketValueSf = fields.borrowedAssetsMarketValueSf
|
|
267
258
|
this.allowedBorrowValueSf = fields.allowedBorrowValueSf
|
|
268
259
|
this.unhealthyBorrowValueSf = fields.unhealthyBorrowValueSf
|
|
269
|
-
this.
|
|
260
|
+
this.depositsAssetTiers = fields.depositsAssetTiers
|
|
261
|
+
this.borrowsAssetTiers = fields.borrowsAssetTiers
|
|
270
262
|
this.elevationGroup = fields.elevationGroup
|
|
271
263
|
this.numOfObsoleteDepositReserves = fields.numOfObsoleteDepositReserves
|
|
272
264
|
this.hasDebt = fields.hasDebt
|
|
@@ -279,10 +271,9 @@ export class Obligation {
|
|
|
279
271
|
this.highestBorrowFactorPct = fields.highestBorrowFactorPct
|
|
280
272
|
this.autodeleverageMarginCallStartedTimestamp =
|
|
281
273
|
fields.autodeleverageMarginCallStartedTimestamp
|
|
282
|
-
this.
|
|
274
|
+
this.orders = fields.orders.map(
|
|
283
275
|
(item) => new types.ObligationOrder({ ...item })
|
|
284
276
|
)
|
|
285
|
-
this.borrowOrder = new types.BorrowOrder({ ...fields.borrowOrder })
|
|
286
277
|
this.padding3 = fields.padding3
|
|
287
278
|
}
|
|
288
279
|
|
|
@@ -355,7 +346,8 @@ export class Obligation {
|
|
|
355
346
|
borrowedAssetsMarketValueSf: dec.borrowedAssetsMarketValueSf,
|
|
356
347
|
allowedBorrowValueSf: dec.allowedBorrowValueSf,
|
|
357
348
|
unhealthyBorrowValueSf: dec.unhealthyBorrowValueSf,
|
|
358
|
-
|
|
349
|
+
depositsAssetTiers: dec.depositsAssetTiers,
|
|
350
|
+
borrowsAssetTiers: dec.borrowsAssetTiers,
|
|
359
351
|
elevationGroup: dec.elevationGroup,
|
|
360
352
|
numOfObsoleteDepositReserves: dec.numOfObsoleteDepositReserves,
|
|
361
353
|
hasDebt: dec.hasDebt,
|
|
@@ -368,12 +360,11 @@ export class Obligation {
|
|
|
368
360
|
highestBorrowFactorPct: dec.highestBorrowFactorPct,
|
|
369
361
|
autodeleverageMarginCallStartedTimestamp:
|
|
370
362
|
dec.autodeleverageMarginCallStartedTimestamp,
|
|
371
|
-
|
|
363
|
+
orders: dec.orders.map(
|
|
372
364
|
(
|
|
373
365
|
item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
|
374
366
|
) => types.ObligationOrder.fromDecoded(item)
|
|
375
367
|
),
|
|
376
|
-
borrowOrder: types.BorrowOrder.fromDecoded(dec.borrowOrder),
|
|
377
368
|
padding3: dec.padding3,
|
|
378
369
|
})
|
|
379
370
|
}
|
|
@@ -394,7 +385,8 @@ export class Obligation {
|
|
|
394
385
|
borrowedAssetsMarketValueSf: this.borrowedAssetsMarketValueSf.toString(),
|
|
395
386
|
allowedBorrowValueSf: this.allowedBorrowValueSf.toString(),
|
|
396
387
|
unhealthyBorrowValueSf: this.unhealthyBorrowValueSf.toString(),
|
|
397
|
-
|
|
388
|
+
depositsAssetTiers: this.depositsAssetTiers,
|
|
389
|
+
borrowsAssetTiers: this.borrowsAssetTiers,
|
|
398
390
|
elevationGroup: this.elevationGroup,
|
|
399
391
|
numOfObsoleteDepositReserves: this.numOfObsoleteDepositReserves,
|
|
400
392
|
hasDebt: this.hasDebt,
|
|
@@ -407,8 +399,7 @@ export class Obligation {
|
|
|
407
399
|
highestBorrowFactorPct: this.highestBorrowFactorPct.toString(),
|
|
408
400
|
autodeleverageMarginCallStartedTimestamp:
|
|
409
401
|
this.autodeleverageMarginCallStartedTimestamp.toString(),
|
|
410
|
-
|
|
411
|
-
borrowOrder: this.borrowOrder.toJSON(),
|
|
402
|
+
orders: this.orders.map((item) => item.toJSON()),
|
|
412
403
|
padding3: this.padding3.map((item) => item.toString()),
|
|
413
404
|
}
|
|
414
405
|
}
|
|
@@ -435,7 +426,8 @@ export class Obligation {
|
|
|
435
426
|
borrowedAssetsMarketValueSf: new BN(obj.borrowedAssetsMarketValueSf),
|
|
436
427
|
allowedBorrowValueSf: new BN(obj.allowedBorrowValueSf),
|
|
437
428
|
unhealthyBorrowValueSf: new BN(obj.unhealthyBorrowValueSf),
|
|
438
|
-
|
|
429
|
+
depositsAssetTiers: obj.depositsAssetTiers,
|
|
430
|
+
borrowsAssetTiers: obj.borrowsAssetTiers,
|
|
439
431
|
elevationGroup: obj.elevationGroup,
|
|
440
432
|
numOfObsoleteDepositReserves: obj.numOfObsoleteDepositReserves,
|
|
441
433
|
hasDebt: obj.hasDebt,
|
|
@@ -449,10 +441,7 @@ export class Obligation {
|
|
|
449
441
|
autodeleverageMarginCallStartedTimestamp: new BN(
|
|
450
442
|
obj.autodeleverageMarginCallStartedTimestamp
|
|
451
443
|
),
|
|
452
|
-
|
|
453
|
-
types.ObligationOrder.fromJSON(item)
|
|
454
|
-
),
|
|
455
|
-
borrowOrder: types.BorrowOrder.fromJSON(obj.borrowOrder),
|
|
444
|
+
orders: obj.orders.map((item) => types.ObligationOrder.fromJSON(item)),
|
|
456
445
|
padding3: obj.padding3.map((item) => new BN(item)),
|
|
457
446
|
})
|
|
458
447
|
}
|
|
@@ -110,7 +110,7 @@ export class Reserve {
|
|
|
110
110
|
types.ReserveCollateral.layout("collateral"),
|
|
111
111
|
borsh.array(borsh.u64(), 150, "reserveCollateralPadding"),
|
|
112
112
|
types.ReserveConfig.layout("config"),
|
|
113
|
-
borsh.array(borsh.u64(),
|
|
113
|
+
borsh.array(borsh.u64(), 116, "configPadding"),
|
|
114
114
|
borsh.u64("borrowedAmountOutsideElevationGroup"),
|
|
115
115
|
borsh.array(
|
|
116
116
|
borsh.u64(),
|
|
@@ -19,17 +19,42 @@ export interface UserStateFields {
|
|
|
19
19
|
userId: BN
|
|
20
20
|
farmState: Address
|
|
21
21
|
owner: Address
|
|
22
|
+
/** Indicate if this user state is part of a delegated farm */
|
|
22
23
|
isFarmDelegated: number
|
|
23
24
|
padding0: Array<number>
|
|
25
|
+
/**
|
|
26
|
+
* Rewards tally used for computation of gained rewards
|
|
27
|
+
* (scaled from `Decimal` representation).
|
|
28
|
+
*/
|
|
24
29
|
rewardsTallyScaled: Array<BN>
|
|
30
|
+
/** Number of reward tokens ready for claim */
|
|
25
31
|
rewardsIssuedUnclaimed: Array<BN>
|
|
26
32
|
lastClaimTs: Array<BN>
|
|
33
|
+
/**
|
|
34
|
+
* User stake deposited and usable, generating rewards and fees.
|
|
35
|
+
* (scaled from `Decimal` representation).
|
|
36
|
+
*/
|
|
27
37
|
activeStakeScaled: BN
|
|
38
|
+
/**
|
|
39
|
+
* User stake deposited but not usable and not generating rewards yet.
|
|
40
|
+
* (scaled from `Decimal` representation).
|
|
41
|
+
*/
|
|
28
42
|
pendingDepositStakeScaled: BN
|
|
43
|
+
/**
|
|
44
|
+
* After this timestamp, pending user stake can be moved to user stake
|
|
45
|
+
* Initialized to now() + delayed user stake period
|
|
46
|
+
*/
|
|
29
47
|
pendingDepositStakeTs: BN
|
|
48
|
+
/**
|
|
49
|
+
* User deposits unstaked, pending for withdrawal, not usable and not generating rewards.
|
|
50
|
+
* (scaled from `Decimal` representation).
|
|
51
|
+
*/
|
|
30
52
|
pendingWithdrawalUnstakeScaled: BN
|
|
53
|
+
/** After this timestamp, user can withdraw their deposit. */
|
|
31
54
|
pendingWithdrawalUnstakeTs: BN
|
|
55
|
+
/** User bump used for account address validation */
|
|
32
56
|
bump: BN
|
|
57
|
+
/** Delegatee used for initialisation - useful to check against */
|
|
33
58
|
delegatee: Address
|
|
34
59
|
lastStakeTs: BN
|
|
35
60
|
padding1: Array<BN>
|
|
@@ -39,17 +64,42 @@ export interface UserStateJSON {
|
|
|
39
64
|
userId: string
|
|
40
65
|
farmState: string
|
|
41
66
|
owner: string
|
|
67
|
+
/** Indicate if this user state is part of a delegated farm */
|
|
42
68
|
isFarmDelegated: number
|
|
43
69
|
padding0: Array<number>
|
|
70
|
+
/**
|
|
71
|
+
* Rewards tally used for computation of gained rewards
|
|
72
|
+
* (scaled from `Decimal` representation).
|
|
73
|
+
*/
|
|
44
74
|
rewardsTallyScaled: Array<string>
|
|
75
|
+
/** Number of reward tokens ready for claim */
|
|
45
76
|
rewardsIssuedUnclaimed: Array<string>
|
|
46
77
|
lastClaimTs: Array<string>
|
|
78
|
+
/**
|
|
79
|
+
* User stake deposited and usable, generating rewards and fees.
|
|
80
|
+
* (scaled from `Decimal` representation).
|
|
81
|
+
*/
|
|
47
82
|
activeStakeScaled: string
|
|
83
|
+
/**
|
|
84
|
+
* User stake deposited but not usable and not generating rewards yet.
|
|
85
|
+
* (scaled from `Decimal` representation).
|
|
86
|
+
*/
|
|
48
87
|
pendingDepositStakeScaled: string
|
|
88
|
+
/**
|
|
89
|
+
* After this timestamp, pending user stake can be moved to user stake
|
|
90
|
+
* Initialized to now() + delayed user stake period
|
|
91
|
+
*/
|
|
49
92
|
pendingDepositStakeTs: string
|
|
93
|
+
/**
|
|
94
|
+
* User deposits unstaked, pending for withdrawal, not usable and not generating rewards.
|
|
95
|
+
* (scaled from `Decimal` representation).
|
|
96
|
+
*/
|
|
50
97
|
pendingWithdrawalUnstakeScaled: string
|
|
98
|
+
/** After this timestamp, user can withdraw their deposit. */
|
|
51
99
|
pendingWithdrawalUnstakeTs: string
|
|
100
|
+
/** User bump used for account address validation */
|
|
52
101
|
bump: string
|
|
102
|
+
/** Delegatee used for initialisation - useful to check against */
|
|
53
103
|
delegatee: string
|
|
54
104
|
lastStakeTs: string
|
|
55
105
|
padding1: Array<string>
|
|
@@ -59,17 +109,42 @@ export class UserState {
|
|
|
59
109
|
readonly userId: BN
|
|
60
110
|
readonly farmState: Address
|
|
61
111
|
readonly owner: Address
|
|
112
|
+
/** Indicate if this user state is part of a delegated farm */
|
|
62
113
|
readonly isFarmDelegated: number
|
|
63
114
|
readonly padding0: Array<number>
|
|
115
|
+
/**
|
|
116
|
+
* Rewards tally used for computation of gained rewards
|
|
117
|
+
* (scaled from `Decimal` representation).
|
|
118
|
+
*/
|
|
64
119
|
readonly rewardsTallyScaled: Array<BN>
|
|
120
|
+
/** Number of reward tokens ready for claim */
|
|
65
121
|
readonly rewardsIssuedUnclaimed: Array<BN>
|
|
66
122
|
readonly lastClaimTs: Array<BN>
|
|
123
|
+
/**
|
|
124
|
+
* User stake deposited and usable, generating rewards and fees.
|
|
125
|
+
* (scaled from `Decimal` representation).
|
|
126
|
+
*/
|
|
67
127
|
readonly activeStakeScaled: BN
|
|
128
|
+
/**
|
|
129
|
+
* User stake deposited but not usable and not generating rewards yet.
|
|
130
|
+
* (scaled from `Decimal` representation).
|
|
131
|
+
*/
|
|
68
132
|
readonly pendingDepositStakeScaled: BN
|
|
133
|
+
/**
|
|
134
|
+
* After this timestamp, pending user stake can be moved to user stake
|
|
135
|
+
* Initialized to now() + delayed user stake period
|
|
136
|
+
*/
|
|
69
137
|
readonly pendingDepositStakeTs: BN
|
|
138
|
+
/**
|
|
139
|
+
* User deposits unstaked, pending for withdrawal, not usable and not generating rewards.
|
|
140
|
+
* (scaled from `Decimal` representation).
|
|
141
|
+
*/
|
|
70
142
|
readonly pendingWithdrawalUnstakeScaled: BN
|
|
143
|
+
/** After this timestamp, user can withdraw their deposit. */
|
|
71
144
|
readonly pendingWithdrawalUnstakeTs: BN
|
|
145
|
+
/** User bump used for account address validation */
|
|
72
146
|
readonly bump: BN
|
|
147
|
+
/** Delegatee used for initialisation - useful to check against */
|
|
73
148
|
readonly delegatee: Address
|
|
74
149
|
readonly lastStakeTs: BN
|
|
75
150
|
readonly padding1: Array<BN>
|
|
@@ -132,17 +132,6 @@ export type CustomError =
|
|
|
132
132
|
| InitialAdminDepositExecuted
|
|
133
133
|
| ReserveHasNotReceivedInitialDeposit
|
|
134
134
|
| CTokenUsageBlocked
|
|
135
|
-
| CannotUseSameReserve
|
|
136
|
-
| TransactionIncludesRestrictedPrograms
|
|
137
|
-
| BorrowOrderDebtLiquidityMintMismatch
|
|
138
|
-
| BorrowOrderMaxBorrowRateExceeded
|
|
139
|
-
| BorrowOrderMinDebtTermInsufficient
|
|
140
|
-
| BorrowOrderFillTimeLimitExceeded
|
|
141
|
-
| ReserveDebtMaturityReached
|
|
142
|
-
| NonUpdatableOrderConfiguration
|
|
143
|
-
| BorrowOrderExecutionDisabled
|
|
144
|
-
| DebtReachedReserveDebtTerm
|
|
145
|
-
| ExpectationNotMet
|
|
146
135
|
|
|
147
136
|
export class InvalidMarketAuthority extends Error {
|
|
148
137
|
static readonly code = 6000
|
|
@@ -1691,145 +1680,6 @@ export class CTokenUsageBlocked extends Error {
|
|
|
1691
1680
|
}
|
|
1692
1681
|
}
|
|
1693
1682
|
|
|
1694
|
-
export class CannotUseSameReserve extends Error {
|
|
1695
|
-
static readonly code = 6133
|
|
1696
|
-
readonly code = 6133
|
|
1697
|
-
readonly name = "CannotUseSameReserve"
|
|
1698
|
-
readonly msg = "Cannot call ix with same reserve"
|
|
1699
|
-
|
|
1700
|
-
constructor(readonly logs?: string[]) {
|
|
1701
|
-
super("6133: Cannot call ix with same reserve")
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
export class TransactionIncludesRestrictedPrograms extends Error {
|
|
1706
|
-
static readonly code = 6134
|
|
1707
|
-
readonly code = 6134
|
|
1708
|
-
readonly name = "TransactionIncludesRestrictedPrograms"
|
|
1709
|
-
readonly msg = "Transaction includes restricted programs"
|
|
1710
|
-
|
|
1711
|
-
constructor(readonly logs?: string[]) {
|
|
1712
|
-
super("6134: Transaction includes restricted programs")
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
export class BorrowOrderDebtLiquidityMintMismatch extends Error {
|
|
1717
|
-
static readonly code = 6135
|
|
1718
|
-
readonly code = 6135
|
|
1719
|
-
readonly name = "BorrowOrderDebtLiquidityMintMismatch"
|
|
1720
|
-
readonly msg = "There is no borrow order requesting debt in the given asset"
|
|
1721
|
-
|
|
1722
|
-
constructor(readonly logs?: string[]) {
|
|
1723
|
-
super("6135: There is no borrow order requesting debt in the given asset")
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
export class BorrowOrderMaxBorrowRateExceeded extends Error {
|
|
1728
|
-
static readonly code = 6136
|
|
1729
|
-
readonly code = 6136
|
|
1730
|
-
readonly name = "BorrowOrderMaxBorrowRateExceeded"
|
|
1731
|
-
readonly msg =
|
|
1732
|
-
"Reserve used for fill exceeds the maximum borrow rate specified by the order"
|
|
1733
|
-
|
|
1734
|
-
constructor(readonly logs?: string[]) {
|
|
1735
|
-
super(
|
|
1736
|
-
"6136: Reserve used for fill exceeds the maximum borrow rate specified by the order"
|
|
1737
|
-
)
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
|
|
1741
|
-
export class BorrowOrderMinDebtTermInsufficient extends Error {
|
|
1742
|
-
static readonly code = 6137
|
|
1743
|
-
readonly code = 6137
|
|
1744
|
-
readonly name = "BorrowOrderMinDebtTermInsufficient"
|
|
1745
|
-
readonly msg =
|
|
1746
|
-
"Reserve used for fill defines a debt term shorter than specified by the order"
|
|
1747
|
-
|
|
1748
|
-
constructor(readonly logs?: string[]) {
|
|
1749
|
-
super(
|
|
1750
|
-
"6137: Reserve used for fill defines a debt term shorter than specified by the order"
|
|
1751
|
-
)
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
|
-
export class BorrowOrderFillTimeLimitExceeded extends Error {
|
|
1756
|
-
static readonly code = 6138
|
|
1757
|
-
readonly code = 6138
|
|
1758
|
-
readonly name = "BorrowOrderFillTimeLimitExceeded"
|
|
1759
|
-
readonly msg = "Borrow order can no longer be filled"
|
|
1760
|
-
|
|
1761
|
-
constructor(readonly logs?: string[]) {
|
|
1762
|
-
super("6138: Borrow order can no longer be filled")
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
export class ReserveDebtMaturityReached extends Error {
|
|
1767
|
-
static readonly code = 6139
|
|
1768
|
-
readonly code = 6139
|
|
1769
|
-
readonly name = "ReserveDebtMaturityReached"
|
|
1770
|
-
readonly msg =
|
|
1771
|
-
"Cannot borrow from a reserve that reached its debt maturity timestamp"
|
|
1772
|
-
|
|
1773
|
-
constructor(readonly logs?: string[]) {
|
|
1774
|
-
super(
|
|
1775
|
-
"6139: Cannot borrow from a reserve that reached its debt maturity timestamp"
|
|
1776
|
-
)
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
export class NonUpdatableOrderConfiguration extends Error {
|
|
1781
|
-
static readonly code = 6140
|
|
1782
|
-
readonly code = 6140
|
|
1783
|
-
readonly name = "NonUpdatableOrderConfiguration"
|
|
1784
|
-
readonly msg =
|
|
1785
|
-
"Some piece of the order's configuration cannot be updated (the order should be cancelled and placed again)"
|
|
1786
|
-
|
|
1787
|
-
constructor(readonly logs?: string[]) {
|
|
1788
|
-
super(
|
|
1789
|
-
"6140: Some piece of the order's configuration cannot be updated (the order should be cancelled and placed again)"
|
|
1790
|
-
)
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
|
|
1794
|
-
export class BorrowOrderExecutionDisabled extends Error {
|
|
1795
|
-
static readonly code = 6141
|
|
1796
|
-
readonly code = 6141
|
|
1797
|
-
readonly name = "BorrowOrderExecutionDisabled"
|
|
1798
|
-
readonly msg = "Execution of borrow orders is disabled"
|
|
1799
|
-
|
|
1800
|
-
constructor(readonly logs?: string[]) {
|
|
1801
|
-
super("6141: Execution of borrow orders is disabled")
|
|
1802
|
-
}
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1805
|
-
export class DebtReachedReserveDebtTerm extends Error {
|
|
1806
|
-
static readonly code = 6142
|
|
1807
|
-
readonly code = 6142
|
|
1808
|
-
readonly name = "DebtReachedReserveDebtTerm"
|
|
1809
|
-
readonly msg =
|
|
1810
|
-
"Cannot increase the debt that has reached its end of term configured by the reserve"
|
|
1811
|
-
|
|
1812
|
-
constructor(readonly logs?: string[]) {
|
|
1813
|
-
super(
|
|
1814
|
-
"6142: Cannot increase the debt that has reached its end of term configured by the reserve"
|
|
1815
|
-
)
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
|
|
1819
|
-
export class ExpectationNotMet extends Error {
|
|
1820
|
-
static readonly code = 6143
|
|
1821
|
-
readonly code = 6143
|
|
1822
|
-
readonly name = "ExpectationNotMet"
|
|
1823
|
-
readonly msg =
|
|
1824
|
-
"The on-chain state does not meet expectation specified by the caller, so the operation must be aborted (to avoid race conditions)"
|
|
1825
|
-
|
|
1826
|
-
constructor(readonly logs?: string[]) {
|
|
1827
|
-
super(
|
|
1828
|
-
"6143: The on-chain state does not meet expectation specified by the caller, so the operation must be aborted (to avoid race conditions)"
|
|
1829
|
-
)
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
1683
|
export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
1834
1684
|
switch (code) {
|
|
1835
1685
|
case 6000:
|
|
@@ -2098,28 +1948,6 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
|
2098
1948
|
return new ReserveHasNotReceivedInitialDeposit(logs)
|
|
2099
1949
|
case 6132:
|
|
2100
1950
|
return new CTokenUsageBlocked(logs)
|
|
2101
|
-
case 6133:
|
|
2102
|
-
return new CannotUseSameReserve(logs)
|
|
2103
|
-
case 6134:
|
|
2104
|
-
return new TransactionIncludesRestrictedPrograms(logs)
|
|
2105
|
-
case 6135:
|
|
2106
|
-
return new BorrowOrderDebtLiquidityMintMismatch(logs)
|
|
2107
|
-
case 6136:
|
|
2108
|
-
return new BorrowOrderMaxBorrowRateExceeded(logs)
|
|
2109
|
-
case 6137:
|
|
2110
|
-
return new BorrowOrderMinDebtTermInsufficient(logs)
|
|
2111
|
-
case 6138:
|
|
2112
|
-
return new BorrowOrderFillTimeLimitExceeded(logs)
|
|
2113
|
-
case 6139:
|
|
2114
|
-
return new ReserveDebtMaturityReached(logs)
|
|
2115
|
-
case 6140:
|
|
2116
|
-
return new NonUpdatableOrderConfiguration(logs)
|
|
2117
|
-
case 6141:
|
|
2118
|
-
return new BorrowOrderExecutionDisabled(logs)
|
|
2119
|
-
case 6142:
|
|
2120
|
-
return new DebtReachedReserveDebtTerm(logs)
|
|
2121
|
-
case 6143:
|
|
2122
|
-
return new ExpectationNotMet(logs)
|
|
2123
1951
|
}
|
|
2124
1952
|
|
|
2125
1953
|
return null
|
|
@@ -19,6 +19,7 @@ export const DISCRIMINATOR = Buffer.from([130, 80, 38, 153, 80, 212, 182, 253])
|
|
|
19
19
|
|
|
20
20
|
export interface IdlMissingTypesArgs {
|
|
21
21
|
reserveFarmKind: types.ReserveFarmKindKind
|
|
22
|
+
assetTier: types.AssetTierKind
|
|
22
23
|
feeCalculation: types.FeeCalculationKind
|
|
23
24
|
reserveStatus: types.ReserveStatusKind
|
|
24
25
|
updateConfigMode: types.UpdateConfigModeKind
|
|
@@ -35,6 +36,7 @@ export interface IdlMissingTypesAccounts {
|
|
|
35
36
|
|
|
36
37
|
export const layout = borsh.struct([
|
|
37
38
|
types.ReserveFarmKind.layout("reserveFarmKind"),
|
|
39
|
+
types.AssetTier.layout("assetTier"),
|
|
38
40
|
types.FeeCalculation.layout("feeCalculation"),
|
|
39
41
|
types.ReserveStatus.layout("reserveStatus"),
|
|
40
42
|
types.UpdateConfigMode.layout("updateConfigMode"),
|
|
@@ -59,6 +61,7 @@ export function idlMissingTypes(
|
|
|
59
61
|
const len = layout.encode(
|
|
60
62
|
{
|
|
61
63
|
reserveFarmKind: args.reserveFarmKind.toEncodable(),
|
|
64
|
+
assetTier: args.assetTier.toEncodable(),
|
|
62
65
|
feeCalculation: args.feeCalculation.toEncodable(),
|
|
63
66
|
reserveStatus: args.reserveStatus.toEncodable(),
|
|
64
67
|
updateConfigMode: args.updateConfigMode.toEncodable(),
|
|
@@ -190,13 +190,6 @@ export type {
|
|
|
190
190
|
SetObligationOrderArgs,
|
|
191
191
|
SetObligationOrderAccounts,
|
|
192
192
|
} from "./setObligationOrder"
|
|
193
|
-
export { setBorrowOrder } from "./setBorrowOrder"
|
|
194
|
-
export type {
|
|
195
|
-
SetBorrowOrderArgs,
|
|
196
|
-
SetBorrowOrderAccounts,
|
|
197
|
-
} from "./setBorrowOrder"
|
|
198
|
-
export { fillBorrowOrder } from "./fillBorrowOrder"
|
|
199
|
-
export type { FillBorrowOrderAccounts } from "./fillBorrowOrder"
|
|
200
193
|
export { initGlobalConfig } from "./initGlobalConfig"
|
|
201
194
|
export type { InitGlobalConfigAccounts } from "./initGlobalConfig"
|
|
202
195
|
export { updateGlobalConfig } from "./updateGlobalConfig"
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { address, Address } from "@solana/kit" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
5
|
+
import { borshAddress } from "../utils"
|
|
6
|
+
|
|
7
|
+
export interface RegularJSON {
|
|
8
|
+
kind: "Regular"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class Regular {
|
|
12
|
+
static readonly discriminator = 0
|
|
13
|
+
static readonly kind = "Regular"
|
|
14
|
+
readonly discriminator = 0
|
|
15
|
+
readonly kind = "Regular"
|
|
16
|
+
|
|
17
|
+
toJSON(): RegularJSON {
|
|
18
|
+
return {
|
|
19
|
+
kind: "Regular",
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
toEncodable() {
|
|
24
|
+
return {
|
|
25
|
+
Regular: {},
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface IsolatedCollateralJSON {
|
|
31
|
+
kind: "IsolatedCollateral"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class IsolatedCollateral {
|
|
35
|
+
static readonly discriminator = 1
|
|
36
|
+
static readonly kind = "IsolatedCollateral"
|
|
37
|
+
readonly discriminator = 1
|
|
38
|
+
readonly kind = "IsolatedCollateral"
|
|
39
|
+
|
|
40
|
+
toJSON(): IsolatedCollateralJSON {
|
|
41
|
+
return {
|
|
42
|
+
kind: "IsolatedCollateral",
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
toEncodable() {
|
|
47
|
+
return {
|
|
48
|
+
IsolatedCollateral: {},
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface IsolatedDebtJSON {
|
|
54
|
+
kind: "IsolatedDebt"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export class IsolatedDebt {
|
|
58
|
+
static readonly discriminator = 2
|
|
59
|
+
static readonly kind = "IsolatedDebt"
|
|
60
|
+
readonly discriminator = 2
|
|
61
|
+
readonly kind = "IsolatedDebt"
|
|
62
|
+
|
|
63
|
+
toJSON(): IsolatedDebtJSON {
|
|
64
|
+
return {
|
|
65
|
+
kind: "IsolatedDebt",
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
toEncodable() {
|
|
70
|
+
return {
|
|
71
|
+
IsolatedDebt: {},
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
+
export function fromDecoded(obj: any): types.AssetTierKind {
|
|
78
|
+
if (typeof obj !== "object") {
|
|
79
|
+
throw new Error("Invalid enum object")
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if ("Regular" in obj) {
|
|
83
|
+
return new Regular()
|
|
84
|
+
}
|
|
85
|
+
if ("IsolatedCollateral" in obj) {
|
|
86
|
+
return new IsolatedCollateral()
|
|
87
|
+
}
|
|
88
|
+
if ("IsolatedDebt" in obj) {
|
|
89
|
+
return new IsolatedDebt()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
throw new Error("Invalid enum object")
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function fromJSON(obj: types.AssetTierJSON): types.AssetTierKind {
|
|
96
|
+
switch (obj.kind) {
|
|
97
|
+
case "Regular": {
|
|
98
|
+
return new Regular()
|
|
99
|
+
}
|
|
100
|
+
case "IsolatedCollateral": {
|
|
101
|
+
return new IsolatedCollateral()
|
|
102
|
+
}
|
|
103
|
+
case "IsolatedDebt": {
|
|
104
|
+
return new IsolatedDebt()
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function layout(property?: string) {
|
|
110
|
+
const ret = borsh.rustEnum([
|
|
111
|
+
borsh.struct([], "Regular"),
|
|
112
|
+
borsh.struct([], "IsolatedCollateral"),
|
|
113
|
+
borsh.struct([], "IsolatedDebt"),
|
|
114
|
+
])
|
|
115
|
+
if (property !== undefined) {
|
|
116
|
+
return ret.replicate(property)
|
|
117
|
+
}
|
|
118
|
+
return ret
|
|
119
|
+
}
|