From 99a03f9dfa909aa7f82f6aca33ac354e87d15fd7 Mon Sep 17 00:00:00 2001 From: jgur-psyops Date: Thu, 19 Dec 2024 14:58:15 -0500 Subject: [PATCH] Fix CLI get bank --- clients/rust/marginfi-cli/src/processor/mod.rs | 8 ++++++-- programs/marginfi/src/state/marginfi_group.rs | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/clients/rust/marginfi-cli/src/processor/mod.rs b/clients/rust/marginfi-cli/src/processor/mod.rs index 987b930c..d003db1b 100644 --- a/clients/rust/marginfi-cli/src/processor/mod.rs +++ b/clients/rust/marginfi-cli/src/processor/mod.rs @@ -56,7 +56,7 @@ use { signature::Keypair, signer::Signer, system_program, - sysvar::{self, Sysvar}, + sysvar::{self}, transaction::Transaction, }, spl_associated_token_account::{ @@ -1166,7 +1166,11 @@ pub fn bank_get(config: Config, bank_pk: Option) -> Result<()> { let mut bank: Bank = config.mfi_program.account(address)?; let group: MarginfiGroup = config.mfi_program.account(bank.group)?; - bank.accrue_interest(Clock::get()?.unix_timestamp, &group)?; + let current_timestamp = SystemTime::now() + .duration_since(UNIX_EPOCH) + .expect("Time went backwards"); + + bank.accrue_interest(current_timestamp.as_secs() as i64, &group)?; print_bank(&address, &bank); diff --git a/programs/marginfi/src/state/marginfi_group.rs b/programs/marginfi/src/state/marginfi_group.rs index 188a6aed..b1809c38 100644 --- a/programs/marginfi/src/state/marginfi_group.rs +++ b/programs/marginfi/src/state/marginfi_group.rs @@ -744,6 +744,7 @@ impl Bank { solana_program::log::sol_log_compute_units(); let time_delta: u64 = (current_timestamp - self.last_update).try_into().unwrap(); + print!(" Cranking accrue interest. Time since last update: {:?}", time_delta); if time_delta == 0 { return Ok(());