@kamino-finance/klend-sdk 2.12.0 → 2.12.2-kv-beta

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 (229) hide show
  1. package/dist/classes/action.d.ts +0 -1
  2. package/dist/classes/action.js +70 -104
  3. package/dist/classes/action.js.map +1 -1
  4. package/dist/classes/index.d.ts +2 -0
  5. package/dist/classes/index.js +2 -0
  6. package/dist/classes/index.js.map +1 -1
  7. package/dist/classes/manager.d.ts +158 -0
  8. package/dist/classes/manager.js +374 -0
  9. package/dist/classes/manager.js.map +1 -0
  10. package/dist/classes/obligation.js +0 -21
  11. package/dist/classes/obligation.js.map +1 -1
  12. package/dist/classes/reserve.d.ts +13 -35
  13. package/dist/classes/reserve.js +747 -73
  14. package/dist/classes/reserve.js.map +1 -1
  15. package/dist/classes/vault.d.ts +69 -0
  16. package/dist/classes/vault.js +433 -0
  17. package/dist/classes/vault.js.map +1 -0
  18. package/dist/client_kamino_manager.d.ts +11 -0
  19. package/dist/client_kamino_manager.js +350 -0
  20. package/dist/client_kamino_manager.js.map +1 -0
  21. package/dist/idl.json +98 -280
  22. package/dist/idl_codegen/accounts/LendingMarket.d.ts +3 -3
  23. package/dist/idl_codegen/accounts/LendingMarket.js +1 -7
  24. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  25. package/dist/idl_codegen/accounts/Obligation.d.ts +3 -6
  26. package/dist/idl_codegen/accounts/Obligation.js +6 -12
  27. package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
  28. package/dist/idl_codegen/accounts/Reserve.d.ts +0 -18
  29. package/dist/idl_codegen/accounts/Reserve.js +2 -14
  30. package/dist/idl_codegen/accounts/Reserve.js.map +1 -1
  31. package/dist/idl_codegen/errors/custom.d.ts +4 -84
  32. package/dist/idl_codegen/errors/custom.js +8 -139
  33. package/dist/idl_codegen/errors/custom.js.map +1 -1
  34. package/dist/idl_codegen/instructions/borrowObligationLiquidity.d.ts +0 -1
  35. package/dist/idl_codegen/instructions/borrowObligationLiquidity.js +0 -5
  36. package/dist/idl_codegen/instructions/borrowObligationLiquidity.js.map +1 -1
  37. package/dist/idl_codegen/instructions/depositReserveLiquidity.d.ts +1 -3
  38. package/dist/idl_codegen/instructions/depositReserveLiquidity.js +1 -15
  39. package/dist/idl_codegen/instructions/depositReserveLiquidity.js.map +1 -1
  40. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.d.ts +1 -3
  41. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js +1 -15
  42. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -1
  43. package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.d.ts +0 -2
  44. package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.js +0 -5
  45. package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.js.map +1 -1
  46. package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.d.ts +0 -2
  47. package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.js +0 -5
  48. package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.js.map +1 -1
  49. package/dist/idl_codegen/instructions/index.d.ts +4 -2
  50. package/dist/idl_codegen/instructions/index.js +5 -3
  51. package/dist/idl_codegen/instructions/index.js.map +1 -1
  52. package/dist/idl_codegen/instructions/initFarmsForReserve.d.ts +1 -0
  53. package/dist/idl_codegen/instructions/initFarmsForReserve.js +1 -0
  54. package/dist/idl_codegen/instructions/initFarmsForReserve.js.map +1 -1
  55. package/dist/idl_codegen/instructions/initObligation.d.ts +1 -0
  56. package/dist/idl_codegen/instructions/initObligation.js +1 -0
  57. package/dist/idl_codegen/instructions/initObligation.js.map +1 -1
  58. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.d.ts +1 -0
  59. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js +1 -0
  60. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js.map +1 -1
  61. package/dist/idl_codegen/instructions/initReserve.d.ts +1 -2
  62. package/dist/idl_codegen/instructions/initReserve.js +1 -10
  63. package/dist/idl_codegen/instructions/initReserve.js.map +1 -1
  64. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.d.ts +2 -6
  65. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js +3 -27
  66. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
  67. package/dist/idl_codegen/instructions/redeemFees.d.ts +0 -1
  68. package/dist/idl_codegen/instructions/redeemFees.js +0 -5
  69. package/dist/idl_codegen/instructions/redeemFees.js.map +1 -1
  70. package/dist/idl_codegen/instructions/redeemReserveCollateral.d.ts +1 -3
  71. package/dist/idl_codegen/instructions/redeemReserveCollateral.js +1 -15
  72. package/dist/idl_codegen/instructions/redeemReserveCollateral.js.map +1 -1
  73. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts +1 -0
  74. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js +1 -0
  75. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
  76. package/dist/idl_codegen/instructions/repayObligationLiquidity.d.ts +0 -1
  77. package/dist/idl_codegen/instructions/repayObligationLiquidity.js +0 -5
  78. package/dist/idl_codegen/instructions/repayObligationLiquidity.js.map +1 -1
  79. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +1 -2
  80. package/dist/idl_codegen/instructions/updateReserveConfig.js +2 -4
  81. package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
  82. package/dist/idl_codegen/instructions/withdrawObligationCollateral.js +1 -1
  83. package/dist/idl_codegen/instructions/withdrawObligationCollateral.js.map +1 -1
  84. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.d.ts +1 -3
  85. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +1 -15
  86. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
  87. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +0 -1
  88. package/dist/idl_codegen/instructions/withdrawProtocolFee.js +0 -5
  89. package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
  90. package/dist/idl_codegen/instructions/withdrawReferrerFees.d.ts +0 -1
  91. package/dist/idl_codegen/instructions/withdrawReferrerFees.js +0 -5
  92. package/dist/idl_codegen/instructions/withdrawReferrerFees.js.map +1 -1
  93. package/dist/idl_codegen/programId.d.ts +1 -2
  94. package/dist/idl_codegen/programId.js +1 -5
  95. package/dist/idl_codegen/programId.js.map +1 -1
  96. package/dist/idl_codegen/types/ElevationGroup.d.ts +10 -24
  97. package/dist/idl_codegen/types/ElevationGroup.js +12 -25
  98. package/dist/idl_codegen/types/ElevationGroup.js.map +1 -1
  99. package/dist/idl_codegen/types/ObligationCollateral.d.ts +0 -23
  100. package/dist/idl_codegen/types/ObligationCollateral.js +1 -8
  101. package/dist/idl_codegen/types/ObligationCollateral.js.map +1 -1
  102. package/dist/idl_codegen/types/ObligationLiquidity.d.ts +0 -8
  103. package/dist/idl_codegen/types/ObligationLiquidity.js +1 -8
  104. package/dist/idl_codegen/types/ObligationLiquidity.js.map +1 -1
  105. package/dist/idl_codegen/types/ReserveConfig.d.ts +9 -55
  106. package/dist/idl_codegen/types/ReserveConfig.js +6 -20
  107. package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
  108. package/dist/idl_codegen/types/ReserveLiquidity.d.ts +0 -8
  109. package/dist/idl_codegen/types/ReserveLiquidity.js +1 -7
  110. package/dist/idl_codegen/types/ReserveLiquidity.js.map +1 -1
  111. package/dist/idl_codegen/types/UpdateConfigMode.d.ts +0 -39
  112. package/dist/idl_codegen/types/UpdateConfigMode.js +1 -79
  113. package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
  114. package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.d.ts +2 -4
  115. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +0 -13
  116. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +1 -27
  117. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  118. package/dist/idl_codegen/types/index.d.ts +4 -4
  119. package/dist/idl_codegen/types/index.js.map +1 -1
  120. package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +2 -3
  121. package/dist/idl_codegen/zero_padding/ObligationZP.js +3 -8
  122. package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
  123. package/dist/idl_codegen_kamino_vault/accounts/Reserve.d.ts +90 -0
  124. package/dist/idl_codegen_kamino_vault/accounts/Reserve.js +168 -0
  125. package/dist/idl_codegen_kamino_vault/accounts/Reserve.js.map +1 -0
  126. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +69 -0
  127. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +181 -0
  128. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -0
  129. package/dist/idl_codegen_kamino_vault/accounts/index.d.ts +4 -0
  130. package/dist/idl_codegen_kamino_vault/accounts/index.js +8 -0
  131. package/dist/idl_codegen_kamino_vault/accounts/index.js.map +1 -0
  132. package/dist/idl_codegen_kamino_vault/errors/anchor.d.ts +434 -0
  133. package/dist/idl_codegen_kamino_vault/errors/anchor.js +713 -0
  134. package/dist/idl_codegen_kamino_vault/errors/anchor.js.map +1 -0
  135. package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +194 -0
  136. package/dist/idl_codegen_kamino_vault/errors/custom.js +322 -0
  137. package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -0
  138. package/dist/idl_codegen_kamino_vault/errors/index.d.ts +5 -0
  139. package/dist/idl_codegen_kamino_vault/errors/index.js +71 -0
  140. package/dist/idl_codegen_kamino_vault/errors/index.js.map +1 -0
  141. package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts +19 -0
  142. package/dist/idl_codegen_kamino_vault/instructions/deposit.js +58 -0
  143. package/dist/idl_codegen_kamino_vault/instructions/deposit.js.map +1 -0
  144. package/dist/idl_codegen_kamino_vault/instructions/index.d.ts +10 -0
  145. package/dist/idl_codegen_kamino_vault/instructions/index.js +14 -0
  146. package/dist/idl_codegen_kamino_vault/instructions/index.js.map +1 -0
  147. package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +13 -0
  148. package/dist/idl_codegen_kamino_vault/instructions/initVault.js +24 -0
  149. package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -0
  150. package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts +18 -0
  151. package/dist/idl_codegen_kamino_vault/instructions/invest.js +44 -0
  152. package/dist/idl_codegen_kamino_vault/instructions/invest.js.map +1 -0
  153. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +19 -0
  154. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js +58 -0
  155. package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -0
  156. package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts +27 -0
  157. package/dist/idl_codegen_kamino_vault/instructions/withdraw.js +77 -0
  158. package/dist/idl_codegen_kamino_vault/instructions/withdraw.js.map +1 -0
  159. package/dist/idl_codegen_kamino_vault/programId.d.ts +3 -0
  160. package/dist/idl_codegen_kamino_vault/programId.js +9 -0
  161. package/dist/idl_codegen_kamino_vault/programId.js.map +1 -0
  162. package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.d.ts +27 -0
  163. package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js +73 -0
  164. package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js.map +1 -0
  165. package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.d.ts +27 -0
  166. package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js +62 -0
  167. package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js.map +1 -0
  168. package/dist/idl_codegen_kamino_vault/types/CurvePoint.d.ts +26 -0
  169. package/dist/idl_codegen_kamino_vault/types/CurvePoint.js +66 -0
  170. package/dist/idl_codegen_kamino_vault/types/CurvePoint.js.map +1 -0
  171. package/dist/idl_codegen_kamino_vault/types/LastUpdate.d.ts +47 -0
  172. package/dist/idl_codegen_kamino_vault/types/LastUpdate.js +86 -0
  173. package/dist/idl_codegen_kamino_vault/types/LastUpdate.js.map +1 -0
  174. package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.d.ts +41 -0
  175. package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js +75 -0
  176. package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js.map +1 -0
  177. package/dist/idl_codegen_kamino_vault/types/PythConfiguration.d.ts +25 -0
  178. package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js +62 -0
  179. package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js.map +1 -0
  180. package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.d.ts +53 -0
  181. package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js +93 -0
  182. package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js.map +1 -0
  183. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts +373 -0
  184. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js +236 -0
  185. package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js.map +1 -0
  186. package/dist/idl_codegen_kamino_vault/types/ReserveFees.d.ts +78 -0
  187. package/dist/idl_codegen_kamino_vault/types/ReserveFees.js +86 -0
  188. package/dist/idl_codegen_kamino_vault/types/ReserveFees.js.map +1 -0
  189. package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts +173 -0
  190. package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js +166 -0
  191. package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js.map +1 -0
  192. package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.d.ts +41 -0
  193. package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js +76 -0
  194. package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js.map +1 -0
  195. package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.d.ts +30 -0
  196. package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js +67 -0
  197. package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js.map +1 -0
  198. package/dist/idl_codegen_kamino_vault/types/TokenInfo.d.ts +117 -0
  199. package/dist/idl_codegen_kamino_vault/types/TokenInfo.js +128 -0
  200. package/dist/idl_codegen_kamino_vault/types/TokenInfo.js.map +1 -0
  201. package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts +56 -0
  202. package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js +104 -0
  203. package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js.map +1 -0
  204. package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.d.ts +38 -0
  205. package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js +86 -0
  206. package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js.map +1 -0
  207. package/dist/idl_codegen_kamino_vault/types/index.d.ts +30 -0
  208. package/dist/idl_codegen_kamino_vault/types/index.js +34 -0
  209. package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -0
  210. package/dist/leverage/instructions.js +0 -2
  211. package/dist/leverage/instructions.js.map +1 -1
  212. package/dist/leverage/operations.js +3 -4
  213. package/dist/leverage/operations.js.map +1 -1
  214. package/dist/utils/ata.d.ts +5 -5
  215. package/dist/utils/ata.js +29 -39
  216. package/dist/utils/ata.js.map +1 -1
  217. package/dist/utils/index.d.ts +1 -0
  218. package/dist/utils/index.js +1 -0
  219. package/dist/utils/index.js.map +1 -1
  220. package/dist/utils/instruction.d.ts +2 -1
  221. package/dist/utils/instruction.js +8 -1
  222. package/dist/utils/instruction.js.map +1 -1
  223. package/dist/utils/sendTransactionsUtils.d.ts +40 -0
  224. package/dist/utils/sendTransactionsUtils.js +154 -0
  225. package/dist/utils/sendTransactionsUtils.js.map +1 -0
  226. package/package.json +3 -2
  227. package/dist/utils/token.d.ts +0 -2
  228. package/dist/utils/token.js +0 -20
  229. package/dist/utils/token.js.map +0 -1
