@kamino-finance/klend-sdk 2.11.0 → 2.12.0-SNAPSHOT.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 (138) hide show
  1. package/dist/classes/action.js +126 -110
  2. package/dist/classes/action.js.map +1 -1
  3. package/dist/classes/fraction.js.map +1 -1
  4. package/dist/classes/jupiterPerps.js.map +1 -1
  5. package/dist/classes/market.js +10 -9
  6. package/dist/classes/market.js.map +1 -1
  7. package/dist/classes/obligation.js.map +1 -1
  8. package/dist/classes/reserve.d.ts +4 -0
  9. package/dist/classes/reserve.js +6 -0
  10. package/dist/classes/reserve.js.map +1 -1
  11. package/dist/classes/shared.js +1 -1
  12. package/dist/classes/shared.js.map +1 -1
  13. package/dist/classes/utils.js.map +1 -1
  14. package/dist/idl.json +127 -29
  15. package/dist/idl_codegen/accounts/LendingMarket.js +4 -4
  16. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  17. package/dist/idl_codegen/accounts/Obligation.js +4 -4
  18. package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
  19. package/dist/idl_codegen/accounts/ReferrerState.js +4 -4
  20. package/dist/idl_codegen/accounts/ReferrerState.js.map +1 -1
  21. package/dist/idl_codegen/accounts/ReferrerTokenState.js +4 -4
  22. package/dist/idl_codegen/accounts/ReferrerTokenState.js.map +1 -1
  23. package/dist/idl_codegen/accounts/Reserve.js +4 -4
  24. package/dist/idl_codegen/accounts/Reserve.js.map +1 -1
  25. package/dist/idl_codegen/accounts/ShortUrl.js +4 -4
  26. package/dist/idl_codegen/accounts/ShortUrl.js.map +1 -1
  27. package/dist/idl_codegen/accounts/UserMetadata.js +4 -4
  28. package/dist/idl_codegen/accounts/UserMetadata.js.map +1 -1
  29. package/dist/idl_codegen/accounts/UserState.js +4 -4
  30. package/dist/idl_codegen/accounts/UserState.js.map +1 -1
  31. package/dist/idl_codegen/errors/anchor.js.map +1 -1
  32. package/dist/idl_codegen/errors/custom.d.ts +9 -1
  33. package/dist/idl_codegen/errors/custom.js +14 -1
  34. package/dist/idl_codegen/errors/custom.js.map +1 -1
  35. package/dist/idl_codegen/errors/index.js.map +1 -1
  36. package/dist/idl_codegen/instructions/borrowObligationLiquidity.d.ts +1 -0
  37. package/dist/idl_codegen/instructions/borrowObligationLiquidity.js +5 -0
  38. package/dist/idl_codegen/instructions/borrowObligationLiquidity.js.map +1 -1
  39. package/dist/idl_codegen/instructions/depositReserveLiquidity.d.ts +3 -1
  40. package/dist/idl_codegen/instructions/depositReserveLiquidity.js +15 -1
  41. package/dist/idl_codegen/instructions/depositReserveLiquidity.js.map +1 -1
  42. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.d.ts +3 -1
  43. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js +15 -1
  44. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -1
  45. package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.d.ts +2 -0
  46. package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.js +5 -0
  47. package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.js.map +1 -1
  48. package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.d.ts +2 -0
  49. package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.js +5 -0
  50. package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.js.map +1 -1
  51. package/dist/idl_codegen/instructions/initFarmsForReserve.d.ts +0 -1
  52. package/dist/idl_codegen/instructions/initFarmsForReserve.js +0 -1
  53. package/dist/idl_codegen/instructions/initFarmsForReserve.js.map +1 -1
  54. package/dist/idl_codegen/instructions/initObligation.d.ts +0 -1
  55. package/dist/idl_codegen/instructions/initObligation.js +0 -1
  56. package/dist/idl_codegen/instructions/initObligation.js.map +1 -1
  57. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.d.ts +0 -1
  58. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js +0 -1
  59. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js.map +1 -1
  60. package/dist/idl_codegen/instructions/initReserve.d.ts +2 -1
  61. package/dist/idl_codegen/instructions/initReserve.js +10 -1
  62. package/dist/idl_codegen/instructions/initReserve.js.map +1 -1
  63. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.d.ts +5 -1
  64. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js +25 -1
  65. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
  66. package/dist/idl_codegen/instructions/redeemFees.d.ts +1 -0
  67. package/dist/idl_codegen/instructions/redeemFees.js +5 -0
  68. package/dist/idl_codegen/instructions/redeemFees.js.map +1 -1
  69. package/dist/idl_codegen/instructions/redeemReserveCollateral.d.ts +3 -1
  70. package/dist/idl_codegen/instructions/redeemReserveCollateral.js +15 -1
  71. package/dist/idl_codegen/instructions/redeemReserveCollateral.js.map +1 -1
  72. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts +0 -1
  73. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js +0 -1
  74. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
  75. package/dist/idl_codegen/instructions/repayObligationLiquidity.d.ts +1 -0
  76. package/dist/idl_codegen/instructions/repayObligationLiquidity.js +5 -0
  77. package/dist/idl_codegen/instructions/repayObligationLiquidity.js.map +1 -1
  78. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.d.ts +3 -1
  79. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +15 -1
  80. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
  81. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +1 -0
  82. package/dist/idl_codegen/instructions/withdrawProtocolFee.js +5 -0
  83. package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
  84. package/dist/idl_codegen/instructions/withdrawReferrerFees.d.ts +1 -0
  85. package/dist/idl_codegen/instructions/withdrawReferrerFees.js +5 -0
  86. package/dist/idl_codegen/instructions/withdrawReferrerFees.js.map +1 -1
  87. package/dist/idl_codegen/programId.js.map +1 -1
  88. package/dist/idl_codegen/types/AssetTier.js.map +1 -1
  89. package/dist/idl_codegen/types/FeeCalculation.js.map +1 -1
  90. package/dist/idl_codegen/types/ReserveFarmKind.js.map +1 -1
  91. package/dist/idl_codegen/types/ReserveLiquidity.d.ts +8 -0
  92. package/dist/idl_codegen/types/ReserveLiquidity.js +7 -1
  93. package/dist/idl_codegen/types/ReserveLiquidity.js.map +1 -1
  94. package/dist/idl_codegen/types/ReserveStatus.js.map +1 -1
  95. package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
  96. package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.js.map +1 -1
  97. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  98. package/dist/idl_codegen/zero_padding/ObligationZP.js +4 -4
  99. package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
  100. package/dist/idl_codegen_jupiter_perps/accounts/Pool.js +4 -4
  101. package/dist/idl_codegen_jupiter_perps/accounts/Pool.js.map +1 -1
  102. package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
  103. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  104. package/dist/leverage/calcs.js +3 -3
  105. package/dist/leverage/calcs.js.map +1 -1
  106. package/dist/leverage/instructions.js +2 -0
  107. package/dist/leverage/instructions.js.map +1 -1
  108. package/dist/leverage/operations.js +6 -6
  109. package/dist/leverage/operations.js.map +1 -1
  110. package/dist/leverage/utils.js +3 -3
  111. package/dist/leverage/utils.js.map +1 -1
  112. package/dist/referrals/instructions.js +2 -2
  113. package/dist/referrals/instructions.js.map +1 -1
  114. package/dist/referrals/operations.d.ts +2 -2
  115. package/dist/referrals/operations.js +15 -15
  116. package/dist/referrals/operations.js.map +1 -1
  117. package/dist/utils/ObligationType.js +1 -1
  118. package/dist/utils/ObligationType.js.map +1 -1
  119. package/dist/utils/api.js +2 -2
  120. package/dist/utils/api.js.map +1 -1
  121. package/dist/utils/ata.d.ts +5 -5
  122. package/dist/utils/ata.js +23 -29
  123. package/dist/utils/ata.js.map +1 -1
  124. package/dist/utils/constants.js.map +1 -1
  125. package/dist/utils/instruction.d.ts +0 -1
  126. package/dist/utils/instruction.js +13 -13
  127. package/dist/utils/instruction.js.map +1 -1
  128. package/dist/utils/kamino.js +2 -24
  129. package/dist/utils/kamino.js.map +1 -1
  130. package/dist/utils/layout.js.map +1 -1
  131. package/dist/utils/lookupTable.js.map +1 -1
  132. package/dist/utils/oracle.js.map +1 -1
  133. package/dist/utils/pubkey.js.map +1 -1
  134. package/dist/utils/rpc.js.map +1 -1
  135. package/dist/utils/seeds.js.map +1 -1
  136. package/dist/utils/userMetadata.js +3 -3
  137. package/dist/utils/userMetadata.js.map +1 -1
  138. package/package.json +4 -4
