@kamino-finance/klend-sdk 7.4.0-beta.2 → 7.4.0-beta.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 (132) hide show
  1. package/dist/@codegen/klend/accounts/LendingMarket.d.ts +150 -3
  2. package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
  3. package/dist/@codegen/klend/accounts/LendingMarket.js +91 -2
  4. package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
  5. package/dist/@codegen/klend/accounts/Reserve.d.ts +6 -0
  6. package/dist/@codegen/klend/accounts/Reserve.d.ts.map +1 -1
  7. package/dist/@codegen/klend/accounts/Reserve.js +8 -1
  8. package/dist/@codegen/klend/accounts/Reserve.js.map +1 -1
  9. package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts +144 -0
  10. package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts.map +1 -0
  11. package/dist/@codegen/klend/accounts/WithdrawTicket.js +205 -0
  12. package/dist/@codegen/klend/accounts/WithdrawTicket.js.map +1 -0
  13. package/dist/@codegen/klend/accounts/index.d.ts +2 -0
  14. package/dist/@codegen/klend/accounts/index.d.ts.map +1 -1
  15. package/dist/@codegen/klend/accounts/index.js +3 -1
  16. package/dist/@codegen/klend/accounts/index.js.map +1 -1
  17. package/dist/@codegen/klend/errors/custom.d.ts +81 -1
  18. package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
  19. package/dist/@codegen/klend/errors/custom.js +142 -1
  20. package/dist/@codegen/klend/errors/custom.js.map +1 -1
  21. package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts +62 -0
  22. package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts.map +1 -0
  23. package/dist/@codegen/klend/instructions/enqueueToWithdraw.js +79 -0
  24. package/dist/@codegen/klend/instructions/enqueueToWithdraw.js.map +1 -0
  25. package/dist/@codegen/klend/instructions/index.d.ts +6 -0
  26. package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
  27. package/dist/@codegen/klend/instructions/index.js +8 -2
  28. package/dist/@codegen/klend/instructions/index.js.map +1 -1
  29. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts +54 -0
  30. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts.map +1 -0
  31. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js +66 -0
  32. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js.map +1 -0
  33. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts +66 -0
  34. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts.map +1 -0
  35. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js +41 -0
  36. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js.map +1 -0
  37. package/dist/@codegen/klend/types/BorrowOrder.d.ts +3 -3
  38. package/dist/@codegen/klend/types/BorrowOrder.js +1 -1
  39. package/dist/@codegen/klend/types/FixedTermBorrowRolloverConfig.d.ts +145 -0
  40. package/dist/@codegen/klend/types/FixedTermBorrowRolloverConfig.d.ts.map +1 -0
  41. package/dist/@codegen/klend/types/FixedTermBorrowRolloverConfig.js +144 -0
  42. package/dist/@codegen/klend/types/FixedTermBorrowRolloverConfig.js.map +1 -0
  43. package/dist/@codegen/klend/types/ObligationLiquidity.d.ts +29 -0
  44. package/dist/@codegen/klend/types/ObligationLiquidity.d.ts.map +1 -1
  45. package/dist/@codegen/klend/types/ObligationLiquidity.js +15 -1
  46. package/dist/@codegen/klend/types/ObligationLiquidity.js.map +1 -1
  47. package/dist/@codegen/klend/types/ProgressCallbackType.d.ts +32 -0
  48. package/dist/@codegen/klend/types/ProgressCallbackType.d.ts.map +1 -0
  49. package/dist/@codegen/klend/types/ProgressCallbackType.js +108 -0
  50. package/dist/@codegen/klend/types/ProgressCallbackType.js.map +1 -0
  51. package/dist/@codegen/klend/types/ReserveLiquidity.d.ts +26 -8
  52. package/dist/@codegen/klend/types/ReserveLiquidity.d.ts.map +1 -1
  53. package/dist/@codegen/klend/types/ReserveLiquidity.js +14 -8
  54. package/dist/@codegen/klend/types/ReserveLiquidity.js.map +1 -1
  55. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +7 -7
  56. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
  57. package/dist/@codegen/klend/types/UpdateConfigMode.js +12 -12
  58. package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
  59. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +78 -0
  60. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
  61. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +145 -1
  62. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
  63. package/dist/@codegen/klend/types/WithdrawQueue.d.ts +64 -0
  64. package/dist/@codegen/klend/types/WithdrawQueue.d.ts.map +1 -0
  65. package/dist/@codegen/klend/types/WithdrawQueue.js +104 -0
  66. package/dist/@codegen/klend/types/WithdrawQueue.js.map +1 -0
  67. package/dist/@codegen/klend/types/index.d.ts +23 -4
  68. package/dist/@codegen/klend/types/index.d.ts.map +1 -1
  69. package/dist/@codegen/klend/types/index.js +7 -1
  70. package/dist/@codegen/klend/types/index.js.map +1 -1
  71. package/dist/classes/action.d.ts +11 -0
  72. package/dist/classes/action.d.ts.map +1 -1
  73. package/dist/classes/action.js +66 -0
  74. package/dist/classes/action.js.map +1 -1
  75. package/dist/classes/actionTypes.d.ts +29 -0
  76. package/dist/classes/actionTypes.d.ts.map +1 -1
  77. package/dist/classes/manager.d.ts +1 -1
  78. package/dist/classes/manager.d.ts.map +1 -1
  79. package/dist/classes/manager.js +9 -8
  80. package/dist/classes/manager.js.map +1 -1
  81. package/dist/classes/market.d.ts +7 -102
  82. package/dist/classes/market.d.ts.map +1 -1
  83. package/dist/classes/market.js +8 -153
  84. package/dist/classes/market.js.map +1 -1
  85. package/dist/classes/reserve.d.ts +3 -10
  86. package/dist/classes/reserve.d.ts.map +1 -1
  87. package/dist/classes/reserve.js +45 -51
  88. package/dist/classes/reserve.js.map +1 -1
  89. package/dist/idl/klend.json +860 -32
  90. package/dist/manager/client_kamino_manager.js +2 -3
  91. package/dist/manager/client_kamino_manager.js.map +1 -1
  92. package/dist/utils/index.d.ts +0 -1
  93. package/dist/utils/index.d.ts.map +1 -1
  94. package/dist/utils/index.js +0 -1
  95. package/dist/utils/index.js.map +1 -1
  96. package/dist/utils/seeds.d.ts +24 -0
  97. package/dist/utils/seeds.d.ts.map +1 -1
  98. package/dist/utils/seeds.js +41 -1
  99. package/dist/utils/seeds.js.map +1 -1
  100. package/package.json +1 -1
  101. package/src/@codegen/klend/accounts/LendingMarket.ts +205 -4
  102. package/src/@codegen/klend/accounts/Reserve.ts +12 -1
  103. package/src/@codegen/klend/accounts/WithdrawTicket.ts +280 -0
  104. package/src/@codegen/klend/accounts/index.ts +2 -0
  105. package/src/@codegen/klend/errors/custom.ts +161 -0
  106. package/src/@codegen/klend/instructions/enqueueToWithdraw.ts +120 -0
  107. package/src/@codegen/klend/instructions/index.ts +12 -0
  108. package/src/@codegen/klend/instructions/recoverInvalidTicketCollateral.ts +103 -0
  109. package/src/@codegen/klend/instructions/withdrawQueuedLiquidity.ts +118 -0
  110. package/src/@codegen/klend/types/BorrowOrder.ts +3 -3
  111. package/src/@codegen/klend/types/FixedTermBorrowRolloverConfig.ts +199 -0
  112. package/src/@codegen/klend/types/ObligationLiquidity.ts +37 -1
  113. package/src/@codegen/klend/types/ProgressCallbackType.ts +91 -0
  114. package/src/@codegen/klend/types/ReserveLiquidity.ts +30 -12
  115. package/src/@codegen/klend/types/UpdateConfigMode.ts +13 -13
  116. package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +180 -0
  117. package/src/@codegen/klend/types/WithdrawQueue.ts +117 -0
  118. package/src/@codegen/klend/types/index.ts +42 -2
  119. package/src/classes/action.ts +115 -1
  120. package/src/classes/actionTypes.ts +31 -0
  121. package/src/classes/manager.ts +19 -27
  122. package/src/classes/market.ts +8 -183
  123. package/src/classes/reserve.ts +45 -68
  124. package/src/idl/klend.json +860 -32
  125. package/src/manager/client_kamino_manager.ts +2 -4
  126. package/src/utils/index.ts +0 -1
  127. package/src/utils/seeds.ts +49 -0
  128. package/dist/utils/ReserveKind.d.ts +0 -57
  129. package/dist/utils/ReserveKind.d.ts.map +0 -1
  130. package/dist/utils/ReserveKind.js +0 -76
  131. package/dist/utils/ReserveKind.js.map +0 -1
  132. package/src/utils/ReserveKind.ts +0 -94
