From a773f1ef73c8c2301fe14e3d9704f52bc921a306 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Sat, 6 Jan 2024 14:53:21 -0800 Subject: [PATCH] Persist exchange account name in deposit address --- src/db.rs | 6 +++--- src/main.rs | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/db.rs b/src/db.rs index 88bce70..54fe8b0 100644 --- a/src/db.rs +++ b/src/db.rs @@ -749,16 +749,16 @@ impl Db { Ok(()) } - pub fn get_default_accounts_from_all_configured_exchanges( + pub fn get_default_accounts_from_configured_exchanges( &self, - ) -> Vec<(Exchange, ExchangeCredentials)> { + ) -> Vec<(Exchange, ExchangeCredentials, String)> { self.credentials_db .get_all() .into_iter() .filter_map(|key| { if let Ok(exchange) = key.parse() { self.get_exchange_credentials(exchange, "") - .map(|exchange_credentials| (exchange, exchange_credentials)) + .map(|exchange_credentials| (exchange, exchange_credentials, "".into())) } else { None } diff --git a/src/main.rs b/src/main.rs index c333781..b633844 100644 --- a/src/main.rs +++ b/src/main.rs @@ -128,6 +128,7 @@ async fn get_block_date_and_price( fn add_exchange_deposit_address_to_db( db: &mut Db, exchange: Exchange, + exchange_account: &str, token: MaybeToken, deposit_address: Pubkey, rpc_client: &RpcClient, @@ -137,7 +138,7 @@ fn add_exchange_deposit_address_to_db( db.add_account(TrackedAccount { address: deposit_address, token, - description: format!("{exchange:?}"), + description: format!("{exchange:?} {exchange_account}"), last_update_epoch: epoch, last_update_balance: 0, lots: vec![], @@ -5579,10 +5580,10 @@ async fn main() -> Result<(), Box> { ("sync", Some(arg_matches)) => { let max_epochs_to_process = value_t!(arg_matches, "max_epochs_to_process", u64).ok(); process_sync_swaps(&mut db, &rpc_client, ¬ifier).await?; - for (exchange, exchange_credentials) in - db.get_default_accounts_from_all_configured_exchanges() + for (exchange, exchange_credentials, exchange_account) in + db.get_default_accounts_from_configured_exchanges() { - println!("Synchronizing {exchange:?}..."); + println!("Synchronizing {exchange:?} {exchange_account}..."); let exchange_client = exchange_client_new(exchange, exchange_credentials)?; process_sync_exchange( &mut db, @@ -6415,6 +6416,7 @@ async fn main() -> Result<(), Box> { add_exchange_deposit_address_to_db( &mut db, exchange, + &exchange_account, token, deposit_address, &rpc_client, @@ -6465,6 +6467,7 @@ async fn main() -> Result<(), Box> { add_exchange_deposit_address_to_db( &mut db, exchange, + &exchange_account, token, deposit_address, &rpc_client,