@kamino-finance/klend-sdk 2.11.0 → 2.12.0-SNAPSHOT

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 (76) hide show
  1. package/dist/classes/action.js +49 -32
  2. package/dist/classes/action.js.map +1 -1
  3. package/dist/classes/reserve.d.ts +4 -0
  4. package/dist/classes/reserve.js +6 -0
  5. package/dist/classes/reserve.js.map +1 -1
  6. package/dist/idl.json +127 -29
  7. package/dist/idl_codegen/errors/custom.d.ts +9 -1
  8. package/dist/idl_codegen/errors/custom.js +14 -1
  9. package/dist/idl_codegen/errors/custom.js.map +1 -1
  10. package/dist/idl_codegen/instructions/borrowObligationLiquidity.d.ts +1 -0
  11. package/dist/idl_codegen/instructions/borrowObligationLiquidity.js +5 -0
  12. package/dist/idl_codegen/instructions/borrowObligationLiquidity.js.map +1 -1
  13. package/dist/idl_codegen/instructions/depositReserveLiquidity.d.ts +3 -1
  14. package/dist/idl_codegen/instructions/depositReserveLiquidity.js +15 -1
  15. package/dist/idl_codegen/instructions/depositReserveLiquidity.js.map +1 -1
  16. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.d.ts +3 -1
  17. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js +15 -1
  18. package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -1
  19. package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.d.ts +2 -0
  20. package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.js +5 -0
  21. package/dist/idl_codegen/instructions/flashBorrowReserveLiquidity.js.map +1 -1
  22. package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.d.ts +2 -0
  23. package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.js +5 -0
  24. package/dist/idl_codegen/instructions/flashRepayReserveLiquidity.js.map +1 -1
  25. package/dist/idl_codegen/instructions/initFarmsForReserve.d.ts +0 -1
  26. package/dist/idl_codegen/instructions/initFarmsForReserve.js +0 -1
  27. package/dist/idl_codegen/instructions/initFarmsForReserve.js.map +1 -1
  28. package/dist/idl_codegen/instructions/initObligation.d.ts +0 -1
  29. package/dist/idl_codegen/instructions/initObligation.js +0 -1
  30. package/dist/idl_codegen/instructions/initObligation.js.map +1 -1
  31. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.d.ts +0 -1
  32. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js +0 -1
  33. package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js.map +1 -1
  34. package/dist/idl_codegen/instructions/initReserve.d.ts +2 -1
  35. package/dist/idl_codegen/instructions/initReserve.js +10 -1
  36. package/dist/idl_codegen/instructions/initReserve.js.map +1 -1
  37. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.d.ts +5 -1
  38. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js +25 -1
  39. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
  40. package/dist/idl_codegen/instructions/redeemFees.d.ts +1 -0
  41. package/dist/idl_codegen/instructions/redeemFees.js +5 -0
  42. package/dist/idl_codegen/instructions/redeemFees.js.map +1 -1
  43. package/dist/idl_codegen/instructions/redeemReserveCollateral.d.ts +3 -1
  44. package/dist/idl_codegen/instructions/redeemReserveCollateral.js +15 -1
  45. package/dist/idl_codegen/instructions/redeemReserveCollateral.js.map +1 -1
  46. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts +0 -1
  47. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js +0 -1
  48. package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
  49. package/dist/idl_codegen/instructions/repayObligationLiquidity.d.ts +1 -0
  50. package/dist/idl_codegen/instructions/repayObligationLiquidity.js +5 -0
  51. package/dist/idl_codegen/instructions/repayObligationLiquidity.js.map +1 -1
  52. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.d.ts +3 -1
  53. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +15 -1
  54. package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
  55. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +1 -0
  56. package/dist/idl_codegen/instructions/withdrawProtocolFee.js +5 -0
  57. package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
  58. package/dist/idl_codegen/instructions/withdrawReferrerFees.d.ts +1 -0
  59. package/dist/idl_codegen/instructions/withdrawReferrerFees.js +5 -0
  60. package/dist/idl_codegen/instructions/withdrawReferrerFees.js.map +1 -1
  61. package/dist/idl_codegen/programId.js.map +1 -1
  62. package/dist/idl_codegen/types/ReserveLiquidity.d.ts +8 -0
  63. package/dist/idl_codegen/types/ReserveLiquidity.js +7 -1
  64. package/dist/idl_codegen/types/ReserveLiquidity.js.map +1 -1
  65. package/dist/leverage/instructions.js +2 -0
  66. package/dist/leverage/instructions.js.map +1 -1
  67. package/dist/leverage/operations.js +4 -3
  68. package/dist/leverage/operations.js.map +1 -1
  69. package/dist/utils/ata.d.ts +5 -5
  70. package/dist/utils/ata.js +39 -29
  71. package/dist/utils/ata.js.map +1 -1
  72. package/dist/utils/instruction.d.ts +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/package.json +2 -2
