@0dotxyz/p0-ts-sdk 3.0.0-next.2 → 3.0.1-alpha.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.
@@ -552,14 +552,40 @@ interface JupLendStatesJSON {
552
552
  fTokenTotalSupply: string;
553
553
  }
554
554
 
555
- /** Curated Gamma `LpVault`: the fields the SDK reads. A decoded `LpVault` satisfies it structurally. */
555
+ /**
556
+ * Curated Gamma `LpVault`: the fields the SDK and its consumers read (accounts for building, NAV and
557
+ * share supply for the share price, staleness for whether deposits/withdrawals can run). A decoded
558
+ * `LpVault` satisfies it structurally.
559
+ */
556
560
  interface GammaLpVault {
557
561
  /** Token account holding the vault's deposited assets. */
558
562
  assetsAccount: Address;
563
+ /** Share token account holding shares during queued (illiquid) withdrawals. */
564
+ pendingSharesAccount: Address;
559
565
  sharesMint: Address;
560
566
  assetsMint: Address;
561
567
  /** Share token account receiving fee shares; the default address when fees are off. */
562
568
  feeRecipient: Address;
569
+ /** Current net asset value: total vault value in asset mint base units. */
570
+ nav: bigint;
571
+ /**
572
+ * Total shares outstanding, in share mint base units. May briefly differ from the share mint's
573
+ * supply between a withdrawal's fulfillment and its claim. Share price = `nav / totalShares`.
574
+ */
575
+ totalShares: bigint;
576
+ /** Unix timestamp (seconds) of the last NAV update. */
577
+ navUpdatedAt: bigint;
578
+ /** Max NAV age in seconds for user operations: deposits and withdrawals fail past it. */
579
+ navMaxStaleness: bigint;
580
+ /**
581
+ * Approximate value of withdrawals queued for liquidity, in asset mint base units (recorded at
582
+ * withdrawal time; operator visibility only, not for exact math).
583
+ */
584
+ pendingWithdrawalValue: bigint;
585
+ /** Performance fee in basis points (2000 = 20%); 0 = disabled. */
586
+ performanceFeeBps: number;
587
+ /** On-chain vault name, e.g. `p0STBL1`. */
588
+ vaultName: string;
563
589
  }
564
590
  /**
565
591
  * Curated Gamma `WithdrawReceipt`: a user's queued withdrawal (pending until a keeper fulfills it)
@@ -575,5 +601,37 @@ interface GammaWithdrawReceipt {
575
601
  /** Asset mint base units ready to claim. */
576
602
  claimableAssets: bigint;
577
603
  }
604
+ /**
605
+ * Curated Gamma `DepositPolicy`: the vault's deposit cap and pause switch. One per vault, PDA
606
+ * `["deposit_policy", lpVault]`.
607
+ */
608
+ interface GammaDepositPolicy {
609
+ lpVault: Address;
610
+ /** Max post-deposit NAV in asset mint base units. */
611
+ capacityAssets: bigint;
612
+ /** When true the program rejects every deposit (withdrawals don't consult it). */
613
+ depositsPaused: boolean;
614
+ }
615
+ /**
616
+ * Curated Gamma `WithdrawalPolicy`: the vault's withdrawal fee and rolling hourly/daily withdrawal
617
+ * caps. One per vault, PDA `["withdrawal_policy", lpVault]`.
618
+ */
619
+ interface GammaWithdrawalPolicy {
620
+ lpVault: Address;
621
+ /** Fee on withdrawn assets, retained in the vault, in basis points (10 = 0.1%). */
622
+ withdrawalFeeBps: number;
623
+ /** Max net withdrawal per hourly window as basis points of current NAV; 0 = disabled. */
624
+ hourlyWithdrawalCapBps: number;
625
+ /** Max net withdrawal per daily window as basis points of current NAV; 0 = disabled. */
626
+ dailyWithdrawalCapBps: number;
627
+ /** Net withdrawn assets counted in the current hourly window, in asset mint base units. */
628
+ hourlyWithdrawnAssets: bigint;
629
+ /** Net withdrawn assets counted in the current daily window, in asset mint base units. */
630
+ dailyWithdrawnAssets: bigint;
631
+ /** Unix timestamp (seconds) the current hourly window started. */
632
+ hourlyWindowStart: bigint;
633
+ /** Unix timestamp (seconds) the current daily window started. */
634
+ dailyWindowStart: bigint;
635
+ }
578
636
 