@@ -0,0 +1,199 @@
1
+ import { address, Address } from "@solana/kit" // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as borsh from "@coral-xyz/borsh"
5
+ import { borshAddress } from "../utils"
6
+
7
+ export interface FixedTermBorrowRolloverConfigFields {
8
+ /**
9
+ * Whether the borrow can be permissionlessly prolonged under the following *joint* conditions:
10
+ *
11
+ * The reserve used to re-borrow the liquidity must have:
12
+ * A) the exact same maximum borrow rate as the current one,
13
+ * B) the exact same debt term as the current one,
14
+ * C) sufficient available liquidity (including no withdraw tickets waiting in its queue).
15
+ *
16
+ * The time left until the current debt term expires must be:
17
+ * D) less than [LendingMarket::fixed_rollover_window_duration_seconds].
18
+ *
19
+ * Note: the other settings are only effective when this one is `1`.
20
+ */
21
+ autoRolloverEnabled: number
22
+ /**
23
+ * When `1`, partially lifts the condition *B* from [Self::auto_rollover_enabled]: additionally
24
+ * allows to use a variable (indefinite) debt term if less than
25
+ * [LendingMarket::variable_rollover_window_duration_seconds] is left until expiration.
26
+ *
27
+ * Note: typically this flag should be used together with [Self::max_borrow_rate_bps] set to
28
+ * `u32::MAX` (to denote a variable-rate reserve).
29
+ */
30
+ openTermAllowed: number
31
+ /** Internal alignment padding (free to reuse). */
32
+ alignmentPadding: Array<number>
33
+ /**
34
+ * A customization setting that can lift the condition *A* from [Self::auto_rollover_enabled]:
35
+ * when not zeroed, the rollover may use a reserve with a maximum borrow rate equal or lower
36
+ * than the given one.
37
+ */
38
+ maxBorrowRateBps: number
39
+ /**
40
+ * A customization setting that can lift the condition *B* from [Self::auto_rollover_enabled]:
41
+ * when not zeroed, the rollover may use a reserve with a *fixed* debt term equal or longer
42
+ * than the given one.
43
+ */
44
+ minDebtTermSeconds: BN
45
+ }
46
+
47
+ export interface FixedTermBorrowRolloverConfigJSON {
48
+ /**
49
+ * Whether the borrow can be permissionlessly prolonged under the following *joint* conditions:
50
+ *
51
+ * The reserve used to re-borrow the liquidity must have:
52
+ * A) the exact same maximum borrow rate as the current one,
53
+ * B) the exact same debt term as the current one,
54
+ * C) sufficient available liquidity (including no withdraw tickets waiting in its queue).
55
+ *
56
+ * The time left until the current debt term expires must be:
57
+ * D) less than [LendingMarket::fixed_rollover_window_duration_seconds].
58
+ *
59
+ * Note: the other settings are only effective when this one is `1`.
60
+ */
61
+ autoRolloverEnabled: number
62
+ /**
63
+ * When `1`, partially lifts the condition *B* from [Self::auto_rollover_enabled]: additionally
64
+ * allows to use a variable (indefinite) debt term if less than
65
+ * [LendingMarket::variable_rollover_window_duration_seconds] is left until expiration.
66
+ *
67
+ * Note: typically this flag should be used together with [Self::max_borrow_rate_bps] set to
68
+ * `u32::MAX` (to denote a variable-rate reserve).
69
+ */
70
+ openTermAllowed: number
71
+ /** Internal alignment padding (free to reuse). */
72
+ alignmentPadding: Array<number>
73
+ /**
74
+ * A customization setting that can lift the condition *A* from [Self::auto_rollover_enabled]:
75
+ * when not zeroed, the rollover may use a reserve with a maximum borrow rate equal or lower
76
+ * than the given one.
77
+ */
78
+ maxBorrowRateBps: number
79
+ /**
80
+ * A customization setting that can lift the condition *B* from [Self::auto_rollover_enabled]:
81
+ * when not zeroed, the rollover may use a reserve with a *fixed* debt term equal or longer
82
+ * than the given one.
83
+ */
84
+ minDebtTermSeconds: string
85
+ }
86
+
87
+ /**
88
+ * Settings driving the auto-rollover of an [ObligationLiquidity] that uses a fixed-term [Reserve]
89
+ * and approaches the end of its [ReserveConfig::debt_term_seconds].
90
+ *
91
+ * By its nature (not a special case), the zeroed struct mean "no auto-rollover".
92
+ */
93
+ export class FixedTermBorrowRolloverConfig {
94
+ /**
95
+ * Whether the borrow can be permissionlessly prolonged under the following *joint* conditions:
96
+ *
97
+ * The reserve used to re-borrow the liquidity must have:
98
+ * A) the exact same maximum borrow rate as the current one,
99
+ * B) the exact same debt term as the current one,
100
+ * C) sufficient available liquidity (including no withdraw tickets waiting in its queue).
101
+ *
102
+ * The time left until the current debt term expires must be:
103
+ * D) less than [LendingMarket::fixed_rollover_window_duration_seconds].
104
+ *
105
+ * Note: the other settings are only effective when this one is `1`.
106
+ */
107
+ readonly autoRolloverEnabled: number
108
+ /**
109
+ * When `1`, partially lifts the condition *B* from [Self::auto_rollover_enabled]: additionally
110
+ * allows to use a variable (indefinite) debt term if less than
111
+ * [LendingMarket::variable_rollover_window_duration_seconds] is left until expiration.
112
+ *
113
+ * Note: typically this flag should be used together with [Self::max_borrow_rate_bps] set to
114
+ * `u32::MAX` (to denote a variable-rate reserve).
115
+ */
116
+ readonly openTermAllowed: number
117
+ /** Internal alignment padding (free to reuse). */
118
+ readonly alignmentPadding: Array<number>
119
+ /**
120
+ * A customization setting that can lift the condition *A* from [Self::auto_rollover_enabled]:
121
+ * when not zeroed, the rollover may use a reserve with a maximum borrow rate equal or lower
122
+ * than the given one.
123
+ */
124
+ readonly maxBorrowRateBps: number
125
+ /**
126
+ * A customization setting that can lift the condition *B* from [Self::auto_rollover_enabled]:
127
+ * when not zeroed, the rollover may use a reserve with a *fixed* debt term equal or longer
128
+ * than the given one.
129
+ */
130
+ readonly minDebtTermSeconds: BN
131
+
132
+ constructor(fields: FixedTermBorrowRolloverConfigFields) {
133
+ this.autoRolloverEnabled = fields.autoRolloverEnabled
134
+ this.openTermAllowed = fields.openTermAllowed
135
+ this.alignmentPadding = fields.alignmentPadding
136
+ this.maxBorrowRateBps = fields.maxBorrowRateBps
137
+ this.minDebtTermSeconds = fields.minDebtTermSeconds
138
+ }
139
+
140
+ static layout(property?: string) {
141
+ return borsh.struct(
142
+ [
143
+ borsh.u8("autoRolloverEnabled"),
144
+ borsh.u8("openTermAllowed"),
145
+ borsh.array(borsh.u8(), 2, "alignmentPadding"),
146
+ borsh.u32("maxBorrowRateBps"),
147
+ borsh.u64("minDebtTermSeconds"),
148
+ ],
149
+ property
150
+ )
151
+ }
152
+
153
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
154
+ static fromDecoded(obj: any) {
155
+ return new FixedTermBorrowRolloverConfig({
156
+ autoRolloverEnabled: obj.autoRolloverEnabled,
157
+ openTermAllowed: obj.openTermAllowed,
158
+ alignmentPadding: obj.alignmentPadding,
159
+ maxBorrowRateBps: obj.maxBorrowRateBps,
160
+ minDebtTermSeconds: obj.minDebtTermSeconds,
161
+ })
162
+ }
163
+
164
+ static toEncodable(fields: FixedTermBorrowRolloverConfigFields) {
165
+ return {
166
+ autoRolloverEnabled: fields.autoRolloverEnabled,
167
+ openTermAllowed: fields.openTermAllowed,
168
+ alignmentPadding: fields.alignmentPadding,
169
+ maxBorrowRateBps: fields.maxBorrowRateBps,
170
+ minDebtTermSeconds: fields.minDebtTermSeconds,
171
+ }
172
+ }
173
+
174
+ toJSON(): FixedTermBorrowRolloverConfigJSON {
175
+ return {
176
+ autoRolloverEnabled: this.autoRolloverEnabled,
177
+ openTermAllowed: this.openTermAllowed,
178
+ alignmentPadding: this.alignmentPadding,
179
+ maxBorrowRateBps: this.maxBorrowRateBps,
180
+ minDebtTermSeconds: this.minDebtTermSeconds.toString(),
181
+ }
182
+ }
183
+
184
+ static fromJSON(
185
+ obj: FixedTermBorrowRolloverConfigJSON
186
+ ): FixedTermBorrowRolloverConfig {
187
+ return new FixedTermBorrowRolloverConfig({
188
+ autoRolloverEnabled: obj.autoRolloverEnabled,
189
+ openTermAllowed: obj.openTermAllowed,
190
+ alignmentPadding: obj.alignmentPadding,
191
+ maxBorrowRateBps: obj.maxBorrowRateBps,
192
+ minDebtTermSeconds: new BN(obj.minDebtTermSeconds),
193
+ })
194
+ }
195
+
196
+ toEncodable() {
197
+ return FixedTermBorrowRolloverConfig.toEncodable(this)
198
+ }
199
+ }
@@ -28,6 +28,11 @@ export interface ObligationLiquidityFields {
28
28
  borrowFactorAdjustedMarketValueSf: BN
29
29
  /** Amount of liquidity borrowed outside of an elevation group */
30
30
  borrowedAmountOutsideElevationGroups: BN
31
+ /**
32
+ * The user's auto-rollover opt-ins - only effective when this borrow is fixed-term (i.e. its
33
+ * reserve has a non-zero [ReserveConfig::debt_term_seconds]).
34
+ */
35
+ fixedTermBorrowRolloverConfig: types.FixedTermBorrowRolloverConfigFields
31
36
  padding2: Array<BN>
32
37
  }
