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

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 (53) hide show
  1. package/dist/classes/action.d.ts.map +1 -1
  2. package/dist/classes/action.js +55 -48
  3. package/dist/classes/action.js.map +1 -1
  4. package/dist/classes/index.d.ts +1 -0
  5. package/dist/classes/index.d.ts.map +1 -1
  6. package/dist/classes/index.js +1 -0
  7. package/dist/classes/index.js.map +1 -1
  8. package/dist/classes/manager.d.ts +5 -0
  9. package/dist/classes/manager.d.ts.map +1 -1
  10. package/dist/classes/manager.js +15 -0
  11. package/dist/classes/manager.js.map +1 -1
  12. package/dist/classes/vault.js +14 -14
  13. package/dist/classes/vault.js.map +1 -1
  14. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +3 -3
  15. package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
  16. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +6 -6
  17. package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
  18. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts +1 -1
  19. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts.map +1 -1
  20. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js +1 -1
  21. package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js.map +1 -1
  22. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts +1 -1
  23. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts.map +1 -1
  24. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js +1 -1
  25. package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js.map +1 -1
  26. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts +1 -1
  27. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts.map +1 -1
  28. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js +1 -1
  29. package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js.map +1 -1
  30. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts +1 -1
  31. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts.map +1 -1
  32. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js +1 -1
  33. package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js.map +1 -1
  34. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts +1 -1
  35. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts.map +1 -1
  36. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js +1 -1
  37. package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js.map +1 -1
  38. package/dist/utils/oracle.d.ts.map +1 -1
  39. package/dist/utils/oracle.js +4 -3
  40. package/dist/utils/oracle.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/classes/action.ts +71 -52
  43. package/src/classes/index.ts +1 -0
  44. package/src/classes/manager.ts +31 -0
  45. package/src/classes/vault.ts +14 -14
  46. package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +8 -8
  47. package/src/idl_codegen_kamino_vault/instructions/giveUpPendingFees.ts +2 -2
  48. package/src/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.ts +2 -2
  49. package/src/idl_codegen_kamino_vault/instructions/updateSharesMetadata.ts +2 -2
  50. package/src/idl_codegen_kamino_vault/instructions/updateVaultConfig.ts +2 -2
  51. package/src/idl_codegen_kamino_vault/instructions/withdrawPendingFees.ts +2 -2
  52. package/src/idl_kamino_vault.json +7 -7
  53. package/src/utils/oracle.ts +5 -4
@@ -503,6 +503,18 @@ export class KaminoAction {
503
503
  axn.addComputeBudgetIxn(extraComputeBudget);
504
504
  }
505
505
 
