Skip to content

Commit

Permalink
feat(bolt-cli): log if operators have collateral
Browse files Browse the repository at this point in the history
  • Loading branch information
estensen committed Dec 11, 2024
1 parent 16152bd commit 59c80b1
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 1 deletion.
139 changes: 138 additions & 1 deletion bolt-cli/src/commands/operators.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloy::{
network::EthereumWallet,
node_bindings::WEI_IN_ETHER,
primitives::{utils::format_ether, Bytes},
primitives::{utils::format_ether, Bytes, Uint},
providers::{Provider, ProviderBuilder, WalletProvider},
signers::{local::PrivateKeySigner, SignerSync},
sol_types::SolInterface,
Expand Down Expand Up @@ -254,6 +254,69 @@ impl OperatorsCommand {
warn!(?address, "Operator not registered");
}

// Check if operator has collateral
let mut total_collateral = Uint::from(0);
// Check r_eth
let stake = bolt_manager
.getOperatorStake(address, deployments.collateral.r_eth)
.call()
.await?
._0;
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token="r_eth", amount=?stake, "Operator has collateral");
}

// Check st_eth
let stake = bolt_manager
.getOperatorStake(address, deployments.collateral.st_eth)
.call()
.await?
._0;
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token="st_eth", amount=?stake, "Operator has collateral");
}

// Check w_eth
let stake = bolt_manager
.getOperatorStake(address, deployments.collateral.w_eth)
.call()
.await?
._0;
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token="w_eth", amount=?stake, "Operator has collateral");
}

// Check cb_eth
let stake = bolt_manager
.getOperatorStake(address, deployments.collateral.cb_eth)
.call()
.await?
._0;
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token="cb_eth", amount=?stake, "Operator has collateral");
}

// Check m_eth
let stake = bolt_manager
.getOperatorStake(address, deployments.collateral.m_eth)
.call()
.await?
._0;
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token="m_eth", amount=?stake, "Operator has collateral");
}

if total_collateral > Uint::from(0) {
info!(?address, total_collateral=?total_collateral, "Operator has collateral");
} else {
warn!(?address, "Operator has no collateral");
}

Ok(())
}
},
Expand Down Expand Up @@ -400,6 +463,80 @@ impl OperatorsCommand {
warn!(?address, "Operator not registered");
}

// Check if operator has collateral
let mut total_collateral = Uint::from(0);
// Check wst_eth
let stake = bolt_manager
.getOperatorStake(address, deployments.collateral.wst_eth)
.call()
.await?
._0;
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token="wst_eth", amount=?stake, "Operator has collateral");
}

// Check r_eth
let stake = bolt_manager
.getOperatorStake(address, deployments.collateral.r_eth)
.call()
.await?
._0;
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token="r_eth", amount=?stake, "Operator has collateral");
}

// Check st_eth
let stake = bolt_manager
.getOperatorStake(address, deployments.collateral.st_eth)
.call()
.await?
._0;
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token="st_eth", amount=?stake, "Operator has collateral");
}

// Check w_eth
let stake = bolt_manager
.getOperatorStake(address, deployments.collateral.w_eth)
.call()
.await?
._0;
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token="w_eth", amount=?stake, "Operator has collateral");
}

// Check cb_eth
let stake = bolt_manager
.getOperatorStake(address, deployments.collateral.cb_eth)
.call()
.await?
._0;
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token="cb_eth", amount=?stake, "Operator has collateral");
}

// Check m_eth
let stake = bolt_manager
.getOperatorStake(address, deployments.collateral.m_eth)
.call()
.await?
._0;
if stake > Uint::from(0) {
total_collateral += stake;
info!(?address, token="m_eth", amount=?stake, "Operator has collateral");
}

if total_collateral > Uint::from(0) {
info!(?address, total_collateral=?total_collateral, "Operator has collateral");
} else {
warn!(?address, "Operator has no collateral");
}

Ok(())
}
},
Expand Down
1 change: 1 addition & 0 deletions bolt-cli/src/common/bolt_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ sol! {
function getProposerStatus(bytes32 pubkeyHash) external view returns (ProposerStatus memory);

function isOperator(address operator) public view returns (bool);
function getOperatorStake(address operator, address collateral) public view returns (uint256);

error InvalidQuery();
error ValidatorDoesNotExist();
Expand Down
1 change: 1 addition & 0 deletions bolt-cli/src/contracts/eigenlayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,6 @@ sol! {
function registerAsOperator(OperatorDetails calldata registeringOperatorDetails, string calldata metadataURI) external;

function isOperator(address operator) public view returns (bool);
function hasCollateral(address operator) public view returns (bool);
}
}
19 changes: 19 additions & 0 deletions bolt-cli/src/contracts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct Contracts {
pub bolt: Bolt,
pub symbiotic: Symbiotic,
pub eigen_layer: EigenLayer,
pub collateral: Token,
}

#[derive(Clone, Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -69,6 +70,16 @@ pub enum EigenLayerStrategy {
MEth,
}

#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct Token {
pub wst_eth: Address,
pub r_eth: Address,
pub st_eth: Address,
pub w_eth: Address,
pub cb_eth: Address,
pub m_eth: Address,
}

impl std::fmt::Display for EigenLayerStrategy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let output = match self {
Expand Down Expand Up @@ -145,4 +156,12 @@ const HOLESKY_DEPLOYMENTS: Contracts = Contracts {
m_eth: address!("accc5A86732BE85b5012e8614AF237801636F8e5"),
},
},
collateral: Token {
wst_eth: address!("8d09a4502Cc8Cf1547aD300E066060D043f6982D"),
r_eth: address!("7322c24752f79c05FFD1E2a6FCB97020C1C264F1"),
st_eth: address!("3F1c547b21f65e10480dE3ad8E19fAAC46C95034"),
w_eth: address!("94373a4919B3240D86eA41593D5eBa789FEF3848"),
cb_eth: address!("8720095Fa5739Ab051799211B146a2EEE4Dd8B37"),
m_eth: address!("e3C063B1BEe9de02eb28352b55D49D85514C67FF"),
},
};

0 comments on commit 59c80b1

Please sign in to comment.