@kamino-finance/klend-sdk 7.4.0-beta.1 → 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 (338) hide show
  1. package/dist/@codegen/klend/accounts/LendingMarket.d.ts +201 -6
  2. package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
  3. package/dist/@codegen/klend/accounts/LendingMarket.js +130 -8
  4. package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
  5. package/dist/@codegen/klend/accounts/Obligation.d.ts +24 -15
  6. package/dist/@codegen/klend/accounts/Obligation.d.ts.map +1 -1
  7. package/dist/@codegen/klend/accounts/Obligation.js +24 -21
  8. package/dist/@codegen/klend/accounts/Obligation.js.map +1 -1
  9. package/dist/@codegen/klend/accounts/Reserve.d.ts +6 -0
  10. package/dist/@codegen/klend/accounts/Reserve.d.ts.map +1 -1
  11. package/dist/@codegen/klend/accounts/Reserve.js +9 -2
  12. package/dist/@codegen/klend/accounts/Reserve.js.map +1 -1
  13. package/dist/@codegen/klend/accounts/UserState.d.ts +0 -75
  14. package/dist/@codegen/klend/accounts/UserState.d.ts.map +1 -1
  15. package/dist/@codegen/klend/accounts/UserState.js +0 -25
  16. package/dist/@codegen/klend/accounts/UserState.js.map +1 -1
  17. package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts +144 -0
  18. package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts.map +1 -0
  19. package/dist/@codegen/klend/accounts/WithdrawTicket.js +205 -0
  20. package/dist/@codegen/klend/accounts/WithdrawTicket.js.map +1 -0
  21. package/dist/@codegen/klend/accounts/index.d.ts +2 -0
  22. package/dist/@codegen/klend/accounts/index.d.ts.map +1 -1
  23. package/dist/@codegen/klend/accounts/index.js +3 -1
  24. package/dist/@codegen/klend/accounts/index.js.map +1 -1
  25. package/dist/@codegen/klend/errors/custom.d.ts +169 -1
  26. package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
  27. package/dist/@codegen/klend/errors/custom.js +296 -1
  28. package/dist/@codegen/klend/errors/custom.js.map +1 -1
  29. package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts +62 -0
  30. package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts.map +1 -0
  31. package/dist/@codegen/klend/instructions/enqueueToWithdraw.js +79 -0
  32. package/dist/@codegen/klend/instructions/enqueueToWithdraw.js.map +1 -0
  33. package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts +36 -0
  34. package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts.map +1 -0
  35. package/dist/@codegen/klend/instructions/fillBorrowOrder.js +49 -0
  36. package/dist/@codegen/klend/instructions/fillBorrowOrder.js.map +1 -0
  37. package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts +0 -1
  38. package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts.map +1 -1
  39. package/dist/@codegen/klend/instructions/idlMissingTypes.js +0 -2
  40. package/dist/@codegen/klend/instructions/idlMissingTypes.js.map +1 -1
  41. package/dist/@codegen/klend/instructions/index.d.ts +10 -0
  42. package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
  43. package/dist/@codegen/klend/instructions/index.js +12 -1
  44. package/dist/@codegen/klend/instructions/index.js.map +1 -1
  45. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts +54 -0
  46. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts.map +1 -0
  47. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js +66 -0
  48. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js.map +1 -0
  49. package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts +33 -0
  50. package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts.map +1 -0
  51. package/dist/@codegen/klend/instructions/setBorrowOrder.js +66 -0
  52. package/dist/@codegen/klend/instructions/setBorrowOrder.js.map +1 -0
  53. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts +66 -0
  54. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts.map +1 -0
  55. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js +41 -0
  56. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js.map +1 -0
  57. package/dist/@codegen/klend/types/BorrowOrder.d.ts +192 -0
  58. package/dist/@codegen/klend/types/BorrowOrder.d.ts.map +1 -0
  59. package/dist/@codegen/klend/types/BorrowOrder.js +194 -0
  60. package/dist/@codegen/klend/types/BorrowOrder.js.map +1 -0
  61. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts +39 -0
  62. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts.map +1 -0
  63. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js +100 -0
  64. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js.map +1 -0
  65. package/dist/@codegen/klend/types/FixedTermBorrowRolloverConfig.d.ts +145 -0
  66. package/dist/@codegen/klend/types/FixedTermBorrowRolloverConfig.d.ts.map +1 -0
  67. package/dist/@codegen/klend/types/FixedTermBorrowRolloverConfig.js +144 -0
  68. package/dist/@codegen/klend/types/FixedTermBorrowRolloverConfig.js.map +1 -0
  69. package/dist/@codegen/klend/types/ObligationLiquidity.d.ts +64 -5
  70. package/dist/@codegen/klend/types/ObligationLiquidity.d.ts.map +1 -1
  71. package/dist/@codegen/klend/types/ObligationLiquidity.js +32 -8
  72. package/dist/@codegen/klend/types/ObligationLiquidity.js.map +1 -1
  73. package/dist/@codegen/klend/types/ObligationOrder.d.ts +4 -4
  74. package/dist/@codegen/klend/types/ObligationOrder.js +2 -2
  75. package/dist/@codegen/klend/types/ProgressCallbackType.d.ts +32 -0
  76. package/dist/@codegen/klend/types/ProgressCallbackType.d.ts.map +1 -0
  77. package/dist/@codegen/klend/types/{AssetTier.js → ProgressCallbackType.js} +24 -48
  78. package/dist/@codegen/klend/types/ProgressCallbackType.js.map +1 -0
  79. package/dist/@codegen/klend/types/ReserveConfig.d.ts +60 -5
  80. package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
  81. package/dist/@codegen/klend/types/ReserveConfig.js +36 -7
  82. package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
  83. package/dist/@codegen/klend/types/ReserveLiquidity.d.ts +26 -8
  84. package/dist/@codegen/klend/types/ReserveLiquidity.d.ts.map +1 -1
  85. package/dist/@codegen/klend/types/ReserveLiquidity.js +14 -8
  86. package/dist/@codegen/klend/types/ReserveLiquidity.js.map +1 -1
  87. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +40 -14
  88. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
  89. package/dist/@codegen/klend/types/UpdateConfigMode.js +72 -24
  90. package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
  91. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +130 -0
  92. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
  93. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +241 -1
  94. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
  95. package/dist/@codegen/klend/types/WithdrawQueue.d.ts +64 -0
  96. package/dist/@codegen/klend/types/WithdrawQueue.d.ts.map +1 -0
  97. package/dist/@codegen/klend/types/WithdrawQueue.js +104 -0
  98. package/dist/@codegen/klend/types/WithdrawQueue.js.map +1 -0
  99. package/dist/@codegen/klend/types/index.d.ts +27 -8
  100. package/dist/@codegen/klend/types/index.d.ts.map +1 -1
  101. package/dist/@codegen/klend/types/index.js +11 -3
  102. package/dist/@codegen/klend/types/index.js.map +1 -1
  103. package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts +8 -5
  104. package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts.map +1 -1
  105. package/dist/@codegen/klend/zero_padding/ObligationZP.js +17 -14
  106. package/dist/@codegen/klend/zero_padding/ObligationZP.js.map +1 -1
  107. package/dist/@codegen/kvault/accounts/LendingMarket.d.ts +480 -0
  108. package/dist/@codegen/kvault/accounts/LendingMarket.d.ts.map +1 -0
  109. package/dist/@codegen/kvault/accounts/LendingMarket.js +480 -0
  110. package/dist/@codegen/kvault/accounts/LendingMarket.js.map +1 -0
  111. package/dist/@codegen/kvault/accounts/Obligation.d.ts +208 -0
  112. package/dist/@codegen/kvault/accounts/Obligation.d.ts.map +1 -0
  113. package/dist/@codegen/kvault/accounts/Obligation.js +298 -0
  114. package/dist/@codegen/kvault/accounts/Obligation.js.map +1 -0
  115. package/dist/@codegen/kvault/accounts/ReferrerTokenState.d.ts +51 -0
  116. package/dist/@codegen/kvault/accounts/ReferrerTokenState.d.ts.map +1 -0
  117. package/dist/@codegen/kvault/accounts/ReferrerTokenState.js +137 -0
  118. package/dist/@codegen/kvault/accounts/ReferrerTokenState.js.map +1 -0
  119. package/dist/@codegen/kvault/accounts/Reserve.d.ts +6 -0
  120. package/dist/@codegen/kvault/accounts/Reserve.d.ts.map +1 -1
  121. package/dist/@codegen/kvault/accounts/Reserve.js +9 -2
  122. package/dist/@codegen/kvault/accounts/Reserve.js.map +1 -1
  123. package/dist/@codegen/kvault/accounts/VaultState.d.ts +45 -3
  124. package/dist/@codegen/kvault/accounts/VaultState.d.ts.map +1 -1
  125. package/dist/@codegen/kvault/accounts/VaultState.js +28 -4
  126. package/dist/@codegen/kvault/accounts/VaultState.js.map +1 -1
  127. package/dist/@codegen/kvault/accounts/WithdrawTicket.d.ts +144 -0
  128. package/dist/@codegen/kvault/accounts/WithdrawTicket.d.ts.map +1 -0
  129. package/dist/@codegen/kvault/accounts/WithdrawTicket.js +205 -0
  130. package/dist/@codegen/kvault/accounts/WithdrawTicket.js.map +1 -0
  131. package/dist/@codegen/kvault/accounts/index.d.ts +8 -0
  132. package/dist/@codegen/kvault/accounts/index.d.ts.map +1 -1
  133. package/dist/@codegen/kvault/accounts/index.js +9 -1
  134. package/dist/@codegen/kvault/accounts/index.js.map +1 -1
  135. package/dist/@codegen/kvault/errors/custom.d.ts +81 -1
  136. package/dist/@codegen/kvault/errors/custom.d.ts.map +1 -1
  137. package/dist/@codegen/kvault/errors/custom.js +141 -1
  138. package/dist/@codegen/kvault/errors/custom.js.map +1 -1
  139. package/dist/@codegen/kvault/instructions/index.d.ts +4 -0
  140. package/dist/@codegen/kvault/instructions/index.d.ts.map +1 -1
  141. package/dist/@codegen/kvault/instructions/index.js +5 -1
  142. package/dist/@codegen/kvault/instructions/index.js.map +1 -1
  143. package/dist/@codegen/kvault/instructions/invest.d.ts +9 -0
  144. package/dist/@codegen/kvault/instructions/invest.d.ts.map +1 -1
  145. package/dist/@codegen/kvault/instructions/invest.js +7 -0
  146. package/dist/@codegen/kvault/instructions/invest.js.map +1 -1
  147. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillOrder.d.ts +51 -0
  148. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillOrder.d.ts.map +1 -0
  149. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillOrder.js +154 -0
  150. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillOrder.js.map +1 -0
  151. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillWithdrawalTicket.d.ts +54 -0
  152. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillWithdrawalTicket.d.ts.map +1 -0
  153. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillWithdrawalTicket.js +166 -0
  154. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillWithdrawalTicket.js.map +1 -0
  155. package/dist/@codegen/kvault/instructions/updateKlendQueueAccounting.d.ts +1 -0
  156. package/dist/@codegen/kvault/instructions/updateKlendQueueAccounting.d.ts.map +1 -0
  157. package/dist/@codegen/kvault/instructions/updateKlendQueueAccounting.js +72 -0
  158. package/dist/@codegen/kvault/instructions/updateKlendQueueAccounting.js.map +1 -0
  159. package/dist/@codegen/kvault/instructions/updateReserveAllocation.d.ts +3 -1
  160. package/dist/@codegen/kvault/instructions/updateReserveAllocation.d.ts.map +1 -1
  161. package/dist/@codegen/kvault/instructions/updateReserveAllocation.js +3 -0
  162. package/dist/@codegen/kvault/instructions/updateReserveAllocation.js.map +1 -1
  163. package/dist/@codegen/kvault/types/BorrowOrder.d.ts +192 -0
  164. package/dist/@codegen/kvault/types/BorrowOrder.d.ts.map +1 -0
  165. package/dist/@codegen/kvault/types/BorrowOrder.js +194 -0
  166. package/dist/@codegen/kvault/types/BorrowOrder.js.map +1 -0
  167. package/dist/@codegen/kvault/types/ElevationGroup.d.ts +67 -0
  168. package/dist/@codegen/kvault/types/ElevationGroup.d.ts.map +1 -0
  169. package/dist/@codegen/kvault/types/ElevationGroup.js +137 -0
  170. package/dist/@codegen/kvault/types/ElevationGroup.js.map +1 -0
  171. package/dist/@codegen/kvault/types/FixedTermBorrowRolloverConfig.d.ts +145 -0
  172. package/dist/@codegen/kvault/types/FixedTermBorrowRolloverConfig.d.ts.map +1 -0
  173. package/dist/@codegen/kvault/types/FixedTermBorrowRolloverConfig.js +144 -0
  174. package/dist/@codegen/kvault/types/FixedTermBorrowRolloverConfig.js.map +1 -0
  175. package/dist/@codegen/kvault/types/ObligationCollateral.d.ts +72 -0
  176. package/dist/@codegen/kvault/types/ObligationCollateral.d.ts.map +1 -0
  177. package/dist/@codegen/kvault/types/ObligationCollateral.js +119 -0
  178. package/dist/@codegen/kvault/types/ObligationCollateral.js.map +1 -0
  179. package/dist/@codegen/kvault/types/ObligationLiquidity.d.ts +143 -0
  180. package/dist/@codegen/kvault/types/ObligationLiquidity.d.ts.map +1 -0
  181. package/dist/@codegen/kvault/types/ObligationLiquidity.js +165 -0
  182. package/dist/@codegen/kvault/types/ObligationLiquidity.js.map +1 -0
  183. package/dist/@codegen/kvault/types/ObligationOrder.d.ts +284 -0
  184. package/dist/@codegen/kvault/types/ObligationOrder.d.ts.map +1 -0
  185. package/dist/@codegen/kvault/types/ObligationOrder.js +205 -0
  186. package/dist/@codegen/kvault/types/ObligationOrder.js.map +1 -0
  187. package/dist/@codegen/kvault/types/ReserveConfig.d.ts +60 -5
  188. package/dist/@codegen/kvault/types/ReserveConfig.d.ts.map +1 -1
  189. package/dist/@codegen/kvault/types/ReserveConfig.js +36 -7
  190. package/dist/@codegen/kvault/types/ReserveConfig.js.map +1 -1
  191. package/dist/@codegen/kvault/types/ReserveLiquidity.d.ts +26 -8
  192. package/dist/@codegen/kvault/types/ReserveLiquidity.d.ts.map +1 -1
  193. package/dist/@codegen/kvault/types/ReserveLiquidity.js +14 -8
  194. package/dist/@codegen/kvault/types/ReserveLiquidity.js.map +1 -1
  195. package/dist/@codegen/kvault/types/ReserveType.d.ts +32 -0
  196. package/dist/@codegen/kvault/types/ReserveType.d.ts.map +1 -0
  197. package/dist/@codegen/kvault/types/ReserveType.js +108 -0
  198. package/dist/@codegen/kvault/types/ReserveType.js.map +1 -0
  199. package/dist/@codegen/kvault/types/VaultAllocation.d.ts +60 -0
  200. package/dist/@codegen/kvault/types/VaultAllocation.d.ts.map +1 -1
  201. package/dist/@codegen/kvault/types/VaultAllocation.js +38 -2
  202. package/dist/@codegen/kvault/types/VaultAllocation.js.map +1 -1
  203. package/dist/@codegen/kvault/types/WithdrawQueue.d.ts +64 -0
  204. package/dist/@codegen/kvault/types/WithdrawQueue.d.ts.map +1 -0
  205. package/dist/@codegen/kvault/types/WithdrawQueue.js +104 -0
  206. package/dist/@codegen/kvault/types/WithdrawQueue.js.map +1 -0
  207. package/dist/@codegen/kvault/types/WithdrawTicketProgressEvent.d.ts +19 -0
  208. package/dist/@codegen/kvault/types/WithdrawTicketProgressEvent.d.ts.map +1 -0
  209. package/dist/@codegen/kvault/types/WithdrawTicketProgressEvent.js +82 -0
  210. package/dist/@codegen/kvault/types/WithdrawTicketProgressEvent.js.map +1 -0
  211. package/dist/@codegen/kvault/types/index.d.ts +34 -0
  212. package/dist/@codegen/kvault/types/index.d.ts.map +1 -1
  213. package/dist/@codegen/kvault/types/index.js +19 -1
  214. package/dist/@codegen/kvault/types/index.js.map +1 -1
  215. package/dist/classes/action.d.ts +11 -0
  216. package/dist/classes/action.d.ts.map +1 -1
  217. package/dist/classes/action.js +66 -0
  218. package/dist/classes/action.js.map +1 -1
  219. package/dist/classes/actionTypes.d.ts +29 -0
  220. package/dist/classes/actionTypes.d.ts.map +1 -1
  221. package/dist/classes/manager.d.ts +1 -1
  222. package/dist/classes/manager.d.ts.map +1 -1
  223. package/dist/classes/manager.js +13 -8
  224. package/dist/classes/manager.js.map +1 -1
  225. package/dist/classes/market.d.ts +10 -5
  226. package/dist/classes/market.d.ts.map +1 -1
  227. package/dist/classes/market.js +22 -15
  228. package/dist/classes/market.js.map +1 -1
  229. package/dist/classes/obligation.d.ts +2 -2
  230. package/dist/classes/obligation.d.ts.map +1 -1
  231. package/dist/classes/obligation.js +9 -7
  232. package/dist/classes/obligation.js.map +1 -1
  233. package/dist/classes/reserve.d.ts +2 -1
  234. package/dist/classes/reserve.d.ts.map +1 -1
  235. package/dist/classes/reserve.js +48 -32
  236. package/dist/classes/reserve.js.map +1 -1
  237. package/dist/classes/utils.d.ts +2 -0
  238. package/dist/classes/utils.d.ts.map +1 -1
  239. package/dist/classes/utils.js +12 -1
  240. package/dist/classes/utils.js.map +1 -1
  241. package/dist/classes/vault.d.ts +4 -2
  242. package/dist/classes/vault.d.ts.map +1 -1
  243. package/dist/classes/vault.js +12 -2
  244. package/dist/classes/vault.js.map +1 -1
  245. package/dist/idl/klend.json +1461 -106
  246. package/dist/manager/client_kamino_manager.js +14 -11
  247. package/dist/manager/client_kamino_manager.js.map +1 -1
  248. package/dist/obligation_orders/price_based.js +5 -4
  249. package/dist/obligation_orders/price_based.js.map +1 -1
  250. package/dist/utils/managerTypes.d.ts.map +1 -1
  251. package/dist/utils/managerTypes.js +3 -1
  252. package/dist/utils/managerTypes.js.map +1 -1
  253. package/dist/utils/seeds.d.ts +24 -0
  254. package/dist/utils/seeds.d.ts.map +1 -1
  255. package/dist/utils/seeds.js +41 -1
  256. package/dist/utils/seeds.js.map +1 -1
  257. package/dist/utils/validations.d.ts +1 -0
  258. package/dist/utils/validations.d.ts.map +1 -1
  259. package/dist/utils/validations.js +5 -0
  260. package/dist/utils/validations.js.map +1 -1
  261. package/dist/utils/vault.d.ts.map +1 -1
  262. package/dist/utils/vault.js +2 -0
  263. package/dist/utils/vault.js.map +1 -1
  264. package/package.json +1 -1
  265. package/src/@codegen/klend/accounts/LendingMarket.ts +284 -12
  266. package/src/@codegen/klend/accounts/Obligation.ts +42 -31
  267. package/src/@codegen/klend/accounts/Reserve.ts +13 -2
  268. package/src/@codegen/klend/accounts/UserState.ts +0 -75
  269. package/src/@codegen/klend/accounts/WithdrawTicket.ts +280 -0
  270. package/src/@codegen/klend/accounts/index.ts +2 -0
  271. package/src/@codegen/klend/errors/custom.ts +333 -0
  272. package/src/@codegen/klend/instructions/enqueueToWithdraw.ts +120 -0
  273. package/src/@codegen/klend/instructions/fillBorrowOrder.ts +96 -0
  274. package/src/@codegen/klend/instructions/idlMissingTypes.ts +0 -3
  275. package/src/@codegen/klend/instructions/index.ts +19 -0
  276. package/src/@codegen/klend/instructions/recoverInvalidTicketCollateral.ts +103 -0
  277. package/src/@codegen/klend/instructions/setBorrowOrder.ts +81 -0
  278. package/src/@codegen/klend/instructions/withdrawQueuedLiquidity.ts +118 -0
  279. package/src/@codegen/klend/types/BorrowOrder.ts +267 -0
  280. package/src/@codegen/klend/types/BorrowOrderConfigArgs.ts +87 -0
  281. package/src/@codegen/klend/types/FixedTermBorrowRolloverConfig.ts +199 -0
  282. package/src/@codegen/klend/types/ObligationLiquidity.ts +76 -10
  283. package/src/@codegen/klend/types/ObligationOrder.ts +4 -4
  284. package/src/@codegen/klend/types/ProgressCallbackType.ts +91 -0
  285. package/src/@codegen/klend/types/ReserveConfig.ts +72 -9
  286. package/src/@codegen/klend/types/ReserveLiquidity.ts +30 -12
  287. package/src/@codegen/klend/types/UpdateConfigMode.ts +86 -26
  288. package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +300 -0
  289. package/src/@codegen/klend/types/WithdrawQueue.ts +117 -0
  290. package/src/@codegen/klend/types/index.ts +63 -16
  291. package/src/@codegen/klend/zero_padding/ObligationZP.ts +17 -14
  292. package/src/@codegen/kvault/accounts/LendingMarket.ts +837 -0
  293. package/src/@codegen/kvault/accounts/Obligation.ts +459 -0
  294. package/src/@codegen/kvault/accounts/ReferrerTokenState.ts +160 -0
  295. package/src/@codegen/kvault/accounts/Reserve.ts +13 -2
  296. package/src/@codegen/kvault/accounts/VaultState.ts +59 -7
  297. package/src/@codegen/kvault/accounts/WithdrawTicket.ts +280 -0
  298. package/src/@codegen/kvault/accounts/index.ts +11 -0
  299. package/src/@codegen/kvault/errors/custom.ts +152 -0
  300. package/src/@codegen/kvault/instructions/index.ts +10 -0
  301. package/src/@codegen/kvault/instructions/invest.ts +16 -0
  302. package/src/@codegen/kvault/instructions/investInVirtualReserveAndFillOrder.ts +189 -0
  303. package/src/@codegen/kvault/instructions/investInVirtualReserveAndFillWithdrawalTicket.ts +205 -0
  304. package/src/@codegen/kvault/instructions/updateKlendQueueAccounting.ts +76 -0
  305. package/src/@codegen/kvault/instructions/updateReserveAllocation.ts +4 -1
  306. package/src/@codegen/kvault/types/BorrowOrder.ts +267 -0
  307. package/src/@codegen/kvault/types/ElevationGroup.ts +134 -0
  308. package/src/@codegen/kvault/types/FixedTermBorrowRolloverConfig.ts +199 -0
  309. package/src/@codegen/kvault/types/ObligationCollateral.ts +129 -0
  310. package/src/@codegen/kvault/types/ObligationLiquidity.ts +226 -0
  311. package/src/@codegen/kvault/types/ObligationOrder.ts +348 -0
  312. package/src/@codegen/kvault/types/ReserveConfig.ts +72 -9
  313. package/src/@codegen/kvault/types/ReserveLiquidity.ts +30 -12
  314. package/src/@codegen/kvault/types/ReserveType.ts +89 -0
  315. package/src/@codegen/kvault/types/VaultAllocation.ts +74 -2
  316. package/src/@codegen/kvault/types/WithdrawQueue.ts +117 -0
  317. package/src/@codegen/kvault/types/WithdrawTicketProgressEvent.ts +59 -0
  318. package/src/@codegen/kvault/types/index.ts +52 -0
  319. package/src/classes/action.ts +115 -1
  320. package/src/classes/actionTypes.ts +31 -0
  321. package/src/classes/manager.ts +24 -27
  322. package/src/classes/market.ts +34 -17
  323. package/src/classes/obligation.ts +9 -7
  324. package/src/classes/reserve.ts +48 -45
  325. package/src/classes/utils.ts +8 -0
  326. package/src/classes/vault.ts +35 -4
  327. package/src/idl/klend.json +1461 -106
  328. package/src/idl/kvault.json +2336 -299
  329. package/src/manager/client_kamino_manager.ts +14 -12
  330. package/src/obligation_orders/price_based.ts +7 -6
  331. package/src/utils/managerTypes.ts +3 -1
  332. package/src/utils/seeds.ts +49 -0
  333. package/src/utils/validations.ts +5 -0
  334. package/src/utils/vault.ts +2 -0
  335. package/dist/@codegen/klend/types/AssetTier.d.ts +0 -45
  336. package/dist/@codegen/klend/types/AssetTier.d.ts.map +0 -1
  337. package/dist/@codegen/klend/types/AssetTier.js.map +0 -1
  338. package/src/@codegen/klend/types/AssetTier.ts +0 -119
