Skip to content

Commit

Permalink
Fix CLI get bank (#265)
Browse files Browse the repository at this point in the history
* Bug in get bank cli, now "accrues" interest before printing bank data.
  • Loading branch information
jgur-psyops authored Dec 19, 2024
1 parent f8ca780 commit 464de33
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[toolchain]
anchor_version = "0.30.1"
solana_version = "1.18.11"
solana_version = "1.18.17"

[features]
resolution = true
Expand Down
10 changes: 8 additions & 2 deletions clients/rust/marginfi-cli/src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use {
signature::Keypair,
signer::Signer,
system_program,
sysvar::{self, Sysvar},
sysvar::{self},
transaction::Transaction,
},
spl_associated_token_account::{
Expand Down Expand Up @@ -1166,7 +1166,13 @@ pub fn bank_get(config: Config, bank_pk: Option<Pubkey>) -> 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");
let current_timestamp = current_timestamp.as_secs() as i64;

bank.accrue_interest(current_timestamp, &group)?;
println!(" Cranking interest at: {:?}", current_timestamp);

print_bank(&address, &bank);

Expand Down
1 change: 0 additions & 1 deletion programs/marginfi/src/state/marginfi_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,6 @@ impl Bank {
solana_program::log::sol_log_compute_units();

let time_delta: u64 = (current_timestamp - self.last_update).try_into().unwrap();

if time_delta == 0 {
return Ok(());
}
Expand Down

0 comments on commit 464de33

Please sign in to comment.