pub struct FixedPoint(pub i64);Expand description
Fixed-point decimal representation using i64 with 8 decimal precision
This avoids floating point rounding errors while maintaining performance. All prices and volumes are stored as integers scaled by SCALE (1e8).
Example:
- 50000.12345678 → 5000012345678
- 1.5 → 150000000
Tuple Fields§
§0: i64Implementations§
Source§impl FixedPoint
impl FixedPoint
Sourcepub fn from_str(s: &str) -> Result<Self, FixedPointError>
pub fn from_str(s: &str) -> Result<Self, FixedPointError>
Sourcepub fn to_string(&self) -> String
pub fn to_string(&self) -> String
Convert FixedPoint to string representation with 8 decimal places
Sourcepub fn compute_range_thresholds(
&self,
threshold_bps: u32,
) -> (FixedPoint, FixedPoint)
pub fn compute_range_thresholds( &self, threshold_bps: u32, ) -> (FixedPoint, FixedPoint)
Compute range thresholds for given basis points
§Arguments
threshold_bps- Threshold in tenths of basis points (0.1bps units)- Example:
250→ 25bps = 0.25% - Example:
10→ 1bps = 0.01% - Minimum:
1→ 0.1bps = 0.001%
- Example:
§Returns
Tuple of (upper_threshold, lower_threshold)
§Breaking Change (v3.0.0)
Prior to v3.0.0, threshold_bps was in 1bps units.
Migration: Multiply all threshold values by 10.
Trait Implementations§
Source§impl Clone for FixedPoint
impl Clone for FixedPoint
Source§fn clone(&self) -> FixedPoint
fn clone(&self) -> FixedPoint
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FixedPoint
impl Debug for FixedPoint
Source§impl<'de> Deserialize<'de> for FixedPoint
impl<'de> Deserialize<'de> for FixedPoint
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
Source§impl Display for FixedPoint
impl Display for FixedPoint
Source§impl FromStr for FixedPoint
impl FromStr for FixedPoint
Source§impl Ord for FixedPoint
impl Ord for FixedPoint
Source§fn cmp(&self, other: &FixedPoint) -> Ordering
fn cmp(&self, other: &FixedPoint) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for FixedPoint
impl PartialEq for FixedPoint
Source§impl PartialOrd for FixedPoint
impl PartialOrd for FixedPoint
Source§impl Serialize for FixedPoint
impl Serialize for FixedPoint
impl Copy for FixedPoint
impl Eq for FixedPoint
impl StructuralPartialEq for FixedPoint
Auto Trait Implementations§
impl Freeze for FixedPoint
impl RefUnwindSafe for FixedPoint
impl Send for FixedPoint
impl Sync for FixedPoint
impl Unpin for FixedPoint
impl UnwindSafe for FixedPoint
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