@0dotxyz/p0-ts-sdk 2.11.0 → 2.12.0

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
@@ -74139,6 +74139,8 @@ function deriveGammaAta(mint, owner, tokenProgram = TOKEN_PROGRAM_ID) {
74139
74139
  var GAMMA_ACCOUNTS_CODER = new anchor.BorshAccountsCoder(GAMMA_VAULT_IDL);
74140
74140
  var lpVaultDiscriminator = Buffer.from([189, 45, 167, 23, 91, 118, 105, 190]);
74141
74141
  var withdrawReceiptDiscriminator = Buffer.from([132, 238, 44, 182, 207, 9, 124, 140]);
74142
+ var depositPolicyDiscriminator = Buffer.from([159, 243, 65, 242, 81, 27, 41, 167]);
74143
+ var withdrawalPolicyDiscriminator = Buffer.from([52, 231, 68, 59, 247, 250, 119, 244]);
74142
74144
  var toBN = (v) => BN8__default.default.isBN(v) ? v : new BN8__default.default((v ?? 0).toString());
74143
74145
  function decodeGammaLpVaultData(data, pubkey) {
74144
74146
  if (!data.subarray(0, 8).equals(lpVaultDiscriminator)) {
@@ -74185,6 +74187,37 @@ function decodeGammaWithdrawReceiptData(data, pubkey) {
74185
74187
  bump: d.bump
74186
74188
  };
74187
74189
  }
74190
+ function decodeGammaDepositPolicyData(data, pubkey) {
74191
+ if (!data.subarray(0, 8).equals(depositPolicyDiscriminator)) {
74192
+ throw new Error("invalid Gamma DepositPolicy account discriminator");
74193
+ }
74194
+ const d = GAMMA_ACCOUNTS_CODER.decode("DepositPolicy", data);
74195
+ return {
74196
+ pubkey,
74197
+ lpVault: d.lp_vault ?? d.lpVault,
74198
+ capacityAssets: toBN(d.capacity_assets ?? d.capacityAssets),
74199
+ depositsPaused: d.deposits_paused ?? d.depositsPaused,
74200
+ bump: d.bump
74201
+ };
74202
+ }
74203
+ function decodeGammaWithdrawalPolicyData(data, pubkey) {
74204
+ if (!data.subarray(0, 8).equals(withdrawalPolicyDiscriminator)) {
74205
+ throw new Error("invalid Gamma WithdrawalPolicy account discriminator");
74206
+ }
74207
+ const d = GAMMA_ACCOUNTS_CODER.decode("WithdrawalPolicy", data);
74208
+ return {
74209
+ pubkey,
74210
+ lpVault: d.lp_vault ?? d.lpVault,
74211
+ withdrawalFeeBps: d.withdrawal_fee_bps ?? d.withdrawalFeeBps,
74212
+ hourlyWithdrawalCapBps: d.hourly_withdrawal_cap_bps ?? d.hourlyWithdrawalCapBps,
74213
+ dailyWithdrawalCapBps: d.daily_withdrawal_cap_bps ?? d.dailyWithdrawalCapBps,
74214
+ hourlyWithdrawnAssets: toBN(d.hourly_withdrawn_assets ?? d.hourlyWithdrawnAssets),
74215
+ dailyWithdrawnAssets: toBN(d.daily_withdrawn_assets ?? d.dailyWithdrawnAssets),
74216
+ hourlyWindowStart: toBN(d.hourly_window_start ?? d.hourlyWindowStart),
74217
+ dailyWindowStart: toBN(d.daily_window_start ?? d.dailyWindowStart),
74218
+ bump: d.bump
74219
+ };
74220
+ }
74188
74221
  var DEPOSIT_DISCRIMINATOR = Buffer.from([242, 35, 198, 137, 82, 225, 242, 182]);
74189
74222
  var WITHDRAW_DISCRIMINATOR = Buffer.from([183, 18, 70, 156, 148, 109, 161, 34]);
74190
74223
  var COMPLETE_WITHDRAWAL_DISCRIMINATOR = Buffer.from([107, 98, 134, 131, 74, 120, 174, 121]);
@@ -86185,9 +86218,16 @@ async function simulateAccountHealthCacheWithFallback(params) {
86185
86218
  marginfiAccount,
86186
86219
  bankIntegrationMap
86187
86220
  });
86188
- simulatedAccount.healthCache.assetValueEquity = bigNumberToWrappedI80F48(assetValueEquity);
86189
- simulatedAccount.healthCache.liabilityValueEquity = bigNumberToWrappedI80F48(liabilityValueEquity);
86190
- marginfiAccount = parseMarginfiAccountRaw(params.marginfiAccount.address, simulatedAccount);
86221
+ const simulated = parseMarginfiAccountRaw(params.marginfiAccount.address, simulatedAccount);
86222
+ marginfiAccount = {
86223
+ ...simulated,
86224
+ healthCache: {
86225
+ ...simulated.healthCache,
86226
+ assetValueEquity,
86227
+ liabilityValueEquity,
86228
+ simulationStatus: 1 /* ONCHAIN */
86229
+ }
86230
+ };
86191
86231
  } catch (e) {
86192
86232
  console.log("e", e);
86193
86233
  const { assets: assetValueMaint, liabilities: liabilityValueMaint } = computeHealthComponentsFromBalances({
@@ -87501,6 +87541,18 @@ async function fetchGammaWithdrawReceipt(connection, user, lpVault) {
87501
87541
  if (!info) return null;
87502
87542
  return decodeGammaWithdrawReceiptData(info.data, receipt);
87503
87543
  }
87544
+ async function fetchGammaDepositPolicy(connection, lpVault) {
87545
+ const [policy] = deriveGammaDepositPolicy(lpVault);
87546
+ const info = await connection.getAccountInfo(policy);
87547
+ if (!info) return null;
87548
+ return decodeGammaDepositPolicyData(info.data, policy);
87549
+ }
87550
+ async function fetchGammaWithdrawalPolicy(connection, lpVault) {
87551
+ const [policy] = deriveGammaWithdrawalPolicy(lpVault);
87552
+ const info = await connection.getAccountInfo(policy);
87553
+ if (!info) return null;
87554
+ return decodeGammaWithdrawalPolicyData(info.data, policy);
87555
+ }
87504
87556
  async function resolveVaultTokenProgram(connection, assetsMint) {
87505
87557
  const info = await connection.getAccountInfo(assetsMint);
87506
87558
  if (info && info.owner.equals(TOKEN_2022_PROGRAM_ID)) {
@@ -90117,8 +90169,10 @@ exports.exceedsCostlyPositionLimit = exceedsCostlyPositionLimit;
90117
90169
  exports.extractPythOracleKeys = extractPythOracleKeys;
90118
90170
  exports.fetchBank = fetchBank;
90119
90171
  exports.fetchBankIntegrationMetadata = fetchBankIntegrationMetadata;
90172
+ exports.fetchGammaDepositPolicy = fetchGammaDepositPolicy;
90120
90173
  exports.fetchGammaLpVault = fetchGammaLpVault;
90121
90174
  exports.fetchGammaWithdrawReceipt = fetchGammaWithdrawReceipt;
90175
+ exports.fetchGammaWithdrawalPolicy = fetchGammaWithdrawalPolicy;
90122
90176
  exports.fetchMarginfiAccountActiveBalancesForBank = fetchMarginfiAccountActiveBalancesForBank;
90123
90177
  exports.fetchMarginfiAccountAddresses = fetchMarginfiAccountAddresses;
90124
90178
  exports.fetchMarginfiAccountAddressesHoldingBank = fetchMarginfiAccountAddressesHoldingBank;