@kamino-finance/klend-sdk 5.14.1-beta.0 → 5.14.1

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 (140) hide show
  1. package/dist/classes/farm_utils.d.ts.map +1 -1
  2. package/dist/classes/farm_utils.js +10 -3
  3. package/dist/classes/farm_utils.js.map +1 -1
  4. package/dist/classes/manager.d.ts +21 -6
  5. package/dist/classes/manager.d.ts.map +1 -1
  6. package/dist/classes/manager.js +311 -40
  7. package/dist/classes/manager.js.map +1 -1
  8. package/dist/classes/obligation.d.ts.map +1 -1
  9. package/dist/classes/obligation.js +0 -14
  10. package/dist/classes/obligation.js.map +1 -1
  11. package/dist/classes/reserve.d.ts +14 -5
  12. package/dist/classes/reserve.d.ts.map +1 -1
  13. package/dist/classes/reserve.js +463 -91
  14. package/dist/classes/reserve.js.map +1 -1
  15. package/dist/classes/shared.d.ts +1 -0
  16. package/dist/classes/shared.d.ts.map +1 -1
  17. package/dist/classes/shared.js.map +1 -1
  18. package/dist/classes/utils.d.ts +0 -1
  19. package/dist/classes/utils.d.ts.map +1 -1
  20. package/dist/classes/utils.js +0 -12
  21. package/dist/classes/utils.js.map +1 -1
  22. package/dist/classes/vault.d.ts +11 -1
  23. package/dist/classes/vault.d.ts.map +1 -1
  24. package/dist/classes/vault.js +54 -6
  25. package/dist/classes/vault.js.map +1 -1
  26. package/dist/client_kamino_manager.d.ts.map +1 -1
  27. package/dist/client_kamino_manager.js +26 -27
  28. package/dist/client_kamino_manager.js.map +1 -1
  29. package/dist/idl.json +9 -186
  30. package/dist/idl_codegen/accounts/LendingMarket.d.ts +3 -24
  31. package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
  32. package/dist/idl_codegen/accounts/LendingMarket.js +7 -25
  33. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  34. package/dist/idl_codegen/accounts/index.d.ts +0 -2
  35. package/dist/idl_codegen/accounts/index.d.ts.map +1 -1
  36. package/dist/idl_codegen/accounts/index.js +1 -3
  37. package/dist/idl_codegen/accounts/index.js.map +1 -1
  38. package/dist/idl_codegen/errors/custom.d.ts +1 -25
  39. package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
  40. package/dist/idl_codegen/errors/custom.js +1 -43
  41. package/dist/idl_codegen/errors/custom.js.map +1 -1
  42. package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +1 -2
  43. package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -1
  44. package/dist/idl_codegen/instructions/idlMissingTypes.js +1 -2
  45. package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
  46. package/dist/idl_codegen/instructions/index.d.ts +0 -6
  47. package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
  48. package/dist/idl_codegen/instructions/index.js +1 -7
  49. package/dist/idl_codegen/instructions/index.js.map +1 -1
  50. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +3 -4
  51. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -1
  52. package/dist/idl_codegen/instructions/updateReserveConfig.js +3 -5
  53. package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
  54. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +2 -2
  55. package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts.map +1 -1
  56. package/dist/idl_codegen/instructions/withdrawProtocolFee.js +6 -2
  57. package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
  58. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +7 -33
  59. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
  60. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +12 -60
  61. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  62. package/dist/idl_codegen/types/index.d.ts +2 -6
  63. package/dist/idl_codegen/types/index.d.ts.map +1 -1
  64. package/dist/idl_codegen/types/index.js +1 -3
  65. package/dist/idl_codegen/types/index.js.map +1 -1
  66. package/dist/utils/accountListing.d.ts +1 -1
  67. package/dist/utils/accountListing.d.ts.map +1 -1
  68. package/dist/utils/accountListing.js +2 -2
  69. package/dist/utils/accountListing.js.map +1 -1
  70. package/dist/utils/api.d.ts +5 -1
  71. package/dist/utils/api.d.ts.map +1 -1
  72. package/dist/utils/api.js +12 -6
  73. package/dist/utils/api.js.map +1 -1
  74. package/dist/utils/constants.d.ts +1 -1
  75. package/dist/utils/constants.js +1 -1
  76. package/dist/utils/lookupTable.d.ts.map +1 -1
  77. package/dist/utils/lookupTable.js +6 -1
  78. package/dist/utils/lookupTable.js.map +1 -1
  79. package/dist/utils/managerTypes.d.ts.map +1 -1
  80. package/dist/utils/managerTypes.js +4 -10
  81. package/dist/utils/managerTypes.js.map +1 -1
  82. package/dist/utils/seeds.d.ts +0 -16
  83. package/dist/utils/seeds.d.ts.map +1 -1
  84. package/dist/utils/seeds.js +1 -23
  85. package/dist/utils/seeds.js.map +1 -1
  86. package/package.json +1 -1
  87. package/src/classes/farm_utils.ts +11 -3
  88. package/src/classes/manager.ts +417 -52
  89. package/src/classes/obligation.ts +0 -16
  90. package/src/classes/reserve.ts +783 -119
  91. package/src/classes/shared.ts +1 -0
  92. package/src/classes/utils.ts +0 -12
  93. package/src/classes/vault.ts +75 -7
  94. package/src/client_kamino_manager.ts +34 -42
  95. package/src/idl.json +9 -186
  96. package/src/idl_codegen/accounts/LendingMarket.ts +9 -41
  97. package/src/idl_codegen/accounts/index.ts +0 -2
  98. package/src/idl_codegen/errors/custom.ts +0 -45
  99. package/src/idl_codegen/instructions/idlMissingTypes.ts +2 -4
  100. package/src/idl_codegen/instructions/index.ts +0 -9
  101. package/src/idl_codegen/instructions/updateReserveConfig.ts +5 -7
  102. package/src/idl_codegen/instructions/withdrawProtocolFee.ts +8 -4
  103. package/src/idl_codegen/types/UpdateLendingMarketMode.ts +13 -73
  104. package/src/idl_codegen/types/index.ts +2 -16
  105. package/src/utils/accountListing.ts +3 -2
  106. package/src/utils/api.ts +19 -7
  107. package/src/utils/constants.ts +1 -1
  108. package/src/utils/lookupTable.ts +7 -1
  109. package/src/utils/managerTypes.ts +4 -10
  110. package/src/utils/seeds.ts +0 -25
  111. package/dist/classes/configItems.d.ts +0 -166
  112. package/dist/classes/configItems.d.ts.map +0 -1
  113. package/dist/classes/configItems.js +0 -202
  114. package/dist/classes/configItems.js.map +0 -1
  115. package/dist/idl_codegen/accounts/GlobalConfig.d.ts +0 -40
  116. package/dist/idl_codegen/accounts/GlobalConfig.d.ts.map +0 -1
  117. package/dist/idl_codegen/accounts/GlobalConfig.js +0 -116
  118. package/dist/idl_codegen/accounts/GlobalConfig.js.map +0 -1
  119. package/dist/idl_codegen/instructions/initGlobalConfig.d.ts +0 -10
  120. package/dist/idl_codegen/instructions/initGlobalConfig.d.ts.map +0 -1
  121. package/dist/idl_codegen/instructions/initGlobalConfig.js +0 -19
  122. package/dist/idl_codegen/instructions/initGlobalConfig.js.map +0 -1
  123. package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts +0 -13
  124. package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts.map +0 -1
  125. package/dist/idl_codegen/instructions/updateGlobalConfig.js +0 -61
  126. package/dist/idl_codegen/instructions/updateGlobalConfig.js.map +0 -1
  127. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts +0 -7
  128. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts.map +0 -1
  129. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js +0 -16
  130. package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js.map +0 -1
  131. package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts +0 -32
  132. package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts.map +0 -1
  133. package/dist/idl_codegen/types/UpdateGlobalConfigMode.js +0 -108
  134. package/dist/idl_codegen/types/UpdateGlobalConfigMode.js.map +0 -1
  135. package/src/classes/configItems.ts +0 -295
  136. package/src/idl_codegen/accounts/GlobalConfig.ts +0 -125
  137. package/src/idl_codegen/instructions/initGlobalConfig.ts +0 -30
  138. package/src/idl_codegen/instructions/updateGlobalConfig.ts +0 -47
  139. package/src/idl_codegen/instructions/updateGlobalConfigAdmin.ts +0 -24
  140. package/src/idl_codegen/types/UpdateGlobalConfigMode.ts +0 -90
