@kamino-finance/klend-sdk 7.2.6 → 7.3.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 (223) hide show
  1. package/README.md +1 -0
  2. package/dist/@codegen/klend/accounts/LendingMarket.d.ts +33 -0
  3. package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
  4. package/dist/@codegen/klend/accounts/LendingMarket.js +24 -2
  5. package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
  6. package/dist/@codegen/klend/errors/custom.d.ts +26 -2
  7. package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
  8. package/dist/@codegen/klend/errors/custom.js +45 -3
  9. package/dist/@codegen/klend/errors/custom.js.map +1 -1
  10. package/dist/@codegen/klend/instructions/index.d.ts +2 -0
  11. package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
  12. package/dist/@codegen/klend/instructions/index.js +3 -1
  13. package/dist/@codegen/klend/instructions/index.js.map +1 -1
  14. package/dist/@codegen/klend/instructions/initReserve.d.ts +1 -1
  15. package/dist/@codegen/klend/instructions/initReserve.d.ts.map +1 -1
  16. package/dist/@codegen/klend/instructions/initReserve.js +1 -5
  17. package/dist/@codegen/klend/instructions/initReserve.js.map +1 -1
  18. package/dist/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateralV2.js +1 -1
  19. package/dist/@codegen/klend/instructions/seedDepositOnInitReserve.d.ts +13 -0
  20. package/dist/@codegen/klend/instructions/seedDepositOnInitReserve.d.ts.map +1 -0
  21. package/dist/@codegen/klend/instructions/seedDepositOnInitReserve.js +24 -0
  22. package/dist/@codegen/klend/instructions/seedDepositOnInitReserve.js.map +1 -0
  23. package/dist/@codegen/klend/instructions/withdrawObligationCollateral.js +1 -1
  24. package/dist/@codegen/klend/instructions/withdrawObligationCollateralV2.js +1 -1
  25. package/dist/@codegen/klend/types/ReserveConfig.d.ts +58 -24
  26. package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
  27. package/dist/@codegen/klend/types/ReserveConfig.js +40 -18
  28. package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
  29. package/dist/@codegen/klend/types/ReserveFees.d.ts +8 -8
  30. package/dist/@codegen/klend/types/ReserveFees.d.ts.map +1 -1
  31. package/dist/@codegen/klend/types/ReserveFees.js +8 -8
  32. package/dist/@codegen/klend/types/ReserveFees.js.map +1 -1
  33. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +46 -7
  34. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
  35. package/dist/@codegen/klend/types/UpdateConfigMode.js +85 -12
  36. package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
  37. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +26 -0
  38. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
  39. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +49 -1
  40. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
  41. package/dist/@codegen/klend/types/index.d.ts +4 -4
  42. package/dist/@codegen/klend/types/index.d.ts.map +1 -1
  43. package/dist/@codegen/klend/types/index.js.map +1 -1
  44. package/dist/@codegen/kvault/accounts/GlobalConfig.d.ts +32 -0
  45. package/dist/@codegen/kvault/accounts/GlobalConfig.d.ts.map +1 -0
  46. package/dist/@codegen/kvault/accounts/GlobalConfig.js +125 -0
  47. package/dist/@codegen/kvault/accounts/GlobalConfig.js.map +1 -0
  48. package/dist/@codegen/kvault/accounts/Reserve.js +1 -1
  49. package/dist/@codegen/kvault/accounts/ReserveWhitelistEntry.d.ts +52 -0
  50. package/dist/@codegen/kvault/accounts/ReserveWhitelistEntry.d.ts.map +1 -0
  51. package/dist/@codegen/kvault/accounts/ReserveWhitelistEntry.js +127 -0
  52. package/dist/@codegen/kvault/accounts/ReserveWhitelistEntry.js.map +1 -0
  53. package/dist/@codegen/kvault/accounts/VaultState.d.ts +18 -0
  54. package/dist/@codegen/kvault/accounts/VaultState.d.ts.map +1 -1
  55. package/dist/@codegen/kvault/accounts/VaultState.js +39 -1
  56. package/dist/@codegen/kvault/accounts/VaultState.js.map +1 -1
  57. package/dist/@codegen/kvault/accounts/index.d.ts +4 -0
  58. package/dist/@codegen/kvault/accounts/index.d.ts.map +1 -1
  59. package/dist/@codegen/kvault/accounts/index.js +5 -1
  60. package/dist/@codegen/kvault/accounts/index.js.map +1 -1
  61. package/dist/@codegen/kvault/errors/custom.d.ts +61 -5
  62. package/dist/@codegen/kvault/errors/custom.d.ts.map +1 -1
  63. package/dist/@codegen/kvault/errors/custom.js +108 -9
  64. package/dist/@codegen/kvault/errors/custom.js.map +1 -1
  65. package/dist/@codegen/kvault/instructions/addUpdateWhitelistedReserve.d.ts +16 -0
  66. package/dist/@codegen/kvault/instructions/addUpdateWhitelistedReserve.d.ts.map +1 -0
  67. package/dist/@codegen/kvault/instructions/addUpdateWhitelistedReserve.js +66 -0
  68. package/dist/@codegen/kvault/instructions/addUpdateWhitelistedReserve.js.map +1 -0
  69. package/dist/@codegen/kvault/instructions/buy.d.ts +24 -0
  70. package/dist/@codegen/kvault/instructions/buy.d.ts.map +1 -0
  71. package/dist/@codegen/kvault/instructions/buy.js +67 -0
  72. package/dist/@codegen/kvault/instructions/buy.js.map +1 -0
  73. package/dist/@codegen/kvault/instructions/index.d.ts +12 -0
  74. package/dist/@codegen/kvault/instructions/index.d.ts.map +1 -1
  75. package/dist/@codegen/kvault/instructions/index.js +13 -1
  76. package/dist/@codegen/kvault/instructions/index.js.map +1 -1
  77. package/dist/@codegen/kvault/instructions/initGlobalConfig.d.ts +11 -0
  78. package/dist/@codegen/kvault/instructions/initGlobalConfig.d.ts.map +1 -0
  79. package/dist/@codegen/kvault/instructions/initGlobalConfig.js +20 -0
  80. package/dist/@codegen/kvault/instructions/initGlobalConfig.js.map +1 -0
  81. package/dist/@codegen/kvault/instructions/invest.d.ts +2 -1
  82. package/dist/@codegen/kvault/instructions/invest.d.ts.map +1 -1
  83. package/dist/@codegen/kvault/instructions/invest.js +5 -0
  84. package/dist/@codegen/kvault/instructions/invest.js.map +1 -1
  85. package/dist/@codegen/kvault/instructions/sell.d.ts +40 -0
  86. package/dist/@codegen/kvault/instructions/sell.d.ts.map +1 -0
  87. package/dist/@codegen/kvault/instructions/sell.js +98 -0
  88. package/dist/@codegen/kvault/instructions/sell.js.map +1 -0
  89. package/dist/@codegen/kvault/instructions/updateGlobalConfig.d.ts +13 -0
  90. package/dist/@codegen/kvault/instructions/updateGlobalConfig.d.ts.map +1 -0
  91. package/dist/@codegen/kvault/instructions/updateGlobalConfig.js +63 -0
  92. package/dist/@codegen/kvault/instructions/updateGlobalConfig.js.map +1 -0
  93. package/dist/@codegen/kvault/instructions/updateGlobalConfigAdmin.d.ts +8 -0
  94. package/dist/@codegen/kvault/instructions/updateGlobalConfigAdmin.d.ts.map +1 -0
  95. package/dist/@codegen/kvault/instructions/updateGlobalConfigAdmin.js +21 -0
  96. package/dist/@codegen/kvault/instructions/updateGlobalConfigAdmin.js.map +1 -0
  97. package/dist/@codegen/kvault/instructions/updateReserveAllocation.d.ts +2 -1
  98. package/dist/@codegen/kvault/instructions/updateReserveAllocation.d.ts.map +1 -1
  99. package/dist/@codegen/kvault/instructions/updateReserveAllocation.js +5 -0
  100. package/dist/@codegen/kvault/instructions/updateReserveAllocation.js.map +1 -1
  101. package/dist/@codegen/kvault/instructions/updateVaultConfig.d.ts +2 -1
  102. package/dist/@codegen/kvault/instructions/updateVaultConfig.d.ts.map +1 -1
  103. package/dist/@codegen/kvault/instructions/updateVaultConfig.js +2 -5
  104. package/dist/@codegen/kvault/instructions/updateVaultConfig.js.map +1 -1
  105. package/dist/@codegen/kvault/instructions/withdraw.d.ts +1 -0
  106. package/dist/@codegen/kvault/instructions/withdraw.d.ts.map +1 -1
  107. package/dist/@codegen/kvault/instructions/withdraw.js +1 -0
  108. package/dist/@codegen/kvault/instructions/withdraw.js.map +1 -1
  109. package/dist/@codegen/kvault/instructions/withdrawFromAvailable.d.ts +1 -0
  110. package/dist/@codegen/kvault/instructions/withdrawFromAvailable.d.ts.map +1 -1
  111. package/dist/@codegen/kvault/instructions/withdrawFromAvailable.js +1 -0
  112. package/dist/@codegen/kvault/instructions/withdrawFromAvailable.js.map +1 -1
  113. package/dist/@codegen/kvault/types/ReserveConfig.d.ts +27 -34
  114. package/dist/@codegen/kvault/types/ReserveConfig.d.ts.map +1 -1
  115. package/dist/@codegen/kvault/types/ReserveConfig.js +20 -17
  116. package/dist/@codegen/kvault/types/ReserveConfig.js.map +1 -1
  117. package/dist/@codegen/kvault/types/ReserveFees.d.ts +8 -8
  118. package/dist/@codegen/kvault/types/ReserveFees.d.ts.map +1 -1
  119. package/dist/@codegen/kvault/types/ReserveFees.js +8 -8
  120. package/dist/@codegen/kvault/types/ReserveFees.js.map +1 -1
  121. package/dist/@codegen/kvault/types/UpdateGlobalConfigMode.d.ts +68 -0
  122. package/dist/@codegen/kvault/types/UpdateGlobalConfigMode.d.ts.map +1 -0
  123. package/dist/@codegen/kvault/types/UpdateGlobalConfigMode.js +162 -0
  124. package/dist/@codegen/kvault/types/UpdateGlobalConfigMode.js.map +1 -0
  125. package/dist/@codegen/kvault/types/UpdateReserveWhitelistMode.d.ts +46 -0
  126. package/dist/@codegen/kvault/types/UpdateReserveWhitelistMode.d.ts.map +1 -0
  127. package/dist/@codegen/kvault/types/UpdateReserveWhitelistMode.js +124 -0
  128. package/dist/@codegen/kvault/types/UpdateReserveWhitelistMode.js.map +1 -0
  129. package/dist/@codegen/kvault/types/VaultConfigField.d.ts +65 -0
  130. package/dist/@codegen/kvault/types/VaultConfigField.d.ts.map +1 -1
  131. package/dist/@codegen/kvault/types/VaultConfigField.js +121 -1
  132. package/dist/@codegen/kvault/types/VaultConfigField.js.map +1 -1
  133. package/dist/@codegen/kvault/types/index.d.ts +10 -2
  134. package/dist/@codegen/kvault/types/index.d.ts.map +1 -1
  135. package/dist/@codegen/kvault/types/index.js +5 -1
  136. package/dist/@codegen/kvault/types/index.js.map +1 -1
  137. package/dist/classes/manager.d.ts +19 -1
  138. package/dist/classes/manager.d.ts.map +1 -1
  139. package/dist/classes/manager.js +28 -0
  140. package/dist/classes/manager.js.map +1 -1
  141. package/dist/classes/reserve.d.ts.map +1 -1
  142. package/dist/classes/reserve.js +7 -4
  143. package/dist/classes/reserve.js.map +1 -1
  144. package/dist/classes/vault.d.ts +33 -5
  145. package/dist/classes/vault.d.ts.map +1 -1
  146. package/dist/classes/vault.js +379 -48
  147. package/dist/classes/vault.js.map +1 -1
  148. package/dist/idl/klend.json +129 -59
  149. package/dist/lib.d.ts +1 -0
  150. package/dist/lib.d.ts.map +1 -1
  151. package/dist/lib.js +4 -2
  152. package/dist/lib.js.map +1 -1
  153. package/dist/manager/client_kamino_manager.js +206 -15
  154. package/dist/manager/client_kamino_manager.js.map +1 -1
  155. package/dist/utils/index.d.ts +1 -0
  156. package/dist/utils/index.d.ts.map +1 -1
  157. package/dist/utils/index.js +1 -0
  158. package/dist/utils/index.js.map +1 -1
  159. package/dist/utils/managerTypes.d.ts +1 -1
  160. package/dist/utils/managerTypes.d.ts.map +1 -1
  161. package/dist/utils/managerTypes.js +5 -3
  162. package/dist/utils/managerTypes.js.map +1 -1
  163. package/dist/utils/parse.d.ts +10 -0
  164. package/dist/utils/parse.d.ts.map +1 -0
  165. package/dist/utils/parse.js +24 -0
  166. package/dist/utils/parse.js.map +1 -0
  167. package/dist/utils/seeds.d.ts +5 -5
  168. package/dist/utils/seeds.d.ts.map +1 -1
  169. package/dist/utils/seeds.js +13 -13
  170. package/dist/utils/seeds.js.map +1 -1
  171. package/dist/utils/vault.d.ts.map +1 -1
  172. package/dist/utils/vault.js +6 -0
  173. package/dist/utils/vault.js.map +1 -1
  174. package/package.json +1 -1
  175. package/src/@codegen/klend/accounts/LendingMarket.ts +46 -2
  176. package/src/@codegen/klend/errors/custom.ts +47 -2
  177. package/src/@codegen/klend/instructions/index.ts +2 -0
  178. package/src/@codegen/klend/instructions/initReserve.ts +2 -6
  179. package/src/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts +1 -1
  180. package/src/@codegen/klend/instructions/seedDepositOnInitReserve.ts +50 -0
  181. package/src/@codegen/klend/instructions/withdrawObligationCollateral.ts +1 -1
  182. package/src/@codegen/klend/instructions/withdrawObligationCollateralV2.ts +1 -1
  183. package/src/@codegen/klend/types/ReserveConfig.ts +72 -30
  184. package/src/@codegen/klend/types/ReserveFees.ts +12 -12
  185. package/src/@codegen/klend/types/UpdateConfigMode.ts +103 -13
  186. package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +60 -0
  187. package/src/@codegen/klend/types/index.ts +12 -2
  188. package/src/@codegen/kvault/accounts/GlobalConfig.ts +136 -0
  189. package/src/@codegen/kvault/accounts/Reserve.ts +1 -1
  190. package/src/@codegen/kvault/accounts/ReserveWhitelistEntry.ts +157 -0
  191. package/src/@codegen/kvault/accounts/VaultState.ts +57 -1
  192. package/src/@codegen/kvault/accounts/index.ts +7 -0
  193. package/src/@codegen/kvault/errors/custom.ts +109 -8
  194. package/src/@codegen/kvault/instructions/addUpdateWhitelistedReserve.ts +64 -0
  195. package/src/@codegen/kvault/instructions/buy.ts +74 -0
  196. package/src/@codegen/kvault/instructions/index.ts +18 -0
  197. package/src/@codegen/kvault/instructions/initGlobalConfig.ts +44 -0
  198. package/src/@codegen/kvault/instructions/invest.ts +4 -0
  199. package/src/@codegen/kvault/instructions/sell.ts +122 -0
  200. package/src/@codegen/kvault/instructions/updateGlobalConfig.ts +58 -0
  201. package/src/@codegen/kvault/instructions/updateGlobalConfigAdmin.ts +42 -0
  202. package/src/@codegen/kvault/instructions/updateReserveAllocation.ts +4 -0
  203. package/src/@codegen/kvault/instructions/updateVaultConfig.ts +4 -6
  204. package/src/@codegen/kvault/instructions/withdraw.ts +2 -0
  205. package/src/@codegen/kvault/instructions/withdrawFromAvailable.ts +2 -0
  206. package/src/@codegen/kvault/types/ReserveConfig.ts +34 -37
  207. package/src/@codegen/kvault/types/ReserveFees.ts +12 -12
  208. package/src/@codegen/kvault/types/UpdateGlobalConfigMode.ts +160 -0
  209. package/src/@codegen/kvault/types/UpdateReserveWhitelistMode.ts +117 -0
  210. package/src/@codegen/kvault/types/VaultConfigField.ts +150 -0
  211. package/src/@codegen/kvault/types/index.ts +31 -0
  212. package/src/classes/manager.ts +50 -1
  213. package/src/classes/reserve.ts +7 -5
  214. package/src/classes/vault.ts +555 -48
  215. package/src/idl/klend.json +130 -60
  216. package/src/idl/kvault.json +582 -23
  217. package/src/lib.ts +2 -1
  218. package/src/manager/client_kamino_manager.ts +313 -18
  219. package/src/utils/index.ts +2 -1
  220. package/src/utils/managerTypes.ts +6 -4
  221. package/src/utils/parse.ts +18 -0
  222. package/src/utils/seeds.ts +13 -17
  223. package/src/utils/vault.ts +6 -0
