@exponent-labs/kamino-reserve-deserializer 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/fraction.d.ts +23 -0
  3. package/build/fraction.js +61 -0
  4. package/build/fraction.js.map +1 -0
  5. package/build/index.d.ts +102 -0
  6. package/build/index.js +214 -0
  7. package/build/index.js.map +1 -0
  8. package/build/types/BigFractionBytes.d.ts +26 -0
  9. package/build/types/BigFractionBytes.js +72 -0
  10. package/build/types/BigFractionBytes.js.map +1 -0
  11. package/build/types/BorrowRateCurve.d.ts +27 -0
  12. package/build/types/BorrowRateCurve.js +63 -0
  13. package/build/types/BorrowRateCurve.js.map +1 -0
  14. package/build/types/CurvePoint.d.ts +25 -0
  15. package/build/types/CurvePoint.js +68 -0
  16. package/build/types/CurvePoint.js.map +1 -0
  17. package/build/types/LastUpdate.d.ts +46 -0
  18. package/build/types/LastUpdate.js +88 -0
  19. package/build/types/LastUpdate.js.map +1 -0
  20. package/build/types/PriceHeuristic.d.ts +40 -0
  21. package/build/types/PriceHeuristic.js +81 -0
  22. package/build/types/PriceHeuristic.js.map +1 -0
  23. package/build/types/PythConfiguration.d.ts +24 -0
  24. package/build/types/PythConfiguration.js +64 -0
  25. package/build/types/PythConfiguration.js.map +1 -0
  26. package/build/types/ReserveCollateral.d.ts +52 -0
  27. package/build/types/ReserveCollateral.js +101 -0
  28. package/build/types/ReserveCollateral.js.map +1 -0
  29. package/build/types/ReserveConfig.d.ts +366 -0
  30. package/build/types/ReserveConfig.js +307 -0
  31. package/build/types/ReserveConfig.js.map +1 -0
  32. package/build/types/ReserveFees.d.ts +77 -0
  33. package/build/types/ReserveFees.js +98 -0
  34. package/build/types/ReserveFees.js.map +1 -0
  35. package/build/types/ReserveLiquidity.d.ts +181 -0
  36. package/build/types/ReserveLiquidity.js +214 -0
  37. package/build/types/ReserveLiquidity.js.map +1 -0
  38. package/build/types/ScopeConfiguration.d.ts +40 -0
  39. package/build/types/ScopeConfiguration.js +82 -0
  40. package/build/types/ScopeConfiguration.js.map +1 -0
  41. package/build/types/SwitchboardConfiguration.d.ts +29 -0
  42. package/build/types/SwitchboardConfiguration.js +70 -0
  43. package/build/types/SwitchboardConfiguration.js.map +1 -0
  44. package/build/types/TokenInfo.d.ts +121 -0
  45. package/build/types/TokenInfo.js +154 -0
  46. package/build/types/TokenInfo.js.map +1 -0
  47. package/build/types/WithdrawalCaps.d.ts +37 -0
  48. package/build/types/WithdrawalCaps.js +90 -0
  49. package/build/types/WithdrawalCaps.js.map +1 -0
  50. package/build/types/index.d.ts +46 -0
  51. package/build/types/index.js +88 -0
  52. package/build/types/index.js.map +1 -0
  53. package/package.json +20 -0
  54. package/src/fraction.ts +70 -0
  55. package/src/index.ts +269 -0
  56. package/src/types/BigFractionBytes.ts +59 -0
  57. package/src/types/BorrowRateCurve.ts +53 -0
  58. package/src/types/CurvePoint.ts +58 -0
  59. package/src/types/LastUpdate.ts +88 -0
  60. package/src/types/PriceHeuristic.ts +76 -0
  61. package/src/types/PythConfiguration.ts +54 -0
  62. package/src/types/ReserveCollateral.ts +103 -0
  63. package/src/types/ReserveConfig.ts +431 -0
  64. package/src/types/ReserveFees.ts +116 -0
  65. package/src/types/ReserveLiquidity.ts +280 -0
  66. package/src/types/ScopeConfiguration.ts +83 -0
  67. package/src/types/SwitchboardConfiguration.ts +62 -0
  68. package/src/types/TokenInfo.ts +178 -0
  69. package/src/types/WithdrawalCaps.ts +84 -0
  70. package/src/types/index.ts +88 -0
  71. package/tsconfig.json +18 -0
