@0dotxyz/p0-ts-sdk 2.8.0-alpha.1 → 2.8.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
2
  import { PublicKey, AccountMeta } from '@solana/web3.js';
3
3
  import BN from 'bn.js';
4
- import { M as MarginfiProgram, B as BankConfigCompactRaw, a as BankConfigOptRaw } from './types-6tM8iZUV.cjs';
4
+ import { M as MarginfiProgram, B as BankConfigCompactRaw, a as BankConfigOptRaw } from './types-Dqhd5rGy.cjs';
5
5
  import '@coral-xyz/anchor';
6
6
  import 'bignumber.js';
7
7
  import './dto-rate-model.types-DnQmHIO6.cjs';
@@ -1,7 +1,7 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
2
  import { PublicKey, AccountMeta } from '@solana/web3.js';
3
3
  import BN from 'bn.js';
4
- import { M as MarginfiProgram, B as BankConfigCompactRaw, a as BankConfigOptRaw } from './types-SY3xiGG8.js';
4
+ import { M as MarginfiProgram, B as BankConfigCompactRaw, a as BankConfigOptRaw } from './types-CX88CgJK.js';
5
5
  import '@coral-xyz/anchor';
6
6
  import 'bignumber.js';
7
7
  import './dto-rate-model.types-DnQmHIO6.js';
@@ -20159,7 +20159,7 @@ interface BankConfigType {
20159
20159
  oracleMaxAge: number;
20160
20160
  oracleMaxConfidence: number;
20161
20161
  fixedPrice: BigNumber$1;
20162
- scopeEntryIndex: number;
20162
+ scopeEntryIndex?: number;
20163
20163
  }
