lib.rs 934 B

123456789101112131415161718192021222324252627282930
  1. #![deny(missing_docs)]
  2. #![forbid(unsafe_code)]
  3. //! An ERC20-like Token program for the Solana blockchain
  4. pub mod entrypoint;
  5. pub mod error;
  6. pub mod instruction;
  7. pub mod native_mint;
  8. pub mod option;
  9. pub mod pack;
  10. pub mod processor;
  11. pub mod state;
  12. // Export current solana-sdk types for downstream users who may also be building with a different
  13. // solana-sdk version
  14. pub use solana_sdk;
  15. /// Convert the UI representation of a token amount (using the decimals field defined in its mint)
  16. /// to the raw amount
  17. pub fn ui_amount_to_amount(ui_amount: f64, decimals: u8) -> u64 {
  18. (ui_amount * 10_usize.pow(decimals as u32) as f64) as u64
  19. }
  20. /// Convert a raw amount to its UI representation (using the decimals field defined in its mint)
  21. pub fn amount_to_ui_amount(amount: u64, decimals: u8) -> f64 {
  22. amount as f64 / 10_usize.pow(decimals as u32) as f64
  23. }
  24. solana_sdk::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");