@@ -0,0 +1,89 @@
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 StandardJSON {
8
+ kind: "Standard"
9
+ }
10
+
11
+ export class Standard {
12
+ static readonly discriminator = 0
13
+ static readonly kind = "Standard"
14
+ readonly discriminator = 0
15
+ readonly kind = "Standard"
16
+
17
+ toJSON(): StandardJSON {
18
+ return {
19
+ kind: "Standard",
20
+ }
21
+ }
22
+
23
+ toEncodable() {
24
+ return {
25
+ Standard: {},
26
+ }
27
+ }
28
+ }
29
+
30
+ export interface VirtualJSON {
31
+ kind: "Virtual"
32
+ }
33
+
34
+ export class Virtual {
35
+ static readonly discriminator = 1
36
+ static readonly kind = "Virtual"
37
+ readonly discriminator = 1
38
+ readonly kind = "Virtual"
39
+
40
+ toJSON(): VirtualJSON {
41
+ return {
42
+ kind: "Virtual",
43
+ }
44
+ }
45
+
46
+ toEncodable() {
47
+ return {
48
+ Virtual: {},
49
+ }
50
+ }
51
+ }
52
+
53
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
+ export function fromDecoded(obj: any): types.ReserveTypeKind {
55
+ if (typeof obj !== "object") {
56
+ throw new Error("Invalid enum object")
57
+ }
58
+
59
+ if ("Standard" in obj) {
60
+ return new Standard()
61
+ }
62
+ if ("Virtual" in obj) {
63
+ return new Virtual()
64
+ }
65
+
66
+ throw new Error("Invalid enum object")
67
+ }
68
+
69
+ export function fromJSON(obj: types.ReserveTypeJSON): types.ReserveTypeKind {
70
+ switch (obj.kind) {
71
+ case "Standard": {
72
+ return new Standard()
73
+ }
74
+ case "Virtual": {
75
+ return new Virtual()
76
+ }
77
+ }
78
+ }
79
+
80
+ export function layout(property?: string) {
81
+ const ret = borsh.rustEnum([
82
+ borsh.struct([], "Standard"),
83
+ borsh.struct([], "Virtual"),
84
+ ])
85
+ if (property !== undefined) {
86
+ return ret.replicate(property)
87
+ }
88
+ return ret
89
+ }
@@ -11,10 +11,28 @@ export interface VaultAllocationFields {
11
11
  /** Maximum token invested in this reserve */
12
12
  tokenAllocationCap: BN
13
13
  ctokenVaultBump: BN
14
+ /** should match the ReserveType enum */
15
+ reserveType: number
16
+ padding0: Array<number>
14
17
  configPadding: Array<BN>
18
+ /**
19
+ * The amount of ctokens that currently earns yield for the vault.
20
+ *
21
+ * Please note that these ctokens are *not* necessarily all in the [Self::ctoken_vault] - they
22
+ * may also be e.g. queued for withdrawal (and held by the corresponding Klend queue vault),
23
+ * see [Self::klend_queued_ctokens].
24
+ */
15
25
  ctokenAllocation: BN
16
26
  lastInvestSlot: BN
17
27
  tokenTargetAllocationSf: BN
28
+ /**
29
+ * The ctokens that are still locked in the [Self::reserve]'s "queued collateral vault" on the
30
+ * Klend's withdraw queue side.
31
+ *
32
+ * Please note that - since such queued ctokens still earn yield for the vault - this amount is
33
+ * also included in the [Self::ctoken_allocation].
34
+ */
35
+ klendQueuedCtokens: BN
18
36
  statePadding: Array<BN>
19
37
  }
