@kamino-finance/klend-sdk 2.10.21 → 2.11.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 (57) hide show
  1. package/dist/classes/action.d.ts +1 -0
  2. package/dist/classes/action.js +55 -38
  3. package/dist/classes/action.js.map +1 -1
  4. package/dist/classes/obligation.js +21 -0
  5. package/dist/classes/obligation.js.map +1 -1
  6. package/dist/classes/reserve.d.ts +30 -0
  7. package/dist/classes/reserve.js +66 -6
  8. package/dist/classes/reserve.js.map +1 -1
  9. package/dist/idl.json +156 -72
  10. package/dist/idl_codegen/accounts/LendingMarket.d.ts +3 -3
  11. package/dist/idl_codegen/accounts/LendingMarket.js +7 -1
  12. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  13. package/dist/idl_codegen/accounts/Obligation.d.ts +6 -3
  14. package/dist/idl_codegen/accounts/Obligation.js +12 -6
  15. package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
  16. package/dist/idl_codegen/accounts/Reserve.d.ts +18 -0
  17. package/dist/idl_codegen/accounts/Reserve.js +14 -2
  18. package/dist/idl_codegen/accounts/Reserve.js.map +1 -1
  19. package/dist/idl_codegen/errors/custom.d.ts +76 -4
  20. package/dist/idl_codegen/errors/custom.js +126 -8
  21. package/dist/idl_codegen/errors/custom.js.map +1 -1
  22. package/dist/idl_codegen/instructions/index.d.ts +2 -4
  23. package/dist/idl_codegen/instructions/index.js +3 -5
  24. package/dist/idl_codegen/instructions/index.js.map +1 -1
  25. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.d.ts +1 -1
  26. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js +2 -2
  27. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
  28. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +2 -1
  29. package/dist/idl_codegen/instructions/updateReserveConfig.js +4 -2
  30. package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
  31. package/dist/idl_codegen/instructions/withdrawObligationCollateral.js +1 -1
  32. package/dist/idl_codegen/instructions/withdrawObligationCollateral.js.map +1 -1
  33. package/dist/idl_codegen/types/ElevationGroup.d.ts +24 -10
  34. package/dist/idl_codegen/types/ElevationGroup.js +25 -12
  35. package/dist/idl_codegen/types/ElevationGroup.js.map +1 -1
  36. package/dist/idl_codegen/types/ObligationCollateral.d.ts +23 -0
  37. package/dist/idl_codegen/types/ObligationCollateral.js +8 -1
  38. package/dist/idl_codegen/types/ObligationCollateral.js.map +1 -1
  39. package/dist/idl_codegen/types/ObligationLiquidity.d.ts +8 -0
  40. package/dist/idl_codegen/types/ObligationLiquidity.js +8 -1
  41. package/dist/idl_codegen/types/ObligationLiquidity.js.map +1 -1
  42. package/dist/idl_codegen/types/ReserveConfig.d.ts +55 -9
  43. package/dist/idl_codegen/types/ReserveConfig.js +20 -6
  44. package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
  45. package/dist/idl_codegen/types/UpdateConfigMode.d.ts +39 -0
  46. package/dist/idl_codegen/types/UpdateConfigMode.js +79 -1
  47. package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
  48. package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.d.ts +4 -2
  49. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +13 -0
  50. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +27 -1
  51. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  52. package/dist/idl_codegen/types/index.d.ts +4 -4
  53. package/dist/idl_codegen/types/index.js.map +1 -1
  54. package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +3 -2
  55. package/dist/idl_codegen/zero_padding/ObligationZP.js +8 -3
  56. package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
  57. package/package.json +1 -1
@@ -153,4 +153,5 @@ export declare class KaminoAction {
153
153
  createAtasIxns: TransactionInstruction[];
154
154
  }>;
155
155
  getObligationPda(): PublicKey;
156
+ getAdditionalDepositReservesList(): PublicKey[];
156
157
  }
@@ -504,7 +504,11 @@ class KaminoAction {
504
504
  }
