@0dotxyz/p0-ts-sdk 3.0.0-next.1 → 3.0.0-next.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.
package/dist/index.cjs CHANGED
@@ -18243,7 +18243,6 @@ function deserializeJupiterInstruction(instruction) {
18243
18243
  function toJupiterConfig(apiConfig) {
18244
18244
  if (!apiConfig) return void 0;
18245
18245
  return {
18246
- basePath: apiConfig.basePath,
18247
18246
  apiKey: apiConfig.apiKey,
18248
18247
  headers: apiConfig.headers
18249
18248
  };
@@ -20191,14 +20190,16 @@ async function simulateAccountHealthCacheWithFallback(params) {
20191
20190
  marginfiAccount,
20192
20191
  bankIntegrationMap
20193
20192
  });
20194
- marginfiAccount = parseMarginfiAccountRaw(params.marginfiAccount.address, {
20195
- ...simulatedAccount,
20193
+ const simulated = parseMarginfiAccountRaw(params.marginfiAccount.address, simulatedAccount);
20194
+ marginfiAccount = {
20195
+ ...simulated,
20196
20196
  healthCache: {
20197
- ...simulatedAccount.healthCache,
20198
- assetValueEquity: bigNumberToWrappedI80F48(assetValueEquity),
20199
- liabilityValueEquity: bigNumberToWrappedI80F48(liabilityValueEquity)
20197
+ ...simulated.healthCache,
20198
+ assetValueEquity,
20199
+ liabilityValueEquity,
20200
+ simulationStatus: 1 /* ONCHAIN */
20200
20201
  }
20201
- });
20202
+ };
20202
20203
  } catch (e) {
20203
20204
  const { assets: assetValueMaint, liabilities: liabilityValueMaint } = computeHealthComponentsFromBalances({
20204
20205
  activeBalances,
@@ -23004,6 +23005,25 @@ async function makeMergeStakeAccountsTx({
23004
23005
  type: "MERGE_STAKE_ACCOUNTS" /* MERGE_STAKE_ACCOUNTS */
23005
23006
  };
23006
23007
  }
23008
+ var DEPOSIT_POLICY_DISCRIMINATOR = new Uint8Array([
23009
+ 159,
23010
+ 243,
23011
+ 65,
23012
+ 242,
23013
+ 81,
23014
+ 27,
23015
+ 41,
23016
+ 167
23017
+ ]);
23018
+ function getDepositPolicyDecoder() {
23019
+ return kit.getStructDecoder([
23020
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
23021
+ ["lpVault", kit.getAddressDecoder()],
23022
+ ["capacityAssets", kit.getU64Decoder()],
23023
+ ["depositsPaused", kit.getBooleanDecoder()],
23024
+ ["bump", kit.getU8Decoder()]
23025
+ ]);
23026
+ }
23007
23027
  var LP_VAULT_DISCRIMINATOR = new Uint8Array([
23008
23028
  189,
23009
23029
  45,
@@ -23037,6 +23057,30 @@ function getLpVaultDecoder() {
23037
23057
  ["keeperAuthority", kit.getAddressDecoder()]
23038
23058
  ]);
23039
23059
  }
23060
+ var WITHDRAWAL_POLICY_DISCRIMINATOR = new Uint8Array([
23061
+ 52,
23062
+ 231,
23063
+ 68,
23064
+ 59,
23065
+ 247,
23066
+ 250,
23067
+ 119,
23068
+ 244
23069
+ ]);
23070
+ function getWithdrawalPolicyDecoder() {
23071
+ return kit.getStructDecoder([
23072
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
23073
+ ["lpVault", kit.getAddressDecoder()],
23074
+ ["withdrawalFeeBps", kit.getU16Decoder()],
23075
+ ["hourlyWithdrawalCapBps", kit.getU16Decoder()],
23076
+ ["dailyWithdrawalCapBps", kit.getU16Decoder()],
23077
+ ["hourlyWithdrawnAssets", kit.getU64Decoder()],
23078
+ ["dailyWithdrawnAssets", kit.getU64Decoder()],
23079
+ ["hourlyWindowStart", kit.getI64Decoder()],
23080
+ ["dailyWindowStart", kit.getI64Decoder()],
23081
+ ["bump", kit.getU8Decoder()]
23082
+ ]);
23083
+ }
23040
23084
  var WITHDRAW_RECEIPT_DISCRIMINATOR = new Uint8Array([
23041
23085
  132,
23042
23086
  238,
@@ -23608,6 +23652,28 @@ function decodeGammaWithdrawReceipt(data) {
23608
23652
  "Gamma WithdrawReceipt"
23609
23653
  );
23610
23654
  }
23655
+ function decodeGammaDepositPolicy(data) {
23656
+ return decodeAccountData(
23657
+ data,
23658
+ DEPOSIT_POLICY_DISCRIMINATOR,
23659
+ getDepositPolicyDecoder(),
23660
+ "Gamma DepositPolicy"
23661
+ );
23662
+ }
23663
+ function decodeGammaWithdrawalPolicy(data) {
23664
+ return decodeAccountData(
23665
+ data,
23666
+ WITHDRAWAL_POLICY_DISCRIMINATOR,
23667
+ getWithdrawalPolicyDecoder(),
23668
+ "Gamma WithdrawalPolicy"
23669
+ );
23670
+ }
23671
+ function deriveGammaDepositPolicy(lpVault) {
23672
+ return findDepositPolicyPda({ lpVault });
23673
+ }
23674
+ function deriveGammaWithdrawalPolicy(lpVault) {
23675
+ return findWithdrawalPolicyPda({ lpVault });
23676
+ }
23611
23677
  function deriveGammaWithdrawReceipt(user, lpVault) {
23612
23678
  return findWithdrawReceiptPda({ crossChainWithdrawer: user, lpVault });
23613
23679
  }
@@ -23626,6 +23692,16 @@ async function fetchGammaWithdrawReceipt(rpc, user, lpVault) {
23626
23692
  const account = await kit.fetchEncodedAccount(rpc, receipt);
23627
23693
  return account.exists ? decodeGammaWithdrawReceipt(account.data) : null;
23628
23694
  }
23695
+ async function fetchGammaDepositPolicy(rpc, lpVault) {
23696
+ const [policy] = await deriveGammaDepositPolicy(lpVault);
23697
+ const account = await kit.fetchEncodedAccount(rpc, policy);
23698
+ return account.exists ? decodeGammaDepositPolicy(account.data) : null;
23699
+ }
23700
+ async function fetchGammaWithdrawalPolicy(rpc, lpVault) {
23701
+ const [policy] = await deriveGammaWithdrawalPolicy(lpVault);
23702
+ const account = await kit.fetchEncodedAccount(rpc, policy);
23703
+ return account.exists ? decodeGammaWithdrawalPolicy(account.data) : null;
23704
+ }
23629
23705
  async function resolveVaultTokenProgram(rpc, assetsMint) {
23630
23706
  const account = await kit.fetchEncodedAccount(rpc, assetsMint);
23631
23707
  return account.exists && account.programAddress === TOKEN_2022_PROGRAM_ID ? TOKEN_2022_PROGRAM_ID : token.TOKEN_PROGRAM_ADDRESS;
@@ -24696,7 +24772,7 @@ var MarginfiAccountWrapper = class {
24696
24772
  }
24697
24773
  /**
24698
24774
  * Withdraw instructions for `amount` (UI units) from `bankAddress`; `withdrawAll` closes the
24699
- * balance.
24775
+ * balance. `opts.groupRateLimiterEnabled` defaults to the group's limiter state.
24700
24776
  * @throws Error if `amount` isn't positive without `withdrawAll`
24701
24777
  */
24702
24778
  async makeWithdrawIx(bankAddress, amount, withdrawAll = false, opts = {}) {
@@ -24707,7 +24783,10 @@ var MarginfiAccountWrapper = class {
24707
24783
  ...await this.lendingContext(bankAddress),
24708
24784
  amount,
24709
24785
  withdrawAll,
24710
- opts
24786
+ opts: {
24787
+ groupRateLimiterEnabled: isGroupRateLimiterEnabled(this.client.group.rateLimiter),
24788
+ ...opts
24789
+ }
24711
24790
  });
24712
24791
  }
24713
24792
  /**
@@ -24737,14 +24816,17 @@ var MarginfiAccountWrapper = class {
24737
24816
  }
24738
24817
  /**
24739
24818
  * Withdraw transaction for `amount` (UI units) from `bankAddress`; `withdrawAll` closes the
24740
- * balance.
24819
+ * balance. `opts.groupRateLimiterEnabled` defaults to the group's limiter state.
24741
24820
  */
24742
24821
  async makeWithdrawTx(bankAddress, amount, withdrawAll = false, opts = {}) {
24743
24822
  return this.account.makeWithdrawTx({
24744
24823
  ...await this.lendingContext(bankAddress),
24745
24824
  amount,
24746
24825
  withdrawAll,
24747
- opts
24826
+ opts: {
24827
+ groupRateLimiterEnabled: isGroupRateLimiterEnabled(this.client.group.rateLimiter),
24828
+ ...opts
24829
+ }
24748
24830
  });
24749
24831
  }
24750
24832
  /** Borrow transaction for `amount` (UI units) from `bankAddress`. */
@@ -25569,8 +25651,10 @@ exports.exceedsCostlyPositionLimit = exceedsCostlyPositionLimit;
25569
25651
  exports.extractPythOracleKeys = extractPythOracleKeys;
25570
25652
  exports.fetchBank = fetchBank;
25571
25653
  exports.fetchBankIntegrationMetadata = fetchBankIntegrationMetadata;
25654
+ exports.fetchGammaDepositPolicy = fetchGammaDepositPolicy;
25572
25655
  exports.fetchGammaLpVault = fetchGammaLpVault;
25573
25656
  exports.fetchGammaWithdrawReceipt = fetchGammaWithdrawReceipt;
25657
+ exports.fetchGammaWithdrawalPolicy = fetchGammaWithdrawalPolicy;
25574
25658
  exports.fetchGlobalFeeWallet = fetchGlobalFeeWallet;
25575
25659
  exports.fetchMarginfiAccountActiveBalancesForBank = fetchMarginfiAccountActiveBalancesForBank;
25576
25660
  exports.fetchMarginfiAccountAddresses = fetchMarginfiAccountAddresses;