@@ -10,6 +10,7 @@ export type MarketConfigType = {
10
10
  description: string;
11
11
  lendingMarket: string;
12
12
  lookupTable: string;
13
+ isCurated: boolean;
13
14
  };
14
15
 
15
16
  export type ReserveConfigResponse = {
@@ -287,18 +287,6 @@ export function orThrow(message: string): never {
287
287
  throw new Error(message);
288
288
  }
289
289
 
290
- export function blobEquals(left: Uint8Array, right: Uint8Array): boolean {
291
- if (left.length !== right.length) {
292
- return false;
293
- }
294
- for (let i = 0; i < left.length; ++i) {
295
- if (left[i] !== right[i]) {
296
- return false;
297
- }
298
- }
299
- return true;
300
- }
301
-
302
290
  /**
303
291
  * Returns an integer {@link Decimal} nearest to the given one.
304
292
  *
@@ -966,7 +966,9 @@ export class KaminoVaultClient {
966
966
  };
967
967
 
968
968
  const depositArgs: DepositArgs = {
969
- maxAmount: new BN(numberToLamportsDecimal(tokenAmount, vaultState.tokenMintDecimals.toNumber()).toString()),
969
+ maxAmount: new BN(
970
+ numberToLamportsDecimal(tokenAmount, vaultState.tokenMintDecimals.toNumber()).floor().toString()
971
+ ),
970
972
  };
971
973
 
972
974
  const depositIx = deposit(depositArgs, depoistAccounts, this._kaminoVaultProgramId);
@@ -1084,7 +1086,7 @@ export class KaminoVaultClient {
1084
1086
  );
1085
1087
 
1086
1088
  if (vaultAllocation) {
1087
- const withdrawFromVaultIxs = await this.wihdrdrawWithReserveIxs(
1089
+ const withdrawFromVaultIxs = await this.withdrawWithReserveIxs(
1088
1090
  user,
1089
1091
  kaminoVault,
1090
1092
  shareAmount,
@@ -1129,7 +1131,7 @@ export class KaminoVaultClient {
1129
1131
  return [createAtaIx, withdrawFromAvailableIxn];
1130
1132
  }
1131
1133
 
1132
- private async wihdrdrawWithReserveIxs(
1134
+ private async withdrawWithReserveIxs(
1133
1135
  user: PublicKey,
1134
1136
  vault: KaminoVault,
1135
1137
  shareAmount: Decimal,
@@ -1139,7 +1141,6 @@ export class KaminoVaultClient {
1139
1141
  const vaultState = await vault.getState(this.getConnection());
1140
1142
 
1141
1143
  const vaultReservesState = vaultReservesMap ? vaultReservesMap : await this.loadVaultReserves(vaultState);
1142
-
1143
1144
  const userSharesAta = getAssociatedTokenAddress(vaultState.sharesMint, user);
1144
1145
  const [{ ata: userTokenAta, createAtaIx }] = createAtasIdempotent(user, [
1145
1146
  {
@@ -1162,9 +1163,12 @@ export class KaminoVaultClient {
1162
1163
  let isFirstWithdraw = true;
1163
1164
 
1164
1165
  if (tokenLeftToWithdraw.lte(0)) {
1165
- // Availabe enough to withdraw all - using first reserve as it does not matter
1166
+ // Availabe enough to withdraw all - using the first existent reserve
1167
+ const firstReserve = vaultState.vaultAllocationStrategy.find(
1168
+ (reserve) => !reserve.reserve.equals(PublicKey.default)
1169
+ );
1166
1170
  reserveWithSharesAmountToWithdraw.push({
1167
- reserve: vaultState.vaultAllocationStrategy[0].reserve,
1171
+ reserve: firstReserve!.reserve,
1168
1172
  shares: shareLamportsToWithdraw,
1169
1173
  });
1170
1174
  } else {
@@ -1197,7 +1201,6 @@ export class KaminoVaultClient {
1197
1201
 
1198
1202
  const withdrawIxs: TransactionInstruction[] = [];
1199
1203
  withdrawIxs.push(createAtaIx);
1200
-
1201
1204
  for (let reserveIndex = 0; reserveIndex < reserveWithSharesAmountToWithdraw.length; reserveIndex++) {
1202
1205
  const reserveWithTokens = reserveWithSharesAmountToWithdraw[reserveIndex];
1203
1206
  const reserveState = vaultReservesState.get(reserveWithTokens.reserve);
@@ -2504,6 +2507,7 @@ export class KaminoVaultClient {
2504
2507
  const slotForOverview = slot ? slot : await this.getConnection().getSlot();
2505
2508
 
2506
2509
  const vaultTheoreticalAPYPromise = await this.getVaultTheoreticalAPY(vault, slotForOverview, vaultReservesState);
2510
+ const vaultActualAPYPromise = await this.getVaultActualAPY(vault, slotForOverview, vaultReservesState);
2507
2511
  const totalInvestedAndBorrowedPromise = await this.getTotalBorrowedAndInvested(
2508
2512
  vault,
2509
2513
  slotForOverview,
@@ -2521,12 +2525,14 @@ export class KaminoVaultClient {
2521
2525
  const [
2522
2526
  vaultHoldingsWithUSDValue,
2523
2527
  vaultTheoreticalAPYs,
2528
+ vaultActualAPYs,
2524
2529
  totalInvestedAndBorrowed,
2525
2530
  vaultCollaterals,
2526
2531
  reservesOverview,
2527
2532
  ] = await Promise.all([
2528
2533
  vaultHoldingsWithUSDValuePromise,
2529
2534
  vaultTheoreticalAPYPromise,
2535
+ vaultActualAPYPromise,
2530
2536
  totalInvestedAndBorrowedPromise,
2531
2537
  vaultCollateralsPromise,
2532
2538
  reservesOverviewPromise,
@@ -2536,6 +2542,7 @@ export class KaminoVaultClient {
2536
2542
  holdingsUSD: vaultHoldingsWithUSDValue,
2537
2543
  reservesOverview: reservesOverview,
2538
2544
  vaultCollaterals: vaultCollaterals,
2545
+ actualSupplyAPY: vaultActualAPYs,
2539
2546
  theoreticalSupplyAPY: vaultTheoreticalAPYs,
2540
2547
  totalBorrowed: totalInvestedAndBorrowed.totalBorrowed,
2541
2548
  totalBorrowedUSD: totalInvestedAndBorrowed.totalBorrowed.mul(price),
@@ -2693,6 +2700,57 @@ export class KaminoVaultClient {
2693
2700
  };
2694
2701
  }
2695
2702
 
2703
+ /**
2704
+ * This will return the APY of the vault based on the current invested amounts; for percentage it needs multiplication by 100
2705
+ * @param vault - the kamino vault to get APY for
2706
+ * @param slot - current slot
2707
+ * @param [vaultReservesMap] - hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
2708
+ * @returns a struct containing estimated gross APY and net APY (gross - vault fees) for the vault
2709
+ */
2710
+ async getVaultActualAPY(
2711
+ vault: VaultState,
2712
+ slot: number,
2713
+ vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>
2714
+ ): Promise<APYs> {
2715
+ const vaultReservesState = vaultReservesMap ? vaultReservesMap : await this.loadVaultReserves(vault);
2716
+
2717
+ let totalAUM = new Decimal(vault.tokenAvailable.toString());
2718
+ let totalAPY = new Decimal(0);
2719
+ vault.vaultAllocationStrategy.forEach((allocationStrategy) => {
2720
+ if (allocationStrategy.reserve.equals(PublicKey.default)) {
2721
+ return;
2722
+ }
2723
+
2724
+ const reserve = vaultReservesState.get(allocationStrategy.reserve);
2725
+ if (reserve === undefined) {
2726
+ throw new Error(`Reserve ${allocationStrategy.reserve.toBase58()} not found`);
2727
+ }
2728
+
2729
+ const reserveAPY = new Decimal(reserve.totalSupplyAPY(slot));
2730
+ const exchangeRate = reserve.getEstimatedCollateralExchangeRate(slot, 0);
2731
+ const investedInReserve = exchangeRate.mul(new Decimal(allocationStrategy.ctokenAllocation.toString()));
2732
+
2733
+ const weightedAPY = reserveAPY.mul(investedInReserve);
2734
+ totalAPY = totalAPY.add(weightedAPY);
2735
+ totalAUM = totalAUM.add(investedInReserve);
2736
+ });
2737
+ if (totalAUM.isZero()) {
2738
+ return {
2739
+ grossAPY: new Decimal(0),
2740
+ netAPY: new Decimal(0),
2741
+ };
2742
+ }
2743
+
2744
+ const grossAPY = totalAPY.div(totalAUM);
2745
+ const netAPY = grossAPY
2746
+ .mul(new Decimal(1).sub(new Decimal(vault.performanceFeeBps.toString()).div(FullBPSDecimal)))
2747
+ .mul(new Decimal(1).sub(new Decimal(vault.managementFeeBps.toString()).div(FullBPSDecimal)));
2748
+ return {
2749
+ grossAPY,
2750
+ netAPY,
2751
+ };
2752
+ }
2753
+
2696
2754
  /**
2697
2755
  * Retrive the total amount of interest earned by the vault since its inception, up to the last interaction with the vault on chain, including what was charged as fees
2698
2756
  * @param vaultState the kamino vault state to get total net yield for
@@ -2784,6 +2842,15 @@ export class KaminoVaultClient {
2784
2842
  performanceFee: performanceFee,
2785
2843
  };
2786
2844
  }
2845
+
2846
+ computeUserFarmStateDelegateePDAForUserInVault(
2847
+ farmProgramID: PublicKey,
2848
+ vault: PublicKey,
2849
+ reserve: PublicKey,
2850
+ user: PublicKey
2851
+ ): [PublicKey, number] {
2852
+ return PublicKey.findProgramAddressSync([vault.toBuffer(), reserve.toBuffer(), user.toBuffer()], farmProgramID);
2853
+ }
2787
2854
  } // KaminoVaultClient
2788
2855
 
2789
2856
  export class KaminoVault {
@@ -2972,6 +3039,7 @@ export type VaultOverview = {
2972
3039
  reservesOverview: PubkeyHashMap<PublicKey, ReserveOverview>;
2973
3040
  vaultCollaterals: PubkeyHashMap<PublicKey, MarketOverview>;
2974
3041
  theoreticalSupplyAPY: APYs;
3042
+ actualSupplyAPY: APYs;
2975
3043
  totalBorrowed: Decimal;
2976
3044
  totalBorrowedUSD: Decimal;
2977
3045
  totalSupplied: Decimal;
@@ -8,20 +8,15 @@ import {
8
8
  Signer,
9
9
  Transaction,
10
10
  TransactionInstruction,
11
- TransactionMessage,
12
11
  TransactionSignature,
13
12
  VersionedTransaction,
14
13
  } from '@solana/web3.js';
15
14
  import {
16
15
  AssetReserveConfigCli,
17
16
  Chain,
18
- createLookupTableIx,
19
17
  DEFAULT_RECENT_SLOT_DURATION_MS,
20
18
  encodeTokenName,
21
- extendLookupTableIxs,
22
- getLookupTableAccounts,
23
19
  getMedianSlotDurationInMsFromLastEpochs,
24
- globalConfigPda,
25
20
  initLookupTableIx,
26
21
  KaminoManager,
27
22
  KaminoMarket,
@@ -32,7 +27,6 @@ import {
32
27
  MAINNET_BETA_CHAIN_ID,
33
28
  parseZeroPaddedUtf8,
34
29
  printHoldings,
35
- PROGRAM_ID,
36
30
  Reserve,
37
31
  ReserveAllocationConfig,
38
32
  ReserveWithAddress,
@@ -159,10 +153,7 @@ async function main() {
159
153
 
160
154
  const _createReserveSig = await processTxn(env.client, env.payer, txnIxs[0], mode, 2500, [reserve]);
161
155
 
162
- const [lut, createLutIxs] = await createUpdateReserveConfigLutIxs(env, marketAddress, reserve.publicKey);
163
- await processTxn(env.client, env.payer, createLutIxs, mode, 2500, []);
164
-
165
- const _updateSig = await processTxn(env.client, env.payer, txnIxs[1], mode, 2500, [], 400_000, 1000, [lut]);
156
+ const _updateReserveSig = await processTxn(env.client, env.payer, txnIxs[1], mode, 2500, [], 400_000);
166
157
 
167
158
  mode === 'execute' &&
168
159
  console.log(
@@ -618,13 +609,21 @@ async function main() {
618
609
  const acceptVaultOwnershipSig = await processTxn(
619
610
  env.client,
620
611
  env.payer,
621
- [instructions.acceptVaultOwnershipIx, ...instructions.updateLUTIxs],
612
+ [instructions.acceptVaultOwnershipIx],
622
613
  mode,
623
614
  2500,
624
615
  []
625
616
  );
626
617
 
627
618
  mode === 'execute' && console.log('Vault ownership accepted:', acceptVaultOwnershipSig);
619
+
620
+ // send the LUT mgmt ixs one by one
621
+ const lutIxs = [...instructions.updateLUTIxs];
622
+ for (let i = 0; i < lutIxs.length; i++) {
623
+ const lutIxsGroup = lutIxs.slice(i, i + 1);
624
+ const lutIxsSig = await processTxn(env.client, env.payer, lutIxsGroup, mode, 2500, []);
625
+ mode === 'execute' && console.log('LUT updated:', lutIxsSig);
626
+ }
628
627
  });
629
628
 
630
629
  commands
@@ -1077,7 +1076,11 @@ async function main() {
1077
1076
  const walletAddress = new PublicKey(wallet);
1078
1077
  const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
1079
1078
  const userShares = await kaminoManager.getUserSharesBalanceSingleVault(walletAddress, kaminoVault);
1080
- console.log(`User shares for vault ${vaultAddress.toBase58()}: ${userShares}`);
1079
+ console.log(
1080
+ `User shares for vault ${vaultAddress.toBase58()}: unstaked shares: ${
1081
+ userShares.unstakedShares
1082
+ } staked shares: ${userShares.stakedShares} total shares: ${userShares.totalShares}`
1083
+ );
1081
1084
  });
1082
1085
 
1083
1086
  commands
@@ -1601,46 +1604,45 @@ async function processTxn(
1601
1604
  priorityFeeMultiplier: number = 2500,
1602
1605
  extraSigners: Signer[],
1603
1606
  computeUnits: number = 200_000,
1604
- priorityFeeLamports: number = 1000,
1605
- luts: PublicKey[] = []
1607
+ priorityFeeLamports: number = 1000
1606
1608
  ): Promise<TransactionSignature> {
1607
1609
  if (mode !== 'inspect' && mode !== 'simulate' && mode !== 'execute' && mode !== 'multisig') {
1608
1610
  throw new Error('Invalid mode: ' + mode + '. Must be one of: inspect/simulate/execute/multisig');
1609
1611
  }
1610
1612
  if (mode === 'multisig') {
1611
1613
  const { blockhash } = await web3Client.connection.getLatestBlockhash();
1612
- const txn = new Transaction();
1613
- txn.add(...ixs);
1614
- txn.recentBlockhash = blockhash;
1615
- txn.feePayer = admin.publicKey;
1614
+ for (const ix of ixs) {
1615
+ const txn = new Transaction();
1616
+ txn.add(ix);
1617
+ txn.recentBlockhash = blockhash;
1618
+ txn.feePayer = admin.publicKey;
1616
1619
 
1617
- console.log(binary_to_base58(txn.serializeMessage()));
1620
+ console.log(`${binary_to_base58(txn.serializeMessage())} \n`);
1621
+ }
1618
1622
 
1619
1623
  return '';
1620
1624
  } else {
1621
1625
  const microLamport = priorityFeeLamports * 10 ** 6; // 1000 lamports
1622
1626
  const microLamportsPrioritizationFee = microLamport / computeUnits;
1623
- const { blockhash } = await web3Client.connection.getLatestBlockhash();
1624
1627
 
1628
+ const tx = new Transaction();
1629
+ const { blockhash } = await web3Client.connection.getLatestBlockhash();
1625
1630
  if (priorityFeeMultiplier) {
1626
1631
  const priorityFeeIxn = createAddExtraComputeUnitFeeTransaction(
1627
1632
  computeUnits,
1628
1633
  microLamportsPrioritizationFee * priorityFeeMultiplier
1629
1634
  );
1630
- ixs.push(...priorityFeeIxn);
1635
+ tx.add(...priorityFeeIxn);
1631
1636
  }
1632
-
1633
- const tx = new TransactionMessage({
1634
- payerKey: admin.publicKey,
1635
- recentBlockhash: blockhash,
1636
- instructions: ixs,
1637
- }).compileToV0Message(await getLookupTableAccounts(web3Client.connection, luts));
1637
+ tx.recentBlockhash = blockhash;
1638
+ tx.feePayer = admin.publicKey;
1639
+ tx.add(...ixs);
1638
1640
 
1639
1641
  if (mode === 'execute') {
1640
1642
  return await signSendAndConfirmRawTransactionWithRetry({
1641
1643
  mainConnection: web3Client.sendConnection,
1642
1644
  extraConnections: [],
1643
- tx: new VersionedTransaction(tx),
1645
+ tx: new VersionedTransaction(tx.compileMessage()),
1644
1646
  signers: [admin, ...extraSigners],
1645
1647
  commitment: 'confirmed',
1646
1648
  sendTransactionOptions: {
@@ -1649,7 +1651,9 @@ async function processTxn(
1649
1651
  },
1650
1652
  });
1651
1653
  } else if (mode === 'simulate') {
1652
- const simulation = await web3Client.sendConnection.simulateTransaction(new VersionedTransaction(tx));
1654
+ const simulation = await web3Client.sendConnection.simulateTransaction(
1655
+ new VersionedTransaction(tx.compileMessage())
1656
+ );
1653
1657
  if (simulation.value.logs && simulation.value.logs.length > 0) {
1654
1658
  console.log('Simulation: \n' + simulation.value.logs);
1655
1659
  } else {
@@ -1659,7 +1663,7 @@ async function processTxn(
1659
1663
  console.log(
1660
1664
  'Tx in B64',
1661
1665
  `https://explorer.solana.com/tx/inspector?message=${encodeURIComponent(
1662
- Buffer.from(tx.serialize()).toString('base64')
1666
+ tx.serializeMessage().toString('base64')
1663
1667
  )}`
1664
1668
  );
1665
1669
  }
@@ -1857,15 +1861,3 @@ function parseReserveConfigToFile(reserveConfig: ReserveConfig) {
1857
1861
  reserved2: Array(9).fill(0),
1858
1862
  };
1859
1863
  }
1860
-
1861
- async function createUpdateReserveConfigLutIxs(
1862
- env: Env,
1863
- lendingMarketAddress: PublicKey,
1864
- reserveAddress: PublicKey
1865
- ): Promise<[PublicKey, TransactionInstruction[]]> {
1866
- const [globalConfigAddress] = globalConfigPda(PROGRAM_ID);
1867
- const contents = [globalConfigAddress, lendingMarketAddress, reserveAddress];
1868
- const [createIx, lut] = await createLookupTableIx(env.connection, env.payer.publicKey);
1869
- const extendIxs = extendLookupTableIxs(env.payer.publicKey, lut, contents);
1870
- return [lut, [createIx, ...extendIxs]];
1871
- }
package/src/idl.json CHANGED
@@ -230,15 +230,10 @@
230
230
  "name": "updateReserveConfig",
231
231
  "accounts": [
232
232
  {
233
- "name": "signer",
233
+ "name": "lendingMarketOwner",
234
234
  "isMut": false,
235
235
  "isSigner": true
236
236
  },
237
- {
238
- "name": "globalConfig",
239
- "isMut": false,
240
- "isSigner": false
241
- },
242
237
  {
243
238
  "name": "lendingMarket",
244
239
  "isMut": false,
@@ -253,9 +248,7 @@
253
248
  "args": [
254
249
  {
255
250
  "name": "mode",
256
- "type": {
257
- "defined": "UpdateConfigMode"
258
- }
251
+ "type": "u64"
259
252
  },
260
253
  {
261
254
  "name": "value",
@@ -312,9 +305,9 @@
312
305
  "name": "withdrawProtocolFee",
313
306
  "accounts": [
314
307
  {
315
- "name": "globalConfig",
308
+ "name": "lendingMarketOwner",
316
309
  "isMut": false,
317
- "isSigner": false
310
+ "isSigner": true
318
311
  },
319
312
  {
320
313
  "name": "lendingMarket",
@@ -342,7 +335,7 @@
342
335
  "isSigner": false
343
336
  },
344
337
  {
345
- "name": "feeCollectorAta",
338
+ "name": "lendingMarketOwnerAta",
346
339
  "isMut": true,
347
340
  "isSigner": false
348
341
  },
@@ -2939,93 +2932,14 @@
2939
2932
  }
2940
2933
  ]
2941
2934
  },
2942
- {
2943
- "name": "initGlobalConfig",
2944
- "accounts": [
2945
- {
2946
- "name": "payer",
2947
- "isMut": true,
2948
- "isSigner": true
2949
- },
2950
- {
2951
- "name": "globalConfig",
2952
- "isMut": true,
2953
- "isSigner": false
2954
- },
2955
- {
2956
- "name": "programData",
2957
- "isMut": false,
2958
- "isSigner": false
2959
- },
2960
- {
2961
- "name": "systemProgram",
2962
- "isMut": false,
2963
- "isSigner": false
2964
- },
2965
- {
2966
- "name": "rent",
2967
- "isMut": false,
2968
- "isSigner": false
2969
- }
2970
- ],
2971
- "args": []
2972
- },
2973
- {
2974
- "name": "updateGlobalConfig",
2975
- "accounts": [
2976
- {
2977
- "name": "globalAdmin",
2978
- "isMut": false,
2979
- "isSigner": true
2980
- },
2981
- {
2982
- "name": "globalConfig",
2983
- "isMut": true,
2984
- "isSigner": false
2985
- }
2986
- ],
2987
- "args": [
2988
- {
2989
- "name": "mode",
2990
- "type": {
2991
- "defined": "UpdateGlobalConfigMode"
2992
- }
2993
- },
2994
- {
2995
- "name": "value",
2996
- "type": "bytes"
2997
- }
2998
- ]
2999
- },
3000
- {
3001
- "name": "updateGlobalConfigAdmin",
3002
- "accounts": [
3003
- {
3004
- "name": "pendingAdmin",
3005
- "isMut": false,
3006
- "isSigner": true
3007
- },
3008
- {
3009
- "name": "globalConfig",
3010
- "isMut": true,
3011
- "isSigner": false
3012
- }
3013
- ],
3014
- "args": []
3015
- },
3016
2935
  {
3017
2936
  "name": "idlMissingTypes",
3018
2937
  "accounts": [
3019
2938
  {
3020
- "name": "signer",
2939
+ "name": "lendingMarketOwner",
3021
2940
  "isMut": false,
3022
2941
  "isSigner": true
3023
2942
  },
3024
- {
3025
- "name": "globalConfig",
3026
- "isMut": false,
3027
- "isSigner": false
3028
- },
3029
2943
  {
3030
2944
  "name": "lendingMarket",
3031
2945
  "isMut": false,
@@ -3220,47 +3134,6 @@
3220
3134
  ]
3221
3135
  }
3222
3136
  },
3223
- {
3224
- "name": "GlobalConfig",
3225
- "type": {
3226
- "kind": "struct",
3227
- "fields": [
3228
- {
3229
- "name": "globalAdmin",
3230
- "docs": [
3231
- "Global admin of the program"
3232
- ],
3233
- "type": "publicKey"
3234
- },
3235
- {
3236
- "name": "pendingAdmin",
3237
- "docs": [
3238
- "Pending admin must sign a specific transaction to become the global admin"
3239
- ],
3240
- "type": "publicKey"
3241
- },
3242
- {
3243
- "name": "feeCollector",
3244
- "docs": [
3245
- "Fee collector is the only allowed owner of token accounts receiving protocol fees"
3246
- ],
3247
- "type": "publicKey"
3248
- },
3249
- {
3250
- "name": "padding",
3251
- "docs": [
3252
- "Padding to make the struct size 1024 bytes"
3253
- ],
3254
- "type": {
3255
- "array": [
3256
- "u8",
3257
- 928
3258
- ]
3259
- }
3260
- }
3261
- ]
3262
- }
3263
- },
3264
3137
  {
3265
3138
  "name": "LendingMarket",
3266
3139
  "type": {
@@ -3480,33 +3353,18 @@
3480
3353
  "type": "u64"
3481
3354
  },
3482
3355
  {
3483
- "name": "obligationOrderExecutionEnabled",
3356
+ "name": "obligationOrdersEnabled",
3484
3357
  "docs": [
3485
3358
  "Whether the obligation orders should be evaluated during liquidations."
3486
3359
  ],
3487
3360
  "type": "u8"
3488
3361
  },
3489
- {
3490
- "name": "immutable",
3491
- "docs": [
3492
- "Whether the lending market is set as immutable."
3493
- ],
3494
- "type": "u8"
3495
- },
3496
- {
3497
- "name": "obligationOrderCreationEnabled",
3498
- "docs": [
3499
- "Whether new obligation orders can be created.",
3500
- "Note: updating or cancelling existing orders is *not* affected by this flag."
3501
- ],
3502
- "type": "u8"
3503
- },
3504
3362
  {
3505
3363
  "name": "padding2",
3506
3364
  "type": {
3507
3365
  "array": [
3508
3366
  "u8",
3509
- 5
3367
+ 7
3510
3368
  ]
3511
3369
  }
3512
3370
  },
@@ -4328,27 +4186,7 @@
4328
4186
  "name": "UpdateInitialDepositAmount"
4329
4187
  },
4330
4188
  {
4331
- "name": "UpdateObligationOrderExecutionEnabled"
4332
- },
4333
- {
4334
- "name": "UpdateImmutableFlag"
4335
- },
4336
- {
4337
- "name": "UpdateObligationOrderCreationEnabled"
4338
- }
4339
- ]
4340
- }
4341
- },
4342
- {
4343
- "name": "UpdateGlobalConfigMode",
4344
- "type": {
4345
- "kind": "enum",
4346
- "variants": [
4347
- {
4348
- "name": "PendingAdmin"
4349
- },
4350
- {
4351
- "name": "FeeCollector"
4189
+ "name": "UpdateObligationOrdersEnabled"
4352
4190
  }
4353
4191
  ]
4354
4192
  }
@@ -6194,21 +6032,6 @@
6194
6032
  "code": 6126,
6195
6033
  "name": "OperationNotPermittedWithCurrentObligationOrders",
6196
6034
  "msg": "Single debt, single collateral obligation orders have to be cancelled before changing the deposit/borrow count"
6197
- },
6198
- {
6199
- "code": 6127,
6200
- "name": "OperationNotPermittedMarketImmutable",
6201
- "msg": "Cannot update lending market because it is set as immutable"
6202
- },
6203
- {
6204
- "code": 6128,
6205
- "name": "OrderCreationDisabled",
6206
- "msg": "Creation of new orders is disabled"
6207
- },
6208
- {
6209
- "code": 6129,
6210
- "name": "NoUpgradeAuthority",
6211
- "msg": "Cannot initialize global config because there is no upgrade authority to the program"
6212
6035
  }
6213
6036
  ]
6214
6037
  }