579
- export { type JupLendingStateJSON as A, type JupTokenReserveJSON as B, type JupLendingRewardsRateModelJSON as C, type DriftSpotMarket as D, type JupRateModelJSON as E, type JupLendBankInput as F, type GammaLpVault as G, type JupLendStatesJSON as H, type KaminoReserveLiquidity as I, type JupTokenReserve as J, type KaminoReserve as K, type KaminoReserveCollateral as L, type KaminoReserveConfig as M, type KaminoReserveTokenInfo as N, type KaminoObligationCollateral as O, type KaminoObligationLiquidity as P, type KaminoFarmTokenInfo as Q, type KaminoRewardCurvePoint as R, SpotBalanceType as S, type DriftSpotPosition as T, type DriftUserFees as U, type DriftSpotPositionJSON as V, type GammaWithdrawReceipt as a, type KaminoStates as b, type DriftStates as c, type JupLendStates as d, type KaminoObligation as e, type KaminoFarmState as f, KaminoInterestRateBasis as g, type KaminoBorrowRateCurvePoint as h, type KaminoFarmRewardInfo as i, type KaminoObligationJSON as j, type KaminoReserveJSON as k, type KaminoFarmStateJSON as l, type KaminoBankInput as m, type KaminoStatesJSON as n, type DriftUser as o, type DriftUserStats as p, type DriftRewards as q, type DriftSpotMarketJSON as r, type DriftUserJSON as s, type DriftRewardsJSON as t, type DriftUserStatsJSON as u, type DriftBankInput as v, type DriftStatesJSON as w, type JupLendingState as x, type JupRateModel as y, type JupLendingRewardsRateModel as z };
637
+ export { type JupRateModel as A, type JupLendingRewardsRateModel as B, type JupLendingStateJSON as C, type DriftSpotMarket as D, type JupTokenReserveJSON as E, type JupLendingRewardsRateModelJSON as F, type GammaLpVault as G, type JupRateModelJSON as H, type JupLendBankInput as I, type JupTokenReserve as J, type KaminoReserve as K, type JupLendStatesJSON as L, type KaminoReserveLiquidity as M, type KaminoReserveCollateral as N, type KaminoReserveConfig as O, type KaminoReserveTokenInfo as P, type KaminoObligationCollateral as Q, type KaminoObligationLiquidity as R, SpotBalanceType as S, type KaminoFarmTokenInfo as T, type KaminoRewardCurvePoint as U, type DriftSpotPosition as V, type DriftUserFees as W, type DriftSpotPositionJSON as X, type GammaWithdrawReceipt as a, type GammaDepositPolicy as b, type GammaWithdrawalPolicy as c, type KaminoStates as d, type DriftStates as e, type JupLendStates as f, type KaminoObligation as g, type KaminoFarmState as h, KaminoInterestRateBasis as i, type KaminoBorrowRateCurvePoint as j, type KaminoFarmRewardInfo as k, type KaminoObligationJSON as l, type KaminoReserveJSON as m, type KaminoFarmStateJSON as n, type KaminoBankInput as o, type KaminoStatesJSON as p, type DriftUser as q, type DriftUserStats as r, type DriftRewards as s, type DriftSpotMarketJSON as t, type DriftUserJSON as u, type DriftRewardsJSON as v, type DriftUserStatsJSON as w, type DriftBankInput as x, type DriftStatesJSON as y, type JupLendingState as z };
@@ -552,14 +552,40 @@ interface JupLendStatesJSON {
552
552
  fTokenTotalSupply: string;
553
553
  }