@@ -153,5 +153,4 @@ export declare class KaminoAction {
153
153
  createAtasIxns: TransactionInstruction[];
154
154
  }>;
155
155
  getObligationPda(): PublicKey;
156
- getAdditionalDepositReservesList(): PublicKey[];
157
156
  }
@@ -24,7 +24,6 @@ const types_1 = require("../idl_codegen/types");
24
24
  const farms_sdk_1 = require("@hubbleprotocol/farms-sdk");
25
25
  const ObligationType_1 = require("../utils/ObligationType");
26
26
  const lib_1 = require("../lib");
27
- const token_1 = require("../utils/token");
28
27
  exports.POSITION_LIMIT = 10;
29
28
  exports.BORROWS_LIMIT = 5;
30
29
  exports.DEPOSITS_LIMIT = 8;
@@ -83,7 +82,7 @@ class KaminoAction {
83
82
  if (reserve === undefined) {
84
83
  throw new Error(`Reserve ${mint} not found in market ${kaminoMarket.getAddress().toBase58()}`);
85
84
  }
86
- const { userTokenAccountAddress, userCollateralAccountAddress } = KaminoAction.getUserAccountAddresses(payer !== null && payer !== void 0 ? payer : owner, reserve.state);
85
+ const { userTokenAccountAddress, userCollateralAccountAddress } = yield KaminoAction.getUserAccountAddresses(payer !== null && payer !== void 0 ? payer : owner, reserve.state);
87
86
  const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } = yield KaminoAction.loadObligation(action, kaminoMarket, owner, reserve.address, obligation);