@@ -76,13 +76,13 @@ class KaminoAction {
76
76
  this.referrer = referrer ? referrer : web3_js_1.PublicKey.default;
77
77
  this.currentSlot = currentSlot;
78
78
  }
79
- static initialize(action, amount, mint, owner, kaminoMarket, obligation, referrer = web3_js_1.PublicKey.default, currentSlot = 0, hostAta, payer) {
80
- return __awaiter(this, void 0, void 0, function* () {
79
+ static initialize(action_1, amount_1, mint_1, owner_1, kaminoMarket_1, obligation_2) {
80
+ return __awaiter(this, arguments, void 0, function* (action, amount, mint, owner, kaminoMarket, obligation, referrer = web3_js_1.PublicKey.default, currentSlot = 0, hostAta, payer) {
81
81
  const reserve = kaminoMarket.getReserveByMint(mint);
82
82
  if (reserve === undefined) {
83
83
  throw new Error(`Reserve ${mint} not found in market ${kaminoMarket.getAddress().toBase58()}`);
84
84
  }
85
- const { userTokenAccountAddress, userCollateralAccountAddress } = yield KaminoAction.getUserAccountAddresses(payer !== null && payer !== void 0 ? payer : owner, reserve.state);
85
+ const { userTokenAccountAddress, userCollateralAccountAddress } = KaminoAction.getUserAccountAddresses(payer !== null && payer !== void 0 ? payer : owner, reserve.state);
86
86
  const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } = yield KaminoAction.loadObligation(action, kaminoMarket, owner, reserve.address, obligation);
87
87
  const [_, userMetadata] = yield kaminoMarket.getUserMetadata(owner);
88
88
  if (userMetadata) {
@@ -93,11 +93,9 @@ class KaminoAction {
93
93
  });
94
94
  }
95
95
  static getUserAccountAddresses(owner, reserve) {
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
- });
96
+ const userTokenAccountAddress = (0, utils_1.getAssociatedTokenAddress)(reserve.liquidity.mintPubkey, owner, true, reserve.liquidity.tokenProgram, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
97
+ const userCollateralAccountAddress = (0, utils_1.getAssociatedTokenAddress)(reserve.collateral.mintPubkey, owner, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
98
+ return { userTokenAccountAddress, userCollateralAccountAddress };
101
99
  }
102
100
  static loadObligation(action, kaminoMarket, owner, reserve, obligation, outflowReserve) {
103
101
  return __awaiter(this, void 0, void 0, function* () {
@@ -144,9 +142,9 @@ class KaminoAction {
144
142
  };
145
143
  });
146
144
  }
147
- static buildRefreshObligationTxns(kaminoMarket, payer, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
148
- currentSlot = 0) {
149
- return __awaiter(this, void 0, void 0, function* () {
145
+ static buildRefreshObligationTxns(kaminoMarket_1, payer_1, obligation_2) {
146
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, payer, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
147
+ currentSlot = 0) {
150
148
  // placeholder for action initialization
151
149
  const firstReserve = obligation.state.deposits[0].depositReserve;
152
150
  const firstKaminoReserve = kaminoMarket.getReserveByAddress(firstReserve);
@@ -161,9 +159,9 @@ class KaminoAction {
161
159
  return axn;
162
160
  });
163
161
  }
164
- static buildRequestElevationGroupTxns(kaminoMarket, payer, obligation, elevationGroup, extraComputeBudget = 1000000, // if > 0 then adds the ixn
165
- currentSlot = 0) {
166
- return __awaiter(this, void 0, void 0, function* () {
162
+ static buildRequestElevationGroupTxns(kaminoMarket_1, payer_1, obligation_2, elevationGroup_1) {
163
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, payer, obligation, elevationGroup, extraComputeBudget = 1000000, // if > 0 then adds the ixn
164
+ currentSlot = 0) {
167
165
  const firstReserve = obligation.state.deposits[0].depositReserve;
168
166
  const firstKaminoReserve = kaminoMarket.getReserveByAddress(firstReserve);
169
167
  if (!firstKaminoReserve) {
@@ -178,11 +176,11 @@ class KaminoAction {
178
176
  return axn;
179
177
  });
180
178
  }
181
- static buildDepositTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
182
- includeAtaIxns = true, // if true it includes create and close wsol and token atas,
183
- requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
184
- referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
185
- return __awaiter(this, void 0, void 0, function* () {
179
+ static buildDepositTxns(kaminoMarket_1, amount_1, mint_1, owner_1, obligation_2) {
180
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
181
+ includeAtaIxns = true, // if true it includes create and close wsol and token atas,
182
+ requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
183
+ referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
186
184
  const axn = yield KaminoAction.initialize('deposit', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
187
185
  const addInitObligationForFarm = true;
188
186
  if (extraComputeBudget > 0) {
@@ -194,11 +192,11 @@ class KaminoAction {
194
192
  return axn;
195
193
  });
196
194
  }
197
- static buildBorrowTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
198
- includeAtaIxns = true, // if true it includes create and close wsol and token atas,
199
- requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
200
- referrer = web3_js_1.PublicKey.default, currentSlot = 0, hostAta) {
201
- return __awaiter(this, void 0, void 0, function* () {
195
+ static buildBorrowTxns(kaminoMarket_1, amount_1, mint_1, owner_1, obligation_2) {
196
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
197
+ includeAtaIxns = true, // if true it includes create and close wsol and token atas,
198
+ requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
199
+ referrer = web3_js_1.PublicKey.default, currentSlot = 0, hostAta) {
202
200
  const axn = yield KaminoAction.initialize('borrow', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot, hostAta);
203
201
  const addInitObligationForFarm = true;
204
202
  if (extraComputeBudget > 0) {
@@ -210,11 +208,11 @@ class KaminoAction {
210
208
  return axn;
211
209
  });
212
210
  }
213
- static buildDepositReserveLiquidityTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
214
- includeAtaIxns = true, // if true it includes create and close wsol and token atas
215
- requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
216
- referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
217
- return __awaiter(this, void 0, void 0, function* () {
211
+ static buildDepositReserveLiquidityTxns(kaminoMarket_1, amount_1, mint_1, owner_1, obligation_2) {
212
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
213
+ includeAtaIxns = true, // if true it includes create and close wsol and token atas
214
+ requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
215
+ referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
218
216
  const axn = yield KaminoAction.initialize('mint', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
219
217
  const addInitObligationForFarm = true;
220
218
  if (extraComputeBudget > 0) {
@@ -226,11 +224,11 @@ class KaminoAction {
226
224
  return axn;
227
225
  });
228
226
  }
229
- static buildRedeemReserveCollateralTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
230
- includeAtaIxns = true, // if true it includes create and close wsol and token atas
231
- requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata,
232
- referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
233
- return __awaiter(this, void 0, void 0, function* () {
227
+ static buildRedeemReserveCollateralTxns(kaminoMarket_1, amount_1, mint_1, owner_1, obligation_2) {
228
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
229
+ includeAtaIxns = true, // if true it includes create and close wsol and token atas
230
+ requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata,
231
+ referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
234
232
  const axn = yield KaminoAction.initialize('redeem', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
235
233
  const addInitObligationForFarm = true;
236
234
  if (extraComputeBudget > 0) {
@@ -242,11 +240,11 @@ class KaminoAction {
242
240
  return axn;
243
241
  });
244
242
  }
245
- static buildDepositObligationCollateralTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
246
- includeAtaIxns = true, // if true it includes create and close wsol and token atas
247
- requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
248
- referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
249
- return __awaiter(this, void 0, void 0, function* () {
243
+ static buildDepositObligationCollateralTxns(kaminoMarket_1, amount_1, mint_1, owner_1, obligation_2) {
244
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
245
+ includeAtaIxns = true, // if true it includes create and close wsol and token atas
246
+ requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
247
+ referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
250
248
  const axn = yield KaminoAction.initialize('depositCollateral', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
251
249
  const addInitObligationForFarm = true;
252
250
  if (extraComputeBudget > 0) {
@@ -258,11 +256,11 @@ class KaminoAction {
258
256
  return axn;
259
257
  });
260
258
  }
261
- static buildDepositAndBorrowTxns(kaminoMarket, depositAmount, depositMint, borrowAmount, borrowMint, payer, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
262
- includeAtaIxns = true, // if true it includes create and close wsol and token atas,
263
- requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata,
264
- referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
265
- return __awaiter(this, void 0, void 0, function* () {
259
+ static buildDepositAndBorrowTxns(kaminoMarket_1, depositAmount_1, depositMint_1, borrowAmount_1, borrowMint_1, payer_1, obligation_2) {
260
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, depositAmount, depositMint, borrowAmount, borrowMint, payer, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
261
+ includeAtaIxns = true, // if true it includes create and close wsol and token atas,
262
+ requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata,
263
+ referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
266
264
  const axn = yield KaminoAction.initializeMultiTokenAction(kaminoMarket, 'depositAndBorrow', depositAmount, depositMint, borrowMint, payer, payer, obligation, borrowAmount, referrer, currentSlot);
267
265
  const addInitObligationForFarmForDeposit = true;
268
266
  const addInitObligationForFarmForBorrow = false;
@@ -277,11 +275,11 @@ class KaminoAction {
277
275
  return axn;
278
276
  });
279
277
  }
280
- static buildRepayAndWithdrawTxns(kaminoMarket, repayAmount, repayMint, withdrawAmount, withdrawMint, payer, currentSlot, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
281
- includeAtaIxns = true, // if true it includes create and close wsol and token atas,
282
- requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata,
283
- isClosingPosition = false, referrer = web3_js_1.PublicKey.default) {
284
- return __awaiter(this, void 0, void 0, function* () {
278
+ static buildRepayAndWithdrawTxns(kaminoMarket_1, repayAmount_1, repayMint_1, withdrawAmount_1, withdrawMint_1, payer_1, currentSlot_1, obligation_2) {
279
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, repayAmount, repayMint, withdrawAmount, withdrawMint, payer, currentSlot, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
280
+ includeAtaIxns = true, // if true it includes create and close wsol and token atas,
281
+ requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata,
282
+ isClosingPosition = false, referrer = web3_js_1.PublicKey.default) {
285
283
  const axn = yield KaminoAction.initializeMultiTokenAction(kaminoMarket, 'repayAndWithdraw', repayAmount, repayMint, withdrawMint, payer, payer, obligation, withdrawAmount, referrer, currentSlot);
286
284
  const addInitObligationForFarmForRepay = true;
287
285
  const addInitObligationForFarmForWithdraw = false;
@@ -296,11 +294,11 @@ class KaminoAction {
296
294
  return axn;
297
295
  });
298
296
  }
299
- static buildWithdrawTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
300
- includeAtaIxns = true, // if true it includes create and close wsol and token atas,
301
- requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
302
- referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
303
- return __awaiter(this, void 0, void 0, function* () {
297
+ static buildWithdrawTxns(kaminoMarket_1, amount_1, mint_1, owner_1, obligation_2) {
298
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
299
+ includeAtaIxns = true, // if true it includes create and close wsol and token atas,
300
+ requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
301
+ referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
304
302
  const axn = yield KaminoAction.initialize('withdraw', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
305
303
  const addInitObligationForFarm = true;
306
304
  if (extraComputeBudget > 0) {
@@ -327,8 +325,8 @@ class KaminoAction {
327
325
  * @param includeUserMetadata - if true it includes user metadata
328
326
  * @param referrer
329
327
  */
330
- static buildRepayTxns(kaminoMarket, amount, mint, owner, obligation, currentSlot, payer = undefined, extraComputeBudget = 1000000, includeAtaIxns = true, requestElevationGroup = false, includeUserMetadata = true, referrer = web3_js_1.PublicKey.default) {
331
- return __awaiter(this, void 0, void 0, function* () {
328
+ static buildRepayTxns(kaminoMarket_1, amount_1, mint_1, owner_1, obligation_2, currentSlot_1) {
329
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, amount, mint, owner, obligation, currentSlot, payer = undefined, extraComputeBudget = 1000000, includeAtaIxns = true, requestElevationGroup = false, includeUserMetadata = true, referrer = web3_js_1.PublicKey.default) {
332
330
  const axn = yield KaminoAction.initialize('repay', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot, undefined, payer);
333
331
  const addInitObligationForFarm = true;
334
332
  if (extraComputeBudget > 0) {
@@ -340,11 +338,11 @@ class KaminoAction {
340
338
  return axn;
341
339
  });
342
340
  }
343
- static buildLiquidateTxns(kaminoMarket, amount, minCollateralReceiveAmount, repayTokenMint, withdrawTokenMint, liquidator, obligationOwner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
344
- includeAtaIxns = true, // if true it includes create and close wsol and token atas, and creates all other token atas if they don't exist
345
- requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
346
- referrer = web3_js_1.PublicKey.default, maxAllowedLtvOverridePercent = 0, currentSlot = 0) {
347
- return __awaiter(this, void 0, void 0, function* () {
341
+ static buildLiquidateTxns(kaminoMarket_1, amount_1, minCollateralReceiveAmount_1, repayTokenMint_1, withdrawTokenMint_1, liquidator_1, obligationOwner_1, obligation_2) {
342
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, amount, minCollateralReceiveAmount, repayTokenMint, withdrawTokenMint, liquidator, obligationOwner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
343
+ includeAtaIxns = true, // if true it includes create and close wsol and token atas, and creates all other token atas if they don't exist
344
+ requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
345
+ referrer = web3_js_1.PublicKey.default, maxAllowedLtvOverridePercent = 0, currentSlot = 0) {
348
346
  const axn = yield KaminoAction.initializeMultiTokenAction(kaminoMarket, 'liquidate', amount, repayTokenMint, withdrawTokenMint, liquidator, obligationOwner, obligation, minCollateralReceiveAmount, referrer, currentSlot);
349
347
  const addInitObligationForFarm = true;
350
348
  if (extraComputeBudget > 0) {
@@ -356,8 +354,8 @@ class KaminoAction {
356
354
  return axn;
357
355
  });
358
356
  }
359
- static buildWithdrawReferrerFeeTxns(owner, tokenMint, kaminoMarket, currentSlot = 0) {
360
- return __awaiter(this, void 0, void 0, function* () {
357
+ static buildWithdrawReferrerFeeTxns(owner_1, tokenMint_1, kaminoMarket_1) {
358
+ return __awaiter(this, arguments, void 0, function* (owner, tokenMint, kaminoMarket, currentSlot = 0) {
361
359
  const { axn, createAtasIxns } = yield KaminoAction.initializeWithdrawReferrerFees(tokenMint, owner, kaminoMarket, currentSlot);
362
360
  axn.preTxnIxs.push(...createAtasIxns);
363
361
  axn.preTxnIxsLabels.push(`createAtasIxs[${axn.userTokenAccountAddress.toString()}]`);
@@ -444,12 +442,14 @@ class KaminoAction {
444
442
  lendingMarket: this.kaminoMarket.getAddress(),
445
443
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
446
444
  reserve: this.reserve.address,
445
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
447
446
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
448
447
  reserveCollateralMint: this.reserve.getCTokenMint(),
449
- reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
448
+ reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault, // destinationCollateral
450
449
  userSourceLiquidity: this.userTokenAccountAddress,
451
450
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
452
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
451
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
452
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
453
453
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
454
454
  }, this.kaminoMarket.programId));
455
455
  }
@@ -462,11 +462,13 @@ class KaminoAction {
462
462
  lendingMarket: this.kaminoMarket.getAddress(),
463
463
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
464
464
  reserve: this.reserve.address,
465
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
465
466
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
466
467
  reserveCollateralMint: this.reserve.getCTokenMint(),
467
468
  userSourceLiquidity: this.userTokenAccountAddress,
468
469
  userDestinationCollateral: this.userCollateralAccountAddress,
469
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
470
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
471
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
470
472
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
471
473
  }, this.kaminoMarket.programId));
472
474
  }
@@ -479,11 +481,13 @@ class KaminoAction {
479
481
  lendingMarket: this.kaminoMarket.getAddress(),
480
482
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
481
483
  reserve: this.reserve.address,
484
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
482
485
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
483
486
  reserveCollateralMint: this.reserve.getCTokenMint(),
484
487
  userSourceCollateral: this.userCollateralAccountAddress,
485
488
  userDestinationLiquidity: this.userTokenAccountAddress,
486
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
489
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
490
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
487
491
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
488
492
  }, this.kaminoMarket.programId));
489
493
  }
@@ -516,11 +520,12 @@ class KaminoAction {
516
520
  lendingMarket: this.kaminoMarket.getAddress(),
517
521
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
518
522
  borrowReserve: this.reserve.address,
523
+ borrowReserveLiquidityMint: this.reserve.getLiquidityMint(),
519
524
  reserveSourceLiquidity: this.reserve.state.liquidity.supplyVault,
520
525
  userDestinationLiquidity: this.userTokenAccountAddress,
521
526
  borrowReserveLiquidityFeeReceiver: this.reserve.state.liquidity.feeVault,
522
527
  referrerTokenState: (0, utils_1.referrerTokenStatePda)(this.referrer, this.reserve.address, this.kaminoMarket.programId)[0],
523
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
528
+ tokenProgram: this.reserve.getLiquidityTokenProgram(),
524
529
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
525
530
  }, this.kaminoMarket.programId);
526
531
  borrowIx.keys = borrowIx.keys.concat([...depositReserveAccountMetas]);
@@ -538,12 +543,14 @@ class KaminoAction {
538
543
  lendingMarket: this.kaminoMarket.getAddress(),
539
544
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
540
545
  reserve: this.reserve.address,
546
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
541
547
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
542
548
  reserveCollateralMint: this.reserve.getCTokenMint(),
543
- reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
549
+ reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault, // destinationCollateral
544
550
  userSourceLiquidity: this.userTokenAccountAddress,
545
551
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
546
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
552
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
553
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
547
554
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
548
555
  }, this.kaminoMarket.programId));
549
556
  if (!this.outflowReserve) {
@@ -570,11 +577,12 @@ class KaminoAction {
570
577
  lendingMarket: this.kaminoMarket.getAddress(),
571
578
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
572
579
  borrowReserve: this.outflowReserve.address,
580
+ borrowReserveLiquidityMint: this.outflowReserve.getLiquidityMint(),
573
581
  reserveSourceLiquidity: this.outflowReserve.state.liquidity.supplyVault,
574
582
  userDestinationLiquidity: this.additionalTokenAccountAddress,
575
583
  borrowReserveLiquidityFeeReceiver: this.outflowReserve.state.liquidity.feeVault,
576
584
  referrerTokenState: (0, utils_1.referrerTokenStatePda)(this.referrer, this.outflowReserve.address, this.kaminoMarket.programId)[0],
577
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
585
+ tokenProgram: this.reserve.getLiquidityTokenProgram(),
578
586
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
579
587
  }, this.kaminoMarket.programId);
580
588
  borrowIx.keys = borrowIx.keys.concat([...depositReserveAccountMetas]);
@@ -592,9 +600,10 @@ class KaminoAction {
592
600
  obligation: this.getObligationPda(),
593
601
  lendingMarket: this.kaminoMarket.getAddress(),
594
602
  repayReserve: this.reserve.address,
603
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
595
604
  userSourceLiquidity: this.userTokenAccountAddress,
596
605
  reserveDestinationLiquidity: this.reserve.state.liquidity.supplyVault,
597
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
606
+ tokenProgram: this.reserve.getLiquidityTokenProgram(),
598
607
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
599
608
  }, this.kaminoMarket.programId));
600
609
  if (!this.outflowReserve) {
@@ -617,12 +626,14 @@ class KaminoAction {
617
626
  lendingMarket: this.kaminoMarket.getAddress(),
618
627
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
619
628
  withdrawReserve: this.outflowReserve.address,
629
+ reserveLiquidityMint: this.outflowReserve.getLiquidityMint(),
620
630
  reserveCollateralMint: this.outflowReserve.getCTokenMint(),
621
631
  reserveLiquiditySupply: this.outflowReserve.state.liquidity.supplyVault,
622
632
  reserveSourceCollateral: this.outflowReserve.state.collateral.supplyVault,
623
633
  userDestinationLiquidity: this.additionalTokenAccountAddress,
624
634
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
625
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
635
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
636
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
626
637
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
627
638
  }, this.kaminoMarket.programId));
628
639
  });
@@ -642,12 +653,14 @@ class KaminoAction {
642
653
  lendingMarket: this.kaminoMarket.getAddress(),
643
654
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
644
655
  withdrawReserve: this.reserve.address,
656
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
645
657
  reserveCollateralMint: this.reserve.getCTokenMint(),
646
658
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
647
659
  reserveSourceCollateral: this.reserve.state.collateral.supplyVault,
648
660
  userDestinationLiquidity: this.userTokenAccountAddress,
649
661
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
650
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
662
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
663
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
651
664
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
652
665
  }, this.kaminoMarket.programId));
653
666
  });
@@ -666,17 +679,18 @@ class KaminoAction {
666
679
  obligation: this.getObligationPda(),
667
680
  lendingMarket: this.kaminoMarket.getAddress(),
668
681
  repayReserve: this.reserve.address,
682
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
669
683
  userSourceLiquidity: this.userTokenAccountAddress,
670
684
  reserveDestinationLiquidity: this.reserve.state.liquidity.supplyVault,
671
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
685
+ tokenProgram: this.reserve.getLiquidityTokenProgram(),
672
686
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
673
687
  }, this.kaminoMarket.programId);
674
688
  repayIx.keys = repayIx.keys.concat([...depositReserveAccountMetas]);
675
689
  this.lendingIxs.push(repayIx);
676
690
  });
677
691
  }
678
- addLiquidateIx(maxAllowedLtvOverridePercent = 0) {
679
- return __awaiter(this, void 0, void 0, function* () {
692
+ addLiquidateIx() {
693
+ return __awaiter(this, arguments, void 0, function* (maxAllowedLtvOverridePercent = 0) {
680
694
  this.lendingIxsLabels.push(`liquidateObligationAndRedeemReserveCollateral`);
681
695
  if (!this.outflowReserve) {
682
696
  throw Error(`Withdraw reserve during liquidation is not defined`);
@@ -699,8 +713,10 @@ class KaminoAction {
699
713
  lendingMarket: this.kaminoMarket.getAddress(),
700
714
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
701
715
  repayReserve: this.reserve.address,
716
+ repayReserveLiquidityMint: this.reserve.getLiquidityMint(),
702
717
  repayReserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
703
718
  withdrawReserve: this.outflowReserve.address,
719
+ withdrawReserveLiquidityMint: this.outflowReserve.getLiquidityMint(),
704
720
  withdrawReserveCollateralMint: this.outflowReserve.getCTokenMint(),
705
721
  withdrawReserveCollateralSupply: this.outflowReserve.state.collateral.supplyVault,
706
722
  withdrawReserveLiquiditySupply: this.outflowReserve.state.liquidity.supplyVault,
@@ -708,15 +724,17 @@ class KaminoAction {
708
724
  userDestinationCollateral: this.userCollateralAccountAddress,
709
725
  userDestinationLiquidity: this.userTokenAccountAddress,
710
726
  withdrawReserveLiquidityFeeReceiver: this.outflowReserve.state.liquidity.feeVault,
711
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
727
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
728
+ repayLiquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
729
+ withdrawLiquidityTokenProgram: this.outflowReserve.getLiquidityTokenProgram(),
712
730
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
713
731
  }, this.kaminoMarket.programId);
714
732
  liquidateIx.keys = liquidateIx.keys.concat([...depositReserveAccountMetas]);
715
733
  this.lendingIxs.push(liquidateIx);
716
734
  });
717
735
  }
718
- addInBetweenIxs(action, includeAtaIxns, requestElevationGroup, addInitObligationForFarm, isClosingPosition = false) {
719
- return __awaiter(this, void 0, void 0, function* () {
736
+ addInBetweenIxs(action_1, includeAtaIxns_1, requestElevationGroup_1, addInitObligationForFarm_1) {
737
+ return __awaiter(this, arguments, void 0, function* (action, includeAtaIxns, requestElevationGroup, addInitObligationForFarm, isClosingPosition = false) {
720
738
  yield this.addSupportIxsWithoutInitObligation(action, includeAtaIxns, false, requestElevationGroup, addInitObligationForFarm, isClosingPosition);
721
739
  });
722
740
  }
@@ -730,9 +748,9 @@ class KaminoAction {
730
748
  this.addRefreshFarmsForReserve(this.borrowReserves.map((r) => this.kaminoMarket.getReserveByAddress(r)), addAllToSetupIxns, types_1.ReserveFarmKind.Debt, crank);
731
749
  this.addRefreshObligationIx(addAllToSetupIxns, false);
732
750
  }
733
- addSupportIxsWithoutInitObligation(action, includeAtaIxns, addToSetupIxs = true, requestElevationGroup = false, addInitObligationForFarm = false, isClosingPosition = false, twoTokenAction = false) {
734
- var _a;
735
- return __awaiter(this, void 0, void 0, function* () {
751
+ addSupportIxsWithoutInitObligation(action_1, includeAtaIxns_1) {
752
+ return __awaiter(this, arguments, void 0, function* (action, includeAtaIxns, addToSetupIxs = true, requestElevationGroup = false, addInitObligationForFarm = false, isClosingPosition = false, twoTokenAction = false) {
753
+ var _a;
736
754
  // TODO: why are we not doing this first?
737
755
  if (includeAtaIxns) {
738
756
  yield this.addAtaIxs(action);
@@ -913,8 +931,8 @@ class KaminoAction {
913
931
  }
914
932
  });
915
933
  }
916
- addSupportIxs(action, includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, twoTokenAction = false) {
917
- return __awaiter(this, void 0, void 0, function* () {
934
+ addSupportIxs(action_1, includeAtaIxns_1, requestElevationGroup_1, includeUserMetadata_1, addInitObligationForFarm_1) {
935
+ return __awaiter(this, arguments, void 0, function* (action, includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, twoTokenAction = false) {
918
936
  if (!['mint', 'redeem'].includes(action)) {
919
937
  const [, ownerUserMetadata] = yield this.kaminoMarket.getUserMetadata(this.owner);
920
938
  if (!ownerUserMetadata && includeUserMetadata) {
@@ -1092,7 +1110,6 @@ class KaminoAction {
1092
1110
  lendingMarket: this.kaminoMarket.getAddress(),
1093
1111
  farmsProgram: farms_sdk_1.farmsId,
1094
1112
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1095
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1096
1113
  systemProgram: web3_js_1.SystemProgram.programId,
1097
1114
  };
1098
1115
  const refreshFarmForObligationix = (0, instructions_1.refreshObligationFarmsForReserve)(args, accounts, this.kaminoMarket.programId);
@@ -1121,8 +1138,8 @@ class KaminoAction {
1121
1138
  this.cleanupIxs.splice(this.cleanupIxs.length - 1, 0, ...this.refreshFarmsCleanupTxnIxs);
1122
1139
  this.cleanupIxsLabels.splice(this.cleanupIxsLabels.length - 1, 0, ...this.refreshFarmsCleanupTxnIxsLabels);
1123
1140
  }
1124
- addInitObligationForFarm(reserve, mode, addToSetupIxs = true) {
1125
- return __awaiter(this, void 0, void 0, function* () {
1141
+ addInitObligationForFarm(reserve_1, mode_1) {
1142
+ return __awaiter(this, arguments, void 0, function* (reserve, mode, addToSetupIxs = true) {
1126
1143
  const BASE_SEED_USER_STATE = Buffer.from('user');
1127
1144
  const getPda = (farm) => web3_js_1.PublicKey.findProgramAddressSync([BASE_SEED_USER_STATE, farm.toBytes(), this.getObligationPda().toBytes()], farms_sdk_1.farmsId)[0];
1128
1145
  const farms = [];
@@ -1153,7 +1170,6 @@ class KaminoAction {
1153
1170
  lendingMarket: this.kaminoMarket.getAddress(),
1154
1171
  farmsProgram: farms_sdk_1.farmsId,
1155
1172
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1156
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1157
1173
  systemProgram: web3_js_1.SystemProgram.programId,
1158
1174
  };
1159
1175
  const initObligationForFarm = (0, instructions_1.initObligationFarmsForReserve)(args, accounts, this.kaminoMarket.programId);
@@ -1187,7 +1203,6 @@ class KaminoAction {
1187
1203
  seed2Account: this.obligationType.toArgs().seed2,
1188
1204
  ownerUserMetadata: userMetadataAddress,
1189
1205
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1190
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1191
1206
  systemProgram: web3_js_1.SystemProgram.programId,
1192
1207
  }, this.kaminoMarket.programId);
1193
1208
  this.setupIxs.push(initObligationIx);
@@ -1218,8 +1233,8 @@ class KaminoAction {
1218
1233
  this.setupIxsLabels.push(`initUserMetadata[${userMetadataAddress.toString()}]`);
1219
1234
  });
1220
1235
  }
1221
- addInitReferrerTokenStateIxs(reservesArr = []) {
1222
- return __awaiter(this, void 0, void 0, function* () {
1236
+ addInitReferrerTokenStateIxs() {
1237
+ return __awaiter(this, arguments, void 0, function* (reservesArr = []) {
1223
1238
  if (this.referrer.equals(web3_js_1.PublicKey.default)) {
1224
1239
  return;
1225
1240
  }
@@ -1256,11 +1271,12 @@ class KaminoAction {
1256
1271
  referrer: this.owner,
1257
1272
  lendingMarket: this.kaminoMarket.getAddress(),
1258
1273
  reserve: this.reserve.address,
1274
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
1259
1275
  referrerTokenState: referrerTokenStateAddress,
1260
1276
  reserveSupplyLiquidity: this.reserve.state.liquidity.supplyVault,
1261
1277
  referrerTokenAccount: this.userTokenAccountAddress,
1262
1278
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
1263
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1279
+ tokenProgram: this.reserve.getLiquidityTokenProgram(),
1264
1280
  }, this.kaminoMarket.programId);
1265
1281
  this.lendingIxs.push(withdrawReferrerFeesIx);
1266
1282
  this.lendingIxsLabels.push(`WithdrawReferrerFeesIx[${this.owner.toString()}]`);
@@ -1270,15 +1286,15 @@ class KaminoAction {
1270
1286
  this.setupIxsLabels.push(`AddComputeBudget[${units}]`);
1271
1287
  }
1272
1288
  addAtaIxs(action) {
1273
- var _a, _b;
1274
1289
  return __awaiter(this, void 0, void 0, function* () {
1290
+ var _a, _b;
1275
1291
  if (this.mint.equals(utils_1.WRAPPED_SOL_MINT) || ((_a = this.secondaryMint) === null || _a === void 0 ? void 0 : _a.equals(utils_1.WRAPPED_SOL_MINT))) {
1276
1292
  yield this.updateWSOLAccount(action);
1277
1293
  }
1278
1294
  if ((action === 'withdraw' || action === 'borrow' || action === 'redeem') && !this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1279
1295
  const userTokenAccountInfo = yield this.kaminoMarket.getConnection().getAccountInfo(this.userTokenAccountAddress);
1280
1296
  if (!userTokenAccountInfo) {
1281
- const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.userTokenAccountAddress);
1297
+ const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.reserve.getLiquidityTokenProgram(), this.userTokenAccountAddress);
1282
1298
  if (this.positions === exports.POSITION_LIMIT && this.hostAta) {
1283
1299
  this.preTxnIxs.push(createUserTokenAccountIx);
1284
1300
  this.preTxnIxsLabels.push(`CreateLiquidityUserAta[${this.owner}]`);
@@ -1295,7 +1311,7 @@ class KaminoAction {
1295
1311
  throw new Error(`Outflow reserve state not found ${this.mint}`);
1296
1312
  }
1297
1313
  if (!userTokenAccountInfo) {
1298
- const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.userTokenAccountAddress);
1314
+ const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.outflowReserve.getLiquidityTokenProgram(), this.userTokenAccountAddress);
1299
1315
  if (this.positions === exports.POSITION_LIMIT && this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1300
1316
  this.preTxnIxs.push(createUserTokenAccountIx);
1301
1317
  this.preTxnIxsLabels.push(`CreateUserAta[${this.userTokenAccountAddress.toBase58()}]`);
@@ -1309,7 +1325,7 @@ class KaminoAction {
1309
1325
  .getConnection()
1310
1326
  .getAccountInfo(this.userCollateralAccountAddress);
1311
1327
  if (!userCollateralAccountInfo) {
1312
- const [, createUserCollateralAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getCTokenMint(), this.owner, this.userCollateralAccountAddress);
1328
+ const [, createUserCollateralAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getCTokenMint(), this.owner, spl_token_1.TOKEN_PROGRAM_ID, this.userCollateralAccountAddress);
1313
1329
  if (this.positions === exports.POSITION_LIMIT && this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1314
1330
  this.preTxnIxs.push(createUserCollateralAccountIx);
1315
1331
  this.preTxnIxsLabels.push(`CreateCollateralUserAta[${this.userCollateralAccountAddress.toString()}]`);
@@ -1335,7 +1351,7 @@ class KaminoAction {
1335
1351
  .getConnection()
1336
1352
  .getAccountInfo(this.additionalTokenAccountAddress);
1337
1353
  if (!additionalUserTokenAccountInfo) {
1338
- const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.additionalTokenAccountAddress);
1354
+ const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.outflowReserve.getLiquidityTokenProgram(), this.additionalTokenAccountAddress);
1339
1355
  this.setupIxs.unshift(createUserTokenAccountIx);
1340
1356
  this.setupIxsLabels.unshift(`CreateAdditionalUserTokenAta[${this.owner}]`);
1341
1357
  }
@@ -1344,7 +1360,7 @@ class KaminoAction {
1344
1360
  const userTokenAccountInfo = yield this.kaminoMarket.getConnection().getAccountInfo(this.userTokenAccountAddress);
1345
1361
  // TODO: Might need to remove this
1346
1362
  if (!userTokenAccountInfo) {
1347
- const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.userTokenAccountAddress);
1363
+ const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.reserve.getLiquidityTokenProgram(), this.userTokenAccountAddress);
1348
1364
  this.preTxnIxs.push(createUserTokenAccountIx);
1349
1365
  this.preTxnIxsLabels.push(`CreateUserAta[${this.userTokenAccountAddress.toBase58()}]`);
1350
1366
  }
@@ -1355,7 +1371,7 @@ class KaminoAction {
1355
1371
  .getAccountInfo(this.userCollateralAccountAddress);
1356
1372
  if (!userCollateralAccountInfo) {
1357
1373
  const collateralMintPubkey = this.reserve.getCTokenMint();
1358
- const [, createUserCollateralAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, collateralMintPubkey, this.owner, this.userCollateralAccountAddress);
1374
+ const [, createUserCollateralAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, collateralMintPubkey, this.owner, spl_token_1.TOKEN_PROGRAM_ID, this.userCollateralAccountAddress);
1359
1375
  if (this.positions === exports.POSITION_LIMIT && this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1360
1376
  this.preTxnIxs.push(createUserCollateralAccountIx);
1361
1377
  this.preTxnIxsLabels.push(`CreateCollateralUserAta[${this.userCollateralAccountAddress.toString()}]`);
@@ -1369,8 +1385,8 @@ class KaminoAction {
1369
1385
  });
1370
1386
  }
1371
1387
  updateWSOLAccount(action) {
1372
- var _a, _b;
1373
1388
  return __awaiter(this, void 0, void 0, function* () {
1389
+ var _a, _b;
1374
1390
  const preIxs = [];
1375
1391
  const postIxs = [];
1376
1392
  const preIxsLabels = [];
@@ -1401,7 +1417,7 @@ class KaminoAction {
1401
1417
  userTokenAccountAddress = this.additionalTokenAccountAddress;
1402
1418
  }
1403
1419
  const userWSOLAccountInfo = yield this.kaminoMarket.getConnection().getAccountInfo(userTokenAccountAddress);
1404
- const rentExempt = yield spl_token_1.Token.getMinBalanceRentForExemptAccount(this.kaminoMarket.getConnection());
1420
+ const rentExempt = yield this.kaminoMarket.getConnection().getMinimumBalanceForRentExemption(165);
1405
1421
  // Add rent exemption lamports for WSOL accounts that need to be pre-funded for inflow/send transactions
1406
1422
  const sendAction = action === 'deposit' ||
1407
1423
  action === 'repay' ||
@@ -1414,7 +1430,7 @@ class KaminoAction {
1414
1430
  });
1415
1431
  preIxs.push(transferLamportsIx);
1416
1432
  preIxsLabels.push(`TransferLamportsToUserAtaSOL[${userTokenAccountAddress}]`);
1417
- const closeWSOLAccountIx = spl_token_1.Token.createCloseAccountInstruction(spl_token_1.TOKEN_PROGRAM_ID, userTokenAccountAddress, this.owner, this.owner, []);
1433
+ const closeWSOLAccountIx = (0, spl_token_1.createCloseAccountInstruction)(userTokenAccountAddress, this.owner, this.owner, [], spl_token_1.TOKEN_PROGRAM_ID);
1418
1434
  const syncIx = (0, utils_1.syncNative)(userTokenAccountAddress);
1419
1435
  if (userWSOLAccountInfo) {
1420
1436
  if (sendAction) {
@@ -1427,7 +1443,7 @@ class KaminoAction {
1427
1443
  }
1428
1444
  }
1429
1445
  else {
1430
- const [, createUserWSOLAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, spl_token_1.NATIVE_MINT, this.owner, userTokenAccountAddress);
1446
+ const [, createUserWSOLAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, spl_token_1.NATIVE_MINT, this.owner, spl_token_1.TOKEN_PROGRAM_ID, userTokenAccountAddress);
1431
1447
  preIxs.push(createUserWSOLAccountIx);
1432
1448
  preIxsLabels.push(`CreateUserAtaSOL[${userTokenAccountAddress}]`);
1433
1449
  preIxs.push(syncIx);
@@ -1449,15 +1465,15 @@ class KaminoAction {
1449
1465
  this.cleanupIxsLabels.push(...postIxsLabels);
1450
1466
  });
1451
1467
  }
1452
- static initializeMultiTokenAction(kaminoMarket, action, inflowAmount, inflowTokenMint, outflowTokenMint, payer, obligationOwner, obligation, outflowAmount, referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
1453
- return __awaiter(this, void 0, void 0, function* () {
1468
+ static initializeMultiTokenAction(kaminoMarket_1, action_1, inflowAmount_1, inflowTokenMint_1, outflowTokenMint_1, payer_1, obligationOwner_1, obligation_2, outflowAmount_1) {
1469
+ return __awaiter(this, arguments, void 0, function* (kaminoMarket, action, inflowAmount, inflowTokenMint, outflowTokenMint, payer, obligationOwner, obligation, outflowAmount, referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
1454
1470
  const inflowReserve = kaminoMarket.getReserveByMint(inflowTokenMint);
1455
1471
  const outflowReserve = kaminoMarket.getReserveByMint(outflowTokenMint);
1456
1472
  if (!outflowReserve || !inflowReserve) {
1457
1473
  throw new Error('reserve states are not fetched');
1458
1474
  }
1459
- const { userTokenAccountAddress: userOutflowTokenAccountAddress, userCollateralAccountAddress: userOutflowCollateralAccountAddress, } = yield KaminoAction.getUserAccountAddresses(payer, outflowReserve.state);
1460
- const { userTokenAccountAddress: userInflowTokenAccountAddress, userCollateralAccountAddress: userInflowCollateralAccountAddress, } = yield KaminoAction.getUserAccountAddresses(payer, inflowReserve.state);
1475
+ const { userTokenAccountAddress: userOutflowTokenAccountAddress, userCollateralAccountAddress: userOutflowCollateralAccountAddress, } = KaminoAction.getUserAccountAddresses(payer, outflowReserve.state);
1476
+ const { userTokenAccountAddress: userInflowTokenAccountAddress, userCollateralAccountAddress: userInflowCollateralAccountAddress, } = KaminoAction.getUserAccountAddresses(payer, inflowReserve.state);
1461
1477
  const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } = yield KaminoAction.loadObligation(action, kaminoMarket, obligationOwner, inflowReserve.address, obligation, outflowReserve.address);
1462
1478
  const [_, userMetadata] = yield kaminoMarket.getUserMetadata(payer);
1463
1479
  if (userMetadata) {
@@ -1496,8 +1512,8 @@ class KaminoAction {
1496
1512
  return new KaminoAction(kaminoMarket, payer, kaminoObligation || obligation, userTokenAccountAddress, userCollateralAccountAddress, primaryMint, distinctReserveCount, inflowAmount, depositReserves, borrowReserves, inflowReserve, currentSlot, undefined, secondaryMint, additionalUserTokenAccountAddress, outflowReserve, outflowAmount, referrerKey);
1497
1513
  });
1498
1514
  }
1499
- static initializeWithdrawReferrerFees(mint, owner, kaminoMarket, currentSlot = 0, hostAta) {
1500
- return __awaiter(this, void 0, void 0, function* () {
1515
+ static initializeWithdrawReferrerFees(mint_1, owner_1, kaminoMarket_1) {
1516
+ return __awaiter(this, arguments, void 0, function* (mint, owner, kaminoMarket, currentSlot = 0, hostAta) {
1501
1517
  const reserve = kaminoMarket.getReserveByMint(mint);
1502
1518
  if (reserve === undefined) {
1503
1519
  throw new Error(`Reserve ${mint} not found in market ${kaminoMarket.getAddress().toBase58()}`);