Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion jito-bell/src/event_parser/jito_steward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use solana_pubkey::Pubkey;

use crate::events::jito_steward::{
AutoAddValidatorEvent, AutoRemoveValidatorEvent, DecreaseComponents, EpochMaintenanceEvent,
InstantUnstakeComponents, RebalanceEvent, ScoreComponents, StateTransition,
InstantUnstakeComponents, RebalanceDirectedEvent, RebalanceEvent, ScoreComponents,
StateTransition,
};

const PROGRAM_LOG: &str = "Program log: ";
Expand All @@ -20,6 +21,7 @@ pub enum JitoStewardEvent {
EpochMaintenance(EpochMaintenanceEvent),
StateTransition(StateTransition),
Rebalance(RebalanceEvent),
RebalanceDirected(RebalanceDirectedEvent),
DecreaseComponents(DecreaseComponents),
ScoreComponents(ScoreComponents),
InstantUnstake(InstantUnstakeComponents),
Expand All @@ -33,6 +35,7 @@ impl std::fmt::Display for JitoStewardEvent {
JitoStewardEvent::EpochMaintenance(_) => write!(f, "epoch_maintenance"),
JitoStewardEvent::StateTransition(_) => write!(f, "state_transition"),
JitoStewardEvent::Rebalance(_) => write!(f, "rebalance"),
JitoStewardEvent::RebalanceDirected(_) => write!(f, "rebalance_directed"),
JitoStewardEvent::DecreaseComponents(_) => write!(f, "decrease_components"),
JitoStewardEvent::ScoreComponents(_) => write!(f, "score_components"),
JitoStewardEvent::InstantUnstake(_) => write!(f, "instant_unstake"),
Expand Down Expand Up @@ -112,6 +115,14 @@ impl JitoStewardEvent {
}
}

// RebalanceDirectedEvent
if discriminator == RebalanceDirectedEvent::DISCRIMINATOR {
match RebalanceDirectedEvent::try_from_slice(event_data) {
Ok(event) => return Some(JitoStewardEvent::RebalanceDirected(event)),
Err(e) => debug!("Failed to deserialize RebalanceDirectedEvent: {e}"),
}
}

// DecreaseComponents
if discriminator == DecreaseComponents::DISCRIMINATOR {
match DecreaseComponents::try_from_slice(event_data) {
Expand Down
13 changes: 13 additions & 0 deletions jito-bell/src/events/jito_steward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ pub enum RebalanceTypeTag {
Decrease,
}

#[derive(Debug, Clone, BorshDeserialize)]
pub struct RebalanceDirectedEvent {
pub vote_account: Pubkey,
pub epoch: u16,
pub rebalance_type_tag: RebalanceTypeTag,
pub increase_lamports: u64,
pub decrease_components: DecreaseComponents,
}

impl RebalanceDirectedEvent {
pub const DISCRIMINATOR: [u8; 8] = [120, 27, 117, 235, 104, 42, 132, 75];
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will change the discriminator

}

/// Deprecated: This struct is no longer emitted but is kept to allow parsing of old events.
/// Because the event discriminator is based on struct name, it's important to rename the struct if
/// fields are changed.
Expand Down
36 changes: 36 additions & 0 deletions jito-bell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,42 @@ impl JitoBellHandler {

(desc, Some(amount_sol), Some("SOL"))
}
JitoStewardEvent::RebalanceDirected(rebalance) => {
let (change_type, amount_lamports) =
if rebalance.increase_lamports > 0 {
("Stake Increase", rebalance.increase_lamports)
} else {
(
"Stake Decrease",
rebalance.decrease_components.total_unstake_lamports,
)
};

let amount_sol = amount_lamports as f64 / 1_000_000_000.0;
let type_emoji = if rebalance.increase_lamports > 0 {
"📈"
} else {
"📉"
};

let validator_short =
self.shorten_pubkey(&rebalance.vote_account.to_string(), 4, 4);

let desc = format!(
"{} *{}* | {:.2} SOL\n\
\n\
Validator: `{}`\n\
Epoch: {} | Type: {:?}",
type_emoji,
change_type,
amount_sol,
validator_short,
rebalance.epoch,
rebalance.rebalance_type_tag
);

(desc, Some(amount_sol), Some("SOL"))
}
_ => {
debug!("Unhandled event type: {:?}", jito_steward_event);
("Unknown event".to_string(), None, None)
Expand Down
19 changes: 19 additions & 0 deletions jito_bell_config_sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ programs:
description: "Whale rebalance detected"
destinations: ["stake_pool_alerts_slack"]

rebalance_directed:
thresholds:
- value: 1.0 # SOL (minimum to notify)
notification:
description: "Small rebalance detected"
destinations: ["stake_pool_alerts_slack"]
- value: 100.0 # SOL
notification:
description: "Medium rebalance detected"
destinations: ["stake_pool_alerts_slack"]
- value: 1000.0 # SOL
notification:
description: "Large rebalance detected"
destinations: ["stake_pool_alerts_slack"]
- value: 10000.0 # SOL
notification:
description: "Whale rebalance detected"
destinations: ["stake_pool_alerts_slack"]

epoch_maintenance:
destinations: ["stake_pool_alerts_slack"]
description: "Epoch maintenance completed"
Expand Down
Loading