88
87
  const [_, userMetadata] = yield kaminoMarket.getUserMetadata(owner);
89
88
  if (userMetadata) {
@@ -94,9 +93,11 @@ class KaminoAction {
94
93
  });
95
94
  }
96
95
  static getUserAccountAddresses(owner, reserve) {
97
- const userTokenAccountAddress = (0, utils_1.getAssociatedTokenAddress)(reserve.liquidity.mintPubkey, owner, true, reserve.liquidity.tokenProgram, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
98
- const userCollateralAccountAddress = (0, utils_1.getAssociatedTokenAddress)(reserve.collateral.mintPubkey, owner, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
99
- return { userTokenAccountAddress, userCollateralAccountAddress };
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const userTokenAccountAddress = yield spl_token_1.Token.getAssociatedTokenAddress(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, reserve.liquidity.mintPubkey, owner, true);
98
+ const userCollateralAccountAddress = yield spl_token_1.Token.getAssociatedTokenAddress(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, reserve.collateral.mintPubkey, owner, true);
99
+ return { userTokenAccountAddress, userCollateralAccountAddress };
100
+ });
100
101
  }
101
102
  static loadObligation(action, kaminoMarket, owner, reserve, obligation, outflowReserve) {
102
103
  return __awaiter(this, void 0, void 0, function* () {
@@ -443,14 +444,12 @@ class KaminoAction {
443
444
  lendingMarket: this.kaminoMarket.getAddress(),
444
445
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
445
446
  reserve: this.reserve.address,
446
- reserveLiquidityMint: this.reserve.getLiquidityMint(),
447
447
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
448
448
  reserveCollateralMint: this.reserve.getCTokenMint(),
449
449
  reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
450
450
  userSourceLiquidity: this.userTokenAccountAddress,
451
451
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
452
- collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
453
- liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
452
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
454
453
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
455
454
  }, this.kaminoMarket.programId));
456
455
  }
