@kamino-finance/klend-sdk 5.11.18 → 5.12.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.
Files changed (112) hide show
  1. package/dist/classes/action.d.ts +9 -1
  2. package/dist/classes/action.d.ts.map +1 -1
  3. package/dist/classes/action.js +15 -1
  4. package/dist/classes/action.js.map +1 -1
  5. package/dist/classes/fraction.d.ts +6 -5
  6. package/dist/classes/fraction.d.ts.map +1 -1
  7. package/dist/classes/fraction.js +13 -8
  8. package/dist/classes/fraction.js.map +1 -1
  9. package/dist/classes/manager.d.ts +3 -2
  10. package/dist/classes/manager.d.ts.map +1 -1
  11. package/dist/classes/manager.js +13 -2
  12. package/dist/classes/manager.js.map +1 -1
  13. package/dist/classes/obligation.d.ts +54 -1
  14. package/dist/classes/obligation.d.ts.map +1 -1
  15. package/dist/classes/obligation.js +47 -1
  16. package/dist/classes/obligation.js.map +1 -1
  17. package/dist/classes/obligationOrder.d.ts +206 -0
  18. package/dist/classes/obligationOrder.d.ts.map +1 -0
  19. package/dist/classes/obligationOrder.js +359 -0
  20. package/dist/classes/obligationOrder.js.map +1 -0
  21. package/dist/classes/reserve.d.ts +5 -5
  22. package/dist/classes/reserve.d.ts.map +1 -1
  23. package/dist/classes/reserve.js +80 -264
  24. package/dist/classes/reserve.js.map +1 -1
  25. package/dist/classes/types.d.ts +14 -1
  26. package/dist/classes/types.d.ts.map +1 -1
  27. package/dist/classes/utils.d.ts +9 -0
  28. package/dist/classes/utils.d.ts.map +1 -1
  29. package/dist/classes/utils.js +21 -0
  30. package/dist/classes/utils.js.map +1 -1
  31. package/dist/classes/vault.d.ts +2 -1
  32. package/dist/classes/vault.d.ts.map +1 -1
  33. package/dist/classes/vault.js +4 -2
  34. package/dist/classes/vault.js.map +1 -1
  35. package/dist/client_kamino_manager.js +6 -6
  36. package/dist/client_kamino_manager.js.map +1 -1
  37. package/dist/idl.json +244 -23
  38. package/dist/idl_codegen/accounts/LendingMarket.d.ts +12 -6
  39. package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
  40. package/dist/idl_codegen/accounts/LendingMarket.js +15 -3
  41. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  42. package/dist/idl_codegen/accounts/Obligation.d.ts +27 -6
  43. package/dist/idl_codegen/accounts/Obligation.d.ts.map +1 -1
  44. package/dist/idl_codegen/accounts/Obligation.js +26 -9
  45. package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
  46. package/dist/idl_codegen/errors/custom.d.ts +36 -4
  47. package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
  48. package/dist/idl_codegen/errors/custom.js +64 -8
  49. package/dist/idl_codegen/errors/custom.js.map +1 -1
  50. package/dist/idl_codegen/instructions/index.d.ts +2 -0
  51. package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
  52. package/dist/idl_codegen/instructions/index.js +3 -1
  53. package/dist/idl_codegen/instructions/index.js.map +1 -1
  54. package/dist/idl_codegen/instructions/setObligationOrder.d.ts +14 -0
  55. package/dist/idl_codegen/instructions/setObligationOrder.d.ts.map +1 -0
  56. package/dist/idl_codegen/instructions/setObligationOrder.js +62 -0
  57. package/dist/idl_codegen/instructions/setObligationOrder.js.map +1 -0
  58. package/dist/idl_codegen/types/ObligationOrder.d.ts +284 -0
  59. package/dist/idl_codegen/types/ObligationOrder.d.ts.map +1 -0
  60. package/dist/idl_codegen/types/ObligationOrder.js +205 -0
  61. package/dist/idl_codegen/types/ObligationOrder.js.map +1 -0
  62. package/dist/idl_codegen/types/ReserveConfig.d.ts +26 -11
  63. package/dist/idl_codegen/types/ReserveConfig.d.ts.map +1 -1
  64. package/dist/idl_codegen/types/ReserveConfig.js +15 -10
  65. package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
  66. package/dist/idl_codegen/types/UpdateConfigMode.d.ts +34 -21
  67. package/dist/idl_codegen/types/UpdateConfigMode.d.ts.map +1 -1
  68. package/dist/idl_codegen/types/UpdateConfigMode.js +58 -34
  69. package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
  70. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +13 -0
  71. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
  72. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +25 -1
  73. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  74. package/dist/idl_codegen/types/index.d.ts +6 -4
  75. package/dist/idl_codegen/types/index.d.ts.map +1 -1
  76. package/dist/idl_codegen/types/index.js +3 -1
  77. package/dist/idl_codegen/types/index.js.map +1 -1
  78. package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +13 -6
  79. package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
  80. package/dist/idl_codegen/zero_padding/ObligationZP.js +25 -11
  81. package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
  82. package/dist/utils/instruction.d.ts +1 -1
  83. package/dist/utils/instruction.d.ts.map +1 -1
  84. package/dist/utils/instruction.js +5 -1
  85. package/dist/utils/instruction.js.map +1 -1
  86. package/dist/utils/managerTypes.js +2 -2
  87. package/dist/utils/managerTypes.js.map +1 -1
  88. package/package.json +1 -1
  89. package/src/classes/action.ts +26 -1
  90. package/src/classes/fraction.ts +16 -12
  91. package/src/classes/manager.ts +17 -2
  92. package/src/classes/obligation.ts +77 -1
  93. package/src/classes/obligationOrder.ts +514 -0
  94. package/src/classes/reserve.ts +257 -336
  95. package/src/classes/types.ts +15 -1
  96. package/src/classes/utils.ts +21 -0
  97. package/src/classes/vault.ts +5 -2
  98. package/src/client_kamino_manager.ts +6 -6
  99. package/src/idl.json +244 -23
  100. package/src/idl_codegen/accounts/LendingMarket.ts +23 -7
  101. package/src/idl_codegen/accounts/Obligation.ts +50 -13
  102. package/src/idl_codegen/errors/custom.ts +68 -6
  103. package/src/idl_codegen/instructions/index.ts +5 -0
  104. package/src/idl_codegen/instructions/setObligationOrder.ts +45 -0
  105. package/src/idl_codegen/types/ObligationOrder.ts +347 -0
  106. package/src/idl_codegen/types/ReserveConfig.ts +31 -16
  107. package/src/idl_codegen/types/UpdateConfigMode.ts +69 -39
  108. package/src/idl_codegen/types/UpdateLendingMarketMode.ts +30 -0
  109. package/src/idl_codegen/types/index.ts +15 -6
  110. package/src/idl_codegen/zero_padding/ObligationZP.ts +37 -15
  111. package/src/utils/instruction.ts +5 -1
  112. package/src/utils/managerTypes.ts +2 -2