554
554
 
555
- /** Curated Gamma `LpVault`: the fields the SDK reads. A decoded `LpVault` satisfies it structurally. */
555
+ /**
556
+ * Curated Gamma `LpVault`: the fields the SDK and its consumers read (accounts for building, NAV and
557
+ * share supply for the share price, staleness for whether deposits/withdrawals can run). A decoded
558
+ * `LpVault` satisfies it structurally.
559
+ */
556
560
  interface GammaLpVault {
557
561
  /** Token account holding the vault's deposited assets. */
558
562
  assetsAccount: Address;
563
+ /** Share token account holding shares during queued (illiquid) withdrawals. */
564
+ pendingSharesAccount: Address;
559
565
  sharesMint: Address;
560
566
  assetsMint: Address;
561
567
  /** Share token account receiving fee shares; the default address when fees are off. */
562
568
  feeRecipient: Address;
569
+ /** Current net asset value: total vault value in asset mint base units. */
570
+ nav: bigint;
571
+ /**
572
+ * Total shares outstanding, in share mint base units. May briefly differ from the share mint's
573
+ * supply between a withdrawal's fulfillment and its claim. Share price = `nav / totalShares`.
574
+ */
575
+ totalShares: bigint;
576
+ /** Unix timestamp (seconds) of the last NAV update. */
577
+ navUpdatedAt: bigint;
578
+ /** Max NAV age in seconds for user operations: deposits and withdrawals fail past it. */
579
+ navMaxStaleness: bigint;
580
+ /**
581
+ * Approximate value of withdrawals queued for liquidity, in asset mint base units (recorded at
582
+ * withdrawal time; operator visibility only, not for exact math).
583
+ */
584
+ pendingWithdrawalValue: bigint;
585
+ /** Performance fee in basis points (2000 = 20%); 0 = disabled. */
586
+ performanceFeeBps: number;
587
+ /** On-chain vault name, e.g. `p0STBL1`. */
588
+ vaultName: string;
563
589
  }
564
590
  /**
565
591
  * Curated Gamma `WithdrawReceipt`: a user's queued withdrawal (pending until a keeper fulfills it)
@@ -575,5 +601,37 @@ interface GammaWithdrawReceipt {
575
601
  /** Asset mint base units ready to claim. */
576
602
  claimableAssets: bigint;
577
603
  }
604
+ /**
605
+ * Curated Gamma `DepositPolicy`: the vault's deposit cap and pause switch. One per vault, PDA
606
+ * `["deposit_policy", lpVault]`.
607
+ */
608
+ interface GammaDepositPolicy {
609
+ lpVault: Address;
610
+ /** Max post-deposit NAV in asset mint base units. */
611
+ capacityAssets: bigint;
612
+ /** When true the program rejects every deposit (withdrawals don't consult it). */
613
+ depositsPaused: boolean;
614
+ }
615
+ /**
616
+ * Curated Gamma `WithdrawalPolicy`: the vault's withdrawal fee and rolling hourly/daily withdrawal
617
+ * caps. One per vault, PDA `["withdrawal_policy", lpVault]`.
618
+ */
619
+ interface GammaWithdrawalPolicy {
620
+ lpVault: Address;
621
+ /** Fee on withdrawn assets, retained in the vault, in basis points (10 = 0.1%). */
622
+ withdrawalFeeBps: number;
623
+ /** Max net withdrawal per hourly window as basis points of current NAV; 0 = disabled. */
624
+ hourlyWithdrawalCapBps: number;
625
+ /** Max net withdrawal per daily window as basis points of current NAV; 0 = disabled. */
626
+ dailyWithdrawalCapBps: number;
627
+ /** Net withdrawn assets counted in the current hourly window, in asset mint base units. */
628
+ hourlyWithdrawnAssets: bigint;
629
+ /** Net withdrawn assets counted in the current daily window, in asset mint base units. */
630
+ dailyWithdrawnAssets: bigint;
631
+ /** Unix timestamp (seconds) the current hourly window started. */
632
+ hourlyWindowStart: bigint;
633
+ /** Unix timestamp (seconds) the current daily window started. */
634
+ dailyWindowStart: bigint;
635
+ }
578
636
 