@@ -463,13 +462,11 @@ class KaminoAction {
463
462
  lendingMarket: this.kaminoMarket.getAddress(),
464
463
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
465
464
  reserve: this.reserve.address,
466
- reserveLiquidityMint: this.reserve.getLiquidityMint(),
467
465
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
468
466
  reserveCollateralMint: this.reserve.getCTokenMint(),
469
467
  userSourceLiquidity: this.userTokenAccountAddress,
470
468
  userDestinationCollateral: this.userCollateralAccountAddress,
471
- collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
472
- liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
469
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
473
470
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
474
471
  }, this.kaminoMarket.programId));
475
472
  }
@@ -482,13 +479,11 @@ class KaminoAction {
482
479
  lendingMarket: this.kaminoMarket.getAddress(),
483
480
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
484
481
  reserve: this.reserve.address,
485
- reserveLiquidityMint: this.reserve.getLiquidityMint(),
486
482
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
487
483
  reserveCollateralMint: this.reserve.getCTokenMint(),
488
484
  userSourceCollateral: this.userCollateralAccountAddress,
489
485
  userDestinationLiquidity: this.userTokenAccountAddress,
490
- collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
491
- liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
486
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
492
487
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
493
488
  }, this.kaminoMarket.programId));
494
489
  }
@@ -509,11 +504,7 @@ class KaminoAction {
509
504
  }
510
505
  addBorrowIx() {
511
506
  this.lendingIxsLabels.push(`borrowObligationLiquidity`);
512
- const depositReservesList = this.getAdditionalDepositReservesList();
513
- const depositReserveAccountMetas = depositReservesList.map((reserve) => {
514
- return { pubkey: reserve, isSigner: false, isWritable: true };
515
- });
516
- const borrowIx = (0, instructions_1.borrowObligationLiquidity)({
507
+ this.lendingIxs.push((0, instructions_1.borrowObligationLiquidity)({
517
508
  liquidityAmount: this.amount,
518
509
  }, {
519
510
  owner: this.owner,
@@ -521,16 +512,13 @@ class KaminoAction {
521
512
  lendingMarket: this.kaminoMarket.getAddress(),
522
513
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
523
514
  borrowReserve: this.reserve.address,
524
- borrowReserveLiquidityMint: this.reserve.getLiquidityMint(),
525
515
  reserveSourceLiquidity: this.reserve.state.liquidity.supplyVault,
526
516
  userDestinationLiquidity: this.userTokenAccountAddress,
527
517
  borrowReserveLiquidityFeeReceiver: this.reserve.state.liquidity.feeVault,
528
518
  referrerTokenState: (0, utils_1.referrerTokenStatePda)(this.referrer, this.reserve.address, this.kaminoMarket.programId)[0],
529
- tokenProgram: this.reserve.getLiquidityTokenProgram(),
519
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
530
520
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
531
- }, this.kaminoMarket.programId);
532
- borrowIx.keys = borrowIx.keys.concat([...depositReserveAccountMetas]);
533
- this.lendingIxs.push(borrowIx);
521
+ }, this.kaminoMarket.programId));
534
522
  }
535
523
  addDepositAndBorrowIx() {
536
524
  return __awaiter(this, void 0, void 0, function* () {
@@ -544,14 +532,12 @@ class KaminoAction {
544
532
  lendingMarket: this.kaminoMarket.getAddress(),
545
533
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
546
534
  reserve: this.reserve.address,
547
- reserveLiquidityMint: this.reserve.getLiquidityMint(),
548
535
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
549
536
  reserveCollateralMint: this.reserve.getCTokenMint(),
550
537
  reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
551
538
  userSourceLiquidity: this.userTokenAccountAddress,
552
539
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
553
- collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
554
- liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
540
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
555
541
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
556
542
  }, this.kaminoMarket.programId));
557
543
  if (!this.outflowReserve) {
@@ -563,14 +549,7 @@ class KaminoAction {
563
549
  if (!this.outflowAmount) {
564
550
  throw new Error(`outflowAmount not set`);
565
551
  }
566
- const depositReservesList = this.getAdditionalDepositReservesList();
567
- if (depositReservesList.length === 0) {
568
- depositReservesList.push(this.reserve.address);
569
- }
570
- const depositReserveAccountMetas = depositReservesList.map((reserve) => {
571
- return { pubkey: reserve, isSigner: false, isWritable: true };
572
- });
573
- const borrowIx = (0, instructions_1.borrowObligationLiquidity)({
552
+ this.lendingIxs.push((0, instructions_1.borrowObligationLiquidity)({
574
553
  liquidityAmount: this.outflowAmount,
575
554
  }, {
576
555
  owner: this.owner,
@@ -578,16 +557,13 @@ class KaminoAction {
578
557
  lendingMarket: this.kaminoMarket.getAddress(),
579
558
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
580
559
  borrowReserve: this.outflowReserve.address,
581
- borrowReserveLiquidityMint: this.outflowReserve.getLiquidityMint(),
582
560
  reserveSourceLiquidity: this.outflowReserve.state.liquidity.supplyVault,
583
561
  userDestinationLiquidity: this.additionalTokenAccountAddress,
584
562
  borrowReserveLiquidityFeeReceiver: this.outflowReserve.state.liquidity.feeVault,
585
563
  referrerTokenState: (0, utils_1.referrerTokenStatePda)(this.referrer, this.outflowReserve.address, this.kaminoMarket.programId)[0],
586
- tokenProgram: this.reserve.getLiquidityTokenProgram(),
564
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
587
565
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
588
- }, this.kaminoMarket.programId);
589
- borrowIx.keys = borrowIx.keys.concat([...depositReserveAccountMetas]);
590
- this.lendingIxs.push(borrowIx);
566
+ }, this.kaminoMarket.programId));
591
567
  });
592
568
  }
593
569
  addRepayAndWithdrawIxs() {
@@ -601,10 +577,9 @@ class KaminoAction {
601
577
  obligation: this.getObligationPda(),
602
578
  lendingMarket: this.kaminoMarket.getAddress(),
603
579
  repayReserve: this.reserve.address,
604
- reserveLiquidityMint: this.reserve.getLiquidityMint(),
605
580
  userSourceLiquidity: this.userTokenAccountAddress,
606
581
  reserveDestinationLiquidity: this.reserve.state.liquidity.supplyVault,
607
- tokenProgram: this.reserve.getLiquidityTokenProgram(),
582
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
608
583
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
609
584
  }, this.kaminoMarket.programId));
610
585
  if (!this.outflowReserve) {
@@ -627,14 +602,12 @@ class KaminoAction {
627
602
  lendingMarket: this.kaminoMarket.getAddress(),
628
603
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
629
604
  withdrawReserve: this.outflowReserve.address,
630
- reserveLiquidityMint: this.outflowReserve.getLiquidityMint(),
631
605
  reserveCollateralMint: this.outflowReserve.getCTokenMint(),
632
606
  reserveLiquiditySupply: this.outflowReserve.state.liquidity.supplyVault,
633
607
  reserveSourceCollateral: this.outflowReserve.state.collateral.supplyVault,
634
608
  userDestinationLiquidity: this.additionalTokenAccountAddress,
635
609
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
636
- collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
637
- liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
610
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
638
611
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
639
612
  }, this.kaminoMarket.programId));
