Skip to content

Commit

Permalink
Add compute breakdown to the indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay111meher committed Dec 4, 2024
1 parent e3f8dea commit 951fcd7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion matching_engine/src/routes/ui_routes/generators.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -41,6 +41,7 @@ struct Operator {
pending_proofs: String,
current_stake: Vec<TokenAmount>,
stake_break_down: StakeBreakDown,
compute_break_down: ComputeBreakDown,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions matching_engine/src/routes/ui_routes/single_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub struct GeneratorResponse {
my_delegations: Vec<TokenAmount>,
withdrawal_requests: Vec<WithdrawRequest>,
stake_break_down: StakeBreakDown,
compute_break_down: ComputeBreakDown,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand All @@ -116,6 +117,13 @@ pub struct StakeBreakDown {
pub available_symbiotic_stake: Vec<TokenAmount>,
}

#[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,
Expand Down Expand Up @@ -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(),
},
})
}

0 comments on commit 951fcd7

Please sign in to comment.