balancer_maths_rust/common/
constants.rs

1//! Mathematical constants used throughout the Balancer maths implementation
2
3use lazy_static::lazy_static;
4use num_bigint::BigInt;
5use std::str::FromStr;
6
7lazy_static! {
8    /// WAD (1e18) - used for fixed-point arithmetic
9    pub static ref WAD: BigInt = BigInt::from(1_000_000_000_000_000_000u64);
10
11    /// TWO_WAD (2e18) - used for power calculations
12    pub static ref TWO_WAD: BigInt = BigInt::from(2_000_000_000_000_000_000u64);
13
14    /// FOUR_WAD (4e18) - used for power calculations
15    pub static ref FOUR_WAD: BigInt = BigInt::from(4_000_000_000_000_000_000u64);
16
17    /// MAX_POW_RELATIVE_ERROR - used for power calculations
18    pub static ref MAX_POW_RELATIVE_ERROR: BigInt = BigInt::from(10_000u64);
19
20    // RAY constant for 36 decimal precision
21    pub static ref RAY: BigInt = BigInt::from_str("1000000000000000000000000000000000000").unwrap();
22}