Skip to main content

Pair

Struct Pair 

Source
pub struct Pair {
    pub pair_id: Vec<u8>,
    pub base_asset_id: Vec<u8>,
    pub quote_asset_id: Vec<u8>,
    pub l1: L1,
    pub market_price: Option<u64>,
    pub orderbook: OrderBook,
    pub clients: Vec<Vec<u8>>,
    pub client_admin_account_ids: HashMap<Vec<u8>, Vec<u8>>,
    pub client_fee_account_ids: HashMap<Vec<u8>, Vec<u8>>,
}

Fields§

§pair_id: Vec<u8>

Pair ID

§base_asset_id: Vec<u8>

base asset id

§quote_asset_id: Vec<u8>

quote asset id

§l1: L1

L1 state

§market_price: Option<u64>

market price

§orderbook: OrderBook

Orderbook

§clients: Vec<Vec<u8>>

list of exchange clients which shares the orderbook

§client_admin_account_ids: HashMap<Vec<u8>, Vec<u8>>

Hash map of client id -> client admin account id

§client_fee_account_ids: HashMap<Vec<u8>, Vec<u8>>

Hash map of client id -> client fee account id

Implementations§

Source§

impl Pair

Source

pub fn new() -> Self

Source

pub fn add_client( &mut self, cid: impl Into<Vec<u8>>, admin_account_id: impl Into<Vec<u8>>, fee_account_id: impl Into<Vec<u8>>, )

Source

pub fn remove_client(&mut self, cid: impl Into<Vec<u8>>)

Source

pub fn _match_at( &mut self, price: u64, is_matching_asks: bool, taker_order: &mut Order, ) -> Result<Order, OrderBookError>

Match all orders at a specific price level until the taker order is fully filled or no more orders at the price level Returns remaining_amount after matching is_matching_asks indicates if we’re matching against ask orders (true) or bid orders (false) Continues matching until remaining amount is 0 or no more orders at the price level

Source

pub fn _limit_order( &mut self, limit_price: u64, taker_order: &mut Order, ) -> Result<(Order, u64, u64), OrderBookError>

Place a limit order (internal helper) Returns (remaining_amount, bid_head, ask_head) Continues matching until remaining amount is 0 or no more matching orders available

Source

pub fn limit_sell( &mut self, cid: impl Into<Vec<u8>>, existing_order_id: Option<OrderId>, owner: impl Into<Vec<u8>>, price: u64, amnt: u64, iqty: u64, timestamp: i64, expires_at: i64, maker_fee_bps: i16, taker_fee_bps: i16, time_in_force: TimeInForce, ) -> Result<OrderId, OrderBookError>

Matches against existing orders first, then places remaining in orderbook based on time_in_force

  • returns the order id and if a dormant order was found.
  • cid is the gateway client id.
  • existing_order_id is the order id to update with the transaction if it exists.
  • owner is the owner of the order.
  • price is the price of the order.
  • amount is the total amount of the order.
  • public_amount is the public amount of the order in case of iceberg order.
  • timestamp is the timestamp of the order.
  • expires_at is the expiring timestamp of the order.
  • maker_fee_bps is the maker fee basis points of the order.
  • taker_fee_bps is the taker fee basis points of the order.
  • time_in_force is the time in force of the order.
Source

pub fn limit_buy( &mut self, cid: impl Into<Vec<u8>>, existing_order_id: Option<OrderId>, owner: impl Into<Vec<u8>>, price: u64, amnt: u64, iqty: u64, timestamp: i64, expires_at: i64, maker_fee_bps: i16, taker_fee_bps: i16, time_in_force: TimeInForce, ) -> Result<(), OrderBookError>

Place a limit buy order (bid order) Matches against existing orders first, then places remaining in orderbook based on time_in_force

  • returns the order id and if a dormant order was found.
  • cid is the gateway client id.
  • existing_order_id is the order id to update with the transaction if it exists.
  • owner is the owner of the order.
  • price is the price of the order.
  • amount is the total amount of the order.
  • public_amount is the public amount of the order in case of iceberg order.
  • timestamp is the timestamp of the order.
  • expires_at is the expiring timestamp of the order.
  • maker_fee_bps is the maker fee basis points of the order.
  • taker_fee_bps is the taker fee basis points of the order.
  • time_in_force is the time in force of the order.
Source

pub fn market_sell( &mut self, cid: impl Into<Vec<u8>>, existing_order_id: Option<OrderId>, owner: impl Into<Vec<u8>>, amnt: u64, iqty: u64, timestamp: i64, expires_at: i64, maker_fee_bps: i16, taker_fee_bps: i16, time_in_force: TimeInForce, ) -> Result<(), OrderBookError>

Execute a market sell order Matches against existing orders first (market orders match at any price)

  • returns the match result.
  • cid is the gateway client id.
  • existing_order_id is the order id to update with the transaction if it exists.
  • owner is the owner of the order.
  • amount is the total amount of the order.
  • clear is whether to clear the order.
  • taker_fee_bps is the taker fee basis points of the order.
  • time_in_force is the time in force of the order.
Source

pub fn market_buy( &mut self, cid: impl Into<Vec<u8>>, existing_order_id: Option<OrderId>, owner: impl Into<Vec<u8>>, amnt: u64, iqty: u64, timestamp: i64, expires_at: i64, maker_fee_bps: i16, taker_fee_bps: i16, time_in_force: TimeInForce, ) -> Result<(), OrderBookError>

Execute a market buy order Matches against existing orders first (market orders match at any price)

  • returns the match result.
  • cid is the gateway client id.
  • existing_order_id is the order id to update with the transaction if it exists.
  • owner is the owner of the order.
  • amount is the total amount of the order.
  • taker_fee_bps is the taker fee basis points of the order.
  • time_in_force is the time in force of the order.
Source

pub fn cancel_order( &mut self, cid: impl Into<Vec<u8>>, pair_id: impl Into<Vec<u8>>, is_bid: bool, order_id: OrderId, owner: impl Into<Vec<u8>>, ) -> Result<(), OrderBookError>

Trait Implementations§

Source§

impl Clone for Pair

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Pair

Source§

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

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

impl Default for Pair

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Pair

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Pair

Source§

impl PartialEq for Pair

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Pair

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Pair

Auto Trait Implementations§

§

impl Forget for Pair

§

impl Freeze for Pair

§

impl RefUnwindSafe for Pair

§

impl Send for Pair

§

impl Sync for Pair

§

impl Unpin for Pair

§

impl UnsafeUnpin for Pair

§

impl UnwindSafe for Pair

Blanket Implementations§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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