579
- export { type JupLendingStateJSON as A, type JupTokenReserveJSON as B, type JupLendingRewardsRateModelJSON as C, type DriftSpotMarket as D, type JupRateModelJSON as E, type JupLendBankInput as F, type GammaLpVault as G, type JupLendStatesJSON as H, type KaminoReserveLiquidity as I, type JupTokenReserve as J, type KaminoReserve as K, type KaminoReserveCollateral as L, type KaminoReserveConfig as M, type KaminoReserveTokenInfo as N, type KaminoObligationCollateral as O, type KaminoObligationLiquidity as P, type KaminoFarmTokenInfo as Q, type KaminoRewardCurvePoint as R, SpotBalanceType as S, type DriftSpotPosition as T, type DriftUserFees as U, type DriftSpotPositionJSON as V, type GammaWithdrawReceipt as a, type KaminoStates as b, type DriftStates as c, type JupLendStates as d, type KaminoObligation as e, type KaminoFarmState as f, KaminoInterestRateBasis as g, type KaminoBorrowRateCurvePoint as h, type KaminoFarmRewardInfo as i, type KaminoObligationJSON as j, type KaminoReserveJSON as k, type KaminoFarmStateJSON as l, type KaminoBankInput as m, type KaminoStatesJSON as n, type DriftUser as o, type DriftUserStats as p, type DriftRewards as q, type DriftSpotMarketJSON as r, type DriftUserJSON as s, type DriftRewardsJSON as t, type DriftUserStatsJSON as u, type DriftBankInput as v, type DriftStatesJSON as w, type JupLendingState as x, type JupRateModel as y, type JupLendingRewardsRateModel as z };
637
+ export { type JupRateModel as A, type JupLendingRewardsRateModel as B, type JupLendingStateJSON as C, type DriftSpotMarket as D, type JupTokenReserveJSON as E, type JupLendingRewardsRateModelJSON as F, type GammaLpVault as G, type JupRateModelJSON as H, type JupLendBankInput as I, type JupTokenReserve as J, type KaminoReserve as K, type JupLendStatesJSON as L, type KaminoReserveLiquidity as M, type KaminoReserveCollateral as N, type KaminoReserveConfig as O, type KaminoReserveTokenInfo as P, type KaminoObligationCollateral as Q, type KaminoObligationLiquidity as R, SpotBalanceType as S, type KaminoFarmTokenInfo as T, type KaminoRewardCurvePoint as U, type DriftSpotPosition as V, type DriftUserFees as W, type DriftSpotPositionJSON as X, type GammaWithdrawReceipt as a, type GammaDepositPolicy as b, type GammaWithdrawalPolicy as c, type KaminoStates as d, type DriftStates as e, type JupLendStates as f, type KaminoObligation as g, type KaminoFarmState as h, KaminoInterestRateBasis as i, type KaminoBorrowRateCurvePoint as j, type KaminoFarmRewardInfo as k, type KaminoObligationJSON as l, type KaminoReserveJSON as m, type KaminoFarmStateJSON as n, type KaminoBankInput as o, type KaminoStatesJSON as p, type DriftUser as q, type DriftUserStats as r, type DriftRewards as s, type DriftSpotMarketJSON as t, type DriftUserJSON as u, type DriftRewardsJSON as v, type DriftUserStatsJSON as w, type DriftBankInput as x, type DriftStatesJSON as y, type JupLendingState as z };
package/dist/vendor.cjs CHANGED
@@ -3080,6 +3080,25 @@ async function fetchJupLendStatesDto(rpc, banks) {
3080
3080
  ])
3081
3081
  );
3082
3082
  }
