@kamino-finance/klend-sdk 7.4.0-beta.0 → 7.4.0-beta.2

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 (264) hide show
  1. package/dist/@codegen/kvault/accounts/LendingMarket.d.ts +480 -0
  2. package/dist/@codegen/kvault/accounts/LendingMarket.d.ts.map +1 -0
  3. package/dist/@codegen/kvault/accounts/LendingMarket.js +480 -0
  4. package/dist/@codegen/kvault/accounts/LendingMarket.js.map +1 -0
  5. package/dist/@codegen/kvault/accounts/Obligation.d.ts +208 -0
  6. package/dist/@codegen/kvault/accounts/Obligation.d.ts.map +1 -0
  7. package/dist/@codegen/kvault/accounts/Obligation.js +298 -0
  8. package/dist/@codegen/kvault/accounts/Obligation.js.map +1 -0
  9. package/dist/@codegen/kvault/accounts/ReferrerTokenState.d.ts +51 -0
  10. package/dist/@codegen/kvault/accounts/ReferrerTokenState.d.ts.map +1 -0
  11. package/dist/@codegen/kvault/accounts/ReferrerTokenState.js +137 -0
  12. package/dist/@codegen/kvault/accounts/ReferrerTokenState.js.map +1 -0
  13. package/dist/@codegen/kvault/accounts/Reserve.d.ts +6 -0
  14. package/dist/@codegen/kvault/accounts/Reserve.d.ts.map +1 -1
  15. package/dist/@codegen/kvault/accounts/Reserve.js +9 -2
  16. package/dist/@codegen/kvault/accounts/Reserve.js.map +1 -1
  17. package/dist/@codegen/kvault/accounts/VaultState.d.ts +45 -3
  18. package/dist/@codegen/kvault/accounts/VaultState.d.ts.map +1 -1
  19. package/dist/@codegen/kvault/accounts/VaultState.js +28 -4
  20. package/dist/@codegen/kvault/accounts/VaultState.js.map +1 -1
  21. package/dist/@codegen/kvault/accounts/WithdrawTicket.d.ts +144 -0
  22. package/dist/@codegen/kvault/accounts/WithdrawTicket.d.ts.map +1 -0
  23. package/dist/@codegen/kvault/accounts/WithdrawTicket.js +205 -0
  24. package/dist/@codegen/kvault/accounts/WithdrawTicket.js.map +1 -0
  25. package/dist/@codegen/kvault/accounts/index.d.ts +8 -0
  26. package/dist/@codegen/kvault/accounts/index.d.ts.map +1 -1
  27. package/dist/@codegen/kvault/accounts/index.js +9 -1
  28. package/dist/@codegen/kvault/accounts/index.js.map +1 -1
  29. package/dist/@codegen/kvault/errors/custom.d.ts +81 -1
  30. package/dist/@codegen/kvault/errors/custom.d.ts.map +1 -1
  31. package/dist/@codegen/kvault/errors/custom.js +141 -1
  32. package/dist/@codegen/kvault/errors/custom.js.map +1 -1
  33. package/dist/@codegen/kvault/instructions/index.d.ts +4 -0
  34. package/dist/@codegen/kvault/instructions/index.d.ts.map +1 -1
  35. package/dist/@codegen/kvault/instructions/index.js +5 -1
  36. package/dist/@codegen/kvault/instructions/index.js.map +1 -1
  37. package/dist/@codegen/kvault/instructions/invest.d.ts +9 -0
  38. package/dist/@codegen/kvault/instructions/invest.d.ts.map +1 -1
  39. package/dist/@codegen/kvault/instructions/invest.js +7 -0
  40. package/dist/@codegen/kvault/instructions/invest.js.map +1 -1
  41. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillOrder.d.ts +51 -0
  42. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillOrder.d.ts.map +1 -0
  43. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillOrder.js +154 -0
  44. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillOrder.js.map +1 -0
  45. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillWithdrawalTicket.d.ts +54 -0
  46. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillWithdrawalTicket.d.ts.map +1 -0
  47. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillWithdrawalTicket.js +166 -0
  48. package/dist/@codegen/kvault/instructions/investInVirtualReserveAndFillWithdrawalTicket.js.map +1 -0
  49. package/dist/@codegen/kvault/instructions/updateKlendQueueAccounting.d.ts +1 -0
  50. package/dist/@codegen/kvault/instructions/updateKlendQueueAccounting.d.ts.map +1 -0
  51. package/dist/@codegen/kvault/instructions/updateKlendQueueAccounting.js +72 -0
  52. package/dist/@codegen/kvault/instructions/updateKlendQueueAccounting.js.map +1 -0
  53. package/dist/@codegen/kvault/instructions/updateReserveAllocation.d.ts +3 -1
  54. package/dist/@codegen/kvault/instructions/updateReserveAllocation.d.ts.map +1 -1
  55. package/dist/@codegen/kvault/instructions/updateReserveAllocation.js +3 -0
  56. package/dist/@codegen/kvault/instructions/updateReserveAllocation.js.map +1 -1
  57. package/dist/@codegen/kvault/types/BorrowOrder.d.ts +192 -0
  58. package/dist/@codegen/kvault/types/BorrowOrder.d.ts.map +1 -0
  59. package/dist/@codegen/kvault/types/BorrowOrder.js +194 -0
  60. package/dist/@codegen/kvault/types/BorrowOrder.js.map +1 -0
  61. package/dist/@codegen/kvault/types/ElevationGroup.d.ts +67 -0
  62. package/dist/@codegen/kvault/types/ElevationGroup.d.ts.map +1 -0
  63. package/dist/@codegen/kvault/types/ElevationGroup.js +137 -0
  64. package/dist/@codegen/kvault/types/ElevationGroup.js.map +1 -0
  65. package/dist/@codegen/kvault/types/FixedTermBorrowRolloverConfig.d.ts +145 -0
  66. package/dist/@codegen/kvault/types/FixedTermBorrowRolloverConfig.d.ts.map +1 -0
  67. package/dist/@codegen/kvault/types/FixedTermBorrowRolloverConfig.js +144 -0
  68. package/dist/@codegen/kvault/types/FixedTermBorrowRolloverConfig.js.map +1 -0
  69. package/dist/@codegen/kvault/types/ObligationCollateral.d.ts +72 -0
  70. package/dist/@codegen/kvault/types/ObligationCollateral.d.ts.map +1 -0
  71. package/dist/@codegen/kvault/types/ObligationCollateral.js +119 -0
  72. package/dist/@codegen/kvault/types/ObligationCollateral.js.map +1 -0
  73. package/dist/@codegen/kvault/types/ObligationLiquidity.d.ts +143 -0
  74. package/dist/@codegen/kvault/types/ObligationLiquidity.d.ts.map +1 -0
  75. package/dist/@codegen/kvault/types/ObligationLiquidity.js +165 -0
  76. package/dist/@codegen/kvault/types/ObligationLiquidity.js.map +1 -0
  77. package/dist/@codegen/kvault/types/ObligationOrder.d.ts +284 -0
  78. package/dist/@codegen/kvault/types/ObligationOrder.d.ts.map +1 -0
  79. package/dist/@codegen/kvault/types/ObligationOrder.js +205 -0
  80. package/dist/@codegen/kvault/types/ObligationOrder.js.map +1 -0
  81. package/dist/@codegen/kvault/types/ReserveConfig.d.ts +60 -5
  82. package/dist/@codegen/kvault/types/ReserveConfig.d.ts.map +1 -1
  83. package/dist/@codegen/kvault/types/ReserveConfig.js +36 -7
  84. package/dist/@codegen/kvault/types/ReserveConfig.js.map +1 -1
  85. package/dist/@codegen/kvault/types/ReserveLiquidity.d.ts +26 -8
  86. package/dist/@codegen/kvault/types/ReserveLiquidity.d.ts.map +1 -1
  87. package/dist/@codegen/kvault/types/ReserveLiquidity.js +14 -8
  88. package/dist/@codegen/kvault/types/ReserveLiquidity.js.map +1 -1
  89. package/dist/@codegen/kvault/types/ReserveType.d.ts +32 -0
  90. package/dist/@codegen/kvault/types/ReserveType.d.ts.map +1 -0
  91. package/dist/@codegen/kvault/types/ReserveType.js +108 -0
  92. package/dist/@codegen/kvault/types/ReserveType.js.map +1 -0
  93. package/dist/@codegen/kvault/types/VaultAllocation.d.ts +60 -0
  94. package/dist/@codegen/kvault/types/VaultAllocation.d.ts.map +1 -1
  95. package/dist/@codegen/kvault/types/VaultAllocation.js +38 -2
  96. package/dist/@codegen/kvault/types/VaultAllocation.js.map +1 -1
  97. package/dist/@codegen/kvault/types/WithdrawQueue.d.ts +64 -0
  98. package/dist/@codegen/kvault/types/WithdrawQueue.d.ts.map +1 -0
  99. package/dist/@codegen/kvault/types/WithdrawQueue.js +104 -0
  100. package/dist/@codegen/kvault/types/WithdrawQueue.js.map +1 -0
  101. package/dist/@codegen/kvault/types/WithdrawTicketProgressEvent.d.ts +19 -0
  102. package/dist/@codegen/kvault/types/WithdrawTicketProgressEvent.d.ts.map +1 -0
  103. package/dist/@codegen/kvault/types/WithdrawTicketProgressEvent.js +82 -0
  104. package/dist/@codegen/kvault/types/WithdrawTicketProgressEvent.js.map +1 -0
  105. package/dist/@codegen/kvault/types/index.d.ts +34 -0
  106. package/dist/@codegen/kvault/types/index.d.ts.map +1 -1
  107. package/dist/@codegen/kvault/types/index.js +19 -1
  108. package/dist/@codegen/kvault/types/index.js.map +1 -1
  109. package/dist/classes/action.d.ts +21 -91
  110. package/dist/classes/action.d.ts.map +1 -1
  111. package/dist/classes/action.js +141 -119
  112. package/dist/classes/action.js.map +1 -1
  113. package/dist/classes/actionTypes.d.ts +310 -0
  114. package/dist/classes/actionTypes.d.ts.map +1 -0
  115. package/dist/classes/actionTypes.js +3 -0
  116. package/dist/classes/actionTypes.js.map +1 -0
  117. package/dist/classes/market.d.ts +109 -15
  118. package/dist/classes/market.d.ts.map +1 -1
  119. package/dist/classes/market.js +186 -26
  120. package/dist/classes/market.js.map +1 -1
  121. package/dist/classes/obligation.d.ts +11 -11
  122. package/dist/classes/obligation.d.ts.map +1 -1
  123. package/dist/classes/obligation.js +56 -56
  124. package/dist/classes/obligation.js.map +1 -1
  125. package/dist/classes/obligationOrder.d.ts.map +1 -1
  126. package/dist/classes/obligationOrder.js +6 -3
  127. package/dist/classes/obligationOrder.js.map +1 -1
  128. package/dist/classes/reserve.d.ts +9 -1
  129. package/dist/classes/reserve.d.ts.map +1 -1
  130. package/dist/classes/reserve.js +20 -0
  131. package/dist/classes/reserve.js.map +1 -1
  132. package/dist/classes/shared.d.ts +1 -0
  133. package/dist/classes/shared.d.ts.map +1 -1
  134. package/dist/classes/utils.d.ts +2 -0
  135. package/dist/classes/utils.d.ts.map +1 -1
  136. package/dist/classes/utils.js +12 -1
  137. package/dist/classes/utils.js.map +1 -1
  138. package/dist/classes/vault.d.ts +4 -2
  139. package/dist/classes/vault.d.ts.map +1 -1
  140. package/dist/classes/vault.js +12 -2
  141. package/dist/classes/vault.js.map +1 -1
  142. package/dist/client/commands/borrow.d.ts +1 -1
  143. package/dist/client/commands/borrow.d.ts.map +1 -1
  144. package/dist/client/commands/borrow.js +11 -2
  145. package/dist/client/commands/borrow.js.map +1 -1
  146. package/dist/client/commands/deposit.d.ts +1 -1
  147. package/dist/client/commands/deposit.d.ts.map +1 -1
  148. package/dist/client/commands/deposit.js +11 -2
  149. package/dist/client/commands/deposit.js.map +1 -1
  150. package/dist/client/commands/printReserve.d.ts +1 -1
  151. package/dist/client/commands/printReserve.d.ts.map +1 -1
  152. package/dist/client/commands/printReserve.js +2 -4
  153. package/dist/client/commands/printReserve.js.map +1 -1
  154. package/dist/client/commands/repay.d.ts +1 -1
  155. package/dist/client/commands/repay.d.ts.map +1 -1
  156. package/dist/client/commands/repay.js +12 -2
  157. package/dist/client/commands/repay.js.map +1 -1
  158. package/dist/client/commands/withdraw.d.ts +1 -1
  159. package/dist/client/commands/withdraw.d.ts.map +1 -1
  160. package/dist/client/commands/withdraw.js +11 -2
  161. package/dist/client/commands/withdraw.js.map +1 -1
  162. package/dist/lending_operations/repay_with_collateral_calcs.d.ts +1 -1
  163. package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -1
  164. package/dist/lending_operations/repay_with_collateral_calcs.js +2 -2
  165. package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
  166. package/dist/lending_operations/repay_with_collateral_operations.d.ts +4 -4
  167. package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
  168. package/dist/lending_operations/repay_with_collateral_operations.js +43 -10
  169. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  170. package/dist/lending_operations/swap_collateral_operations.d.ts +4 -4
  171. package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
  172. package/dist/lending_operations/swap_collateral_operations.js +40 -21
  173. package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
  174. package/dist/leverage/operations.d.ts +6 -6
  175. package/dist/leverage/operations.d.ts.map +1 -1
  176. package/dist/leverage/operations.js +167 -52
  177. package/dist/leverage/operations.js.map +1 -1
  178. package/dist/leverage/types.d.ts +2 -2
  179. package/dist/leverage/types.d.ts.map +1 -1
  180. package/dist/manager/client_kamino_manager.js +0 -2
  181. package/dist/manager/client_kamino_manager.js.map +1 -1
  182. package/dist/obligation_orders/price_based.js +5 -3
  183. package/dist/obligation_orders/price_based.js.map +1 -1
  184. package/dist/utils/ObligationType.d.ts +33 -1
  185. package/dist/utils/ObligationType.d.ts.map +1 -1
  186. package/dist/utils/ObligationType.js +81 -2
  187. package/dist/utils/ObligationType.js.map +1 -1
  188. package/dist/utils/ReserveKind.d.ts +57 -0
  189. package/dist/utils/ReserveKind.d.ts.map +1 -0
  190. package/dist/utils/ReserveKind.js +76 -0
  191. package/dist/utils/ReserveKind.js.map +1 -0
  192. package/dist/utils/index.d.ts +1 -0
  193. package/dist/utils/index.d.ts.map +1 -1
  194. package/dist/utils/index.js +1 -0
  195. package/dist/utils/index.js.map +1 -1
  196. package/dist/utils/userMetadata.d.ts +2 -2
  197. package/dist/utils/userMetadata.d.ts.map +1 -1
  198. package/dist/utils/userMetadata.js +49 -25
  199. package/dist/utils/userMetadata.js.map +1 -1
  200. package/dist/utils/validations.d.ts +1 -0
  201. package/dist/utils/validations.d.ts.map +1 -1
  202. package/dist/utils/validations.js +5 -0
  203. package/dist/utils/validations.js.map +1 -1
  204. package/dist/utils/vault.d.ts.map +1 -1
  205. package/dist/utils/vault.js +2 -0
  206. package/dist/utils/vault.js.map +1 -1
  207. package/package.json +1 -1
  208. package/src/@codegen/kvault/accounts/LendingMarket.ts +837 -0
  209. package/src/@codegen/kvault/accounts/Obligation.ts +459 -0
  210. package/src/@codegen/kvault/accounts/ReferrerTokenState.ts +160 -0
  211. package/src/@codegen/kvault/accounts/Reserve.ts +13 -2
  212. package/src/@codegen/kvault/accounts/VaultState.ts +59 -7
  213. package/src/@codegen/kvault/accounts/WithdrawTicket.ts +280 -0
  214. package/src/@codegen/kvault/accounts/index.ts +11 -0
  215. package/src/@codegen/kvault/errors/custom.ts +152 -0
  216. package/src/@codegen/kvault/instructions/index.ts +10 -0
  217. package/src/@codegen/kvault/instructions/invest.ts +16 -0
  218. package/src/@codegen/kvault/instructions/investInVirtualReserveAndFillOrder.ts +189 -0
  219. package/src/@codegen/kvault/instructions/investInVirtualReserveAndFillWithdrawalTicket.ts +205 -0
  220. package/src/@codegen/kvault/instructions/updateKlendQueueAccounting.ts +76 -0
  221. package/src/@codegen/kvault/instructions/updateReserveAllocation.ts +4 -1
  222. package/src/@codegen/kvault/types/BorrowOrder.ts +267 -0
  223. package/src/@codegen/kvault/types/ElevationGroup.ts +134 -0
  224. package/src/@codegen/kvault/types/FixedTermBorrowRolloverConfig.ts +199 -0
  225. package/src/@codegen/kvault/types/ObligationCollateral.ts +129 -0
  226. package/src/@codegen/kvault/types/ObligationLiquidity.ts +226 -0
  227. package/src/@codegen/kvault/types/ObligationOrder.ts +348 -0
  228. package/src/@codegen/kvault/types/ReserveConfig.ts +72 -9
  229. package/src/@codegen/kvault/types/ReserveLiquidity.ts +30 -12
  230. package/src/@codegen/kvault/types/ReserveType.ts +89 -0
  231. package/src/@codegen/kvault/types/VaultAllocation.ts +74 -2
  232. package/src/@codegen/kvault/types/WithdrawQueue.ts +117 -0
  233. package/src/@codegen/kvault/types/WithdrawTicketProgressEvent.ts +59 -0
  234. package/src/@codegen/kvault/types/index.ts +52 -0
  235. package/src/classes/action.ts +321 -347
  236. package/src/classes/actionTypes.ts +295 -0
  237. package/src/classes/manager.ts +1 -1
  238. package/src/classes/market.ts +232 -30
  239. package/src/classes/obligation.ts +62 -59
  240. package/src/classes/obligationOrder.ts +6 -3
  241. package/src/classes/reserve.ts +24 -0
  242. package/src/classes/shared.ts +2 -0
  243. package/src/classes/utils.ts +8 -0
  244. package/src/classes/vault.ts +35 -4
  245. package/src/client/client.ts +17 -18
  246. package/src/client/commands/borrow.ts +10 -9
  247. package/src/client/commands/deposit.ts +10 -9
  248. package/src/client/commands/printReserve.ts +2 -4
  249. package/src/client/commands/repay.ts +11 -10
  250. package/src/client/commands/withdraw.ts +15 -9
  251. package/src/idl/kvault.json +2336 -299
  252. package/src/lending_operations/repay_with_collateral_calcs.ts +3 -4
  253. package/src/lending_operations/repay_with_collateral_operations.ts +40 -38
  254. package/src/lending_operations/swap_collateral_operations.ts +47 -41
  255. package/src/leverage/operations.ts +168 -129
  256. package/src/leverage/types.ts +2 -2
  257. package/src/manager/client_kamino_manager.ts +0 -2
  258. package/src/obligation_orders/price_based.ts +7 -5
  259. package/src/utils/ObligationType.ts +92 -1
  260. package/src/utils/ReserveKind.ts +94 -0
  261. package/src/utils/index.ts +1 -0
  262. package/src/utils/userMetadata.ts +64 -30
  263. package/src/utils/validations.ts +5 -0
  264. package/src/utils/vault.ts +2 -0
