diff --git a/src/db/cauldron/tokenlist/token_utils.rs b/src/db/cauldron/tokenlist/token_utils.rs index 0245b63..030868d 100644 --- a/src/db/cauldron/tokenlist/token_utils.rs +++ b/src/db/cauldron/tokenlist/token_utils.rs @@ -55,9 +55,9 @@ pub fn dec_to_f64_bounded(d: Decimal) -> f64 { } pub const SATS_PER_BCH: i64 = 100_000_000; -/// On-chain Delphi oracle scale: prices are stored as price * 1_000_000 -/// (e.g. $384.24 → 384_240_000). -pub const ORACLE_SCALE: i64 = 1_000_000; +/// On-chain Delphi oracle scale: prices are stored in cents +/// (e.g. $384.24 → 38424). Same unit as the oracles.cash feed. +pub const ORACLE_SCALE: i64 = 100; /// Timestamps before this value are looked up in the on-chain Delphi indexed table. /// Timestamps on or after are looked up in the oracle_cash table (oracles.cash feed). /// Value: 2026-04-23 00:00:00 UTC (last reliable Delphi oracle update). @@ -76,8 +76,7 @@ pub async fn usd_per_bch_at_or_before(oracle_pool: &SqlitePool, ts: i64) -> Deci // oracles.cash prices are in cents; divide by 100 to get USD/BCH match get_oracle_cash_closest(oracle_pool, ts).await { Ok(Some(e)) => { - Decimal::from_i64(e.oracle_price).unwrap_or(Decimal::ZERO) - / Decimal::from(100) + Decimal::from_i64(e.oracle_price).unwrap_or(Decimal::ZERO) / Decimal::from(100) } _ => Decimal::ZERO, }