3083
+ var DEPOSIT_POLICY_DISCRIMINATOR = new Uint8Array([
3084
+ 159,
3085
+ 243,
3086
+ 65,
3087
+ 242,
3088
+ 81,
3089
+ 27,
3090
+ 41,
3091
+ 167
3092
+ ]);
3093
+ function getDepositPolicyDecoder() {
3094
+ return kit.getStructDecoder([
3095
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
3096
+ ["lpVault", kit.getAddressDecoder()],
3097
+ ["capacityAssets", kit.getU64Decoder()],
3098
+ ["depositsPaused", kit.getBooleanDecoder()],
3099
+ ["bump", kit.getU8Decoder()]
3100
+ ]);
3101
+ }
3083
3102
  var LP_VAULT_DISCRIMINATOR = new Uint8Array([
3084
3103
  189,
3085
3104
  45,
@@ -3113,6 +3132,30 @@ function getLpVaultDecoder() {
3113
3132
  ["keeperAuthority", kit.getAddressDecoder()]
3114
3133
  ]);
3115
3134
  }
3135
+ var WITHDRAWAL_POLICY_DISCRIMINATOR = new Uint8Array([
3136
+ 52,
3137
+ 231,
3138
+ 68,
3139
+ 59,
3140
+ 247,
3141
+ 250,
3142
+ 119,
3143
+ 244
3144
+ ]);
3145
+ function getWithdrawalPolicyDecoder() {
3146
+ return kit.getStructDecoder([
3147
+ ["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
3148
+ ["lpVault", kit.getAddressDecoder()],
3149
+ ["withdrawalFeeBps", kit.getU16Decoder()],
3150
+ ["hourlyWithdrawalCapBps", kit.getU16Decoder()],
3151
+ ["dailyWithdrawalCapBps", kit.getU16Decoder()],
3152
+ ["hourlyWithdrawnAssets", kit.getU64Decoder()],
3153
+ ["dailyWithdrawnAssets", kit.getU64Decoder()],
3154
+ ["hourlyWindowStart", kit.getI64Decoder()],
3155
+ ["dailyWindowStart", kit.getI64Decoder()],
3156
+ ["bump", kit.getU8Decoder()]
3157
+ ]);
3158
+ }
3116
3159
  var WITHDRAW_RECEIPT_DISCRIMINATOR = new Uint8Array([
3117
3160
  132,
3118
3161
  238,
@@ -3150,6 +3193,52 @@ async function findCompleteWithdrawalWithdrawEscrowPda(seeds, config = {}) {
3150
3193
  ]
3151
3194
  });
3152
3195
  }