33
38
 
@@ -55,6 +60,11 @@ export interface ObligationLiquidityJSON {
55
60
  borrowFactorAdjustedMarketValueSf: string
56
61
  /** Amount of liquidity borrowed outside of an elevation group */
57
62
  borrowedAmountOutsideElevationGroups: string
63
+ /**
64
+ * The user's auto-rollover opt-ins - only effective when this borrow is fixed-term (i.e. its
65
+ * reserve has a non-zero [ReserveConfig::debt_term_seconds]).
66
+ */
67
+ fixedTermBorrowRolloverConfig: types.FixedTermBorrowRolloverConfigJSON
58
68
  padding2: Array<string>
59
69
  }
60
70
 
@@ -83,6 +93,11 @@ export class ObligationLiquidity {
83
93
  readonly borrowFactorAdjustedMarketValueSf: BN
84
94
  /** Amount of liquidity borrowed outside of an elevation group */
85
95
  readonly borrowedAmountOutsideElevationGroups: BN
96
+ /**
97
+ * The user's auto-rollover opt-ins - only effective when this borrow is fixed-term (i.e. its
98
+ * reserve has a non-zero [ReserveConfig::debt_term_seconds]).
99
+ */
100
+ readonly fixedTermBorrowRolloverConfig: types.FixedTermBorrowRolloverConfig
86
101
  readonly padding2: Array<BN>
87
102
 
88
103
  constructor(fields: ObligationLiquidityFields) {
@@ -97,6 +112,10 @@ export class ObligationLiquidity {
97
112
  fields.borrowFactorAdjustedMarketValueSf
98
113
  this.borrowedAmountOutsideElevationGroups =
99
114
  fields.borrowedAmountOutsideElevationGroups
115
+ this.fixedTermBorrowRolloverConfig =
116
+ new types.FixedTermBorrowRolloverConfig({
117
+ ...fields.fixedTermBorrowRolloverConfig,
118
+ })
100
119
  this.padding2 = fields.padding2
101
120
  }
102
121
 
@@ -110,7 +129,10 @@ export class ObligationLiquidity {
110
129
  borsh.u128("marketValueSf"),
111
130
  borsh.u128("borrowFactorAdjustedMarketValueSf"),
112
131
  borsh.u64("borrowedAmountOutsideElevationGroups"),
113
- borsh.array(borsh.u64(), 7, "padding2"),
132
+ types.FixedTermBorrowRolloverConfig.layout(
133
+ "fixedTermBorrowRolloverConfig"
134
+ ),
135
+ borsh.array(borsh.u64(), 5, "padding2"),
114
136
  ],
115
137
  property
116
138
  )
@@ -129,6 +151,10 @@ export class ObligationLiquidity {
129
151
  borrowFactorAdjustedMarketValueSf: obj.borrowFactorAdjustedMarketValueSf,
130
152
  borrowedAmountOutsideElevationGroups:
131
153
  obj.borrowedAmountOutsideElevationGroups,
154
+ fixedTermBorrowRolloverConfig:
155
+ types.FixedTermBorrowRolloverConfig.fromDecoded(
156
+ obj.fixedTermBorrowRolloverConfig
157
+ ),
132
158
  padding2: obj.padding2,
133
159
  })
