Drop unused HealthCache function, rename ClampedToNum (#382)
This commit is contained in:
parent
3ed416a97f
commit
42657dcf80
|
@ -537,21 +537,6 @@ impl HealthCache {
|
|||
self.has_spot_borrows() || perp_borrows
|
||||
}
|
||||
|
||||
pub fn has_liquidatable_spot_or_perp_base(&self) -> bool {
|
||||
let spot_liquidatable = self.has_spot_assets();
|
||||
let serum3_cancelable = self.has_serum3_open_orders_funds();
|
||||
let perp_liquidatable = self.perp_infos.iter().any(|p| {
|
||||
// can use perp_liq_base_position
|
||||
p.base_lots != 0
|
||||
// can use perp_liq_force_cancel_orders
|
||||
|| p.has_open_orders
|
||||
// A remaining quote position can be reduced with perp_settle_pnl and that can improve health.
|
||||
// However, since it's not guaranteed that there is a counterparty, a positive perp quote position
|
||||
// does not prevent bankruptcy.
|
||||
});
|
||||
spot_liquidatable || serum3_cancelable || perp_liquidatable
|
||||
}
|
||||
|
||||
pub(crate) fn compute_serum3_reservations(
|
||||
&self,
|
||||
health_type: HealthType,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use fixed::types::I80F48;
|
||||
|
||||
pub trait ClampedToNum {
|
||||
pub trait ClampToInt {
|
||||
fn clamp_to_i64(&self) -> i64;
|
||||
fn clamp_to_u64(&self) -> u64;
|
||||
}
|
||||
|
||||
impl ClampedToNum for I80F48 {
|
||||
impl ClampToInt for I80F48 {
|
||||
fn clamp_to_i64(&self) -> i64 {
|
||||
if *self <= i64::MIN {
|
||||
i64::MIN
|
||||
|
@ -27,7 +27,7 @@ impl ClampedToNum for I80F48 {
|
|||
}
|
||||
}
|
||||
|
||||
impl ClampedToNum for f64 {
|
||||
impl ClampToInt for f64 {
|
||||
fn clamp_to_i64(&self) -> i64 {
|
||||
if *self <= i64::MIN as f64 {
|
||||
i64::MIN
|
||||
|
@ -49,7 +49,7 @@ impl ClampedToNum for f64 {
|
|||
}
|
||||
}
|
||||
|
||||
impl ClampedToNum for u64 {
|
||||
impl ClampToInt for u64 {
|
||||
fn clamp_to_i64(&self) -> i64 {
|
||||
if *self >= i64::MAX as u64 {
|
||||
i64::MAX
|
||||
|
|
|
@ -6,7 +6,7 @@ use static_assertions::const_assert_eq;
|
|||
use std::cmp::Ordering;
|
||||
use std::mem::size_of;
|
||||
|
||||
use crate::i80f48::ClampedToNum;
|
||||
use crate::i80f48::ClampToInt;
|
||||
use crate::state::*;
|
||||
|
||||
pub const FREE_ORDER_SLOT: PerpMarketIndex = PerpMarketIndex::MAX;
|
||||
|
|
Loading…
Reference in New Issue