Skip to content

Commit a36d15b

Browse files
feat(fortuna): track balance of fee manager (#2915)
1 parent 0014f7e commit a36d15b

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fortuna/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fortuna"
3-
version = "8.2.5"
3+
version = "8.2.6"
44
edition = "2021"
55

66
[lib]

apps/fortuna/src/keeper.rs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ use {
1818
},
1919
},
2020
anyhow,
21-
ethers::{signers::Signer, types::U256},
21+
ethers::{
22+
signers::{LocalWallet, Signer},
23+
types::U256,
24+
},
2225
keeper_metrics::{AccountLabel, KeeperMetrics},
23-
std::{collections::HashSet, sync::Arc},
26+
std::{collections::HashSet, str::FromStr, sync::Arc},
2427
tokio::{
2528
spawn,
2629
sync::{mpsc, RwLock},
@@ -128,7 +131,7 @@ pub async fn run_keeper_threads(
128131
None
129132
};
130133

131-
if let Some(fee_manager_private_key) = fee_manager_private_key {
134+
if let Some(fee_manager_private_key) = fee_manager_private_key.clone() {
132135
let contract_as_fee_manager = Arc::new(InstrumentedSignablePythContract::from_config(
133136
&chain_eth_config,
134137
&fee_manager_private_key,
@@ -178,13 +181,23 @@ pub async fn run_keeper_threads(
178181

179182
spawn(update_commitments_loop(contract.clone(), chain_state.clone()).in_current_span());
180183

181-
// Spawn a thread to track the provider info and the balance of the keeper
184+
// Spawn a thread to track the provider info and the balance of the keeper & fee manager
182185
spawn(
183186
async move {
184187
let chain_id = chain_state.id.clone();
185188
let chain_config = chain_eth_config.clone();
186189
let provider_address = chain_state.provider_address;
187190
let keeper_metrics = metrics.clone();
191+
let fee_manager_address_option = fee_manager_private_key.as_ref().and_then(
192+
|private_key| match LocalWallet::from_str(private_key) {
193+
Ok(wallet) => Some(wallet.address()),
194+
Err(e) => {
195+
tracing::error!("Invalid fee manager private key: {:?}", e);
196+
None
197+
}
198+
},
199+
);
200+
188201
let contract = match InstrumentedPythContract::from_config(
189202
&chain_config,
190203
chain_id.clone(),
@@ -223,10 +236,25 @@ pub async fn run_keeper_threads(
223236
)
224237
.await
225238
{
226-
tracing::error!("Error tracking balance: {:?}", e);
239+
tracing::error!("Error tracking balance for keeper: {:?}", e);
227240
continue;
228241
}
229242

243+
if let Some(fee_manager_address) = fee_manager_address_option {
244+
if fee_manager_address != keeper_address {
245+
if let Err(e) = track_balance(
246+
chain_id.clone(),
247+
contract.client(),
248+
fee_manager_address,
249+
keeper_metrics.clone(),
250+
)
251+
.await
252+
{
253+
tracing::error!("Error tracking balance for fee manager: {:?}", e);
254+
continue;
255+
}
256+
}
257+
}
230258
if let Err(e) = track_accrued_pyth_fees(
231259
chain_id.clone(),
232260
contract.clone(),

0 commit comments

Comments
 (0)