20
38
 
@@ -25,10 +43,28 @@ export interface VaultAllocationJSON {
25
43
  /** Maximum token invested in this reserve */
26
44
  tokenAllocationCap: string
27
45
  ctokenVaultBump: string
46
+ /** should match the ReserveType enum */
47
+ reserveType: number
48
+ padding0: Array<number>
28
49
  configPadding: Array<string>
50
+ /**
51
+ * The amount of ctokens that currently earns yield for the vault.
52
+ *
53
+ * Please note that these ctokens are *not* necessarily all in the [Self::ctoken_vault] - they
54
+ * may also be e.g. queued for withdrawal (and held by the corresponding Klend queue vault),
55
+ * see [Self::klend_queued_ctokens].
56
+ */
29
57
  ctokenAllocation: string
30
58
  lastInvestSlot: string
31
59
  tokenTargetAllocationSf: string
60
+ /**
61
+ * The ctokens that are still locked in the [Self::reserve]'s "queued collateral vault" on the
62
+ * Klend's withdraw queue side.
63
+ *
64
+ * Please note that - since such queued ctokens still earn yield for the vault - this amount is
65
+ * also included in the [Self::ctoken_allocation].
66
+ */
67
+ klendQueuedCtokens: string
32
68
  statePadding: Array<string>
33
69
  }