@@ -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;
@@ -82,7 +83,7 @@ class KaminoAction {
82
83
  if (reserve === undefined) {
83
84
  throw new Error(`Reserve ${mint} not found in market ${kaminoMarket.getAddress().toBase58()}`);
84
85
  }
85
- const { userTokenAccountAddress, userCollateralAccountAddress } = yield KaminoAction.getUserAccountAddresses(payer !== null && payer !== void 0 ? payer : owner, reserve.state);
86
+ const { userTokenAccountAddress, userCollateralAccountAddress } = KaminoAction.getUserAccountAddresses(payer !== null && payer !== void 0 ? payer : owner, reserve.state);
86
87
  const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } = yield KaminoAction.loadObligation(action, kaminoMarket, owner, reserve.address, obligation);
87
88
  const [_, userMetadata] = yield kaminoMarket.getUserMetadata(owner);
88
89
  if (userMetadata) {
@@ -93,11 +94,9 @@ class KaminoAction {
93
94
  });
94
95
  }
95
96
  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
- });
97
+ const userTokenAccountAddress = (0, utils_1.getAssociatedTokenAddress)(reserve.liquidity.mintPubkey, owner, true, reserve.liquidity.tokenProgram, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
98
+ const userCollateralAccountAddress = (0, utils_1.getAssociatedTokenAddress)(reserve.collateral.mintPubkey, owner, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
99
+ return { userTokenAccountAddress, userCollateralAccountAddress };
101
100
  }
102
101
  static loadObligation(action, kaminoMarket, owner, reserve, obligation, outflowReserve) {
103
102
  return __awaiter(this, void 0, void 0, function* () {
@@ -444,12 +443,14 @@ class KaminoAction {
444
443
  lendingMarket: this.kaminoMarket.getAddress(),
445
444
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
446
445
  reserve: this.reserve.address,
446
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
447
447
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
448
448
  reserveCollateralMint: this.reserve.getCTokenMint(),
449
449
  reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
450
450
  userSourceLiquidity: this.userTokenAccountAddress,
451
451
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
452
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
452
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
453
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
453
454
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
454
455
  }, this.kaminoMarket.programId));
455
456
  }
@@ -462,11 +463,13 @@ class KaminoAction {
462
463
  lendingMarket: this.kaminoMarket.getAddress(),
463
464
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
464
465
  reserve: this.reserve.address,
466
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
465
467
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
466
468
  reserveCollateralMint: this.reserve.getCTokenMint(),
467
469
  userSourceLiquidity: this.userTokenAccountAddress,
468
470
  userDestinationCollateral: this.userCollateralAccountAddress,
469
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
471
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
472
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
470
473
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
471
474
  }, this.kaminoMarket.programId));
472
475
  }
@@ -479,11 +482,13 @@ class KaminoAction {
479
482
  lendingMarket: this.kaminoMarket.getAddress(),
480
483
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
481
484
  reserve: this.reserve.address,
485
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
482
486
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
483
487
  reserveCollateralMint: this.reserve.getCTokenMint(),
484
488
  userSourceCollateral: this.userCollateralAccountAddress,
485
489
  userDestinationLiquidity: this.userTokenAccountAddress,
486
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
490
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
491
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
487
492
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
488
493
  }, this.kaminoMarket.programId));
489
494
  }
@@ -516,11 +521,12 @@ class KaminoAction {
516
521
  lendingMarket: this.kaminoMarket.getAddress(),
517
522
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
518
523
  borrowReserve: this.reserve.address,
524
+ borrowReserveLiquidityMint: this.reserve.getLiquidityMint(),
519
525
  reserveSourceLiquidity: this.reserve.state.liquidity.supplyVault,
520
526
  userDestinationLiquidity: this.userTokenAccountAddress,
521
527
  borrowReserveLiquidityFeeReceiver: this.reserve.state.liquidity.feeVault,
522
528
  referrerTokenState: (0, utils_1.referrerTokenStatePda)(this.referrer, this.reserve.address, this.kaminoMarket.programId)[0],
523
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
529
+ tokenProgram: this.reserve.getLiquidityTokenProgram(),
524
530
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
525
531
  }, this.kaminoMarket.programId);
