@@ -10,7 +10,7 @@ use crate::{
1010 } ,
1111 wrappers:: liquidator_account:: LiquidatorAccount ,
1212} ;
13- use log:: { error, info} ;
13+ use log:: { error, info, warn } ;
1414use solana_client:: rpc_client:: RpcClient ;
1515use solana_sdk:: { signature:: Keypair , signer:: Signer } ;
1616use std:: {
@@ -34,7 +34,12 @@ pub fn run_liquidator(config: Eva01Config, stop_liquidator: Arc<AtomicBool>) ->
3434 let mut clock_manager = ClockManager :: new ( clock. clone ( ) , config. rpc_url . clone ( ) ) ?;
3535
3636 info ! ( "Loading Cache..." ) ;
37- let mut cache = Cache :: new ( wallet_pubkey, config. marginfi_group_key , clock. clone ( ) ) ;
37+ let mut cache = Cache :: new (
38+ wallet_pubkey,
39+ config. marginfi_group_key ,
40+ clock. clone ( ) ,
41+ config. excluded_liquidation_mints . iter ( ) . copied ( ) . collect ( ) ,
42+ ) ;
3843
3944 let cache_loader = CacheLoader :: new (
4045 & config. wallet_keypair ,
@@ -69,38 +74,46 @@ pub fn run_liquidator(config: Eva01Config, stop_liquidator: Arc<AtomicBool>) ->
6974 cache. clone ( ) ,
7075 ) ?;
7176
77+ let swb_fetcher_tx = geyser_tx. clone ( ) ;
78+ let integration_fetcher_tx = geyser_tx. clone ( ) ;
79+
7280 let geyser_service = GeyserService :: new (
7381 config,
7482 accounts_to_track,
7583 geyser_tx,
7684 stop_liquidator. clone ( ) ,
7785 ) ?;
7886
79- let swb_fetcher_cache = cache. clone ( ) ;
80- let swb_fetcher_stop = stop_liquidator. clone ( ) ;
81- let integration_fetcher_cache = cache. clone ( ) ;
82- let integration_fetcher_stop = stop_liquidator. clone ( ) ;
87+ let swb_fetcher = SwbPriceFetcher :: new (
88+ swb_fetcher_api_url,
89+ swb_fetcher_crossbar_url,
90+ cache. clone ( ) ,
91+ swb_fetcher_tx,
92+ stop_liquidator. clone ( ) ,
93+ ) ;
94+ let integration_fetcher = IntegrationAccountFetcher :: new (
95+ integration_fetcher_rpc_url,
96+ cache. clone ( ) ,
97+ integration_fetcher_tx,
98+ stop_liquidator. clone ( ) ,
99+ ) ;
83100
84- info ! ( "Starting services..." ) ;
101+ // Prime both fetchers before any service runs: the accounts they own are loaded from chain in
102+ // a state marginfi rejects as stale (Switchboard feeds, Kamino reserves, JupLend lending
103+ // states), so anything pricing a bank before their first cycle — the Liquidator's initial scan
104+ // above all — fails on staleness instead of evaluating the account.
105+ info ! ( "Priming the fetcher-owned accounts..." ) ;
106+ if let Err ( e) = integration_fetcher. fetch_and_update ( ) {
107+ warn ! ( "Failed to prime the integration accounts: {:?}" , e) ;
108+ }
109+ if let Err ( e) = swb_fetcher. fetch_and_update ( ) {
110+ warn ! ( "Failed to prime the Switchboard prices: {:?}" , e) ;
111+ }
85112
86- thread:: spawn ( move || {
87- SwbPriceFetcher :: new (
88- swb_fetcher_api_url,
89- swb_fetcher_crossbar_url,
90- swb_fetcher_cache,
91- swb_fetcher_stop,
92- )
93- . start ( ) ;
94- } ) ;
113+ info ! ( "Starting services..." ) ;
95114
96- thread:: spawn ( move || {
97- IntegrationAccountFetcher :: new (
98- integration_fetcher_rpc_url,
99- integration_fetcher_cache,
100- integration_fetcher_stop,
101- )
102- . start ( ) ;
103- } ) ;
115+ thread:: spawn ( move || swb_fetcher. start ( ) ) ;
116+ thread:: spawn ( move || integration_fetcher. start ( ) ) ;
104117
105118 let cloned_stop = stop_liquidator. clone ( ) ;
106119 thread:: spawn ( move || clock_manager. start ( cloned_stop) ) ;
0 commit comments