34
70
 
@@ -39,10 +75,28 @@ export class VaultAllocation {
39
75
  /** Maximum token invested in this reserve */
40
76
  readonly tokenAllocationCap: BN
41
77
  readonly ctokenVaultBump: BN
78
+ /** should match the ReserveType enum */
79
+ readonly reserveType: number
80
+ readonly padding0: Array<number>
42
81
  readonly configPadding: Array<BN>
82
+ /**
83
+ * The amount of ctokens that currently earns yield for the vault.
84
+ *
85
+ * Please note that these ctokens are *not* necessarily all in the [Self::ctoken_vault] - they
86
+ * may also be e.g. queued for withdrawal (and held by the corresponding Klend queue vault),
87
+ * see [Self::klend_queued_ctokens].
88
+ */
43
89
  readonly ctokenAllocation: BN
44
90
  readonly lastInvestSlot: BN
45
91
  readonly tokenTargetAllocationSf: BN
92
+ /**
93
+ * The ctokens that are still locked in the [Self::reserve]'s "queued collateral vault" on the
94
+ * Klend's withdraw queue side.
95
+ *
96
+ * Please note that - since such queued ctokens still earn yield for the vault - this amount is
97
+ * also included in the [Self::ctoken_allocation].
98
+ */
99
+ readonly klendQueuedCtokens: BN
46
100
  readonly statePadding: Array<BN>
47
101
 
48
102
  constructor(fields: VaultAllocationFields) {
@@ -51,10 +105,13 @@ export class VaultAllocation {
51
105
  this.targetAllocationWeight = fields.targetAllocationWeight
52
106
  this.tokenAllocationCap = fields.tokenAllocationCap
53
107
  this.ctokenVaultBump = fields.ctokenVaultBump
108
+ this.reserveType = fields.reserveType
109
+ this.padding0 = fields.padding0
54
110
  this.configPadding = fields.configPadding
55
111
  this.ctokenAllocation = fields.ctokenAllocation
56
112
  this.lastInvestSlot = fields.lastInvestSlot
57
113
  this.tokenTargetAllocationSf = fields.tokenTargetAllocationSf
114
+ this.klendQueuedCtokens = fields.klendQueuedCtokens
58
115
  this.statePadding = fields.statePadding
59
116
  }
60
117
 
@@ -66,11 +123,14 @@ export class VaultAllocation {
66
123
  borsh.u64("targetAllocationWeight"),
67
124
  borsh.u64("tokenAllocationCap"),
68
125
  borsh.u64("ctokenVaultBump"),
69
- borsh.array(borsh.u64(), 127, "configPadding"),
126
+ borsh.u8("reserveType"),
127
+ borsh.array(borsh.u8(), 7, "padding0"),
128
+ borsh.array(borsh.u64(), 126, "configPadding"),
70
129
  borsh.u64("ctokenAllocation"),
71
130
  borsh.u64("lastInvestSlot"),
72
131
  borsh.u128("tokenTargetAllocationSf"),
73
- borsh.array(borsh.u64(), 128, "statePadding"),
132
+ borsh.u64("klendQueuedCtokens"),
133
+ borsh.array(borsh.u64(), 127, "statePadding"),
74
134
  ],
75
135
  property
76
136
  )
@@ -84,10 +144,13 @@ export class VaultAllocation {
84
144
  targetAllocationWeight: obj.targetAllocationWeight,
85
145
  tokenAllocationCap: obj.tokenAllocationCap,
86
146
  ctokenVaultBump: obj.ctokenVaultBump,
147
+ reserveType: obj.reserveType,
148
+ padding0: obj.padding0,
87
149
  configPadding: obj.configPadding,
88
150
  ctokenAllocation: obj.ctokenAllocation,
89
151
  lastInvestSlot: obj.lastInvestSlot,
90
152
  tokenTargetAllocationSf: obj.tokenTargetAllocationSf,
153
+ klendQueuedCtokens: obj.klendQueuedCtokens,
91
154
  statePadding: obj.statePadding,
92
155
  })