526
532
  borrowIx.keys = borrowIx.keys.concat([...depositReserveAccountMetas]);
@@ -538,12 +544,14 @@ class KaminoAction {
538
544
  lendingMarket: this.kaminoMarket.getAddress(),
539
545
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
540
546
  reserve: this.reserve.address,
547
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
541
548
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
542
549
  reserveCollateralMint: this.reserve.getCTokenMint(),
543
550
  reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
544
551
  userSourceLiquidity: this.userTokenAccountAddress,
545
552
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
546
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
553
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
554
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
547
555
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
548
556
  }, this.kaminoMarket.programId));
549
557
  if (!this.outflowReserve) {
@@ -570,11 +578,12 @@ class KaminoAction {
570
578
  lendingMarket: this.kaminoMarket.getAddress(),
571
579
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
572
580
  borrowReserve: this.outflowReserve.address,
581
+ borrowReserveLiquidityMint: this.outflowReserve.getLiquidityMint(),
573
582
  reserveSourceLiquidity: this.outflowReserve.state.liquidity.supplyVault,
574
583
  userDestinationLiquidity: this.additionalTokenAccountAddress,
575
584
  borrowReserveLiquidityFeeReceiver: this.outflowReserve.state.liquidity.feeVault,
576
585
  referrerTokenState: (0, utils_1.referrerTokenStatePda)(this.referrer, this.outflowReserve.address, this.kaminoMarket.programId)[0],
577
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
586
+ tokenProgram: this.reserve.getLiquidityTokenProgram(),
578
587
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
579
588
  }, this.kaminoMarket.programId);
580
589
  borrowIx.keys = borrowIx.keys.concat([...depositReserveAccountMetas]);
@@ -592,9 +601,10 @@ class KaminoAction {
592
601
  obligation: this.getObligationPda(),
593
602
  lendingMarket: this.kaminoMarket.getAddress(),
594
603
  repayReserve: this.reserve.address,
604
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
595
605
  userSourceLiquidity: this.userTokenAccountAddress,
596
606
  reserveDestinationLiquidity: this.reserve.state.liquidity.supplyVault,
597
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
607
+ tokenProgram: this.reserve.getLiquidityTokenProgram(),
598
608
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
599
609
  }, this.kaminoMarket.programId));
600
610
  if (!this.outflowReserve) {
@@ -617,12 +627,14 @@ class KaminoAction {
617
627
  lendingMarket: this.kaminoMarket.getAddress(),
618
628
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
619
629
  withdrawReserve: this.outflowReserve.address,
630
+ reserveLiquidityMint: this.outflowReserve.getLiquidityMint(),
620
631
  reserveCollateralMint: this.outflowReserve.getCTokenMint(),
621
632
  reserveLiquiditySupply: this.outflowReserve.state.liquidity.supplyVault,
622
633
  reserveSourceCollateral: this.outflowReserve.state.collateral.supplyVault,
623
634
  userDestinationLiquidity: this.additionalTokenAccountAddress,
624
635
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
625
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
636
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
637
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
626
638
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
627
639
  }, this.kaminoMarket.programId));
628
640
  });
@@ -642,12 +654,14 @@ class KaminoAction {
642
654
  lendingMarket: this.kaminoMarket.getAddress(),
643
655
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
644
656
  withdrawReserve: this.reserve.address,
657
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
645
658
  reserveCollateralMint: this.reserve.getCTokenMint(),
646
659
  reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
647
660
  reserveSourceCollateral: this.reserve.state.collateral.supplyVault,
648
661
  userDestinationLiquidity: this.userTokenAccountAddress,
649
662
  placeholderUserDestinationCollateral: this.kaminoMarket.programId,
650
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
663
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
664
+ liquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
651
665
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
652
666
  }, this.kaminoMarket.programId));
653
667
  });
@@ -666,9 +680,10 @@ class KaminoAction {
666
680
  obligation: this.getObligationPda(),
667
681
  lendingMarket: this.kaminoMarket.getAddress(),
668
682
  repayReserve: this.reserve.address,
683
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
669
684
  userSourceLiquidity: this.userTokenAccountAddress,
670
685
  reserveDestinationLiquidity: this.reserve.state.liquidity.supplyVault,
671
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
686
+ tokenProgram: this.reserve.getLiquidityTokenProgram(),
672
687
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
673
688
  }, this.kaminoMarket.programId);