134
160
  }
@@ -146,6 +172,10 @@ export class ObligationLiquidity {
146
172
  fields.borrowFactorAdjustedMarketValueSf,
147
173
  borrowedAmountOutsideElevationGroups:
148
174
  fields.borrowedAmountOutsideElevationGroups,
175
+ fixedTermBorrowRolloverConfig:
176
+ types.FixedTermBorrowRolloverConfig.toEncodable(
177
+ fields.fixedTermBorrowRolloverConfig
178
+ ),
149
179
  padding2: fields.padding2,
150
180
  }
151
181
  }
@@ -161,6 +191,8 @@ export class ObligationLiquidity {
161
191
  this.borrowFactorAdjustedMarketValueSf.toString(),
162
192
  borrowedAmountOutsideElevationGroups:
163
193
  this.borrowedAmountOutsideElevationGroups.toString(),
194
+ fixedTermBorrowRolloverConfig:
195
+ this.fixedTermBorrowRolloverConfig.toJSON(),
164
196
  padding2: this.padding2.map((item) => item.toString()),
165
197
  }
166
198
  }
@@ -180,6 +212,10 @@ export class ObligationLiquidity {
180
212
  borrowedAmountOutsideElevationGroups: new BN(
181
213
  obj.borrowedAmountOutsideElevationGroups
182
214
  ),
215
+ fixedTermBorrowRolloverConfig:
216
+ types.FixedTermBorrowRolloverConfig.fromJSON(
217
+ obj.fixedTermBorrowRolloverConfig
218
+ ),
183
219
  padding2: obj.padding2.map((item) => new BN(item)),
184
220
  })
