mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-19 06:58:11 -07:00
docs: update generated docs
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
use brk_types::{Close, Dollars, SatsFract};
|
||||
use vecdb::UnaryTransform;
|
||||
|
||||
/// Dollars -> SatsFract (exchange rate: sats per dollar at this price level)
|
||||
/// Formula: sats = 100_000_000 / usd_price
|
||||
pub struct DollarsToSatsFract;
|
||||
|
||||
impl UnaryTransform<Dollars, SatsFract> for DollarsToSatsFract {
|
||||
#[inline(always)]
|
||||
fn apply(usd: Dollars) -> SatsFract {
|
||||
let usd_f64 = f64::from(usd);
|
||||
if usd_f64 == 0.0 {
|
||||
SatsFract::NAN
|
||||
} else {
|
||||
SatsFract::from(SatsFract::SATS_PER_BTC / usd_f64)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Close<Dollars> -> SatsFract
|
||||
pub struct CloseDollarsToSatsFract;
|
||||
|
||||
impl UnaryTransform<Close<Dollars>, SatsFract> for CloseDollarsToSatsFract {
|
||||
#[inline(always)]
|
||||
fn apply(usd: Close<Dollars>) -> SatsFract {
|
||||
DollarsToSatsFract::apply(*usd)
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vecdb::{CheckedSub, Formattable, Pco};
|
||||
|
||||
use crate::{Close, Dollars};
|
||||
|
||||
/// Fractional satoshis (f64) - for representing USD prices in sats
|
||||
///
|
||||
/// Formula: `sats_fract = usd_value * 100_000_000 / btc_price`
|
||||
|
||||
Reference in New Issue
Block a user