[−][src]Struct nash_protocol::types::exchange::OrderRate
Order rates impose limits on what trades the smart contract is allowed to execute. For example, the smart contract will reject a payload that requests a less favorable amount of asset_to than is imposed by the minimum order rate. For Sell orders, an order rate represented by currency B an in A/B market. For Buy orders, an order rate is represented in the protocol by currency A. Note that OrderRates are always created w.r.t. currency B, then potentially inverted during payload creation. This is because, unlike the smart contract, the ME always wants order prices expressed in currency B. In either case, these rates are encoded as 64 bit integers which take the initial price ratio, multiply by 10^8, and then drop all precision after the decimal.
Implementations
impl OrderRate[src]
pub fn to_be_bytes(&self) -> Result<[u8; 8]>[src]
Serialize the OrderRate to bytes for payload creation. We always use a precision of 8 and multiplication factor of 10^8
pub fn from_be_bytes(bytes: [u8; 8]) -> Result<Self>[src]
Create OrderRate from big endian bytes in Ethereum FillOrder payload
impl OrderRate[src]
pub fn to_le_bytes(&self) -> Result<[u8; 8]>[src]
Serialize the OrderRate to bytes for payload creation. We always use a precision of 8 and multiplication factor of 10^8
impl OrderRate[src]
pub fn new(str_num: &str) -> Result<Self>[src]
Construct a new OrderRate from a numerical string
pub fn from_bigdecimal(decimal: BigDecimal) -> Self[src]
Create new OrderRate from bigdecimal
pub fn invert_rate(&self, precision: Option<u32>) -> Self[src]
Invert the price to units of the other market pair. For example, if price is in terms of ETH in an ETH/USDC market, this will convert it to terms of USDC
pub fn to_bigdecimal(&self) -> BigDecimal[src]
Return a new BigDecimal based on OrderRate
pub fn subtract_fee(&self, fee: BigDecimal) -> Self[src]
Subtract fee from user by adjusting the order rate downwards. This will keep track of as much precision as BigDecimal is capable of. However, this method is exclusively used by the smart contract and will be reduced to an integer in scale of 10^8 before encoding
Trait Implementations
impl Clone for OrderRate[src]
impl Debug for OrderRate[src]
impl From<OrderRate> for Rate[src]
Enum wrappers are kind of annoying. This allows us to use .into()
on a value to generate a wrapped value. For example:
OrderRate::new("1").unwrap().into() => Rate::OrderRate(...)
impl PartialEq<OrderRate> for OrderRate[src]
impl StructuralPartialEq for OrderRate[src]
Auto Trait Implementations
impl RefUnwindSafe for OrderRate
impl Send for OrderRate
impl Sync for OrderRate
impl Unpin for OrderRate
impl UnwindSafe for OrderRate
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,