Skip to content
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

Merged
merged 7 commits into from
Jun 9, 2023
Merged

Min liquidation amount #111

merged 7 commits into from
Jun 9, 2023

Conversation

maneva3
Copy link
Collaborator

@maneva3 maneva3 commented Jun 5, 2023

No description provided.

@maneva3 maneva3 requested a review from gmanev7 June 5, 2023 15:33
spec.amount_to_liquidate(asset, total_due),
min_asset,
)
let ltv = ltv(overdue, asset);
Copy link
Member

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

Comment on lines 106 to 110
if ltv >= spec.max() {
no_liquidation(spec, total_due, spec.third_liq_warn())
} else {
no_liquidation(spec, total_due, ltv)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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()))

Comment on lines 135 to 139
if overdue < min_liquidation {
no_liquidation(spec, overdue, ltv)
} else {
ask_liquidation(asset, Cause::Overdue(), overdue, min_asset)
}
Copy link
Member

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

Comment on lines 124 to 126
if liquidation_amount < min_liquidation {
None
} else {
Copy link
Member

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(),
Copy link
Member

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());
Copy link
Member

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

Copy link
Member

@gmanev7 gmanev7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gmanev7 gmanev7 merged commit ec8d74e into main Jun 9, 2023
@gmanev7 gmanev7 deleted the min_liquidation_amount branch June 9, 2023 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants