@kamino-finance/klend-sdk 7.1.4-beta.0 → 7.1.4

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 (240) hide show
  1. package/dist/@codegen/klend/accounts/LendingMarket.d.ts +3 -144
  2. package/dist/@codegen/klend/accounts/LendingMarket.d.ts.map +1 -1
  3. package/dist/@codegen/klend/accounts/LendingMarket.js +3 -105
  4. package/dist/@codegen/klend/accounts/LendingMarket.js.map +1 -1
  5. package/dist/@codegen/klend/accounts/Obligation.d.ts +15 -30
  6. package/dist/@codegen/klend/accounts/Obligation.d.ts.map +1 -1
  7. package/dist/@codegen/klend/accounts/Obligation.js +21 -31
  8. package/dist/@codegen/klend/accounts/Obligation.js.map +1 -1
  9. package/dist/@codegen/klend/accounts/Reserve.d.ts +0 -6
  10. package/dist/@codegen/klend/accounts/Reserve.d.ts.map +1 -1
  11. package/dist/@codegen/klend/accounts/Reserve.js +2 -9
  12. package/dist/@codegen/klend/accounts/Reserve.js.map +1 -1
  13. package/dist/@codegen/klend/accounts/UserState.d.ts +75 -0
  14. package/dist/@codegen/klend/accounts/UserState.d.ts.map +1 -1
  15. package/dist/@codegen/klend/accounts/UserState.js +25 -0
  16. package/dist/@codegen/klend/accounts/UserState.js.map +1 -1
  17. package/dist/@codegen/klend/accounts/index.d.ts +0 -6
  18. package/dist/@codegen/klend/accounts/index.d.ts.map +1 -1
  19. package/dist/@codegen/klend/accounts/index.js +1 -7
  20. package/dist/@codegen/klend/accounts/index.js.map +1 -1
  21. package/dist/@codegen/klend/errors/custom.d.ts +2 -226
  22. package/dist/@codegen/klend/errors/custom.d.ts.map +1 -1
  23. package/dist/@codegen/klend/errors/custom.js +3 -396
  24. package/dist/@codegen/klend/errors/custom.js.map +1 -1
  25. package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts +2 -1
  26. package/dist/@codegen/klend/instructions/idlMissingTypes.d.ts.map +1 -1
  27. package/dist/@codegen/klend/instructions/idlMissingTypes.js +2 -6
  28. package/dist/@codegen/klend/instructions/idlMissingTypes.js.map +1 -1
  29. package/dist/@codegen/klend/instructions/index.d.ts +0 -16
  30. package/dist/@codegen/klend/instructions/index.d.ts.map +1 -1
  31. package/dist/@codegen/klend/instructions/index.js +1 -18
  32. package/dist/@codegen/klend/instructions/index.js.map +1 -1
  33. package/dist/@codegen/klend/instructions/initReserve.d.ts +1 -1
  34. package/dist/@codegen/klend/instructions/initReserve.d.ts.map +1 -1
  35. package/dist/@codegen/klend/instructions/initReserve.js +5 -1
  36. package/dist/@codegen/klend/instructions/initReserve.js.map +1 -1
  37. package/dist/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateral.js +1 -1
  38. package/dist/@codegen/klend/instructions/updateGlobalConfig.d.ts +1 -1
  39. package/dist/@codegen/klend/instructions/updateGlobalConfig.d.ts.map +1 -1
  40. package/dist/@codegen/klend/instructions/updateGlobalConfig.js +0 -1
  41. package/dist/@codegen/klend/instructions/updateGlobalConfig.js.map +1 -1
  42. package/dist/@codegen/klend/instructions/updateReserveConfig.d.ts +1 -1
  43. package/dist/@codegen/klend/instructions/updateReserveConfig.d.ts.map +1 -1
  44. package/dist/@codegen/klend/instructions/updateReserveConfig.js +0 -1
  45. package/dist/@codegen/klend/instructions/updateReserveConfig.js.map +1 -1
  46. package/dist/@codegen/klend/instructions/withdrawObligationCollateral.js +1 -1
  47. package/dist/@codegen/klend/instructions/withdrawObligationCollateralV2.js +1 -1
  48. package/dist/@codegen/klend/types/AssetTier.d.ts +45 -0
  49. package/dist/@codegen/klend/types/AssetTier.d.ts.map +1 -0
  50. package/dist/@codegen/klend/types/AssetTier.js +132 -0
  51. package/dist/@codegen/klend/types/AssetTier.js.map +1 -0
  52. package/dist/@codegen/klend/types/ObligationLiquidity.d.ts +5 -35
  53. package/dist/@codegen/klend/types/ObligationLiquidity.d.ts.map +1 -1
  54. package/dist/@codegen/klend/types/ObligationLiquidity.js +7 -17
  55. package/dist/@codegen/klend/types/ObligationLiquidity.js.map +1 -1
  56. package/dist/@codegen/klend/types/ObligationOrder.d.ts +4 -4
  57. package/dist/@codegen/klend/types/ObligationOrder.js +2 -2
  58. package/dist/@codegen/klend/types/ReserveConfig.d.ts +29 -141
  59. package/dist/@codegen/klend/types/ReserveConfig.d.ts.map +1 -1
  60. package/dist/@codegen/klend/types/ReserveConfig.js +25 -89
  61. package/dist/@codegen/klend/types/ReserveConfig.js.map +1 -1
  62. package/dist/@codegen/klend/types/ReserveFees.d.ts +8 -8
  63. package/dist/@codegen/klend/types/ReserveFees.d.ts.map +1 -1
  64. package/dist/@codegen/klend/types/ReserveFees.js +8 -8
  65. package/dist/@codegen/klend/types/ReserveFees.js.map +1 -1
  66. package/dist/@codegen/klend/types/ReserveLiquidity.d.ts +8 -26
  67. package/dist/@codegen/klend/types/ReserveLiquidity.d.ts.map +1 -1
  68. package/dist/@codegen/klend/types/ReserveLiquidity.js +8 -14
  69. package/dist/@codegen/klend/types/ReserveLiquidity.js.map +1 -1
  70. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts +14 -92
  71. package/dist/@codegen/klend/types/UpdateConfigMode.d.ts.map +1 -1
  72. package/dist/@codegen/klend/types/UpdateConfigMode.js +23 -168
  73. package/dist/@codegen/klend/types/UpdateConfigMode.js.map +1 -1
  74. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts +0 -130
  75. package/dist/@codegen/klend/types/UpdateLendingMarketMode.d.ts.map +1 -1
  76. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js +1 -241
  77. package/dist/@codegen/klend/types/UpdateLendingMarketMode.js.map +1 -1
  78. package/dist/@codegen/klend/types/index.d.ts +8 -10
  79. package/dist/@codegen/klend/types/index.d.ts.map +1 -1
  80. package/dist/@codegen/klend/types/index.js +3 -7
  81. package/dist/@codegen/klend/types/index.js.map +1 -1
  82. package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts +4 -9
  83. package/dist/@codegen/klend/zero_padding/ObligationZP.d.ts.map +1 -1
  84. package/dist/@codegen/klend/zero_padding/ObligationZP.js +13 -22
  85. package/dist/@codegen/klend/zero_padding/ObligationZP.js.map +1 -1
  86. package/dist/classes/action.d.ts +3 -30
  87. package/dist/classes/action.d.ts.map +1 -1
  88. package/dist/classes/action.js +10 -364
  89. package/dist/classes/action.js.map +1 -1
  90. package/dist/classes/manager.d.ts.map +1 -1
  91. package/dist/classes/manager.js +0 -10
  92. package/dist/classes/manager.js.map +1 -1
  93. package/dist/classes/market.d.ts +2 -6
  94. package/dist/classes/market.d.ts.map +1 -1
  95. package/dist/classes/market.js +6 -26
  96. package/dist/classes/market.js.map +1 -1
  97. package/dist/classes/obligation.js +1 -1
  98. package/dist/classes/obligation.js.map +1 -1
  99. package/dist/classes/reserve.d.ts.map +1 -1
  100. package/dist/classes/reserve.js +7 -13
  101. package/dist/classes/reserve.js.map +1 -1
  102. package/dist/classes/unstakingPool.d.ts +3 -20
  103. package/dist/classes/unstakingPool.d.ts.map +1 -1
  104. package/dist/classes/unstakingPool.js +8 -62
  105. package/dist/classes/unstakingPool.js.map +1 -1
  106. package/dist/classes/vault.d.ts +1 -1
  107. package/dist/classes/vault.d.ts.map +1 -1
  108. package/dist/classes/vault.js +46 -28
  109. package/dist/classes/vault.js.map +1 -1
  110. package/dist/idl/klend.json +293 -2186
  111. package/dist/lending_operations/index.d.ts +0 -1
  112. package/dist/lending_operations/index.d.ts.map +1 -1
  113. package/dist/lending_operations/index.js +0 -1
  114. package/dist/lending_operations/index.js.map +1 -1
  115. package/dist/manager/client_kamino_manager.js +9 -12
  116. package/dist/manager/client_kamino_manager.js.map +1 -1
  117. package/dist/utils/ata.d.ts +10 -1
  118. package/dist/utils/ata.d.ts.map +1 -1
  119. package/dist/utils/ata.js +47 -0
  120. package/dist/utils/ata.js.map +1 -1
  121. package/dist/utils/managerTypes.d.ts.map +1 -1
  122. package/dist/utils/managerTypes.js +4 -9
  123. package/dist/utils/managerTypes.js.map +1 -1
  124. package/dist/utils/seeds.d.ts +14 -10
  125. package/dist/utils/seeds.d.ts.map +1 -1
  126. package/dist/utils/seeds.js +22 -25
  127. package/dist/utils/seeds.js.map +1 -1
  128. package/package.json +1 -1
  129. package/src/@codegen/klend/accounts/LendingMarket.ts +5 -210
  130. package/src/@codegen/klend/accounts/Obligation.ts +31 -53
  131. package/src/@codegen/klend/accounts/Reserve.ts +2 -13
  132. package/src/@codegen/klend/accounts/UserState.ts +75 -0
  133. package/src/@codegen/klend/accounts/index.ts +0 -6
  134. package/src/@codegen/klend/errors/custom.ts +2 -427
  135. package/src/@codegen/klend/instructions/idlMissingTypes.ts +4 -7
  136. package/src/@codegen/klend/instructions/index.ts +0 -34
  137. package/src/@codegen/klend/instructions/initReserve.ts +6 -2
  138. package/src/@codegen/klend/instructions/liquidateObligationAndRedeemReserveCollateral.ts +1 -1
  139. package/src/@codegen/klend/instructions/updateGlobalConfig.ts +1 -2
  140. package/src/@codegen/klend/instructions/updateReserveConfig.ts +1 -2
  141. package/src/@codegen/klend/instructions/withdrawObligationCollateral.ts +1 -1
  142. package/src/@codegen/klend/instructions/withdrawObligationCollateralV2.ts +1 -1
  143. package/src/@codegen/klend/types/AssetTier.ts +119 -0
  144. package/src/@codegen/klend/types/ObligationLiquidity.ts +9 -39
  145. package/src/@codegen/klend/types/ObligationOrder.ts +4 -4
  146. package/src/@codegen/klend/types/ReserveConfig.ts +39 -171
  147. package/src/@codegen/klend/types/ReserveFees.ts +12 -12
  148. package/src/@codegen/klend/types/ReserveLiquidity.ts +12 -30
  149. package/src/@codegen/klend/types/UpdateConfigMode.ts +26 -206
  150. package/src/@codegen/klend/types/UpdateLendingMarketMode.ts +0 -300
  151. package/src/@codegen/klend/types/index.ts +16 -45
  152. package/src/@codegen/klend/zero_padding/ObligationZP.ts +13 -22
  153. package/src/classes/action.ts +8 -577
  154. package/src/classes/manager.ts +0 -11
  155. package/src/classes/market.ts +5 -36
  156. package/src/classes/obligation.ts +1 -1
  157. package/src/classes/reserve.ts +8 -13
  158. package/src/classes/unstakingPool.ts +6 -83
  159. package/src/classes/vault.ts +57 -38
  160. package/src/idl/klend.json +294 -2187
  161. package/src/lending_operations/index.ts +0 -1
  162. package/src/manager/client_kamino_manager.ts +9 -13
  163. package/src/utils/ata.ts +79 -0
  164. package/src/utils/managerTypes.ts +4 -9
  165. package/src/utils/seeds.ts +26 -28
  166. package/dist/@codegen/klend/accounts/PoolState.d.ts +0 -53
  167. package/dist/@codegen/klend/accounts/PoolState.d.ts.map +0 -1
  168. package/dist/@codegen/klend/accounts/PoolState.js +0 -167
  169. package/dist/@codegen/klend/accounts/PoolState.js.map +0 -1
  170. package/dist/@codegen/klend/accounts/UnstakeTicket.d.ts +0 -41
  171. package/dist/@codegen/klend/accounts/UnstakeTicket.d.ts.map +0 -1
  172. package/dist/@codegen/klend/accounts/UnstakeTicket.js +0 -143
  173. package/dist/@codegen/klend/accounts/UnstakeTicket.js.map +0 -1
  174. package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts +0 -132
  175. package/dist/@codegen/klend/accounts/WithdrawTicket.d.ts.map +0 -1
  176. package/dist/@codegen/klend/accounts/WithdrawTicket.js +0 -191
  177. package/dist/@codegen/klend/accounts/WithdrawTicket.js.map +0 -1
  178. package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts +0 -39
  179. package/dist/@codegen/klend/instructions/enqueueToWithdraw.d.ts.map +0 -1
  180. package/dist/@codegen/klend/instructions/enqueueToWithdraw.js +0 -67
  181. package/dist/@codegen/klend/instructions/enqueueToWithdraw.js.map +0 -1
  182. package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts +0 -36
  183. package/dist/@codegen/klend/instructions/fillBorrowOrder.d.ts.map +0 -1
  184. package/dist/@codegen/klend/instructions/fillBorrowOrder.js +0 -49
  185. package/dist/@codegen/klend/instructions/fillBorrowOrder.js.map +0 -1
  186. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts +0 -47
  187. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.d.ts.map +0 -1
  188. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js +0 -66
  189. package/dist/@codegen/klend/instructions/recoverInvalidTicketCollateral.js.map +0 -1
  190. package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts +0 -31
  191. package/dist/@codegen/klend/instructions/setBorrowOrder.d.ts.map +0 -1
  192. package/dist/@codegen/klend/instructions/setBorrowOrder.js +0 -64
  193. package/dist/@codegen/klend/instructions/setBorrowOrder.js.map +0 -1
  194. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.d.ts +0 -53
  195. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.d.ts.map +0 -1
  196. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.js +0 -190
  197. package/dist/@codegen/klend/instructions/unstakeLstCollateralEnd.js.map +0 -1
  198. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.d.ts +0 -70
  199. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.d.ts.map +0 -1
  200. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.js +0 -261
  201. package/dist/@codegen/klend/instructions/unstakeLstCollateralStart.js.map +0 -1
  202. package/dist/@codegen/klend/instructions/withdrawObligationUsol.d.ts +0 -41
  203. package/dist/@codegen/klend/instructions/withdrawObligationUsol.d.ts.map +0 -1
  204. package/dist/@codegen/klend/instructions/withdrawObligationUsol.js +0 -135
  205. package/dist/@codegen/klend/instructions/withdrawObligationUsol.js.map +0 -1
  206. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts +0 -51
  207. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.d.ts.map +0 -1
  208. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js +0 -28
  209. package/dist/@codegen/klend/instructions/withdrawQueuedLiquidity.js.map +0 -1
  210. package/dist/@codegen/klend/types/BorrowOrder.d.ts +0 -192
  211. package/dist/@codegen/klend/types/BorrowOrder.d.ts.map +0 -1
  212. package/dist/@codegen/klend/types/BorrowOrder.js +0 -194
  213. package/dist/@codegen/klend/types/BorrowOrder.js.map +0 -1
  214. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts +0 -39
  215. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.d.ts.map +0 -1
  216. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js +0 -100
  217. package/dist/@codegen/klend/types/BorrowOrderConfigArgs.js.map +0 -1
  218. package/dist/@codegen/klend/types/WithdrawQueue.d.ts +0 -64
  219. package/dist/@codegen/klend/types/WithdrawQueue.d.ts.map +0 -1
  220. package/dist/@codegen/klend/types/WithdrawQueue.js +0 -104
  221. package/dist/@codegen/klend/types/WithdrawQueue.js.map +0 -1
  222. package/dist/lending_operations/unstake_lst_collateral.d.ts +0 -12
  223. package/dist/lending_operations/unstake_lst_collateral.d.ts.map +0 -1
  224. package/dist/lending_operations/unstake_lst_collateral.js +0 -104
  225. package/dist/lending_operations/unstake_lst_collateral.js.map +0 -1
  226. package/src/@codegen/klend/accounts/PoolState.ts +0 -192
  227. package/src/@codegen/klend/accounts/UnstakeTicket.ts +0 -160
  228. package/src/@codegen/klend/accounts/WithdrawTicket.ts +0 -256
  229. package/src/@codegen/klend/instructions/enqueueToWithdraw.ts +0 -89
  230. package/src/@codegen/klend/instructions/fillBorrowOrder.ts +0 -96
  231. package/src/@codegen/klend/instructions/recoverInvalidTicketCollateral.ts +0 -96
  232. package/src/@codegen/klend/instructions/setBorrowOrder.ts +0 -77
  233. package/src/@codegen/klend/instructions/unstakeLstCollateralEnd.ts +0 -251
  234. package/src/@codegen/klend/instructions/unstakeLstCollateralStart.ts +0 -353
  235. package/src/@codegen/klend/instructions/withdrawObligationUsol.ts +0 -168
  236. package/src/@codegen/klend/instructions/withdrawQueuedLiquidity.ts +0 -92
  237. package/src/@codegen/klend/types/BorrowOrder.ts +0 -267
  238. package/src/@codegen/klend/types/BorrowOrderConfigArgs.ts +0 -87
  239. package/src/@codegen/klend/types/WithdrawQueue.ts +0 -117
  240. package/src/lending_operations/unstake_lst_collateral.ts +0 -174
