typed_money/currency/
comp.rs1use super::{Currency, CurrencyType, LiquidityRating, SymbolPosition, VolatilityRating};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
20pub struct COMP;
21
22impl Currency for COMP {
23 const DECIMALS: u8 = 18;
24 const CODE: &'static str = "COMP";
25 const SYMBOL: &'static str = "COMP";
26
27 const NAME: &'static str = "Compound";
29 const COUNTRY: &'static str = "Global";
30 const REGION: &'static str = "Worldwide";
31 const CURRENCY_TYPE: CurrencyType = CurrencyType::Cryptocurrency;
32 const IS_MAJOR: bool = false;
33 const IS_STABLE: bool = false;
34 const INTRODUCED_YEAR: u16 = 2020;
35 const ISO_4217_NUMBER: u16 = 0; const THOUSANDS_SEPARATOR: char = ',';
37 const DECIMAL_SEPARATOR: char = '.';
38 const SYMBOL_POSITION: SymbolPosition = SymbolPosition::After;
39 const SPACE_BETWEEN: bool = true;
40 const VOLATILITY_RATING: VolatilityRating = VolatilityRating::High;
41 const LIQUIDITY_RATING: LiquidityRating = LiquidityRating::Medium;
42}
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47 use crate::Amount;
48
49 #[test]
50 fn test_comp_currency_properties() {
51 assert_eq!(COMP::DECIMALS, 18);
52 assert_eq!(COMP::CODE, "COMP");
53 assert_eq!(COMP::SYMBOL, "COMP");
54 }
55
56 #[test]
57 fn test_comp_amount_creation() {
58 let amount = Amount::<COMP>::from_major(10);
59 assert_eq!(amount.to_major_floor(), 10);
60 }
61
62 #[test]
63 fn test_comp_amount_with_wei() {
64 let amount = Amount::<COMP>::from_minor(1_000_000_000_000_000_000); assert_eq!(amount.to_major_floor(), 1);
66 assert_eq!(amount.to_minor(), 1_000_000_000_000_000_000);
67 }
68}