Pool

Struct Pool 

Source
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: u8

Pool 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: i64

Unix timestamp of the pool creation, in seconds.

§updated_at: i64

Unix timestamp of the last time the pool has been updated, in seconds.

§expiry: i64

Unix timestamp of when the pool expires, in seconds.

§owner: Pubkey

The owner of the pool.

§whitelist: Pubkey

The whitelist of the pool, determining which NFTs can be deposited or sold into the pool.

§rent_payer: Pubkey§currency: Currency§amount: u64

The amount of currency held in the pool.

§price_offset: i32

The 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: u32

The number of NFTs currently held in the pool.

§stats: PoolStats

Various stats about the pool, including the number of buys and sells.

§shared_escrow: NullableAddress

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: NullableAddress

An 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: NullableAddress

Maker broker fees will be sent to this address if populated. Default pubkey is interpreted as no value.

§max_taker_sell_count: u32

Limit how many buys a pool can execute - useful for shared escrow pools, else keeps buying into infinity.

§config: PoolConfig

Pool configuration values.

§reserved: [u8; 100]

Reserved space for future upgrades.

Implementations§

Source§

impl Pool

Source

pub const LEN: usize = 447usize

Source

pub const PREFIX: &'static [u8]

Prefix values used to generate a PDA for this account.

Values are positional and appear in the following order:

  1. Pool::PREFIX
  2. owner (Pubkey)
  3. pool_id ([u8; 32])
Source

pub fn create_pda( owner: Pubkey, pool_id: [u8; 32], bump: u8, ) -> Result<Pubkey, PubkeyError>

Source

pub fn find_pda(owner: &Pubkey, pool_id: [u8; 32]) -> (Pubkey, u8)

Source

pub fn from_bytes(data: &[u8]) -> Result<Self, Error>

Source§

impl Pool

Source

pub fn shift_price( &self, price_offset: i32, side: TakerSide, ) -> Result<u64, TensorAmmError>

Shifts the price of a pool by a certain offset.

Source

pub fn current_price(&self, side: TakerSide) -> Result<u64, TensorAmmError>

Calculate the price of the pool after shifting it by a certain offset.

Source

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 Pool

Source§

fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Source§

impl BorshSerialize for Pool

Source§

fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn try_to_vec(&self) -> Result<Vec<u8>, Error>

Serialize this instance into a vector of bytes.
Source§

impl Clone for Pool

Source§

fn clone(&self) -> Pool

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Pool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Pool

Source§

fn eq(&self, other: &Pool) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> TryFrom<&AccountInfo<'a>> for Pool

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(account_info: &AccountInfo<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for Pool

Source§

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> AbiExample for T

Source§

default fn example() -> T

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V