-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Min liquidation amount #111
Conversation
spec.amount_to_liquidate(asset, total_due), | ||
min_asset, | ||
) | ||
let ltv = ltv(overdue, asset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we lie for the real ltv since we calculate it only from overdue
if ltv >= spec.max() { | ||
no_liquidation(spec, total_due, spec.third_liq_warn()) | ||
} else { | ||
no_liquidation(spec, total_due, ltv) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ltv >= spec.max() { | |
no_liquidation(spec, total_due, spec.third_liq_warn()) | |
} else { | |
no_liquidation(spec, total_due, ltv) | |
} | |
no_liquidation(spec, total_due, ltv.min(spec.third_liq_warn())) |
if overdue < min_liquidation { | ||
no_liquidation(spec, overdue, ltv) | ||
} else { | ||
ask_liquidation(asset, Cause::Overdue(), overdue, min_asset) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic is similar to the one used on liquidation by liability ... think on reusing it
if liquidation_amount < min_liquidation { | ||
None | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take this into may_ask_liquidation
to avoid copy/paste
878.into(), | ||
752.into(), | ||
0.into(), | ||
800.into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[all occurrences within this test] select a corner value, not like here 800
which is far from the threshold. The idea is to prove that the result No is returned at that corner value while a value Liquidate is returned at the value + 1
where | ||
Asset: Currency, | ||
{ | ||
if total_due.is_zero() { | ||
Status::NoDebt | ||
} else { | ||
let ltv = Percent::from_ratio(total_due, asset); | ||
debug_assert!(ltv < spec.max()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move it at the beginning of the method because it checks a precondition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.