674
689
  repayIx.keys = repayIx.keys.concat([...depositReserveAccountMetas]);
@@ -699,8 +714,10 @@ class KaminoAction {
699
714
  lendingMarket: this.kaminoMarket.getAddress(),
700
715
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
701
716
  repayReserve: this.reserve.address,
717
+ repayReserveLiquidityMint: this.reserve.getLiquidityMint(),
702
718
  repayReserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
703
719
  withdrawReserve: this.outflowReserve.address,
720
+ withdrawReserveLiquidityMint: this.outflowReserve.getLiquidityMint(),
704
721
  withdrawReserveCollateralMint: this.outflowReserve.getCTokenMint(),
705
722
  withdrawReserveCollateralSupply: this.outflowReserve.state.collateral.supplyVault,
706
723
  withdrawReserveLiquiditySupply: this.outflowReserve.state.liquidity.supplyVault,
@@ -708,7 +725,9 @@ class KaminoAction {
708
725
  userDestinationCollateral: this.userCollateralAccountAddress,
709
726
  userDestinationLiquidity: this.userTokenAccountAddress,
710
727
  withdrawReserveLiquidityFeeReceiver: this.outflowReserve.state.liquidity.feeVault,
711
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
728
+ collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
729
+ repayLiquidityTokenProgram: this.reserve.getLiquidityTokenProgram(),
730
+ withdrawLiquidityTokenProgram: this.outflowReserve.getLiquidityTokenProgram(),
712
731
  instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
713
732
  }, this.kaminoMarket.programId);
714
733
  liquidateIx.keys = liquidateIx.keys.concat([...depositReserveAccountMetas]);
@@ -1092,7 +1111,6 @@ class KaminoAction {
1092
1111
  lendingMarket: this.kaminoMarket.getAddress(),
1093
1112
  farmsProgram: farms_sdk_1.farmsId,
1094
1113
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1095
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1096
1114
  systemProgram: web3_js_1.SystemProgram.programId,
1097
1115
  };
1098
1116
  const refreshFarmForObligationix = (0, instructions_1.refreshObligationFarmsForReserve)(args, accounts, this.kaminoMarket.programId);
@@ -1153,7 +1171,6 @@ class KaminoAction {
1153
1171
  lendingMarket: this.kaminoMarket.getAddress(),
1154
1172
  farmsProgram: farms_sdk_1.farmsId,
1155
1173
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1156
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1157
1174
  systemProgram: web3_js_1.SystemProgram.programId,
1158
1175
  };
1159
1176
  const initObligationForFarm = (0, instructions_1.initObligationFarmsForReserve)(args, accounts, this.kaminoMarket.programId);
@@ -1187,7 +1204,6 @@ class KaminoAction {
1187
1204
  seed2Account: this.obligationType.toArgs().seed2,
1188
1205
  ownerUserMetadata: userMetadataAddress,
1189
1206
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1190
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1191
1207
  systemProgram: web3_js_1.SystemProgram.programId,
1192
1208
  }, this.kaminoMarket.programId);
1193
1209
  this.setupIxs.push(initObligationIx);
@@ -1256,11 +1272,12 @@ class KaminoAction {
1256
1272
  referrer: this.owner,
1257
1273
  lendingMarket: this.kaminoMarket.getAddress(),
1258
1274
  reserve: this.reserve.address,
1275
+ reserveLiquidityMint: this.reserve.getLiquidityMint(),
1259
1276
  referrerTokenState: referrerTokenStateAddress,
1260
1277
  reserveSupplyLiquidity: this.reserve.state.liquidity.supplyVault,
1261
1278
  referrerTokenAccount: this.userTokenAccountAddress,
1262
1279
  lendingMarketAuthority: this.kaminoMarket.getLendingMarketAuthority(),
1263
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
1280
+ tokenProgram: this.reserve.getLiquidityTokenProgram(),
1264
1281
  }, this.kaminoMarket.programId);
1265
1282
  this.lendingIxs.push(withdrawReferrerFeesIx);
1266
1283
  this.lendingIxsLabels.push(`WithdrawReferrerFeesIx[${this.owner.toString()}]`);
