pub struct Vault {Show 15 fields
pub discriminator: [u8; 8],
pub version: u16,
pub bump: [u8; 1],
pub mint: Pubkey,
pub deposited_funds: u64,
pub deposited_shares: u64,
pub borrowed_funds: u64,
pub borrowed_shares: u64,
pub unpaid_debt_shares: u64,
pub interest_rate: u64,
pub last_update_timestamp: u64,
pub supply_limit: u64,
pub pyth_oracle_price_update: Pubkey,
pub pyth_oracle_feed_id: Pubkey,
pub reserved: [u8; 184],
}Fields§
§discriminator: [u8; 8]§version: u16Struct version
bump: [u8; 1]Bump seed for the vault account
mint: PubkeyThe mint of the token that this vault holds
deposited_funds: u64The amount of funds deposited in the vault - takes into account accrued interest
The amount of shares deposited in the vault
borrowed_funds: u64The amount of funds borrowed from the vault - takes into account accrued interest
The amount of shares borrowed from the vault
Bad dept may appear on a position liquidation if not enough funds to repay the debt to a lending pool.
interest_rate: u64The interest rate of the vault per seconds. (1<<60) / 31536000 = 1152921504606846976 / 31536000 = 100% annually.
last_update_timestamp: u64The last time the vault was updated.
supply_limit: u64The maximum allowed supply for this pool. The default value 0 is unlimited supply.
pyth_oracle_price_update: PubkeyPyth oracle price update account.
pyth_oracle_feed_id: PubkeyPyth oracle price feed id.
reserved: [u8; 184]Reserved
Implementations§
Source§impl Vault
impl Vault
pub fn get_utilization(&self) -> Fixed128
Sourcepub fn compounded_interest_rate(r: Fixed128) -> Result<Fixed128, ErrorCode>
pub fn compounded_interest_rate(r: Fixed128) -> Result<Fixed128, ErrorCode>
Returns the sum of the first three terms of a Taylor expansion of e^r - 1, to approximate a continuous compound interest rate.
pub fn accrue_interest(&mut self, timestamp: u64) -> Result<(), ErrorCode>
pub fn calculate_deposited_funds( &self, shares: u64, rounding: Rounding, ) -> Result<u64, ErrorCode>
pub fn calculate_borrowed_funds( &self, shares: u64, rounding: Rounding, ) -> Result<u64, ErrorCode>
Trait Implementations§
Source§impl BorshDeserialize for Vaultwhere
[u8; 8]: BorshDeserialize,
u16: BorshDeserialize,
[u8; 1]: BorshDeserialize,
Pubkey: BorshDeserialize,
u64: BorshDeserialize,
[u8; 184]: BorshDeserialize,
impl BorshDeserialize for Vaultwhere
[u8; 8]: BorshDeserialize,
u16: BorshDeserialize,
[u8; 1]: BorshDeserialize,
Pubkey: BorshDeserialize,
u64: BorshDeserialize,
[u8; 184]: BorshDeserialize,
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for Vaultwhere
[u8; 8]: BorshSerialize,
u16: BorshSerialize,
[u8; 1]: BorshSerialize,
Pubkey: BorshSerialize,
u64: BorshSerialize,
[u8; 184]: BorshSerialize,
impl BorshSerialize for Vaultwhere
[u8; 8]: BorshSerialize,
u16: BorshSerialize,
[u8; 1]: BorshSerialize,
Pubkey: BorshSerialize,
u64: BorshSerialize,
[u8; 184]: BorshSerialize,
Source§impl<'a> TryFrom<&AccountInfo<'a>> for Vault
impl<'a> TryFrom<&AccountInfo<'a>> for Vault
impl Eq for Vault
impl StructuralPartialEq for Vault
Auto Trait Implementations§
impl Freeze for Vault
impl RefUnwindSafe for Vault
impl Send for Vault
impl Sync for Vault
impl Unpin for Vault
impl UnwindSafe for Vault
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more