pub struct Market {
pub contract_id: ContractId,
pub market_id: MarketId,
pub whitelist_id: Option<ContractId>,
pub blacklist_id: Option<ContractId>,
pub maker_fee: u64,
pub taker_fee: u64,
pub min_order: u64,
pub dust: u64,
pub price_window: u64,
pub base: MarketAsset,
pub quote: MarketAsset,
}Expand description
A trading market.
Fields§
§contract_id: ContractId§market_id: MarketId§whitelist_id: Option<ContractId>§blacklist_id: Option<ContractId>§maker_fee: u64§taker_fee: u64§min_order: u64§dust: u64§price_window: u64§base: MarketAsset§quote: MarketAssetImplementations§
Source§impl Market
impl Market
fn parsed_unsigned(value: &str, field: &str) -> Result<UnsignedDecimal, O2Error>
fn decimal_scale(value: &UnsignedDecimal) -> u32
Sourcepub fn price(&self, value: &str) -> Result<Price, O2Error>
pub fn price(&self, value: &str) -> Result<Price, O2Error>
Build a typed, market-bound price from a string.
Sourcepub fn price_from_decimal(
&self,
value: UnsignedDecimal,
) -> Result<Price, O2Error>
pub fn price_from_decimal( &self, value: UnsignedDecimal, ) -> Result<Price, O2Error>
Build a typed, market-bound price from an UnsignedDecimal.
Sourcepub fn quantity(&self, value: &str) -> Result<Quantity, O2Error>
pub fn quantity(&self, value: &str) -> Result<Quantity, O2Error>
Build a typed, market-bound quantity from a string.
Sourcepub fn quantity_from_decimal(
&self,
value: UnsignedDecimal,
) -> Result<Quantity, O2Error>
pub fn quantity_from_decimal( &self, value: UnsignedDecimal, ) -> Result<Quantity, O2Error>
Build a typed, market-bound quantity from an UnsignedDecimal.
Sourcepub fn validate_price_binding(&self, price: &Price) -> Result<(), O2Error>
pub fn validate_price_binding(&self, price: &Price) -> Result<(), O2Error>
Validate that a Price wrapper is compatible with this market.
Sourcepub fn validate_quantity_binding(
&self,
quantity: &Quantity,
) -> Result<(), O2Error>
pub fn validate_quantity_binding( &self, quantity: &Quantity, ) -> Result<(), O2Error>
Validate that a Quantity wrapper is compatible with this market.
fn checked_pow_u64(exp: u32, field: &str) -> Result<u64, O2Error>
fn checked_pow_u128(exp: u32, field: &str) -> Result<u128, O2Error>
fn checked_truncate_factor( decimals: u32, max_precision: u32, field: &str, ) -> Result<u64, O2Error>
Sourcepub fn format_price(&self, chain_value: u64) -> UnsignedDecimal
pub fn format_price(&self, chain_value: u64) -> UnsignedDecimal
Convert a chain-scaled price to human-readable.
Sourcepub fn scale_price(&self, human_value: &UnsignedDecimal) -> Result<u64, O2Error>
pub fn scale_price(&self, human_value: &UnsignedDecimal) -> Result<u64, O2Error>
Convert a human-readable price to chain-scaled integer, truncated to max_precision.
Sourcepub fn format_quantity(&self, chain_value: u64) -> UnsignedDecimal
pub fn format_quantity(&self, chain_value: u64) -> UnsignedDecimal
Convert a chain-scaled quantity to human-readable.
Sourcepub fn scale_quantity(
&self,
human_value: &UnsignedDecimal,
) -> Result<u64, O2Error>
pub fn scale_quantity( &self, human_value: &UnsignedDecimal, ) -> Result<u64, O2Error>
Convert a human-readable quantity to chain-scaled integer, truncated to max_precision.
Sourcepub fn symbol_pair(&self) -> MarketSymbol
pub fn symbol_pair(&self) -> MarketSymbol
The symbol pair, e.g. “FUEL/USDC”.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Market
impl<'de> Deserialize<'de> for Market
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Market
impl RefUnwindSafe for Market
impl Send for Market
impl Sync for Market
impl Unpin for Market
impl UnwindSafe for Market
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