@kamino-finance/klend-sdk 5.13.0 → 5.13.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 (116) hide show
  1. package/dist/classes/action.d.ts +74 -49
  2. package/dist/classes/action.d.ts.map +1 -1
  3. package/dist/classes/action.js +167 -115
  4. package/dist/classes/action.js.map +1 -1
  5. package/dist/classes/fraction.d.ts +2 -0
  6. package/dist/classes/fraction.d.ts.map +1 -1
  7. package/dist/classes/fraction.js +6 -0
  8. package/dist/classes/fraction.js.map +1 -1
  9. package/dist/classes/index.d.ts +3 -2
  10. package/dist/classes/index.d.ts.map +1 -1
  11. package/dist/classes/index.js +3 -2
  12. package/dist/classes/index.js.map +1 -1
  13. package/dist/classes/manager.d.ts +7 -7
  14. package/dist/classes/manager.d.ts.map +1 -1
  15. package/dist/classes/manager.js +46 -46
  16. package/dist/classes/manager.js.map +1 -1
  17. package/dist/classes/obligation.d.ts.map +1 -1
  18. package/dist/classes/obligation.js +1 -6
  19. package/dist/classes/obligation.js.map +1 -1
  20. package/dist/classes/obligationOrder.d.ts +1 -1
  21. package/dist/classes/obligationOrder.d.ts.map +1 -1
  22. package/dist/classes/reserve.d.ts +2 -2
  23. package/dist/classes/reserve.d.ts.map +1 -1
  24. package/dist/classes/reserve.js +71 -74
  25. package/dist/classes/reserve.js.map +1 -1
  26. package/dist/classes/shared.d.ts +13 -0
  27. package/dist/classes/shared.d.ts.map +1 -1
  28. package/dist/classes/utils.d.ts +1 -9
  29. package/dist/classes/utils.d.ts.map +1 -1
  30. package/dist/classes/utils.js +4 -51
  31. package/dist/classes/utils.js.map +1 -1
  32. package/dist/classes/vault.d.ts +5 -3
  33. package/dist/classes/vault.d.ts.map +1 -1
  34. package/dist/classes/vault.js +53 -41
  35. package/dist/classes/vault.js.map +1 -1
  36. package/dist/classes/{types.d.ts → vault_types.d.ts} +2 -15
  37. package/dist/classes/vault_types.d.ts.map +1 -0
  38. package/dist/classes/{types.js → vault_types.js} +1 -1
  39. package/dist/classes/vault_types.js.map +1 -0
  40. package/dist/client_kamino_manager.d.ts.map +1 -1
  41. package/dist/client_kamino_manager.js +25 -26
  42. package/dist/client_kamino_manager.js.map +1 -1
  43. package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
  44. package/dist/lending_operations/repay_with_collateral_operations.js +8 -8
  45. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  46. package/dist/lending_operations/swap_collateral_operations.d.ts +6 -6
  47. package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
  48. package/dist/lending_operations/swap_collateral_operations.js +63 -65
  49. package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
  50. package/dist/leverage/calcs.d.ts +0 -1
  51. package/dist/leverage/calcs.d.ts.map +1 -1
  52. package/dist/leverage/calcs.js +5 -8
  53. package/dist/leverage/calcs.js.map +1 -1
  54. package/dist/leverage/operations.d.ts +5 -5
  55. package/dist/leverage/operations.d.ts.map +1 -1
  56. package/dist/leverage/operations.js +80 -87
  57. package/dist/leverage/operations.js.map +1 -1
  58. package/dist/leverage/types.d.ts +1 -1
  59. package/dist/leverage/types.d.ts.map +1 -1
  60. package/dist/leverage/utils.d.ts +2 -2
  61. package/dist/leverage/utils.d.ts.map +1 -1
  62. package/dist/leverage/utils.js +5 -5
  63. package/dist/leverage/utils.js.map +1 -1
  64. package/dist/referrals/instructions.d.ts +3 -3
  65. package/dist/referrals/instructions.d.ts.map +1 -1
  66. package/dist/referrals/instructions.js +10 -10
  67. package/dist/referrals/instructions.js.map +1 -1
  68. package/dist/referrals/operations.js +6 -6
  69. package/dist/referrals/operations.js.map +1 -1
  70. package/dist/utils/ata.d.ts +3 -3
  71. package/dist/utils/ata.d.ts.map +1 -1
  72. package/dist/utils/ata.js +22 -22
  73. package/dist/utils/ata.js.map +1 -1
  74. package/dist/utils/instruction.d.ts +2 -2
  75. package/dist/utils/instruction.d.ts.map +1 -1
  76. package/dist/utils/instruction.js +12 -12
  77. package/dist/utils/instruction.js.map +1 -1
  78. package/dist/utils/lookupTable.js +6 -6
  79. package/dist/utils/lookupTable.js.map +1 -1
  80. package/dist/utils/userMetadata.d.ts +1 -1
  81. package/dist/utils/userMetadata.d.ts.map +1 -1
  82. package/dist/utils/userMetadata.js +3 -3
  83. package/dist/utils/userMetadata.js.map +1 -1
  84. package/package.json +1 -1
  85. package/src/classes/action.ts +198 -150
  86. package/src/classes/fraction.ts +7 -0
  87. package/src/classes/index.ts +5 -2
  88. package/src/classes/manager.ts +54 -51
  89. package/src/classes/obligation.ts +2 -7
  90. package/src/classes/obligationOrder.ts +1 -1
  91. package/src/classes/reserve.ts +128 -137
  92. package/src/classes/shared.ts +15 -0
  93. package/src/classes/utils.ts +3 -52
  94. package/src/classes/vault.ts +56 -42
  95. package/src/classes/{types.ts → vault_types.ts} +1 -16
  96. package/src/client.ts +16 -16
  97. package/src/client_kamino_manager.ts +25 -25
  98. package/src/lending_operations/repay_with_collateral_operations.ts +13 -15
  99. package/src/lending_operations/swap_collateral_operations.ts +87 -89
  100. package/src/leverage/calcs.ts +2 -6
  101. package/src/leverage/operations.ts +91 -97
  102. package/src/leverage/types.ts +1 -1
  103. package/src/leverage/utils.ts +5 -5
  104. package/src/referrals/instructions.ts +6 -6
  105. package/src/referrals/operations.ts +9 -9
  106. package/src/utils/ata.ts +18 -18
  107. package/src/utils/instruction.ts +10 -10
  108. package/src/utils/lookupTable.ts +6 -6
  109. package/src/utils/userMetadata.ts +1 -1
  110. package/dist/classes/types.d.ts.map +0 -1
  111. package/dist/classes/types.js.map +0 -1
  112. package/dist/classes/types_utils.d.ts +0 -14
  113. package/dist/classes/types_utils.d.ts.map +0 -1
  114. package/dist/classes/types_utils.js +0 -50
  115. package/dist/classes/types_utils.js.map +0 -1
  116. package/src/classes/types_utils.ts +0 -49
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getScopeRefreshIx = void 0;
7
7
  exports.getDepositWithLeverageSwapInputs = getDepositWithLeverageSwapInputs;
