Trait tulipv2_sdk_common::traits::vault::TokenizedShares
source · [−]pub trait TokenizedShares {
Show 18 methods
fn is_locked(&self, last_deposit_time: i64) -> bool;
fn compound(&mut self, balance_to_add: u64) -> bool;
fn supports_compound(&self) -> bool;
fn shares_to_give(&self, amount: u64) -> u64;
fn underlying_to_redeem(&self, amount: u64) -> u64;
fn record_deposit(&mut self, amount: u64) -> u64;
fn record_withdraw(&mut self, shares_to_burn: u64, balance_to_remove: u64);
fn total_deposited_tokens(&self) -> u64;
fn total_shares(&self) -> u64;
fn shares_mint(&self) -> Pubkey;
fn underlying_mint(&self) -> Pubkey;
fn issue_shares<'info>(
&mut self,
mint: &AccountInfo<'info>,
receiver: &AccountInfo<'info>,
pda: &AccountInfo<'info>,
token_program: &AccountInfo<'info>,
signer_seeds: &[&[&[u8]]],
amount: u64
) -> Result<()>;
fn burn_shares<'info>(
&mut self,
shares_account: &AccountInfo<'info>,
shares_mint: &mut Box<Account<'info, Mint>>,
authority: &AccountInfo<'info>,
token_program: &AccountInfo<'info>,
signer_seeds: &[&[&[u8]]],
shares_to_burn: u64,
additional_signers: Option<Vec<AccountInfo<'info>>>
) -> Result<()>;
fn transfer_underlying<'info>(
&mut self,
underlying_account: &AccountInfo<'info>,
receiver: &AccountInfo<'info>,
pda: &AccountInfo<'info>,
token_program: &AccountInfo<'info>,
signer_seeds: &[&[&[u8]]],
amount: u64
) -> Result<()>;
fn deposits_capped(&self, incoming_deposit_amount: u64) -> bool;
fn sync_shares(&mut self, mint: &Mint);
fn exchange_rate(&mut self, mint: &Mint) -> f64;
fn cached_exchange_rate(&self, mint: &Mint) -> f64;
}Required Methods
sourcefn is_locked(&self, last_deposit_time: i64) -> bool
fn is_locked(&self, last_deposit_time: i64) -> bool
used to check if a withdraw attempt is locked. whether or not a vault is locked depends on the underlying implementation
sourcefn compound(&mut self, balance_to_add: u64) -> bool
fn compound(&mut self, balance_to_add: u64) -> bool
used to compound the underlying token represented by the shares returns true if the implementation supports compound operations and returns false if the implementation does not support compound operations
sourcefn supports_compound(&self) -> bool
fn supports_compound(&self) -> bool
returns true if the implementation supports compound operations
returns the amount of shares to give in exchange for depositing the amount of underlying asset
sourcefn underlying_to_redeem(&self, amount: u64) -> u64
fn underlying_to_redeem(&self, amount: u64) -> u64
returns the amount of underlying to redeem in exchange for burning the amount of shares
sourcefn record_deposit(&mut self, amount: u64) -> u64
fn record_deposit(&mut self, amount: u64) -> u64
used to record the effects of depositing underlying asset into the vault
sourcefn record_withdraw(&mut self, shares_to_burn: u64, balance_to_remove: u64)
fn record_withdraw(&mut self, shares_to_burn: u64, balance_to_remove: u64)
used to record the effect of withdrawing and burning the shares for their underlying assets. note you will need to calculate the shares to burn and the corresponding balance to remove
sourcefn total_deposited_tokens(&self) -> u64
fn total_deposited_tokens(&self) -> u64
returns the total deposited underlying tokens
returns the total shares issued, which should match the shares mint supply
returns the share’s mint account address
sourcefn underlying_mint(&self) -> Pubkey
fn underlying_mint(&self) -> Pubkey
returns the share’s underlying asset mint account address
used to issue the actual shares
used to burn the actual shares
sourcefn transfer_underlying<'info>(
&mut self,
underlying_account: &AccountInfo<'info>,
receiver: &AccountInfo<'info>,
pda: &AccountInfo<'info>,
token_program: &AccountInfo<'info>,
signer_seeds: &[&[&[u8]]],
amount: u64
) -> Result<()>
fn transfer_underlying<'info>(
&mut self,
underlying_account: &AccountInfo<'info>,
receiver: &AccountInfo<'info>,
pda: &AccountInfo<'info>,
token_program: &AccountInfo<'info>,
signer_seeds: &[&[&[u8]]],
amount: u64
) -> Result<()>
used to transfer underlying tokens
sourcefn deposits_capped(&self, incoming_deposit_amount: u64) -> bool
fn deposits_capped(&self, incoming_deposit_amount: u64) -> bool
is used to check whether or not the incoming deposited amount will push the vault over the cap. if the deposit cap is reached, returns true, otherwise returns false
syncs the variable tracked by the vault with the shares supply of a mint
sourcefn exchange_rate(&mut self, mint: &Mint) -> f64
fn exchange_rate(&mut self, mint: &Mint) -> f64
returns the amount of underlying backing 1 share
sourcefn cached_exchange_rate(&self, mint: &Mint) -> f64
fn cached_exchange_rate(&self, mint: &Mint) -> f64
returns the cached exchange rate value without first performing a shares sync this is generally only useful for on-chain programs which aren’t the owner of the account backing this particular trait.