93
156
  }
@@ -99,10 +162,13 @@ export class VaultAllocation {
99
162
  targetAllocationWeight: fields.targetAllocationWeight,
100
163
  tokenAllocationCap: fields.tokenAllocationCap,
101
164
  ctokenVaultBump: fields.ctokenVaultBump,
165
+ reserveType: fields.reserveType,
166
+ padding0: fields.padding0,
102
167
  configPadding: fields.configPadding,
103
168
  ctokenAllocation: fields.ctokenAllocation,
104
169
  lastInvestSlot: fields.lastInvestSlot,
105
170
  tokenTargetAllocationSf: fields.tokenTargetAllocationSf,
171
+ klendQueuedCtokens: fields.klendQueuedCtokens,
106
172
  statePadding: fields.statePadding,
107
173
  }
108
174
  }
@@ -114,10 +180,13 @@ export class VaultAllocation {
114
180
  targetAllocationWeight: this.targetAllocationWeight.toString(),
115
181
  tokenAllocationCap: this.tokenAllocationCap.toString(),
116
182
  ctokenVaultBump: this.ctokenVaultBump.toString(),
183
+ reserveType: this.reserveType,
184
+ padding0: this.padding0,
117
185
  configPadding: this.configPadding.map((item) => item.toString()),
118
186
  ctokenAllocation: this.ctokenAllocation.toString(),
119
187
  lastInvestSlot: this.lastInvestSlot.toString(),
120
188
  tokenTargetAllocationSf: this.tokenTargetAllocationSf.toString(),
189
+ klendQueuedCtokens: this.klendQueuedCtokens.toString(),
121
190
  statePadding: this.statePadding.map((item) => item.toString()),
122
191
  }