640
613
  });
@@ -654,14 +627,12 @@ class KaminoAction {
654
627
  lendingMarket: this.kaminoMarket.getAddress(),
655
628
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
656
629
  withdrawReserve: this.reserve.address,
657
- reserveLiquidityMint: this.reserve.getLiquidityMint(),
658
630
  reserveCollateralMint: this.reserve.getCTokenMint(),
659
631
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
660
632
  reserveSourceCollateral: this.reserve.state.collateral.supplyVault,
661
633
  userDestinationLiquidity: this.userTokenAccountAddress,
662
634
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
663
- collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
664
- liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
635
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
665
636
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
666
637
  }, this.kaminoMarket.programId));
667
638
  });
@@ -669,25 +640,18 @@ class KaminoAction {
669
640
  addRepayIx() {
670
641
  return __awaiter(this, void 0, void 0, function* () {
671
642
  this.lendingIxsLabels.push(`repayObligationLiquidity(reserve=${this.reserve.address})(obligation=${this.getObligationPda()})`);
672
- const depositReservesList = this.getAdditionalDepositReservesList();
673
- const depositReserveAccountMetas = depositReservesList.map((reserve) => {
674
- return { pubkey: reserve, isSigner: false, isWritable: true };
675
- });
676
- const repayIx = (0, instructions_1.repayObligationLiquidity)({
643
+ this.lendingIxs.push((0, instructions_1.repayObligationLiquidity)({
677
644
  liquidityAmount: this.amount,
678
645
  }, {
679
646
  owner: this.payer,
680
647
  obligation: this.getObligationPda(),
681
648
  lendingMarket: this.kaminoMarket.getAddress(),
682
649
  repayReserve: this.reserve.address,
683
- reserveLiquidityMint: this.reserve.getLiquidityMint(),
684
650
  userSourceLiquidity: this.userTokenAccountAddress,
685
651
  reserveDestinationLiquidity: this.reserve.state.liquidity.supplyVault,
686
- tokenProgram: this.reserve.getLiquidityTokenProgram(),
652
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
687
653
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
688
- }, this.kaminoMarket.programId);
689
- repayIx.keys = repayIx.keys.concat([...depositReserveAccountMetas]);
690
- this.lendingIxs.push(repayIx);
654
+ }, this.kaminoMarket.programId));
691
655
  });
692
656
  }
693
657
  addLiquidateIx(maxAllowedLtvOverridePercent = 0) {
@@ -699,14 +663,11 @@ class KaminoAction {
699
663
  if (!this.additionalTokenAccountAddress) {
700
664
  throw Error(`Liquidating token account address is not defined`);
701
665
  }
702
- const depositReservesList = this.getAdditionalDepositReservesList();
703
- const depositReserveAccountMetas = depositReservesList.map((reserve) => {
704
- return { pubkey: reserve, isSigner: false, isWritable: true };
705
- });
706
- const liquidateIx = (0, instructions_1.liquidateObligationAndRedeemReserveCollateral)({
666
+ this.lendingIxs.push((0, instructions_1.liquidateObligationAndRedeemReserveCollateral)({
707
667
  liquidityAmount: this.amount,
708
668
  // TODO: Configure this when updating liquidator with new interface
709
- minAcceptableReceivedLiquidityAmount: this.outflowAmount || new bn_js_1.default(0),
669
+ minAcceptableReceivedCollateralAmount: this.outflowAmount || new bn_js_1.default(0),
670
+ // TODO: remove this before going live
710
671
  maxAllowedLtvOverridePercent: new bn_js_1.default(maxAllowedLtvOverridePercent),
711
672
  }, {
712
673
  liquidator: this.owner,
@@ -714,10 +675,8 @@ class KaminoAction {
714
675
  lendingMarket: this.kaminoMarket.getAddress(),
715
676
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
716
677
  repayReserve: this.reserve.address,
717
- repayReserveLiquidityMint: this.reserve.getLiquidityMint(),
718
678
  repayReserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
719
679
  withdrawReserve: this.outflowReserve.address,
720
- withdrawReserveLiquidityMint: this.outflowReserve.getLiquidityMint(),
721
680
  withdrawReserveCollateralMint: this.outflowReserve.getCTokenMint(),
722
681
  withdrawReserveCollateralSupply: this.outflowReserve.state.collateral.supplyVault,
723
682
  withdrawReserveLiquiditySupply: this.outflowReserve.state.liquidity.supplyVault,
@@ -725,13 +684,9 @@ class KaminoAction {
725
684
  userDestinationCollateral: this.userCollateralAccountAddress,
726
685
  userDestinationLiquidity: this.userTokenAccountAddress,
727
686
  withdrawReserveLiquidityFeeReceiver: this.outflowReserve.state.liquidity.feeVault,
728
- collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
729
- repayLiquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
730
- withdrawLiquidityTokenProgram: this.outflowReserve.getLiquidityTokenProgram(),
687
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
731
688
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
732
- }, this.kaminoMarket.programId);
733
- liquidateIx.keys = liquidateIx.keys.concat([...depositReserveAccountMetas]);
734
- this.lendingIxs.push(liquidateIx);
689
+ }, this.kaminoMarket.programId));
735
690
  });
736
691
  }
737
692
  addInBetweenIxs(action, includeAtaIxns, requestElevationGroup, addInitObligationForFarm, isClosingPosition = false) {
@@ -1002,7 +957,20 @@ class KaminoAction {
1002
957
  lendingMarket: marketAddress,
1003
958
  obligation: obligationPda,
1004
959
  }, this.kaminoMarket.programId);
1005
- const depositReservesList = this.getAdditionalDepositReservesList();
960
+ const depositReservesList = this.depositReserves;
961
+ // check if there's any member in the preloadedDepositReserves that is not in the depositReserves
962
+ // if so, add it to the depositReserves
963
+ for (let i = 0; i < this.preLoadedDepositReservesSameTx.length; i++) {
964
+ const preloadedDepositReserve = this.preLoadedDepositReservesSameTx[i];
965
+ // Check if the depositReserves array contains the current preloadedDepositReserve
966
+ const found = this.depositReserves.some((depositReserve) => {
967
+ return depositReserve.equals(preloadedDepositReserve);
968
+ });
969
+ // If not found, push the current preloadedDepositReserve to the depositReserves array
970
+ if (!found) {
971
+ depositReservesList.push(this.preLoadedDepositReservesSameTx[i]);
972
+ }
973
+ }
1006
974
  const depositReserveAccountMetas = depositReservesList.map((reserve) => {
1007
975
  return { pubkey: reserve, isSigner: false, isWritable: true };
1008
976
  });
@@ -1044,7 +1012,20 @@ class KaminoAction {
1044
1012
  lendingMarket: this.kaminoMarket.getAddress(),
1045
1013
  };
1046
1014
  const requestElevationGroupIx = (0, instructions_1.requestElevationGroup)(args, accounts, this.kaminoMarket.programId);
1047
- const depositReservesList = this.getAdditionalDepositReservesList();
1015
+ const depositReservesList = this.depositReserves;
1016
+ // check if there's any member in the preloadedDepositReserves that is not in the depositReserves
1017
+ // if so, add it to the depositReserves
1018
+ for (let i = 0; i < this.preLoadedDepositReservesSameTx.length; i++) {
1019
+ const preloadedDepositReserveString = this.preLoadedDepositReservesSameTx[i].toString();
1020
+ // Check if the depositReserves array contains the current preloadedDepositReserve
1021
+ const found = this.depositReserves.some((depositReserve) => {
1022
+ return depositReserve.toString() === preloadedDepositReserveString;
1023
+ });
1024
+ // If not found, push the current preloadedDepositReserve to the depositReserves array
1025
+ if (!found) {
1026
+ depositReservesList.push(this.preLoadedDepositReservesSameTx[i]);
1027
+ }
1028
+ }
1048
1029
  const depositReserveAccountMetas = depositReservesList.map((reserve) => {
1049
1030
  return { pubkey: reserve, isSigner: false, isWritable: true };
1050
1031
  });
@@ -1111,6 +1092,7 @@ class KaminoAction {
1111
1092
  lendingMarket: this.kaminoMarket.getAddress(),
1112
1093
  farmsProgram: farms_sdk_1.farmsId,
1113
1094
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1095
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1114
1096
  systemProgram: web3_js_1.SystemProgram.programId,
1115
1097
  };
1116
1098
  const refreshFarmForObligationix = (0, instructions_1.refreshObligationFarmsForReserve)(args, accounts, this.kaminoMarket.programId);
@@ -1171,6 +1153,7 @@ class KaminoAction {
1171
1153
  lendingMarket: this.kaminoMarket.getAddress(),
1172
1154
  farmsProgram: farms_sdk_1.farmsId,
1173
1155
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1156
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1174
1157
  systemProgram: web3_js_1.SystemProgram.programId,
1175
1158
  };
1176
1159
  const initObligationForFarm = (0, instructions_1.initObligationFarmsForReserve)(args, accounts, this.kaminoMarket.programId);
@@ -1204,6 +1187,7 @@ class KaminoAction {
1204
1187
  seed2Account: this.obligationType.toArgs().seed2,
1205
1188
  ownerUserMetadata: userMetadataAddress,
1206
1189
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1190
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1207
1191
  systemProgram: web3_js_1.SystemProgram.programId,
1208
1192
  }, this.kaminoMarket.programId);
1209
1193
  this.setupIxs.push(initObligationIx);
@@ -1272,12 +1256,11 @@ class KaminoAction {
1272
1256
  referrer: this.owner,
1273
1257
  lendingMarket: this.kaminoMarket.getAddress(),
1274
1258
  reserve: this.reserve.address,
1275
- reserveLiquidityMint: this.reserve.getLiquidityMint(),
1276
1259
  referrerTokenState: referrerTokenStateAddress,
1277
1260
  reserveSupplyLiquidity: this.reserve.state.liquidity.supplyVault,
1278
1261
  referrerTokenAccount: this.userTokenAccountAddress,
1279
1262
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
1280
- tokenProgram: this.reserve.getLiquidityTokenProgram(),
1263
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1281
1264
  }, this.kaminoMarket.programId);
