native_mint.rs 595 B

1234567891011121314151617181920212223
  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_pubkey::declare_id!("So11111111111111111111111111111111111111112");
  6. #[cfg(test)]
  7. mod tests {
  8. use {super::*, solana_native_token::*};
  9. #[test]
  10. fn test_decimals() {
  11. assert!(
  12. (lamports_to_sol(42) - crate::amount_to_ui_amount(42, DECIMALS)).abs() < f64::EPSILON
  13. );
  14. assert_eq!(
  15. sol_to_lamports(42.),
  16. crate::ui_amount_to_amount(42., DECIMALS)
  17. );
  18. }
  19. }