Skip to content

Commit

Permalink
chore: remove obsolete arg
Browse files Browse the repository at this point in the history
  • Loading branch information
losman0s committed Nov 20, 2023
1 parent ba1f392 commit bfb7ed5
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 135 deletions.
124 changes: 43 additions & 81 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion observability/indexer/src/utils/transactions_crawler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use anyhow::Result;
use chrono::{Local, TimeZone};
use concurrent_queue::ConcurrentQueue;
use futures::{future::join_all, stream, Future, StreamExt};
use log::{error, info, warn};
use solana_client::{
nonblocking::rpc_client::RpcClient, rpc_client::GetConfirmedSignaturesForAddress2Config,
rpc_config::RpcTransactionConfig,
Expand All @@ -22,7 +23,6 @@ use std::{
};
use std::{str::FromStr, time::Duration};
use tokio::{join, runtime::Builder};
use tracing::{error, info, warn};

use crate::common::{
Target, DEFAULT_MAX_PENDING_SIGNATURES, DEFAULT_MONITOR_INTERVAL, DEFAULT_RPC_ENDPOINT,
Expand Down
5 changes: 2 additions & 3 deletions programs/marginfi/src/instructions/marginfi_account/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub fn lending_account_borrow(ctx: Context<LendingAccountBorrow>, amount: u64) -
..
} = ctx.accounts;

let current_time = Clock::get()?.unix_timestamp;
let mut marginfi_account = marginfi_account_loader.load_mut()?;

check!(
Expand All @@ -42,7 +41,7 @@ pub fn lending_account_borrow(ctx: Context<LendingAccountBorrow>, amount: u64) -
);

bank_loader.load_mut()?.accrue_interest(
current_time,
Clock::get()?.unix_timestamp,
#[cfg(not(feature = "client"))]
bank_loader.key(),
)?;
Expand Down Expand Up @@ -89,7 +88,7 @@ pub fn lending_account_borrow(ctx: Context<LendingAccountBorrow>, amount: u64) -
// Check account health, if below threshold fail transaction
// Assuming `ctx.remaining_accounts` holds only oracle accounts
RiskEngine::new(&marginfi_account, ctx.remaining_accounts)?
.check_account_health(RiskRequirementType::Initial, current_time)?;
.check_account_health(RiskRequirementType::Initial)?;

Ok(())
}
Expand Down
10 changes: 2 additions & 8 deletions programs/marginfi/src/instructions/marginfi_account/liquidate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ pub fn lending_account_liquidate(
..
} = ctx.accounts;

let current_timestamp = Clock::get()?.unix_timestamp;

let mut liquidator_marginfi_account = liquidator_marginfi_account_loader.load_mut()?;
let mut liquidatee_marginfi_account = liquidatee_marginfi_account_loader.load_mut()?;
let current_timestamp = Clock::get()?.unix_timestamp;
Expand All @@ -115,10 +113,7 @@ pub fn lending_account_liquidate(
&ctx.remaining_accounts[liquidatee_accounts_starting_pos..];

RiskEngine::new(&liquidatee_marginfi_account, liquidatee_remaining_accounts)?
.check_pre_liquidation_condition_and_get_account_health(
&ctx.accounts.liab_bank.key(),
current_timestamp,
)?
.check_pre_liquidation_condition_and_get_account_health(&ctx.accounts.liab_bank.key())?
};

// ##Accounting changes##
Expand Down Expand Up @@ -348,12 +343,11 @@ pub fn lending_account_liquidate(
.check_post_liquidation_condition_and_get_account_health(
&ctx.accounts.liab_bank.key(),
pre_liquidation_health,
current_timestamp,
)?;

// Verify liquidator account health
RiskEngine::new(&liquidator_marginfi_account, liquidator_remaining_accounts)?
.check_account_health(RiskRequirementType::Initial, current_timestamp)?;
.check_account_health(RiskRequirementType::Initial)?;

emit!(LendingAccountLiquidateEvent {
header: AccountEventHeader {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ pub fn lending_account_withdraw(
..
} = ctx.accounts;

let current_timestamp = Clock::get()?.unix_timestamp;

let withdraw_all = withdraw_all.unwrap_or(false);
let mut marginfi_account = marginfi_account_loader.load_mut()?;

Expand All @@ -48,7 +46,7 @@ pub fn lending_account_withdraw(
);

bank_loader.load_mut()?.accrue_interest(
current_timestamp,
Clock::get()?.unix_timestamp,
#[cfg(not(feature = "client"))]
bank_loader.key(),
)?;
Expand Down Expand Up @@ -103,7 +101,7 @@ pub fn lending_account_withdraw(
// Check account health, if below threshold fail transaction
// Assuming `ctx.remaining_accounts` holds only oracle accounts
RiskEngine::new(&marginfi_account, ctx.remaining_accounts)?
.check_account_health(RiskRequirementType::Initial, current_timestamp)?;
.check_account_health(RiskRequirementType::Initial)?;

Ok(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ pub fn lending_pool_handle_bankruptcy(ctx: Context<LendingPoolHandleBankruptcy>)

let mut marginfi_account = marginfi_account_loader.load_mut()?;

let current_time = Clock::get()?.unix_timestamp;
RiskEngine::new(&marginfi_account, ctx.remaining_accounts)?
.check_account_bankrupt(current_time)?;
RiskEngine::new(&marginfi_account, ctx.remaining_accounts)?.check_account_bankrupt()?;

let mut bank = bank_loader.load_mut()?;

bank.accrue_interest(
current_time,
Clock::get()?.unix_timestamp,
#[cfg(not(feature = "client"))]
bank_loader.key(),
)?;
Expand Down
Loading

0 comments on commit bfb7ed5

Please sign in to comment.