@@ -1566,17 +1566,6 @@ export const MARKET_UPDATER = new ConfigUpdater(UpdateLendingMarketMode.fromDeco
1566
1566
  [UpdateLendingMarketMode.UpdateInitialDepositAmount.kind]: config.minInitialDepositAmount,
1567
1567
  [UpdateLendingMarketMode.UpdateObligationOrderCreationEnabled.kind]: config.obligationOrderCreationEnabled,
1568
1568
  [UpdateLendingMarketMode.UpdateObligationOrderExecutionEnabled.kind]: config.obligationOrderExecutionEnabled,
1569
- [UpdateLendingMarketMode.UpdateMatureReserveDebtLiquidationEnabled.kind]: config.matureReserveDebtLiquidationEnabled,
1570
- [UpdateLendingMarketMode.UpdateObligationBorrowDebtTermLiquidationEnabled.kind]:
1571
- config.obligationBorrowDebtTermLiquidationEnabled,
1572
- [UpdateLendingMarketMode.UpdateProposerAuthority.kind]: config.proposerAuthority,
1573
- [UpdateLendingMarketMode.UpdateBorrowOrderCreationEnabled.kind]: config.borrowOrderCreationEnabled,
1574
- [UpdateLendingMarketMode.UpdateBorrowOrderExecutionEnabled.kind]: config.borrowOrderExecutionEnabled,
1575
- [UpdateLendingMarketMode.UpdatePriceTriggeredLiquidationDisabled.kind]: config.priceTriggeredLiquidationDisabled,
1576
- [UpdateLendingMarketMode.UpdateUnstakingPoolState.kind]: config.unstakingPoolState,
1577
- [UpdateLendingMarketMode.UpdateWithdrawTicketIssuanceEnabled.kind]: config.withdrawTicketIssuanceEnabled,
1578
- [UpdateLendingMarketMode.UpdateWithdrawTicketRedemptionEnabled.kind]: config.withdrawTicketRedemptionEnabled,
1579
- [UpdateLendingMarketMode.UpdateMinWithdrawQueuedLiquidityValue.kind]: config.minWithdrawQueuedLiquidityValue,
1580
1569
  }));
