|
18 | 18 | },
|
19 | 19 | },
|
20 | 20 | anyhow,
|
21 |
| - ethers::{signers::Signer, types::U256}, |
| 21 | + ethers::{ |
| 22 | + signers::{LocalWallet, Signer}, |
| 23 | + types::U256, |
| 24 | + }, |
22 | 25 | keeper_metrics::{AccountLabel, KeeperMetrics},
|
23 |
| - std::{collections::HashSet, sync::Arc}, |
| 26 | + std::{collections::HashSet, str::FromStr, sync::Arc}, |
24 | 27 | tokio::{
|
25 | 28 | spawn,
|
26 | 29 | sync::{mpsc, RwLock},
|
@@ -128,7 +131,7 @@ pub async fn run_keeper_threads(
|
128 | 131 | None
|
129 | 132 | };
|
130 | 133 |
|
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() { |
132 | 135 | let contract_as_fee_manager = Arc::new(InstrumentedSignablePythContract::from_config(
|
133 | 136 | &chain_eth_config,
|
134 | 137 | &fee_manager_private_key,
|
@@ -178,13 +181,23 @@ pub async fn run_keeper_threads(
|
178 | 181 |
|
179 | 182 | spawn(update_commitments_loop(contract.clone(), chain_state.clone()).in_current_span());
|
180 | 183 |
|
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 |
182 | 185 | spawn(
|
183 | 186 | async move {
|
184 | 187 | let chain_id = chain_state.id.clone();
|
185 | 188 | let chain_config = chain_eth_config.clone();
|
186 | 189 | let provider_address = chain_state.provider_address;
|
187 | 190 | 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 | + |
188 | 201 | let contract = match InstrumentedPythContract::from_config(
|
189 | 202 | &chain_config,
|
190 | 203 | chain_id.clone(),
|
@@ -223,10 +236,25 @@ pub async fn run_keeper_threads(
|
223 | 236 | )
|
224 | 237 | .await
|
225 | 238 | {
|
226 |
| - tracing::error!("Error tracking balance: {:?}", e); |
| 239 | + tracing::error!("Error tracking balance for keeper: {:?}", e); |
227 | 240 | continue;
|
228 | 241 | }
|
229 | 242 |
|
| 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 | + } |
230 | 258 | if let Err(e) = track_accrued_pyth_fees(
|
231 | 259 | chain_id.clone(),
|
232 | 260 | contract.clone(),
|
|
0 commit comments