Skip to content

Commit

Permalink
fix: ignore bankrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
losman0s committed Sep 6, 2024
1 parent 5555d83 commit c9c03a9
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/liquidator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use fixed::types::I80F48;
use fixed_macro::types::I80F48;
use log::{debug, error, info};
use marginfi::{
constants::EXP_10_I80F48,
constants::{BANKRUPT_THRESHOLD, EXP_10_I80F48},
state::{
marginfi_account::{BalanceSide, MarginfiAccount, RequirementType},
marginfi_group::{Bank, BankOperationalState, RiskTier},
Expand Down Expand Up @@ -277,6 +277,25 @@ impl Liquidator {
return None;
}

let (deposit_shares, liabs_shares) = account.get_deposits_and_liabilities_shares();

let deposit_values = self
.get_value_of_shares(
deposit_shares,
&BalanceSide::Assets,
RequirementType::Maintenance,
)
.unwrap();

if deposit_values
.iter()
.map(|(v, _)| v.to_num::<f64>())
.sum::<f64>()
< BANKRUPT_THRESHOLD
{
return None;
}

let (asset_bank_pk, liab_bank_pk) =
match self.find_liquidation_bank_candidates(account) {
Ok(Some((asset_bank_pk, liab_bank_pk))) => (asset_bank_pk, liab_bank_pk),
Expand Down

0 comments on commit c9c03a9

Please sign in to comment.