Liquidation: Ignore dust balances and perp pnl
Liquidation and perp pnl settlement may not bring spot amounts to exactly zero. Having a small spot amount < 1 native token can otherwise make the liquidation get stuck and not move one to the next phase.
This commit is contained in:
parent
f68a11145f
commit
55e8fc390f
|
@ -264,6 +264,9 @@ impl<'a> LiquidateHelper<'a> {
|
||||||
} else {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
if settleable_pnl.abs() < 1 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
Some((pp.market_index, settleable_pnl))
|
Some((pp.market_index, settleable_pnl))
|
||||||
})
|
})
|
||||||
.collect::<Vec<(PerpMarketIndex, I80F48)>>();
|
.collect::<Vec<(PerpMarketIndex, I80F48)>>();
|
||||||
|
|
|
@ -442,7 +442,7 @@ impl HealthCache {
|
||||||
pub fn has_spot_assets(&self) -> bool {
|
pub fn has_spot_assets(&self) -> bool {
|
||||||
self.token_infos.iter().any(|ti| {
|
self.token_infos.iter().any(|ti| {
|
||||||
// can use token_liq_with_token
|
// can use token_liq_with_token
|
||||||
ti.balance_native.is_positive()
|
ti.balance_native >= 1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,9 +466,7 @@ impl HealthCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_spot_borrows(&self) -> bool {
|
pub fn has_spot_borrows(&self) -> bool {
|
||||||
self.token_infos
|
self.token_infos.iter().any(|ti| ti.balance_native < 0)
|
||||||
.iter()
|
|
||||||
.any(|ti| ti.balance_native.is_negative())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_borrows(&self) -> bool {
|
pub fn has_borrows(&self) -> bool {
|
||||||
|
|
Loading…
Reference in New Issue