pub struct Asset {
pub vault: [u8; 32],
pub asset_mint: [u8; 32],
pub oracle: OracleConfig,
pub deposit_cap_atoms: u64,
pub asset_decimals: u8,
pub bump: u8,
/* private fields */
}Fields§
§vault: [u8; 32]Vault this non-base asset belongs to.
asset_mint: [u8; 32]Mint of the supported non-base deposit asset.
oracle: OracleConfigOracle pricing one whole asset token. Direct mode: in whole base
tokens. Routed mode: in the quote currency shared with the vault’s
base_oracle.
deposit_cap_atoms: u64Inventory cap in asset atoms: deposits reject once the custody balance
plus the deposit would exceed it. u64::MAX = uncapped (explicit — no
zero-means-off magic; a zero cap blocks all deposits of this asset).
asset_decimals: u8Asset mint decimals.
bump: u8Implementations§
Source§impl Asset
impl Asset
pub const SEED: &'static [u8] = b"asset"
pub const SPACE: usize
pub fn new( vault: [u8; 32], asset_mint: [u8; 32], oracle: OracleConfig, asset_decimals: u8, enabled: bool, routed: bool, deposit_cap_atoms: u64, bump: u8, ) -> Result<Self, ProgramError>
pub fn find_address(vault: &Pubkey, asset_mint: &Pubkey) -> (Pubkey, u8)
Sourcepub fn from_account_data(data: &[u8]) -> Result<Self, ProgramError>
pub fn from_account_data(data: &[u8]) -> Result<Self, ProgramError>
Decode an Asset from raw Roshi account data — the wincode Account::Asset
payload (a one-byte tag then the asset). Mirrors super::Vault::from_account_data.
pub fn enabled(&self) -> Result<bool, ProgramError>
pub fn set_enabled(&mut self, enabled: bool)
pub fn routed(&self) -> Result<bool, ProgramError>
pub fn set_routed(&mut self, routed: bool)
pub fn validate_state(&self) -> ProgramResult
Trait Implementations§
impl Copy for Asset
impl Eq for Asset
Source§impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for Asset
impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for Asset
Source§impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for Asset
impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for Asset
impl StructuralPartialEq for Asset
Source§impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for Assetwhere
for<'_wincode_internal, '_wincode_internal> [u8; 32]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> OracleConfig: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> u64: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> u8: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> [u8; 4]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> Assert<{ _ }>: IsTrue,
impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for Assetwhere
for<'_wincode_internal, '_wincode_internal> [u8; 32]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> OracleConfig: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> u64: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> u8: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> [u8; 4]: 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>,
Like
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>,
Like
crate::ZeroCopy::from_bytes_mut, but allows the caller to provide a custom configuration.Auto Trait Implementations§
impl Freeze for Asset
impl RefUnwindSafe for Asset
impl Send for Asset
impl Sync for Asset
impl Unpin for Asset
impl UnsafeUnpin for Asset
impl UnwindSafe for Asset
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
Mutably borrows from an owned value. Read more
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>
Deserialize from the given
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>
Deserialize from the given
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>
Deserialize from the given
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>
Deserialize from the given
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>
Serialize a serializable type into a
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>
Serialize a serializable type into the given byte buffer.
Source§fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>
fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>
Get the size in bytes of the type when serialized.
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>
Serialize a serializable type into a
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>
Serialize a serializable type into the given
Writer.Source§fn serialized_size(src: &Self::Src, config: C) -> Result<u64, WriteError>
fn serialized_size(src: &Self::Src, config: C) -> Result<u64, WriteError>
Get the size in bytes of the type when serialized.