@@ -83,6 +83,24 @@ import {
83
83
  } from '@solana-program/token-2022';
84
84
  import { getTransferSolInstruction, SYSTEM_PROGRAM_ADDRESS } from '@solana-program/system';
85
85
  import { noopSigner } from '../utils/signer';
86
+ import {
87
+ BuildDepositTxnsProps,
88
+ BuildBorrowTxnsProps,
89
+ BuildDepositReserveLiquidityTxnsProps,
90
+ BuildRedeemReserveCollateralTxnsProps,
91
+ BuildWithdrawTxnsProps,
92
+ BuildRepayTxnsProps,
93
+ BuildDepositAndBorrowTxnsProps,
94
+ BuildRefreshObligationTxnsProps,
95
+ BuildRequestElevationGroupTxnsProps,
96
+ BuildDepositAndWithdrawV2TxnsProps,
97
+ BuildRepayAndWithdrawTxnsProps,
98
+ BuildRepayAndWithdrawV2TxnsProps,
99
+ BuildLiquidateTxnsProps,
100
+ BuildWithdrawReferrerFeeTxnsProps,
101
+ BuildDepositObligationCollateralTxnsProps,
102
+ InitializeActionProps,
103
+ } from './actionTypes';
86
104
 
87
105
  export type ActionType =