1581
1570
 
1582
1571
  function parseForChangesMarketConfigAndGetIxs(
@@ -54,8 +54,6 @@ import { parseTokenSymbol, parseZeroPaddedUtf8 } from './utils';
54
54
  import { ObligationZP } from '../@codegen/klend/zero_padding';
55
55
  import { checkDefined } from '../utils/validations';
56
56
  import { Buffer } from 'buffer';
57
- import { UNSTAKING_POOL_STAGING_ID, unstakingPoolMintPda } from './unstakingPool';
58
- import { PROGRAM_ID as UNSTAKING_POOL_ID } from '../@codegen/unstaking_pool/programId';
59
57
 
60
58
  export type KaminoMarketRpcApi = GetAccountInfoApi &
61
59
  GetMultipleAccountsApi &
@@ -66,9 +64,6 @@ export type KaminoMarketRpcApi = GetAccountInfoApi &
66
64
  GetBalanceApi;
67
65
 
68
66
  const base58Decoder = getBase58Decoder();
69
- // This is a list of reserves (for STAGING only) that were incorrectly initialized and mess up with the mapping from mint -> reserve
70
- // This can be removed once we migrate all ixs to act upon reserve pubkey instead of mints
71
- export const INCORRECT_RESERVES_STAGING: Address[] = [address('5JPmNb5oxRZF4yp3kQL44HWmZnbyjguRVZbo2ew6FoxV')];
72
67
 
73
68
  export interface ReserveRewardInfo {
74
69
  rewardsPerSecond: Decimal; // not lamport
@@ -235,15 +230,8 @@ export class KaminoMarket {
235
230
  this.reservesActive = getReservesActive(this.reserves);
236
231
  }
237
232
 
238
- async reloadSingleReserve(reservePk: Address, reserveData?: Reserve, programId: Address = PROGRAM_ID): Promise<void> {
239
- const reserve = await getSingleReserve(
240
- reservePk,
241
- this.rpc,
242
- this.recentSlotDurationMs,
243
- reserveData,
244
- undefined,
245
- programId
246
- );
233
+ async reloadSingleReserve(reservePk: Address, reserveData?: Reserve): Promise<void> {
234
+ const reserve = await getSingleReserve(reservePk, this.rpc, this.recentSlotDurationMs, reserveData);
247
235
  this.reserves.set(reservePk, reserve);
248
236
  this.reservesActive.set(reservePk, reserve);
249
237
  }
@@ -256,20 +244,6 @@ export class KaminoMarket {
256
244
  return this.address;
257
245
  }
258
246
 
259
- getUsolPoolAddress(): Address {
260
- return this.state.unstakingPoolState;
261
- }
262
-
263
- getUsolPoolProgramId(): Address {
264
- return this.programId == PROGRAM_ID ? UNSTAKING_POOL_ID : UNSTAKING_POOL_STAGING_ID;
265
- }
266
-
267
- async getUsolPoolMint(): Promise<Address> {
268
- const usolPoolPk = this.getUsolPoolAddress();
269
- const usolPoolProgram = this.getUsolPoolProgramId();
270
- return (await unstakingPoolMintPda(usolPoolPk, usolPoolProgram))[0];
271
- }
272
-
273
247
  /**
274
248
  * Get a list of reserves for this market
275
249
  */
@@ -1610,7 +1584,7 @@ export async function getReservesForMarket(
1610
1584
  recentSlotDurationMs: number,
1611
1585
  oracleAccounts?: AllOracleAccounts
1612
1586
  ): Promise<Map<Address, KaminoReserve>> {
1613
- let reserves = await rpc
1587
+ const reserves = await rpc
1614
1588
  .getProgramAccounts(programId, {
1615
1589
  filters: [
1616
1590
  {
@@ -1627,10 +1601,6 @@ export async function getReservesForMarket(
1627
1601
  encoding: 'base64',
1628
1602
  })
1629
1603
  .send();
1630
- // If staging env always filter the incorrect reserves
1631
- if (programId !== PROGRAM_ID) {
1632
- reserves = reserves.filter((reserve) => INCORRECT_RESERVES_STAGING.includes(reserve.pubkey) === false);
1633
- }
1634
1604
  const deserializedReserves: ReserveWithAddress[] = reserves.map((reserve) => {
1635
1605
  if (reserve.account === null) {
1636
1606
  throw new Error(`Reserve account ${reserve.pubkey} does not exist`);
@@ -1667,10 +1637,9 @@ export async function getSingleReserve(
1667
1637
  rpc: Rpc<KaminoReserveRpcApi>,
1668
1638
  recentSlotDurationMs: number,
1669
1639
  reserveData?: Reserve,
1670
- oracleAccounts?: AllOracleAccounts,
1671
- programId: Address = PROGRAM_ID
1640
+ oracleAccounts?: AllOracleAccounts
1672
1641
  ): Promise<KaminoReserve> {
1673
- const reserve = reserveData ?? (await Reserve.fetch(rpc, reservePk, programId));
1642
+ const reserve = reserveData ?? (await Reserve.fetch(rpc, reservePk));
1674
1643
 
1675
1644
  if (reserve === null) {
1676
1645
  throw new Error(`Reserve account ${reservePk} does not exist`);
@@ -270,7 +270,7 @@ export class KaminoObligation {
270
270
  * Returns obligation orders (including the null ones, i.e. non-active positions in the orders' array).
271
271
  */
272
272
  getOrders(): Array<KaminoObligationOrder | null> {
273
- return this.state.obligationOrders.map((order) => KaminoObligationOrder.fromState(order));
273
+ return this.state.orders.map((order) => KaminoObligationOrder.fromState(order));
274
274
  }
275
275
 
276
276
  /**
@@ -144,7 +144,7 @@ export class KaminoReserve {
144
144
  * @returns the available liquidity amount of the reserve in lamports
145
145
  */
146
146
  getLiquidityAvailableAmount(): Decimal {
147
- return new Decimal(this.state.liquidity.totalAvailableAmount.toString());
147
+ return new Decimal(this.state.liquidity.availableAmount.toString());
148
148
  }
149
149
 
150
150
  /**
@@ -199,7 +199,7 @@ export class KaminoReserve {
199
199
  * @returns the origination fee percentage of the reserve
200
200
  */
201
201
  getBorrowFee = (): Decimal => {
202
- return new Fraction(this.state.config.fees.originationFeeSf).toDecimal();
202
+ return new Fraction(this.state.config.fees.borrowFeeSf).toDecimal();
203
203
  };
204
204
 
205
205
  /**
@@ -1163,12 +1163,13 @@ export async function createReserveIxs(
1163
1163
 
1164
1164
  const { liquiditySupplyVault, collateralMint, collateralSupplyVault, feeVault } = await reservePdas(
1165
1165
  programId,
1166
- reserveAddress.address
1166
+ lendingMarket,
1167
+ liquidityMint
1167
1168
  );
1168
1169
  const [lendingMarketAuthority] = await lendingMarketAuthPda(lendingMarket, programId);
1169
1170
 
1170
1171
  const accounts: InitReserveAccounts = {
1171
- signer: owner,
1172
+ lendingMarketOwner: owner,
1172
1173
  lendingMarket: lendingMarket,
1173
1174
  lendingMarketAuthority: lendingMarketAuthority,
1174
1175
  reserve: reserveAddress.address,
@@ -1221,7 +1222,7 @@ export const RESERVE_CONFIG_UPDATER = new ConfigUpdater(UpdateConfigMode.fromDec
1221
1222
  [UpdateConfigMode.UpdateLiquidationThresholdPct.kind]: config.liquidationThresholdPct,
1222
1223
  [UpdateConfigMode.UpdateProtocolLiquidationFee.kind]: config.protocolLiquidationFeePct,
1223
1224
  [UpdateConfigMode.UpdateProtocolTakeRate.kind]: config.protocolTakeRatePct,
1224
- [UpdateConfigMode.UpdateFeesOriginationFee.kind]: config.fees.originationFeeSf,
1225
+ [UpdateConfigMode.UpdateFeesBorrowFee.kind]: config.fees.borrowFeeSf,
1225
1226
  [UpdateConfigMode.UpdateFeesFlashLoanFee.kind]: config.fees.flashLoanFeeSf,
1226
1227
  [UpdateConfigMode.DeprecatedUpdateFeesReferralFeeBps.kind]: [], // deprecated
1227
1228
  [UpdateConfigMode.UpdateDepositLimit.kind]: config.depositLimit,
@@ -1255,7 +1256,7 @@ export const RESERVE_CONFIG_UPDATER = new ConfigUpdater(UpdateConfigMode.fromDec
1255
1256
  [UpdateConfigMode.UpdateMinLiquidationBonusBps.kind]: config.minLiquidationBonusBps,
1256
1257
  [UpdateConfigMode.UpdateDeleveragingMarginCallPeriod.kind]: config.deleveragingMarginCallPeriodSecs,
1257
1258
  [UpdateConfigMode.UpdateBorrowFactor.kind]: config.borrowFactorPct,
1258
- [UpdateConfigMode.DeprecatedUpdateAssetTier.kind]: [], //deprecated
1259
+ [UpdateConfigMode.UpdateAssetTier.kind]: config.assetTier,
1259
1260
  [UpdateConfigMode.UpdateElevationGroup.kind]: config.elevationGroups,
1260
1261
  [UpdateConfigMode.UpdateDeleveragingThresholdDecreaseBpsPerDay.kind]: config.deleveragingThresholdDecreaseBpsPerDay,
1261
1262
  [UpdateConfigMode.DeprecatedUpdateMultiplierSideBoost.kind]: [], // deprecated
@@ -1273,12 +1274,6 @@ export const RESERVE_CONFIG_UPDATER = new ConfigUpdater(UpdateConfigMode.fromDec
1273
1274
  [UpdateConfigMode.UpdateAutodeleverageEnabled.kind]: config.autodeleverageEnabled,
1274
1275
  [UpdateConfigMode.UpdateDeleveragingBonusIncreaseBpsPerDay.kind]: config.deleveragingBonusIncreaseBpsPerDay,
1275
1276
  [UpdateConfigMode.UpdateProtocolOrderExecutionFee.kind]: config.protocolOrderExecutionFeePct,
1276
- [UpdateConfigMode.UpdateDebtMaturityTimestamp.kind]: config.debtMaturityTimestamp,
1277
- [UpdateConfigMode.UpdateDebtTermSeconds.kind]: config.debtTermSeconds,
1278
- [UpdateConfigMode.UpdateProposerAuthorityLock.kind]: config.proposerAuthorityLocked,
1279
- [UpdateConfigMode.UpdateMinDeleveragingBonusBps.kind]: config.minDeleveragingBonusBps,
1280
- [UpdateConfigMode.UpdateCanUnstakeLstCollateral.kind]: config.canUnstakeLstCollateral,
1281
- [UpdateConfigMode.UpdateLtvLamportsMargin.kind]: config.ltvLamportsMargin,
1282
1277
  }));
1283
1278
 
1284
1279
  export async function updateEntireReserveConfigIx(
@@ -1350,7 +1345,7 @@ const NON_VALIDATED_DISCRIMINATORS = [
1350
1345
  function shouldSkipValidation(mode: UpdateConfigModeKind, reserve: Reserve | undefined): boolean {
1351
1346
  return (
1352
1347
  NON_VALIDATED_DISCRIMINATORS.includes(mode.discriminator) &&
1353
- !reserve?.liquidity.totalAvailableAmount.gten(MIN_INITIAL_DEPOSIT)
1348
+ !reserve?.liquidity.availableAmount.gten(MIN_INITIAL_DEPOSIT)
1354
1349
  );
1355
1350
  }
1356
1351
 
@@ -17,7 +17,6 @@ import { TOKEN_2022_PROGRAM_ADDRESS } from '@solana-program/token-2022';
17
17
  import { getAssociatedTokenAddress } from '../lib';
18
18
  import { PoolState, UnstakeTicket } from '../@codegen/unstaking_pool/accounts';
19
19
  import {
20
- createAssociatedTokenAccountIdempotentInstruction,
21
20
  createLookupTableIx,
22
21
  DEFAULT_PUBLIC_KEY,
23
22
  extendLookupTableIxs,
@@ -50,7 +49,6 @@ import {
50
49
  Rpc,
51
50
  SolanaRpcApi,
52
51
  TransactionSigner,
53
- getBase58Decoder,
54
52
  } from '@solana/kit';
55
53
  import { getCreateAccountInstruction, SYSTEM_PROGRAM_ADDRESS } from '@solana-program/system';
56
54
  import { SYSVAR_CLOCK_ADDRESS, SYSVAR_INSTRUCTIONS_ADDRESS, SYSVAR_RENT_ADDRESS } from '@solana/sysvars';
@@ -64,29 +62,16 @@ const STAKE_HISTORY_PROGRAM_ID: Address = address('SysvarStakeHistory11111111111
64
62
  const STAKE_ACCOUNT_SIZE: number = 200;
65
63
  export const STAKE_POOL_SIZE: number = 611;
66
64
  const addressEncoder = getAddressEncoder();
67
- const base58Decoder = getBase58Decoder();
68
65
 
69
66
  /**
70
67
  * Unstaking sol mint seed
71
68
  */
72
69
  export const UNSTAKING_SOL_MINT_SEED = Buffer.from('unstaking_sol_mint');
73
70
 
74
- /**
75
- * Unstaking sol mint seed
76
- */
77
- export const UNSTAKING_SOL_WSOL_VAULT_SEED = Buffer.from('wsol_vault');
78
-
79
71
  /**
80
72
  * Unstaking sol pool base authority seed
81
73
  */
82
- export const BASE_POOL_AUTHORITY_SEED = Buffer.from('base_authority');
83
-
84
- /**
85
- * Unstaking sol pool lending market authority seed
86
- */
87
- export const UNSTAKING_POOL_AUTHORITY_SEED = Buffer.from('upa');
88
-
89
- /**
74
+ export const BASE_POOL_AUTHORITY_SEED = Buffer.from('authority');
90
75
 
91
76
  /**
92
77
  * KaminoPoolClient is a class that provides a high-level interface to interact with the Kamino Pool program.
@@ -127,8 +112,8 @@ export class UnstakingPoolClient {
127
112
  });
128
113
 
129
114
  const unstakingSolMint = (await unstakingPoolMintPda(poolState.address))[0];
130
- const basePoolAuthority = (await unstakingPoolBaseAuthorityPda(poolState.address))[0];
131
- const wsolVault = (await unstakingPoolWsolVaultPda(poolState.address))[0];
115
+ const basePoolAuthority = (await unstakingPoolAuthorityPda(poolState.address))[0];
116
+ const wsolVault = await getAssociatedTokenAddress(WRAPPED_SOL_MINT, basePoolAuthority);
132
117
 
133
118
  const initPoolAccounts: InitializePoolAccounts = {
134
119
  admin: poolConfig.admin,
@@ -291,7 +276,6 @@ export class UnstakingPoolClient {
291
276
  * @param stakedSolMint - staked sol mint
292
277
  * @param stakedSolToDeposit - staked sol to convert to USOL (at the pool ratio)
293
278
  * @param minSharesToReceive - parameter to control slippage
294
- * @param initUsolAta - pass if you want the usol ata initialized
295
279
  * @returns burn instruction
296
280
  */
297
281
  async mintIx(
@@ -301,8 +285,7 @@ export class UnstakingPoolClient {
301
285
  unstakeTicket: TransactionSigner,
302
286
  stakedSolMint: Address,
303
287
  stakedSolToDeposit: BN,
304
- minSharesToReceive: BN,
305
- initUsolAta: boolean
288
+ minSharesToReceive: BN
306
289
  ): Promise<MintIxs> {
307
290
  const pool = await poolState.getState(this.getConnection());
308
291
  // Create unstake ticket ix
@@ -357,17 +340,7 @@ export class UnstakingPoolClient {
357
340
  accounts: ixAccounts.concat(remainingAccounts),
358
341
  data: ix.data,
359
342
  };
360
- const ixs = [createUnstakeTicketIx, mintIx];
361
- if (initUsolAta) {
362
- const [_, createAtaIx] = await createAssociatedTokenAccountIdempotentInstruction(
363
- user,
364
- pool.unstakingSolMint,
365
- user.address,
366
- TOKEN_PROGRAM_ADDRESS
367
- );
368
- ixs.splice(1, 0, createAtaIx);
369
- }
370
- return { mintIxs: ixs, additionalSigners: remainingSigners };
343
+ return { mintIxs: [createUnstakeTicketIx, mintIx], additionalSigners: remainingSigners };
371
344
  }
372
345
 
373
346
  /**
@@ -494,46 +467,6 @@ export class UnstakingPool {
494
467
  }
495
468
  }
496
469
 
497
- export async function getAllTicketsForUser(
498
- rpc: Rpc<GetProgramAccountsApi>,
499
- user: Address,
500
- programId: Address = UNSTAKING_POOL_ID
501
- ): Promise<Array<UnstakeTicketInfo>> {
502
- const results = await rpc
503
- .getProgramAccounts(programId, {
504
- filters: [
505
- {
506
- dataSize: BigInt(UnstakeTicket.layout.span + 8),
507
- },
508
- {
509
- memcmp: {
510
- offset: 0n,
511
- bytes: base58Decoder.decode(UnstakeTicket.discriminator) as Base58EncodedBytes,
512
- encoding: 'base58',
513
- },
514
- },
515
- {
516
- memcmp: {
517
- offset: 8n,
518
- bytes: user.toString() as Base58EncodedBytes,
519
- encoding: 'base58',
520
- },
521
- },
522
- ],
523
- encoding: 'base64',
524
- })
525
- .send();
526
-
527
- return results.map((result) => {
528
- return { state: UnstakeTicket.decode(Buffer.from(result.account.data[0], 'base64')), pk: result.pubkey };
529
- });
530
- }
531
-
532
- export type UnstakeTicketInfo = {
533
- pk: Address;
534
- state: UnstakeTicket;
535
- };
536
-
537
470
  export type StakeAccountInfo = {
538
471
  pk: Address;
539
472
  stakeAccount: StakeAccount;
@@ -560,17 +493,7 @@ export function unstakingPoolMintPda(
560
493
  });
561
494
  }
562
495
 
563
- export function unstakingPoolWsolVaultPda(
564
- pool: Address,
565
- programId: Address = UNSTAKING_POOL_ID
566
- ): Promise<ProgramDerivedAddress> {
567
- return getProgramDerivedAddress({
568
- seeds: [UNSTAKING_SOL_WSOL_VAULT_SEED, addressEncoder.encode(pool)],
569
- programAddress: programId,
570
- });
571
- }
572
-
573
- export function unstakingPoolBaseAuthorityPda(
496
+ export function unstakingPoolAuthorityPda(
574
497
  pool: Address,
575
498
  programId: Address = UNSTAKING_POOL_ID
576
499
  ): Promise<ProgramDerivedAddress> {
@@ -21,6 +21,9 @@ import {
21
21
  Slot,
22
22
  SolanaRpcApi,
23
23
  TransactionSigner,
24
+ AccountInfoWithPubkey,
25
+ AccountInfoBase,
26
+ AccountInfoWithJsonData,
24
27
  } from '@solana/kit';
25
28
  import {
26
29
  AllOracleAccounts,
@@ -77,7 +80,10 @@ import { Fraction } from './fraction';
77
80
  import {
78
81
  createAtasIdempotent,
79
82
  createWsolAtaIfMissing,
83
+ getAllStandardTokenProgramTokenAccounts,
80
84
  getKVaultSharesMetadataPda,
85
+ getTokenAccountAmount,
86
+ getTokenAccountMint,
81
87
  lendingMarketAuthPda,
82
88
  SECONDS_PER_YEAR,
83
89
  U64_MAX,
@@ -112,12 +118,7 @@ import {
112
118
  import { getCreateAccountInstruction, SYSTEM_PROGRAM_ADDRESS } from '@solana-program/system';
113
119
  import { getInitializeKVaultSharesMetadataIx, getUpdateSharesMetadataIx, resolveMetadata } from '../utils/metadata';
114
120
  import { decodeVaultState } from '../utils/vault';
115
- import {
116
- fetchAllMaybeToken,
117
- fetchMaybeToken,
118
- findAssociatedTokenPda,
119
- getCloseAccountInstruction,
120
- } from '@solana-program/token-2022';
121
+ import { fetchMaybeToken, findAssociatedTokenPda, getCloseAccountInstruction } from '@solana-program/token-2022';
121
122
  import { TOKEN_PROGRAM_ADDRESS } from '@solana-program/token';
122
123
  import { SYSVAR_INSTRUCTIONS_ADDRESS, SYSVAR_RENT_ADDRESS } from '@solana/sysvars';
123
124
  import { noopSigner } from '../utils/signer';
@@ -1937,15 +1938,22 @@ export class KaminoVaultClient {
1937
1938
  stakedShares: new Decimal(0),
1938
1939
  totalShares: new Decimal(0),
1939
1940
  };
1940
- const userSharesAta = await getAssociatedTokenAddress(vaultState.sharesMint, user);
1941
- const userSharesAccountInfo = await fetchMaybeToken(this.getConnection(), userSharesAta);
1942
- if (userSharesAccountInfo.exists) {
1943
- const userSharesAccount = userSharesAccountInfo.data;
1944
1941
 
1945
- userShares.unstakedShares = new Decimal(userSharesAccount.amount.toString()).div(
1946
- new Decimal(10).pow(vaultState.sharesMintDecimals.toString())
1947
- );
1948
- }
1942
+ const userSharesTokenAccounts = await getAllStandardTokenProgramTokenAccounts(this.getConnection(), user);
1943
+
1944
+ const userSharesTokenAccount = userSharesTokenAccounts.filter((tokenAccount) => {
1945
+ const accountData = tokenAccount.account.data;
1946
+ const mint = getTokenAccountMint(accountData);
1947
+ return mint === vaultState.sharesMint;
1948
+ });
1949
+ userShares.unstakedShares = userSharesTokenAccount.reduce((acc, tokenAccount) => {
1950
+ const accountData = tokenAccount.account.data;
1951
+ const amount = getTokenAccountAmount(accountData);
1952
+ if (amount !== null) {
1953
+ return acc.add(new Decimal(amount));
1954
+ }
1955
+ return acc;
1956
+ }, new Decimal(0));
1949
1957
 
1950
1958
  if (await vault.hasFarm(this.getConnection())) {
1951
1959
  const userSharesInFarm = await getUserSharesInTokensStakedInFarm(
@@ -1984,14 +1992,23 @@ export class KaminoVaultClient {
1984
1992
  // stores vault address for each userSharesAta
1985
1993
  const vaultUserShareBalance = new Map<Address, UserSharesForVault>();
1986
1994
 
1987
- const userSharesAtaArray: Address[] = [];
1995
+ const allUserTokenAccounts = await getAllStandardTokenProgramTokenAccounts(this.getConnection(), user);
1996
+ const userSharesTokenAccountsPerVault = new Map<
1997
+ Address,
1998
+ AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithJsonData>[]
1999
+ >();
1988
2000
  vaults.forEach(async (vault) => {
1989
2001
  const state = vault.state;
1990
2002
  if (!state) {
1991
2003
  throw new Error(`Vault ${vault.address} not fetched`);
1992
2004
  }
1993
- const userSharesAta = await getAssociatedTokenAddress(state.sharesMint, user);
1994
- userSharesAtaArray.push(userSharesAta);
2005
+
2006
+ const userSharesTokenAccounts = allUserTokenAccounts.filter((tokenAccount) => {
2007
+ const accountData = tokenAccount.account.data;
2008
+ const mint = getTokenAccountMint(accountData);
2009
+ return mint === state.sharesMint;
2010
+ });
2011
+ userSharesTokenAccountsPerVault.set(vault.address, userSharesTokenAccounts);
1995
2012
 
1996
2013
  if (await vault.hasFarm(this.getConnection())) {
1997
2014
  const userFarmState = allUserFarmStatesMap.get(state.vaultFarm);
@@ -2015,27 +2032,29 @@ export class KaminoVaultClient {
2015
2032
  }
2016
2033
  });
2017
2034
 
2018
- const userSharesAtaAccounts = await fetchAllMaybeToken(this.getConnection(), userSharesAtaArray);
2019
-
2020
- userSharesAtaAccounts.forEach((userShareAtaAccount, index) => {
2021
- let userSharesForVault = vaultUserShareBalance.get(vaults[index].address);
2022
- if (!userSharesForVault) {
2023
- userSharesForVault = {
2024
- unstakedShares: new Decimal(0),
2025
- stakedShares: new Decimal(0),
2026
- totalShares: new Decimal(0),
2027
- };
2028
- }
2035
+ userSharesTokenAccountsPerVault.forEach((userSharesTokenAccounts, vaultAddress) => {
2036
+ userSharesTokenAccounts.forEach((userSharesTokenAccount) => {
2037
+ let userSharesForVault = vaultUserShareBalance.get(vaultAddress);
2038
+ if (!userSharesForVault) {
2039
+ userSharesForVault = {
2040
+ unstakedShares: new Decimal(0),
2041
+ stakedShares: new Decimal(0),
2042
+ totalShares: new Decimal(0),
2043
+ };
2044
+ }
2029
2045
 
2030
- if (!userShareAtaAccount.exists) {
2031
- vaultUserShareBalance.set(vaults[index].address, userSharesForVault);
2032
- } else {
2033
- userSharesForVault.unstakedShares = new Decimal(userShareAtaAccount.data.amount.toString()).div(
2034
- new Decimal(10).pow(vaults[index].state!.sharesMintDecimals.toString())
2035
- );
2036
- userSharesForVault.totalShares = userSharesForVault.unstakedShares.add(userSharesForVault.stakedShares);
2037
- vaultUserShareBalance.set(vaults[index].address, userSharesForVault);
2038
- }
2046
+ if (!userSharesTokenAccount) {
2047
+ vaultUserShareBalance.set(vaultAddress, userSharesForVault);
2048
+ } else {
2049
+ const accountData = userSharesTokenAccount.account.data;
2050
+ const amount = getTokenAccountAmount(accountData);
2051
+ if (amount !== null) {
2052
+ userSharesForVault.unstakedShares = new Decimal(amount);
2053
+ userSharesForVault.totalShares = userSharesForVault.unstakedShares.add(userSharesForVault.stakedShares);
2054
+ vaultUserShareBalance.set(vaultAddress, userSharesForVault);
2055
+ }
2056
+ }
2057
+ });
2039
2058
  });
2040
2059
 
2041
2060
  return vaultUserShareBalance;
@@ -2849,7 +2868,7 @@ export class KaminoVaultClient {
2849
2868
  }
2850
2869
 
2851
2870
  /**
2852
- * This will return the APY of the vault under the assumption that all the available tokens in the vault are all the time invested in the reserves as ratio; for percentage it needs multiplication by 100
2871
+ * This will return the APY of the vault under the assumption that all the available tokens in the vault are all the time invested in the reserves as requested by the weights; for percentage it needs multiplication by 100
2853
2872
  * @param vault - the kamino vault to get APY for
2854
2873
  * @param slot - current slot
2855
2874
  * @param [vaultReservesMap] - hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves