diff --git a/src/entities/ether.rs b/src/entities/ether.rs index cefa4c2..5549810 100644 --- a/src/entities/ether.rs +++ b/src/entities/ether.rs @@ -4,6 +4,8 @@ use crate::prelude::*; /// Represents the native currency of the blockchain. pub type Ether = CurrencyLike>; +impl NativeCurrency for Ether {} + impl Currency for Ether { /// Retrieves the address associated with the currency. #[inline] diff --git a/src/entities/mod.rs b/src/entities/mod.rs index fbd5c8a..6e0c6df 100644 --- a/src/entities/mod.rs +++ b/src/entities/mod.rs @@ -2,5 +2,6 @@ pub mod base_currency; pub mod currency; pub mod ether; pub mod fractions; +pub mod native_currency; pub mod token; pub mod weth9; diff --git a/src/entities/native_currency.rs b/src/entities/native_currency.rs new file mode 100644 index 0000000..3691e05 --- /dev/null +++ b/src/entities/native_currency.rs @@ -0,0 +1,12 @@ +use crate::prelude::*; + +/// Represents the native currency of the chain on which it resides +pub trait NativeCurrency: Currency { + fn is_native(&self) -> bool { + true + } + + fn is_token(&self) -> bool { + false + } +} diff --git a/src/prelude.rs b/src/prelude.rs index 2be0562..0838304 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -11,6 +11,7 @@ pub use crate::{ percent::Percent, price::Price, }, + native_currency::NativeCurrency, token::Token, weth9::WETH9, },