pub struct Price {
pub numerator: BigUint,
pub denominator: BigUint,
}Expand description
Represents a price as a fraction in the token_in -> token_out direction. With units [token_out/token_in].
§Fields
numerator- The amount of token_out (what you receive), including token decimalsdenominator- The amount of token_in (what you pay), including token decimals
In the context of swap_to_price and query_supply, this represents the pool’s price in
the token_out/token_in direction
A fraction struct is used for price to have flexibility in precision independent of the decimal precisions of the numerator and denominator tokens. This allows for:
- Exact price representation without floating-point errors
- Handling tokens with different decimal places without loss of precision
Fields§
§numerator: BigUint§denominator: BigUintImplementations§
Trait Implementations§
impl Eq for Price
impl StructuralPartialEq for Price
Auto Trait Implementations§
impl Freeze for Price
impl RefUnwindSafe for Price
impl Send for Price
impl Sync for Price
impl Unpin for Price
impl UnwindSafe for Price
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.