Struct jet_margin::MarginAccount
source · [−]#[repr(C)]#[repr(align(8))]pub struct MarginAccount {
pub version: u8,
pub bump_seed: [u8; 1],
pub user_seed: [u8; 2],
pub invocation: Invocation,
pub reserved0: [u8; 3],
pub owner: Pubkey,
pub liquidation: Pubkey,
pub liquidator: Pubkey,
pub positions: [u8; 7432],
}
Fields
version: u8
bump_seed: [u8; 1]
user_seed: [u8; 2]
invocation: Invocation
Data an adapter can use to check what the margin program thinks about the current invocation Must normally be zeroed, except during an invocation.
reserved0: [u8; 3]
owner: Pubkey
The owner of this account, which generally has to sign for any changes to it
liquidation: Pubkey
The state of an active liquidation for this account
liquidator: Pubkey
The active liquidator for this account
positions: [u8; 7432]
The storage for tracking account balances
Implementations
sourceimpl MarginAccount
impl MarginAccount
pub fn start_liquidation(&mut self, liquidation: Pubkey, liquidator: Pubkey)
pub fn end_liquidation(&mut self)
pub fn verify_not_liquidating(&self) -> AnchorResult<()>
pub fn is_liquidating(&self) -> bool
pub fn initialize(&mut self, owner: Pubkey, seed: u16, bump_seed: u8)
sourcepub fn positions(&self) -> impl Iterator<Item = &AccountPosition>
pub fn positions(&self) -> impl Iterator<Item = &AccountPosition>
Get the list of positions on this account
sourcepub fn register_position(
&mut self,
token: Pubkey,
decimals: u8,
address: Pubkey,
adapter: Pubkey,
kind: TokenKind,
value_modifier: u16,
max_staleness: u64,
approvals: &[Approver]
) -> AnchorResult<AccountPositionKey>
pub fn register_position(
&mut self,
token: Pubkey,
decimals: u8,
address: Pubkey,
adapter: Pubkey,
kind: TokenKind,
value_modifier: u16,
max_staleness: u64,
approvals: &[Approver]
) -> AnchorResult<AccountPositionKey>
Register the space for a new position into this account
sourcepub fn unregister_position(
&mut self,
mint: &Pubkey,
account: &Pubkey,
approvals: &[Approver]
) -> AnchorResult<()>
pub fn unregister_position(
&mut self,
mint: &Pubkey,
account: &Pubkey,
approvals: &[Approver]
) -> AnchorResult<()>
Free the space from a previously registered position no longer needed
pub fn refresh_position_metadata(
&mut self,
mint: &Pubkey,
kind: TokenKind,
value_modifier: u16,
max_staleness: u64
) -> Result<AccountPosition, ErrorCode>
pub fn get_position_key(&self, mint: &Pubkey) -> Option<AccountPositionKey>
pub fn get_position(&mut self, mint: &Pubkey) -> Option<&AccountPosition>
pub fn get_position_mut(&mut self, mint: &Pubkey) -> Option<&mut AccountPosition>
sourcepub fn get_position_by_key(
&self,
key: &AccountPositionKey
) -> Option<&AccountPosition>
pub fn get_position_by_key(
&self,
key: &AccountPositionKey
) -> Option<&AccountPosition>
faster than searching by mint only if you have the correct key slightly slower if you have the wrong key
sourcepub fn get_position_by_key_mut(
&mut self,
key: &AccountPositionKey
) -> Option<&mut AccountPosition>
pub fn get_position_by_key_mut(
&mut self,
key: &AccountPositionKey
) -> Option<&mut AccountPosition>
faster than searching by mint only if you have the correct key slightly slower if you have the wrong key
sourcepub fn set_position_balance(
&mut self,
mint: &Pubkey,
account: &Pubkey,
balance: u64
) -> Result<AccountPosition, ErrorCode>
pub fn set_position_balance(
&mut self,
mint: &Pubkey,
account: &Pubkey,
balance: u64
) -> Result<AccountPosition, ErrorCode>
Change the balance for a position
sourcepub fn set_position_price(
&mut self,
mint: &Pubkey,
price: &PriceInfo
) -> Result<(), ErrorCode>
pub fn set_position_price(
&mut self,
mint: &Pubkey,
price: &PriceInfo
) -> Result<(), ErrorCode>
Change the current price value of a position
sourcepub fn verify_healthy_positions(&self) -> AnchorResult<()>
pub fn verify_healthy_positions(&self) -> AnchorResult<()>
Check that the overall health of the account is acceptable, by comparing the total value of the claims versus the available collateral. If the collateralization ratio is above the minimum, then the account is considered healthy.
sourcepub fn verify_unhealthy_positions(&self) -> AnchorResult<()>
pub fn verify_unhealthy_positions(&self) -> AnchorResult<()>
Check that the overall health of the account is not acceptable.
Check if the given address is the current authority for this margin account
pub fn valuation(&self) -> AnchorResult<Valuation>
Trait Implementations
sourceimpl AccountDeserialize for MarginAccount
impl AccountDeserialize for MarginAccount
sourcefn try_deserialize(buf: &mut &[u8]) -> Result<Self>
fn try_deserialize(buf: &mut &[u8]) -> Result<Self>
Mint
account into a token
Account
. Read moresourcefn try_deserialize_unchecked(buf: &mut &[u8]) -> Result<Self>
fn try_deserialize_unchecked(buf: &mut &[u8]) -> Result<Self>
sourceimpl AnchorVerify for MarginAccount
impl AnchorVerify for MarginAccount
fn anchor_verify(info: &AccountInfo<'_>) -> AnchorResult<()>
sourceimpl Clone for MarginAccount
impl Clone for MarginAccount
sourcefn clone(&self) -> MarginAccount
fn clone(&self) -> MarginAccount
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for MarginAccount
impl Debug for MarginAccount
sourceimpl Discriminator for MarginAccount
impl Discriminator for MarginAccount
fn discriminator() -> [u8; 8]
sourceimpl Owner for MarginAccount
impl Owner for MarginAccount
sourceimpl SignerSeeds<3> for MarginAccount
impl SignerSeeds<3> for MarginAccount
fn signer_seeds(&self) -> [&[u8]; 3]
fn signer_seeds_owned(&self) -> Box<dyn SignerSeeds<3>>
sourceimpl Zeroable for MarginAccount
impl Zeroable for MarginAccount
impl Copy for MarginAccount
impl Pod for MarginAccount
impl ZeroCopy for MarginAccount
Auto Trait Implementations
impl RefUnwindSafe for MarginAccount
impl Send for MarginAccount
impl Sync for MarginAccount
impl Unpin for MarginAccount
impl UnwindSafe for MarginAccount
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
. Read more