@kamino-finance/klend-sdk 2.12.0-SNAPSHOT.2 → 2.12.0

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 (78) hide show
  1. package/dist/classes/action.js +80 -79
  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 +9 -10
  6. package/dist/classes/market.js.map +1 -1
  7. package/dist/classes/obligation.js.map +1 -1
  8. package/dist/classes/reserve.js.map +1 -1
  9. package/dist/classes/shared.js +1 -1
  10. package/dist/classes/shared.js.map +1 -1
  11. package/dist/classes/utils.js.map +1 -1
  12. package/dist/idl_codegen/accounts/LendingMarket.js +4 -4
  13. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  14. package/dist/idl_codegen/accounts/Obligation.js +4 -4
  15. package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
  16. package/dist/idl_codegen/accounts/ReferrerState.js +4 -4
  17. package/dist/idl_codegen/accounts/ReferrerState.js.map +1 -1
  18. package/dist/idl_codegen/accounts/ReferrerTokenState.js +4 -4
  19. package/dist/idl_codegen/accounts/ReferrerTokenState.js.map +1 -1
  20. package/dist/idl_codegen/accounts/Reserve.js +4 -4
  21. package/dist/idl_codegen/accounts/Reserve.js.map +1 -1
  22. package/dist/idl_codegen/accounts/ShortUrl.js +4 -4
  23. package/dist/idl_codegen/accounts/ShortUrl.js.map +1 -1
  24. package/dist/idl_codegen/accounts/UserMetadata.js +4 -4
  25. package/dist/idl_codegen/accounts/UserMetadata.js.map +1 -1
  26. package/dist/idl_codegen/accounts/UserState.js +4 -4
  27. package/dist/idl_codegen/accounts/UserState.js.map +1 -1
  28. package/dist/idl_codegen/errors/anchor.js.map +1 -1
  29. package/dist/idl_codegen/errors/custom.js.map +1 -1
  30. package/dist/idl_codegen/errors/index.js.map +1 -1
  31. package/dist/idl_codegen/types/AssetTier.js.map +1 -1
  32. package/dist/idl_codegen/types/FeeCalculation.js.map +1 -1
  33. package/dist/idl_codegen/types/ReserveFarmKind.js.map +1 -1
  34. package/dist/idl_codegen/types/ReserveStatus.js.map +1 -1
  35. package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
  36. package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.js.map +1 -1
  37. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  38. package/dist/idl_codegen/zero_padding/ObligationZP.js +4 -4
  39. package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
  40. package/dist/idl_codegen_jupiter_perps/accounts/Pool.js +4 -4
  41. package/dist/idl_codegen_jupiter_perps/accounts/Pool.js.map +1 -1
  42. package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
  43. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  44. package/dist/leverage/calcs.js +3 -3
  45. package/dist/leverage/calcs.js.map +1 -1
  46. package/dist/leverage/operations.js +6 -5
  47. package/dist/leverage/operations.js.map +1 -1
  48. package/dist/leverage/utils.js +3 -3
  49. package/dist/leverage/utils.js.map +1 -1
  50. package/dist/referrals/instructions.js +2 -2
  51. package/dist/referrals/instructions.js.map +1 -1
  52. package/dist/referrals/operations.d.ts +2 -2
  53. package/dist/referrals/operations.js +15 -15
  54. package/dist/referrals/operations.js.map +1 -1
  55. package/dist/utils/ObligationType.js +1 -1
  56. package/dist/utils/ObligationType.js.map +1 -1
  57. package/dist/utils/api.js +2 -2
  58. package/dist/utils/api.js.map +1 -1
  59. package/dist/utils/ata.js +19 -3
  60. package/dist/utils/ata.js.map +1 -1
  61. package/dist/utils/constants.js.map +1 -1
  62. package/dist/utils/instruction.d.ts +1 -0
  63. package/dist/utils/instruction.js +13 -13
  64. package/dist/utils/instruction.js.map +1 -1
  65. package/dist/utils/kamino.js +24 -2
  66. package/dist/utils/kamino.js.map +1 -1
  67. package/dist/utils/layout.js.map +1 -1
  68. package/dist/utils/lookupTable.js.map +1 -1
  69. package/dist/utils/oracle.js.map +1 -1
  70. package/dist/utils/pubkey.js.map +1 -1
  71. package/dist/utils/rpc.js.map +1 -1
  72. package/dist/utils/seeds.js.map +1 -1
  73. package/dist/utils/token.d.ts +2 -0
  74. package/dist/utils/token.js +20 -0
  75. package/dist/utils/token.js.map +1 -0
  76. package/dist/utils/userMetadata.js +3 -3
  77. package/dist/utils/userMetadata.js.map +1 -1
  78. package/package.json +4 -4
