pub struct Marketplace {
pub fee_bps: u64,
pub protocol_fee_address: String,
/* private fields */
}Expand description
The marketplace engine.
Fields§
§fee_bps: u64Fee in basis points (e.g. 25 = 0.25%) charged to the filled side.
protocol_fee_address: StringProtocol address that collects marketplace fees.
Implementations§
Source§impl Marketplace
impl Marketplace
pub fn new(fee_bps: u64, protocol_fee_address: String) -> Marketplace
Sourcepub fn place_order(
&mut self,
maker: &str,
side: OrderSide,
sell_asset: MarketAsset,
buy_asset: MarketAsset,
amount: u64,
price: u64,
) -> String
pub fn place_order( &mut self, maker: &str, side: OrderSide, sell_asset: MarketAsset, buy_asset: MarketAsset, amount: u64, price: u64, ) -> String
Place a limit order. Returns the order ID.
Sourcepub fn cancel_order(&mut self, order_id: &str) -> bool
pub fn cancel_order(&mut self, order_id: &str) -> bool
Cancel an open order. Returns true if found and cancelled.
Sourcepub fn order_book(
&self,
sell_asset: &MarketAsset,
buy_asset: &MarketAsset,
) -> OrderBook
pub fn order_book( &self, sell_asset: &MarketAsset, buy_asset: &MarketAsset, ) -> OrderBook
Get the order book for a given asset pair.
Sourcepub fn orders_for_maker(&self, maker: &str) -> Vec<&Order>
pub fn orders_for_maker(&self, maker: &str) -> Vec<&Order>
Get all orders for a maker.
Sourcepub fn try_match(
&mut self,
maker: &str,
side: OrderSide,
sell_asset: &MarketAsset,
buy_asset: &MarketAsset,
amount: u64,
price: u64,
) -> Vec<Trade>
pub fn try_match( &mut self, maker: &str, side: OrderSide, sell_asset: &MarketAsset, buy_asset: &MarketAsset, amount: u64, price: u64, ) -> Vec<Trade>
Try to match a new sell order against existing buy orders (and vice versa). Returns the trades that were executed. This is a simple price-time priority matching engine.
Sourcepub fn place_and_match(
&mut self,
maker: &str,
side: OrderSide,
sell_asset: MarketAsset,
buy_asset: MarketAsset,
amount: u64,
price: u64,
) -> (String, Vec<Trade>)
pub fn place_and_match( &mut self, maker: &str, side: OrderSide, sell_asset: MarketAsset, buy_asset: MarketAsset, amount: u64, price: u64, ) -> (String, Vec<Trade>)
Place an order and immediately attempt to match it. Returns the order ID and any trades that were executed.
Sourcepub fn open_orders(&self) -> Vec<&Order>
pub fn open_orders(&self) -> Vec<&Order>
Get all open orders.
Auto Trait Implementations§
impl Freeze for Marketplace
impl RefUnwindSafe for Marketplace
impl Send for Marketplace
impl Sync for Marketplace
impl Unpin for Marketplace
impl UnsafeUnpin for Marketplace
impl UnwindSafe for Marketplace
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
Mutably borrows from an owned value. Read more