pub struct TunaPosition {Show 27 fields
pub discriminator: [u8; 8],
pub version: u16,
pub bump: [u8; 1],
pub authority: Pubkey,
pub pool: Pubkey,
pub mint_a: Pubkey,
pub mint_b: Pubkey,
pub position_mint: Pubkey,
pub liquidity: u128,
pub tick_lower_index: i32,
pub tick_upper_index: i32,
pub loan_shares_a: u64,
pub loan_shares_b: u64,
pub loan_funds_a: u64,
pub loan_funds_b: u64,
pub leftovers_a: u64,
pub leftovers_b: u64,
pub tick_entry_index: i32,
pub tick_stop_loss_index: i32,
pub tick_take_profit_index: i32,
pub state: TunaPositionState,
pub swap_to_token_on_limit_order: u8,
pub compounded_yield_a: u64,
pub compounded_yield_b: u64,
pub flags: u32,
pub market_maker: MarketMaker,
pub reserved: [u8; 61],
}Fields§
§discriminator: [u8; 8]§version: u16Struct version
bump: [u8; 1]Bump seed for the tuna position account
The authority address used for managing the position
pool: PubkeyLiquidity pool address this position belongs to
mint_a: PubkeyThe mint address for token A
mint_b: PubkeyThe mint address for token B
position_mint: PubkeyThe mint address for the position token (minted and used in Orca/Fusion)
liquidity: u128Total minted liquidity
tick_lower_index: i32Position lower tick
tick_upper_index: i32Position upper tick
The amount of shares borrowed by user from vault A.
The amount of shares borrowed by user from vault B.
loan_funds_a: u64The amount of funds borrowed by user from vault A. Doesn’t include accrued interest.
loan_funds_b: u64The amount of funds borrowed by user from vault B. Doesn’t include accrued interest.
leftovers_a: u64The leftovers are funds that couldn’t be added to a pool as liquidity. They remain in the position token account.
leftovers_b: u64The leftovers are funds that couldn’t be added to a pool as liquidity. They remain in the position token account.
tick_entry_index: i32Position entry tick index.
tick_stop_loss_index: i32Position stop loss tick index.
tick_take_profit_index: i32Position stop loss tick index.
state: TunaPositionStatePosition state: normal, liquidated, closed by limit order
swap_to_token_on_limit_order: u8OBSOLETE: Which token to swap collateral to when a limit order is executed. Used for position ver 4 or older. bits 0..1: Stop loss swap. 0 - no swap, 1 - swap to token A, 2 - swap to token B bits 2..3: Take profit swap. 0 - no swap, 1 - swap to token A, 2 - swap to token B
compounded_yield_a: u64Yield amount in token A that has already been collected and compounded into the position.
compounded_yield_b: u64Yield amount in token B that has already been collected and compounded into the position.
flags: u32Position options. Bits 0..1: Stop loss swap. 0 - no swap, 1 - swap to token A, 2 - swap to token B Bits 2..3: Take profit swap. 0 - no swap, 1 - swap to token A, 2 - swap to token B Bits 4..5: Yield auto compounding. 0 - don’t compound, 1 - compound yield, 2 - compound yield with leverage
market_maker: MarketMakerMarket maker (Orca, Fusion)
reserved: [u8; 61]Reserved
Implementations§
Source§impl TunaPosition
impl TunaPosition
Sourcepub fn get_total_balance(
&self,
sqrt_price: u128,
) -> Result<(u64, u64), ErrorCode>
pub fn get_total_balance( &self, sqrt_price: u128, ) -> Result<(u64, u64), ErrorCode>
Returns the total position balance.
Sourcepub fn compute_total_and_debt(
&self,
sqrt_price: u128,
vault_a: &Vault,
vault_b: &Vault,
) -> Result<(u64, u64), ErrorCode>
pub fn compute_total_and_debt( &self, sqrt_price: u128, vault_a: &Vault, vault_b: &Vault, ) -> Result<(u64, u64), ErrorCode>
Returns the current position total and debt size.
Sourcepub fn is_healthy(
&self,
sqrt_price: u128,
market: &Market,
vault_a: &Vault,
vault_b: &Vault,
) -> Result<(bool, u32), ErrorCode>
pub fn is_healthy( &self, sqrt_price: u128, market: &Market, vault_a: &Vault, vault_b: &Vault, ) -> Result<(bool, u32), ErrorCode>
Returns if the position is healthy or not. Vaults must be passed with accrued interest.
pub fn is_liquidated(&self) -> bool
pub fn is_limit_order_reached(&self, sqrt_price: u128) -> bool
Sourcepub fn compute_leverage(
&self,
sqrt_price: u128,
vault_a: &Vault,
vault_b: &Vault,
) -> Result<Fixed128, ErrorCode>
pub fn compute_leverage( &self, sqrt_price: u128, vault_a: &Vault, vault_b: &Vault, ) -> Result<Fixed128, ErrorCode>
Returns the current leverage of a position. Vaults must be passed with accrued interest.
pub fn get_pool_key(&self) -> String
Trait Implementations§
Source§impl BorshDeserialize for TunaPositionwhere
[u8; 8]: BorshDeserialize,
u16: BorshDeserialize,
[u8; 1]: BorshDeserialize,
Pubkey: BorshDeserialize,
u128: BorshDeserialize,
i32: BorshDeserialize,
u64: BorshDeserialize,
TunaPositionState: BorshDeserialize,
u8: BorshDeserialize,
u32: BorshDeserialize,
MarketMaker: BorshDeserialize,
[u8; 61]: BorshDeserialize,
impl BorshDeserialize for TunaPositionwhere
[u8; 8]: BorshDeserialize,
u16: BorshDeserialize,
[u8; 1]: BorshDeserialize,
Pubkey: BorshDeserialize,
u128: BorshDeserialize,
i32: BorshDeserialize,
u64: BorshDeserialize,
TunaPositionState: BorshDeserialize,
u8: BorshDeserialize,
u32: BorshDeserialize,
MarketMaker: BorshDeserialize,
[u8; 61]: 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 TunaPositionwhere
[u8; 8]: BorshSerialize,
u16: BorshSerialize,
[u8; 1]: BorshSerialize,
Pubkey: BorshSerialize,
u128: BorshSerialize,
i32: BorshSerialize,
u64: BorshSerialize,
TunaPositionState: BorshSerialize,
u8: BorshSerialize,
u32: BorshSerialize,
MarketMaker: BorshSerialize,
[u8; 61]: BorshSerialize,
impl BorshSerialize for TunaPositionwhere
[u8; 8]: BorshSerialize,
u16: BorshSerialize,
[u8; 1]: BorshSerialize,
Pubkey: BorshSerialize,
u128: BorshSerialize,
i32: BorshSerialize,
u64: BorshSerialize,
TunaPositionState: BorshSerialize,
u8: BorshSerialize,
u32: BorshSerialize,
MarketMaker: BorshSerialize,
[u8; 61]: BorshSerialize,
Source§impl Clone for TunaPosition
impl Clone for TunaPosition
Source§fn clone(&self) -> TunaPosition
fn clone(&self) -> TunaPosition
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TunaPosition
impl Debug for TunaPosition
Source§impl Display for TunaPosition
impl Display for TunaPosition
Source§impl PartialEq for TunaPosition
impl PartialEq for TunaPosition
Source§impl<'a> TryFrom<&AccountInfo<'a>> for TunaPosition
impl<'a> TryFrom<&AccountInfo<'a>> for TunaPosition
impl Eq for TunaPosition
impl StructuralPartialEq for TunaPosition
Auto Trait Implementations§
impl Freeze for TunaPosition
impl RefUnwindSafe for TunaPosition
impl Send for TunaPosition
impl Sync for TunaPosition
impl Unpin for TunaPosition
impl UnwindSafe for TunaPosition
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