506
+ if (!axn.referrer.equals(PublicKey.default)) {
507
+ const referrerTokenState = referrerTokenStatePda(
508
+ axn.referrer,
509
+ axn.reserve.address,
510
+ axn.kaminoMarket.programId
511
+ )[0];
512
+ const account = await axn.kaminoMarket.getConnection().getAccountInfo(referrerTokenState);
513
+ if (!account) {
514
+ axn.addInitReferrerTokenStateIx(axn.reserve, referrerTokenState);
515
+ }
516
+ }
517
+
506
518
  await axn.addSupportIxs(
507
519
  'borrow',
508
520
  includeAtaIxns,
@@ -703,6 +715,17 @@ export class KaminoAction {
703
715
  axn.addComputeBudgetIxn(extraComputeBudget);
704
716
  }
705
717
 
718
+ if (!axn.referrer.equals(PublicKey.default)) {
719
+ const referrerTokenState = referrerTokenStatePda(
720
+ axn.referrer,
721
+ axn.outflowReserve!.address,
722
+ axn.kaminoMarket.programId
723
+ )[0];
724
+ const account = await axn.kaminoMarket.getConnection().getAccountInfo(referrerTokenState);
725
+ if (!account) {
726
+ axn.addInitReferrerTokenStateIx(axn.outflowReserve!, referrerTokenState);
727
+ }
728
+ }
706
729
  await axn.addSupportIxs(
707
730
  'deposit',
708
731
  includeAtaIxns,
@@ -1035,6 +1058,17 @@ export class KaminoAction {
1035
1058
  axn.preTxnIxs.push(...createAtaIxs);
1036
1059
  axn.preTxnIxsLabels.push(`createAtasIxs[${axn.userTokenAccountAddress.toString()}]`);
1037
1060
 
1061
+ if (!axn.referrer.equals(PublicKey.default)) {
1062
+ const referrerTokenState = referrerTokenStatePda(
1063
+ axn.referrer,
1064
+ axn.reserve.address,
1065
+ axn.kaminoMarket.programId
1066
+ )[0];
1067
+ const account = await axn.kaminoMarket.getConnection().getAccountInfo(referrerTokenState);
1068
+ if (!account) {
1069
+ axn.addInitReferrerTokenStateIx(axn.reserve, referrerTokenState);
1070
+ }
1071
+ }
1038
1072
  axn.addRefreshReserveIxs([axn.reserve.address]);
1039
1073
  axn.addWithdrawReferrerFeesIxs();
1040
1074
 
@@ -1223,8 +1257,8 @@ export class KaminoAction {
1223
1257
  addDepositIxV2() {
1224
1258
  const farmsAccounts = this.reserve.state.farmCollateral.equals(PublicKey.default)
1225
1259
  ? {
1226
- obligationFarmUserState: PROGRAM_ID,
1227
- reserveFarmState: PROGRAM_ID,
1260
+ obligationFarmUserState: this.kaminoMarket.programId,
1261
+ reserveFarmState: this.kaminoMarket.programId,
1228
1262
  }
1229
1263
  : {
1230
1264
  obligationFarmUserState: obligationFarmStatePda(
@@ -1291,8 +1325,8 @@ export class KaminoAction {
1291
1325
  addDepositObligationCollateralIxV2() {
1292
1326
  const farmsAccounts = this.reserve.state.farmCollateral.equals(PublicKey.default)
1293
1327
  ? {
1294
- obligationFarmUserState: PROGRAM_ID,
1295
- reserveFarmState: PROGRAM_ID,
1328
+ obligationFarmUserState: this.kaminoMarket.programId,
1329
+ reserveFarmState: this.kaminoMarket.programId,
1296
1330
  }
1297
1331
  : {
1298
1332
  obligationFarmUserState: obligationFarmStatePda(
@@ -1376,8 +1410,8 @@ export class KaminoAction {
1376
1410
 
1377
1411
  const farmsAccounts = this.reserve.state.farmDebt.equals(PublicKey.default)
1378
1412
  ? {
1379
- obligationFarmUserState: PROGRAM_ID,
1380
- reserveFarmState: PROGRAM_ID,
1413
+ obligationFarmUserState: this.kaminoMarket.programId,
1414
+ reserveFarmState: this.kaminoMarket.programId,
1381
1415
  }
1382
1416
  : {
1383
1417
  obligationFarmUserState: obligationFarmStatePda(this.getObligationPda(), this.reserve.state.farmDebt)[0],
@@ -1451,8 +1485,8 @@ export class KaminoAction {
1451
1485
  async addWithdrawIxV2(collateralAmount: BN) {
1452
1486
  const farmsAccounts = this.reserve.state.farmCollateral.equals(PublicKey.default)
1453
1487
  ? {
1454
- obligationFarmUserState: PROGRAM_ID,
1455
- reserveFarmState: PROGRAM_ID,
1488
+ obligationFarmUserState: this.kaminoMarket.programId,
1489
+ reserveFarmState: this.kaminoMarket.programId,
1456
1490
  }
1457
1491
  : {
1458
1492
  obligationFarmUserState: obligationFarmStatePda(
@@ -1538,8 +1572,8 @@ export class KaminoAction {
1538
1572
 
1539
1573
  const farmsAccounts = this.reserve.state.farmDebt.equals(PublicKey.default)
1540
1574
  ? {
1541
- obligationFarmUserState: PROGRAM_ID,
1542
- reserveFarmState: PROGRAM_ID,
1575
+ obligationFarmUserState: this.kaminoMarket.programId,
1576
+ reserveFarmState: this.kaminoMarket.programId,
1543
1577
  }
1544
1578
  : {
1545
1579
  obligationFarmUserState: obligationFarmStatePda(this.getObligationPda(), this.reserve.state.farmDebt)[0],
@@ -1659,8 +1693,8 @@ export class KaminoAction {
1659
1693
  async addDepositAndBorrowIxV2() {
1660
1694
  const collateralFarmsAccounts = this.reserve.state.farmCollateral.equals(PublicKey.default)
1661
1695
  ? {
1662
- obligationFarmUserState: PROGRAM_ID,
1663
- reserveFarmState: PROGRAM_ID,
1696
+ obligationFarmUserState: this.kaminoMarket.programId,
1697
+ reserveFarmState: this.kaminoMarket.programId,
1664
1698
  }
1665
1699
  : {
1666
1700
  obligationFarmUserState: obligationFarmStatePda(
@@ -1723,8 +1757,8 @@ export class KaminoAction {
1723
1757
 
1724
1758
  const debtFarmsAccounts = this.outflowReserve.state.farmDebt.equals(PublicKey.default)
1725
1759
  ? {
1726
- obligationFarmUserState: PROGRAM_ID,
1727
- reserveFarmState: PROGRAM_ID,
1760
+ obligationFarmUserState: this.kaminoMarket.programId,
1761
+ reserveFarmState: this.kaminoMarket.programId,
1728
1762
  }
1729
1763
  : {
1730
1764
  obligationFarmUserState: obligationFarmStatePda(
@@ -1852,8 +1886,8 @@ export class KaminoAction {
1852
1886
 
1853
1887
  const debtFarmsAccounts = this.reserve.state.farmDebt.equals(PublicKey.default)
1854
1888
  ? {
1855
- obligationFarmUserState: PROGRAM_ID,
1856
- reserveFarmState: PROGRAM_ID,
1889
+ obligationFarmUserState: this.kaminoMarket.programId,
1890
+ reserveFarmState: this.kaminoMarket.programId,
1857
1891
  }
1858
1892
  : {
1859
1893
  obligationFarmUserState: obligationFarmStatePda(this.getObligationPda(), this.reserve.state.farmDebt)[0],
@@ -1900,8 +1934,8 @@ export class KaminoAction {
1900
1934
 
1901
1935
  const collateralFarmsAccounts = this.outflowReserve.state.farmCollateral.equals(PublicKey.default)
1902
1936
  ? {
1903
- obligationFarmUserState: PROGRAM_ID,
1904
- reserveFarmState: PROGRAM_ID,
1937
+ obligationFarmUserState: this.kaminoMarket.programId,
1938
+ reserveFarmState: this.kaminoMarket.programId,
1905
1939
  }
1906
1940
  : {
1907
1941
  obligationFarmUserState: obligationFarmStatePda(
@@ -2009,8 +2043,8 @@ export class KaminoAction {
2009
2043
 
2010
2044
  const collateralFarmsAccounts = this.outflowReserve.state.farmCollateral.equals(PublicKey.default)
2011
2045
  ? {
2012
- obligationFarmUserState: PROGRAM_ID,
2013
- reserveFarmState: PROGRAM_ID,
2046
+ obligationFarmUserState: this.kaminoMarket.programId,
2047
+ reserveFarmState: this.kaminoMarket.programId,
2014
2048
  }
2015
2049
  : {
2016
2050
  obligationFarmUserState: obligationFarmStatePda(
@@ -2022,8 +2056,8 @@ export class KaminoAction {
2022
2056
 
2023
2057
  const debtFarmsAccounts = this.reserve.state.farmDebt.equals(PublicKey.default)
2024
2058
  ? {
2025
- obligationFarmUserState: PROGRAM_ID,
2026
- reserveFarmState: PROGRAM_ID,
2059
+ obligationFarmUserState: this.kaminoMarket.programId,
2060
+ reserveFarmState: this.kaminoMarket.programId,
2027
2061
  }
2028
2062
  : {
2029
2063
  obligationFarmUserState: obligationFarmStatePda(this.getObligationPda(), this.reserve.state.farmDebt)[0],
@@ -2420,13 +2454,6 @@ export class KaminoAction {
2420
2454
  this.addInitUserMetadataIxs(lookupTable);
2421
2455
  }
2422
2456
 
2423
- if (['borrow', 'withdrawReferrerFees'].includes(action)) {
2424
- await this.addInitReferrerTokenStateIx(this.reserve);
2425
- }
2426
- // depositAndBorrow
2427
- if (action === 'deposit' && this.outflowReserve) {
2428
- await this.addInitReferrerTokenStateIx(this.outflowReserve);
2429
- }
2430
2457
  await this.addInitObligationIxs();
2431
2458
  }
2432
2459
 
@@ -2861,29 +2888,21 @@ export class KaminoAction {
2861
2888
  this.setupIxsLabels.push(`initUserMetadata[${userMetadataAddress.toString()}]`);
2862
2889
  }
2863
2890
 
2864
- private async addInitReferrerTokenStateIx(reserve: KaminoReserve) {
2865
- if (this.referrer.equals(PublicKey.default)) {
2866
- return;
2867
- }
2868
-
2869
- const referrerTokenState = referrerTokenStatePda(this.referrer, reserve.address, this.kaminoMarket.programId)[0];
2870
- const account = await this.kaminoMarket.getConnection().getAccountInfo(referrerTokenState);
2871
- if (!account) {
2872
- const initReferrerTokenStateIx = initReferrerTokenState(
2873
- {
2874
- lendingMarket: this.kaminoMarket.getAddress(),
2875
- payer: this.owner,
2876
- reserve: reserve.address,
2877
- referrer: this.referrer,
2878
- referrerTokenState,
2879
- rent: SYSVAR_RENT_PUBKEY,
2880
- systemProgram: SystemProgram.programId,
2881
- },
2882
- this.kaminoMarket.programId
2883
- );
2884
- this.setupIxs.unshift(initReferrerTokenStateIx);
2885
- this.setupIxsLabels.unshift(`InitReferrerTokenState[${referrerTokenState.toString()} res=${reserve.address}]`);
2886
- }
2891
+ private addInitReferrerTokenStateIx(reserve: KaminoReserve, referrerTokenState: PublicKey) {
2892
+ const initReferrerTokenStateIx = initReferrerTokenState(
2893
+ {
2894
+ lendingMarket: this.kaminoMarket.getAddress(),
2895
+ payer: this.owner,
2896
+ reserve: reserve.address,
2897
+ referrer: this.referrer,
2898
+ referrerTokenState,
2899
+ rent: SYSVAR_RENT_PUBKEY,
2900
+ systemProgram: SystemProgram.programId,
2901
+ },
2902
+ this.kaminoMarket.programId
2903
+ );
2904
+ this.setupIxs.unshift(initReferrerTokenStateIx);
2905
+ this.setupIxsLabels.unshift(`InitReferrerTokenState[${referrerTokenState.toString()} res=${reserve.address}]`);
2887
2906
  }
2888
2907
 
2889
2908
  private addWithdrawReferrerFeesIxs() {
@@ -9,3 +9,4 @@ export * from './jupiterPerps';
9
9
  export * from './manager';
10
10
  export * from './vault';
11
11
  export * from './fraction';
12
+ export * from './types';
@@ -575,6 +575,37 @@ export class KaminoManager {
575
575
  return this._vaultClient.getAllVaults();
576
576
  }
577
577
 
578
+ /**
579
+ * Get all lending markets
580
+ * @returns an array of all lending markets
581
+ */
582
+ async getAllMarkets(): Promise<KaminoMarket[]> {
583
+ const lendingMarketsAccounts = await getProgramAccounts(
584
+ this.getConnection(),
585
+ this._kaminoLendProgramId,
586
+ LendingMarket.layout.span + 8,
587
+ {
588
+ commitment: this.getConnection().commitment ?? 'processed',
589
+ filters: [
590
+ { dataSize: LendingMarket.layout.span + 8 },
591
+ { memcmp: { offset: 0, bytes: bs58.encode(LendingMarket.discriminator) } },
592
+ ],
593
+ }
594
+ );
595
+
596
+ const markets = await Promise.all(
597
+ lendingMarketsAccounts.map((account) =>
598
+ KaminoMarket.load(
599
+ this._connection,
600
+ account.pubkey,
601
+ this.recentSlotDurationMs,
602
+ this._kaminoLendProgramId
603
+ )
604
+ )
605
+ );
606
+ return markets.filter((market): market is KaminoMarket => market !== null);
607
+ }
608
+
578
609
  /**
579
610
  * Get all vaults for owner
580
611
  * @param owner the pubkey of the vaults owner
@@ -293,7 +293,7 @@ export class KaminoVaultClient {
293
293
  );
294
294
 
295
295
  const updateReserveAllocationAccounts: UpdateReserveAllocationAccounts = {
296
- signer: vaultState.adminAuthority,
296
+ signer: vaultState.vaultAdminAuthority,
297
297
  vaultState: vault.address,
298
298
  baseVaultAuthority: vaultState.baseVaultAuthority,
299
299
  reserveCollateralMint: reserveState.collateral.mintPubkey,
@@ -325,7 +325,7 @@ export class KaminoVaultClient {
325
325
  accountsToAddToLUT.push(lendingMarketAuth);
326
326
 
327
327
  const insertIntoLUTIxs = await this.insertIntoLookupTableIxs(
328
- vaultState.adminAuthority,
328
+ vaultState.vaultAdminAuthority,
329
329
  vaultState.vaultLookupTable,
330
330
  accountsToAddToLUT
331
331
  );
@@ -355,12 +355,12 @@ export class KaminoVaultClient {
355
355
  const vaultState: VaultState = await vault.getState(this.getConnection());
356
356
 
357
357
  const updateVaultConfigAccs: UpdateVaultConfigAccounts = {
358
- adminAuthority: vaultState.adminAuthority,
358
+ vaultAdminAuthority: vaultState.vaultAdminAuthority,
359
359
  vaultState: vault.address,
360
360
  klendProgram: this._kaminoLendProgramId,
361
361
  };
362
362
  if (signer) {
363
- updateVaultConfigAccs.adminAuthority = signer;
363
+ updateVaultConfigAccs.vaultAdminAuthority = signer;
364
364
  }
365
365
 
366
366
  const updateVaultConfigArgs: UpdateVaultConfigArgs = {
@@ -414,7 +414,7 @@ export class KaminoVaultClient {
414
414
  if (mode.kind === new VaultConfigField.PendingVaultAdmin().kind) {
415
415
  const newPubkey = new PublicKey(value);
416
416
  const insertIntoLutIxs = await this.insertIntoLookupTableIxs(
417
- vaultState.adminAuthority,
417
+ vaultState.vaultAdminAuthority,
418
418
  vaultState.vaultLookupTable,
419
419
  [newPubkey]
420
420
  );
@@ -432,7 +432,7 @@ export class KaminoVaultClient {
432
432
  farmState!.globalConfig
433
433
  );
434
434
  const insertIntoLutIxs = await this.insertIntoLookupTableIxs(
435
- vaultState.adminAuthority,
435
+ vaultState.vaultAdminAuthority,
436
436
  vaultState.vaultLookupTable,
437
437
  keysToAddToLUT
438
438
  );
@@ -481,7 +481,7 @@ export class KaminoVaultClient {
481
481
  value: string
482
482
  ): TransactionInstruction {
483
483
  const updateVaultConfigAccs: UpdateVaultConfigAccounts = {
484
- adminAuthority: admin,
484
+ vaultAdminAuthority: admin,
485
485
  vaultState: vault,
486
486
  klendProgram: this._kaminoLendProgramId,
487
487
  };
@@ -531,7 +531,7 @@ export class KaminoVaultClient {
531
531
 
532
532
  // read the current LUT and create a new one for the new admin and backfill it
533
533
  const accountsInExistentLUT = (await getAccountsInLUT(this.getConnection(), vaultState.vaultLookupTable)).filter(
534
- (account) => !account.equals(vaultState.adminAuthority)
534
+ (account) => !account.equals(vaultState.vaultAdminAuthority)
535
535
  );
536
536
 
537
537
  const LUTIxs: TransactionInstruction[] = [];
@@ -574,7 +574,7 @@ export class KaminoVaultClient {
574
574
  const vaultState: VaultState = await vault.getState(this.getConnection());
575
575
 
576
576
  const giveUpPendingFeesAccounts: GiveUpPendingFeesAccounts = {
577
- adminAuthority: vaultState.adminAuthority,
577
+ vaultAdminAuthority: vaultState.vaultAdminAuthority,
578
578
  vaultState: vault.address,
579
579
  klendProgram: this._kaminoLendProgramId,
580
580
  };
@@ -604,7 +604,7 @@ export class KaminoVaultClient {
604
604
  ): Promise<TransactionInstruction[]> {
605
605
  const vaultState: VaultState = await vault.getState(this.getConnection());
606
606
  const vaultReservesState = vaultReservesMap ? vaultReservesMap : await this.loadVaultReserves(vaultState);
607
- const [{ ata: adminTokenAta, createAtaIx }] = createAtasIdempotent(vaultState.adminAuthority, [
607
+ const [{ ata: adminTokenAta, createAtaIx }] = createAtasIdempotent(vaultState.vaultAdminAuthority, [
608
608
  {
609
609
  mint: vaultState.tokenMint,
610
610
  tokenProgram: TOKEN_PROGRAM_ID,
@@ -1295,7 +1295,7 @@ export class KaminoVaultClient {
1295
1295
  const lendingMarketAuth = lendingMarketAuthPda(marketAddress, this._kaminoLendProgramId)[0];
1296
1296
 
1297
1297
  const withdrawPendingFeesAccounts: WithdrawPendingFeesAccounts = {
1298
- adminAuthority: vaultState.adminAuthority,
1298
+ vaultAdminAuthority: vaultState.vaultAdminAuthority,
1299
1299
  vaultState: vault.address,
1300
1300
  reserve: reserve.address,
1301
1301
  tokenVault: vaultState.tokenVault,
@@ -1355,7 +1355,7 @@ export class KaminoVaultClient {
1355
1355
  const vaultState = await vault.getState(this.getConnection());
1356
1356
  const allAccountsToBeInserted = [
1357
1357
  vault.address,
1358
- vaultState.adminAuthority,
1358
+ vaultState.vaultAdminAuthority,
1359
1359
  vaultState.baseVaultAuthority,
1360
1360
  vaultState.tokenMint,
1361
1361
  vaultState.tokenVault,
@@ -1400,7 +1400,7 @@ export class KaminoVaultClient {
1400
1400
  let lut = vaultState.vaultLookupTable;
1401
1401
  if (lut.equals(PublicKey.default)) {
1402
1402
  const recentSlot = await this.getConnection().getSlot();
1403
- const [ixn, address] = initLookupTableIx(vaultState.adminAuthority, recentSlot);
1403
+ const [ixn, address] = initLookupTableIx(vaultState.vaultAdminAuthority, recentSlot);
1404
1404
  setupLUTIfNeededIxs.push(ixn);
1405
1405
  lut = address;
1406
1406
 
@@ -1420,7 +1420,7 @@ export class KaminoVaultClient {
1420
1420
  }
1421
1421
  ixns.push(
1422
1422
  ...(await this.insertIntoLookupTableIxs(
1423
- vaultState.adminAuthority,
1423
+ vaultState.vaultAdminAuthority,
1424
1424
  lut,
1425
1425
  allAccountsToBeInserted,
1426
1426
  overridenExistentAccounts
@@ -5,7 +5,7 @@ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-u
5
5
  import { PROGRAM_ID } from "../programId"
6
6
 
7
7
  export interface VaultStateFields {
8
- adminAuthority: PublicKey
8
+ vaultAdminAuthority: PublicKey
9
9
  baseVaultAuthority: PublicKey
10
10
  baseVaultAuthorityBump: BN
11
11
  tokenMint: PublicKey
@@ -43,7 +43,7 @@ export interface VaultStateFields {
43
43
  }
44
44
 
45
45
  export interface VaultStateJSON {
46
- adminAuthority: string
46
+ vaultAdminAuthority: string
47
47
  baseVaultAuthority: string
48
48
  baseVaultAuthorityBump: string
49
49
  tokenMint: string
@@ -81,7 +81,7 @@ export interface VaultStateJSON {
81
81
  }
82
82
 
83
83
  export class VaultState {
84
- readonly adminAuthority: PublicKey
84
+ readonly vaultAdminAuthority: PublicKey
85
85
  readonly baseVaultAuthority: PublicKey
86
86
  readonly baseVaultAuthorityBump: BN
87
87
  readonly tokenMint: PublicKey
@@ -122,7 +122,7 @@ export class VaultState {
122
122
  ])
123
123
 
124
124
  static readonly layout = borsh.struct([
125
- borsh.publicKey("adminAuthority"),
125
+ borsh.publicKey("vaultAdminAuthority"),
126
126
  borsh.publicKey("baseVaultAuthority"),
127
127
  borsh.u64("baseVaultAuthorityBump"),
128
128
  borsh.publicKey("tokenMint"),
@@ -160,7 +160,7 @@ export class VaultState {
160
160
  ])
161
161
 
162
162
  constructor(fields: VaultStateFields) {
163
- this.adminAuthority = fields.adminAuthority
163
+ this.vaultAdminAuthority = fields.vaultAdminAuthority
164
164
  this.baseVaultAuthority = fields.baseVaultAuthority
165
165
  this.baseVaultAuthorityBump = fields.baseVaultAuthorityBump
166
166
  this.tokenMint = fields.tokenMint
@@ -243,7 +243,7 @@ export class VaultState {
243
243
  const dec = VaultState.layout.decode(data.slice(8))
244
244
 
245
245
  return new VaultState({
246
- adminAuthority: dec.adminAuthority,
246
+ vaultAdminAuthority: dec.vaultAdminAuthority,
247
247
  baseVaultAuthority: dec.baseVaultAuthority,
248
248
  baseVaultAuthorityBump: dec.baseVaultAuthorityBump,
249
249
  tokenMint: dec.tokenMint,
@@ -287,7 +287,7 @@ export class VaultState {
287
287
 
288
288
  toJSON(): VaultStateJSON {
289
289
  return {
290
- adminAuthority: this.adminAuthority.toString(),
290
+ vaultAdminAuthority: this.vaultAdminAuthority.toString(),
291
291
  baseVaultAuthority: this.baseVaultAuthority.toString(),
292
292
  baseVaultAuthorityBump: this.baseVaultAuthorityBump.toString(),
293
293
  tokenMint: this.tokenMint.toString(),
@@ -329,7 +329,7 @@ export class VaultState {
329
329
 
330
330
  static fromJSON(obj: VaultStateJSON): VaultState {
331
331
  return new VaultState({
332
- adminAuthority: new PublicKey(obj.adminAuthority),
332
+ vaultAdminAuthority: new PublicKey(obj.vaultAdminAuthority),
333
333
  baseVaultAuthority: new PublicKey(obj.baseVaultAuthority),
334
334
  baseVaultAuthorityBump: new BN(obj.baseVaultAuthorityBump),
335
335
  tokenMint: new PublicKey(obj.tokenMint),
@@ -9,7 +9,7 @@ export interface GiveUpPendingFeesArgs {
9
9
  }
10
10
 
11
11
  export interface GiveUpPendingFeesAccounts {
12
- adminAuthority: PublicKey
12
+ vaultAdminAuthority: PublicKey
13
13
  vaultState: PublicKey
14
14
  klendProgram: PublicKey
15
15
  }
@@ -22,7 +22,7 @@ export function giveUpPendingFees(
22
22
  programId: PublicKey = PROGRAM_ID
23
23
  ) {
24
24
  const keys: Array<AccountMeta> = [
25
- { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
25
+ { pubkey: accounts.vaultAdminAuthority, isSigner: true, isWritable: true },
26
26
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
27
27
  { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
28
28
  ]
@@ -11,7 +11,7 @@ export interface InitializeSharesMetadataArgs {
11
11
  }
12
12
 
13
13
  export interface InitializeSharesMetadataAccounts {
14
- adminAuthority: PublicKey
14
+ vaultAdminAuthority: PublicKey
15
15
  vaultState: PublicKey
16
16
  sharesMint: PublicKey
17
17
  baseVaultAuthority: PublicKey
@@ -33,7 +33,7 @@ export function initializeSharesMetadata(
33
33
  programId: PublicKey = PROGRAM_ID
34
34
  ) {
35
35
  const keys: Array<AccountMeta> = [
36
- { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
36
+ { pubkey: accounts.vaultAdminAuthority, isSigner: true, isWritable: true },
37
37
  { pubkey: accounts.vaultState, isSigner: false, isWritable: false },
38
38
  { pubkey: accounts.sharesMint, isSigner: false, isWritable: false },
39
39
  { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: false },
@@ -11,7 +11,7 @@ export interface UpdateSharesMetadataArgs {
11
11
  }
12
12
 
13
13
  export interface UpdateSharesMetadataAccounts {
14
- adminAuthority: PublicKey
14
+ vaultAdminAuthority: PublicKey
15
15
  vaultState: PublicKey
16
16
  baseVaultAuthority: PublicKey
17
17
  sharesMetadata: PublicKey
@@ -30,7 +30,7 @@ export function updateSharesMetadata(
30
30
  programId: PublicKey = PROGRAM_ID
31
31
  ) {
32
32
  const keys: Array<AccountMeta> = [
33
- { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
33
+ { pubkey: accounts.vaultAdminAuthority, isSigner: true, isWritable: true },
34
34
  { pubkey: accounts.vaultState, isSigner: false, isWritable: false },
35
35
  { pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: false },
36
36
  { pubkey: accounts.sharesMetadata, isSigner: false, isWritable: true },
@@ -10,7 +10,7 @@ export interface UpdateVaultConfigArgs {
10
10
  }
11
11
 
12
12
  export interface UpdateVaultConfigAccounts {
13
- adminAuthority: PublicKey
13
+ vaultAdminAuthority: PublicKey
14
14
  vaultState: PublicKey
15
15
  klendProgram: PublicKey
16
16
  }
@@ -26,7 +26,7 @@ export function updateVaultConfig(
26
26
  programId: PublicKey = PROGRAM_ID
27
27
  ) {
28
28
  const keys: Array<AccountMeta> = [
29
- { pubkey: accounts.adminAuthority, isSigner: true, isWritable: false },
29
+ { pubkey: accounts.vaultAdminAuthority, isSigner: true, isWritable: false },
30
30
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
31
31
  { pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
32
32
  ]
@@ -5,7 +5,7 @@ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-u
5
5
  import { PROGRAM_ID } from "../programId"
6
6
 
7
7
  export interface WithdrawPendingFeesAccounts {
8
- adminAuthority: PublicKey
8
+ vaultAdminAuthority: PublicKey
9
9
  vaultState: PublicKey
10
10
  reserve: PublicKey
11
11
  tokenVault: PublicKey
@@ -29,7 +29,7 @@ export function withdrawPendingFees(
29
29
  programId: PublicKey = PROGRAM_ID
30
30
  ) {
31
31
  const keys: Array<AccountMeta> = [
32
- { pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
32
+ { pubkey: accounts.vaultAdminAuthority, isSigner: true, isWritable: true },
33
33
  { pubkey: accounts.vaultState, isSigner: false, isWritable: true },
34
34
  { pubkey: accounts.reserve, isSigner: false, isWritable: true },
35
35
  { pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
@@ -403,7 +403,7 @@
403
403
  "name": "updateVaultConfig",
404
404
  "accounts": [
405
405
  {
406
- "name": "adminAuthority",
406
+ "name": "vaultAdminAuthority",
407
407
  "isMut": false,
408
408
  "isSigner": true
409
409
  },
@@ -435,7 +435,7 @@
435
435
  "name": "withdrawPendingFees",
436
436
  "accounts": [
437
437
  {
438
- "name": "adminAuthority",
438
+ "name": "vaultAdminAuthority",
439
439
  "isMut": true,
440
440
  "isSigner": true
441
441
  },
@@ -540,7 +540,7 @@
540
540
  "name": "giveUpPendingFees",
541
541
  "accounts": [
542
542
  {
543
- "name": "adminAuthority",
543
+ "name": "vaultAdminAuthority",
544
544
  "isMut": true,
545
545
  "isSigner": true
546
546
  },
@@ -566,7 +566,7 @@
566
566
  "name": "initializeSharesMetadata",
567
567
  "accounts": [
568
568
  {
569
- "name": "adminAuthority",
569
+ "name": "vaultAdminAuthority",
570
570
  "isMut": true,
571
571
  "isSigner": true
572
572
  },
@@ -625,7 +625,7 @@
625
625
  "name": "updateSharesMetadata",
626
626
  "accounts": [
627
627
  {
628
- "name": "adminAuthority",
628
+ "name": "vaultAdminAuthority",
629
629
  "isMut": true,
630
630
  "isSigner": true
631
631
  },
@@ -858,7 +858,7 @@
858
858
  "kind": "struct",
859
859
  "fields": [
860
860
  {
861
- "name": "adminAuthority",
861
+ "name": "vaultAdminAuthority",
862
862
  "type": "publicKey"
863
863
  },
864
864
  {
@@ -2189,4 +2189,4 @@
2189
2189
  "msg": "Wrong admin or allocation admin"
2190
2190
  }
2191
2191
  ]
2192
- }
2192
+ }
@@ -170,10 +170,11 @@ export function cacheOrGetPythPrices(
170
170
  const { price, exponent, conf: confidence, publishTime: timestamp, emaPrice } = priceMessage;
171
171
  if (price) {
172
172
  const px = new Decimal(price.toString()).div(10 ** Math.abs(exponent));
173
+ const conf = new Decimal(confidence.toString());
173
174
  prices.spot = {
174
175
  price: px,
175
176
  timestamp: BigInt(timestamp.toString()),
176
- valid: validatePythPx(px, confidence.toNumber()),
177
+ valid: validatePythPx(px, conf),
177
178
  };
178
179
  }
179
180
  if (emaPrice !== undefined && emaPrice !== null) {
@@ -297,9 +298,9 @@ function isBetterPrice(current: CandidatePrice | undefined, next: CandidatePrice
297
298
  return next.timestamp > current.timestamp;
298
299
  }
299
300
 
300
- function validatePythPx(price: Decimal, confidence: number | undefined): boolean {
301
- const conf50x = new Decimal(confidence || 0).mul(CONFIDENCE_FACTOR);
302
- return price.gt(conf50x);
301
+ function validatePythPx(price: Decimal, confidence: Decimal): boolean {
302
+ const conf50x = confidence.mul(CONFIDENCE_FACTOR);
303
+ return !price.isZero() && price.gt(conf50x);
303
304
  }
304
305
 
305
306
  function validateSwitchboardV2Px(agg: any): boolean {