505
505
  addBorrowIx() {
506
506
  this.lendingIxsLabels.push(`borrowObligationLiquidity`);
507
- this.lendingIxs.push((0, instructions_1.borrowObligationLiquidity)({
507
+ const depositReservesList = this.getAdditionalDepositReservesList();
508
+ const depositReserveAccountMetas = depositReservesList.map((reserve) => {
509
+ return { pubkey: reserve, isSigner: false, isWritable: true };
510
+ });
511
+ const borrowIx = (0, instructions_1.borrowObligationLiquidity)({
508
512
  liquidityAmount: this.amount,
509
513
  }, {
510
514
  owner: this.owner,
@@ -518,7 +522,9 @@ class KaminoAction {
518
522
  referrerTokenState: (0, utils_1.referrerTokenStatePda)(this.referrer, this.reserve.address, this.kaminoMarket.programId)[0],
519
523
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
520
524
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
521
- }, this.kaminoMarket.programId));
525
+ }, this.kaminoMarket.programId);
526
+ borrowIx.keys = borrowIx.keys.concat([...depositReserveAccountMetas]);
527
+ this.lendingIxs.push(borrowIx);
522
528
  }
523
529
  addDepositAndBorrowIx() {
524
530
  return __awaiter(this, void 0, void 0, function* () {
@@ -549,7 +555,14 @@ class KaminoAction {
549
555
  if (!this.outflowAmount) {
550
556
  throw new Error(`outflowAmount not set`);
551
557
  }
552
- this.lendingIxs.push((0, instructions_1.borrowObligationLiquidity)({
558
+ const depositReservesList = this.getAdditionalDepositReservesList();
559
+ if (depositReservesList.length === 0) {
560
+ depositReservesList.push(this.reserve.address);
561
+ }
562
+ const depositReserveAccountMetas = depositReservesList.map((reserve) => {
563
+ return { pubkey: reserve, isSigner: false, isWritable: true };
564
+ });
565
+ const borrowIx = (0, instructions_1.borrowObligationLiquidity)({
553
566
  liquidityAmount: this.outflowAmount,
554
567
  }, {
555
568
  owner: this.owner,
@@ -563,7 +576,9 @@ class KaminoAction {
563
576
  referrerTokenState: (0, utils_1.referrerTokenStatePda)(this.referrer, this.outflowReserve.address, this.kaminoMarket.programId)[0],
564
577
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
565
578
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
566
- }, this.kaminoMarket.programId));
579
+ }, this.kaminoMarket.programId);
580
+ borrowIx.keys = borrowIx.keys.concat([...depositReserveAccountMetas]);
581
+ this.lendingIxs.push(borrowIx);
567
582
  });
568
583
  }
569
584
  addRepayAndWithdrawIxs() {
@@ -640,7 +655,11 @@ class KaminoAction {
640
655
  addRepayIx() {
641
656
  return __awaiter(this, void 0, void 0, function* () {
642
657
  this.lendingIxsLabels.push(`repayObligationLiquidity(reserve=${this.reserve.address})(obligation=${this.getObligationPda()})`);
643
- this.lendingIxs.push((0, instructions_1.repayObligationLiquidity)({
658
+ const depositReservesList = this.getAdditionalDepositReservesList();
659
+ const depositReserveAccountMetas = depositReservesList.map((reserve) => {
660
+ return { pubkey: reserve, isSigner: false, isWritable: true };
661
+ });
662
+ const repayIx = (0, instructions_1.repayObligationLiquidity)({
644
663
  liquidityAmount: this.amount,
645
664
  }, {
646
665
  owner: this.payer,
@@ -651,7 +670,9 @@ class KaminoAction {
651
670
  reserveDestinationLiquidity: this.reserve.state.liquidity.supplyVault,
652
671
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
653
672
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
654
- }, this.kaminoMarket.programId));
673
+ }, this.kaminoMarket.programId);
674
+ repayIx.keys = repayIx.keys.concat([...depositReserveAccountMetas]);
675
+ this.lendingIxs.push(repayIx);
655
676
  });
656
677
  }
657
678
  addLiquidateIx(maxAllowedLtvOverridePercent = 0) {
@@ -663,11 +684,14 @@ class KaminoAction {
663
684
  if (!this.additionalTokenAccountAddress) {
664
685
  throw Error(`Liquidating token account address is not defined`);
665
686
  }
666
- this.lendingIxs.push((0, instructions_1.liquidateObligationAndRedeemReserveCollateral)({
687
+ const depositReservesList = this.getAdditionalDepositReservesList();
688
+ const depositReserveAccountMetas = depositReservesList.map((reserve) => {
689
+ return { pubkey: reserve, isSigner: false, isWritable: true };
690
+ });
691
+ const liquidateIx = (0, instructions_1.liquidateObligationAndRedeemReserveCollateral)({
667
692
  liquidityAmount: this.amount,
668
693
  // TODO: Configure this when updating liquidator with new interface
669
- minAcceptableReceivedCollateralAmount: this.outflowAmount || new bn_js_1.default(0),
670
- // TODO: remove this before going live
694
+ minAcceptableReceivedLiquidityAmount: this.outflowAmount || new bn_js_1.default(0),
671
695
  maxAllowedLtvOverridePercent: new bn_js_1.default(maxAllowedLtvOverridePercent),
672
696
  }, {
673
697
  liquidator: this.owner,
@@ -686,7 +710,9 @@ class KaminoAction {
686
710
  withdrawReserveLiquidityFeeReceiver: this.outflowReserve.state.liquidity.feeVault,
687
711
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
688
712
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
689
- }, this.kaminoMarket.programId));
713
+ }, this.kaminoMarket.programId);
714
+ liquidateIx.keys = liquidateIx.keys.concat([...depositReserveAccountMetas]);
715
+ this.lendingIxs.push(liquidateIx);
690
716
  });
691
717
  }
692
718
  addInBetweenIxs(action, includeAtaIxns, requestElevationGroup, addInitObligationForFarm, isClosingPosition = false) {
@@ -957,20 +983,7 @@ class KaminoAction {
957
983
  lendingMarket: marketAddress,
958
984
  obligation: obligationPda,
959
985
  }, this.kaminoMarket.programId);
960
- const depositReservesList = this.depositReserves;
961
- // check if there's any member in the preloadedDepositReserves that is not in the depositReserves
962
- // if so, add it to the depositReserves
963
- for (let i = 0; i < this.preLoadedDepositReservesSameTx.length; i++) {
964
- const preloadedDepositReserve = this.preLoadedDepositReservesSameTx[i];
965
- // Check if the depositReserves array contains the current preloadedDepositReserve
966
- const found = this.depositReserves.some((depositReserve) => {
967
- return depositReserve.equals(preloadedDepositReserve);
968
- });
969
- // If not found, push the current preloadedDepositReserve to the depositReserves array
970
- if (!found) {
971
- depositReservesList.push(this.preLoadedDepositReservesSameTx[i]);
972
- }
973
- }
986
+ const depositReservesList = this.getAdditionalDepositReservesList();
974
987
  const depositReserveAccountMetas = depositReservesList.map((reserve) => {
975
988
  return { pubkey: reserve, isSigner: false, isWritable: true };
976
989
  });
@@ -1012,20 +1025,7 @@ class KaminoAction {
1012
1025
  lendingMarket: this.kaminoMarket.getAddress(),
1013
1026
  };
1014
1027
  const requestElevationGroupIx = (0, instructions_1.requestElevationGroup)(args, accounts, this.kaminoMarket.programId);
1015
- const depositReservesList = this.depositReserves;
1016
- // check if there's any member in the preloadedDepositReserves that is not in the depositReserves
1017
- // if so, add it to the depositReserves
1018
- for (let i = 0; i < this.preLoadedDepositReservesSameTx.length; i++) {
1019
- const preloadedDepositReserveString = this.preLoadedDepositReservesSameTx[i].toString();
1020
- // Check if the depositReserves array contains the current preloadedDepositReserve
1021
- const found = this.depositReserves.some((depositReserve) => {
1022
- return depositReserve.toString() === preloadedDepositReserveString;
1023
- });
1024
- // If not found, push the current preloadedDepositReserve to the depositReserves array
1025
- if (!found) {
1026
- depositReservesList.push(this.preLoadedDepositReservesSameTx[i]);
1027
- }
1028
- }
1028
+ const depositReservesList = this.getAdditionalDepositReservesList();
1029
1029
  const depositReserveAccountMetas = depositReservesList.map((reserve) => {
1030
1030
  return { pubkey: reserve, isSigner: false, isWritable: true };
1031
1031
  });
@@ -1517,6 +1517,23 @@ class KaminoAction {
1517
1517
  ? this.obligation.obligationAddress
1518
1518
  : this.obligationType.toPda(this.kaminoMarket.getAddress(), this.owner);
1519
1519
  }
1520
+ getAdditionalDepositReservesList() {
1521
+ const depositReservesList = this.depositReserves;
1522
+ // check if there's any member in the preloadedDepositReserves that is not in the depositReserves
1523
+ // if so, add it to the depositReserves
1524
+ for (let i = 0; i < this.preLoadedDepositReservesSameTx.length; i++) {
1525
+ const preloadedDepositReserve = this.preLoadedDepositReservesSameTx[i];
1526
+ // Check if the depositReserves array contains the current preloadedDepositReserve
1527
+ const found = this.depositReserves.some((depositReserve) => {
1528
+ return depositReserve.equals(preloadedDepositReserve);
1529
+ });
1530
+ // If not found, push the current preloadedDepositReserve to the depositReserves array
1531
+ if (!found) {
1532
+ depositReservesList.push(this.preLoadedDepositReservesSameTx[i]);
1533
+ }
1534
+ }
1535
+ return depositReservesList;
1536
+ }
1520
1537
  }
1521
1538
  exports.KaminoAction = KaminoAction;
1522
1539
  //# sourceMappingURL=action.js.map