@@ -0,0 +1,347 @@
1
+ import { PublicKey } 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 types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as borsh from "@coral-xyz/borsh"
5
+
6
+ export interface ObligationOrderFields {
7
+ /**
8
+ * A threshold value used by the condition (scaled [Fraction]).
9
+ * The exact meaning depends on the specific [Self::condition_type].
10
+ *
11
+ * Examples:
12
+ * - when `condition_type == 2 (UserLtvBelow)`:
13
+ * then a value of `0.455` here means that the order is active only when the obligation's
14
+ * user LTV is less than `0.455` (i.e. < 45.5%).
15
+ * - when `condition_type == 3 (DebtCollPriceRatioAbove)`:
16
+ * assuming the obligation uses BTC collateral for SOL debt, then a value of `491.3` here
17
+ * means that the order is active only when the BTC-SOL price is greater than `491.3` (i.e.
18
+ * > 491.3 SOL per BTC).
19
+ */
20
+ conditionThresholdSf: BN
21
+ /**
22
+ * A configuration parameter used by the opportunity (scaled [Fraction]).
23
+ * The exact meaning depends on the specific [Self::opportunity_type].
24
+ *
25
+ * Examples:
26
+ * - when `opportunity_type == 0 (DeleverageSingleDebtAmount)`:
27
+ * Assuming the obligation uses BTC collateral for SOL debt, then a value of `1_234_000_000`
28
+ * here means that a liquidator may repay up to 1234000000 lamports (i.e. 1.234 SOL) on this
29
+ * obligation.
30
+ * Note: the special value of [Fraction::MAX] is *not* allowed in this case.
31
+ * - when `opportunity_type == 1 (DeleverageAllDebtAmount)`:
32
+ * The only allowed value in this case is [Fraction::MAX] (to emphasize that *all* debt
33
+ * should be repaid).
34
+ */
35
+ opportunityParameterSf: BN
36
+ /**
37
+ * A *minimum* additional fraction of collateral transferred to the liquidator, in bps.
38
+ *
39
+ * The minimum bonus is applied exactly when the [Self::condition_threshold_sf] is met, and
40
+ * grows linearly towards the [Self::max_execution_bonus_bps].
41
+ *
42
+ * Example: a value of `50` here means 50bps == 0.5% bonus for an "LTV > 65%" order, when
43
+ * executed precisely at the moment LTV exceeds 65%.
44
+ */
45
+ minExecutionBonusBps: number
46
+ /**
47
+ * A *maximum* additional fraction of collateral transferred to the liquidator, in bps.
48
+ *
49
+ * The maximum bonus is applied at the relevant "extreme" state of the obligation, i.e.:
50
+ * - for a stop-loss condition, it is a point at which the obligation becomes liquidatable;
51
+ * - for a take-profit condition, it is a point at which obligation has 0% LTV.
52
+ *
53
+ * In non-extreme states, the actual bonus value is interpolated linearly, starting from
54
+ * [Self::min_execution_bonus_bps] (at the point specified by the order's condition).
55
+ *
56
+ * Example: a value of `300` here means 300bps == 3.0% bonus for a "debt/coll price > 140"
57
+ * order, when executed at a higher price = 200, at which the obligation's LTV happens to
58
+ * be equal to its liquidation LTV.
59
+ */
60
+ maxExecutionBonusBps: number
61
+ /**
62
+ * Serialized [ConditionType].
63
+ * The entire order is void when this is zeroed (i.e. representing [ConditionType::Never]).
64
+ *
65
+ * Example: a value of `2` here denotes `UserLtvBelow` condition type. Of course, to
66
+ * interpret this condition, we also need to take the [Self::condition_threshold_sf] into
67
+ * account.
68
+ */
69
+ conditionType: number
70
+ /**
71
+ * Serialized [OpportunityType].
72
+ *
73
+ * Example: a value of `0` here denotes `DeleverageSingleDebtAmount` opportunity. Of course, to
74
+ * interpret this opportunity, we also need to take the [Self::opportunity_parameter_sf] into
75
+ * account.
76
+ */
77
+ opportunityType: number
78
+ /**
79
+ * Internal padding.
80
+ * The fields above take up 2+2+1+1 bytes = 48 bits, which means we need 80 bits = 10 bytes to
81
+ * align with `u128`s.
82
+ */
83
+ padding1: Array<number>
84
+ /**
85
+ * End padding.
86
+ * The total size of a single instance is 8*u128 = 128 bytes.
87
+ */
88
+ padding2: Array<BN>
89
+ }
90
+
91
+ export interface ObligationOrderJSON {
92
+ /**
93
+ * A threshold value used by the condition (scaled [Fraction]).
94
+ * The exact meaning depends on the specific [Self::condition_type].
95
+ *
96
+ * Examples:
97
+ * - when `condition_type == 2 (UserLtvBelow)`:
98
+ * then a value of `0.455` here means that the order is active only when the obligation's
99
+ * user LTV is less than `0.455` (i.e. < 45.5%).
100
+ * - when `condition_type == 3 (DebtCollPriceRatioAbove)`:
101
+ * assuming the obligation uses BTC collateral for SOL debt, then a value of `491.3` here
102
+ * means that the order is active only when the BTC-SOL price is greater than `491.3` (i.e.
103
+ * > 491.3 SOL per BTC).
104
+ */
105
+ conditionThresholdSf: string
106
+ /**
107
+ * A configuration parameter used by the opportunity (scaled [Fraction]).
108
+ * The exact meaning depends on the specific [Self::opportunity_type].
109
+ *
110
+ * Examples:
111
+ * - when `opportunity_type == 0 (DeleverageSingleDebtAmount)`:
112
+ * Assuming the obligation uses BTC collateral for SOL debt, then a value of `1_234_000_000`
113
+ * here means that a liquidator may repay up to 1234000000 lamports (i.e. 1.234 SOL) on this
114
+ * obligation.
115
+ * Note: the special value of [Fraction::MAX] is *not* allowed in this case.
116
+ * - when `opportunity_type == 1 (DeleverageAllDebtAmount)`:
117
+ * The only allowed value in this case is [Fraction::MAX] (to emphasize that *all* debt
118
+ * should be repaid).
119
+ */
120
+ opportunityParameterSf: string
121
+ /**
122
+ * A *minimum* additional fraction of collateral transferred to the liquidator, in bps.
123
+ *
124
+ * The minimum bonus is applied exactly when the [Self::condition_threshold_sf] is met, and
125
+ * grows linearly towards the [Self::max_execution_bonus_bps].
126
+ *
127
+ * Example: a value of `50` here means 50bps == 0.5% bonus for an "LTV > 65%" order, when
128
+ * executed precisely at the moment LTV exceeds 65%.
129
+ */
130
+ minExecutionBonusBps: number
131
+ /**
132
+ * A *maximum* additional fraction of collateral transferred to the liquidator, in bps.
133
+ *
134
+ * The maximum bonus is applied at the relevant "extreme" state of the obligation, i.e.:
135
+ * - for a stop-loss condition, it is a point at which the obligation becomes liquidatable;
136
+ * - for a take-profit condition, it is a point at which obligation has 0% LTV.
137
+ *
138
+ * In non-extreme states, the actual bonus value is interpolated linearly, starting from
139
+ * [Self::min_execution_bonus_bps] (at the point specified by the order's condition).
140
+ *
141
+ * Example: a value of `300` here means 300bps == 3.0% bonus for a "debt/coll price > 140"
142
+ * order, when executed at a higher price = 200, at which the obligation's LTV happens to
143
+ * be equal to its liquidation LTV.
144
+ */
145
+ maxExecutionBonusBps: number
146
+ /**
147
+ * Serialized [ConditionType].
148
+ * The entire order is void when this is zeroed (i.e. representing [ConditionType::Never]).
149
+ *
150
+ * Example: a value of `2` here denotes `UserLtvBelow` condition type. Of course, to
151
+ * interpret this condition, we also need to take the [Self::condition_threshold_sf] into
152
+ * account.
153
+ */
154
+ conditionType: number
155
+ /**
156
+ * Serialized [OpportunityType].
157
+ *
158
+ * Example: a value of `0` here denotes `DeleverageSingleDebtAmount` opportunity. Of course, to
159
+ * interpret this opportunity, we also need to take the [Self::opportunity_parameter_sf] into
160
+ * account.
161
+ */
162
+ opportunityType: number
163
+ /**
164
+ * Internal padding.
165
+ * The fields above take up 2+2+1+1 bytes = 48 bits, which means we need 80 bits = 10 bytes to
166
+ * align with `u128`s.
167
+ */
168
+ padding1: Array<number>
169
+ /**
170
+ * End padding.
171
+ * The total size of a single instance is 8*u128 = 128 bytes.
172
+ */
173
+ padding2: Array<string>
174
+ }
175
+
176
+ /**
177
+ * A single obligation order.
178
+ * See [Obligation::orders].
179
+ */
180
+ export class ObligationOrder {
181
+ /**
182
+ * A threshold value used by the condition (scaled [Fraction]).
183
+ * The exact meaning depends on the specific [Self::condition_type].
184
+ *
185
+ * Examples:
186
+ * - when `condition_type == 2 (UserLtvBelow)`:
187
+ * then a value of `0.455` here means that the order is active only when the obligation's
188
+ * user LTV is less than `0.455` (i.e. < 45.5%).
189
+ * - when `condition_type == 3 (DebtCollPriceRatioAbove)`:
190
+ * assuming the obligation uses BTC collateral for SOL debt, then a value of `491.3` here
191
+ * means that the order is active only when the BTC-SOL price is greater than `491.3` (i.e.
192
+ * > 491.3 SOL per BTC).
193
+ */
194
+ readonly conditionThresholdSf: BN
195
+ /**
196
+ * A configuration parameter used by the opportunity (scaled [Fraction]).
197
+ * The exact meaning depends on the specific [Self::opportunity_type].
198
+ *
199
+ * Examples:
200
+ * - when `opportunity_type == 0 (DeleverageSingleDebtAmount)`:
201
+ * Assuming the obligation uses BTC collateral for SOL debt, then a value of `1_234_000_000`
202
+ * here means that a liquidator may repay up to 1234000000 lamports (i.e. 1.234 SOL) on this
203
+ * obligation.
204
+ * Note: the special value of [Fraction::MAX] is *not* allowed in this case.
205
+ * - when `opportunity_type == 1 (DeleverageAllDebtAmount)`:
206
+ * The only allowed value in this case is [Fraction::MAX] (to emphasize that *all* debt
207
+ * should be repaid).
208
+ */
209
+ readonly opportunityParameterSf: BN
210
+ /**
211
+ * A *minimum* additional fraction of collateral transferred to the liquidator, in bps.
212
+ *
213
+ * The minimum bonus is applied exactly when the [Self::condition_threshold_sf] is met, and
214
+ * grows linearly towards the [Self::max_execution_bonus_bps].
215
+ *
216
+ * Example: a value of `50` here means 50bps == 0.5% bonus for an "LTV > 65%" order, when
217
+ * executed precisely at the moment LTV exceeds 65%.
218
+ */
219
+ readonly minExecutionBonusBps: number
220
+ /**
221
+ * A *maximum* additional fraction of collateral transferred to the liquidator, in bps.
222
+ *
223
+ * The maximum bonus is applied at the relevant "extreme" state of the obligation, i.e.:
224
+ * - for a stop-loss condition, it is a point at which the obligation becomes liquidatable;
225
+ * - for a take-profit condition, it is a point at which obligation has 0% LTV.
226
+ *
227
+ * In non-extreme states, the actual bonus value is interpolated linearly, starting from
228
+ * [Self::min_execution_bonus_bps] (at the point specified by the order's condition).
229
+ *
230
+ * Example: a value of `300` here means 300bps == 3.0% bonus for a "debt/coll price > 140"
231
+ * order, when executed at a higher price = 200, at which the obligation's LTV happens to
232
+ * be equal to its liquidation LTV.
233
+ */
234
+ readonly maxExecutionBonusBps: number
235
+ /**
236
+ * Serialized [ConditionType].
237
+ * The entire order is void when this is zeroed (i.e. representing [ConditionType::Never]).
238
+ *
239
+ * Example: a value of `2` here denotes `UserLtvBelow` condition type. Of course, to
240
+ * interpret this condition, we also need to take the [Self::condition_threshold_sf] into
241
+ * account.
242
+ */
243
+ readonly conditionType: number
244
+ /**
245
+ * Serialized [OpportunityType].
246
+ *
247
+ * Example: a value of `0` here denotes `DeleverageSingleDebtAmount` opportunity. Of course, to
248
+ * interpret this opportunity, we also need to take the [Self::opportunity_parameter_sf] into
249
+ * account.
250
+ */
251
+ readonly opportunityType: number
252
+ /**
253
+ * Internal padding.
254
+ * The fields above take up 2+2+1+1 bytes = 48 bits, which means we need 80 bits = 10 bytes to
255
+ * align with `u128`s.
256
+ */
257
+ readonly padding1: Array<number>
258
+ /**
259
+ * End padding.
260
+ * The total size of a single instance is 8*u128 = 128 bytes.
261
+ */
262
+ readonly padding2: Array<BN>
263
+
264
+ constructor(fields: ObligationOrderFields) {
265
+ this.conditionThresholdSf = fields.conditionThresholdSf
266
+ this.opportunityParameterSf = fields.opportunityParameterSf
267
+ this.minExecutionBonusBps = fields.minExecutionBonusBps
268
+ this.maxExecutionBonusBps = fields.maxExecutionBonusBps
269
+ this.conditionType = fields.conditionType
270
+ this.opportunityType = fields.opportunityType
271
+ this.padding1 = fields.padding1
272
+ this.padding2 = fields.padding2
273
+ }
274
+
275
+ static layout(property?: string) {
276
+ return borsh.struct(
277
+ [
278
+ borsh.u128("conditionThresholdSf"),
279
+ borsh.u128("opportunityParameterSf"),
280
+ borsh.u16("minExecutionBonusBps"),
281
+ borsh.u16("maxExecutionBonusBps"),
282
+ borsh.u8("conditionType"),
283
+ borsh.u8("opportunityType"),
284
+ borsh.array(borsh.u8(), 10, "padding1"),
285
+ borsh.array(borsh.u128(), 5, "padding2"),
286
+ ],
287
+ property
288
+ )
289
+ }
290
+
291
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
292
+ static fromDecoded(obj: any) {
293
+ return new ObligationOrder({
294
+ conditionThresholdSf: obj.conditionThresholdSf,
295
+ opportunityParameterSf: obj.opportunityParameterSf,
296
+ minExecutionBonusBps: obj.minExecutionBonusBps,
297
+ maxExecutionBonusBps: obj.maxExecutionBonusBps,
298
+ conditionType: obj.conditionType,
299
+ opportunityType: obj.opportunityType,
300
+ padding1: obj.padding1,
301
+ padding2: obj.padding2,
302
+ })
303
+ }
304
+
305
+ static toEncodable(fields: ObligationOrderFields) {
306
+ return {
307
+ conditionThresholdSf: fields.conditionThresholdSf,
308
+ opportunityParameterSf: fields.opportunityParameterSf,
309
+ minExecutionBonusBps: fields.minExecutionBonusBps,
310
+ maxExecutionBonusBps: fields.maxExecutionBonusBps,
311
+ conditionType: fields.conditionType,
312
+ opportunityType: fields.opportunityType,
313
+ padding1: fields.padding1,
314
+ padding2: fields.padding2,
315
+ }
316
+ }
317
+
318
+ toJSON(): ObligationOrderJSON {
319
+ return {
320
+ conditionThresholdSf: this.conditionThresholdSf.toString(),
321
+ opportunityParameterSf: this.opportunityParameterSf.toString(),
322
+ minExecutionBonusBps: this.minExecutionBonusBps,
323
+ maxExecutionBonusBps: this.maxExecutionBonusBps,
324
+ conditionType: this.conditionType,
325
+ opportunityType: this.opportunityType,
326
+ padding1: this.padding1,
327
+ padding2: this.padding2.map((item) => item.toString()),
328
+ }
329
+ }
330
+
331
+ static fromJSON(obj: ObligationOrderJSON): ObligationOrder {
332
+ return new ObligationOrder({
333
+ conditionThresholdSf: new BN(obj.conditionThresholdSf),
334
+ opportunityParameterSf: new BN(obj.opportunityParameterSf),
335
+ minExecutionBonusBps: obj.minExecutionBonusBps,
336
+ maxExecutionBonusBps: obj.maxExecutionBonusBps,
337
+ conditionType: obj.conditionType,
338
+ opportunityType: obj.opportunityType,
339
+ padding1: obj.padding1,
340
+ padding2: obj.padding2.map((item) => new BN(item)),
341
+ })
342
+ }
343
+
344
+ toEncodable() {
345
+ return ObligationOrder.toEncodable(this)
346
+ }
347
+ }
@@ -10,10 +10,15 @@ export interface ReserveConfigFields {
10
10
  assetTier: number
11
11
  /** Flat rate that goes to the host */
12
12
  hostFixedInterestRateBps: number
13
- /** [DEPRECATED] Boost for side (debt or collateral) */
13
+ /**
14
+ * [DEPRECATED] Space that used to hold 2 fields:
15
+ * - Boost for side (debt or collateral)
16
+ * - Reward points multiplier per obligation type
17
+ * Can be re-used after making sure all underlying production account data is zeroed.
18
+ */
14
19
  reserved2: Array<number>
15
- /** [DEPRECATED] Reward points multiplier per obligation type */
16
- reserved3: Array<number>
20
+ /** Cut of the order execution bonus that the protocol receives, as a percentage */
21
+ protocolOrderExecutionFeePct: number
17
22
  /** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
18
23
  protocolTakeRatePct: number
19
24
  /** Cut of the liquidation bonus that the protocol receives, as a percentage */
@@ -98,10 +103,15 @@ export interface ReserveConfigJSON {
98
103
  assetTier: number
99
104
  /** Flat rate that goes to the host */
100
105
  hostFixedInterestRateBps: number
101
- /** [DEPRECATED] Boost for side (debt or collateral) */
106
+ /**
107
+ * [DEPRECATED] Space that used to hold 2 fields:
108
+ * - Boost for side (debt or collateral)
109
+ * - Reward points multiplier per obligation type
110
+ * Can be re-used after making sure all underlying production account data is zeroed.
111
+ */
102
112
  reserved2: Array<number>
103
- /** [DEPRECATED] Reward points multiplier per obligation type */
104
- reserved3: Array<number>
113
+ /** Cut of the order execution bonus that the protocol receives, as a percentage */
114
+ protocolOrderExecutionFeePct: number
105
115
  /** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
106
116
  protocolTakeRatePct: number
107
117
  /** Cut of the liquidation bonus that the protocol receives, as a percentage */
@@ -187,10 +197,15 @@ export class ReserveConfig {
187
197
  readonly assetTier: number
188
198
  /** Flat rate that goes to the host */
189
199
  readonly hostFixedInterestRateBps: number
190
- /** [DEPRECATED] Boost for side (debt or collateral) */
200
+ /**
201
+ * [DEPRECATED] Space that used to hold 2 fields:
202
+ * - Boost for side (debt or collateral)
203
+ * - Reward points multiplier per obligation type
204
+ * Can be re-used after making sure all underlying production account data is zeroed.
205
+ */
191
206
  readonly reserved2: Array<number>
192
- /** [DEPRECATED] Reward points multiplier per obligation type */
193
- readonly reserved3: Array<number>
207
+ /** Cut of the order execution bonus that the protocol receives, as a percentage */
208
+ readonly protocolOrderExecutionFeePct: number
194
209
  /** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
195
210
  readonly protocolTakeRatePct: number
196
211
  /** Cut of the liquidation bonus that the protocol receives, as a percentage */
@@ -272,7 +287,7 @@ export class ReserveConfig {
272
287
  this.assetTier = fields.assetTier
273
288
  this.hostFixedInterestRateBps = fields.hostFixedInterestRateBps
274
289
  this.reserved2 = fields.reserved2
275
- this.reserved3 = fields.reserved3
290
+ this.protocolOrderExecutionFeePct = fields.protocolOrderExecutionFeePct
276
291
  this.protocolTakeRatePct = fields.protocolTakeRatePct
277
292
  this.protocolLiquidationFeePct = fields.protocolLiquidationFeePct
278
293
  this.loanToValuePct = fields.loanToValuePct
@@ -318,8 +333,8 @@ export class ReserveConfig {
318
333
  borsh.u8("status"),
319
334
  borsh.u8("assetTier"),
320
335
  borsh.u16("hostFixedInterestRateBps"),
321
- borsh.array(borsh.u8(), 2, "reserved2"),
322
- borsh.array(borsh.u8(), 8, "reserved3"),
336
+ borsh.array(borsh.u8(), 9, "reserved2"),
337
+ borsh.u8("protocolOrderExecutionFeePct"),
323
338
  borsh.u8("protocolTakeRatePct"),
324
339
  borsh.u8("protocolLiquidationFeePct"),
325
340
  borsh.u8("loanToValuePct"),
@@ -361,7 +376,7 @@ export class ReserveConfig {
361
376
  assetTier: obj.assetTier,
362
377
  hostFixedInterestRateBps: obj.hostFixedInterestRateBps,
363
378
  reserved2: obj.reserved2,
364
- reserved3: obj.reserved3,
379
+ protocolOrderExecutionFeePct: obj.protocolOrderExecutionFeePct,
365
380
  protocolTakeRatePct: obj.protocolTakeRatePct,
366
381
  protocolLiquidationFeePct: obj.protocolLiquidationFeePct,
367
382
  loanToValuePct: obj.loanToValuePct,
@@ -404,7 +419,7 @@ export class ReserveConfig {
404
419
  assetTier: fields.assetTier,
405
420
  hostFixedInterestRateBps: fields.hostFixedInterestRateBps,
406
421
  reserved2: fields.reserved2,
407
- reserved3: fields.reserved3,
422
+ protocolOrderExecutionFeePct: fields.protocolOrderExecutionFeePct,
408
423
  protocolTakeRatePct: fields.protocolTakeRatePct,
409
424
  protocolLiquidationFeePct: fields.protocolLiquidationFeePct,
410
425
  loanToValuePct: fields.loanToValuePct,
@@ -449,7 +464,7 @@ export class ReserveConfig {
449
464
  assetTier: this.assetTier,
450
465
  hostFixedInterestRateBps: this.hostFixedInterestRateBps,
451
466
  reserved2: this.reserved2,
452
- reserved3: this.reserved3,
467
+ protocolOrderExecutionFeePct: this.protocolOrderExecutionFeePct,
453
468
  protocolTakeRatePct: this.protocolTakeRatePct,
454
469
  protocolLiquidationFeePct: this.protocolLiquidationFeePct,
455
470
  loanToValuePct: this.loanToValuePct,
@@ -492,7 +507,7 @@ export class ReserveConfig {
492
507
  assetTier: obj.assetTier,
493
508
  hostFixedInterestRateBps: obj.hostFixedInterestRateBps,
494
509
  reserved2: obj.reserved2,
495
- reserved3: obj.reserved3,
510
+ protocolOrderExecutionFeePct: obj.protocolOrderExecutionFeePct,
496
511
  protocolTakeRatePct: obj.protocolTakeRatePct,
497
512
  protocolLiquidationFeePct: obj.protocolLiquidationFeePct,
498
513
  loanToValuePct: obj.loanToValuePct,
@@ -164,25 +164,25 @@ export class UpdateFeesFlashLoanFee {
164
164
  }
165
165
  }
166
166
 
167
- export interface UpdateFeesReferralFeeBpsJSON {
168
- kind: "UpdateFeesReferralFeeBps"
167
+ export interface DeprecatedUpdateFeesReferralFeeBpsJSON {
168
+ kind: "DeprecatedUpdateFeesReferralFeeBps"
169
169
  }
170
170
 
171
- export class UpdateFeesReferralFeeBps {
171
+ export class DeprecatedUpdateFeesReferralFeeBps {
172
172
  static readonly discriminator = 7
173
- static readonly kind = "UpdateFeesReferralFeeBps"
173
+ static readonly kind = "DeprecatedUpdateFeesReferralFeeBps"
174
174
  readonly discriminator = 7
175
- readonly kind = "UpdateFeesReferralFeeBps"
175
+ readonly kind = "DeprecatedUpdateFeesReferralFeeBps"
176
176
 
177
- toJSON(): UpdateFeesReferralFeeBpsJSON {
177
+ toJSON(): DeprecatedUpdateFeesReferralFeeBpsJSON {
178
178
  return {
179
- kind: "UpdateFeesReferralFeeBps",
179
+ kind: "DeprecatedUpdateFeesReferralFeeBps",
180
180
  }
181
181
  }
182
182
 
183
183
  toEncodable() {
184
184
  return {
185
- UpdateFeesReferralFeeBps: {},
185
+ DeprecatedUpdateFeesReferralFeeBps: {},
186
186
  }
187
187
  }
188
188
  }
@@ -624,48 +624,48 @@ export class UpdateDepositWithdrawalCap {
624
624
  }
625
625
  }
626
626
 
627
- export interface UpdateDebtWithdrawalCapCurrentTotalJSON {
628
- kind: "UpdateDebtWithdrawalCapCurrentTotal"
627
+ export interface DeprecatedUpdateDebtWithdrawalCapCurrentTotalJSON {
628
+ kind: "DeprecatedUpdateDebtWithdrawalCapCurrentTotal"
629
629
  }
630
630
 
631
- export class UpdateDebtWithdrawalCapCurrentTotal {
631
+ export class DeprecatedUpdateDebtWithdrawalCapCurrentTotal {
632
632
  static readonly discriminator = 27
633
- static readonly kind = "UpdateDebtWithdrawalCapCurrentTotal"
633
+ static readonly kind = "DeprecatedUpdateDebtWithdrawalCapCurrentTotal"
634
634
  readonly discriminator = 27
635
- readonly kind = "UpdateDebtWithdrawalCapCurrentTotal"
635
+ readonly kind = "DeprecatedUpdateDebtWithdrawalCapCurrentTotal"
636
636
 
637
- toJSON(): UpdateDebtWithdrawalCapCurrentTotalJSON {
637
+ toJSON(): DeprecatedUpdateDebtWithdrawalCapCurrentTotalJSON {
638
638
  return {
639
- kind: "UpdateDebtWithdrawalCapCurrentTotal",
639
+ kind: "DeprecatedUpdateDebtWithdrawalCapCurrentTotal",
640
640
  }
641
641
  }
642
642
 
643
643
  toEncodable() {
644
644
  return {
645
- UpdateDebtWithdrawalCapCurrentTotal: {},
645
+ DeprecatedUpdateDebtWithdrawalCapCurrentTotal: {},
646
646
  }
647
647
  }
648
648
  }
649
649
 
650
- export interface UpdateDepositWithdrawalCapCurrentTotalJSON {
651
- kind: "UpdateDepositWithdrawalCapCurrentTotal"
650
+ export interface DeprecatedUpdateDepositWithdrawalCapCurrentTotalJSON {
651
+ kind: "DeprecatedUpdateDepositWithdrawalCapCurrentTotal"
652
652
  }
653
653
 
654
- export class UpdateDepositWithdrawalCapCurrentTotal {
654
+ export class DeprecatedUpdateDepositWithdrawalCapCurrentTotal {
655
655
  static readonly discriminator = 28
656
- static readonly kind = "UpdateDepositWithdrawalCapCurrentTotal"
656
+ static readonly kind = "DeprecatedUpdateDepositWithdrawalCapCurrentTotal"
657
657
  readonly discriminator = 28
658
- readonly kind = "UpdateDepositWithdrawalCapCurrentTotal"
658
+ readonly kind = "DeprecatedUpdateDepositWithdrawalCapCurrentTotal"
659
659
 
660
- toJSON(): UpdateDepositWithdrawalCapCurrentTotalJSON {
660
+ toJSON(): DeprecatedUpdateDepositWithdrawalCapCurrentTotalJSON {
661
661
  return {
662
- kind: "UpdateDepositWithdrawalCapCurrentTotal",
662
+ kind: "DeprecatedUpdateDepositWithdrawalCapCurrentTotal",
663
663
  }
664
664
  }
665
665
 
666
666
  toEncodable() {
667
667
  return {
668
- UpdateDepositWithdrawalCapCurrentTotal: {},
668
+ DeprecatedUpdateDepositWithdrawalCapCurrentTotal: {},
669
669
  }
670
670
  }
671
671
  }
@@ -1130,6 +1130,29 @@ export class UpdateDeleveragingBonusIncreaseBpsPerDay {
1130
1130
  }
1131
1131
  }
1132
1132
 
1133
+ export interface UpdateProtocolOrderExecutionFeeJSON {
1134
+ kind: "UpdateProtocolOrderExecutionFee"
1135
+ }
1136
+
1137
+ export class UpdateProtocolOrderExecutionFee {
1138
+ static readonly discriminator = 49
1139
+ static readonly kind = "UpdateProtocolOrderExecutionFee"
1140
+ readonly discriminator = 49
1141
+ readonly kind = "UpdateProtocolOrderExecutionFee"
1142
+
1143
+ toJSON(): UpdateProtocolOrderExecutionFeeJSON {
1144
+ return {
1145
+ kind: "UpdateProtocolOrderExecutionFee",
1146
+ }
1147
+ }
1148
+
1149
+ toEncodable() {
1150
+ return {
1151
+ UpdateProtocolOrderExecutionFee: {},
1152
+ }
1153
+ }
1154
+ }
1155
+
1133
1156
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1134
1157
  export function fromDecoded(obj: any): types.UpdateConfigModeKind {
1135
1158
  if (typeof obj !== "object") {
@@ -1157,8 +1180,8 @@ export function fromDecoded(obj: any): types.UpdateConfigModeKind {
1157
1180
  if ("UpdateFeesFlashLoanFee" in obj) {
1158
1181
  return new UpdateFeesFlashLoanFee()
1159
1182
  }
1160
- if ("UpdateFeesReferralFeeBps" in obj) {
1161
- return new UpdateFeesReferralFeeBps()
1183
+ if ("DeprecatedUpdateFeesReferralFeeBps" in obj) {
1184
+ return new DeprecatedUpdateFeesReferralFeeBps()
1162
1185
  }
1163
1186
  if ("UpdateDepositLimit" in obj) {
1164
1187
  return new UpdateDepositLimit()
@@ -1217,11 +1240,11 @@ export function fromDecoded(obj: any): types.UpdateConfigModeKind {
1217
1240
  if ("UpdateDepositWithdrawalCap" in obj) {
1218
1241
  return new UpdateDepositWithdrawalCap()
1219
1242
  }
1220
- if ("UpdateDebtWithdrawalCapCurrentTotal" in obj) {
1221
- return new UpdateDebtWithdrawalCapCurrentTotal()
1243
+ if ("DeprecatedUpdateDebtWithdrawalCapCurrentTotal" in obj) {
1244
+ return new DeprecatedUpdateDebtWithdrawalCapCurrentTotal()
1222
1245
  }
1223
- if ("UpdateDepositWithdrawalCapCurrentTotal" in obj) {
1224
- return new UpdateDepositWithdrawalCapCurrentTotal()
1246
+ if ("DeprecatedUpdateDepositWithdrawalCapCurrentTotal" in obj) {
1247
+ return new DeprecatedUpdateDepositWithdrawalCapCurrentTotal()
1225
1248
  }
1226
1249
  if ("UpdateBadDebtLiquidationBonusBps" in obj) {
1227
1250
  return new UpdateBadDebtLiquidationBonusBps()
@@ -1283,6 +1306,9 @@ export function fromDecoded(obj: any): types.UpdateConfigModeKind {
1283
1306
  if ("UpdateDeleveragingBonusIncreaseBpsPerDay" in obj) {
1284
1307
  return new UpdateDeleveragingBonusIncreaseBpsPerDay()
1285
1308
  }
1309
+ if ("UpdateProtocolOrderExecutionFee" in obj) {
1310
+ return new UpdateProtocolOrderExecutionFee()
1311
+ }
1286
1312
 
1287
1313
  throw new Error("Invalid enum object")
1288
1314
  }
@@ -1312,8 +1338,8 @@ export function fromJSON(
1312
1338
  case "UpdateFeesFlashLoanFee": {
1313
1339
  return new UpdateFeesFlashLoanFee()
1314
1340
  }
1315
- case "UpdateFeesReferralFeeBps": {
1316
- return new UpdateFeesReferralFeeBps()
1341
+ case "DeprecatedUpdateFeesReferralFeeBps": {
1342
+ return new DeprecatedUpdateFeesReferralFeeBps()
1317
1343
  }
1318
1344
  case "UpdateDepositLimit": {
1319
1345
  return new UpdateDepositLimit()
@@ -1372,11 +1398,11 @@ export function fromJSON(
1372
1398
  case "UpdateDepositWithdrawalCap": {
1373
1399
  return new UpdateDepositWithdrawalCap()
1374
1400
  }
1375
- case "UpdateDebtWithdrawalCapCurrentTotal": {
1376
- return new UpdateDebtWithdrawalCapCurrentTotal()
1401
+ case "DeprecatedUpdateDebtWithdrawalCapCurrentTotal": {
1402
+ return new DeprecatedUpdateDebtWithdrawalCapCurrentTotal()
1377
1403
  }
1378
- case "UpdateDepositWithdrawalCapCurrentTotal": {
1379
- return new UpdateDepositWithdrawalCapCurrentTotal()
1404
+ case "DeprecatedUpdateDepositWithdrawalCapCurrentTotal": {
1405
+ return new DeprecatedUpdateDepositWithdrawalCapCurrentTotal()
1380
1406
  }
1381
1407
  case "UpdateBadDebtLiquidationBonusBps": {
1382
1408
  return new UpdateBadDebtLiquidationBonusBps()
@@ -1438,6 +1464,9 @@ export function fromJSON(
1438
1464
  case "UpdateDeleveragingBonusIncreaseBpsPerDay": {
1439
1465
  return new UpdateDeleveragingBonusIncreaseBpsPerDay()
1440
1466
  }
1467
+ case "UpdateProtocolOrderExecutionFee": {
1468
+ return new UpdateProtocolOrderExecutionFee()
1469
+ }
1441
1470
  }
1442
1471
  }
1443
1472
 
@@ -1450,7 +1479,7 @@ export function layout(property?: string) {
1450
1479
  borsh.struct([], "UpdateProtocolTakeRate"),
1451
1480
  borsh.struct([], "UpdateFeesBorrowFee"),
1452
1481
  borsh.struct([], "UpdateFeesFlashLoanFee"),
1453
- borsh.struct([], "UpdateFeesReferralFeeBps"),
1482
+ borsh.struct([], "DeprecatedUpdateFeesReferralFeeBps"),
1454
1483
  borsh.struct([], "UpdateDepositLimit"),
1455
1484
  borsh.struct([], "UpdateBorrowLimit"),
1456
1485
  borsh.struct([], "UpdateTokenInfoLowerHeuristic"),
@@ -1470,8 +1499,8 @@ export function layout(property?: string) {
1470
1499
  borsh.struct([], "UpdateEntireReserveConfig"),
1471
1500
  borsh.struct([], "UpdateDebtWithdrawalCap"),
1472
1501
  borsh.struct([], "UpdateDepositWithdrawalCap"),
1473
- borsh.struct([], "UpdateDebtWithdrawalCapCurrentTotal"),
1474
- borsh.struct([], "UpdateDepositWithdrawalCapCurrentTotal"),
1502
+ borsh.struct([], "DeprecatedUpdateDebtWithdrawalCapCurrentTotal"),
1503
+ borsh.struct([], "DeprecatedUpdateDepositWithdrawalCapCurrentTotal"),
1475
1504
  borsh.struct([], "UpdateBadDebtLiquidationBonusBps"),
1476
1505
  borsh.struct([], "UpdateMinLiquidationBonusBps"),
1477
1506
  borsh.struct([], "UpdateDeleveragingMarginCallPeriod"),
@@ -1492,6 +1521,7 @@ export function layout(property?: string) {
1492
1521
  borsh.struct([], "UpdateHostFixedInterestRateBps"),
1493
1522
  borsh.struct([], "UpdateAutodeleverageEnabled"),
1494
1523
  borsh.struct([], "UpdateDeleveragingBonusIncreaseBpsPerDay"),
1524
+ borsh.struct([], "UpdateProtocolOrderExecutionFee"),
1495
1525
  ])
1496
1526
  if (property !== undefined) {
1497
1527
  return ret.replicate(property)