@@ -24,6 +24,7 @@ const types_1 = require("../idl_codegen/types");
24
24
  const farms_sdk_1 = require("@hubbleprotocol/farms-sdk");
25
25
  const ObligationType_1 = require("../utils/ObligationType");
26
26
  const lib_1 = require("../lib");
27
+ const token_1 = require("../utils/token");
27
28
  exports.POSITION_LIMIT = 10;
28
29
  exports.BORROWS_LIMIT = 5;
29
30
  exports.DEPOSITS_LIMIT = 8;
@@ -76,8 +77,8 @@ class KaminoAction {
76
77
  this.referrer = referrer ? referrer : web3_js_1.PublicKey.default;
77
78
  this.currentSlot = currentSlot;
78
79
  }
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) {
80
+ static initialize(action, amount, mint, owner, kaminoMarket, obligation, referrer = web3_js_1.PublicKey.default, currentSlot = 0, hostAta, payer) {
81
+ return __awaiter(this, void 0, void 0, function* () {
81
82
  const reserve = kaminoMarket.getReserveByMint(mint);
82
83
  if (reserve === undefined) {
83
84
  throw new Error(`Reserve ${mint} not found in market ${kaminoMarket.getAddress().toBase58()}`);
@@ -142,9 +143,9 @@ class KaminoAction {
142
143
  };
143
144
  });
144
145
  }
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) {
146
+ static buildRefreshObligationTxns(kaminoMarket, payer, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
147
+ currentSlot = 0) {
148
+ return __awaiter(this, void 0, void 0, function* () {
148
149
  // placeholder for action initialization
149
150
  const firstReserve = obligation.state.deposits[0].depositReserve;
150
151
  const firstKaminoReserve = kaminoMarket.getReserveByAddress(firstReserve);
@@ -159,9 +160,9 @@ class KaminoAction {
159
160
  return axn;
160
161
  });
161
162
  }
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) {
163
+ static buildRequestElevationGroupTxns(kaminoMarket, payer, obligation, elevationGroup, extraComputeBudget = 1000000, // if > 0 then adds the ixn
164
+ currentSlot = 0) {
165
+ return __awaiter(this, void 0, void 0, function* () {
165
166
  const firstReserve = obligation.state.deposits[0].depositReserve;
166
167
  const firstKaminoReserve = kaminoMarket.getReserveByAddress(firstReserve);
167
168
  if (!firstKaminoReserve) {
@@ -176,11 +177,11 @@ class KaminoAction {
176
177
  return axn;
177
178
  });
178
179
  }
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) {
180
+ static buildDepositTxns(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) {
184
+ return __awaiter(this, void 0, void 0, function* () {
184
185
  const axn = yield KaminoAction.initialize('deposit', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
185
186
  const addInitObligationForFarm = true;
186
187
  if (extraComputeBudget > 0) {
@@ -192,11 +193,11 @@ class KaminoAction {
192
193
  return axn;
193
194
  });
194
195
  }
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) {
196
+ static buildBorrowTxns(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) {
200
+ return __awaiter(this, void 0, void 0, function* () {
200
201
  const axn = yield KaminoAction.initialize('borrow', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot, hostAta);
201
202
  const addInitObligationForFarm = true;
202
203
  if (extraComputeBudget > 0) {
@@ -208,11 +209,11 @@ class KaminoAction {
208
209
  return axn;
209
210
  });
210
211
  }
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) {
212
+ static buildDepositReserveLiquidityTxns(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) {
216
+ return __awaiter(this, void 0, void 0, function* () {
216
217
  const axn = yield KaminoAction.initialize('mint', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
217
218
  const addInitObligationForFarm = true;
218
219
  if (extraComputeBudget > 0) {
@@ -224,11 +225,11 @@ class KaminoAction {
224
225
  return axn;
225
226
  });
226
227
  }
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) {
228
+ static buildRedeemReserveCollateralTxns(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) {
232
+ return __awaiter(this, void 0, void 0, function* () {
232
233
  const axn = yield KaminoAction.initialize('redeem', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
233
234
  const addInitObligationForFarm = true;
234
235
  if (extraComputeBudget > 0) {
@@ -240,11 +241,11 @@ class KaminoAction {
240
241
  return axn;
241
242
  });
242
243
  }
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) {
244
+ static buildDepositObligationCollateralTxns(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) {
248
+ return __awaiter(this, void 0, void 0, function* () {
248
249
  const axn = yield KaminoAction.initialize('depositCollateral', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
249
250
  const addInitObligationForFarm = true;
250
251
  if (extraComputeBudget > 0) {
@@ -256,11 +257,11 @@ class KaminoAction {
256
257
  return axn;
257
258
  });
258
259
  }
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) {
260
+ static buildDepositAndBorrowTxns(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) {
264
+ return __awaiter(this, void 0, void 0, function* () {
264
265
  const axn = yield KaminoAction.initializeMultiTokenAction(kaminoMarket, 'depositAndBorrow', depositAmount, depositMint, borrowMint, payer, payer, obligation, borrowAmount, referrer, currentSlot);
265
266
  const addInitObligationForFarmForDeposit = true;
266
267
  const addInitObligationForFarmForBorrow = false;
@@ -275,11 +276,11 @@ class KaminoAction {
275
276
  return axn;
276
277
  });
277
278
  }
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) {
279
+ static buildRepayAndWithdrawTxns(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) {
283
+ return __awaiter(this, void 0, void 0, function* () {
283
284
  const axn = yield KaminoAction.initializeMultiTokenAction(kaminoMarket, 'repayAndWithdraw', repayAmount, repayMint, withdrawMint, payer, payer, obligation, withdrawAmount, referrer, currentSlot);
284
285
  const addInitObligationForFarmForRepay = true;
285
286
  const addInitObligationForFarmForWithdraw = false;
@@ -294,11 +295,11 @@ class KaminoAction {
294
295
  return axn;
295
296
  });
296
297
  }
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) {
298
+ static buildWithdrawTxns(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) {
302
+ return __awaiter(this, void 0, void 0, function* () {
302
303
  const axn = yield KaminoAction.initialize('withdraw', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
303
304
  const addInitObligationForFarm = true;
304
305
  if (extraComputeBudget > 0) {
@@ -325,8 +326,8 @@ class KaminoAction {
325
326
  * @param includeUserMetadata - if true it includes user metadata
326
327
  * @param referrer
327
328
  */
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) {
329
+ static buildRepayTxns(kaminoMarket, amount, mint, owner, obligation, currentSlot, payer = undefined, extraComputeBudget = 1000000, includeAtaIxns = true, requestElevationGroup = false, includeUserMetadata = true, referrer = web3_js_1.PublicKey.default) {
330
+ return __awaiter(this, void 0, void 0, function* () {
330
331
  const axn = yield KaminoAction.initialize('repay', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot, undefined, payer);
331
332
  const addInitObligationForFarm = true;
332
333
  if (extraComputeBudget > 0) {
@@ -338,11 +339,11 @@ class KaminoAction {
338
339
  return axn;
339
340
  });
340
341
  }
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) {
342
+ static buildLiquidateTxns(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) {
346
+ return __awaiter(this, void 0, void 0, function* () {
346
347
  const axn = yield KaminoAction.initializeMultiTokenAction(kaminoMarket, 'liquidate', amount, repayTokenMint, withdrawTokenMint, liquidator, obligationOwner, obligation, minCollateralReceiveAmount, referrer, currentSlot);
347
348
  const addInitObligationForFarm = true;
348
349
  if (extraComputeBudget > 0) {
@@ -354,8 +355,8 @@ class KaminoAction {
354
355
  return axn;
355
356
  });
356
357
  }
357
- static buildWithdrawReferrerFeeTxns(owner_1, tokenMint_1, kaminoMarket_1) {
358
- return __awaiter(this, arguments, void 0, function* (owner, tokenMint, kaminoMarket, currentSlot = 0) {
358
+ static buildWithdrawReferrerFeeTxns(owner, tokenMint, kaminoMarket, currentSlot = 0) {
359
+ return __awaiter(this, void 0, void 0, function* () {
359
360
  const { axn, createAtasIxns } = yield KaminoAction.initializeWithdrawReferrerFees(tokenMint, owner, kaminoMarket, currentSlot);
360
361
  axn.preTxnIxs.push(...createAtasIxns);
361
362
  axn.preTxnIxsLabels.push(`createAtasIxs[${axn.userTokenAccountAddress.toString()}]`);
@@ -445,7 +446,7 @@ class KaminoAction {
445
446
  reserveLiquidityMint: this.reserve.getLiquidityMint(),
446
447
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
447
448
  reserveCollateralMint: this.reserve.getCTokenMint(),
448
- reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault, // destinationCollateral
449
+ reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
449
450
  userSourceLiquidity: this.userTokenAccountAddress,
450
451
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
451
452
  collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
@@ -546,7 +547,7 @@ class KaminoAction {
546
547
  reserveLiquidityMint: this.reserve.getLiquidityMint(),
547
548
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
548
549
  reserveCollateralMint: this.reserve.getCTokenMint(),
549
- reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault, // destinationCollateral
550
+ reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
550
551
  userSourceLiquidity: this.userTokenAccountAddress,
551
552
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
552
553
  collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
@@ -689,8 +690,8 @@ class KaminoAction {
689
690
  this.lendingIxs.push(repayIx);
690
691
  });
691
692
  }
692
- addLiquidateIx() {
693
- return __awaiter(this, arguments, void 0, function* (maxAllowedLtvOverridePercent = 0) {
693
+ addLiquidateIx(maxAllowedLtvOverridePercent = 0) {
694
+ return __awaiter(this, void 0, void 0, function* () {
694
695
  this.lendingIxsLabels.push(`liquidateObligationAndRedeemReserveCollateral`);
695
696
  if (!this.outflowReserve) {
696
697
  throw Error(`Withdraw reserve during liquidation is not defined`);
@@ -733,8 +734,8 @@ class KaminoAction {
733
734
  this.lendingIxs.push(liquidateIx);
734
735
  });
735
736
  }
736
- addInBetweenIxs(action_1, includeAtaIxns_1, requestElevationGroup_1, addInitObligationForFarm_1) {
737
- return __awaiter(this, arguments, void 0, function* (action, includeAtaIxns, requestElevationGroup, addInitObligationForFarm, isClosingPosition = false) {
737
+ addInBetweenIxs(action, includeAtaIxns, requestElevationGroup, addInitObligationForFarm, isClosingPosition = false) {
738
+ return __awaiter(this, void 0, void 0, function* () {
738
739
  yield this.addSupportIxsWithoutInitObligation(action, includeAtaIxns, false, requestElevationGroup, addInitObligationForFarm, isClosingPosition);
739
740
  });
740
741
  }
@@ -748,9 +749,9 @@ class KaminoAction {
748
749
  this.addRefreshFarmsForReserve(this.borrowReserves.map((r) => this.kaminoMarket.getReserveByAddress(r)), addAllToSetupIxns, types_1.ReserveFarmKind.Debt, crank);
749
750
  this.addRefreshObligationIx(addAllToSetupIxns, false);
750
751
  }
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;
752
+ addSupportIxsWithoutInitObligation(action, includeAtaIxns, addToSetupIxs = true, requestElevationGroup = false, addInitObligationForFarm = false, isClosingPosition = false, twoTokenAction = false) {
753
+ var _a;
754
+ return __awaiter(this, void 0, void 0, function* () {
754
755
  // TODO: why are we not doing this first?
755
756
  if (includeAtaIxns) {
756
757
  yield this.addAtaIxs(action);
@@ -931,8 +932,8 @@ class KaminoAction {
931
932
  }
932
933
  });
933
934
  }
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) {
935
+ addSupportIxs(action, includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, twoTokenAction = false) {
936
+ return __awaiter(this, void 0, void 0, function* () {
936
937
  if (!['mint', 'redeem'].includes(action)) {
937
938
  const [, ownerUserMetadata] = yield this.kaminoMarket.getUserMetadata(this.owner);
938
939
  if (!ownerUserMetadata && includeUserMetadata) {
@@ -1138,8 +1139,8 @@ class KaminoAction {
1138
1139
  this.cleanupIxs.splice(this.cleanupIxs.length - 1, 0, ...this.refreshFarmsCleanupTxnIxs);
1139
1140
  this.cleanupIxsLabels.splice(this.cleanupIxsLabels.length - 1, 0, ...this.refreshFarmsCleanupTxnIxsLabels);
1140
1141
  }
1141
- addInitObligationForFarm(reserve_1, mode_1) {
1142
- return __awaiter(this, arguments, void 0, function* (reserve, mode, addToSetupIxs = true) {
1142
+ addInitObligationForFarm(reserve, mode, addToSetupIxs = true) {
1143
+ return __awaiter(this, void 0, void 0, function* () {
1143
1144
  const BASE_SEED_USER_STATE = Buffer.from('user');
1144
1145
  const getPda = (farm) => web3_js_1.PublicKey.findProgramAddressSync([BASE_SEED_USER_STATE, farm.toBytes(), this.getObligationPda().toBytes()], farms_sdk_1.farmsId)[0];
1145
1146
  const farms = [];
@@ -1233,8 +1234,8 @@ class KaminoAction {
1233
1234
  this.setupIxsLabels.push(`initUserMetadata[${userMetadataAddress.toString()}]`);
1234
1235
  });
1235
1236
  }
1236
- addInitReferrerTokenStateIxs() {
1237
- return __awaiter(this, arguments, void 0, function* (reservesArr = []) {
1237
+ addInitReferrerTokenStateIxs(reservesArr = []) {
1238
+ return __awaiter(this, void 0, void 0, function* () {
1238
1239
  if (this.referrer.equals(web3_js_1.PublicKey.default)) {
1239
1240
  return;
1240
1241
  }
@@ -1286,8 +1287,8 @@ class KaminoAction {
1286
1287
  this.setupIxsLabels.push(`AddComputeBudget[${units}]`);
1287
1288
  }
1288
1289
  addAtaIxs(action) {
1290
+ var _a, _b;
1289
1291
  return __awaiter(this, void 0, void 0, function* () {
1290
- var _a, _b;
1291
1292
  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))) {
1292
1293
  yield this.updateWSOLAccount(action);
1293
1294
  }
@@ -1385,8 +1386,8 @@ class KaminoAction {
1385
1386
  });
1386
1387
  }
1387
1388
  updateWSOLAccount(action) {
1389
+ var _a, _b;
1388
1390
  return __awaiter(this, void 0, void 0, function* () {
1389
- var _a, _b;
1390
1391
  const preIxs = [];
1391
1392
  const postIxs = [];
1392
1393
  const preIxsLabels = [];
@@ -1430,7 +1431,7 @@ class KaminoAction {
1430
1431
  });
1431
1432
  preIxs.push(transferLamportsIx);
1432
1433
  preIxsLabels.push(`TransferLamportsToUserAtaSOL[${userTokenAccountAddress}]`);
1433
- const closeWSOLAccountIx = (0, spl_token_1.createCloseAccountInstruction)(userTokenAccountAddress, this.owner, this.owner, [], spl_token_1.TOKEN_PROGRAM_ID);
1434
+ const closeWSOLAccountIx = (0, token_1.createCloseAccountInstruction)(userTokenAccountAddress, this.owner, this.owner, spl_token_1.TOKEN_PROGRAM_ID);
1434
1435
  const syncIx = (0, utils_1.syncNative)(userTokenAccountAddress);
1435
1436
  if (userWSOLAccountInfo) {
1436
1437
  if (sendAction) {
@@ -1465,8 +1466,8 @@ class KaminoAction {
1465
1466
  this.cleanupIxsLabels.push(...postIxsLabels);
1466
1467
  });
1467
1468
  }
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) {
1469
+ static initializeMultiTokenAction(kaminoMarket, action, inflowAmount, inflowTokenMint, outflowTokenMint, payer, obligationOwner, obligation, outflowAmount, referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
1470
+ return __awaiter(this, void 0, void 0, function* () {
1470
1471
  const inflowReserve = kaminoMarket.getReserveByMint(inflowTokenMint);
1471
1472
  const outflowReserve = kaminoMarket.getReserveByMint(outflowTokenMint);
1472
1473
  if (!outflowReserve || !inflowReserve) {
@@ -1512,8 +1513,8 @@ class KaminoAction {
1512
1513
  return new KaminoAction(kaminoMarket, payer, kaminoObligation || obligation, userTokenAccountAddress, userCollateralAccountAddress, primaryMint, distinctReserveCount, inflowAmount, depositReserves, borrowReserves, inflowReserve, currentSlot, undefined, secondaryMint, additionalUserTokenAccountAddress, outflowReserve, outflowAmount, referrerKey);
1513
1514
  });
1514
1515
  }
1515
- static initializeWithdrawReferrerFees(mint_1, owner_1, kaminoMarket_1) {
1516
- return __awaiter(this, arguments, void 0, function* (mint, owner, kaminoMarket, currentSlot = 0, hostAta) {
1516
+ static initializeWithdrawReferrerFees(mint, owner, kaminoMarket, currentSlot = 0, hostAta) {
1517
+ return __awaiter(this, void 0, void 0, function* () {
1517
1518
  const reserve = kaminoMarket.getReserveByMint(mint);
1518
1519
  if (reserve === undefined) {
1519
1520
  throw new Error(`Reserve ${mint} not found in market ${kaminoMarket.getAddress().toBase58()}`);