@kamino-finance/klend-sdk 5.11.18 → 5.12.0
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/classes/action.d.ts +9 -1
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +15 -1
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/fraction.d.ts +6 -5
- package/dist/classes/fraction.d.ts.map +1 -1
- package/dist/classes/fraction.js +13 -8
- package/dist/classes/fraction.js.map +1 -1
- package/dist/classes/manager.d.ts +1 -1
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +10 -0
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts +54 -1
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +47 -1
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/obligationOrder.d.ts +206 -0
- package/dist/classes/obligationOrder.d.ts.map +1 -0
- package/dist/classes/obligationOrder.js +359 -0
- package/dist/classes/obligationOrder.js.map +1 -0
- package/dist/classes/reserve.d.ts +5 -5
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +80 -264
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/types.d.ts +14 -1
- package/dist/classes/types.d.ts.map +1 -1
- package/dist/classes/utils.d.ts +9 -0
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +21 -0
- package/dist/classes/utils.js.map +1 -1
- package/dist/client_kamino_manager.js +6 -6
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +244 -23
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +12 -6
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +15 -3
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.d.ts +27 -6
- package/dist/idl_codegen/accounts/Obligation.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.js +26 -9
- package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +36 -4
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +64 -8
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +2 -0
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +3 -1
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/setObligationOrder.d.ts +14 -0
- package/dist/idl_codegen/instructions/setObligationOrder.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/setObligationOrder.js +62 -0
- package/dist/idl_codegen/instructions/setObligationOrder.js.map +1 -0
- package/dist/idl_codegen/types/ObligationOrder.d.ts +284 -0
- package/dist/idl_codegen/types/ObligationOrder.d.ts.map +1 -0
- package/dist/idl_codegen/types/ObligationOrder.js +205 -0
- package/dist/idl_codegen/types/ObligationOrder.js.map +1 -0
- package/dist/idl_codegen/types/ReserveConfig.d.ts +26 -11
- package/dist/idl_codegen/types/ReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen/types/ReserveConfig.js +15 -10
- package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts +34 -21
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.js +58 -34
- package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +13 -0
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +25 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +6 -4
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen/types/index.js +3 -1
- package/dist/idl_codegen/types/index.js.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +13 -6
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.js +25 -11
- package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
- package/dist/utils/instruction.d.ts +1 -1
- package/dist/utils/instruction.d.ts.map +1 -1
- package/dist/utils/instruction.js +5 -1
- package/dist/utils/instruction.js.map +1 -1
- package/dist/utils/managerTypes.js +2 -2
- package/dist/utils/managerTypes.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/action.ts +26 -1
- package/src/classes/fraction.ts +16 -12
- package/src/classes/manager.ts +13 -0
- package/src/classes/obligation.ts +77 -1
- package/src/classes/obligationOrder.ts +514 -0
- package/src/classes/reserve.ts +257 -336
- package/src/classes/types.ts +15 -1
- package/src/classes/utils.ts +21 -0
- package/src/client_kamino_manager.ts +6 -6
- package/src/idl.json +244 -23
- package/src/idl_codegen/accounts/LendingMarket.ts +23 -7
- package/src/idl_codegen/accounts/Obligation.ts +50 -13
- package/src/idl_codegen/errors/custom.ts +68 -6
- package/src/idl_codegen/instructions/index.ts +5 -0
- package/src/idl_codegen/instructions/setObligationOrder.ts +45 -0
- package/src/idl_codegen/types/ObligationOrder.ts +347 -0
- package/src/idl_codegen/types/ReserveConfig.ts +31 -16
- package/src/idl_codegen/types/UpdateConfigMode.ts +69 -39
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +30 -0
- package/src/idl_codegen/types/index.ts +15 -6
- package/src/idl_codegen/zero_padding/ObligationZP.ts +37 -15
- package/src/utils/instruction.ts +5 -1
- package/src/utils/managerTypes.ts +2 -2
|
@@ -35,8 +35,8 @@ export interface ObligationFields {
|
|
|
35
35
|
borrowsAssetTiers: Array<number>
|
|
36
36
|
/** The elevation group id the obligation opted into. */
|
|
37
37
|
elevationGroup: number
|
|
38
|
-
/** The number of
|
|
39
|
-
|
|
38
|
+
/** The number of obsolete reserves the obligation has a deposit in */
|
|
39
|
+
numOfObsoleteDepositReserves: number
|
|
40
40
|
/** Marked = 1 if borrows array is not empty, 0 = borrows empty */
|
|
41
41
|
hasDebt: number
|
|
42
42
|
/** Wallet address of the referrer */
|
|
@@ -50,6 +50,8 @@ export interface ObligationFields {
|
|
|
50
50
|
autodeleverageTargetLtvPct: number
|
|
51
51
|
/** The lowest max LTV found amongst the collateral deposits */
|
|
52
52
|
lowestReserveDepositMaxLtvPct: number
|
|
53
|
+
/** The number of obsolete reserves the obligation has a borrow in */
|
|
54
|
+
numOfObsoleteBorrowReserves: number
|
|
53
55
|
reserved: Array<number>
|
|
54
56
|
highestBorrowFactorPct: BN
|
|
55
57
|
/**
|
|
@@ -57,6 +59,11 @@ export interface ObligationFields {
|
|
|
57
59
|
* Zero if not currently subject to deleveraging.
|
|
58
60
|
*/
|
|
59
61
|
autodeleverageMarginCallStartedTimestamp: BN
|
|
62
|
+
/**
|
|
63
|
+
* Owner-defined, liquidator-executed orders applicable to this obligation.
|
|
64
|
+
* Typical use-cases would be a stop-loss and a take-profit (possibly co-existing).
|
|
65
|
+
*/
|
|
66
|
+
orders: Array<types.ObligationOrderFields>
|
|
60
67
|
padding3: Array<BN>
|
|
61
68
|
}
|
|
62
69
|
|
|
@@ -91,8 +98,8 @@ export interface ObligationJSON {
|
|
|
91
98
|
borrowsAssetTiers: Array<number>
|
|
92
99
|
/** The elevation group id the obligation opted into. */
|
|
93
100
|
elevationGroup: number
|
|
94
|
-
/** The number of
|
|
95
|
-
|
|
101
|
+
/** The number of obsolete reserves the obligation has a deposit in */
|
|
102
|
+
numOfObsoleteDepositReserves: number
|
|
96
103
|
/** Marked = 1 if borrows array is not empty, 0 = borrows empty */
|
|
97
104
|
hasDebt: number
|
|
98
105
|
/** Wallet address of the referrer */
|
|
@@ -106,6 +113,8 @@ export interface ObligationJSON {
|
|
|
106
113
|
autodeleverageTargetLtvPct: number
|
|
107
114
|
/** The lowest max LTV found amongst the collateral deposits */
|
|
108
115
|
lowestReserveDepositMaxLtvPct: number
|
|
116
|
+
/** The number of obsolete reserves the obligation has a borrow in */
|
|
117
|
+
numOfObsoleteBorrowReserves: number
|
|
109
118
|
reserved: Array<number>
|
|
110
119
|
highestBorrowFactorPct: string
|
|
111
120
|
/**
|
|
@@ -113,6 +122,11 @@ export interface ObligationJSON {
|
|
|
113
122
|
* Zero if not currently subject to deleveraging.
|
|
114
123
|
*/
|
|
115
124
|
autodeleverageMarginCallStartedTimestamp: string
|
|
125
|
+
/**
|
|
126
|
+
* Owner-defined, liquidator-executed orders applicable to this obligation.
|
|
127
|
+
* Typical use-cases would be a stop-loss and a take-profit (possibly co-existing).
|
|
128
|
+
*/
|
|
129
|
+
orders: Array<types.ObligationOrderJSON>
|
|
116
130
|
padding3: Array<string>
|
|
117
131
|
}
|
|
118
132
|
|
|
@@ -148,8 +162,8 @@ export class Obligation {
|
|
|
148
162
|
readonly borrowsAssetTiers: Array<number>
|
|
149
163
|
/** The elevation group id the obligation opted into. */
|
|
150
164
|
readonly elevationGroup: number
|
|
151
|
-
/** The number of
|
|
152
|
-
readonly
|
|
165
|
+
/** The number of obsolete reserves the obligation has a deposit in */
|
|
166
|
+
readonly numOfObsoleteDepositReserves: number
|
|
153
167
|
/** Marked = 1 if borrows array is not empty, 0 = borrows empty */
|
|
154
168
|
readonly hasDebt: number
|
|
155
169
|
/** Wallet address of the referrer */
|
|
@@ -163,6 +177,8 @@ export class Obligation {
|
|
|
163
177
|
readonly autodeleverageTargetLtvPct: number
|
|
164
178
|
/** The lowest max LTV found amongst the collateral deposits */
|
|
165
179
|
readonly lowestReserveDepositMaxLtvPct: number
|
|
180
|
+
/** The number of obsolete reserves the obligation has a borrow in */
|
|
181
|
+
readonly numOfObsoleteBorrowReserves: number
|
|
166
182
|
readonly reserved: Array<number>
|
|
167
183
|
readonly highestBorrowFactorPct: BN
|
|
168
184
|
/**
|
|
@@ -170,6 +186,11 @@ export class Obligation {
|
|
|
170
186
|
* Zero if not currently subject to deleveraging.
|
|
171
187
|
*/
|
|
172
188
|
readonly autodeleverageMarginCallStartedTimestamp: BN
|
|
189
|
+
/**
|
|
190
|
+
* Owner-defined, liquidator-executed orders applicable to this obligation.
|
|
191
|
+
* Typical use-cases would be a stop-loss and a take-profit (possibly co-existing).
|
|
192
|
+
*/
|
|
193
|
+
readonly orders: Array<types.ObligationOrder>
|
|
173
194
|
readonly padding3: Array<BN>
|
|
174
195
|
|
|
175
196
|
static readonly discriminator = Buffer.from([
|
|
@@ -192,16 +213,18 @@ export class Obligation {
|
|
|
192
213
|
borsh.array(borsh.u8(), 8, "depositsAssetTiers"),
|
|
193
214
|
borsh.array(borsh.u8(), 5, "borrowsAssetTiers"),
|
|
194
215
|
borsh.u8("elevationGroup"),
|
|
195
|
-
borsh.u8("
|
|
216
|
+
borsh.u8("numOfObsoleteDepositReserves"),
|
|
196
217
|
borsh.u8("hasDebt"),
|
|
197
218
|
borsh.publicKey("referrer"),
|
|
198
219
|
borsh.u8("borrowingDisabled"),
|
|
199
220
|
borsh.u8("autodeleverageTargetLtvPct"),
|
|
200
221
|
borsh.u8("lowestReserveDepositMaxLtvPct"),
|
|
201
|
-
borsh.
|
|
222
|
+
borsh.u8("numOfObsoleteBorrowReserves"),
|
|
223
|
+
borsh.array(borsh.u8(), 4, "reserved"),
|
|
202
224
|
borsh.u64("highestBorrowFactorPct"),
|
|
203
225
|
borsh.u64("autodeleverageMarginCallStartedTimestamp"),
|
|
204
|
-
borsh.array(
|
|
226
|
+
borsh.array(types.ObligationOrder.layout(), 2, "orders"),
|
|
227
|
+
borsh.array(borsh.u64(), 93, "padding3"),
|
|
205
228
|
])
|
|
206
229
|
|
|
207
230
|
constructor(fields: ObligationFields) {
|
|
@@ -226,16 +249,20 @@ export class Obligation {
|
|
|
226
249
|
this.depositsAssetTiers = fields.depositsAssetTiers
|
|
227
250
|
this.borrowsAssetTiers = fields.borrowsAssetTiers
|
|
228
251
|
this.elevationGroup = fields.elevationGroup
|
|
229
|
-
this.
|
|
252
|
+
this.numOfObsoleteDepositReserves = fields.numOfObsoleteDepositReserves
|
|
230
253
|
this.hasDebt = fields.hasDebt
|
|
231
254
|
this.referrer = fields.referrer
|
|
232
255
|
this.borrowingDisabled = fields.borrowingDisabled
|
|
233
256
|
this.autodeleverageTargetLtvPct = fields.autodeleverageTargetLtvPct
|
|
234
257
|
this.lowestReserveDepositMaxLtvPct = fields.lowestReserveDepositMaxLtvPct
|
|
258
|
+
this.numOfObsoleteBorrowReserves = fields.numOfObsoleteBorrowReserves
|
|
235
259
|
this.reserved = fields.reserved
|
|
236
260
|
this.highestBorrowFactorPct = fields.highestBorrowFactorPct
|
|
237
261
|
this.autodeleverageMarginCallStartedTimestamp =
|
|
238
262
|
fields.autodeleverageMarginCallStartedTimestamp
|
|
263
|
+
this.orders = fields.orders.map(
|
|
264
|
+
(item) => new types.ObligationOrder({ ...item })
|
|
265
|
+
)
|
|
239
266
|
this.padding3 = fields.padding3
|
|
240
267
|
}
|
|
241
268
|
|
|
@@ -307,16 +334,22 @@ export class Obligation {
|
|
|
307
334
|
depositsAssetTiers: dec.depositsAssetTiers,
|
|
308
335
|
borrowsAssetTiers: dec.borrowsAssetTiers,
|
|
309
336
|
elevationGroup: dec.elevationGroup,
|
|
310
|
-
|
|
337
|
+
numOfObsoleteDepositReserves: dec.numOfObsoleteDepositReserves,
|
|
311
338
|
hasDebt: dec.hasDebt,
|
|
312
339
|
referrer: dec.referrer,
|
|
313
340
|
borrowingDisabled: dec.borrowingDisabled,
|
|
314
341
|
autodeleverageTargetLtvPct: dec.autodeleverageTargetLtvPct,
|
|
315
342
|
lowestReserveDepositMaxLtvPct: dec.lowestReserveDepositMaxLtvPct,
|
|
343
|
+
numOfObsoleteBorrowReserves: dec.numOfObsoleteBorrowReserves,
|
|
316
344
|
reserved: dec.reserved,
|
|
317
345
|
highestBorrowFactorPct: dec.highestBorrowFactorPct,
|
|
318
346
|
autodeleverageMarginCallStartedTimestamp:
|
|
319
347
|
dec.autodeleverageMarginCallStartedTimestamp,
|
|
348
|
+
orders: dec.orders.map(
|
|
349
|
+
(
|
|
350
|
+
item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
|
351
|
+
) => types.ObligationOrder.fromDecoded(item)
|
|
352
|
+
),
|
|
320
353
|
padding3: dec.padding3,
|
|
321
354
|
})
|
|
322
355
|
}
|
|
@@ -340,16 +373,18 @@ export class Obligation {
|
|
|
340
373
|
depositsAssetTiers: this.depositsAssetTiers,
|
|
341
374
|
borrowsAssetTiers: this.borrowsAssetTiers,
|
|
342
375
|
elevationGroup: this.elevationGroup,
|
|
343
|
-
|
|
376
|
+
numOfObsoleteDepositReserves: this.numOfObsoleteDepositReserves,
|
|
344
377
|
hasDebt: this.hasDebt,
|
|
345
378
|
referrer: this.referrer.toString(),
|
|
346
379
|
borrowingDisabled: this.borrowingDisabled,
|
|
347
380
|
autodeleverageTargetLtvPct: this.autodeleverageTargetLtvPct,
|
|
348
381
|
lowestReserveDepositMaxLtvPct: this.lowestReserveDepositMaxLtvPct,
|
|
382
|
+
numOfObsoleteBorrowReserves: this.numOfObsoleteBorrowReserves,
|
|
349
383
|
reserved: this.reserved,
|
|
350
384
|
highestBorrowFactorPct: this.highestBorrowFactorPct.toString(),
|
|
351
385
|
autodeleverageMarginCallStartedTimestamp:
|
|
352
386
|
this.autodeleverageMarginCallStartedTimestamp.toString(),
|
|
387
|
+
orders: this.orders.map((item) => item.toJSON()),
|
|
353
388
|
padding3: this.padding3.map((item) => item.toString()),
|
|
354
389
|
}
|
|
355
390
|
}
|
|
@@ -379,17 +414,19 @@ export class Obligation {
|
|
|
379
414
|
depositsAssetTiers: obj.depositsAssetTiers,
|
|
380
415
|
borrowsAssetTiers: obj.borrowsAssetTiers,
|
|
381
416
|
elevationGroup: obj.elevationGroup,
|
|
382
|
-
|
|
417
|
+
numOfObsoleteDepositReserves: obj.numOfObsoleteDepositReserves,
|
|
383
418
|
hasDebt: obj.hasDebt,
|
|
384
419
|
referrer: new PublicKey(obj.referrer),
|
|
385
420
|
borrowingDisabled: obj.borrowingDisabled,
|
|
386
421
|
autodeleverageTargetLtvPct: obj.autodeleverageTargetLtvPct,
|
|
387
422
|
lowestReserveDepositMaxLtvPct: obj.lowestReserveDepositMaxLtvPct,
|
|
423
|
+
numOfObsoleteBorrowReserves: obj.numOfObsoleteBorrowReserves,
|
|
388
424
|
reserved: obj.reserved,
|
|
389
425
|
highestBorrowFactorPct: new BN(obj.highestBorrowFactorPct),
|
|
390
426
|
autodeleverageMarginCallStartedTimestamp: new BN(
|
|
391
427
|
obj.autodeleverageMarginCallStartedTimestamp
|
|
392
428
|
),
|
|
429
|
+
orders: obj.orders.map((item) => types.ObligationOrder.fromJSON(item)),
|
|
393
430
|
padding3: obj.padding3.map((item) => new BN(item)),
|
|
394
431
|
})
|
|
395
432
|
}
|
|
@@ -83,7 +83,7 @@ export type CustomError =
|
|
|
83
83
|
| ShortUrlNotAsciiAlphanumeric
|
|
84
84
|
| ReserveObsolete
|
|
85
85
|
| ElevationGroupAlreadyActivated
|
|
86
|
-
|
|
|
86
|
+
| ObligationInObsoleteReserve
|
|
87
87
|
| ReferrerStateOwnerMismatch
|
|
88
88
|
| UserMetadataOwnerAlreadySet
|
|
89
89
|
| CollateralNonLiquidatable
|
|
@@ -122,6 +122,10 @@ export type CustomError =
|
|
|
122
122
|
| FarmAccountsMissing
|
|
123
123
|
| RepayTooSmallForFullLiquidation
|
|
124
124
|
| InsufficientRepayAmount
|
|
125
|
+
| OrderIndexOutOfBounds
|
|
126
|
+
| InvalidOrderConfiguration
|
|
127
|
+
| OrderConfigurationNotSupportedByObligation
|
|
128
|
+
| OperationNotPermittedWithCurrentObligationOrders
|
|
125
129
|
|
|
126
130
|
export class InvalidMarketAuthority extends Error {
|
|
127
131
|
static readonly code = 6000
|
|
@@ -1080,14 +1084,14 @@ export class ElevationGroupAlreadyActivated extends Error {
|
|
|
1080
1084
|
}
|
|
1081
1085
|
}
|
|
1082
1086
|
|
|
1083
|
-
export class
|
|
1087
|
+
export class ObligationInObsoleteReserve extends Error {
|
|
1084
1088
|
static readonly code = 6084
|
|
1085
1089
|
readonly code = 6084
|
|
1086
|
-
readonly name = "
|
|
1087
|
-
readonly msg = "Obligation has a deposit in
|
|
1090
|
+
readonly name = "ObligationInObsoleteReserve"
|
|
1091
|
+
readonly msg = "Obligation has a deposit or borrow in an obsolete reserve"
|
|
1088
1092
|
|
|
1089
1093
|
constructor(readonly logs?: string[]) {
|
|
1090
|
-
super("6084: Obligation has a deposit in
|
|
1094
|
+
super("6084: Obligation has a deposit or borrow in an obsolete reserve")
|
|
1091
1095
|
}
|
|
1092
1096
|
}
|
|
1093
1097
|
|
|
@@ -1548,6 +1552,56 @@ export class InsufficientRepayAmount extends Error {
|
|
|
1548
1552
|
}
|
|
1549
1553
|
}
|
|
1550
1554
|
|
|
1555
|
+
export class OrderIndexOutOfBounds extends Error {
|
|
1556
|
+
static readonly code = 6123
|
|
1557
|
+
readonly code = 6123
|
|
1558
|
+
readonly name = "OrderIndexOutOfBounds"
|
|
1559
|
+
readonly msg = "Obligation order of the given index cannot exist"
|
|
1560
|
+
|
|
1561
|
+
constructor(readonly logs?: string[]) {
|
|
1562
|
+
super("6123: Obligation order of the given index cannot exist")
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
export class InvalidOrderConfiguration extends Error {
|
|
1567
|
+
static readonly code = 6124
|
|
1568
|
+
readonly code = 6124
|
|
1569
|
+
readonly name = "InvalidOrderConfiguration"
|
|
1570
|
+
readonly msg = "Given order configuration has wrong parameters"
|
|
1571
|
+
|
|
1572
|
+
constructor(readonly logs?: string[]) {
|
|
1573
|
+
super("6124: Given order configuration has wrong parameters")
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
export class OrderConfigurationNotSupportedByObligation extends Error {
|
|
1578
|
+
static readonly code = 6125
|
|
1579
|
+
readonly code = 6125
|
|
1580
|
+
readonly name = "OrderConfigurationNotSupportedByObligation"
|
|
1581
|
+
readonly msg =
|
|
1582
|
+
"Given order configuration cannot be used with the current state of the obligation"
|
|
1583
|
+
|
|
1584
|
+
constructor(readonly logs?: string[]) {
|
|
1585
|
+
super(
|
|
1586
|
+
"6125: Given order configuration cannot be used with the current state of the obligation"
|
|
1587
|
+
)
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
export class OperationNotPermittedWithCurrentObligationOrders extends Error {
|
|
1592
|
+
static readonly code = 6126
|
|
1593
|
+
readonly code = 6126
|
|
1594
|
+
readonly name = "OperationNotPermittedWithCurrentObligationOrders"
|
|
1595
|
+
readonly msg =
|
|
1596
|
+
"Single debt, single collateral obligation orders have to be cancelled before changing the deposit/borrow count"
|
|
1597
|
+
|
|
1598
|
+
constructor(readonly logs?: string[]) {
|
|
1599
|
+
super(
|
|
1600
|
+
"6126: Single debt, single collateral obligation orders have to be cancelled before changing the deposit/borrow count"
|
|
1601
|
+
)
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1551
1605
|
export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
1552
1606
|
switch (code) {
|
|
1553
1607
|
case 6000:
|
|
@@ -1719,7 +1773,7 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
|
1719
1773
|
case 6083:
|
|
1720
1774
|
return new ElevationGroupAlreadyActivated(logs)
|
|
1721
1775
|
case 6084:
|
|
1722
|
-
return new
|
|
1776
|
+
return new ObligationInObsoleteReserve(logs)
|
|
1723
1777
|
case 6085:
|
|
1724
1778
|
return new ReferrerStateOwnerMismatch(logs)
|
|
1725
1779
|
case 6086:
|
|
@@ -1796,6 +1850,14 @@ export function fromCode(code: number, logs?: string[]): CustomError | null {
|
|
|
1796
1850
|
return new RepayTooSmallForFullLiquidation(logs)
|
|
1797
1851
|
case 6122:
|
|
1798
1852
|
return new InsufficientRepayAmount(logs)
|
|
1853
|
+
case 6123:
|
|
1854
|
+
return new OrderIndexOutOfBounds(logs)
|
|
1855
|
+
case 6124:
|
|
1856
|
+
return new InvalidOrderConfiguration(logs)
|
|
1857
|
+
case 6125:
|
|
1858
|
+
return new OrderConfigurationNotSupportedByObligation(logs)
|
|
1859
|
+
case 6126:
|
|
1860
|
+
return new OperationNotPermittedWithCurrentObligationOrders(logs)
|
|
1799
1861
|
}
|
|
1800
1862
|
|
|
1801
1863
|
return null
|
|
@@ -183,6 +183,11 @@ export type {
|
|
|
183
183
|
} from "./initReferrerStateAndShortUrl"
|
|
184
184
|
export { deleteReferrerStateAndShortUrl } from "./deleteReferrerStateAndShortUrl"
|
|
185
185
|
export type { DeleteReferrerStateAndShortUrlAccounts } from "./deleteReferrerStateAndShortUrl"
|
|
186
|
+
export { setObligationOrder } from "./setObligationOrder"
|
|
187
|
+
export type {
|
|
188
|
+
SetObligationOrderArgs,
|
|
189
|
+
SetObligationOrderAccounts,
|
|
190
|
+
} from "./setObligationOrder"
|
|
186
191
|
export { idlMissingTypes } from "./idlMissingTypes"
|
|
187
192
|
export type {
|
|
188
193
|
IdlMissingTypesArgs,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // 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 borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
|
6
|
+
|
|
7
|
+
export interface SetObligationOrderArgs {
|
|
8
|
+
index: number
|
|
9
|
+
order: types.ObligationOrderFields
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SetObligationOrderAccounts {
|
|
13
|
+
owner: PublicKey
|
|
14
|
+
obligation: PublicKey
|
|
15
|
+
lendingMarket: PublicKey
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const layout = borsh.struct([
|
|
19
|
+
borsh.u8("index"),
|
|
20
|
+
types.ObligationOrder.layout("order"),
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
export function setObligationOrder(
|
|
24
|
+
args: SetObligationOrderArgs,
|
|
25
|
+
accounts: SetObligationOrderAccounts,
|
|
26
|
+
programId: PublicKey = PROGRAM_ID
|
|
27
|
+
) {
|
|
28
|
+
const keys: Array<AccountMeta> = [
|
|
29
|
+
{ pubkey: accounts.owner, isSigner: true, isWritable: false },
|
|
30
|
+
{ pubkey: accounts.obligation, isSigner: false, isWritable: true },
|
|
31
|
+
{ pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
|
|
32
|
+
]
|
|
33
|
+
const identifier = Buffer.from([81, 1, 99, 156, 211, 83, 78, 46])
|
|
34
|
+
const buffer = Buffer.alloc(1000)
|
|
35
|
+
const len = layout.encode(
|
|
36
|
+
{
|
|
37
|
+
index: args.index,
|
|
38
|
+
order: types.ObligationOrder.toEncodable(args.order),
|
|
39
|
+
},
|
|
40
|
+
buffer
|
|
41
|
+
)
|
|
42
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
43
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
44
|
+
return ix
|
|
45
|
+
}
|