Struct nash_protocol::types::exchange::OrderRate[][src]

pub struct OrderRate { /* fields omitted */ }
Expand description

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

Serialize the OrderRate to bytes for payload creation. We always use a precision of 8 and multiplication factor of 10^8

Create OrderRate from big endian bytes in Ethereum FillOrder payload

Serialize the OrderRate to bytes for payload creation. We always use a precision of 8 and multiplication factor of 10^8

Construct a new OrderRate from a numerical string

Create new OrderRate from bigdecimal

Round the price in the specified precision.

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

Return a new BigDecimal based on OrderRate

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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(...)

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more