88
106
  | 'deposit'
@@ -203,20 +221,22 @@ export class KaminoAction {
203
221
  this.currentSlot = currentSlot;
204
222
  }
205
223
 
206
- static async initialize(
207
- action: ActionType,
208
- amount: string | BN,
209
- mint: Address,
210
- owner: TransactionSigner,
211
- kaminoMarket: KaminoMarket,
212
- obligation: KaminoObligation | ObligationType,
213
- referrer: Option<Address> = none(),
214
- currentSlot: Slot = 0n,
215
- payer: TransactionSigner = owner
216
- ) {
217
- const reserve = kaminoMarket.getReserveByMint(mint);
224
+ static async initialize(props: InitializeActionProps) {
225
+ const {
226
+ kaminoMarket,
227
+ action,
228
+ amount,
229
+ reserveAddress,
230
+ owner,
231
+ obligation,
232
+ referrer = none(),
233
+ currentSlot = 0n,
234
+ payer = owner,
235
+ } = props;
236
+
237
+ const reserve = kaminoMarket.getReserveByAddress(reserveAddress);
218
238
  if (reserve === undefined) {
219
- throw new Error(`Reserve ${mint} not found in market ${kaminoMarket.getAddress()}`);
239
+ throw new Error(`Reserve ${reserveAddress} not found in market ${kaminoMarket.getAddress()}`);
220
240
  }
221
241
 
222
242
  const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } =
@@ -228,7 +248,7 @@ export class KaminoAction {
228
248
  kaminoMarket,
229
249
  owner,
230
250
  kaminoObligation || obligation,
231
- mint,
251
+ reserve.getLiquidityMint(),
232
252
  distinctReserveCount,
233
253
  amount,
234
254
  depositReserves,
@@ -309,29 +329,23 @@ export class KaminoAction {
309
329
  };
310
330
  }
311
331
 
312
- static async buildRefreshObligationTxns(
313
- kaminoMarket: KaminoMarket,
314
- payer: TransactionSigner,
315
- obligation: KaminoObligation,
316
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
317
- currentSlot: Slot = 0n
318
- ) {
332
+ static async buildRefreshObligationTxns(props: BuildRefreshObligationTxnsProps) {
333
+ const { kaminoMarket, payer, obligation, extraComputeBudget = 1_000_000, currentSlot = 0n } = props;
319
334
  // placeholder for action initialization
320
335
  const firstReserve = obligation.getDeposits()[0].reserveAddress;
321
336
  const firstKaminoReserve = kaminoMarket.getReserveByAddress(firstReserve);
322
337
  if (!firstKaminoReserve) {
323
338
  throw new Error(`Reserve ${firstReserve} not found`);
324
339
  }
325
- const axn = await KaminoAction.initialize(
326
- 'refreshObligation',
327
- '0',
328
- firstKaminoReserve?.getLiquidityMint(),
329
- noopSigner(obligation.state.owner), // owner does not need to sign for refresh
340
+ const axn = await KaminoAction.initialize({
330
341
  kaminoMarket,
342
+ action: 'refreshObligation',
343
+ amount: '0',
344
+ reserveAddress: firstKaminoReserve.address,
345
+ owner: noopSigner(obligation.state.owner), // owner does not need to sign for refresh
331
346
  obligation,
332
- undefined,
333
- currentSlot
334
- );
347
+ currentSlot,
348
+ });
335
349
 
336
350
  if (extraComputeBudget > 0) {
337
351
  axn.addComputeBudgetIx(extraComputeBudget);
@@ -342,29 +356,22 @@ export class KaminoAction {
342
356
  return axn;
343
357
  }
344
358
 
345
- static async buildRequestElevationGroupTxns(
346
- kaminoMarket: KaminoMarket,
347
- owner: TransactionSigner,
348
- obligation: KaminoObligation,
349
- elevationGroup: number,
350
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
351
- currentSlot: Slot = 0n
352
- ) {
359
+ static async buildRequestElevationGroupTxns(props: BuildRequestElevationGroupTxnsProps) {
360
+ const { kaminoMarket, owner, obligation, elevationGroup, extraComputeBudget = 1_000_000, currentSlot = 0n } = props;
353
361
  const firstReserve = obligation.state.deposits.find((x) => x.depositReserve !== DEFAULT_PUBLIC_KEY)!.depositReserve;
354
362
  const firstKaminoReserve = kaminoMarket.getReserveByAddress(firstReserve);
355
363
  if (!firstKaminoReserve) {
356
364
  throw new Error(`Reserve ${firstReserve} not found`);
357
365
  }
358
- const axn = await KaminoAction.initialize(
359
- 'requestElevationGroup',
360
- '0',
361
- firstKaminoReserve?.getLiquidityMint(),
362
- owner,
366
+ const axn = await KaminoAction.initialize({
363
367
  kaminoMarket,
368
+ action: 'requestElevationGroup',
369
+ amount: '0',
370
+ reserveAddress: firstKaminoReserve.address,
371
+ owner,
364
372
  obligation,
365
- undefined,
366
- currentSlot
367
- );
373
+ currentSlot,
374
+ });
368
375
 
369
376
  if (extraComputeBudget > 0) {
370
377
  axn.addComputeBudgetIx(extraComputeBudget);
@@ -376,35 +383,34 @@ export class KaminoAction {
376
383
  return axn;
377
384
  }
378
385
 
379
- static async buildDepositTxns(
380
- kaminoMarket: KaminoMarket,
381
- amount: string | BN,
382
- mint: Address,
383
- owner: TransactionSigner,
384
- obligation: KaminoObligation | ObligationType,
385
- useV2Ixs: boolean,
386
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
387
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
388
- includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas,
389
- requestElevationGroup: boolean = false, // to be requested *before* the deposit
390
- initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
391
- skipInitialization: false,
392
- skipLutCreation: false,
393
- },
394
- referrer: Option<Address> = none(),
395
- currentSlot: Slot = 0n,
396
- overrideElevationGroupRequest: number | undefined = undefined // if set, when an elevationgroup request is made, it will use this value
397
- ) {
398
- const axn = await KaminoAction.initialize(
399
- 'deposit',
386
+ static async buildDepositTxns(props: BuildDepositTxnsProps) {
387
+ const {
388
+ kaminoMarket,
400
389
  amount,
401
- mint,
390
+ reserveAddress,
402
391
  owner,
392
+ obligation,
393
+ useV2Ixs,
394
+ scopeRefreshConfig,
395
+ extraComputeBudget = 1_000_000,
396
+ includeAtaIxs = true,
397
+ requestElevationGroup = false,
398
+ initUserMetadata = { skipInitialization: false, skipLutCreation: false },
399
+ referrer = none(),
400
+ currentSlot = 0n,
401
+ overrideElevationGroupRequest,
402
+ } = props;
403
+
404
+ const axn = await KaminoAction.initialize({
403
405
  kaminoMarket,
406
+ action: 'deposit',
407
+ amount,
408
+ reserveAddress,
409
+ owner,
404
410
  obligation,
405
411
  referrer,
406
- currentSlot
407
- );
412
+ currentSlot,
413
+ });
408
414
  const addInitObligationForFarm = true;
409
415
 
410
416
  if (extraComputeBudget > 0) {
@@ -440,35 +446,34 @@ export class KaminoAction {
440
446
  }
441
447
  }
442
448
 
443
- static async buildBorrowTxns(
444
- kaminoMarket: KaminoMarket,
445
- amount: string | BN,
446
- mint: Address,
447
- owner: TransactionSigner,
448
- obligation: KaminoObligation | ObligationType,
449
- useV2Ixs: boolean,
450
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
451
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
452
- includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas,
453
- requestElevationGroup: boolean = false,
454
- initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
455
- skipInitialization: false,
456
- skipLutCreation: false,
457
- },
458
- referrer: Option<Address> = none(),
459
- currentSlot: Slot = 0n,
460
- overrideElevationGroupRequest: number | undefined = undefined // if set, when an elevationgroup request is made, it will use this value
461
- ) {
462
- const axn = await KaminoAction.initialize(
463
- 'borrow',
449
+ static async buildBorrowTxns(props: BuildBorrowTxnsProps) {
450
+ const {
451
+ kaminoMarket,
464
452
  amount,
465
- mint,
453
+ reserveAddress,
466
454
  owner,
455
+ obligation,
456
+ useV2Ixs,
457
+ scopeRefreshConfig,
458
+ extraComputeBudget = 1_000_000,
459
+ includeAtaIxs = true,
460
+ requestElevationGroup = false,
461
+ initUserMetadata = { skipInitialization: false, skipLutCreation: false },
462
+ referrer = none(),
463
+ currentSlot = 0n,
464
+ overrideElevationGroupRequest,
465
+ } = props;
466
+
467
+ const axn = await KaminoAction.initialize({
467
468
  kaminoMarket,
469
+ action: 'borrow',
470
+ amount,
471
+ reserveAddress,
472
+ owner,
468
473
  obligation,
469
474
  referrer,
470
- currentSlot
471
- );
475
+ currentSlot,
476
+ });
472
477
  const addInitObligationForFarm = true;
473
478
  if (extraComputeBudget > 0) {
474
479
  axn.addComputeBudgetIx(extraComputeBudget);
@@ -507,29 +512,31 @@ export class KaminoAction {
507
512
  return axn;
508
513
  }
509
514
 
510
- static async buildDepositReserveLiquidityTxns(
511
- kaminoMarket: KaminoMarket,
512
- amount: string | BN,
513
- mint: Address,
514
- owner: TransactionSigner,
515
- obligation: KaminoObligation | ObligationType,
516
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
517
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
518
- includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas
519
- requestElevationGroup: boolean = false,
520
- referrer: Option<Address> = none(),
521
- currentSlot: Slot = 0n
522
- ) {
523
- const axn = await KaminoAction.initialize(
524
- 'mint',
515
+ static async buildDepositReserveLiquidityTxns(props: BuildDepositReserveLiquidityTxnsProps) {
516
+ const {
517
+ kaminoMarket,
525
518
  amount,
526
- mint,
519
+ reserveAddress,
527
520
  owner,
521
+ obligation,
522
+ scopeRefreshConfig,
523
+ extraComputeBudget = 1_000_000,
524
+ includeAtaIxs = true,
525
+ requestElevationGroup = false,
526
+ referrer = none(),
527
+ currentSlot = 0n,
528
+ } = props;
529
+
530
+ const axn = await KaminoAction.initialize({
528
531
  kaminoMarket,
532
+ action: 'mint',
533
+ amount,
534
+ reserveAddress,
535
+ owner,
529
536
  obligation,
530
537
  referrer,
531
- currentSlot
532
- );
538
+ currentSlot,
539
+ });
533
540
  const addInitObligationForFarm = true;
534
541
 
535
542
  if (extraComputeBudget > 0) {
@@ -550,29 +557,31 @@ export class KaminoAction {
550
557
  return axn;
551
558
  }
552
559
 
553
- static async buildRedeemReserveCollateralTxns(
554
- kaminoMarket: KaminoMarket,
555
- amount: string | BN,
556
- mint: Address,
557
- owner: TransactionSigner,
558
- obligation: KaminoObligation | ObligationType,
559
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
560
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
561
- includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas
562
- requestElevationGroup: boolean = false,
563
- referrer: Option<Address> = none(),
564
- currentSlot: Slot = 0n
565
- ) {
566
- const axn = await KaminoAction.initialize(
567
- 'redeem',
560
+ static async buildRedeemReserveCollateralTxns(props: BuildRedeemReserveCollateralTxnsProps) {
561
+ const {
562
+ kaminoMarket,
568
563
  amount,
569
- mint,
564
+ reserveAddress,
570
565
  owner,
566
+ obligation,
567
+ scopeRefreshConfig,
568
+ extraComputeBudget = 1_000_000,
569
+ includeAtaIxs = true,
570
+ requestElevationGroup = false,
571
+ referrer = none(),
572
+ currentSlot = 0n,
573
+ } = props;
574
+
575
+ const axn = await KaminoAction.initialize({
571
576
  kaminoMarket,
577
+ action: 'redeem',
578
+ amount,
579
+ reserveAddress,
580
+ owner,
572
581
  obligation,
573
582
  referrer,
574
- currentSlot
575
- );
583
+ currentSlot,
584
+ });
576
585
  const addInitObligationForFarm = true;
577
586
 
578
587
  if (extraComputeBudget > 0) {
@@ -593,34 +602,32 @@ export class KaminoAction {
593
602
  return axn;
594
603
  }
595
604
 
596
- static async buildDepositObligationCollateralTxns(
597
- kaminoMarket: KaminoMarket,
598
- amount: string | BN,
599
- mint: Address,
600
- owner: TransactionSigner,
601
- obligation: KaminoObligation | ObligationType,
602
- useV2Ixs: boolean,
603
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
604
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
605
- includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas
606
- requestElevationGroup: boolean = false,
607
- initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
608
- skipInitialization: false,
609
- skipLutCreation: false,
610
- },
611
- referrer: Option<Address> = none(),
612
- currentSlot: Slot = 0n
613
- ) {
614
- const axn = await KaminoAction.initialize(
615
- 'depositCollateral',
605
+ static async buildDepositObligationCollateralTxns(props: BuildDepositObligationCollateralTxnsProps) {
606
+ const {
607
+ kaminoMarket,
616
608
  amount,
617
- mint,
609
+ reserveAddress,
618
610
  owner,
611
+ obligation,
612
+ useV2Ixs,
613
+ scopeRefreshConfig,
614
+ extraComputeBudget = 1_000_000,
615
+ includeAtaIxs = true,
616
+ requestElevationGroup = false,
617
+ initUserMetadata = { skipInitialization: false, skipLutCreation: false },
618
+ referrer = none(),
619
+ currentSlot = 0n,
620
+ } = props;
621
+ const axn = await KaminoAction.initialize({
619
622
  kaminoMarket,
623
+ action: 'depositCollateral',
624
+ amount,
625
+ reserveAddress,
626
+ owner,
620
627
  obligation,
621
628
  referrer,
622
- currentSlot
623
- );
629
+ currentSlot,
630
+ });
624
631
  const addInitObligationForFarm = true;
625
632
 
626
633
  if (extraComputeBudget > 0) {
@@ -645,32 +652,30 @@ export class KaminoAction {
645
652
  return axn;
646
653
  }
647
654
 
648
- static async buildDepositAndBorrowTxns(
649
- kaminoMarket: KaminoMarket,
650
- depositAmount: string | BN,
651
- depositMint: Address,
652
- borrowAmount: string | BN,
653
- borrowMint: Address,
654
- owner: TransactionSigner,
655
- obligation: KaminoObligation | ObligationType,
656
- useV2Ixs: boolean,
657
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
658
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
659
- includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas,
660
- requestElevationGroup: boolean = false,
661
- initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
662
- skipInitialization: false,
663
- skipLutCreation: false,
664
- },
665
- referrer: Option<Address> = none(),
666
- currentSlot: Slot = 0n
667
- ) {
655
+ static async buildDepositAndBorrowTxns(props: BuildDepositAndBorrowTxnsProps) {
656
+ const {
657
+ kaminoMarket,
658
+ depositAmount,
659
+ depositReserveAddress,
660
+ borrowAmount,
661
+ borrowReserveAddress,
662
+ owner,
663
+ obligation,
664
+ useV2Ixs,
665
+ scopeRefreshConfig,
666
+ extraComputeBudget = 1_000_000,
667
+ includeAtaIxs = true,
668
+ requestElevationGroup = false,
669
+ initUserMetadata = { skipInitialization: false, skipLutCreation: false },
670
+ referrer = none(),
671
+ currentSlot = 0n,
672
+ } = props;
668
673
  const axn = await KaminoAction.initializeMultiTokenAction(
669
674
  kaminoMarket,
670
675
  'depositAndBorrow',
671
676
  depositAmount,
672
- depositMint,
673
- borrowMint,
677
+ depositReserveAddress,
678
+ borrowReserveAddress,
674
679
  owner,
675
680
  owner.address,
676
681
  obligation,
@@ -745,31 +750,29 @@ export class KaminoAction {
745
750
  return axn;
746
751
  }
747
752
 
748
- static async buildDepositAndWithdrawV2Txns(
749
- kaminoMarket: KaminoMarket,
750
- depositAmount: string | BN,
751
- depositMint: Address,
752
- withdrawAmount: string | BN,
753
- withdrawMint: Address,
754
- owner: TransactionSigner,
755
- currentSlot: Slot,
756
- obligation: KaminoObligation | ObligationType,
757
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
758
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
759
- includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas,
760
- requestElevationGroup: boolean = false,
761
- initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
762
- skipInitialization: false,
763
- skipLutCreation: false,
764
- },
765
- referrer: Option<Address> = none()
766
- ) {
753
+ static async buildDepositAndWithdrawV2Txns(props: BuildDepositAndWithdrawV2TxnsProps) {
754
+ const {
755
+ kaminoMarket,
756
+ depositAmount,
757
+ depositReserveAddress,
758
+ withdrawAmount,
759
+ withdrawReserveAddress,
760
+ owner,
761
+ currentSlot,
762
+ obligation,
763
+ scopeRefreshConfig,
764
+ extraComputeBudget = 1_000_000,
765
+ includeAtaIxs = true,
766
+ requestElevationGroup = false,
767
+ initUserMetadata = { skipInitialization: false, skipLutCreation: false },
768
+ referrer = none(),
769
+ } = props;
767
770
  const axn = await KaminoAction.initializeMultiTokenAction(
768
771
  kaminoMarket,
769
772
  'depositAndWithdraw',
770
773
  depositAmount,
771
- depositMint,
772
- withdrawMint,
774
+ depositReserveAddress,
775
+ withdrawReserveAddress,
773
776
  owner,
774
777
  owner.address,
775
778
  obligation,
@@ -799,31 +802,29 @@ export class KaminoAction {
799
802
  return axn;
800
803
  }
801
804
 
802
- static async buildRepayAndWithdrawV2Txns(
803
- kaminoMarket: KaminoMarket,
804
- repayAmount: string | BN,
805
- repayMint: Address,
806
- withdrawAmount: string | BN,
807
- withdrawMint: Address,
808
- payer: TransactionSigner,
809
- currentSlot: Slot,
810
- obligation: KaminoObligation | ObligationType,
811
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
812
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
813
- includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas,
814
- requestElevationGroup: boolean = false,
815
- initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
816
- skipInitialization: false,
817
- skipLutCreation: false,
818
- },
819
- referrer: Option<Address> = none()
820
- ) {
805
+ static async buildRepayAndWithdrawV2Txns(props: BuildRepayAndWithdrawV2TxnsProps) {
806
+ const {
807
+ kaminoMarket,
808
+ repayAmount,
809
+ repayReserveAddress,
810
+ withdrawAmount,
811
+ withdrawReserveAddress,
812
+ payer,
813
+ currentSlot,
814
+ obligation,
815
+ scopeRefreshConfig,
816
+ extraComputeBudget = 1_000_000,
817
+ includeAtaIxs = true,
818
+ requestElevationGroup = false,
819
+ initUserMetadata = { skipInitialization: false, skipLutCreation: false },
820
+ referrer = none(),
821
+ } = props;
821
822
  const axn = await KaminoAction.initializeMultiTokenAction(
822
823
  kaminoMarket,
823
824
  'repayAndWithdrawV2',
824
825
  repayAmount,
825
- repayMint,
826
- withdrawMint,
826
+ repayReserveAddress,
827
+ withdrawReserveAddress,
827
828
  payer,
828
829
  payer.address,
829
830
  obligation,
@@ -853,32 +854,30 @@ export class KaminoAction {
853
854
  return axn;
854
855
  }
855
856
 
856
- static async buildRepayAndWithdrawTxns(
857
- kaminoMarket: KaminoMarket,
858
- repayAmount: string | BN,
859
- repayMint: Address,
860
- withdrawAmount: string | BN,
861
- withdrawMint: Address,
862
- payer: TransactionSigner,
863
- currentSlot: Slot,
864
- obligation: KaminoObligation | ObligationType,
865
- useV2Ixs: boolean,
866
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
867
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
868
- includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas,
869
- requestElevationGroup: boolean = false,
870
- initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
871
- skipInitialization: false,
872
- skipLutCreation: false,
873
- },
874
- referrer: Option<Address> = none()
875
- ) {
857
+ static async buildRepayAndWithdrawTxns(props: BuildRepayAndWithdrawTxnsProps) {
858
+ const {
859
+ kaminoMarket,
860
+ repayAmount,
861
+ repayReserveAddress,
862
+ withdrawAmount,
863
+ withdrawReserveAddress,
864
+ payer,
865
+ currentSlot,
866
+ obligation,
867
+ useV2Ixs,
868
+ scopeRefreshConfig,
869
+ extraComputeBudget = 1_000_000,
870
+ includeAtaIxs = true,
871
+ requestElevationGroup = false,
872
+ initUserMetadata = { skipInitialization: false, skipLutCreation: false },
873
+ referrer = none(),
874
+ } = props;
876
875
  const axn = await KaminoAction.initializeMultiTokenAction(
877
876
  kaminoMarket,
878
877
  'repayAndWithdraw',
879
878
  repayAmount,
880
- repayMint,
881
- withdrawMint,
879
+ repayReserveAddress,
880
+ withdrawReserveAddress,
882
881
  payer,
883
882
  payer.address,
884
883
  obligation,
@@ -942,40 +941,35 @@ export class KaminoAction {
942
941
  return axn;
943
942
  }
944
943
 
945
- static async buildWithdrawTxns(
946
- kaminoMarket: KaminoMarket,
947
- amount: string | BN,
948
- mint: Address,
949
- owner: TransactionSigner,
950
- obligation: KaminoObligation | ObligationType,
951
- useV2Ixs: boolean,
952
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
953
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
954
- includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas,
955
- requestElevationGroup: boolean = false, // to be requested *after* the withdraw
956
- initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
957
- skipInitialization: false,
958
- skipLutCreation: false,
959
- },
960
- referrer: Option<Address> = none(),
961
- currentSlot: Slot = 0n,
962
- overrideElevationGroupRequest?: number,
963
- // Optional customizations which may be needed if the obligation was mutated by some previous ix.
964
- obligationCustomizations?: {
965
- // Any newly-added deposit reserves.
966
- addedDepositReserves?: Address[];
967
- }
968
- ) {
969
- const axn = await KaminoAction.initialize(
970
- 'withdraw',
944
+ static async buildWithdrawTxns(props: BuildWithdrawTxnsProps) {
945
+ const {
946
+ kaminoMarket,
971
947
  amount,
972
- mint,
948
+ reserveAddress,
973
949
  owner,
950
+ obligation,
951
+ useV2Ixs,
952
+ scopeRefreshConfig,
953
+ extraComputeBudget = 1_000_000,
954
+ includeAtaIxs = true,
955
+ requestElevationGroup = false,
956
+ initUserMetadata = { skipInitialization: false, skipLutCreation: false },
957
+ referrer = none(),
958
+ currentSlot = 0n,
959
+ overrideElevationGroupRequest,
960
+ obligationCustomizations,
961
+ } = props;
962
+
963
+ const axn = await KaminoAction.initialize({
974
964
  kaminoMarket,
965
+ action: 'withdraw',
966
+ amount,
967
+ reserveAddress,
968
+ owner,
975
969
  obligation,
976
970
  referrer,
977
- currentSlot
978
- );
971
+ currentSlot,
972
+ });
979
973
  const addInitObligationForFarm = true;
980
974
 
981
975
  if (extraComputeBudget > 0) {
@@ -1009,52 +1003,38 @@ export class KaminoAction {
1009
1003
  }
1010
1004
 
1011
1005
  /**
1012
- *
1013
- * @param kaminoMarket
1014
- * @param amount
1015
- * @param mint
1016
- * @param owner
1017
- * @param obligation - obligation to repay or the PDA seeds
1018
- * @param useV2Ixs
1019
- * @param scopeRefreshConfig
1020
- * @param currentSlot
1021
- * @param payer - if not set then owner is used
1022
- * @param extraComputeBudget - if > 0 then adds the ix
1023
- * @param includeAtaIxs - if true it includes create and close wsol and token atas
1024
- * @param requestElevationGroup
1025
- * @param initUserMetadata
1026
- * @param referrer
1006
+ * Build repay transactions
1007
+ * @param props - BuildRepayTxnsProps containing all required and optional parameters
1027
1008
  */
1028
- static async buildRepayTxns(
1029
- kaminoMarket: KaminoMarket,
1030
- amount: string | BN,
1031
- mint: Address,
1032
- owner: TransactionSigner,
1033
- obligation: KaminoObligation | ObligationType,
1034
- useV2Ixs: boolean,
1035
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
1036
- currentSlot: Slot,
1037
- payer: TransactionSigner = owner,
1038
- extraComputeBudget: number = 1_000_000,
1039
- includeAtaIxs: boolean = true,
1040
- requestElevationGroup: boolean = false,
1041
- initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
1042
- skipInitialization: false,
1043
- skipLutCreation: false,
1044
- },
1045
- referrer: Option<Address> = none()
1046
- ) {
1047
- const axn = await KaminoAction.initialize(
1048
- 'repay',
1009
+ static async buildRepayTxns(props: BuildRepayTxnsProps) {
1010
+ const {
1011
+ kaminoMarket,
1049
1012
  amount,
1050
- mint,
1013
+ reserveAddress,
1051
1014
  owner,
1015
+ obligation,
1016
+ useV2Ixs,
1017
+ scopeRefreshConfig,
1018
+ currentSlot,
1019
+ payer = owner,
1020
+ extraComputeBudget = 1_000_000,
1021
+ includeAtaIxs = true,
1022
+ requestElevationGroup = false,
1023
+ initUserMetadata = { skipInitialization: false, skipLutCreation: false },
1024
+ referrer = none(),
1025
+ } = props;
1026
+
1027
+ const axn = await KaminoAction.initialize({
1052
1028
  kaminoMarket,
1029
+ action: 'repay',
1030
+ amount,
1031
+ reserveAddress,
1032
+ owner,
1053
1033
  obligation,
1054
1034
  referrer,
1055
1035
  currentSlot,
1056
- payer
1057
- );
1036
+ payer,
1037
+ });
1058
1038
  const addInitObligationForFarm = true;
1059
1039
 
1060
1040
  if (extraComputeBudget > 0) {
@@ -1080,34 +1060,32 @@ export class KaminoAction {
1080
1060
  return axn;
1081
1061
  }
1082
1062
 
1083
- static async buildLiquidateTxns(
1084
- kaminoMarket: KaminoMarket,
1085
- amount: string | BN,
1086
- minCollateralReceiveAmount: string | BN,
1087
- repayTokenMint: Address,
1088
- withdrawTokenMint: Address,
1089
- liquidator: TransactionSigner,
1090
- obligationOwner: Address,
1091
- obligation: KaminoObligation | ObligationType,
1092
- useV2Ixs: boolean,
1093
- scopeRefreshConfig: ScopePriceRefreshConfig | undefined = undefined,
1094
- extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
1095
- includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas, and creates all other token atas if they don't exist
1096
- requestElevationGroup: boolean = false,
1097
- initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
1098
- skipInitialization: false,
1099
- skipLutCreation: false,
1100
- },
1101
- referrer: Option<Address> = none(),
1102
- maxAllowedLtvOverridePercent: number = 0,
1103
- currentSlot: Slot = 0n
1104
- ): Promise<KaminoAction> {
1063
+ static async buildLiquidateTxns(props: BuildLiquidateTxnsProps): Promise<KaminoAction> {
1064
+ const {
1065
+ kaminoMarket,
1066
+ amount,
1067
+ minCollateralReceiveAmount,
1068
+ repayReserveAddress,
1069
+ withdrawReserveAddress,
1070
+ liquidator,
1071
+ obligationOwner,
1072
+ obligation,
1073
+ useV2Ixs,
1074
+ scopeRefreshConfig,
1075
+ extraComputeBudget = 1_000_000,
1076
+ includeAtaIxs = true,
1077
+ requestElevationGroup = false,
1078
+ initUserMetadata = { skipInitialization: false, skipLutCreation: false },
1079
+ referrer = none(),
1080
+ maxAllowedLtvOverridePercent = 0,
1081
+ currentSlot = 0n,
1082
+ } = props;
1105
1083
  const axn = await KaminoAction.initializeMultiTokenAction(
1106
1084
  kaminoMarket,
1107
1085
  'liquidate',
1108
1086
  amount,
1109
- repayTokenMint,
1110
- withdrawTokenMint,
1087
+ repayReserveAddress,
1088
+ withdrawReserveAddress,
1111
1089
  liquidator,
1112
1090
  obligationOwner,
1113
1091
  obligation,
@@ -1140,14 +1118,10 @@ export class KaminoAction {
1140
1118
  return axn;
1141
1119
  }
1142
1120
 
1143
- static async buildWithdrawReferrerFeeTxns(
1144
- owner: TransactionSigner,
1145
- tokenMint: Address,
1146
- kaminoMarket: KaminoMarket,
1147
- currentSlot: Slot = 0n
1148
- ) {
1121
+ static async buildWithdrawReferrerFeeTxns(props: BuildWithdrawReferrerFeeTxnsProps) {
1122
+ const { owner, reserveAddress, kaminoMarket, currentSlot = 0n } = props;
1149
1123
  const { axn, createAtaIxs } = await KaminoAction.initializeWithdrawReferrerFees(
1150
- tokenMint,
1124
+ reserveAddress,
1151
1125
  owner,
1152
1126
  kaminoMarket,
1153
1127
  currentSlot
@@ -3346,8 +3320,8 @@ export class KaminoAction {
3346
3320
  kaminoMarket: KaminoMarket,
3347
3321
  action: ActionType,
3348
3322
  inflowAmount: string | BN,
3349
- inflowTokenMint: Address,
3350
- outflowTokenMint: Address,
3323
+ inflowReserveAddress: Address,
3324
+ outflowReserveAddress: Address,
3351
3325
  signer: TransactionSigner,
3352
3326
  obligationOwner: Address,
3353
3327
  obligation: KaminoObligation | ObligationType,
@@ -3355,8 +3329,8 @@ export class KaminoAction {
3355
3329
  referrer: Option<Address> = none(),
3356
3330
  currentSlot: Slot = 0n
3357
3331
  ) {
3358
- const inflowReserve = kaminoMarket.getExistingReserveByMint(inflowTokenMint);
3359
- const outflowReserve = kaminoMarket.getExistingReserveByMint(outflowTokenMint);
3332
+ const inflowReserve = kaminoMarket.getExistingReserveByAddress(inflowReserveAddress);
3333
+ const outflowReserve = kaminoMarket.getExistingReserveByAddress(outflowReserveAddress);
3360
3334
 
3361
3335
  const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } =
3362
3336
  await KaminoAction.loadObligation(
@@ -3378,8 +3352,8 @@ export class KaminoAction {
3378
3352
  action === 'repayAndWithdraw' ||
3379
3353
  action === 'repayAndWithdrawV2'
3380
3354
  ) {
3381
- primaryMint = inflowTokenMint;
3382
- secondaryMint = outflowTokenMint;
3355
+ primaryMint = inflowReserve.getLiquidityMint();
3356
+ secondaryMint = outflowReserve.getLiquidityMint();
3383
3357
  } else {
3384
3358
  throw new Error('Invalid action');
3385
3359
  }
@@ -3403,14 +3377,14 @@ export class KaminoAction {
3403
3377
  }
3404
3378
 
3405
3379
  static async initializeWithdrawReferrerFees(
3406
- mint: Address,
3380
+ reserveAddress: Address,
3407
3381
  owner: TransactionSigner,
3408
3382
  kaminoMarket: KaminoMarket,
3409
3383
  currentSlot: Slot = 0n
3410
3384
  ) {
3411
- const reserve = kaminoMarket.getReserveByMint(mint);
3385
+ const reserve = kaminoMarket.getReserveByAddress(reserveAddress);
3412
3386
  if (reserve === undefined) {
3413
- throw new Error(`Reserve ${mint} not found in market ${kaminoMarket.getAddress()}`);
3387
+ throw new Error(`Reserve ${reserveAddress} not found in market ${kaminoMarket.getAddress()}`);
3414
3388
  }
3415
3389
 
3416
3390
  const [{ createAtaIx }] = await createAtasIdempotent(owner, [
@@ -3425,7 +3399,7 @@ export class KaminoAction {
3425
3399
  kaminoMarket,
3426
3400
  owner,
3427
3401
  new VanillaObligation(kaminoMarket.programId),
3428
- mint,
3402
+ reserve.getLiquidityMint(),
3429
3403
  0,
3430
3404
  new BN(0),
3431
3405
  [],