pub struct Pool {Show 21 fields
pub discriminator: [u8; 8],
pub version: u8,
pub bump: [u8; 1],
pub pool_id: [u8; 32],
pub created_at: i64,
pub updated_at: i64,
pub expiry: i64,
pub owner: Pubkey,
pub whitelist: Pubkey,
pub rent_payer: Pubkey,
pub currency: Currency,
pub amount: u64,
pub price_offset: i32,
pub nfts_held: u32,
pub stats: PoolStats,
pub shared_escrow: NullableAddress,
pub cosigner: NullableAddress,
pub maker_broker: NullableAddress,
pub max_taker_sell_count: u32,
pub config: PoolConfig,
pub reserved: [u8; 100],
}Expand description
Pool is the main state account in the AMM program and represents the AMM pool where trades can happen.
Pool accounts are Program Derived Addresses derived from the seeds: "pool", owner, and identifier.
Fields§
§discriminator: [u8; 8]§version: u8Pool version, used to control upgrades.
bump: [u8; 1]Bump seed for the pool PDA.
pool_id: [u8; 32]Owner-chosen identifier for the pool
created_at: i64Unix timestamp of the pool creation, in seconds.
updated_at: i64Unix timestamp of the last time the pool has been updated, in seconds.
expiry: i64Unix timestamp of when the pool expires, in seconds.
owner: PubkeyThe owner of the pool.
whitelist: PubkeyThe whitelist of the pool, determining which NFTs can be deposited or sold into the pool.
rent_payer: Pubkey§currency: Currency§amount: u64The amount of currency held in the pool.
price_offset: i32The difference between the number of buys and sells where a postive number indicates the taker has BOUGHT more NFTs than sold and a negative number indicates the taker has SOLD more NFTs than bought. This is used to calculate the current price of the pool.
nfts_held: u32The number of NFTs currently held in the pool.
stats: PoolStatsVarious stats about the pool, including the number of buys and sells.
If an escrow account is present, it means it’s a shared-escrow pool where liquidity is shared with other pools. Default pubkey is interpreted as no value.
cosigner: NullableAddressAn offchain actor that signs off to make sure an offchain condition is met (eg trait present). Default pubkey is interpreted as no value.
maker_broker: NullableAddressMaker broker fees will be sent to this address if populated. Default pubkey is interpreted as no value.
max_taker_sell_count: u32Limit how many buys a pool can execute - useful for shared escrow pools, else keeps buying into infinity.
config: PoolConfigPool configuration values.
reserved: [u8; 100]Reserved space for future upgrades.
Implementations§
Source§impl Pool
impl Pool
pub const LEN: usize = 447usize
Sourcepub const PREFIX: &'static [u8]
pub const PREFIX: &'static [u8]
Prefix values used to generate a PDA for this account.
Values are positional and appear in the following order:
Pool::PREFIX- owner (
Pubkey) - pool_id (
[u8; 32])
pub fn create_pda( owner: Pubkey, pool_id: [u8; 32], bump: u8, ) -> Result<Pubkey, PubkeyError>
pub fn find_pda(owner: &Pubkey, pool_id: [u8; 32]) -> (Pubkey, u8)
pub fn from_bytes(data: &[u8]) -> Result<Self, Error>
Source§impl Pool
impl Pool
Sourcepub fn shift_price(
&self,
price_offset: i32,
side: TakerSide,
) -> Result<u64, TensorAmmError>
pub fn shift_price( &self, price_offset: i32, side: TakerSide, ) -> Result<u64, TensorAmmError>
Shifts the price of a pool by a certain offset.
Sourcepub fn current_price(&self, side: TakerSide) -> Result<u64, TensorAmmError>
pub fn current_price(&self, side: TakerSide) -> Result<u64, TensorAmmError>
Calculate the price of the pool after shifting it by a certain offset.
Sourcepub fn calc_mm_fee(&self, current_price: u64) -> Result<u64, TensorAmmError>
pub fn calc_mm_fee(&self, current_price: u64) -> Result<u64, TensorAmmError>
Calculate the fee the MM receives when providing liquidity to a two-sided pool.
Trait Implementations§
Source§impl BorshDeserialize for Poolwhere
[u8; 8]: BorshDeserialize,
u8: BorshDeserialize,
[u8; 1]: BorshDeserialize,
[u8; 32]: BorshDeserialize,
i64: BorshDeserialize,
Pubkey: BorshDeserialize,
Currency: BorshDeserialize,
u64: BorshDeserialize,
i32: BorshDeserialize,
u32: BorshDeserialize,
PoolStats: BorshDeserialize,
NullableAddress: BorshDeserialize,
PoolConfig: BorshDeserialize,
[u8; 100]: BorshDeserialize,
impl BorshDeserialize for Poolwhere
[u8; 8]: BorshDeserialize,
u8: BorshDeserialize,
[u8; 1]: BorshDeserialize,
[u8; 32]: BorshDeserialize,
i64: BorshDeserialize,
Pubkey: BorshDeserialize,
Currency: BorshDeserialize,
u64: BorshDeserialize,
i32: BorshDeserialize,
u32: BorshDeserialize,
PoolStats: BorshDeserialize,
NullableAddress: BorshDeserialize,
PoolConfig: BorshDeserialize,
[u8; 100]: 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 Poolwhere
[u8; 8]: BorshSerialize,
u8: BorshSerialize,
[u8; 1]: BorshSerialize,
[u8; 32]: BorshSerialize,
i64: BorshSerialize,
Pubkey: BorshSerialize,
Currency: BorshSerialize,
u64: BorshSerialize,
i32: BorshSerialize,
u32: BorshSerialize,
PoolStats: BorshSerialize,
NullableAddress: BorshSerialize,
PoolConfig: BorshSerialize,
[u8; 100]: BorshSerialize,
impl BorshSerialize for Poolwhere
[u8; 8]: BorshSerialize,
u8: BorshSerialize,
[u8; 1]: BorshSerialize,
[u8; 32]: BorshSerialize,
i64: BorshSerialize,
Pubkey: BorshSerialize,
Currency: BorshSerialize,
u64: BorshSerialize,
i32: BorshSerialize,
u32: BorshSerialize,
PoolStats: BorshSerialize,
NullableAddress: BorshSerialize,
PoolConfig: BorshSerialize,
[u8; 100]: BorshSerialize,
Source§impl<'a> TryFrom<&AccountInfo<'a>> for Pool
impl<'a> TryFrom<&AccountInfo<'a>> for Pool
impl Eq for Pool
impl StructuralPartialEq for Pool
Auto Trait Implementations§
impl Freeze for Pool
impl RefUnwindSafe for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl UnwindSafe for Pool
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
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<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