@@ -0,0 +1,366 @@
1
+ import BN from "bn.js";
2
+ import { ReserveFees, ReserveFeesFields, ReserveFeesJSON } from "./ReserveFees";
3
+ import { BorrowRateCurve, BorrowRateCurveFields, BorrowRateCurveJSON } from "./BorrowRateCurve";
4
+ import { TokenInfo, TokenInfoFields, TokenInfoJSON } from "./TokenInfo";
5
+ import { WithdrawalCaps, WithdrawalCapsFields, WithdrawalCapsJSON } from "./WithdrawalCaps";
6
+ export interface ReserveConfigFields {
7
+ /** Status of the reserve Active/Obsolete/Hidden */
8
+ status: number;
9
+ /** Asset tier -> 0 - regular (collateral & debt), 1 - isolated collateral, 2 - isolated debt */
10
+ assetTier: number;
11
+ /** Flat rate that goes to the host */
12
+ hostFixedInterestRateBps: number;
13
+ /** [DEPRECATED] Boost for side (debt or collateral) */
14
+ reserved2: Array<number>;
15
+ /** [DEPRECATED] Reward points multiplier per obligation type */
16
+ reserved3: Array<number>;
17
+ /** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
18
+ protocolTakeRatePct: number;
19
+ /** Cut of the liquidation bonus that the protocol receives, as a percentage */
20
+ protocolLiquidationFeePct: number;
21
+ /**
22
+ * Target ratio of the value of borrows to deposits, as a percentage
23
+ * 0 if use as collateral is disabled
24
+ */
25
+ loanToValuePct: number;
26
+ /** Loan to value ratio at which an obligation can be liquidated, as percentage */
27
+ liquidationThresholdPct: number;
28
+ /** Minimum bonus a liquidator receives when repaying part of an unhealthy obligation, as bps */
29
+ minLiquidationBonusBps: number;
30
+ /** Maximum bonus a liquidator receives when repaying part of an unhealthy obligation, as bps */
31
+ maxLiquidationBonusBps: number;
32
+ /** Bad debt liquidation bonus for an undercollateralized obligation, as bps */
33
+ badDebtLiquidationBonusBps: number;
34
+ /** Time in seconds that must pass before redemptions are enabled after the deposit limit is crossed */
35
+ deleveragingMarginCallPeriodSecs: BN;
36
+ /**
37
+ * The rate at which the deleveraging threshold decreases in slots per bps
38
+ * e.g. 1 bps per hour would be 7200 slots per bps (assuming 2 slots per second)
39
+ */
40
+ deleveragingThresholdSlotsPerBps: BN;
41
+ /** Program owner fees assessed, separate from gains due to interest accrual */
42
+ fees: ReserveFeesFields;
43
+ /** Borrow rate curve based on utilization */
44
+ borrowRateCurve: BorrowRateCurveFields;
45
+ /** Borrow factor in percentage - used for risk adjustment */
46
+ borrowFactorPct: BN;
47
+ /** Maximum deposit limit of liquidity in native units, u64::MAX for inf */
48
+ depositLimit: BN;
49
+ /** Maximum amount borrowed, u64::MAX for inf, 0 to disable borrows (protected deposits) */
50
+ borrowLimit: BN;
51
+ /** Token id from TokenInfos struct */
52
+ tokenInfo: TokenInfoFields;
53
+ /** Deposit withdrawl caps - deposit & redeem */
54
+ depositWithdrawalCap: WithdrawalCapsFields;
55
+ /** Debt withdrawl caps - borrow & repay */
56
+ debtWithdrawalCap: WithdrawalCapsFields;
57
+ elevationGroups: Array<number>;
58
+ disableUsageAsCollOutsideEmode: number;
59
+ utilizationLimitBlockBorrowingAbove: number;
60
+ reserved1: Array<number>;
61
+ /**
62
+ * Maximum amount liquidity of this reserve borrowed outside all elevation groups
63
+ * - u64::MAX for inf
64
+ * - 0 to disable borrows outside elevation groups
65
+ */
66
+ borrowLimitOutsideElevationGroup: BN;
67
+ /**
68
+ * Defines the maximum amount (in lamports of elevation group debt asset)
69
+ * that can be borrowed when this reserve is used as collateral.
70
+ * - u64::MAX for inf
71
+ * - 0 to disable borrows in this elevation group (expected value for the debt asset)
72
+ */
73
+ borrowLimitAgainstThisCollateralInElevationGroup: Array<BN>;
74
+ }
75
+ export interface ReserveConfigJSON {
76
+ /** Status of the reserve Active/Obsolete/Hidden */
77
+ status: number;
78
+ /** Asset tier -> 0 - regular (collateral & debt), 1 - isolated collateral, 2 - isolated debt */
79
+ assetTier: number;
80
+ /** Flat rate that goes to the host */
81
+ hostFixedInterestRateBps: number;
82
+ /** [DEPRECATED] Boost for side (debt or collateral) */
83
+ reserved2: Array<number>;
84
+ /** [DEPRECATED] Reward points multiplier per obligation type */
85
+ reserved3: Array<number>;
86
+ /** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
87
+ protocolTakeRatePct: number;
88
+ /** Cut of the liquidation bonus that the protocol receives, as a percentage */
89
+ protocolLiquidationFeePct: number;
90
+ /**
91
+ * Target ratio of the value of borrows to deposits, as a percentage
92
+ * 0 if use as collateral is disabled
93
+ */
94
+ loanToValuePct: number;
95
+ /** Loan to value ratio at which an obligation can be liquidated, as percentage */
96
+ liquidationThresholdPct: number;
97
+ /** Minimum bonus a liquidator receives when repaying part of an unhealthy obligation, as bps */
98
+ minLiquidationBonusBps: number;
99
+ /** Maximum bonus a liquidator receives when repaying part of an unhealthy obligation, as bps */
100
+ maxLiquidationBonusBps: number;
101
+ /** Bad debt liquidation bonus for an undercollateralized obligation, as bps */
102
+ badDebtLiquidationBonusBps: number;
103
+ /** Time in seconds that must pass before redemptions are enabled after the deposit limit is crossed */
104
+ deleveragingMarginCallPeriodSecs: string;
105
+ /**
106
+ * The rate at which the deleveraging threshold decreases in slots per bps
107
+ * e.g. 1 bps per hour would be 7200 slots per bps (assuming 2 slots per second)
108
+ */
109
+ deleveragingThresholdSlotsPerBps: string;
110
+ /** Program owner fees assessed, separate from gains due to interest accrual */
111
+ fees: ReserveFeesJSON;
112
+ /** Borrow rate curve based on utilization */
113
+ borrowRateCurve: BorrowRateCurveJSON;
114
+ /** Borrow factor in percentage - used for risk adjustment */
115
+ borrowFactorPct: string;
116
+ /** Maximum deposit limit of liquidity in native units, u64::MAX for inf */
117
+ depositLimit: string;
118
+ /** Maximum amount borrowed, u64::MAX for inf, 0 to disable borrows (protected deposits) */
119
+ borrowLimit: string;
120
+ /** Token id from TokenInfos struct */
121
+ tokenInfo: TokenInfoJSON;
122
+ /** Deposit withdrawl caps - deposit & redeem */
123
+ depositWithdrawalCap: WithdrawalCapsJSON;
124
+ /** Debt withdrawl caps - borrow & repay */
125
+ debtWithdrawalCap: WithdrawalCapsJSON;
126
+ elevationGroups: Array<number>;
127
+ disableUsageAsCollOutsideEmode: number;
128
+ utilizationLimitBlockBorrowingAbove: number;
129
+ reserved1: Array<number>;
130
+ /**
131
+ * Maximum amount liquidity of this reserve borrowed outside all elevation groups
132
+ * - u64::MAX for inf
133
+ * - 0 to disable borrows outside elevation groups
134
+ */
135
+ borrowLimitOutsideElevationGroup: string;
136
+ /**
137
+ * Defines the maximum amount (in lamports of elevation group debt asset)
138
+ * that can be borrowed when this reserve is used as collateral.
139
+ * - u64::MAX for inf
140
+ * - 0 to disable borrows in this elevation group (expected value for the debt asset)
141
+ */
142
+ borrowLimitAgainstThisCollateralInElevationGroup: Array<string>;
143
+ }
144
+ /** Reserve configuration values */
145
+ export declare class ReserveConfig {
146
+ /** Status of the reserve Active/Obsolete/Hidden */
147
+ readonly status: number;
148
+ /** Asset tier -> 0 - regular (collateral & debt), 1 - isolated collateral, 2 - isolated debt */
149
+ readonly assetTier: number;
150
+ /** Flat rate that goes to the host */
151
+ readonly hostFixedInterestRateBps: number;
152
+ /** [DEPRECATED] Boost for side (debt or collateral) */
153
+ readonly reserved2: Array<number>;
154
+ /** [DEPRECATED] Reward points multiplier per obligation type */
155
+ readonly reserved3: Array<number>;
156
+ /** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
157
+ readonly protocolTakeRatePct: number;
158
+ /** Cut of the liquidation bonus that the protocol receives, as a percentage */
159
+ readonly protocolLiquidationFeePct: number;
160
+ /**
161
+ * Target ratio of the value of borrows to deposits, as a percentage
162
+ * 0 if use as collateral is disabled
163
+ */
164
+ readonly loanToValuePct: number;
165
+ /** Loan to value ratio at which an obligation can be liquidated, as percentage */
166
+ readonly liquidationThresholdPct: number;
167
+ /** Minimum bonus a liquidator receives when repaying part of an unhealthy obligation, as bps */
168
+ readonly minLiquidationBonusBps: number;
169
+ /** Maximum bonus a liquidator receives when repaying part of an unhealthy obligation, as bps */
170
+ readonly maxLiquidationBonusBps: number;
171
+ /** Bad debt liquidation bonus for an undercollateralized obligation, as bps */
172
+ readonly badDebtLiquidationBonusBps: number;
173
+ /** Time in seconds that must pass before redemptions are enabled after the deposit limit is crossed */
174
+ readonly deleveragingMarginCallPeriodSecs: BN;
175
+ /**
176
+ * The rate at which the deleveraging threshold decreases in slots per bps
177
+ * e.g. 1 bps per hour would be 7200 slots per bps (assuming 2 slots per second)
178
+ */
179
+ readonly deleveragingThresholdSlotsPerBps: BN;
180
+ /** Program owner fees assessed, separate from gains due to interest accrual */
181
+ readonly fees: ReserveFees;
182
+ /** Borrow rate curve based on utilization */
183
+ readonly borrowRateCurve: BorrowRateCurve;
184
+ /** Borrow factor in percentage - used for risk adjustment */
185
+ readonly borrowFactorPct: BN;
186
+ /** Maximum deposit limit of liquidity in native units, u64::MAX for inf */
187
+ readonly depositLimit: BN;
188
+ /** Maximum amount borrowed, u64::MAX for inf, 0 to disable borrows (protected deposits) */
189
+ readonly borrowLimit: BN;
190
+ /** Token id from TokenInfos struct */
191
+ readonly tokenInfo: TokenInfo;
192
+ /** Deposit withdrawl caps - deposit & redeem */
193
+ readonly depositWithdrawalCap: WithdrawalCaps;
194
+ /** Debt withdrawl caps - borrow & repay */
195
+ readonly debtWithdrawalCap: WithdrawalCaps;
196
+ readonly elevationGroups: Array<number>;
197
+ readonly disableUsageAsCollOutsideEmode: number;
198
+ readonly utilizationLimitBlockBorrowingAbove: number;
199
+ readonly reserved1: Array<number>;
200
+ /**
201
+ * Maximum amount liquidity of this reserve borrowed outside all elevation groups
202
+ * - u64::MAX for inf
203
+ * - 0 to disable borrows outside elevation groups
204
+ */
205
+ readonly borrowLimitOutsideElevationGroup: BN;
206
+ /**
207
+ * Defines the maximum amount (in lamports of elevation group debt asset)
208
+ * that can be borrowed when this reserve is used as collateral.
209
+ * - u64::MAX for inf
210
+ * - 0 to disable borrows in this elevation group (expected value for the debt asset)
211
+ */
212
+ readonly borrowLimitAgainstThisCollateralInElevationGroup: Array<BN>;
213
+ constructor(fields: ReserveConfigFields);
214
+ static layout(property?: string): any;
215
+ static fromDecoded(obj: any): ReserveConfig;
216
+ static toEncodable(fields: ReserveConfigFields): {
217
+ status: number;
218
+ assetTier: number;
219
+ hostFixedInterestRateBps: number;
220
+ reserved2: number[];
221
+ reserved3: number[];
222
+ protocolTakeRatePct: number;
223
+ protocolLiquidationFeePct: number;
224
+ loanToValuePct: number;
225
+ liquidationThresholdPct: number;
226
+ minLiquidationBonusBps: number;
227
+ maxLiquidationBonusBps: number;
228
+ badDebtLiquidationBonusBps: number;
229
+ deleveragingMarginCallPeriodSecs: BN;
230
+ deleveragingThresholdSlotsPerBps: BN;
231
+ fees: {
232
+ borrowFeeSf: BN;
233
+ flashLoanFeeSf: BN;
234
+ padding: number[];
235
+ };
236
+ borrowRateCurve: {
237
+ points: {
238
+ utilizationRateBps: number;
239
+ borrowRateBps: number;
240
+ }[];
241
+ };
242
+ borrowFactorPct: BN;
243
+ depositLimit: BN;
244
+ borrowLimit: BN;
245
+ tokenInfo: {
246
+ name: number[];
247
+ heuristic: {
248
+ lower: BN;
249
+ upper: BN;
250
+ exp: BN;
251
+ };
252
+ maxTwapDivergenceBps: BN;
253
+ maxAgePriceSeconds: BN;
254
+ maxAgeTwapSeconds: BN;
255
+ scopeConfiguration: {
256
+ priceFeed: import("@solana/web3.js").PublicKey;
257
+ priceChain: number[];
258
+ twapChain: number[];
259
+ };
260
+ switchboardConfiguration: {
261
+ priceAggregator: import("@solana/web3.js").PublicKey;
262
+ twapAggregator: import("@solana/web3.js").PublicKey;
263
+ };
264
+ pythConfiguration: {
265
+ price: import("@solana/web3.js").PublicKey;
266
+ };
267
+ blockPriceUsage: number;
268
+ reserved: number[];
269
+ padding: BN[];
270
+ };
271
+ depositWithdrawalCap: {
272
+ configCapacity: BN;
273
+ currentTotal: BN;
274
+ lastIntervalStartTimestamp: BN;
275
+ configIntervalLengthSeconds: BN;
276
+ };
277
+ debtWithdrawalCap: {
278
+ configCapacity: BN;
279
+ currentTotal: BN;
280
+ lastIntervalStartTimestamp: BN;
281
+ configIntervalLengthSeconds: BN;
282
+ };
283
+ elevationGroups: number[];
284
+ disableUsageAsCollOutsideEmode: number;
285
+ utilizationLimitBlockBorrowingAbove: number;
286
+ reserved1: number[];
287
+ borrowLimitOutsideElevationGroup: BN;
288
+ borrowLimitAgainstThisCollateralInElevationGroup: BN[];
289
+ };
290
+ toJSON(): ReserveConfigJSON;
291
+ static fromJSON(obj: ReserveConfigJSON): ReserveConfig;
292
+ toEncodable(): {
293
+ status: number;
294
+ assetTier: number;
295
+ hostFixedInterestRateBps: number;
296
+ reserved2: number[];
297
+ reserved3: number[];
298
+ protocolTakeRatePct: number;
299
+ protocolLiquidationFeePct: number;
300
+ loanToValuePct: number;
301
+ liquidationThresholdPct: number;
302
+ minLiquidationBonusBps: number;
303
+ maxLiquidationBonusBps: number;
304
+ badDebtLiquidationBonusBps: number;
305
+ deleveragingMarginCallPeriodSecs: BN;
306
+ deleveragingThresholdSlotsPerBps: BN;
307
+ fees: {
308
+ borrowFeeSf: BN;
309
+ flashLoanFeeSf: BN;
310
+ padding: number[];
311
+ };
312
+ borrowRateCurve: {
313
+ points: {
314
+ utilizationRateBps: number;
315
+ borrowRateBps: number;
316
+ }[];
317
+ };
318
+ borrowFactorPct: BN;
319
+ depositLimit: BN;
320
+ borrowLimit: BN;
321
+ tokenInfo: {
322
+ name: number[];
323
+ heuristic: {
324
+ lower: BN;
325
+ upper: BN;
326
+ exp: BN;
327
+ };
328
+ maxTwapDivergenceBps: BN;
329
+ maxAgePriceSeconds: BN;
330
+ maxAgeTwapSeconds: BN;
331
+ scopeConfiguration: {
332
+ priceFeed: import("@solana/web3.js").PublicKey;
333
+ priceChain: number[];
334
+ twapChain: number[];
335
+ };
336
+ switchboardConfiguration: {
337
+ priceAggregator: import("@solana/web3.js").PublicKey;
338
+ twapAggregator: import("@solana/web3.js").PublicKey;
339
+ };
340
+ pythConfiguration: {
341
+ price: import("@solana/web3.js").PublicKey;
342
+ };
343
+ blockPriceUsage: number;
344
+ reserved: number[];
345
+ padding: BN[];
346
+ };
347
+ depositWithdrawalCap: {
348
+ configCapacity: BN;
349
+ currentTotal: BN;
350
+ lastIntervalStartTimestamp: BN;
351
+ configIntervalLengthSeconds: BN;
352
+ };
353
+ debtWithdrawalCap: {
354
+ configCapacity: BN;
355
+ currentTotal: BN;
356
+ lastIntervalStartTimestamp: BN;
357
+ configIntervalLengthSeconds: BN;
358
+ };
359
+ elevationGroups: number[];
360
+ disableUsageAsCollOutsideEmode: number;
361
+ utilizationLimitBlockBorrowingAbove: number;
362
+ reserved1: number[];
363
+ borrowLimitOutsideElevationGroup: BN;
364
+ borrowLimitAgainstThisCollateralInElevationGroup: BN[];
365
+ };
366
+ }
@@ -0,0 +1,307 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ReserveConfig = void 0;
30
+ const bn_js_1 = __importDefault(require("bn.js")); // eslint-disable-line @typescript-eslint/no-unused-vars
31
+ const borsh = __importStar(require("@coral-xyz/borsh"));
32
+ const ReserveFees_1 = require("./ReserveFees");
33
+ const BorrowRateCurve_1 = require("./BorrowRateCurve");
34
+ const TokenInfo_1 = require("./TokenInfo");
35
+ const WithdrawalCaps_1 = require("./WithdrawalCaps");
36
+ /** Reserve configuration values */
37
+ class ReserveConfig {
38
+ /** Status of the reserve Active/Obsolete/Hidden */
39
+ status;
40
+ /** Asset tier -> 0 - regular (collateral & debt), 1 - isolated collateral, 2 - isolated debt */
41
+ assetTier;
42
+ /** Flat rate that goes to the host */
43
+ hostFixedInterestRateBps;
44
+ /** [DEPRECATED] Boost for side (debt or collateral) */
45
+ reserved2;
46
+ /** [DEPRECATED] Reward points multiplier per obligation type */
47
+ reserved3;
48
+ /** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
49
+ protocolTakeRatePct;
50
+ /** Cut of the liquidation bonus that the protocol receives, as a percentage */
51
+ protocolLiquidationFeePct;
52
+ /**
53
+ * Target ratio of the value of borrows to deposits, as a percentage
54
+ * 0 if use as collateral is disabled
55
+ */
56
+ loanToValuePct;
57
+ /** Loan to value ratio at which an obligation can be liquidated, as percentage */
58
+ liquidationThresholdPct;
59
+ /** Minimum bonus a liquidator receives when repaying part of an unhealthy obligation, as bps */
60
+ minLiquidationBonusBps;
61
+ /** Maximum bonus a liquidator receives when repaying part of an unhealthy obligation, as bps */
62
+ maxLiquidationBonusBps;
63
+ /** Bad debt liquidation bonus for an undercollateralized obligation, as bps */
64
+ badDebtLiquidationBonusBps;
65
+ /** Time in seconds that must pass before redemptions are enabled after the deposit limit is crossed */
66
+ deleveragingMarginCallPeriodSecs;
67
+ /**
68
+ * The rate at which the deleveraging threshold decreases in slots per bps
69
+ * e.g. 1 bps per hour would be 7200 slots per bps (assuming 2 slots per second)
70
+ */
71
+ deleveragingThresholdSlotsPerBps;
72
+ /** Program owner fees assessed, separate from gains due to interest accrual */
73
+ fees;
74
+ /** Borrow rate curve based on utilization */
75
+ borrowRateCurve;
76
+ /** Borrow factor in percentage - used for risk adjustment */
77
+ borrowFactorPct;
78
+ /** Maximum deposit limit of liquidity in native units, u64::MAX for inf */
79
+ depositLimit;
80
+ /** Maximum amount borrowed, u64::MAX for inf, 0 to disable borrows (protected deposits) */
81
+ borrowLimit;
82
+ /** Token id from TokenInfos struct */
83
+ tokenInfo;
84
+ /** Deposit withdrawl caps - deposit & redeem */
85
+ depositWithdrawalCap;
86
+ /** Debt withdrawl caps - borrow & repay */
87
+ debtWithdrawalCap;
88
+ elevationGroups;
89
+ disableUsageAsCollOutsideEmode;
90
+ utilizationLimitBlockBorrowingAbove;
91
+ reserved1;
92
+ /**
93
+ * Maximum amount liquidity of this reserve borrowed outside all elevation groups
94
+ * - u64::MAX for inf
95
+ * - 0 to disable borrows outside elevation groups
96
+ */
97
+ borrowLimitOutsideElevationGroup;
98
+ /**
99
+ * Defines the maximum amount (in lamports of elevation group debt asset)
100
+ * that can be borrowed when this reserve is used as collateral.
101
+ * - u64::MAX for inf
102
+ * - 0 to disable borrows in this elevation group (expected value for the debt asset)
103
+ */
104
+ borrowLimitAgainstThisCollateralInElevationGroup;
105
+ constructor(fields) {
106
+ this.status = fields.status;
107
+ this.assetTier = fields.assetTier;
108
+ this.hostFixedInterestRateBps = fields.hostFixedInterestRateBps;
109
+ this.reserved2 = fields.reserved2;
110
+ this.reserved3 = fields.reserved3;
111
+ this.protocolTakeRatePct = fields.protocolTakeRatePct;
112
+ this.protocolLiquidationFeePct = fields.protocolLiquidationFeePct;
113
+ this.loanToValuePct = fields.loanToValuePct;
114
+ this.liquidationThresholdPct = fields.liquidationThresholdPct;
115
+ this.minLiquidationBonusBps = fields.minLiquidationBonusBps;
116
+ this.maxLiquidationBonusBps = fields.maxLiquidationBonusBps;
117
+ this.badDebtLiquidationBonusBps = fields.badDebtLiquidationBonusBps;
118
+ this.deleveragingMarginCallPeriodSecs = fields.deleveragingMarginCallPeriodSecs;
119
+ this.deleveragingThresholdSlotsPerBps = fields.deleveragingThresholdSlotsPerBps;
120
+ this.fees = new ReserveFees_1.ReserveFees({ ...fields.fees });
121
+ this.borrowRateCurve = new BorrowRateCurve_1.BorrowRateCurve({
122
+ ...fields.borrowRateCurve,
123
+ });
124
+ this.borrowFactorPct = fields.borrowFactorPct;
125
+ this.depositLimit = fields.depositLimit;
126
+ this.borrowLimit = fields.borrowLimit;
127
+ this.tokenInfo = new TokenInfo_1.TokenInfo({ ...fields.tokenInfo });
128
+ this.depositWithdrawalCap = new WithdrawalCaps_1.WithdrawalCaps({
129
+ ...fields.depositWithdrawalCap,
130
+ });
131
+ this.debtWithdrawalCap = new WithdrawalCaps_1.WithdrawalCaps({
132
+ ...fields.debtWithdrawalCap,
133
+ });
134
+ this.elevationGroups = fields.elevationGroups;
135
+ this.disableUsageAsCollOutsideEmode = fields.disableUsageAsCollOutsideEmode;
136
+ this.utilizationLimitBlockBorrowingAbove = fields.utilizationLimitBlockBorrowingAbove;
137
+ this.reserved1 = fields.reserved1;
138
+ this.borrowLimitOutsideElevationGroup = fields.borrowLimitOutsideElevationGroup;
139
+ this.borrowLimitAgainstThisCollateralInElevationGroup = fields.borrowLimitAgainstThisCollateralInElevationGroup;
140
+ }
141
+ static layout(property) {
142
+ return borsh.struct([
143
+ borsh.u8("status"),
144
+ borsh.u8("assetTier"),
145
+ borsh.u16("hostFixedInterestRateBps"),
146
+ borsh.array(borsh.u8(), 2, "reserved2"),
147
+ borsh.array(borsh.u8(), 8, "reserved3"),
148
+ borsh.u8("protocolTakeRatePct"),
149
+ borsh.u8("protocolLiquidationFeePct"),
150
+ borsh.u8("loanToValuePct"),
151
+ borsh.u8("liquidationThresholdPct"),
152
+ borsh.u16("minLiquidationBonusBps"),
153
+ borsh.u16("maxLiquidationBonusBps"),
154
+ borsh.u16("badDebtLiquidationBonusBps"),
155
+ borsh.u64("deleveragingMarginCallPeriodSecs"),
156
+ borsh.u64("deleveragingThresholdSlotsPerBps"),
157
+ ReserveFees_1.ReserveFees.layout("fees"),
158
+ BorrowRateCurve_1.BorrowRateCurve.layout("borrowRateCurve"),
159
+ borsh.u64("borrowFactorPct"),
160
+ borsh.u64("depositLimit"),
161
+ borsh.u64("borrowLimit"),
162
+ TokenInfo_1.TokenInfo.layout("tokenInfo"),
163
+ WithdrawalCaps_1.WithdrawalCaps.layout("depositWithdrawalCap"),
164
+ WithdrawalCaps_1.WithdrawalCaps.layout("debtWithdrawalCap"),
165
+ borsh.array(borsh.u8(), 20, "elevationGroups"),
166
+ borsh.u8("disableUsageAsCollOutsideEmode"),
167
+ borsh.u8("utilizationLimitBlockBorrowingAbove"),
168
+ borsh.array(borsh.u8(), 2, "reserved1"),
169
+ borsh.u64("borrowLimitOutsideElevationGroup"),
170
+ borsh.array(borsh.u64(), 32, "borrowLimitAgainstThisCollateralInElevationGroup"),
171
+ ], property);
172
+ }
173
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
174
+ static fromDecoded(obj) {
175
+ return new ReserveConfig({
176
+ status: obj.status,
177
+ assetTier: obj.assetTier,
178
+ hostFixedInterestRateBps: obj.hostFixedInterestRateBps,
179
+ reserved2: obj.reserved2,
180
+ reserved3: obj.reserved3,
181
+ protocolTakeRatePct: obj.protocolTakeRatePct,
182
+ protocolLiquidationFeePct: obj.protocolLiquidationFeePct,
183
+ loanToValuePct: obj.loanToValuePct,
184
+ liquidationThresholdPct: obj.liquidationThresholdPct,
185
+ minLiquidationBonusBps: obj.minLiquidationBonusBps,
186
+ maxLiquidationBonusBps: obj.maxLiquidationBonusBps,
187
+ badDebtLiquidationBonusBps: obj.badDebtLiquidationBonusBps,
188
+ deleveragingMarginCallPeriodSecs: obj.deleveragingMarginCallPeriodSecs,
189
+ deleveragingThresholdSlotsPerBps: obj.deleveragingThresholdSlotsPerBps,
190
+ fees: ReserveFees_1.ReserveFees.fromDecoded(obj.fees),
191
+ borrowRateCurve: BorrowRateCurve_1.BorrowRateCurve.fromDecoded(obj.borrowRateCurve),
192
+ borrowFactorPct: obj.borrowFactorPct,
193
+ depositLimit: obj.depositLimit,
194
+ borrowLimit: obj.borrowLimit,
195
+ tokenInfo: TokenInfo_1.TokenInfo.fromDecoded(obj.tokenInfo),
196
+ depositWithdrawalCap: WithdrawalCaps_1.WithdrawalCaps.fromDecoded(obj.depositWithdrawalCap),
197
+ debtWithdrawalCap: WithdrawalCaps_1.WithdrawalCaps.fromDecoded(obj.debtWithdrawalCap),
198
+ elevationGroups: obj.elevationGroups,
199
+ disableUsageAsCollOutsideEmode: obj.disableUsageAsCollOutsideEmode,
200
+ utilizationLimitBlockBorrowingAbove: obj.utilizationLimitBlockBorrowingAbove,
201
+ reserved1: obj.reserved1,
202
+ borrowLimitOutsideElevationGroup: obj.borrowLimitOutsideElevationGroup,
203
+ borrowLimitAgainstThisCollateralInElevationGroup: obj.borrowLimitAgainstThisCollateralInElevationGroup,
204
+ });
205
+ }
206
+ static toEncodable(fields) {
207
+ return {
208
+ status: fields.status,
209
+ assetTier: fields.assetTier,
210
+ hostFixedInterestRateBps: fields.hostFixedInterestRateBps,
211
+ reserved2: fields.reserved2,
212
+ reserved3: fields.reserved3,
213
+ protocolTakeRatePct: fields.protocolTakeRatePct,
214
+ protocolLiquidationFeePct: fields.protocolLiquidationFeePct,
215
+ loanToValuePct: fields.loanToValuePct,
216
+ liquidationThresholdPct: fields.liquidationThresholdPct,
217
+ minLiquidationBonusBps: fields.minLiquidationBonusBps,
218
+ maxLiquidationBonusBps: fields.maxLiquidationBonusBps,
219
+ badDebtLiquidationBonusBps: fields.badDebtLiquidationBonusBps,
220
+ deleveragingMarginCallPeriodSecs: fields.deleveragingMarginCallPeriodSecs,
221
+ deleveragingThresholdSlotsPerBps: fields.deleveragingThresholdSlotsPerBps,
222
+ fees: ReserveFees_1.ReserveFees.toEncodable(fields.fees),
223
+ borrowRateCurve: BorrowRateCurve_1.BorrowRateCurve.toEncodable(fields.borrowRateCurve),
224
+ borrowFactorPct: fields.borrowFactorPct,
225
+ depositLimit: fields.depositLimit,
226
+ borrowLimit: fields.borrowLimit,
227
+ tokenInfo: TokenInfo_1.TokenInfo.toEncodable(fields.tokenInfo),
228
+ depositWithdrawalCap: WithdrawalCaps_1.WithdrawalCaps.toEncodable(fields.depositWithdrawalCap),
229
+ debtWithdrawalCap: WithdrawalCaps_1.WithdrawalCaps.toEncodable(fields.debtWithdrawalCap),
230
+ elevationGroups: fields.elevationGroups,
231
+ disableUsageAsCollOutsideEmode: fields.disableUsageAsCollOutsideEmode,
232
+ utilizationLimitBlockBorrowingAbove: fields.utilizationLimitBlockBorrowingAbove,
233
+ reserved1: fields.reserved1,
234
+ borrowLimitOutsideElevationGroup: fields.borrowLimitOutsideElevationGroup,
235
+ borrowLimitAgainstThisCollateralInElevationGroup: fields.borrowLimitAgainstThisCollateralInElevationGroup,
236
+ };
237
+ }
238
+ toJSON() {
239
+ return {
240
+ status: this.status,
241
+ assetTier: this.assetTier,
242
+ hostFixedInterestRateBps: this.hostFixedInterestRateBps,
243
+ reserved2: this.reserved2,
244
+ reserved3: this.reserved3,
245
+ protocolTakeRatePct: this.protocolTakeRatePct,
246
+ protocolLiquidationFeePct: this.protocolLiquidationFeePct,
247
+ loanToValuePct: this.loanToValuePct,
248
+ liquidationThresholdPct: this.liquidationThresholdPct,
249
+ minLiquidationBonusBps: this.minLiquidationBonusBps,
250
+ maxLiquidationBonusBps: this.maxLiquidationBonusBps,
251
+ badDebtLiquidationBonusBps: this.badDebtLiquidationBonusBps,
252
+ deleveragingMarginCallPeriodSecs: this.deleveragingMarginCallPeriodSecs.toString(),
253
+ deleveragingThresholdSlotsPerBps: this.deleveragingThresholdSlotsPerBps.toString(),
254
+ fees: this.fees.toJSON(),
255
+ borrowRateCurve: this.borrowRateCurve.toJSON(),
256
+ borrowFactorPct: this.borrowFactorPct.toString(),
257
+ depositLimit: this.depositLimit.toString(),
258
+ borrowLimit: this.borrowLimit.toString(),
259
+ tokenInfo: this.tokenInfo.toJSON(),
260
+ depositWithdrawalCap: this.depositWithdrawalCap.toJSON(),
261
+ debtWithdrawalCap: this.debtWithdrawalCap.toJSON(),
262
+ elevationGroups: this.elevationGroups,
263
+ disableUsageAsCollOutsideEmode: this.disableUsageAsCollOutsideEmode,
264
+ utilizationLimitBlockBorrowingAbove: this.utilizationLimitBlockBorrowingAbove,
265
+ reserved1: this.reserved1,
266
+ borrowLimitOutsideElevationGroup: this.borrowLimitOutsideElevationGroup.toString(),
267
+ borrowLimitAgainstThisCollateralInElevationGroup: this.borrowLimitAgainstThisCollateralInElevationGroup.map((item) => item.toString()),
268
+ };
269
+ }
270
+ static fromJSON(obj) {
271
+ return new ReserveConfig({
272
+ status: obj.status,
273
+ assetTier: obj.assetTier,
274
+ hostFixedInterestRateBps: obj.hostFixedInterestRateBps,
275
+ reserved2: obj.reserved2,
276
+ reserved3: obj.reserved3,
277
+ protocolTakeRatePct: obj.protocolTakeRatePct,
278
+ protocolLiquidationFeePct: obj.protocolLiquidationFeePct,
279
+ loanToValuePct: obj.loanToValuePct,
280
+ liquidationThresholdPct: obj.liquidationThresholdPct,
281
+ minLiquidationBonusBps: obj.minLiquidationBonusBps,
282
+ maxLiquidationBonusBps: obj.maxLiquidationBonusBps,
283
+ badDebtLiquidationBonusBps: obj.badDebtLiquidationBonusBps,
284
+ deleveragingMarginCallPeriodSecs: new bn_js_1.default(obj.deleveragingMarginCallPeriodSecs),
285
+ deleveragingThresholdSlotsPerBps: new bn_js_1.default(obj.deleveragingThresholdSlotsPerBps),
286
+ fees: ReserveFees_1.ReserveFees.fromJSON(obj.fees),
287
+ borrowRateCurve: BorrowRateCurve_1.BorrowRateCurve.fromJSON(obj.borrowRateCurve),
288
+ borrowFactorPct: new bn_js_1.default(obj.borrowFactorPct),
289
+ depositLimit: new bn_js_1.default(obj.depositLimit),
290
+ borrowLimit: new bn_js_1.default(obj.borrowLimit),
291
+ tokenInfo: TokenInfo_1.TokenInfo.fromJSON(obj.tokenInfo),
292
+ depositWithdrawalCap: WithdrawalCaps_1.WithdrawalCaps.fromJSON(obj.depositWithdrawalCap),
293
+ debtWithdrawalCap: WithdrawalCaps_1.WithdrawalCaps.fromJSON(obj.debtWithdrawalCap),
294
+ elevationGroups: obj.elevationGroups,
295
+ disableUsageAsCollOutsideEmode: obj.disableUsageAsCollOutsideEmode,
296
+ utilizationLimitBlockBorrowingAbove: obj.utilizationLimitBlockBorrowingAbove,
297
+ reserved1: obj.reserved1,
298
+ borrowLimitOutsideElevationGroup: new bn_js_1.default(obj.borrowLimitOutsideElevationGroup),
299
+ borrowLimitAgainstThisCollateralInElevationGroup: obj.borrowLimitAgainstThisCollateralInElevationGroup.map((item) => new bn_js_1.default(item)),
300
+ });
301
+ }
302
+ toEncodable() {
303
+ return ReserveConfig.toEncodable(this);
304
+ }
305
+ }
306
+ exports.ReserveConfig = ReserveConfig;
307
+ //# sourceMappingURL=ReserveConfig.js.map