123
192
  }
@@ -129,10 +198,13 @@ export class VaultAllocation {
129
198
  targetAllocationWeight: new BN(obj.targetAllocationWeight),
130
199
  tokenAllocationCap: new BN(obj.tokenAllocationCap),
131
200
  ctokenVaultBump: new BN(obj.ctokenVaultBump),
201
+ reserveType: obj.reserveType,
202
+ padding0: obj.padding0,
132
203
  configPadding: obj.configPadding.map((item) => new BN(item)),
133
204
  ctokenAllocation: new BN(obj.ctokenAllocation),
134
205
  lastInvestSlot: new BN(obj.lastInvestSlot),
135
206
  tokenTargetAllocationSf: new BN(obj.tokenTargetAllocationSf),
207
+ klendQueuedCtokens: new BN(obj.klendQueuedCtokens),
136
208
  statePadding: obj.statePadding.map((item) => new BN(item)),
137
209
  })
138
210
  }
@@ -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 interface WithdrawQueueFields {
8
+ /** The part of [ReserveLiquidity::total_available_amount] locked for ticketed withdrawals. */
9
+ queuedCollateralAmount: BN
10
+ /**
11
+ * The sequence number of the next ticket to be issued when enqueueing to withdraw.
12
+ * Note: it is also a number of tickets issued so far.
13
+ */
14
+ nextIssuedTicketSequenceNumber: BN
15
+ /**
16
+ * The sequence number of the next ticket to be used for actually transferring the withdrawn
17
+ * liquidity (assuming it is available in the reserve).
18
+ * Note: it is also a number of fully-consumed tickets so far.
19
+ */
20
+ nextWithdrawableTicketSequenceNumber: BN
21
+ }
22
+
23
+ export interface WithdrawQueueJSON {
24
+ /** The part of [ReserveLiquidity::total_available_amount] locked for ticketed withdrawals. */
25
+ queuedCollateralAmount: string
26
+ /**
27
+ * The sequence number of the next ticket to be issued when enqueueing to withdraw.
28
+ * Note: it is also a number of tickets issued so far.
29
+ */
30
+ nextIssuedTicketSequenceNumber: string
31
+ /**
32
+ * The sequence number of the next ticket to be used for actually transferring the withdrawn
33
+ * liquidity (assuming it is available in the reserve).
34
+ * Note: it is also a number of fully-consumed tickets so far.
35
+ */
36
+ nextWithdrawableTicketSequenceNumber: string
37
+ }
38
+
39
+ /** A tracker of ticket-based withdrawals. */
40
+ export class WithdrawQueue {
41
+ /** The part of [ReserveLiquidity::total_available_amount] locked for ticketed withdrawals. */
42
+ readonly queuedCollateralAmount: BN
43
+ /**
44
+ * The sequence number of the next ticket to be issued when enqueueing to withdraw.
45
+ * Note: it is also a number of tickets issued so far.
46
+ */
47
+ readonly nextIssuedTicketSequenceNumber: BN
48
+ /**
49
+ * The sequence number of the next ticket to be used for actually transferring the withdrawn
50
+ * liquidity (assuming it is available in the reserve).
51
+ * Note: it is also a number of fully-consumed tickets so far.
52
+ */
53
+ readonly nextWithdrawableTicketSequenceNumber: BN
54
+
55
+ constructor(fields: WithdrawQueueFields) {
56
+ this.queuedCollateralAmount = fields.queuedCollateralAmount
57
+ this.nextIssuedTicketSequenceNumber = fields.nextIssuedTicketSequenceNumber
58
+ this.nextWithdrawableTicketSequenceNumber =
59
+ fields.nextWithdrawableTicketSequenceNumber
60
+ }
61
+
62
+ static layout(property?: string) {
63
+ return borsh.struct(
64
+ [
65
+ borsh.u64("queuedCollateralAmount"),
66
+ borsh.u64("nextIssuedTicketSequenceNumber"),
67
+ borsh.u64("nextWithdrawableTicketSequenceNumber"),
68
+ ],
69
+ property
70
+ )
71
+ }
72
+
73
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
+ static fromDecoded(obj: any) {
75
+ return new WithdrawQueue({
76
+ queuedCollateralAmount: obj.queuedCollateralAmount,
77
+ nextIssuedTicketSequenceNumber: obj.nextIssuedTicketSequenceNumber,
78
+ nextWithdrawableTicketSequenceNumber:
79
+ obj.nextWithdrawableTicketSequenceNumber,
80
+ })
81
+ }
82
+
83
+ static toEncodable(fields: WithdrawQueueFields) {
84
+ return {
85
+ queuedCollateralAmount: fields.queuedCollateralAmount,
86
+ nextIssuedTicketSequenceNumber: fields.nextIssuedTicketSequenceNumber,
87
+ nextWithdrawableTicketSequenceNumber:
88
+ fields.nextWithdrawableTicketSequenceNumber,
89
+ }
90
+ }
91
+
92
+ toJSON(): WithdrawQueueJSON {
93
+ return {
94
+ queuedCollateralAmount: this.queuedCollateralAmount.toString(),
95
+ nextIssuedTicketSequenceNumber:
96
+ this.nextIssuedTicketSequenceNumber.toString(),
97
+ nextWithdrawableTicketSequenceNumber:
98
+ this.nextWithdrawableTicketSequenceNumber.toString(),
99
+ }
100
+ }
101
+
102
+ static fromJSON(obj: WithdrawQueueJSON): WithdrawQueue {
103
+ return new WithdrawQueue({
104
+ queuedCollateralAmount: new BN(obj.queuedCollateralAmount),
105
+ nextIssuedTicketSequenceNumber: new BN(
106
+ obj.nextIssuedTicketSequenceNumber
107
+ ),
108
+ nextWithdrawableTicketSequenceNumber: new BN(
109
+ obj.nextWithdrawableTicketSequenceNumber
110
+ ),
111
+ })
112
+ }
113
+
114
+ toEncodable() {
115
+ return WithdrawQueue.toEncodable(this)
116
+ }
117
+ }
@@ -0,0 +1,59 @@
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 QueuedLiquidityWithdrawnJSON {
8
+ kind: "QueuedLiquidityWithdrawn"
9
+ }
10
+
11
+ export class QueuedLiquidityWithdrawn {
12
+ static readonly discriminator = 0
13
+ static readonly kind = "QueuedLiquidityWithdrawn"
14
+ readonly discriminator = 0
15
+ readonly kind = "QueuedLiquidityWithdrawn"
16
+
17
+ toJSON(): QueuedLiquidityWithdrawnJSON {
18
+ return {
19
+ kind: "QueuedLiquidityWithdrawn",
20
+ }
21
+ }
22
+
23
+ toEncodable() {
24
+ return {
25
+ QueuedLiquidityWithdrawn: {},
26
+ }
27
+ }
28
+ }
29
+
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ export function fromDecoded(obj: any): types.WithdrawTicketProgressEventKind {
32
+ if (typeof obj !== "object") {
33
+ throw new Error("Invalid enum object")
34
+ }
35
+
36
+ if ("QueuedLiquidityWithdrawn" in obj) {
37
+ return new QueuedLiquidityWithdrawn()
38
+ }
39
+
40
+ throw new Error("Invalid enum object")
41
+ }
42
+
43
+ export function fromJSON(
44
+ obj: types.WithdrawTicketProgressEventJSON
45
+ ): types.WithdrawTicketProgressEventKind {
46
+ switch (obj.kind) {
47
+ case "QueuedLiquidityWithdrawn": {
48
+ return new QueuedLiquidityWithdrawn()
49
+ }
50
+ }
51
+ }
52
+
53
+ export function layout(property?: string) {
54
+ const ret = borsh.rustEnum([borsh.struct([], "QueuedLiquidityWithdrawn")])
55
+ if (property !== undefined) {
56
+ return ret.replicate(property)
57
+ }
58
+ return ret
59
+ }
@@ -1,9 +1,35 @@
1
+ import * as WithdrawTicketProgressEvent from "./WithdrawTicketProgressEvent"
1
2
  import * as UpdateReserveWhitelistMode from "./UpdateReserveWhitelistMode"
