pub struct Vault {Show 31 fields
pub base_oracle: OracleConfig,
pub total_assets: u64,
pub external_assets: u64,
pub pending_withdrawal_assets: u64,
pub fees_payable: u64,
pub high_watermark: u64,
pub report_epoch: u64,
pub requested_withdrawal_shares: u64,
pub last_update_ts: i64,
pub locked_profit: u64,
pub profit_unlock_start_ts: i64,
pub profit_unlock_end_ts: i64,
pub tag: [u8; 32],
pub admin: [u8; 32],
pub strategist: [u8; 32],
pub swap_authority: [u8; 32],
pub nav_authority: [u8; 32],
pub withdrawal_authority: [u8; 32],
pub base_mint: [u8; 32],
pub share_mint: [u8; 32],
pub treasury: [u8; 32],
pub last_report_hash: [u8; 32],
pub access_merkle_root: [u8; 32],
pub controls: VaultControls,
pub performance_fee_bps: u16,
pub withdrawal_buffer_bps: u16,
pub tag_len: u8,
pub base_decimals: u8,
pub deposit_sub_account: u8,
pub withdraw_sub_account: u8,
pub bump: u8,
/* private fields */
}Fields§
§base_oracle: OracleConfig§total_assets: u64§external_assets: u64§pending_withdrawal_assets: u64§fees_payable: u64§high_watermark: u64§report_epoch: u64§last_update_ts: i64§locked_profit: u64Reported profit still locked from past gain reports; drips out
linearly between the unlock timestamps. Always at most total_assets.
profit_unlock_start_ts: i64§profit_unlock_end_ts: i64§tag: [u8; 32]§admin: [u8; 32]§strategist: [u8; 32]§base_mint: [u8; 32]§treasury: [u8; 32]§last_report_hash: [u8; 32]§access_merkle_root: [u8; 32]§controls: VaultControls§performance_fee_bps: u16§withdrawal_buffer_bps: u16§tag_len: u8§base_decimals: u8§deposit_sub_account: u8§withdraw_sub_account: u8§bump: u8Implementations§
Source§impl Vault
impl Vault
pub const SEED: &'static [u8] = b"vault"
pub const MAX_TAG_LEN: usize = 32
pub const SPACE: usize
pub fn new( tag: &[u8], admin: [u8; 32], strategist: [u8; 32], swap_authority: [u8; 32], nav_authority: [u8; 32], withdrawal_authority: [u8; 32], base_mint: [u8; 32], share_mint: [u8; 32], base_decimals: u8, base_oracle: OracleConfig, deposit_sub_account: u8, withdraw_sub_account: u8, treasury: [u8; 32], performance_fee_bps: u16, withdrawal_buffer_bps: u16, controls: VaultControls, private: bool, access_merkle_root: [u8; 32], bump: u8, ) -> Result<Self, ProgramError>
Sourcepub fn from_account_data(data: &[u8]) -> Result<Self, ProgramError>
pub fn from_account_data(data: &[u8]) -> Result<Self, ProgramError>
Decode a Vault from raw Roshi account data — the wincode Account::Vault
payload (a one-byte tag then the vault).
pub fn validate_config( base_mint: [u8; 32], share_mint: [u8; 32], base_decimals: u8, performance_fee_bps: u16, withdrawal_buffer_bps: u16, ) -> ProgramResult
pub fn pack_tag(tag: &[u8]) -> Result<([u8; 32], u8), ProgramError>
pub fn unpack_tag(tag: &[u8; 32], tag_len: u8) -> Result<&[u8], ProgramError>
pub fn tag_seed(&self) -> Result<&[u8], ProgramError>
pub fn find_address( tag: &[u8], base_mint: &Pubkey, ) -> Result<(Pubkey, u8), ProgramError>
pub fn has_role(&self, role: Role, signer: &Pubkey) -> bool
Sourcepub fn verify_address(&self, vault_key: &Pubkey) -> ProgramResult
pub fn verify_address(&self, vault_key: &Pubkey) -> ProgramResult
Verify vault_key is the canonical PDA for this vault’s tag and base mint.
The economic share supply: circulating shares plus the shares already burned for in-flight withdrawals.
Sourcepub fn remaining_locked_profit(&self, now: i64) -> Result<u64, ProgramError>
pub fn remaining_locked_profit(&self, now: i64) -> Result<u64, ProgramError>
Reported profit still locked at now: the full locked_profit until
the window starts, decaying linearly to zero at the window end.
Sourcepub fn effective_total_assets(&self, now: i64) -> Result<u64, ProgramError>
pub fn effective_total_assets(&self, now: i64) -> Result<u64, ProgramError>
Share-pricing NAV at now: total_assets minus the profit still
dripping. Every pricing read (deposit mint, redeem dust guard, ticket
strike, atomic-redeem entitlement) uses this, never raw total_assets.
Sourcepub fn debit_assets_at_effective(
&mut self,
amount: u64,
now: i64,
) -> ProgramResult
pub fn debit_assets_at_effective( &mut self, amount: u64, now: i64, ) -> ProgramResult
Pay amount (priced at Self::effective_total_assets) out of the
vault at now. Re-anchors the unlock window at now with the
still-locked remainder — the unlock line is preserved up to one atom
of floor rounding, and amount <= effective keeps the static
locked_profit <= total_assets invariant true after the debit.
Recognize a report’s post-fee NAV at now. A gain re-locks in full —
rolling any unfinished drip forward — over the span it was earned in,
clamped to controls.max_unlock_duration_secs. A loss recognizes
instantly: the locked remainder absorbs it first (locked_profit = 0
with the lower total_assets means effective NAV never jumps up).
Sourcepub fn verify_report_fresh(&self, now: i64) -> ProgramResult
pub fn verify_report_fresh(&self, now: i64) -> ProgramResult
Staleness gate: reject when the last report is older than
controls.max_report_age_secs. Applied to atomic redeems only —
deposits are never staleness-gated (stale-entry capture is bounded by
the drip and the gain bound; stale-high entry harms only the
depositor) and queued redeems price later at strike. Pre-first-report
vaults are exempt (pricing is exactly par via the virtual offset).
Sourcepub fn verify_report_interval(&self, now: i64) -> ProgramResult
pub fn verify_report_interval(&self, now: i64) -> ProgramResult
Report rate limit: reject reports arriving sooner than
controls.min_report_interval_secs after the previous one (the first
report is exempt). Without this, a compromised NAV authority chains
small in-bound reports past the gain bound.
NAV gain bound: a report may not raise the net share price by more
than controls.max_nav_gain_bps vs. the stored pre-report price. No
downward bound — honest losses must land in one report. An over-bound
honest gain is not lost: the authority reports the capped amount and
rolls the remainder into subsequent reports. Skipped when supply or
the stored price is zero so post-total-loss recovery cannot wedge.
Sourcepub fn verify_idle_sub_account(&self, sub_account: u8) -> ProgramResult
pub fn verify_idle_sub_account(&self, sub_account: u8) -> ProgramResult
Base custody only ever moves through the sub-accounts whose base ATAs
report_nav reads as idle — the vault’s current deposit and withdraw
sub-accounts. External investment, returns, and fee collection are pinned
to these so the on-chain idle read always covers base in the current
custodies. The admin may repoint either sub-account, but every base
movement stays consistent with whatever the vault currently designates.
Repointing while the old custody still holds base strands it: the on-chain
idle read no longer sees it, so the off-chain NAV must fold that balance
into the reported external_value.
pub fn verify_manage_enabled(&self) -> ProgramResult
pub fn allows_depositor(&self, depositor: &Pubkey, proof: &[[u8; 32]]) -> bool
pub fn deposits_paused(&self) -> Result<bool, ProgramError>
pub fn withdrawals_paused(&self) -> Result<bool, ProgramError>
pub fn manage_paused(&self) -> Result<bool, ProgramError>
pub fn private(&self) -> Result<bool, ProgramError>
pub fn external_enabled(&self) -> Result<bool, ProgramError>
pub fn set_deposits_paused(&mut self, deposits_paused: bool)
pub fn set_withdrawals_paused(&mut self, withdrawals_paused: bool)
pub fn set_manage_paused(&mut self, manage_paused: bool)
pub fn set_private(&mut self, private: bool)
pub fn set_external_enabled(&mut self, external_enabled: bool)
pub fn validate_state(&self) -> ProgramResult
Trait Implementations§
impl Copy for Vault
impl Eq for Vault
Source§impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for Vault
impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for Vault
Source§impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for Vault
impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for Vault
impl StructuralPartialEq for Vault
Source§impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for Vaultwhere
for<'_wincode_internal> OracleConfig: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> u64: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal> i64: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> [u8; 32]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> VaultControls: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal> u16: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> u8: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> [u8; 2]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> Assert<{ _ }>: IsTrue,
impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for Vaultwhere
for<'_wincode_internal> OracleConfig: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> u64: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal> i64: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> [u8; 32]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> VaultControls: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal> u16: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> u8: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> [u8; 2]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> Assert<{ _ }>: IsTrue,
Source§fn from_bytes<'de>(bytes: &'de [u8], config: C) -> Result<&'de Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
fn from_bytes<'de>(bytes: &'de [u8], config: C) -> Result<&'de Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
crate::ZeroCopy::from_bytes, but allows the caller to provide a custom configuration.Source§fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> Result<&'de mut Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> Result<&'de mut Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
crate::ZeroCopy::from_bytes_mut, but allows the caller to provide a custom configuration.Auto Trait Implementations§
impl Freeze for Vault
impl RefUnwindSafe for Vault
impl Send for Vault
impl Sync for Vault
impl Unpin for Vault
impl UnsafeUnpin for Vault
impl UnwindSafe for Vault
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
Source§impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
Source§impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader into dst.Source§impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader into dst.impl<T, C> SchemaReadOwned<C> for Twhere
C: ConfigCore,
T: for<'de> SchemaRead<'de, C>,
Source§impl<T> Serialize for T
impl<T> Serialize for T
Source§fn serialize(src: &Self::Src) -> Result<Vec<u8>, WriteError>
fn serialize(src: &Self::Src) -> Result<Vec<u8>, WriteError>
Vec of bytes.Source§fn serialize_into(dst: impl Writer, src: &Self::Src) -> Result<(), WriteError>
fn serialize_into(dst: impl Writer, src: &Self::Src) -> Result<(), WriteError>
Source§fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>
fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>
Source§impl<T, C> Serialize<C> for T
impl<T, C> Serialize<C> for T
Source§fn serialize(src: &Self::Src, config: C) -> Result<Vec<u8>, WriteError>
fn serialize(src: &Self::Src, config: C) -> Result<Vec<u8>, WriteError>
Vec of bytes.Source§fn serialize_into(
dst: impl Writer,
src: &Self::Src,
config: C,
) -> Result<(), WriteError>
fn serialize_into( dst: impl Writer, src: &Self::Src, config: C, ) -> Result<(), WriteError>
Writer.