3196
+ async function findDepositPolicyPda(seeds, config = {}) {
3197
+ const {
3198
+ programAddress = "GaMmanX9i4jGmqDZZD2tbD6B2v9p21btenPneMXnTczV"
3199
+ } = config;
3200
+ return await kit.getProgramDerivedAddress({
3201
+ programAddress,
3202
+ seeds: [
3203
+ kit.getBytesEncoder().encode(
3204
+ new Uint8Array([100, 101, 112, 111, 115, 105, 116, 95, 112, 111, 108, 105, 99, 121])
3205
+ ),
3206
+ kit.getAddressEncoder().encode(seeds.lpVault)
3207
+ ]
3208
+ });
3209
+ }
3210
+ async function findWithdrawalPolicyPda(seeds, config = {}) {
3211
+ const {
3212
+ programAddress = "GaMmanX9i4jGmqDZZD2tbD6B2v9p21btenPneMXnTczV"
3213
+ } = config;
3214
+ return await kit.getProgramDerivedAddress({
3215
+ programAddress,
3216
+ seeds: [
3217
+ kit.getBytesEncoder().encode(
3218
+ new Uint8Array([
3219
+ 119,
3220
+ 105,
3221
+ 116,
3222
+ 104,
3223
+ 100,
3224
+ 114,
3225
+ 97,
3226
+ 119,
3227
+ 97,
3228
+ 108,
3229
+ 95,
3230
+ 112,
3231
+ 111,
3232
+ 108,
3233
+ 105,
3234
+ 99,
3235
+ 121
3236
+ ])
3237
+ ),
3238
+ kit.getAddressEncoder().encode(seeds.lpVault)
3239
+ ]
3240
+ });
3241
+ }
3153
3242
  async function findWithdrawReceiptPda(seeds, config = {}) {
3154
3243
  const {
3155
3244
  programAddress = "GaMmanX9i4jGmqDZZD2tbD6B2v9p21btenPneMXnTczV"
@@ -3196,6 +3285,28 @@ function decodeGammaWithdrawReceipt(data) {
3196
3285
  "Gamma WithdrawReceipt"
3197
3286
  );
3198
3287
  }
3288
+ function decodeGammaDepositPolicy(data) {
3289
+ return decodeAccountData(
3290
+ data,
3291
+ DEPOSIT_POLICY_DISCRIMINATOR,
3292
+ getDepositPolicyDecoder(),
3293
+ "Gamma DepositPolicy"
3294
+ );
3295
+ }
3296
+ function decodeGammaWithdrawalPolicy(data) {
3297
+ return decodeAccountData(
3298
+ data,
3299
+ WITHDRAWAL_POLICY_DISCRIMINATOR,
3300
+ getWithdrawalPolicyDecoder(),
3301
+ "Gamma WithdrawalPolicy"
3302
+ );
3303
+ }
3304
+ function deriveGammaDepositPolicy(lpVault) {
3305
+ return findDepositPolicyPda({ lpVault });
3306
+ }
3307
+ function deriveGammaWithdrawalPolicy(lpVault) {
3308
+ return findWithdrawalPolicyPda({ lpVault });
3309
+ }
3199
3310
  function deriveGammaWithdrawReceipt(user, lpVault) {
3200
3311
  return findWithdrawReceiptPda({ crossChainWithdrawer: user, lpVault });
3201
3312
  }
@@ -3760,8 +3871,10 @@ exports.calculateUtilizationRatio = calculateUtilizationRatio;
3760
3871
  exports.decodeDriftSpotMarket = decodeDriftSpotMarket;
3761
3872
  exports.decodeDriftUser = decodeDriftUser;
3762
3873
  exports.decodeDriftUserStats = decodeDriftUserStats;
3874
+ exports.decodeGammaDepositPolicy = decodeGammaDepositPolicy;
3763
3875
  exports.decodeGammaLpVault = decodeGammaLpVault;
3764
3876
  exports.decodeGammaWithdrawReceipt = decodeGammaWithdrawReceipt;
3877
+ exports.decodeGammaWithdrawalPolicy = decodeGammaWithdrawalPolicy;
3765
3878
  exports.decodeJupLendingRewardsRateModel = decodeJupLendingRewardsRateModel;
3766
3879
  exports.decodeJupLendingState = decodeJupLendingState;
3767
3880
  exports.decodeJupRateModel = decodeJupRateModel;
@@ -3779,8 +3892,10 @@ exports.deriveDriftState = deriveDriftState;
3779
3892
  exports.deriveDriftUser = deriveDriftUser;
3780
3893
  exports.deriveDriftUserStats = deriveDriftUserStats;
3781
3894
  exports.deriveFeeReceiver = deriveFeeReceiver;
3895
+ exports.deriveGammaDepositPolicy = deriveGammaDepositPolicy;
3782
3896
  exports.deriveGammaWithdrawEscrow = deriveGammaWithdrawEscrow;
3783
3897
  exports.deriveGammaWithdrawReceipt = deriveGammaWithdrawReceipt;
3898
+ exports.deriveGammaWithdrawalPolicy = deriveGammaWithdrawalPolicy;
3784
3899
  exports.deriveJupLendLendingRewardsRateModel = deriveJupLendLendingRewardsRateModel;
3785
3900
  exports.deriveJupLendRateModel = deriveJupLendRateModel;
3786
3901
  exports.deriveLendingMarketAuthority = deriveLendingMarketAuthority;