2
3
  import * as VaultConfigField from "./VaultConfigField"
3
4
  import * as UpdateGlobalConfigMode from "./UpdateGlobalConfigMode"
5
+ import * as ReserveType from "./ReserveType"
4
6
 
5
7
  export { LastUpdate } from "./LastUpdate"
6
8
  export type { LastUpdateFields, LastUpdateJSON } from "./LastUpdate"
9
+ export { ElevationGroup } from "./ElevationGroup"
10
+ export type { ElevationGroupFields, ElevationGroupJSON } from "./ElevationGroup"
11
+ export { BorrowOrder } from "./BorrowOrder"
12
+ export type { BorrowOrderFields, BorrowOrderJSON } from "./BorrowOrder"
13
+ export { FixedTermBorrowRolloverConfig } from "./FixedTermBorrowRolloverConfig"
14
+ export type {
15
+ FixedTermBorrowRolloverConfigFields,
16
+ FixedTermBorrowRolloverConfigJSON,
17
+ } from "./FixedTermBorrowRolloverConfig"
18
+ export { ObligationCollateral } from "./ObligationCollateral"
19
+ export type {
20
+ ObligationCollateralFields,
21
+ ObligationCollateralJSON,
22
+ } from "./ObligationCollateral"
23
+ export { ObligationLiquidity } from "./ObligationLiquidity"
24
+ export type {
25
+ ObligationLiquidityFields,
26
+ ObligationLiquidityJSON,
27
+ } from "./ObligationLiquidity"
28
+ export { ObligationOrder } from "./ObligationOrder"
29
+ export type {
30
+ ObligationOrderFields,
31
+ ObligationOrderJSON,
32
+ } from "./ObligationOrder"
7
33
  export { BigFractionBytes } from "./BigFractionBytes"