20164
20164
  interface BankType {
20165
20165
  address: PublicKey;
@@ -21172,8 +21172,8 @@ declare class BankConfig implements BankConfigType {
21172
21172
  readonly oracleMaxConfidence: number;
21173
21173
  readonly fixedPrice: BigNumber$1;
21174
21174
  readonly configFlags?: BankConfigFlag | undefined;
21175
- readonly scopeEntryIndex: number;
21176
- constructor(assetWeightInit: BigNumber$1, assetWeightMaint: BigNumber$1, liabilityWeightInit: BigNumber$1, liabilityWeightMaint: BigNumber$1, depositLimit: BigNumber$1, borrowLimit: BigNumber$1, riskTier: RiskTier, totalAssetValueInitLimit: BigNumber$1, assetTag: AssetTag, oracleSetup: OracleSetup, oracleKeys: PublicKey[], oracleMaxAge: number, interestRateConfig: InterestRateConfig, operationalState: OperationalState, oracleMaxConfidence: number, fixedPrice: BigNumber$1, configFlags?: BankConfigFlag | undefined, scopeEntryIndex?: number);
21175
+ readonly scopeEntryIndex?: number | undefined;
21176
+ constructor(assetWeightInit: BigNumber$1, assetWeightMaint: BigNumber$1, liabilityWeightInit: BigNumber$1, liabilityWeightMaint: BigNumber$1, depositLimit: BigNumber$1, borrowLimit: BigNumber$1, riskTier: RiskTier, totalAssetValueInitLimit: BigNumber$1, assetTag: AssetTag, oracleSetup: OracleSetup, oracleKeys: PublicKey[], oracleMaxAge: number, interestRateConfig: InterestRateConfig, operationalState: OperationalState, oracleMaxConfidence: number, fixedPrice: BigNumber$1, configFlags?: BankConfigFlag | undefined, scopeEntryIndex?: number | undefined);
21177
21177
  static fromAccountParsed(bankConfigRaw: BankConfigRaw): BankConfig;
21178
21178
  }
21179
21179
 
@@ -20159,7 +20159,7 @@ interface BankConfigType {
20159
20159
  oracleMaxAge: number;
20160
20160
  oracleMaxConfidence: number;
20161
20161
  fixedPrice: BigNumber$1;
20162
- scopeEntryIndex: number;
20162
+ scopeEntryIndex?: number;
20163
20163
  }
20164
20164
  interface BankType {
20165
20165
  address: PublicKey;
@@ -21172,8 +21172,8 @@ declare class BankConfig implements BankConfigType {
21172
21172
  readonly oracleMaxConfidence: number;
21173
21173
  readonly fixedPrice: BigNumber$1;
21174
21174
  readonly configFlags?: BankConfigFlag | undefined;
21175
- readonly scopeEntryIndex: number;
21176
- constructor(assetWeightInit: BigNumber$1, assetWeightMaint: BigNumber$1, liabilityWeightInit: BigNumber$1, liabilityWeightMaint: BigNumber$1, depositLimit: BigNumber$1, borrowLimit: BigNumber$1, riskTier: RiskTier, totalAssetValueInitLimit: BigNumber$1, assetTag: AssetTag, oracleSetup: OracleSetup, oracleKeys: PublicKey[], oracleMaxAge: number, interestRateConfig: InterestRateConfig, operationalState: OperationalState, oracleMaxConfidence: number, fixedPrice: BigNumber$1, configFlags?: BankConfigFlag | undefined, scopeEntryIndex?: number);
21175
+ readonly scopeEntryIndex?: number | undefined;
21176
+ constructor(assetWeightInit: BigNumber$1, assetWeightMaint: BigNumber$1, liabilityWeightInit: BigNumber$1, liabilityWeightMaint: BigNumber$1, depositLimit: BigNumber$1, borrowLimit: BigNumber$1, riskTier: RiskTier, totalAssetValueInitLimit: BigNumber$1, assetTag: AssetTag, oracleSetup: OracleSetup, oracleKeys: PublicKey[], oracleMaxAge: number, interestRateConfig: InterestRateConfig, operationalState: OperationalState, oracleMaxConfidence: number, fixedPrice: BigNumber$1, configFlags?: BankConfigFlag | undefined, scopeEntryIndex?: number | undefined);
21177
21177
  static fromAccountParsed(bankConfigRaw: BankConfigRaw): BankConfig;
21178
21178
  }
21179
21179
 
package/dist/vendor.cjs CHANGED
@@ -3917,6 +3917,9 @@ function decodeScopePriceAtIndex(data, entryIndex) {
3917
3917
  const exp = data.readBigUInt64LE(offset + 8);
3918
3918
  const lastUpdatedSlot = data.readBigUInt64LE(offset + 16);
3919
3919
  const unixTimestamp = data.readBigUInt64LE(offset + 24);
3920
+ if (exp >= 24n) {
3921
+ throw new Error(`Scope entry exponent out of bounds: ${exp}`);
3922
+ }
3920
3923
  const price = new BigNumber3__default.default(value.toString()).shiftedBy(-Number(exp));
3921
3924
  return {
3922
3925
  price,
@@ -3925,17 +3928,24 @@ function decodeScopePriceAtIndex(data, entryIndex) {
3925
3928
  };
3926
3929
  }
3927
3930
  var MARINADE_PROGRAM_ID = new web3_js.PublicKey("MarBmsSgKXdrN1egZf5sqe1TMai9K1rChYNDJgjq7aD");
3928
- var MARINADE_STATE_SIZE = 520;
3931
+ var MARINADE_STATE_DISCRIMINATOR = Buffer.from([216, 146, 107, 94, 104, 75, 182, 177]);
3932
+ var MARINADE_STATE_MIN_SIZE = 520;
3929
3933
  var MSOL_PRICE_OFFSET = 512;
3930
3934
  var MSOL_PRICE_PRECISION = new BigNumber3__default.default(2).pow(32);
3935
+ var MAX_MSOL_SOL_RATE = 200;
3931
3936
  function decodeMarinadeState(data) {
3932
- if (data.length !== MARINADE_STATE_SIZE) {
3937
+ if (data.length < MARINADE_STATE_MIN_SIZE) {
3933
3938
  throw new Error(`Invalid Marinade State account size: ${data.length}`);
3934
3939
  }
3940
+ if (!data.subarray(0, 8).equals(MARINADE_STATE_DISCRIMINATOR)) {
3941
+ throw new Error("Invalid Marinade State discriminator");
3942
+ }
3935
3943
  const msolPriceRaw = data.readBigUInt64LE(MSOL_PRICE_OFFSET);
3936
- return {
3937
- msolPrice: new BigNumber3__default.default(msolPriceRaw.toString()).div(MSOL_PRICE_PRECISION)
3938
- };
3944
+ const msolPrice = new BigNumber3__default.default(msolPriceRaw.toString()).div(MSOL_PRICE_PRECISION);
3945
+ if (!msolPrice.gt(0) || msolPrice.gte(MAX_MSOL_SOL_RATE)) {
3946
+ throw new Error(`Marinade mSOL/SOL rate out of bounds: ${msolPrice.toString()}`);
3947
+ }
3948
+ return { msolPrice };
3939
3949
  }
3940
3950
  var SPL_STAKE_POOL_PROGRAM_ID = new web3_js.PublicKey(
3941
3951
  "SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy"
@@ -3950,6 +3960,7 @@ var ACCOUNT_TYPE_STAKE_POOL = 1;
3950
3960
  var TOTAL_LAMPORTS_OFFSET = 258;
3951
3961
  var POOL_TOKEN_SUPPLY_OFFSET = 266;
3952
3962
  var LAST_UPDATE_EPOCH_OFFSET = 274;
3963
+ var MAX_LST_SOL_RATE = 200;
3953
3964
  function decodeStakePool(data) {
3954
3965
  if (data.length < LAST_UPDATE_EPOCH_OFFSET + 8) {
3955
3966
  throw new Error(`Invalid StakePool account size: ${data.length}`);
@@ -3963,13 +3974,17 @@ function decodeStakePool(data) {
3963
3974
  if (poolTokenSupply === 0n) {
3964
3975
  throw new Error("StakePool has zero token supply");
3965
3976
  }
3977
+ const exchangeRate = new BigNumber3__default.default(totalLamports.toString()).div(
3978
+ new BigNumber3__default.default(poolTokenSupply.toString())
3979
+ );
3980
+ if (!exchangeRate.gt(0) || exchangeRate.gte(MAX_LST_SOL_RATE)) {
3981
+ throw new Error(`StakePool LST/SOL rate out of bounds: ${exchangeRate.toString()}`);
3982
+ }
3966
3983
  return {
3967
3984
  totalLamports,
3968
3985
  poolTokenSupply,
3969
3986
  lastUpdateEpoch,
3970
- exchangeRate: new BigNumber3__default.default(totalLamports.toString()).div(
3971
- new BigNumber3__default.default(poolTokenSupply.toString())
3972
- )
3987
+ exchangeRate
3973
3988
  };
3974
3989
  }
3975
3990
  var KLEND_PROGRAM_ID = new web3_js.PublicKey(
@@ -52706,7 +52721,8 @@ exports.KLEND_PROGRAM_ID = KLEND_PROGRAM_ID;
52706
52721
  exports.KaminoInterestRateBasis = KaminoInterestRateBasis;
52707
52722
  exports.LENGTH_SIZE = LENGTH_SIZE;
52708
52723
  exports.MARINADE_PROGRAM_ID = MARINADE_PROGRAM_ID;
52709
- exports.MARINADE_STATE_SIZE = MARINADE_STATE_SIZE;
52724
+ exports.MARINADE_STATE_DISCRIMINATOR = MARINADE_STATE_DISCRIMINATOR;
52725
+ exports.MARINADE_STATE_MIN_SIZE = MARINADE_STATE_MIN_SIZE;
52710
52726
  exports.MAX_SLOT_DIFFERENCE = MAX_SLOT_DIFFERENCE;
52711
52727
  exports.MEMO_PROGRAM_ID = MEMO_PROGRAM_ID;
52712
52728
  exports.MINT_SIZE = MINT_SIZE;