@@ -1278,7 +1295,7 @@ class KaminoAction {
1278
1295
  if ((action === 'withdraw' || action === 'borrow' || action === 'redeem') && !this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1279
1296
  const userTokenAccountInfo = yield this.kaminoMarket.getConnection().getAccountInfo(this.userTokenAccountAddress);
1280
1297
  if (!userTokenAccountInfo) {
1281
- const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.userTokenAccountAddress);
1298
+ const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.reserve.getLiquidityTokenProgram(), this.userTokenAccountAddress);
1282
1299
  if (this.positions === exports.POSITION_LIMIT && this.hostAta) {
1283
1300
  this.preTxnIxs.push(createUserTokenAccountIx);
1284
1301
  this.preTxnIxsLabels.push(`CreateLiquidityUserAta[${this.owner}]`);
@@ -1295,7 +1312,7 @@ class KaminoAction {
1295
1312
  throw new Error(`Outflow reserve state not found ${this.mint}`);
1296
1313
  }
1297
1314
  if (!userTokenAccountInfo) {
1298
- const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.userTokenAccountAddress);
1315
+ const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.outflowReserve.getLiquidityTokenProgram(), this.userTokenAccountAddress);
1299
1316
  if (this.positions === exports.POSITION_LIMIT && this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1300
1317
  this.preTxnIxs.push(createUserTokenAccountIx);
1301
1318
  this.preTxnIxsLabels.push(`CreateUserAta[${this.userTokenAccountAddress.toBase58()}]`);
@@ -1309,7 +1326,7 @@ class KaminoAction {
1309
1326
  .getConnection()
1310
1327
  .getAccountInfo(this.userCollateralAccountAddress);
1311
1328
  if (!userCollateralAccountInfo) {
1312
- const [, createUserCollateralAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getCTokenMint(), this.owner, this.userCollateralAccountAddress);
1329
+ const [, createUserCollateralAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getCTokenMint(), this.owner, spl_token_1.TOKEN_PROGRAM_ID, this.userCollateralAccountAddress);
1313
1330
  if (this.positions === exports.POSITION_LIMIT && this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1314
1331
  this.preTxnIxs.push(createUserCollateralAccountIx);
1315
1332
  this.preTxnIxsLabels.push(`CreateCollateralUserAta[${this.userCollateralAccountAddress.toString()}]`);
@@ -1335,7 +1352,7 @@ class KaminoAction {
1335
1352
  .getConnection()
1336
1353
  .getAccountInfo(this.additionalTokenAccountAddress);
1337
1354
  if (!additionalUserTokenAccountInfo) {
1338
- const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.additionalTokenAccountAddress);
1355
+ const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.outflowReserve.getLiquidityMint(), this.owner, this.outflowReserve.getLiquidityTokenProgram(), this.additionalTokenAccountAddress);
1339
1356
  this.setupIxs.unshift(createUserTokenAccountIx);
1340
1357
  this.setupIxsLabels.unshift(`CreateAdditionalUserTokenAta[${this.owner}]`);
1341
1358
  }
@@ -1344,7 +1361,7 @@ class KaminoAction {
1344
1361
  const userTokenAccountInfo = yield this.kaminoMarket.getConnection().getAccountInfo(this.userTokenAccountAddress);
1345
1362
  // TODO: Might need to remove this
1346
1363
  if (!userTokenAccountInfo) {
1347
- const [, createUserTokenAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.userTokenAccountAddress);
1364
+ const [, createUserTokenAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, this.reserve.getLiquidityMint(), this.owner, this.reserve.getLiquidityTokenProgram(), this.userTokenAccountAddress);
1348
1365
  this.preTxnIxs.push(createUserTokenAccountIx);
1349
1366
  this.preTxnIxsLabels.push(`CreateUserAta[${this.userTokenAccountAddress.toBase58()}]`);
1350
1367
  }
@@ -1355,7 +1372,7 @@ class KaminoAction {
1355
1372
  .getAccountInfo(this.userCollateralAccountAddress);
1356
1373
  if (!userCollateralAccountInfo) {
1357
1374
  const collateralMintPubkey = this.reserve.getCTokenMint();
1358
- const [, createUserCollateralAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, collateralMintPubkey, this.owner, this.userCollateralAccountAddress);
1375
+ const [, createUserCollateralAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, collateralMintPubkey, this.owner, spl_token_1.TOKEN_PROGRAM_ID, this.userCollateralAccountAddress);
1359
1376
  if (this.positions === exports.POSITION_LIMIT && this.mint.equals(utils_1.WRAPPED_SOL_MINT)) {
1360
1377
  this.preTxnIxs.push(createUserCollateralAccountIx);
1361
1378
  this.preTxnIxsLabels.push(`CreateCollateralUserAta[${this.userCollateralAccountAddress.toString()}]`);
@@ -1401,7 +1418,7 @@ class KaminoAction {
1401
1418
  userTokenAccountAddress = this.additionalTokenAccountAddress;
1402
1419
  }
1403
1420
  const userWSOLAccountInfo = yield this.kaminoMarket.getConnection().getAccountInfo(userTokenAccountAddress);
1404
- const rentExempt = yield spl_token_1.Token.getMinBalanceRentForExemptAccount(this.kaminoMarket.getConnection());
1421
+ const rentExempt = yield this.kaminoMarket.getConnection().getMinimumBalanceForRentExemption(165);
1405
1422
  // Add rent exemption lamports for WSOL accounts that need to be pre-funded for inflow/send transactions
1406
1423
  const sendAction = action === 'deposit' ||
1407
1424
  action === 'repay' ||
@@ -1414,7 +1431,7 @@ class KaminoAction {
1414
1431
  });
1415
1432
  preIxs.push(transferLamportsIx);
1416
1433
  preIxsLabels.push(`TransferLamportsToUserAtaSOL[${userTokenAccountAddress}]`);
1417
- const closeWSOLAccountIx = spl_token_1.Token.createCloseAccountInstruction(spl_token_1.TOKEN_PROGRAM_ID, userTokenAccountAddress, this.owner, this.owner, []);
1434
+ const closeWSOLAccountIx = (0, token_1.createCloseAccountInstruction)(userTokenAccountAddress, this.owner, this.owner, spl_token_1.TOKEN_PROGRAM_ID);
1418
1435
  const syncIx = (0, utils_1.syncNative)(userTokenAccountAddress);
1419
1436
  if (userWSOLAccountInfo) {
1420
1437
  if (sendAction) {
@@ -1427,7 +1444,7 @@ class KaminoAction {
1427
1444
  }
1428
1445
  }
1429
1446
  else {
1430
- const [, createUserWSOLAccountIx] = yield (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, spl_token_1.NATIVE_MINT, this.owner, userTokenAccountAddress);
1447
+ const [, createUserWSOLAccountIx] = (0, utils_1.createAssociatedTokenAccountIdempotentInstruction)(this.owner, spl_token_1.NATIVE_MINT, this.owner, spl_token_1.TOKEN_PROGRAM_ID, userTokenAccountAddress);
1431
1448
  preIxs.push(createUserWSOLAccountIx);
1432
1449
  preIxsLabels.push(`CreateUserAtaSOL[${userTokenAccountAddress}]`);
1433
1450
  preIxs.push(syncIx);
@@ -1456,8 +1473,8 @@ class KaminoAction {
1456
1473
  if (!outflowReserve || !inflowReserve) {
1457
1474
  throw new Error('reserve states are not fetched');
1458
1475
  }
1459
- const { userTokenAccountAddress: userOutflowTokenAccountAddress, userCollateralAccountAddress: userOutflowCollateralAccountAddress, } = yield KaminoAction.getUserAccountAddresses(payer, outflowReserve.state);
1460
- const { userTokenAccountAddress: userInflowTokenAccountAddress, userCollateralAccountAddress: userInflowCollateralAccountAddress, } = yield KaminoAction.getUserAccountAddresses(payer, inflowReserve.state);
1476
+ const { userTokenAccountAddress: userOutflowTokenAccountAddress, userCollateralAccountAddress: userOutflowCollateralAccountAddress, } = KaminoAction.getUserAccountAddresses(payer, outflowReserve.state);
1477
+ const { userTokenAccountAddress: userInflowTokenAccountAddress, userCollateralAccountAddress: userInflowCollateralAccountAddress, } = KaminoAction.getUserAccountAddresses(payer, inflowReserve.state);
1461
1478
  const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } = yield KaminoAction.loadObligation(action, kaminoMarket, obligationOwner, inflowReserve.address, obligation, outflowReserve.address);
1462
1479
  const [_, userMetadata] = yield kaminoMarket.getUserMetadata(payer);
1463
1480
  if (userMetadata) {