8
34
  export type {
9
35
  BigFractionBytesFields,
@@ -23,6 +49,8 @@ export type {
23
49
  ReserveLiquidityFields,
24
50
  ReserveLiquidityJSON,
25
51
  } from "./ReserveLiquidity"
52
+ export { WithdrawQueue } from "./WithdrawQueue"
53
+ export type { WithdrawQueueFields, WithdrawQueueJSON } from "./WithdrawQueue"
26
54
  export { WithdrawalCaps } from "./WithdrawalCaps"
27
55
  export type { WithdrawalCapsFields, WithdrawalCapsJSON } from "./WithdrawalCaps"
28
56
  export { PriceHeuristic } from "./PriceHeuristic"
@@ -44,6 +72,13 @@ export type {
44
72
  } from "./SwitchboardConfiguration"
45
73
  export { TokenInfo } from "./TokenInfo"
46
74
  export type { TokenInfoFields, TokenInfoJSON } from "./TokenInfo"
75
+ export { WithdrawTicketProgressEvent }
76
+
77
+ export type WithdrawTicketProgressEventKind =
78
+ WithdrawTicketProgressEvent.QueuedLiquidityWithdrawn
79
+ export type WithdrawTicketProgressEventJSON =
80
+ WithdrawTicketProgressEvent.QueuedLiquidityWithdrawnJSON
81
+
47
82
  export { BorrowRateCurve } from "./BorrowRateCurve"
48
83
  export type {
49
84
  BorrowRateCurveFields,
@@ -118,3 +153,20 @@ export type UpdateGlobalConfigModeJSON =
118
153
  | UpdateGlobalConfigMode.PendingAdminJSON
119
154
  | UpdateGlobalConfigMode.MinWithdrawalPenaltyLamportsJSON
120
155
  | UpdateGlobalConfigMode.MinWithdrawalPenaltyBPSJSON
156
+
157
+ export { ReserveType }
158
+
159
+ /**
160
+ * The type of the reserve determine how investing and uninvesting (mechanisms + the way to compute how much should be invested/uninvested) works
161
+ *
162
+ * Standard:
163
+ * - investing happens through the `invest` handler and the amount invested is computed based on the weight of the reserve, from the vault AUM - the amount invested in virtual reserves
164
+ *
165
+ * Virtual (i.e. the allocation can be moved to that reserve if needed, so it is virtually there but will be allocated only if needed by a borrow order or reserve withdrawal ticket):
166
+ * - investing in a virtual reserve doesn't happen through the `invest` handler but using a dedicated handler which ensures that the amount to be invested fills (fully or partially) a borrow order or a reserve withdrawal ticket
167
+ * - has a higher allocation priority comparing to the Standard reserves and can disinvest from a Standard reserve and invest into the Virtual one if needed
168
+ * -the weight is not used for virtual reserves, only the cap is limiting the amount that can be invested in the reserve, and calling `invest` on a virtual reserve will disinvest if the amount invested exceeds the cap
169
+ * - current main use case is for fixed term reserves, such that the manager decides their desired max exposure to a fixed term reserve and anytime there is an order or withdrawal ticket we invest into the fixed term reserve until the cap is reached or the order/ticket is filled
170
+ */
171
+ export type ReserveTypeKind = ReserveType.Standard | ReserveType.Virtual
172
+ export type ReserveTypeJSON = ReserveType.StandardJSON | ReserveType.VirtualJSON
@@ -23,6 +23,7 @@ import {
23
23
  depositReserveLiquidity,
24
24
  depositReserveLiquidityAndObligationCollateral,
25
25
  depositReserveLiquidityAndObligationCollateralV2,
26
+ enqueueToWithdraw,
26
27
  initObligation,
27
28
  initObligationFarmsForReserve,
28
29
  InitObligationFarmsForReserveAccounts,
@@ -46,6 +47,7 @@ import {
46
47
  setObligationOrder,
47
48
  withdrawObligationCollateralAndRedeemReserveCollateral,
48
49
  withdrawObligationCollateralAndRedeemReserveCollateralV2,
50
+ withdrawQueuedLiquidity,
49
51
  withdrawReferrerFees,
50
52
  } from '../@codegen/klend/instructions';
51
53
  import {
@@ -58,17 +60,19 @@ import {
58
60
  isNotNullPubkey,
59
61
  obligationFarmStatePda,
60
62
  ObligationType,
63
+ ownerQueuedCollateralVaultPda,
61
64
  referrerTokenStatePda,
62
65
  ScopePriceRefreshConfig,
63
66
  SOL_PADDING_FOR_INTEREST,
64
67
  U64_MAX,
65
68
  userMetadataPda,
69
+ withdrawTicketPda,
66
70
  WRAPPED_SOL_MINT,
67
71
  } from '../utils';
68
72
  import { getTokenIdsForScopeRefresh, KaminoMarket } from './market';
69
73
  import { isKaminoObligation, KaminoObligation } from './obligation';
70
74
  import { KaminoReserve } from './reserve';
71
- import { ReserveFarmKind } from '../@codegen/klend/types';
75
+ import { ProgressCallbackType, ReserveFarmKind } from '../@codegen/klend/types';
72
76
  import { PROGRAM_ID as FARMS_PROGRAM_ID } from '@kamino-finance/farms-sdk/dist/@codegen/farms/programId';
73
77
  import { Reserve } from '../@codegen/klend/accounts';
74
78
  import { VanillaObligation } from '../utils/ObligationType';
@@ -1174,6 +1178,116 @@ export class KaminoAction {
1174
1178
  );
1175
1179
  }
1176
1180
 
1181
+ /**
1182
+ * Builds an instruction for enqueueing a withdrawal request to the withdraw queue.
1183
+ * This is used when there isn't enough liquidity to immediately withdraw.
1184
+ */
1185
+ static async buildEnqueueToWithdrawIx(
1186
+ owner: TransactionSigner,
1187
+ kaminoMarket: KaminoMarket,
1188
+ reserve: KaminoReserve,
1189
+ collateralAmount: BN,
1190
+ userDestinationLiquidityTa: Address,
1191
+ progressCallbackType: ProgressCallbackType.None | ProgressCallbackType.KlendQueueAccountingHandlerOnKvault = new ProgressCallbackType.None(),
1192
+ progressCallbackCustomAccount0: Option<Address> = none(),
1193
+ progressCallbackCustomAccount1: Option<Address> = none()
1194
+ ): Promise<Instruction> {
1195
+ const lendingMarketAuthority = await kaminoMarket.getLendingMarketAuthority();
1196
+ const userSourceCollateralTa = await getAssociatedTokenAddress(reserve.getCTokenMint(), owner.address);
1197
+ const withdrawTicket = await withdrawTicketPda(
1198
+ reserve.address,
1199
+ BigInt(reserve.state.withdrawQueue.nextIssuedTicketSequenceNumber.toString()),
1200
+ kaminoMarket.programId
1201
+ );
1202
+ const ownerQueuedCollateralVault = await ownerQueuedCollateralVaultPda(
1203
+ reserve.address,
1204
+ owner.address,
1205
+ kaminoMarket.programId
1206
+ );
1207
+
1208
+ return enqueueToWithdraw(
1209
+ {
1210
+ collateralAmount,
1211
+ progressCallbackType,
1212
+ },
1213
+ {
1214
+ owner,
1215
+ lendingMarket: kaminoMarket.getAddress(),
1216
+ lendingMarketAuthority,
1217
+ reserve: reserve.address,
1218
+ userSourceCollateralTa,
1219
+ userDestinationLiquidityTa,
1220
+ reserveLiquidityMint: reserve.getLiquidityMint(),
1221
+ reserveCollateralMint: reserve.getCTokenMint(),
1222
+ collateralTokenProgram: TOKEN_PROGRAM_ADDRESS,
1223
+ withdrawTicket,
1224
+ ownerQueuedCollateralVault,
1225
+ systemProgram: SYSTEM_PROGRAM_ADDRESS,
1226
+ progressCallbackCustomAccount0,
1227
+ progressCallbackCustomAccount1,
1228
+ },
1229
+ undefined,
1230
+ kaminoMarket.programId
1231
+ );
1232
+ }
1233
+
1234
+ /**
1235
+ * Builds an instruction for withdrawing queued liquidity (permissionless).
1236
+ * This allows anyone to process a withdraw ticket when liquidity becomes available.
1237
+ */
1238
+ static async buildWithdrawQueuedLiquidityIx(
1239
+ payer: TransactionSigner,
1240
+ kaminoMarket: KaminoMarket,
1241
+ reserve: KaminoReserve,
1242
+ withdrawTicket: Address,
1243
+ withdrawTicketOwner: Address,
1244
+ userDestinationLiquidity: Address,
1245
+ progressCallbackProgram: Option<Address> = none(),
1246
+ progressCallbackCustomAccount0: Option<Address> = none(),
1247
+ progressCallbackCustomAccount1: Option<Address> = none()
1248
+ ): Promise<Instruction> {
1249
+ const lendingMarketAuthority = await kaminoMarket.getLendingMarketAuthority();
1250
+ const resolvedProgressCallbackProgram = isNone(progressCallbackProgram)
1251
+ ? some(SYSTEM_PROGRAM_ADDRESS)
1252
+ : progressCallbackProgram;
1253
+ const resolvedProgressCallbackCustomAccount0 = isNone(progressCallbackCustomAccount0)
1254
+ ? some(SYSTEM_PROGRAM_ADDRESS)
1255
+ : progressCallbackCustomAccount0;
1256
+ const resolvedProgressCallbackCustomAccount1 = isNone(progressCallbackCustomAccount1)
1257
+ ? some(SYSTEM_PROGRAM_ADDRESS)
1258
+ : progressCallbackCustomAccount1;
1259
+ const ownerQueuedCollateralVault = await ownerQueuedCollateralVaultPda(
1260
+ reserve.address,
1261
+ withdrawTicketOwner,
1262
+ kaminoMarket.programId
1263
+ );
1264
+
1265
+ return withdrawQueuedLiquidity(
1266
+ {
1267
+ payer,
1268
+ lendingMarket: kaminoMarket.getAddress(),
1269
+ lendingMarketAuthority,
1270
+ reserve: reserve.address,
1271
+ reserveLiquidityMint: reserve.getLiquidityMint(),
1272
+ reserveCollateralMint: reserve.getCTokenMint(),
1273
+ reserveLiquiditySupply: reserve.state.liquidity.supplyVault,
1274
+ ownerQueuedCollateralVault,
1275
+ userDestinationLiquidity,
1276
+ collateralTokenProgram: TOKEN_PROGRAM_ADDRESS,
1277
+ liquidityTokenProgram: reserve.getLiquidityTokenProgram(),
1278
+ withdrawTicket,
1279
+ withdrawTicketOwner,
1280
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
1281
+ systemProgram: SYSTEM_PROGRAM_ADDRESS,
1282
+ progressCallbackProgram: resolvedProgressCallbackProgram,
1283
+ progressCallbackCustomAccount0: resolvedProgressCallbackCustomAccount0,
1284
+ progressCallbackCustomAccount1: resolvedProgressCallbackCustomAccount1,
1285
+ },
1286
+ undefined,
1287
+ kaminoMarket.programId
1288
+ );
1289
+ }
1290
+
1177
1291
  async addDepositReserveLiquidityIx() {
1178
1292
  this.lendingIxsLabels.push(`depositReserveLiquidity`);
1179
1293
  this.lendingIxs.push(