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: L1L1 state
market_price: Option<u64>market price
orderbook: OrderBookOrderbook
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
impl Pair
pub fn new() -> Self
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>>, )
pub fn remove_client(&mut self, cid: impl Into<Vec<u8>>)
Sourcepub fn _match_at(
&mut self,
price: u64,
is_matching_asks: bool,
taker_order: &mut Order,
) -> Result<Order, OrderBookError>
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
Sourcepub fn _limit_order(
&mut self,
limit_price: u64,
taker_order: &mut Order,
) -> Result<(Order, u64, u64), OrderBookError>
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
Sourcepub 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>
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.
cidis the gateway client id.existing_order_idis the order id to update with the transaction if it exists.owneris the owner of the order.priceis the price of the order.amountis the total amount of the order.public_amountis the public amount of the order in case of iceberg order.timestampis the timestamp of the order.expires_atis the expiring timestamp of the order.maker_fee_bpsis the maker fee basis points of the order.taker_fee_bpsis the taker fee basis points of the order.time_in_forceis the time in force of the order.
Sourcepub 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>
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.
cidis the gateway client id.existing_order_idis the order id to update with the transaction if it exists.owneris the owner of the order.priceis the price of the order.amountis the total amount of the order.public_amountis the public amount of the order in case of iceberg order.timestampis the timestamp of the order.expires_atis the expiring timestamp of the order.maker_fee_bpsis the maker fee basis points of the order.taker_fee_bpsis the taker fee basis points of the order.time_in_forceis the time in force of the order.
Sourcepub 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>
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.
cidis the gateway client id.existing_order_idis the order id to update with the transaction if it exists.owneris the owner of the order.amountis the total amount of the order.clearis whether to clear the order.taker_fee_bpsis the taker fee basis points of the order.time_in_forceis the time in force of the order.
Sourcepub 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>
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.
cidis the gateway client id.existing_order_idis the order id to update with the transaction if it exists.owneris the owner of the order.amountis the total amount of the order.taker_fee_bpsis the taker fee basis points of the order.time_in_forceis the time in force of the order.