8
- exports.getDepositWithLeverageIxns = getDepositWithLeverageIxns;
8
+ exports.getDepositWithLeverageIxs = getDepositWithLeverageIxs;
9
9
  exports.getWithdrawWithLeverageSwapInputs = getWithdrawWithLeverageSwapInputs;
10
- exports.getWithdrawWithLeverageIxns = getWithdrawWithLeverageIxns;
11
- exports.buildWithdrawWithLeverageIxns = buildWithdrawWithLeverageIxns;
10
+ exports.getWithdrawWithLeverageIxs = getWithdrawWithLeverageIxs;
11
+ exports.buildWithdrawWithLeverageIxs = buildWithdrawWithLeverageIxs;
12
12
  exports.getAdjustLeverageSwapInputs = getAdjustLeverageSwapInputs;
13
- exports.getAdjustLeverageIxns = getAdjustLeverageIxns;
13
+ exports.getAdjustLeverageIxs = getAdjustLeverageIxs;
14
14
  const web3_js_1 = require("@solana/web3.js");
15
15
  const decimal_js_1 = __importDefault(require("decimal.js"));
16
16
  const classes_1 = require("../classes");
@@ -31,7 +31,7 @@ async function getDepositWithLeverageSwapInputs({ owner, kaminoMarket, debtToken
31
31
  const collIsKtoken = await isKtoken(collTokenMint);
32
32
  const strategy = collIsKtoken ? (await kamino.getStrategyByKTokenMint(collTokenMint)) : undefined;
33
33
  const calcs = await getDepositWithLeverageCalcs(depositAmount, selectedTokenIsCollToken, collIsKtoken, depositTokenIsSol, priceDebtToColl, targetLeverage, slippagePct, flashLoanFee, kamino, strategy, debtTokenMint, priceAinB, debtReserve);
34
- console.log('Ops Calcs', (0, calcs_1.toJson)(calcs));
34
+ console.log('Ops Calcs', (0, classes_1.toJson)(calcs));
35
35
  let obligationType;
36
36
  if (obligationTypeTagOverride === utils_1.ObligationTypeTag.Multiply) {
37
37
  // multiply
@@ -45,7 +45,7 @@ async function getDepositWithLeverageSwapInputs({ owner, kaminoMarket, debtToken
45
45
  throw Error('Obligation type tag not supported for leverage, please use 1 - multiply or 3 - leverage');
46
46
  }
47
47
  // Build the repay & withdraw collateral tx to get the number of accounts
48
- const klendIxs = await buildDepositWithLeverageIxns(kaminoMarket, debtReserve, collReserve, owner, obligation ? obligation : obligationType, referrer, currentSlot, depositTokenIsSol, scopeRefreshConfig, calcs, budgetAndPriorityFeeIxs, {
48
+ const klendIxs = await buildDepositWithLeverageIxs(kaminoMarket, debtReserve, collReserve, owner, obligation ? obligation : obligationType, referrer, currentSlot, depositTokenIsSol, scopeRefreshConfig, calcs, budgetAndPriorityFeeIxs, {
49
49
  preActionIxs: [],
50
50
  swapIxs: [],
51
51
  lookupTables: [],
@@ -124,7 +124,7 @@ async function getDepositWithLeverageCalcs(depositAmount, selectedTokenIsCollTok
124
124
  }
125
125
  return calcs;
126
126
  }
127
- async function getDepositWithLeverageIxns({ owner, kaminoMarket, debtTokenMint, collTokenMint, depositAmount, priceDebtToColl, slippagePct, obligation, referrer, currentSlot, targetLeverage, selectedTokenMint, kamino, obligationTypeTagOverride, scopeRefreshConfig, budgetAndPriorityFeeIxs, quoteBufferBps, priceAinB, isKtoken, quoter, swapper, elevationGroupOverride, useV2Ixs, }) {
127
+ async function getDepositWithLeverageIxs({ owner, kaminoMarket, debtTokenMint, collTokenMint, depositAmount, priceDebtToColl, slippagePct, obligation, referrer, currentSlot, targetLeverage, selectedTokenMint, kamino, obligationTypeTagOverride, scopeRefreshConfig, budgetAndPriorityFeeIxs, quoteBufferBps, priceAinB, isKtoken, quoter, swapper, elevationGroupOverride, useV2Ixs, }) {
128
128
  const { swapInputs, initialInputs } = await getDepositWithLeverageSwapInputs({
129
129
  owner,
130
130
  kaminoMarket,
@@ -172,7 +172,7 @@ async function getDepositWithLeverageIxns({ owner, kaminoMarket, debtTokenMint,
172
172
  const debtReserve = kaminoMarket.getReserveByMint(debtTokenMint);
173
173
  const solTokenReserve = kaminoMarket.getReserveByMint(spl_token_1.NATIVE_MINT);
174
174
  const depositTokenIsSol = !solTokenReserve ? false : selectedTokenMint.equals(solTokenReserve.getLiquidityMint());
175
- const ixs = await buildDepositWithLeverageIxns(kaminoMarket, debtReserve, collReserve, owner, initialInputs.obligation, referrer, currentSlot, depositTokenIsSol, scopeRefreshConfig, initialInputs.calcs, budgetAndPriorityFeeIxs, {
175
+ const ixs = await buildDepositWithLeverageIxs(kaminoMarket, debtReserve, collReserve, owner, initialInputs.obligation, referrer, currentSlot, depositTokenIsSol, scopeRefreshConfig, initialInputs.calcs, budgetAndPriorityFeeIxs, {
176
176
  preActionIxs: [],
177
177
  swapIxs: swapIxs,
178
178
  lookupTables: lookupTables,
@@ -185,13 +185,13 @@ async function getDepositWithLeverageIxns({ owner, kaminoMarket, debtTokenMint,
185
185
  initialInputs,
186
186
  };
187
187
  }
188
- async function buildDepositWithLeverageIxns(market, debtReserve, collReserve, owner, obligation, referrer, currentSlot, depositTokenIsSol, scopeRefreshConfig, calcs, budgetAndPriorityFeeIxs, swapQuoteIxs, strategy, collIsKtoken, useV2Ixs, elevationGroupOverride) {
189
- const budgetIxns = budgetAndPriorityFeeIxs || (0, utils_1.getComputeBudgetAndPriorityFeeIxns)(3000000);
188
+ async function buildDepositWithLeverageIxs(market, debtReserve, collReserve, owner, obligation, referrer, currentSlot, depositTokenIsSol, scopeRefreshConfig, calcs, budgetAndPriorityFeeIxs, swapQuoteIxs, strategy, collIsKtoken, useV2Ixs, elevationGroupOverride) {
189
+ const budgetIxs = budgetAndPriorityFeeIxs || (0, utils_1.getComputeBudgetAndPriorityFeeIxs)(3000000);
190
190
  const collTokenMint = collReserve.getLiquidityMint();
191
191
  const debtTokenMint = debtReserve.getLiquidityMint();
192
192
  const collTokenAta = (0, spl_token_1.getAssociatedTokenAddressSync)(collTokenMint, owner, false, collReserve.getLiquidityTokenProgram());
193
193
  const debtTokenAta = (0, spl_token_1.getAssociatedTokenAddressSync)(debtTokenMint, owner, false, debtReserve.getLiquidityTokenProgram());
194
- // 1. Create atas & budget ixns
194
+ // 1. Create atas & budget ixs
195
195
  let mintsToCreateAtas;
196
196
  if (collIsKtoken) {
197
197
  const secondTokenAta = strategy.strategy.tokenAMint.equals(debtTokenMint)
@@ -239,16 +239,16 @@ async function buildDepositWithLeverageIxns(market, debtReserve, collReserve, ow
239
239
  },
240
240
  ];
241
241
  }
242
- const atasAndCreateIxns = (0, utils_1.createAtasIdempotent)(owner, mintsToCreateAtas);
243
- const fillWsolAtaIxns = [];
242
+ const atasAndCreateIxs = (0, utils_1.createAtasIdempotent)(owner, mintsToCreateAtas);
243
+ const fillWsolAtaIxs = [];
244
244
  if (depositTokenIsSol) {
245
- fillWsolAtaIxns.push(...(0, utils_1.getTransferWsolIxns)(owner, (0, spl_token_1.getAssociatedTokenAddressSync)(spl_token_1.NATIVE_MINT, owner), (0, classes_2.numberToLamportsDecimal)(calcs.initDepositInSol, utils_1.SOL_DECIMALS).ceil()));
245
+ fillWsolAtaIxs.push(...(0, utils_1.getTransferWsolIxs)(owner, (0, spl_token_1.getAssociatedTokenAddressSync)(spl_token_1.NATIVE_MINT, owner), (0, classes_2.numberToLamportsDecimal)(calcs.initDepositInSol, utils_1.SOL_DECIMALS).ceil()));
246
246
  }
247
247
  const scopeRefreshIxn = await (0, exports.getScopeRefreshIx)(market, collReserve, debtReserve, obligation, scopeRefreshConfig);
248
248
  // 2. Flash borrow & repay the collateral amount needed for given leverage
249
249
  // if user deposits coll, then we borrow the diff, else we borrow the entire amount
250
250
  const { flashBorrowIxn, flashRepayIxn } = (0, instructions_1.getFlashLoanInstructions)({
251
- borrowIxnIndex: budgetIxns.length + atasAndCreateIxns.length + fillWsolAtaIxns.length + (scopeRefreshIxn.length > 0 ? 1 : 0),
251
+ borrowIxnIndex: budgetIxs.length + atasAndCreateIxs.length + fillWsolAtaIxs.length + (scopeRefreshIxn.length > 0 ? 1 : 0),
252
252
  walletPublicKey: owner,
253
253
  lendingMarketAuthority: market.getLendingMarketAuthority(),
254
254
  lendingMarketAddress: market.getAddress(),
@@ -266,12 +266,11 @@ async function buildDepositWithLeverageIxns(market, debtReserve, collReserve, ow
266
266
  .toString(), collTokenMint, (0, classes_2.numberToLamportsDecimal)(!collIsKtoken ? calcs.debtTokenToBorrow : calcs.debtTokenToBorrow, debtReserve.stats.decimals)
267
267
  .ceil()
268
268
  .toString(), debtTokenMint, owner, obligation, useV2Ixs, undefined, 0, false, elevationGroupOverride === 0 ? false : true, // emode
269
- false, // to be checked and created in a setup tx in the UI
270
- false, // to be checked and created in a setup tx in the UI
269
+ { skipInitialization: true, skipLutCreation: true }, // to be checked and created in a setup tx in the UI
271
270
  referrer, currentSlot);
272
271
  // 4. Swap
273
272
  const { swapIxs } = swapQuoteIxs;
274
- const swapInstructions = (0, utils_1.removeBudgetAndAtaIxns)(swapIxs, []);
273
+ const swapInstructions = (0, utils_1.removeBudgetAndAtaIxs)(swapIxs, []);
275
274
  const flashBorrowReserve = !collIsKtoken ? collReserve : debtReserve;
276
275
  const flashLoanInfo = {
277
276
  flashBorrowReserve: flashBorrowReserve.address,
@@ -282,9 +281,9 @@ async function buildDepositWithLeverageIxns(market, debtReserve, collReserve, ow
282
281
  flashLoanInfo,
283
282
  instructions: [
284
283
  ...scopeRefreshIxn,
285
- ...budgetIxns,
286
- ...atasAndCreateIxns.map((x) => x.createAtaIx),
287
- ...fillWsolAtaIxns,
284
+ ...budgetIxs,
285
+ ...atasAndCreateIxs.map((x) => x.createAtaIx),
286
+ ...fillWsolAtaIxs,
288
287
  ...[flashBorrowIxn],
289
288
  ...classes_1.KaminoAction.actionToIxs(kaminoDepositAndBorrowAction),
290
289
  ...swapInstructions,
@@ -297,9 +296,9 @@ async function buildDepositWithLeverageIxns(market, debtReserve, collReserve, ow
297
296
  flashLoanInfo,
298
297
  instructions: [
299
298
  ...scopeRefreshIxn,
300
- ...budgetIxns,
301
- ...atasAndCreateIxns.map((x) => x.createAtaIx),
302
- ...fillWsolAtaIxns,
299
+ ...budgetIxs,
300
+ ...atasAndCreateIxs.map((x) => x.createAtaIx),
301
+ ...fillWsolAtaIxs,
303
302
  ...[flashBorrowIxn],
304
303
  ...swapInstructions,
305
304
  ...kaminoDepositAndBorrowAction.setupIxs,
@@ -320,7 +319,7 @@ async function getWithdrawWithLeverageSwapInputs({ owner, kaminoMarket, debtToke
320
319
  const solTokenReserve = kaminoMarket.getReserveByMint(spl_token_1.NATIVE_MINT);
321
320
  const depositTokenIsSol = !solTokenReserve ? false : selectedTokenMint.equals(solTokenReserve.getLiquidityMint());
322
321
  const calcs = (0, calcs_1.withdrawLeverageCalcs)(kaminoMarket, collReserve, debtReserve, priceCollToDebt, withdrawAmount, deposited, borrowed, currentSlot, isClosingPosition, selectedTokenIsCollToken, selectedTokenMint, obligation, flashLoanFee, slippagePct);
323
- const klendIxs = await buildWithdrawWithLeverageIxns(kaminoMarket, debtReserve, collReserve, owner, obligation, referrer, currentSlot, isClosingPosition, depositTokenIsSol, scopeRefreshConfig, calcs, budgetAndPriorityFeeIxs, {
322
+ const klendIxs = await buildWithdrawWithLeverageIxs(kaminoMarket, debtReserve, collReserve, owner, obligation, referrer, currentSlot, isClosingPosition, depositTokenIsSol, scopeRefreshConfig, calcs, budgetAndPriorityFeeIxs, {
324
323
  preActionIxs: [],
325
324
  swapIxs: [],
326
325
  lookupTables: [],
@@ -356,7 +355,7 @@ async function getWithdrawWithLeverageSwapInputs({ owner, kaminoMarket, debtToke
356
355
  },
357
356
  };
358
357
  }
359
- async function getWithdrawWithLeverageIxns({ owner, kaminoMarket, debtTokenMint, collTokenMint, obligation, deposited, borrowed, referrer, currentSlot, withdrawAmount, priceCollToDebt, slippagePct, isClosingPosition, selectedTokenMint, budgetAndPriorityFeeIxs, kamino, scopeRefreshConfig, quoteBufferBps, isKtoken, quoter, swapper, useV2Ixs, }) {
358
+ async function getWithdrawWithLeverageIxs({ owner, kaminoMarket, debtTokenMint, collTokenMint, obligation, deposited, borrowed, referrer, currentSlot, withdrawAmount, priceCollToDebt, slippagePct, isClosingPosition, selectedTokenMint, budgetAndPriorityFeeIxs, kamino, scopeRefreshConfig, quoteBufferBps, isKtoken, quoter, swapper, useV2Ixs, }) {
360
359
  const collReserve = kaminoMarket.getReserveByMint(collTokenMint);
361
360
  const debtReserve = kaminoMarket.getReserveByMint(debtTokenMint);
362
361
  const solTokenReserve = kaminoMarket.getReserveByMint(spl_token_1.NATIVE_MINT);
@@ -404,12 +403,12 @@ async function getWithdrawWithLeverageIxns({ owner, kaminoMarket, debtTokenMint,
404
403
  console.log('Strategy lookup table not found');
405
404
  }
406
405
  }
407
- const ixs = await buildWithdrawWithLeverageIxns(kaminoMarket, debtReserve, collReserve, owner, obligation, referrer, currentSlot, isClosingPosition, depositTokenIsSol, scopeRefreshConfig, initialInputs.calcs, budgetAndPriorityFeeIxs, {
406
+ const ixs = await buildWithdrawWithLeverageIxs(kaminoMarket, debtReserve, collReserve, owner, obligation, referrer, currentSlot, isClosingPosition, depositTokenIsSol, scopeRefreshConfig, initialInputs.calcs, budgetAndPriorityFeeIxs, {
408
407
  preActionIxs: [],
409
408
  swapIxs,
410
409
  lookupTables,
411
410
  }, initialInputs.strategy, initialInputs.collIsKtoken, useV2Ixs);
412
- // Send ixns and lookup tables
411
+ // Send ixs and lookup tables
413
412
  return {
414
413
  ixs: ixs.instructions,
415
414
  flashLoanInfo: ixs.flashLoanInfo,
@@ -418,7 +417,7 @@ async function getWithdrawWithLeverageIxns({ owner, kaminoMarket, debtTokenMint,
418
417
  initialInputs: initialInputs,
419
418
  };
420
419
  }
421
- async function buildWithdrawWithLeverageIxns(market, debtReserve, collReserve, owner, obligation, referrer, currentSlot, isClosingPosition, depositTokenIsSol, scopeRefreshConfig, calcs, budgetAndPriorityFeeIxs, swapQuoteIxs, strategy, collIsKtoken, useV2Ixs) {
420
+ async function buildWithdrawWithLeverageIxs(market, debtReserve, collReserve, owner, obligation, referrer, currentSlot, isClosingPosition, depositTokenIsSol, scopeRefreshConfig, calcs, budgetAndPriorityFeeIxs, swapQuoteIxs, strategy, collIsKtoken, useV2Ixs) {
422
421
  const collTokenMint = collReserve.getLiquidityMint();
423
422
  const debtTokenMint = debtReserve.getLiquidityMint();
424
423
  const debtTokenAta = (0, spl_token_1.getAssociatedTokenAddressSync)(debtTokenMint, owner, false, debtReserve.getLiquidityTokenProgram());
@@ -470,27 +469,27 @@ async function buildWithdrawWithLeverageIxns(market, debtReserve, collReserve, o
470
469
  },
471
470
  ];
472
471
  }
473
- const atasAndCreateIxns = (0, utils_1.createAtasIdempotent)(owner, mintsToCreateAtas);
474
- const closeWsolAtaIxns = [];
472
+ const atasAndCreateIxs = (0, utils_1.createAtasIdempotent)(owner, mintsToCreateAtas);
473
+ const closeWsolAtaIxs = [];
475
474
  if (depositTokenIsSol || debtTokenMint.equals(spl_token_1.NATIVE_MINT)) {
476
475
  const wsolAta = (0, utils_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, owner, false);
477
- closeWsolAtaIxns.push((0, spl_token_1.createCloseAccountInstruction)(wsolAta, owner, owner, [], spl_token_1.TOKEN_PROGRAM_ID));
476
+ closeWsolAtaIxs.push((0, spl_token_1.createCloseAccountInstruction)(wsolAta, owner, owner, [], spl_token_1.TOKEN_PROGRAM_ID));
478
477
  }
479
- const budgetIxns = budgetAndPriorityFeeIxs || (0, utils_1.getComputeBudgetAndPriorityFeeIxns)(3000000);
478
+ const budgetIxs = budgetAndPriorityFeeIxs || (0, utils_1.getComputeBudgetAndPriorityFeeIxs)(3000000);
480
479
  // TODO: Mihai/Marius check if we can improve this logic and not convert any SOL
481
480
  // This is here so that we have enough wsol to repay in case the kAB swapped to sol after estimates is not enough
482
- const fillWsolAtaIxns = [];
481
+ const fillWsolAtaIxs = [];
483
482
  if (debtTokenMint.equals(spl_token_1.NATIVE_MINT)) {
484
483
  const halfSolBalance = (await market.getConnection().getBalance(owner)) / web3_js_1.LAMPORTS_PER_SOL / 2;
485
484
  const balanceToWrap = halfSolBalance < 0.1 ? halfSolBalance : 0.1;
486
- fillWsolAtaIxns.push(...(0, utils_1.getTransferWsolIxns)(owner, (0, spl_token_1.getAssociatedTokenAddressSync)(spl_token_1.NATIVE_MINT, owner), (0, classes_2.numberToLamportsDecimal)(balanceToWrap, utils_1.SOL_DECIMALS).ceil()));
485
+ fillWsolAtaIxs.push(...(0, utils_1.getTransferWsolIxs)(owner, (0, spl_token_1.getAssociatedTokenAddressSync)(spl_token_1.NATIVE_MINT, owner), (0, classes_2.numberToLamportsDecimal)(balanceToWrap, utils_1.SOL_DECIMALS).ceil()));
487
486
  }
488
487
  const scopeRefreshIxn = await (0, exports.getScopeRefreshIx)(market, collReserve, debtReserve, obligation, scopeRefreshConfig);
489
- // 2. Prepare the flash borrow and flash repay amounts and ixns
488
+ // 2. Prepare the flash borrow and flash repay amounts and ixs
490
489
  // We borrow exactly how much we need to repay
491
490
  // and repay that + flash amount fee
492
491
  const { flashBorrowIxn, flashRepayIxn } = (0, instructions_1.getFlashLoanInstructions)({
493
- borrowIxnIndex: budgetIxns.length + atasAndCreateIxns.length + fillWsolAtaIxns.length + (scopeRefreshIxn.length > 0 ? 1 : 0),
492
+ borrowIxnIndex: budgetIxs.length + atasAndCreateIxs.length + fillWsolAtaIxs.length + (scopeRefreshIxn.length > 0 ? 1 : 0),
494
493
  walletPublicKey: owner,
495
494
  lendingMarketAuthority: market.getLendingMarketAuthority(),
496
495
  lendingMarketAddress: market.getAddress(),
@@ -505,10 +504,9 @@ async function buildWithdrawWithLeverageIxns(market, debtReserve, collReserve, o
505
504
  // 3. Repay borrowed tokens and Withdraw tokens from reserve that will be swapped to repay flash loan
506
505
  const repayAndWithdrawAction = await classes_1.KaminoAction.buildRepayAndWithdrawTxns(market, isClosingPosition ? utils_1.U64_MAX : (0, classes_2.numberToLamportsDecimal)(calcs.repayAmount, debtReserve.stats.decimals).floor().toString(), debtTokenMint, isClosingPosition
507
506
  ? utils_1.U64_MAX
508
- : (0, classes_2.numberToLamportsDecimal)(calcs.depositTokenWithdrawAmount, collReserve.stats.decimals).ceil().toString(), collTokenMint, owner, currentSlot, obligation, useV2Ixs, undefined, 0, false, false, // to be checked and created in a setup tx in the UI (won't be the case for withdraw anyway as this would be created in deposit)
509
- false, // to be checked and created in a setup tx in the UI (won't be the case for withdraw anyway as this would be created in deposit)
510
- isClosingPosition, referrer);
511
- const swapInstructions = (0, utils_1.removeBudgetAndAtaIxns)(swapQuoteIxs.swapIxs, []);
507
+ : (0, classes_2.numberToLamportsDecimal)(calcs.depositTokenWithdrawAmount, collReserve.stats.decimals).ceil().toString(), collTokenMint, owner, currentSlot, obligation, useV2Ixs, undefined, 0, false, false, { skipInitialization: true, skipLutCreation: true }, // to be checked and created in a setup tx in the UI (won't be the case for withdraw anyway as this would be created in deposit)
508
+ referrer);
509
+ const swapInstructions = (0, utils_1.removeBudgetAndAtaIxs)(swapQuoteIxs.swapIxs, []);
512
510
  return {
513
511
  flashLoanInfo: {
514
512
  flashLoanFee: debtReserve.getFlashLoanFee(),
@@ -516,14 +514,14 @@ async function buildWithdrawWithLeverageIxns(market, debtReserve, collReserve, o
516
514
  },
517
515
  instructions: [
518
516
  ...scopeRefreshIxn,
519
- ...budgetIxns,
520
- ...atasAndCreateIxns.map((x) => x.createAtaIx),
521
- ...fillWsolAtaIxns,
517
+ ...budgetIxs,
518
+ ...atasAndCreateIxs.map((x) => x.createAtaIx),
519
+ ...fillWsolAtaIxs,
522
520
  ...[flashBorrowIxn],
523
521
  ...classes_1.KaminoAction.actionToIxs(repayAndWithdrawAction),
524
522
  ...swapInstructions,
525
523
  ...[flashRepayIxn],
526
- ...closeWsolAtaIxns,
524
+ ...closeWsolAtaIxs,
527
525
  ],
528
526
  };
529
527
  }
@@ -558,7 +556,7 @@ async function getAdjustLeverageSwapInputs({ owner, kaminoMarket, debtTokenMint,
558
556
  if (isDeposit) {
559
557
  const calcs = await (0, calcs_1.adjustDepositLeverageCalcs)(kaminoMarket, owner, debtReserve, adjustDepositPosition, adjustBorrowPosition, priceDebtToColl, flashLoanFee, slippagePct, collIsKtoken);
560
558
  // Build the repay & withdraw collateral tx to get the number of accounts
561
- const klendIxs = await buildIncreaseLeverageIxns(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, calcs, strategy, scopeRefreshConfig, collIsKtoken, {
559
+ const klendIxs = await buildIncreaseLeverageIxs(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, calcs, strategy, scopeRefreshConfig, collIsKtoken, {
562
560
  preActionIxs: [],
563
561
  swapIxs: [],
564
562
  lookupTables: [],
@@ -608,7 +606,7 @@ async function getAdjustLeverageSwapInputs({ owner, kaminoMarket, debtTokenMint,
608
606
  }
609
607
  else {
610
608
  const calcs = (0, calcs_1.adjustWithdrawLeverageCalcs)(adjustDepositPosition, adjustBorrowPosition, flashLoanFee, slippagePct);
611
- const klendIxs = await buildDecreaseLeverageIxns(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, calcs, strategy, scopeRefreshConfig, collIsKtoken, {
609
+ const klendIxs = await buildDecreaseLeverageIxs(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, calcs, strategy, scopeRefreshConfig, collIsKtoken, {
612
610
  preActionIxs: [],
613
611
  swapIxs: [],
614
612
  lookupTables: [],
@@ -653,7 +651,7 @@ async function getAdjustLeverageSwapInputs({ owner, kaminoMarket, debtTokenMint,
653
651
  };
654
652
  }
655
653
  }
656
- async function getAdjustLeverageIxns({ owner, kaminoMarket, debtTokenMint, collTokenMint, obligation, depositedLamports, borrowedLamports, referrer, currentSlot, targetLeverage, priceCollToDebt, priceDebtToColl, slippagePct, budgetAndPriorityFeeIxs, kamino, scopeRefreshConfig, quoteBufferBps, priceAinB, isKtoken, quoter, swapper, useV2Ixs, }) {
654
+ async function getAdjustLeverageIxs({ owner, kaminoMarket, debtTokenMint, collTokenMint, obligation, depositedLamports, borrowedLamports, referrer, currentSlot, targetLeverage, priceCollToDebt, priceDebtToColl, slippagePct, budgetAndPriorityFeeIxs, kamino, scopeRefreshConfig, quoteBufferBps, priceAinB, isKtoken, quoter, swapper, useV2Ixs, }) {
657
655
  const { swapInputs, initialInputs } = await getAdjustLeverageSwapInputs({
658
656
  owner,
659
657
  kaminoMarket,
@@ -690,7 +688,7 @@ async function getAdjustLeverageIxns({ owner, kaminoMarket, debtTokenMint, collT
690
688
  depositSwapper = swapper;
691
689
  }
692
690
  const { swapIxs, lookupTables } = await depositSwapper(swapInputs, initialInputs.klendAccounts, initialInputs.swapQuote);
693
- const ixs = await buildIncreaseLeverageIxns(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, initialInputs.calcs, initialInputs.strategy, scopeRefreshConfig, initialInputs.collIsKtoken, {
691
+ const ixs = await buildIncreaseLeverageIxs(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, initialInputs.calcs, initialInputs.strategy, scopeRefreshConfig, initialInputs.collIsKtoken, {
694
692
  preActionIxs: [],
695
693
  swapIxs,
696
694
  lookupTables,
@@ -715,9 +713,9 @@ async function getAdjustLeverageIxns({ owner, kaminoMarket, debtTokenMint, collT
715
713
  else {
716
714
  withdrawSwapper = swapper;
717
715
  }
718
- // 5. Get swap ixns
716
+ // 5. Get swap ixs
719
717
  const { swapIxs, lookupTables } = await withdrawSwapper(swapInputs, initialInputs.klendAccounts, initialInputs.swapQuote);
720
- const ixs = await buildDecreaseLeverageIxns(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, initialInputs.calcs, initialInputs.strategy, scopeRefreshConfig, initialInputs.collIsKtoken, {
718
+ const ixs = await buildDecreaseLeverageIxs(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, initialInputs.calcs, initialInputs.strategy, scopeRefreshConfig, initialInputs.collIsKtoken, {
721
719
  preActionIxs: [],
722
720
  swapIxs,
723
721
  lookupTables,
@@ -734,13 +732,13 @@ async function getAdjustLeverageIxns({ owner, kaminoMarket, debtTokenMint, collT
734
732
  /**
735
733
  * Deposit and borrow tokens if leverage increased
736
734
  */
737
- async function buildIncreaseLeverageIxns(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, calcs, strategy, scopeRefreshConfig, collIsKtoken, swapQuoteIxs, budgetAndPriorityFeeIxns, useV2Ixs) {
735
+ async function buildIncreaseLeverageIxs(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, calcs, strategy, scopeRefreshConfig, collIsKtoken, swapQuoteIxs, budgetAndPriorityFeeIxs, useV2Ixs) {
738
736
  const collReserve = kaminoMarket.getReserveByMint(collTokenMint);
739
737
  const debtReserve = kaminoMarket.getReserveByMint(debtTokenMint);
740
738
  const debtTokenAta = (0, spl_token_1.getAssociatedTokenAddressSync)(debtTokenMint, owner, false, debtReserve.getLiquidityTokenProgram());
741
739
  const collTokenAta = (0, spl_token_1.getAssociatedTokenAddressSync)(collTokenMint, owner, false, collReserve.getLiquidityTokenProgram());
742
740
  // 1. Create atas & budget txns
743
- const budgetIxns = budgetAndPriorityFeeIxns || (0, utils_1.getComputeBudgetAndPriorityFeeIxns)(3000000);
741
+ const budgetIxs = budgetAndPriorityFeeIxs || (0, utils_1.getComputeBudgetAndPriorityFeeIxs)(3000000);
744
742
  let mintsToCreateAtas;
745
743
  if (collIsKtoken) {
746
744
  const secondTokenAta = strategy.strategy.tokenAMint.equals(debtTokenMint)
@@ -788,11 +786,11 @@ async function buildIncreaseLeverageIxns(owner, kaminoMarket, collTokenMint, deb
788
786
  },
789
787
  ];
790
788
  }
791
- const atasAndCreateIxns = (0, utils_1.createAtasIdempotent)(owner, mintsToCreateAtas);
789
+ const atasAndCreateIxs = (0, utils_1.createAtasIdempotent)(owner, mintsToCreateAtas);
792
790
  const scopeRefreshIxn = await (0, exports.getScopeRefreshIx)(kaminoMarket, collReserve, debtReserve, obligation, scopeRefreshConfig);
793
791
  // 2. Create borrow flash loan instruction
794
792
  const { flashBorrowIxn, flashRepayIxn } = (0, instructions_1.getFlashLoanInstructions)({
795
- borrowIxnIndex: budgetIxns.length + atasAndCreateIxns.length + (scopeRefreshIxn.length > 0 ? 1 : 0), // TODO: how about user metadata ixns
793
+ borrowIxnIndex: budgetIxs.length + atasAndCreateIxs.length + (scopeRefreshIxn.length > 0 ? 1 : 0), // TODO: how about user metadata ixs
796
794
  walletPublicKey: owner,
797
795
  lendingMarketAuthority: kaminoMarket.getLendingMarketAuthority(),
798
796
  lendingMarketAddress: kaminoMarket.getAddress(),
@@ -804,19 +802,16 @@ async function buildIncreaseLeverageIxns(owner, kaminoMarket, collTokenMint, deb
804
802
  referrerTokenState: kaminoMarket.programId,
805
803
  programId: kaminoMarket.programId,
806
804
  });
807
- const depositAction = await classes_1.KaminoAction.buildDepositTxns(kaminoMarket, (0, classes_2.numberToLamportsDecimal)(calcs.adjustDepositPosition, collReserve.stats.decimals).floor().toString(), collTokenMint, owner, obligation, useV2Ixs, undefined, 0, false, false, false, // to be checked and create in a setup tx in the UI (won't be the case for adjust anyway as this would be created in deposit)
808
- false, // to be checked and create in a setup tx in the UI (won't be the case for adjust anyway as this would be created in deposit)
809
- referrer, currentSlot);
805
+ const depositAction = await classes_1.KaminoAction.buildDepositTxns(kaminoMarket, (0, classes_2.numberToLamportsDecimal)(calcs.adjustDepositPosition, collReserve.stats.decimals).floor().toString(), collTokenMint, owner, obligation, useV2Ixs, undefined, 0, false, false, { skipInitialization: true, skipLutCreation: true }, referrer, currentSlot);
810
806
  // 4. Borrow tokens in borrow token reserve that will be swapped to repay flash loan
811
- const borrowAction = await classes_1.KaminoAction.buildBorrowTxns(kaminoMarket, (0, classes_2.numberToLamportsDecimal)(calcs.borrowAmount, debtReserve.stats.decimals).ceil().toString(), debtTokenMint, owner, obligation, useV2Ixs, undefined, 0, false, false, false, // to be checked and create in a setup tx in the UI (won't be the case for adjust anyway as this would be created in deposit)
812
- false, // to be checked and create in a setup tx in the UI (won't be the case for adjust anyway as this would be created in deposit)
807
+ const borrowAction = await classes_1.KaminoAction.buildBorrowTxns(kaminoMarket, (0, classes_2.numberToLamportsDecimal)(calcs.borrowAmount, debtReserve.stats.decimals).ceil().toString(), debtTokenMint, owner, obligation, useV2Ixs, undefined, 0, false, false, { skipInitialization: true, skipLutCreation: true }, // to be checked and create in a setup tx in the UI (won't be the case for adjust anyway as this would be created in deposit)
813
808
  referrer, currentSlot);
814
- const swapInstructions = (0, utils_1.removeBudgetAndAtaIxns)(swapQuoteIxs.swapIxs, []);
809
+ const swapInstructions = (0, utils_1.removeBudgetAndAtaIxs)(swapQuoteIxs.swapIxs, []);
815
810
  const ixs = !collIsKtoken
816
811
  ? [
817
812
  ...scopeRefreshIxn,
818
- ...budgetIxns,
819
- ...atasAndCreateIxns.map((x) => x.createAtaIx),
813
+ ...budgetIxs,
814
+ ...atasAndCreateIxs.map((x) => x.createAtaIx),
820
815
  ...[flashBorrowIxn],
821
816
  ...classes_1.KaminoAction.actionToIxs(depositAction),
822
817
  ...classes_1.KaminoAction.actionToIxs(borrowAction),
@@ -825,8 +820,8 @@ async function buildIncreaseLeverageIxns(owner, kaminoMarket, collTokenMint, deb
825
820
  ]
826
821
  : [
827
822
  ...scopeRefreshIxn,
828
- ...budgetIxns,
829
- ...atasAndCreateIxns.map((x) => x.createAtaIx),
823
+ ...budgetIxs,
824
+ ...atasAndCreateIxs.map((x) => x.createAtaIx),
830
825
  ...[flashBorrowIxn],
831
826
  ...swapInstructions,
832
827
  ...classes_1.KaminoAction.actionToIxs(depositAction),
@@ -846,12 +841,12 @@ async function buildIncreaseLeverageIxns(owner, kaminoMarket, collTokenMint, deb
846
841
  /**
847
842
  * Withdraw and repay tokens if leverage decreased
848
843
  */
849
- async function buildDecreaseLeverageIxns(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, calcs, strategy, scopeRefreshConfig, collIsKtoken, swapQuoteIxs, budgetAndPriorityFeeIxns, useV2Ixs) {
844
+ async function buildDecreaseLeverageIxs(owner, kaminoMarket, collTokenMint, debtTokenMint, obligation, referrer, currentSlot, calcs, strategy, scopeRefreshConfig, collIsKtoken, swapQuoteIxs, budgetAndPriorityFeeIxs, useV2Ixs) {
850
845
  const collReserve = kaminoMarket.getReserveByMint(collTokenMint);
851
846
  const debtReserve = kaminoMarket.getReserveByMint(debtTokenMint);
852
847
  const debtTokenAta = (0, spl_token_1.getAssociatedTokenAddressSync)(debtTokenMint, owner, false, debtReserve.getLiquidityTokenProgram());
853
848
  // 1. Create atas & budget txns
854
- const budgetIxns = budgetAndPriorityFeeIxns || (0, utils_1.getComputeBudgetAndPriorityFeeIxns)(3000000);
849
+ const budgetIxs = budgetAndPriorityFeeIxs || (0, utils_1.getComputeBudgetAndPriorityFeeIxs)(3000000);
855
850
  let mintsToCreateAtas;
856
851
  if (collIsKtoken) {
857
852
  const secondTokenAta = strategy.strategy.tokenAMint.equals(debtTokenMint)
@@ -899,22 +894,22 @@ async function buildDecreaseLeverageIxns(owner, kaminoMarket, collTokenMint, deb
899
894
  },
900
895
  ];
901
896
  }
902
- const atasAndCreateIxns = (0, utils_1.createAtasIdempotent)(owner, mintsToCreateAtas);
897
+ const atasAndCreateIxs = (0, utils_1.createAtasIdempotent)(owner, mintsToCreateAtas);
903
898
  // TODO: Mihai/Marius check if we can improve this logic and not convert any SOL
904
899
  // This is here so that we have enough wsol to repay in case the kAB swapped to sol after estimates is not enough
905
- const closeWsolAtaIxns = [];
906
- const fillWsolAtaIxns = [];
900
+ const closeWsolAtaIxs = [];
901
+ const fillWsolAtaIxs = [];
907
902
  if (debtTokenMint.equals(spl_token_1.NATIVE_MINT)) {
908
903
  const wsolAta = (0, utils_1.getAssociatedTokenAddress)(spl_token_1.NATIVE_MINT, owner, false);
909
- closeWsolAtaIxns.push((0, spl_token_1.createCloseAccountInstruction)(wsolAta, owner, owner, [], spl_token_1.TOKEN_PROGRAM_ID));
904
+ closeWsolAtaIxs.push((0, spl_token_1.createCloseAccountInstruction)(wsolAta, owner, owner, [], spl_token_1.TOKEN_PROGRAM_ID));
910
905
  const halfSolBalance = (await kaminoMarket.getConnection().getBalance(owner)) / web3_js_1.LAMPORTS_PER_SOL / 2;
911
906
  const balanceToWrap = halfSolBalance < 0.1 ? halfSolBalance : 0.1;
912
- fillWsolAtaIxns.push(...(0, utils_1.getTransferWsolIxns)(owner, wsolAta, (0, classes_2.numberToLamportsDecimal)(balanceToWrap, debtReserve.stats.decimals).ceil()));
907
+ fillWsolAtaIxs.push(...(0, utils_1.getTransferWsolIxs)(owner, wsolAta, (0, classes_2.numberToLamportsDecimal)(balanceToWrap, debtReserve.stats.decimals).ceil()));
913
908
  }
914
909
  const scopeRefreshIxn = await (0, exports.getScopeRefreshIx)(kaminoMarket, collReserve, debtReserve, obligation, scopeRefreshConfig);
915
910
  // 3. Flash borrow & repay amount to repay (debt)
916
911
  const { flashBorrowIxn, flashRepayIxn } = (0, instructions_1.getFlashLoanInstructions)({
917
- borrowIxnIndex: budgetIxns.length + atasAndCreateIxns.length + fillWsolAtaIxns.length + (scopeRefreshIxn.length > 0 ? 1 : 0),
912
+ borrowIxnIndex: budgetIxs.length + atasAndCreateIxs.length + fillWsolAtaIxs.length + (scopeRefreshIxn.length > 0 ? 1 : 0),
918
913
  walletPublicKey: owner,
919
914
  lendingMarketAuthority: kaminoMarket.getLendingMarketAuthority(),
920
915
  lendingMarketAddress: kaminoMarket.getAddress(),
@@ -927,32 +922,30 @@ async function buildDecreaseLeverageIxns(owner, kaminoMarket, collTokenMint, deb
927
922
  programId: kaminoMarket.programId,
928
923
  });
929
924
  // 4. Actually do the repay of the flash borrowed amounts
930
- const repayAction = await classes_1.KaminoAction.buildRepayTxns(kaminoMarket, (0, classes_2.numberToLamportsDecimal)(decimal_js_1.default.abs(calcs.adjustBorrowPosition), debtReserve.stats.decimals).floor().toString(), debtTokenMint, owner, obligation, useV2Ixs, undefined, currentSlot, undefined, 0, false, false, false, // to be checked and create in a setup tx in the UI (won't be the case for adjust anyway as this would be created in deposit)
931
- false, // to be checked and create in a setup tx in the UI (won't be the case for adjust anyway as this would be created in deposit)
925
+ const repayAction = await classes_1.KaminoAction.buildRepayTxns(kaminoMarket, (0, classes_2.numberToLamportsDecimal)(decimal_js_1.default.abs(calcs.adjustBorrowPosition), debtReserve.stats.decimals).floor().toString(), debtTokenMint, owner, obligation, useV2Ixs, undefined, currentSlot, undefined, 0, false, false, { skipInitialization: true, skipLutCreation: true }, // to be checked and create in a setup tx in the UI (won't be the case for adjust anyway as this would be created in deposit)
932
926
  referrer);
933
927
  // 6. Withdraw collateral (a little bit more to be able to pay for the slippage on swap)
934
- const withdrawAction = await classes_1.KaminoAction.buildWithdrawTxns(kaminoMarket, (0, classes_2.numberToLamportsDecimal)(calcs.withdrawAmountWithSlippageAndFlashLoanFee, collReserve.stats.decimals).ceil().toString(), collTokenMint, owner, obligation, useV2Ixs, undefined, 0, false, false, false, // to be checked and create in a setup tx in the UI (won't be the case for adjust anyway as this would be created in deposit)
935
- false, // to be checked and create in a setup tx in the UI (won't be the case for adjust anyway as this would be created in deposit)
928
+ const withdrawAction = await classes_1.KaminoAction.buildWithdrawTxns(kaminoMarket, (0, classes_2.numberToLamportsDecimal)(calcs.withdrawAmountWithSlippageAndFlashLoanFee, collReserve.stats.decimals).ceil().toString(), collTokenMint, owner, obligation, useV2Ixs, undefined, 0, false, false, { skipInitialization: true, skipLutCreation: true }, // to be checked and create in a setup tx in the UI (won't be the case for adjust anyway as this would be created in deposit)
936
929
  referrer, currentSlot);
937
- const swapInstructions = (0, utils_1.removeBudgetAndAtaIxns)(swapQuoteIxs.swapIxs, []);
938
- const ixns = [
930
+ const swapInstructions = (0, utils_1.removeBudgetAndAtaIxs)(swapQuoteIxs.swapIxs, []);
931
+ const ixs = [
939
932
  ...scopeRefreshIxn,
940
- ...budgetIxns,
941
- ...atasAndCreateIxns.map((x) => x.createAtaIx),
942
- ...fillWsolAtaIxns,
933
+ ...budgetIxs,
934
+ ...atasAndCreateIxs.map((x) => x.createAtaIx),
935
+ ...fillWsolAtaIxs,
943
936
  ...[flashBorrowIxn],
944
937
  ...classes_1.KaminoAction.actionToIxs(repayAction),
945
938
  ...classes_1.KaminoAction.actionToIxs(withdrawAction),
946
939
  ...swapInstructions,
947
940
  ...[flashRepayIxn],
948
- ...closeWsolAtaIxns,
941
+ ...closeWsolAtaIxs,
949
942
  ];
950
943
  const res = {
951
944
  flashLoanInfo: {
952
945
  flashBorrowReserve: debtReserve.address,
953
946
  flashLoanFee: debtReserve.getFlashLoanFee(),
954
947
  },
955
- instructions: ixns,
948
+ instructions: ixs,
956
949
  };
957
950
  return res;
958
951
  }
@@ -966,13 +959,13 @@ const getScopeRefreshIx = async (market, collReserve, debtReserve, obligation, s
966
959
  ]).toArray()
967
960
  : new utils_1.PublicKeySet([collReserve.address, debtReserve.address]).toArray();
968
961
  const tokenIds = (0, classes_1.getTokenIdsForScopeRefresh)(market, allReserves);
969
- const scopeRefreshIxns = [];
962
+ const scopeRefreshIxs = [];
970
963
  if (tokenIds.length > 0 && scopeRefreshConfig) {
971
- scopeRefreshIxns.push(await scopeRefreshConfig.scope.refreshPriceListIx({
964
+ scopeRefreshIxs.push(await scopeRefreshConfig.scope.refreshPriceListIx({
972
965
  feed: scopeRefreshConfig.scopeFeed,
973
966
  }, tokenIds));
974
967
  }
975
- return scopeRefreshIxns;
968
+ return scopeRefreshIxs;
976
969
  };
977
970
  exports.getScopeRefreshIx = getScopeRefreshIx;
978
971
  //# sourceMappingURL=operations.js.map