use super::*;
#[derive(Copy, Clone, Eq, PartialEq, Debug, Display, Ord, PartialOrd, Deserialize, Serialize)]
#[serde(transparent)]
pub struct Sat(pub u64);
impl Sat {
pub(crate) const LAST: Self = Self(Self::SUPPLY - 1);
pub(crate) const SUPPLY: u64 = 2099999997690000;
pub(crate) fn n(self) -> u64 {
self.0
}
pub(crate) fn degree(self) -> Degree {
self.into()
}
pub(crate) fn height(self) -> Height {
self.epoch().starting_height()
+ u32::try_from(self.epoch_position() / self.epoch().subsidy()).unwrap()
}
pub(crate) fn cycle(self) -> u32 {
Epoch::from(self).0 / CYCLE_EPOCHS
}
pub(crate) fn nineball(self) -> bool {
self.n() >= 50 * COIN_VALUE * 9 && self.n() < 50 * COIN_VALUE * 10
}
pub(crate) fn percentile(self) -> String {
format!("{}%", (self.0 as f64 / Self::LAST.0 as f64) * 100.0)
}
pub(crate) fn epoch(self) -> Epoch {
self.into()
}
pub(crate) fn period(self) -> u32 {
self.height().n() / DIFFCHANGE_INTERVAL
}
pub(crate) fn third(self) -> u64 {