1282
1265
  this.lendingIxs.push(withdrawReferrerFeesIx);
1283
1266
  this.lendingIxsLabels.push(`WithdrawReferrerFeesIx[${this.owner.toString()}]`);
@@ -1295,7 +1278,7 @@ class KaminoAction {
1295
1278
  if ((action === 'withdraw' || action === 'borrow' || action === 'redeem') && !this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1296
1279
  const userTokenAccountInfo = yield this.kaminoMarket.getConnection().getAccountInfo(this.userTokenAccountAddress);
1297
1280
  if (!userTokenAccountInfo) {
1298
- const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.reserve.getLiquidityTokenProgram(), this.userTokenAccountAddress);
1281
+ const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.userTokenAccountAddress);
1299
1282
  if (this.positions === exports.POSITION_LIMIT && this.hostAta) {
1300
1283
  this.preTxnIxs.push(createUserTokenAccountIx);
1301
1284
  this.preTxnIxsLabels.push(`CreateLiquidityUserAta[${this.owner}]`);
@@ -1312,7 +1295,7 @@ class KaminoAction {
1312
1295
  throw new Error(`Outflow reserve state not found ${this.mint}`);
1313
1296
  }
1314
1297
  if (!userTokenAccountInfo) {
1315
- const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.outflowReserve.getLiquidityTokenProgram(), this.userTokenAccountAddress);
1298
+ const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.userTokenAccountAddress);
1316
1299
  if (this.positions === exports.POSITION_LIMIT && this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1317
1300
  this.preTxnIxs.push(createUserTokenAccountIx);
1318
1301
  this.preTxnIxsLabels.push(`CreateUserAta[${this.userTokenAccountAddress.toBase58()}]`);
@@ -1326,7 +1309,7 @@ class KaminoAction {
1326
1309
  .getConnection()
1327
1310
  .getAccountInfo(this.userCollateralAccountAddress);
1328
1311
  if (!userCollateralAccountInfo) {
1329
- const [, createUserCollateralAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getCTokenMint(), this.owner, spl_token_1.TOKEN_PROGRAM_ID, this.userCollateralAccountAddress);
1312
+ const [, createUserCollateralAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getCTokenMint(), this.owner, this.userCollateralAccountAddress);
1330
1313
  if (this.positions === exports.POSITION_LIMIT && this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1331
1314
  this.preTxnIxs.push(createUserCollateralAccountIx);
1332
1315
  this.preTxnIxsLabels.push(`CreateCollateralUserAta[${this.userCollateralAccountAddress.toString()}]`);
@@ -1352,7 +1335,7 @@ class KaminoAction {
1352
1335
  .getConnection()
1353
1336
  .getAccountInfo(this.additionalTokenAccountAddress);
1354
1337
  if (!additionalUserTokenAccountInfo) {
1355
- const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.outflowReserve.getLiquidityTokenProgram(), this.additionalTokenAccountAddress);
1338
+ const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.additionalTokenAccountAddress);
1356
1339
  this.setupIxs.unshift(createUserTokenAccountIx);
1357
1340
  this.setupIxsLabels.unshift(`CreateAdditionalUserTokenAta[${this.owner}]`);
1358
1341
  }
@@ -1361,7 +1344,7 @@ class KaminoAction {
1361
1344
  const userTokenAccountInfo = yield this.kaminoMarket.getConnection().getAccountInfo(this.userTokenAccountAddress);
1362
1345
  // TODO: Might need to remove this
1363
1346
  if (!userTokenAccountInfo) {
1364
- const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.reserve.getLiquidityTokenProgram(), this.userTokenAccountAddress);
1347
+ const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.userTokenAccountAddress);
1365
1348
  this.preTxnIxs.push(createUserTokenAccountIx);
1366
1349
  this.preTxnIxsLabels.push(`CreateUserAta[${this.userTokenAccountAddress.toBase58()}]`);
1367
1350
  }
@@ -1372,7 +1355,7 @@ class KaminoAction {
1372
1355
  .getAccountInfo(this.userCollateralAccountAddress);
1373
1356
  if (!userCollateralAccountInfo) {
1374
1357
  const collateralMintPubkey = this.reserve.getCTokenMint();
1375
- const [, createUserCollateralAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, collateralMintPubkey, this.owner, spl_token_1.TOKEN_PROGRAM_ID, this.userCollateralAccountAddress);
1358
+ const [, createUserCollateralAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, collateralMintPubkey, this.owner, this.userCollateralAccountAddress);
1376
1359
  if (this.positions === exports.POSITION_LIMIT && this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1377
1360
  this.preTxnIxs.push(createUserCollateralAccountIx);
1378
1361
  this.preTxnIxsLabels.push(`CreateCollateralUserAta[${this.userCollateralAccountAddress.toString()}]`);
@@ -1418,7 +1401,7 @@ class KaminoAction {
1418
1401
  userTokenAccountAddress = this.additionalTokenAccountAddress;
1419
1402
  }
1420
1403
  const userWSOLAccountInfo = yield this.kaminoMarket.getConnection().getAccountInfo(userTokenAccountAddress);
1421
- const rentExempt = yield this.kaminoMarket.getConnection().getMinimumBalanceForRentExemption(165);
1404
+ const rentExempt = yield spl_token_1.Token.getMinBalanceRentForExemptAccount(this.kaminoMarket.getConnection());
1422
1405
  // Add rent exemption lamports for WSOL accounts that need to be pre-funded for inflow/send transactions
1423
1406
  const sendAction = action === 'deposit' ||
1424
1407
  action === 'repay' ||
@@ -1431,7 +1414,7 @@ class KaminoAction {
1431
1414
  });
1432
1415
  preIxs.push(transferLamportsIx);
1433
1416
  preIxsLabels.push(`TransferLamportsToUserAtaSOL[${userTokenAccountAddress}]`);
1434
- const closeWSOLAccountIx = (0, token_1.createCloseAccountInstruction)(userTokenAccountAddress, this.owner, this.owner, spl_token_1.TOKEN_PROGRAM_ID);
1417
+ const closeWSOLAccountIx = spl_token_1.Token.createCloseAccountInstruction(spl_token_1.TOKEN_PROGRAM_ID, userTokenAccountAddress, this.owner, this.owner, []);
1435
1418
  const syncIx = (0, utils_1.syncNative)(userTokenAccountAddress);
1436
1419
  if (userWSOLAccountInfo) {
1437
1420
  if (sendAction) {
@@ -1444,7 +1427,7 @@ class KaminoAction {
1444
1427
  }
1445
1428
  }
1446
1429
  else {
1447
- const [, createUserWSOLAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, spl_token_1.NATIVE_MINT, this.owner, spl_token_1.TOKEN_PROGRAM_ID, userTokenAccountAddress);
1430
+ const [, createUserWSOLAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, spl_token_1.NATIVE_MINT, this.owner, userTokenAccountAddress);
1448
1431
  preIxs.push(createUserWSOLAccountIx);
1449
1432
  preIxsLabels.push(`CreateUserAtaSOL[${userTokenAccountAddress}]`);
1450
1433
  preIxs.push(syncIx);
@@ -1473,8 +1456,8 @@ class KaminoAction {
1473
1456
  if (!outflowReserve || !inflowReserve) {
1474
1457
  throw new Error('reserve states are not fetched');
1475
1458
  }
1476
- const { userTokenAccountAddress: userOutflowTokenAccountAddress, userCollateralAccountAddress: userOutflowCollateralAccountAddress, } = KaminoAction.getUserAccountAddresses(payer, outflowReserve.state);
1477
- const { userTokenAccountAddress: userInflowTokenAccountAddress, userCollateralAccountAddress: userInflowCollateralAccountAddress, } = KaminoAction.getUserAccountAddresses(payer, inflowReserve.state);
1459
+ const { userTokenAccountAddress: userOutflowTokenAccountAddress, userCollateralAccountAddress: userOutflowCollateralAccountAddress, } = yield KaminoAction.getUserAccountAddresses(payer, outflowReserve.state);
1460
+ const { userTokenAccountAddress: userInflowTokenAccountAddress, userCollateralAccountAddress: userInflowCollateralAccountAddress, } = yield KaminoAction.getUserAccountAddresses(payer, inflowReserve.state);
1478
1461
  const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } = yield KaminoAction.loadObligation(action, kaminoMarket, obligationOwner, inflowReserve.address, obligation, outflowReserve.address);
1479
1462
  const [_, userMetadata] = yield kaminoMarket.getUserMetadata(payer);
1480
1463
  if (userMetadata) {
@@ -1534,23 +1517,6 @@ class KaminoAction {
1534
1517
  ? this.obligation.obligationAddress
1535
1518
  : this.obligationType.toPda(this.kaminoMarket.getAddress(), this.owner);
1536
1519
  }
1537
- getAdditionalDepositReservesList() {
1538
- const depositReservesList = this.depositReserves;
1539
- // check if there's any member in the preloadedDepositReserves that is not in the depositReserves
1540
- // if so, add it to the depositReserves
1541
- for (let i = 0; i < this.preLoadedDepositReservesSameTx.length; i++) {
1542
- const preloadedDepositReserve = this.preLoadedDepositReservesSameTx[i];
1543
- // Check if the depositReserves array contains the current preloadedDepositReserve
1544
- const found = this.depositReserves.some((depositReserve) => {
1545
- return depositReserve.equals(preloadedDepositReserve);
1546
- });
1547
- // If not found, push the current preloadedDepositReserve to the depositReserves array
1548
- if (!found) {
1549
- depositReservesList.push(this.preLoadedDepositReservesSameTx[i]);
1550
- }
1551
- }
1552
- return depositReservesList;
1553
- }
1554
1520
  }
1555
1521
  exports.KaminoAction = KaminoAction;
1556
1522
  //# sourceMappingURL=action.js.map