From 951fcd7615ad77787c4232f819cb8fde286c8d1c Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 4 Dec 2024 08:17:06 +0000 Subject: [PATCH] Add compute breakdown to the indexer --- .../src/routes/ui_routes/generators.rs | 11 ++++++++++- .../src/routes/ui_routes/single_generator.rs | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/matching_engine/src/routes/ui_routes/generators.rs b/matching_engine/src/routes/ui_routes/generators.rs index fed9905..4b16b07 100644 --- a/matching_engine/src/routes/ui_routes/generators.rs +++ b/matching_engine/src/routes/ui_routes/generators.rs @@ -1,5 +1,5 @@ use super::cache::CachedResponse; -use super::single_generator::StakeBreakDown; +use super::single_generator::{ComputeBreakDown, StakeBreakDown}; use crate::generator_lib::generator_store::{GeneratorMeta, GeneratorStore}; use crate::generator_lib::native_stake_store::NativeStakingStore; use crate::generator_lib::symbiotic_stake_store::SymbioticStakeStore; @@ -41,6 +41,7 @@ struct Operator { pending_proofs: String, current_stake: Vec, stake_break_down: StakeBreakDown, + compute_break_down: ComputeBreakDown, } #[derive(Serialize, Deserialize, Debug, Clone)] @@ -206,6 +207,14 @@ async fn recompute_generator_response<'a>( - operator_data.symbiotic_stake_locked) .to_token_amount(), }, + compute_break_down: ComputeBreakDown { + total_compute: operator_data.declared_compute.to_string(), + compute_locked: operator_data.compute_consumed.to_string(), + compute_available: (operator_data + .declared_compute + .saturating_sub(operator_data.compute_consumed)) + .to_string(), + }, }; result.push(operator); diff --git a/matching_engine/src/routes/ui_routes/single_generator.rs b/matching_engine/src/routes/ui_routes/single_generator.rs index 48cc532..ca1084c 100644 --- a/matching_engine/src/routes/ui_routes/single_generator.rs +++ b/matching_engine/src/routes/ui_routes/single_generator.rs @@ -104,6 +104,7 @@ pub struct GeneratorResponse { my_delegations: Vec, withdrawal_requests: Vec, stake_break_down: StakeBreakDown, + compute_break_down: ComputeBreakDown, } #[derive(Serialize, Deserialize, Debug, Clone)] @@ -116,6 +117,13 @@ pub struct StakeBreakDown { pub available_symbiotic_stake: Vec, } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct ComputeBreakDown { + pub total_compute: String, + pub compute_locked: String, + pub compute_available: String, +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct WithdrawRequest { account: String, @@ -525,5 +533,13 @@ async fn recompute_single_generator_response<'a>( index: a.index.to_string(), }) .collect(), + compute_break_down: ComputeBreakDown { + total_compute: generator_data.declared_compute.to_string(), + compute_locked: generator_data.compute_consumed.to_string(), + compute_available: (generator_data + .declared_compute + .saturating_sub(generator_data.compute_consumed)) + .to_string(), + }, }) }