native_mint.rs 609 B

123456789101112131415161718192021222324
  1. //! The Mint that represents the native token
  2. /// There are 10^9 lamports in one SOL
  3. pub const DECIMALS: u8 = 9;
  4. // The Mint for native SOL Token accounts
  5. solana_program::declare_id!("So11111111111111111111111111111111111111112");
  6. #[cfg(test)]
  7. mod tests {
  8. use super::*;
  9. use solana_program::native_token::*;
  10. #[test]
  11. fn test_decimals() {
  12. assert!(
  13. (lamports_to_sol(42) - crate::amount_to_ui_amount(42, DECIMALS)).abs() < f64::EPSILON
  14. );
  15. assert_eq!(
  16. sol_to_lamports(42.),
  17. crate::ui_amount_to_amount(42., DECIMALS)
  18. );
  19. }
  20. }