@@ -11,9 +11,9 @@ export interface ReserveFeesFields {
11
11
  * clarity:
12
12
  * 1% = (1 << 60) / 100 = 11529215046068470
13
13
  * 0.01% (1 basis point) = 115292150460685
14
- * 0.00001% (Aave borrow fee) = 115292150461
14
+ * 0.00001% (Aave origination fee) = 115292150461
15
15
  */
16
- borrowFeeSf: BN
16
+ originationFeeSf: BN
17
17
  /**
18
18
  * Fee for flash loan, expressed as scaled fraction.
19
19
  * 0.3% (Aave flash loan fee) = 0.003 * 2^60 = 3458764513820541
@@ -30,9 +30,9 @@ export interface ReserveFeesJSON {
30
30
  * clarity:
31
31
  * 1% = (1 << 60) / 100 = 11529215046068470
32
32
  * 0.01% (1 basis point) = 115292150460685
33
- * 0.00001% (Aave borrow fee) = 115292150461
33
+ * 0.00001% (Aave origination fee) = 115292150461
34
34
  */
35
- borrowFeeSf: string
35
+ originationFeeSf: string
36
36
  /**
37
37
  * Fee for flash loan, expressed as scaled fraction.
38
38
  * 0.3% (Aave flash loan fee) = 0.003 * 2^60 = 3458764513820541
@@ -56,9 +56,9 @@ export class ReserveFees {
56
56
  * clarity:
57
57
  * 1% = (1 << 60) / 100 = 11529215046068470
58
58
  * 0.01% (1 basis point) = 115292150460685
59
- * 0.00001% (Aave borrow fee) = 115292150461
59
+ * 0.00001% (Aave origination fee) = 115292150461
60
60
  */
61
- readonly borrowFeeSf: BN
61
+ readonly originationFeeSf: BN
62
62
  /**
63
63
  * Fee for flash loan, expressed as scaled fraction.
64
64
  * 0.3% (Aave flash loan fee) = 0.003 * 2^60 = 3458764513820541
@@ -68,7 +68,7 @@ export class ReserveFees {
68
68
  readonly padding: Array<number>
69
69
 
70
70
  constructor(fields: ReserveFeesFields) {
71
- this.borrowFeeSf = fields.borrowFeeSf
71
+ this.originationFeeSf = fields.originationFeeSf
72
72
  this.flashLoanFeeSf = fields.flashLoanFeeSf
73
73
  this.padding = fields.padding
74
74
  }
@@ -76,7 +76,7 @@ export class ReserveFees {
76
76
  static layout(property?: string) {
77
77
  return borsh.struct(
78
78
  [
79
- borsh.u64("borrowFeeSf"),
79
+ borsh.u64("originationFeeSf"),
80
80
  borsh.u64("flashLoanFeeSf"),
81
81
  borsh.array(borsh.u8(), 8, "padding"),
82
82
  ],
@@ -87,7 +87,7 @@ export class ReserveFees {
87
87
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
88
  static fromDecoded(obj: any) {
89
89
  return new ReserveFees({
90
- borrowFeeSf: obj.borrowFeeSf,
90
+ originationFeeSf: obj.originationFeeSf,
91
91
  flashLoanFeeSf: obj.flashLoanFeeSf,
92
92
  padding: obj.padding,
93
93
  })
@@ -95,7 +95,7 @@ export class ReserveFees {
95
95
 
96
96
  static toEncodable(fields: ReserveFeesFields) {
97
97
  return {
98
- borrowFeeSf: fields.borrowFeeSf,
98
+ originationFeeSf: fields.originationFeeSf,
99
99
  flashLoanFeeSf: fields.flashLoanFeeSf,
100
100
  padding: fields.padding,
101
101
  }
@@ -103,7 +103,7 @@ export class ReserveFees {
103
103
 
104
104
  toJSON(): ReserveFeesJSON {
105
105
  return {
106
- borrowFeeSf: this.borrowFeeSf.toString(),
106
+ originationFeeSf: this.originationFeeSf.toString(),
107
107
  flashLoanFeeSf: this.flashLoanFeeSf.toString(),
108
108
  padding: this.padding,
109
109
  }
@@ -111,7 +111,7 @@ export class ReserveFees {
111
111
 
112
112
  static fromJSON(obj: ReserveFeesJSON): ReserveFees {
113
113
  return new ReserveFees({
114
- borrowFeeSf: new BN(obj.borrowFeeSf),
114
+ originationFeeSf: new BN(obj.originationFeeSf),
115
115
  flashLoanFeeSf: new BN(obj.flashLoanFeeSf),
116
116
  padding: obj.padding,
117
117
  })
@@ -0,0 +1,160 @@
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 type PendingAdminFields = [Address]
8
+ export type PendingAdminValue = [Address]
9
+
10
+ export interface PendingAdminJSON {
11
+ kind: "PendingAdmin"
12
+ value: [string]
13
+ }
14
+
15
+ export class PendingAdmin {
16
+ static readonly discriminator = 0
17
+ static readonly kind = "PendingAdmin"
18
+ readonly discriminator = 0
19
+ readonly kind = "PendingAdmin"
20
+ readonly value: PendingAdminValue
21
+
22
+ constructor(value: PendingAdminFields) {
23
+ this.value = [value[0]]
24
+ }
25
+
26
+ toJSON(): PendingAdminJSON {
27
+ return {
28
+ kind: "PendingAdmin",
29
+ value: [this.value[0]],
30
+ }
31
+ }
32
+
33
+ toEncodable() {
34
+ return {
35
+ PendingAdmin: {
36
+ _0: this.value[0],
37
+ },
38
+ }
39
+ }
40
+ }
41
+
42
+ export type MinWithdrawalPenaltyLamportsFields = [BN]
43
+ export type MinWithdrawalPenaltyLamportsValue = [BN]
44
+
45
+ export interface MinWithdrawalPenaltyLamportsJSON {
46
+ kind: "MinWithdrawalPenaltyLamports"
47
+ value: [string]
48
+ }
49
+
50
+ export class MinWithdrawalPenaltyLamports {
51
+ static readonly discriminator = 1
52
+ static readonly kind = "MinWithdrawalPenaltyLamports"
53
+ readonly discriminator = 1
54
+ readonly kind = "MinWithdrawalPenaltyLamports"
55
+ readonly value: MinWithdrawalPenaltyLamportsValue
56
+
57
+ constructor(value: MinWithdrawalPenaltyLamportsFields) {
58
+ this.value = [value[0]]
59
+ }
60
+
61
+ toJSON(): MinWithdrawalPenaltyLamportsJSON {
62
+ return {
63
+ kind: "MinWithdrawalPenaltyLamports",
64
+ value: [this.value[0].toString()],
65
+ }
66
+ }
67
+
68
+ toEncodable() {
69
+ return {
70
+ MinWithdrawalPenaltyLamports: {
71
+ _0: this.value[0],
72
+ },
73
+ }
74
+ }
75
+ }
76
+
77
+ export type MinWithdrawalPenaltyBPSFields = [BN]
78
+ export type MinWithdrawalPenaltyBPSValue = [BN]
79
+
80
+ export interface MinWithdrawalPenaltyBPSJSON {
81
+ kind: "MinWithdrawalPenaltyBPS"
82
+ value: [string]
83
+ }
84
+
85
+ export class MinWithdrawalPenaltyBPS {
86
+ static readonly discriminator = 2
87
+ static readonly kind = "MinWithdrawalPenaltyBPS"
88
+ readonly discriminator = 2
89
+ readonly kind = "MinWithdrawalPenaltyBPS"
90
+ readonly value: MinWithdrawalPenaltyBPSValue
91
+
92
+ constructor(value: MinWithdrawalPenaltyBPSFields) {
93
+ this.value = [value[0]]
94
+ }
95
+
96
+ toJSON(): MinWithdrawalPenaltyBPSJSON {
97
+ return {
98
+ kind: "MinWithdrawalPenaltyBPS",
99
+ value: [this.value[0].toString()],
100
+ }
101
+ }
102
+
103
+ toEncodable() {
104
+ return {
105
+ MinWithdrawalPenaltyBPS: {
106
+ _0: this.value[0],
107
+ },
108
+ }
109
+ }
110
+ }
111
+
112
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
+ export function fromDecoded(obj: any): types.UpdateGlobalConfigModeKind {
114
+ if (typeof obj !== "object") {
115
+ throw new Error("Invalid enum object")
116
+ }
117
+
118
+ if ("PendingAdmin" in obj) {
119
+ const val = obj["PendingAdmin"]
120
+ return new PendingAdmin([val["_0"]])
121
+ }
122
+ if ("MinWithdrawalPenaltyLamports" in obj) {
123
+ const val = obj["MinWithdrawalPenaltyLamports"]
124
+ return new MinWithdrawalPenaltyLamports([val["_0"]])
125
+ }
126
+ if ("MinWithdrawalPenaltyBPS" in obj) {
127
+ const val = obj["MinWithdrawalPenaltyBPS"]
128
+ return new MinWithdrawalPenaltyBPS([val["_0"]])
129
+ }
130
+
131
+ throw new Error("Invalid enum object")
132
+ }
133
+
134
+ export function fromJSON(
135
+ obj: types.UpdateGlobalConfigModeJSON
136
+ ): types.UpdateGlobalConfigModeKind {
137
+ switch (obj.kind) {
138
+ case "PendingAdmin": {
139
+ return new PendingAdmin([address(obj.value[0])])
140
+ }
141
+ case "MinWithdrawalPenaltyLamports": {
142
+ return new MinWithdrawalPenaltyLamports([new BN(obj.value[0])])
143
+ }
144
+ case "MinWithdrawalPenaltyBPS": {
145
+ return new MinWithdrawalPenaltyBPS([new BN(obj.value[0])])
146
+ }
147
+ }
148
+ }
149
+
150
+ export function layout(property?: string) {
151
+ const ret = borsh.rustEnum([
152
+ borsh.struct([borshAddress("_0")], "PendingAdmin"),
153
+ borsh.struct([borsh.u64("_0")], "MinWithdrawalPenaltyLamports"),
154
+ borsh.struct([borsh.u64("_0")], "MinWithdrawalPenaltyBPS"),
155
+ ])
156
+ if (property !== undefined) {
157
+ return ret.replicate(property)
158
+ }
159
+ return ret
160
+ }
@@ -0,0 +1,117 @@
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 type InvestFields = [number]
8
+ export type InvestValue = [number]
9
+
10
+ export interface InvestJSON {
11
+ kind: "Invest"
12
+ value: [number]
13
+ }
14
+
15
+ export class Invest {
16
+ static readonly discriminator = 0
17
+ static readonly kind = "Invest"
18
+ readonly discriminator = 0
19
+ readonly kind = "Invest"
20
+ readonly value: InvestValue
21
+
22
+ constructor(value: InvestFields) {
23
+ this.value = [value[0]]
24
+ }
25
+
26
+ toJSON(): InvestJSON {
27
+ return {
28
+ kind: "Invest",
29
+ value: [this.value[0]],
30
+ }
31
+ }
32
+
33
+ toEncodable() {
34
+ return {
35
+ Invest: {
36
+ _0: this.value[0],
37
+ },
38
+ }
39
+ }
40
+ }
41
+
42
+ export type AddAllocationFields = [number]
43
+ export type AddAllocationValue = [number]
44
+
45
+ export interface AddAllocationJSON {
46
+ kind: "AddAllocation"
47
+ value: [number]
48
+ }
49
+
50
+ export class AddAllocation {
51
+ static readonly discriminator = 1
52
+ static readonly kind = "AddAllocation"
53
+ readonly discriminator = 1
54
+ readonly kind = "AddAllocation"
55
+ readonly value: AddAllocationValue
56
+
57
+ constructor(value: AddAllocationFields) {
58
+ this.value = [value[0]]
59
+ }
60
+
61
+ toJSON(): AddAllocationJSON {
62
+ return {
63
+ kind: "AddAllocation",
64
+ value: [this.value[0]],
65
+ }
66
+ }
67
+
68
+ toEncodable() {
69
+ return {
70
+ AddAllocation: {
71
+ _0: this.value[0],
72
+ },
73
+ }
74
+ }
75
+ }
76
+
77
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
+ export function fromDecoded(obj: any): types.UpdateReserveWhitelistModeKind {
79
+ if (typeof obj !== "object") {
80
+ throw new Error("Invalid enum object")
81
+ }
82
+
83
+ if ("Invest" in obj) {
84
+ const val = obj["Invest"]
85
+ return new Invest([val["_0"]])
86
+ }
87
+ if ("AddAllocation" in obj) {
88
+ const val = obj["AddAllocation"]
89
+ return new AddAllocation([val["_0"]])
90
+ }
91
+
92
+ throw new Error("Invalid enum object")
93
+ }
94
+
95
+ export function fromJSON(
96
+ obj: types.UpdateReserveWhitelistModeJSON
97
+ ): types.UpdateReserveWhitelistModeKind {
98
+ switch (obj.kind) {
99
+ case "Invest": {
100
+ return new Invest([obj.value[0]])
101
+ }
102
+ case "AddAllocation": {
103
+ return new AddAllocation([obj.value[0]])
104
+ }
105
+ }
106
+ }
107
+
108
+ export function layout(property?: string) {
109
+ const ret = borsh.rustEnum([
110
+ borsh.struct([borsh.u8("_0")], "Invest"),
111
+ borsh.struct([borsh.u8("_0")], "AddAllocation"),
112
+ ])
113
+ if (property !== undefined) {
114
+ return ret.replicate(property)
115
+ }
116
+ return ret
117
+ }
@@ -326,6 +326,121 @@ export class UnallocatedTokensCap {
326
326
  }
327
327
  }
328
328
 
329
+ export interface WithdrawalPenaltyLamportsJSON {
330
+ kind: "WithdrawalPenaltyLamports"
331
+ }
332
+
333
+ export class WithdrawalPenaltyLamports {
334
+ static readonly discriminator = 14
335
+ static readonly kind = "WithdrawalPenaltyLamports"
336
+ readonly discriminator = 14
337
+ readonly kind = "WithdrawalPenaltyLamports"
338
+
339
+ toJSON(): WithdrawalPenaltyLamportsJSON {
340
+ return {
341
+ kind: "WithdrawalPenaltyLamports",
342
+ }
343
+ }
344
+
345
+ toEncodable() {
346
+ return {
347
+ WithdrawalPenaltyLamports: {},
348
+ }
349
+ }
350
+ }
351
+
352
+ export interface WithdrawalPenaltyBpsJSON {
353
+ kind: "WithdrawalPenaltyBps"
354
+ }
355
+
356
+ export class WithdrawalPenaltyBps {
357
+ static readonly discriminator = 15
358
+ static readonly kind = "WithdrawalPenaltyBps"
359
+ readonly discriminator = 15
360
+ readonly kind = "WithdrawalPenaltyBps"
361
+
362
+ toJSON(): WithdrawalPenaltyBpsJSON {
363
+ return {
364
+ kind: "WithdrawalPenaltyBps",
365
+ }
366
+ }
367
+
368
+ toEncodable() {
369
+ return {
370
+ WithdrawalPenaltyBps: {},
371
+ }
372
+ }
373
+ }
374
+
375
+ export interface FirstLossCapitalFarmJSON {
376
+ kind: "FirstLossCapitalFarm"
377
+ }
378
+
379
+ export class FirstLossCapitalFarm {
380
+ static readonly discriminator = 16
381
+ static readonly kind = "FirstLossCapitalFarm"
382
+ readonly discriminator = 16
383
+ readonly kind = "FirstLossCapitalFarm"
384
+
385
+ toJSON(): FirstLossCapitalFarmJSON {
386
+ return {
387
+ kind: "FirstLossCapitalFarm",
388
+ }
389
+ }
390
+
391
+ toEncodable() {
392
+ return {
393
+ FirstLossCapitalFarm: {},
394
+ }
395
+ }
396
+ }
397
+
398
+ export interface AllowAllocationsInWhitelistedReservesOnlyJSON {
399
+ kind: "AllowAllocationsInWhitelistedReservesOnly"
400
+ }
401
+
402
+ export class AllowAllocationsInWhitelistedReservesOnly {
403
+ static readonly discriminator = 17
404
+ static readonly kind = "AllowAllocationsInWhitelistedReservesOnly"
405
+ readonly discriminator = 17
406
+ readonly kind = "AllowAllocationsInWhitelistedReservesOnly"
407
+
408
+ toJSON(): AllowAllocationsInWhitelistedReservesOnlyJSON {
409
+ return {
410
+ kind: "AllowAllocationsInWhitelistedReservesOnly",
411
+ }
412
+ }
413
+
414
+ toEncodable() {
415
+ return {
416
+ AllowAllocationsInWhitelistedReservesOnly: {},
417
+ }
418
+ }
419
+ }
420
+
421
+ export interface AllowInvestInWhitelistedReservesOnlyJSON {
422
+ kind: "AllowInvestInWhitelistedReservesOnly"
423
+ }
424
+
425
+ export class AllowInvestInWhitelistedReservesOnly {
426
+ static readonly discriminator = 18
427
+ static readonly kind = "AllowInvestInWhitelistedReservesOnly"
428
+ readonly discriminator = 18
429
+ readonly kind = "AllowInvestInWhitelistedReservesOnly"
430
+
431
+ toJSON(): AllowInvestInWhitelistedReservesOnlyJSON {
432
+ return {
433
+ kind: "AllowInvestInWhitelistedReservesOnly",
434
+ }
435
+ }
436
+
437
+ toEncodable() {
438
+ return {
439
+ AllowInvestInWhitelistedReservesOnly: {},
440
+ }
441
+ }
442
+ }
443
+
329
444
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
330
445
  export function fromDecoded(obj: any): types.VaultConfigFieldKind {
331
446
  if (typeof obj !== "object") {
@@ -374,6 +489,21 @@ export function fromDecoded(obj: any): types.VaultConfigFieldKind {
374
489
  if ("UnallocatedTokensCap" in obj) {
375
490
  return new UnallocatedTokensCap()
376
491
  }
492
+ if ("WithdrawalPenaltyLamports" in obj) {
493
+ return new WithdrawalPenaltyLamports()
494
+ }
495
+ if ("WithdrawalPenaltyBps" in obj) {
496
+ return new WithdrawalPenaltyBps()
497
+ }
498
+ if ("FirstLossCapitalFarm" in obj) {
499
+ return new FirstLossCapitalFarm()
500
+ }
501
+ if ("AllowAllocationsInWhitelistedReservesOnly" in obj) {
502
+ return new AllowAllocationsInWhitelistedReservesOnly()
503
+ }
504
+ if ("AllowInvestInWhitelistedReservesOnly" in obj) {
505
+ return new AllowInvestInWhitelistedReservesOnly()
506
+ }
377
507
 
378
508
  throw new Error("Invalid enum object")
379
509
  }
@@ -424,6 +554,21 @@ export function fromJSON(
424
554
  case "UnallocatedTokensCap": {
425
555
  return new UnallocatedTokensCap()
426
556
  }
557
+ case "WithdrawalPenaltyLamports": {
558
+ return new WithdrawalPenaltyLamports()
559
+ }
560
+ case "WithdrawalPenaltyBps": {
561
+ return new WithdrawalPenaltyBps()
562
+ }
563
+ case "FirstLossCapitalFarm": {
564
+ return new FirstLossCapitalFarm()
565
+ }
566
+ case "AllowAllocationsInWhitelistedReservesOnly": {
567
+ return new AllowAllocationsInWhitelistedReservesOnly()
568
+ }
569
+ case "AllowInvestInWhitelistedReservesOnly": {
570
+ return new AllowInvestInWhitelistedReservesOnly()
571
+ }
427
572
  }
428
573
  }
429
574
 
@@ -443,6 +588,11 @@ export function layout(property?: string) {
443
588
  borsh.struct([], "AllocationAdmin"),
444
589
  borsh.struct([], "UnallocatedWeight"),
445
590
  borsh.struct([], "UnallocatedTokensCap"),
591
+ borsh.struct([], "WithdrawalPenaltyLamports"),
592
+ borsh.struct([], "WithdrawalPenaltyBps"),
593
+ borsh.struct([], "FirstLossCapitalFarm"),
594
+ borsh.struct([], "AllowAllocationsInWhitelistedReservesOnly"),
595
+ borsh.struct([], "AllowInvestInWhitelistedReservesOnly"),
446
596
  ])
447
597
  if (property !== undefined) {
448
598
  return ret.replicate(property)
@@ -1,4 +1,6 @@
1
+ import * as UpdateReserveWhitelistMode from "./UpdateReserveWhitelistMode"
1
2
  import * as VaultConfigField from "./VaultConfigField"
3
+ import * as UpdateGlobalConfigMode from "./UpdateGlobalConfigMode"
2
4
 
3
5
  export { LastUpdate } from "./LastUpdate"
4
6
  export type { LastUpdateFields, LastUpdateJSON } from "./LastUpdate"
@@ -49,6 +51,15 @@ export type {
49
51
  } from "./BorrowRateCurve"
50
52
  export { CurvePoint } from "./CurvePoint"
51
53
  export type { CurvePointFields, CurvePointJSON } from "./CurvePoint"
54
+ export { UpdateReserveWhitelistMode }
55
+
56
+ export type UpdateReserveWhitelistModeKind =
57
+ | UpdateReserveWhitelistMode.Invest
58
+ | UpdateReserveWhitelistMode.AddAllocation
59
+ export type UpdateReserveWhitelistModeJSON =
60
+ | UpdateReserveWhitelistMode.InvestJSON
61
+ | UpdateReserveWhitelistMode.AddAllocationJSON
62
+
52
63
  export { VaultConfigField }
53
64
 
54
65
  export type VaultConfigFieldKind =
@@ -66,6 +77,11 @@ export type VaultConfigFieldKind =
66
77
  | VaultConfigField.AllocationAdmin
67
78
  | VaultConfigField.UnallocatedWeight
68
79
  | VaultConfigField.UnallocatedTokensCap
80
+ | VaultConfigField.WithdrawalPenaltyLamports
81
+ | VaultConfigField.WithdrawalPenaltyBps
82
+ | VaultConfigField.FirstLossCapitalFarm
83
+ | VaultConfigField.AllowAllocationsInWhitelistedReservesOnly
84
+ | VaultConfigField.AllowInvestInWhitelistedReservesOnly
69
85
  export type VaultConfigFieldJSON =
70
86
  | VaultConfigField.PerformanceFeeBpsJSON
71
87
  | VaultConfigField.ManagementFeeBpsJSON
@@ -81,9 +97,24 @@ export type VaultConfigFieldJSON =
81
97
  | VaultConfigField.AllocationAdminJSON
82
98
  | VaultConfigField.UnallocatedWeightJSON
83
99
  | VaultConfigField.UnallocatedTokensCapJSON
100
+ | VaultConfigField.WithdrawalPenaltyLamportsJSON
101
+ | VaultConfigField.WithdrawalPenaltyBpsJSON
102
+ | VaultConfigField.FirstLossCapitalFarmJSON
103
+ | VaultConfigField.AllowAllocationsInWhitelistedReservesOnlyJSON
104
+ | VaultConfigField.AllowInvestInWhitelistedReservesOnlyJSON
84
105
 
85
106
  export { VaultAllocation } from "./VaultAllocation"
86
107
  export type {
87
108
  VaultAllocationFields,
88
109
  VaultAllocationJSON,
89
110
  } from "./VaultAllocation"
111
+ export { UpdateGlobalConfigMode }
112
+
113
+ export type UpdateGlobalConfigModeKind =
114
+ | UpdateGlobalConfigMode.PendingAdmin
115
+ | UpdateGlobalConfigMode.MinWithdrawalPenaltyLamports
116
+ | UpdateGlobalConfigMode.MinWithdrawalPenaltyBPS
117
+ export type UpdateGlobalConfigModeJSON =
118
+ | UpdateGlobalConfigMode.PendingAdminJSON
119
+ | UpdateGlobalConfigMode.MinWithdrawalPenaltyLamportsJSON
120
+ | UpdateGlobalConfigMode.MinWithdrawalPenaltyBPSJSON
@@ -76,7 +76,7 @@ import { ReserveConfig, UpdateLendingMarketMode, UpdateLendingMarketModeKind } f
76
76
  import Decimal from 'decimal.js';
77
77
  import { VaultState } from '../@codegen/kvault/accounts';
78
78
  import { getProgramAccounts } from '../utils/rpc';
79
- import { VaultConfigField, VaultConfigFieldKind } from '../@codegen/kvault/types';
79
+ import { UpdateReserveWhitelistModeKind, VaultConfigField, VaultConfigFieldKind } from '../@codegen/kvault/types';
80
80
  import {
81
81
  AcceptVaultOwnershipIxs,
82
82
  APYs,
@@ -228,6 +228,15 @@ export class KaminoManager {
228
228
  return { reserve: reserveAccount, txnIxs };
229
229
  }
230
230
 
231
+ /**
232
+ * This method initializes the kvault global config (one off, needs to be signed by program owner)
233
+ * @param admin - the admin of the kvault program
234
+ * @returns - an instruction to initialize the kvault global config
235
+ */
236
+ async initKvaultGlobalConfigIx(admin: TransactionSigner) {
237
+ return this._vaultClient.initKvaultGlobalConfigIx(admin);
238
+ }
239
+
231
240
  /**
232
241
  * This method will create a vault with a given config. The config can be changed later on, but it is recommended to set it up correctly from the start
233
242
  * @param vaultConfig - the config object used to create a vault
@@ -576,6 +585,16 @@ export class KaminoManager {
576
585
  return this._vaultClient.depositIxs(user, vault, tokenAmount, vaultReservesMap, farmState);
577
586
  }
578
587
 
588
+ async buyVaultSharesIxs(
589
+ user: TransactionSigner,
590
+ vault: KaminoVault,
591
+ tokenAmount: Decimal,
592
+ vaultReservesMap?: Map<Address, KaminoReserve>,
593
+ farmState?: FarmState
594
+ ): Promise<DepositIxs> {
595
+ return this._vaultClient.buySharesIxs(user, vault, tokenAmount, vaultReservesMap, farmState);
596
+ }
597
+
579
598
  /**
580
599
  * This function creates instructions to stake the shares in the vault farm if the vault has a farm
581
600
  * @param user - user to stake
@@ -619,6 +638,23 @@ export class KaminoManager {
619
638
  return this._vaultClient.updateVaultConfigIxs(vault, mode, value, signer, lutIxsSigner, skipLutUpdate);
620
639
  }
621
640
 
641
+ /**
642
+ * Add or update a reserve whitelist entry. This controls whether the reserve is whitelisted for adding/updating
643
+ * allocations or for invest, depending on the mode parameter.
644
+ *
645
+ * @param reserve - Address of the reserve to whitelist
646
+ * @param mode - The whitelist mode: either 'Invest' or 'AddAllocation' with a value (1 = add, 0 = remove)
647
+ * @param globalAdmin - The global admin that signs the transaction
648
+ * @returns - An instruction to add/update the whitelisted reserve entry
649
+ */
650
+ async addUpdateWhitelistedReserveIx(
651
+ reserve: Address,
652
+ mode: UpdateReserveWhitelistModeKind,
653
+ globalAdmin: TransactionSigner
654
+ ): Promise<Instruction> {
655
+ return this._vaultClient.addUpdateWhitelistedReserveIx(reserve, mode, globalAdmin);
656
+ }
657
+
622
658
  /** Sets the farm where the shares can be staked. This is store in vault state and a vault can only have one farm, so the new farm will ovveride the old farm
623
659
  * @param vault - vault to set the farm for
624
660
  * @param farm - the farm where the vault shares can be staked
@@ -692,6 +728,17 @@ export class KaminoManager {
692
728
  return this._vaultClient.withdrawIxs(user, vault, shareAmount, slot, vaultReservesMap, farmState);
693
729
  }
694
730
 
731
+ async sellVaultSharesIxs(
732
+ user: TransactionSigner,
733
+ vault: KaminoVault,
734
+ shareAmount: Decimal,
735
+ slot: Slot,
736
+ vaultReservesMap?: Map<Address, KaminoReserve>,
737
+ farmState?: FarmState
738
+ ): Promise<WithdrawIxs> {
739
+ return this._vaultClient.sellSharesIxs(user, vault, shareAmount, slot, vaultReservesMap, farmState);
740
+ }
741
+
695
742
  /**
696
743
  * This method withdraws all the pending fees from the vault to the owner's token ATA
697
744
  * @param vault - vault for which the admin withdraws the pending fees
@@ -1706,6 +1753,8 @@ export const MARKET_UPDATER = new ConfigUpdater(UpdateLendingMarketMode.fromDeco
1706
1753
  [UpdateLendingMarketMode.UpdateInitialDepositAmount.kind]: config.minInitialDepositAmount,
1707
1754
  [UpdateLendingMarketMode.UpdateObligationOrderCreationEnabled.kind]: config.obligationOrderCreationEnabled,
1708
1755
  [UpdateLendingMarketMode.UpdateObligationOrderExecutionEnabled.kind]: config.obligationOrderExecutionEnabled,
1756
+ [UpdateLendingMarketMode.UpdateProposerAuthority.kind]: config.proposerAuthority,
1757
+ [UpdateLendingMarketMode.UpdatePriceTriggeredLiquidationDisabled.kind]: config.priceTriggeredLiquidationDisabled,
1709
1758
  }));
1710
1759
 
1711
1760
  function parseForChangesMarketConfigAndGetIxs(