185
221
  }
@@ -0,0 +1,91 @@
1
+ import { address, Address } from "@solana/kit" // eslint-disable-line @typescript-eslint/no-unused-vars
2
+ import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
4
+ import * as borsh from "@coral-xyz/borsh"
5
+ import { borshAddress } from "../utils"
6
+
7
+ export interface NoneJSON {
8
+ kind: "None"
9
+ }
10
+
11
+ export class None {
12
+ static readonly discriminator = 0
13
+ static readonly kind = "None"
14
+ readonly discriminator = 0
15
+ readonly kind = "None"
16
+
17
+ toJSON(): NoneJSON {
18
+ return {
19
+ kind: "None",
20
+ }
21
+ }
22
+
23
+ toEncodable() {
24
+ return {
25
+ None: {},
26
+ }
27
+ }
28
+ }
29
+
30
+ export interface KlendQueueAccountingHandlerOnKvaultJSON {
31
+ kind: "KlendQueueAccountingHandlerOnKvault"
32
+ }
33
+
34
+ export class KlendQueueAccountingHandlerOnKvault {
35
+ static readonly discriminator = 1
36
+ static readonly kind = "KlendQueueAccountingHandlerOnKvault"
37
+ readonly discriminator = 1
38
+ readonly kind = "KlendQueueAccountingHandlerOnKvault"
39
+
40
+ toJSON(): KlendQueueAccountingHandlerOnKvaultJSON {
41
+ return {
42
+ kind: "KlendQueueAccountingHandlerOnKvault",
43
+ }
44
+ }
45
+
46
+ toEncodable() {
47
+ return {
48
+ KlendQueueAccountingHandlerOnKvault: {},
49
+ }
50
+ }
51
+ }
52
+
53
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
+ export function fromDecoded(obj: any): types.ProgressCallbackTypeKind {
55
+ if (typeof obj !== "object") {
56
+ throw new Error("Invalid enum object")
57
+ }
58
+
59
+ if ("None" in obj) {
60
+ return new None()
61
+ }
62
+ if ("KlendQueueAccountingHandlerOnKvault" in obj) {
63
+ return new KlendQueueAccountingHandlerOnKvault()
64
+ }
65
+
66
+ throw new Error("Invalid enum object")
67
+ }
68
+
69
+ export function fromJSON(
70
+ obj: types.ProgressCallbackTypeJSON
71
+ ): types.ProgressCallbackTypeKind {
72
+ switch (obj.kind) {
73
+ case "None": {
74
+ return new None()
75
+ }
76
+ case "KlendQueueAccountingHandlerOnKvault": {
77
+ return new KlendQueueAccountingHandlerOnKvault()
78
+ }
79
+ }
80
+ }
81
+
82
+ export function layout(property?: string) {
83
+ const ret = borsh.rustEnum([
84
+ borsh.struct([], "None"),
85
+ borsh.struct([], "KlendQueueAccountingHandlerOnKvault"),
86
+ ])
87
+ if (property !== undefined) {
88
+ return ret.replicate(property)
89
+ }
90
+ return ret
91
+ }
@@ -11,8 +11,14 @@ export interface ReserveLiquidityFields {
11
11
  supplyVault: Address
12
12
  /** Reserve liquidity fee collection address */
13
13
  feeVault: Address
14
- /** Reserve liquidity available */
15
- availableAmount: BN
14
+ /**
15
+ * Total reserve liquidity available.
16
+ *
17
+ * Note: not all of this liquidity can be freely used for any purpose. Production code should
18
+ * use the specialized getters - see e.g. [Reserve::total_available_liquidity_amount()],
19
+ * [Reserve::freely_available_liquidity_amount()].
20
+ */
21
+ totalAvailableAmount: BN
16
22
  /** Reserve liquidity borrowed (scaled fraction) */
17
23
  borrowedAmountSf: BN
18
24
  /** Reserve liquidity market price in quote currency (scaled fraction) */
@@ -54,8 +60,14 @@ export interface ReserveLiquidityJSON {
54
60
  supplyVault: string
55
61
  /** Reserve liquidity fee collection address */
56
62
  feeVault: string
57
- /** Reserve liquidity available */
58
- availableAmount: string
63
+ /**
64
+ * Total reserve liquidity available.
65
+ *
66
+ * Note: not all of this liquidity can be freely used for any purpose. Production code should
67
+ * use the specialized getters - see e.g. [Reserve::total_available_liquidity_amount()],
68
+ * [Reserve::freely_available_liquidity_amount()].
69
+ */
70
+ totalAvailableAmount: string
59
71
  /** Reserve liquidity borrowed (scaled fraction) */
60
72
  borrowedAmountSf: string
61
73
  /** Reserve liquidity market price in quote currency (scaled fraction) */
@@ -98,8 +110,14 @@ export class ReserveLiquidity {
98
110
  readonly supplyVault: Address
99
111
  /** Reserve liquidity fee collection address */
100
112
  readonly feeVault: Address
101
- /** Reserve liquidity available */
102
- readonly availableAmount: BN
113
+ /**
114
+ * Total reserve liquidity available.
115
+ *
116
+ * Note: not all of this liquidity can be freely used for any purpose. Production code should
117
+ * use the specialized getters - see e.g. [Reserve::total_available_liquidity_amount()],
118
+ * [Reserve::freely_available_liquidity_amount()].
119
+ */
120
+ readonly totalAvailableAmount: BN
103
121
  /** Reserve liquidity borrowed (scaled fraction) */
104
122
  readonly borrowedAmountSf: BN
105
123
  /** Reserve liquidity market price in quote currency (scaled fraction) */
@@ -137,7 +155,7 @@ export class ReserveLiquidity {
137
155
  this.mintPubkey = fields.mintPubkey
138
156
  this.supplyVault = fields.supplyVault
139
157
  this.feeVault = fields.feeVault
140
- this.availableAmount = fields.availableAmount
158
+ this.totalAvailableAmount = fields.totalAvailableAmount
141
159
  this.borrowedAmountSf = fields.borrowedAmountSf
142
160
  this.marketPriceSf = fields.marketPriceSf
143
161
  this.marketPriceLastUpdatedTs = fields.marketPriceLastUpdatedTs
@@ -162,7 +180,7 @@ export class ReserveLiquidity {
162
180
  borshAddress("mintPubkey"),
163
181
  borshAddress("supplyVault"),
164
182
  borshAddress("feeVault"),
165
- borsh.u64("availableAmount"),
183
+ borsh.u64("totalAvailableAmount"),
166
184
  borsh.u128("borrowedAmountSf"),
167
185
  borsh.u128("marketPriceSf"),
168
186
  borsh.u64("marketPriceLastUpdatedTs"),
@@ -188,7 +206,7 @@ export class ReserveLiquidity {
188
206
  mintPubkey: obj.mintPubkey,
189
207
  supplyVault: obj.supplyVault,
190
208
  feeVault: obj.feeVault,
191
- availableAmount: obj.availableAmount,
209
+ totalAvailableAmount: obj.totalAvailableAmount,
192
210
  borrowedAmountSf: obj.borrowedAmountSf,
193
211
  marketPriceSf: obj.marketPriceSf,
194
212
  marketPriceLastUpdatedTs: obj.marketPriceLastUpdatedTs,
@@ -213,7 +231,7 @@ export class ReserveLiquidity {
213
231
  mintPubkey: fields.mintPubkey,
214
232
  supplyVault: fields.supplyVault,
215
233
  feeVault: fields.feeVault,
216
- availableAmount: fields.availableAmount,
234
+ totalAvailableAmount: fields.totalAvailableAmount,
217
235
  borrowedAmountSf: fields.borrowedAmountSf,
218
236
  marketPriceSf: fields.marketPriceSf,
219
237
  marketPriceLastUpdatedTs: fields.marketPriceLastUpdatedTs,
@@ -238,7 +256,7 @@ export class ReserveLiquidity {
238
256
  mintPubkey: this.mintPubkey,
239
257
  supplyVault: this.supplyVault,
240
258
  feeVault: this.feeVault,
241
- availableAmount: this.availableAmount.toString(),
259
+ totalAvailableAmount: this.totalAvailableAmount.toString(),
242
260
  borrowedAmountSf: this.borrowedAmountSf.toString(),
243
261
  marketPriceSf: this.marketPriceSf.toString(),
244
262
  marketPriceLastUpdatedTs: this.marketPriceLastUpdatedTs.toString(),
@@ -262,7 +280,7 @@ export class ReserveLiquidity {
262
280
  mintPubkey: address(obj.mintPubkey),
263
281
  supplyVault: address(obj.supplyVault),
264
282
  feeVault: address(obj.feeVault),
265
- availableAmount: new BN(obj.availableAmount),
283
+ totalAvailableAmount: new BN(obj.totalAvailableAmount),
266
284
  borrowedAmountSf: new BN(obj.borrowedAmountSf),
267
285
  marketPriceSf: new BN(obj.marketPriceSf),
268
286
  marketPriceLastUpdatedTs: new BN(obj.marketPriceLastUpdatedTs),
@@ -556,25 +556,25 @@ export class UpdateBorrowRateCurve {
556
556
  }
557
557
  }
558
558
 
559
- export interface UpdateEntireReserveConfigJSON {
560
- kind: "UpdateEntireReserveConfig"
559
+ export interface DeprecatedUpdateEntireReserveConfigJSON {
560
+ kind: "DeprecatedUpdateEntireReserveConfig"
561
561
  }
562
562
 
563
- export class UpdateEntireReserveConfig {
563
+ export class DeprecatedUpdateEntireReserveConfig {
564
564
  static readonly discriminator = 24
565
- static readonly kind = "UpdateEntireReserveConfig"
565
+ static readonly kind = "DeprecatedUpdateEntireReserveConfig"
566
566
  readonly discriminator = 24
567
- readonly kind = "UpdateEntireReserveConfig"
567
+ readonly kind = "DeprecatedUpdateEntireReserveConfig"
568
568
 
569
- toJSON(): UpdateEntireReserveConfigJSON {
569
+ toJSON(): DeprecatedUpdateEntireReserveConfigJSON {
570
570
  return {
571
- kind: "UpdateEntireReserveConfig",
571
+ kind: "DeprecatedUpdateEntireReserveConfig",
572
572
  }
573
573
  }
574
574
 
575
575
  toEncodable() {
576
576
  return {
577
- UpdateEntireReserveConfig: {},
577
+ DeprecatedUpdateEntireReserveConfig: {},
578
578
  }
579
579
  }
580
580
  }
@@ -1347,8 +1347,8 @@ export function fromDecoded(obj: any): types.UpdateConfigModeKind {
1347
1347
  if ("UpdateBorrowRateCurve" in obj) {
1348
1348
  return new UpdateBorrowRateCurve()
1349
1349
  }
1350
- if ("UpdateEntireReserveConfig" in obj) {
1351
- return new UpdateEntireReserveConfig()
1350
+ if ("DeprecatedUpdateEntireReserveConfig" in obj) {
1351
+ return new DeprecatedUpdateEntireReserveConfig()
1352
1352
  }
1353
1353
  if ("UpdateDebtWithdrawalCap" in obj) {
1354
1354
  return new UpdateDebtWithdrawalCap()
@@ -1520,8 +1520,8 @@ export function fromJSON(
1520
1520
  case "UpdateBorrowRateCurve": {
1521
1521
  return new UpdateBorrowRateCurve()
1522
1522
  }
1523
- case "UpdateEntireReserveConfig": {
1524
- return new UpdateEntireReserveConfig()
1523
+ case "DeprecatedUpdateEntireReserveConfig": {
1524
+ return new DeprecatedUpdateEntireReserveConfig()
1525
1525
  }
1526
1526
  case "UpdateDebtWithdrawalCap": {
1527
1527
  return new UpdateDebtWithdrawalCap()
@@ -1642,7 +1642,7 @@ export function layout(property?: string) {
1642
1642
  borsh.struct([], "UpdateSwitchboardFeed"),
1643
1643
  borsh.struct([], "UpdateSwitchboardTwapFeed"),
1644
1644
  borsh.struct([], "UpdateBorrowRateCurve"),
1645
- borsh.struct([], "UpdateEntireReserveConfig"),
1645
+ borsh.struct([], "DeprecatedUpdateEntireReserveConfig"),
1646
1646
  borsh.struct([], "UpdateDebtWithdrawalCap"),
1647
1647
  borsh.struct([], "UpdateDepositWithdrawalCap"),
1648
1648
  borsh.struct([], "DeprecatedUpdateDebtWithdrawalCapCurrentTotal"),