diff --git a/src/data.rs b/src/data.rs index 1fd236c..dc6dcc0 100644 --- a/src/data.rs +++ b/src/data.rs @@ -27,6 +27,7 @@ pub struct Dashboard { pub outbound: u16, // price & market pub supply: String, + pub supply_raw: String, pub soft_supply: String, pub inflation: String, pub price_usd: String, @@ -65,6 +66,7 @@ impl Dashboard { inbound: 0, outbound: 0, supply: String::new(), + supply_raw: String::new(), soft_supply: String::new(), inflation: String::new(), price_usd: String::new(), diff --git a/src/main.rs b/src/main.rs index b54af23..e76cc43 100644 --- a/src/main.rs +++ b/src/main.rs @@ -487,6 +487,14 @@ fn market_supply(dashboard: &State>>) -> String { } +#[get("/rpc/market/supply_raw")] +fn supply_raw(dashboard: &State>>) -> String { + let data = dashboard.lock().unwrap(); + + data.supply_raw.clone() +} + + #[get("/rpc/market/soft_supply")] fn soft_supply(dashboard: &State>>) -> String { let data = dashboard.lock().unwrap(); @@ -962,7 +970,7 @@ async fn main() { soft_supply, production_cost, reward_ratio, breakeven_cost, last_block_age, block_list_by_height, block_list_index, search, kernel, output, api_owner, api_foreign, stats, unspent_outputs, kernels, - emission, api_overview, donate]) + emission, api_overview, donate, supply_raw]) .mount("/static", FileServer::from("static")) .attach(Template::custom(|engines| {engines.tera.register_filter("separate_with_commas", separate_with_commas)})) .launch() diff --git a/src/requests.rs b/src/requests.rs index 2afcde9..e3548aa 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -210,8 +210,9 @@ pub async fn get_market(dashboard: Arc>) -> Result<(), anyhow:: // 31536000 seconds in a year let inflation = (31536000.0 / (supply as f64)) * 100.0; - data.inflation = format!("{:.2}", inflation); - data.supply = supply.to_formatted_string(&Locale::en); + data.inflation = format!("{:.2}", inflation); + data.supply_raw = supply.to_string(); + data.supply = supply.to_formatted_string(&Locale::en); // https://john-tromp.medium.com/a-case-for-using-soft-total-supply-1169a188d153 data.soft_supply = format!("{:.2}", supply.to_string().parse::().unwrap() / 3150000000.0 * 100.0); diff --git a/templates/api_overview.html.tera b/templates/api_overview.html.tera index eda6709..0d11f44 100644 --- a/templates/api_overview.html.tera +++ b/templates/api_overview.html.tera @@ -50,6 +50,7 @@
https://grincoin.org/rpc/block/latest
https://grincoin.org/rpc/market/supply
+ https://grincoin.org/rpc/market/supply_raw
https://grincoin.org/rpc/network/hashrate
https://grincoin.org/rpc/network/difficulty