Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Changing liquidation bonus rounding #71

Merged
merged 1 commit into from
Dec 13, 2022
Merged

Changing liquidation bonus rounding #71

merged 1 commit into from
Dec 13, 2022

Conversation

grod220
Copy link
Contributor

@grod220 grod220 commented Dec 12, 2022

At the moment, the math that does the calculations for liquidation bonuses rounds up. The initial reasoning behind this was:

  • To ensure accounts can be liquidated down to the last unit (relevant when we used to liquidate unlocking positions before locked ones, but not relevant anymore)
  • To ensure the liquidator does not lose money on the liquidation

However, as a general principle and related to #70, we should always default to rounding in favor of the protocol/pool/target versus the profiteer. This was also pointed out in the Oak audit that this rounding can be taken advantage of. Though gas constraints make it unfeasible, I think it's still safer to implement.

The only issue are some cases with rounding down where the liquidator can lose money. Simulations: https://docs.google.com/spreadsheets/d/14V2R50U2NUxliShSMik5s3PA6W4HnhsYCUXD3sLnCdw/edit#gid=1380620294.

  • If the liquidation amounts are low
  • If the price difference between two debt and request asset is very large

For that reason, I added an assertion to ensure the liquidator does indeed profit as a consequence of the liquidation.

Side note: the need for cosmwasm ceil division has been acknowledged by core team: CosmWasm/cosmwasm#1485. May contribute some of this work there.

))
);

assert_liquidation_profitable(&deps.querier, &oracle, result.clone())?;
Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm what if we want to repay debt even without profit? Maybe we want to remove bad debt..
Just thinking loud

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In Fields you could call the liquidation endpoint and not request any coin in return. It's the use case you describe, but I have a hard time understanding when this would be used and why. We need to spend more time thinking through this. If we were to clear bad debt, the remaining debt pool participants would end up on the hook for that. Or if we want to allow people to pay down debt on behalf of another, perhaps we should add a recipient: Optional<AccountId> field to the repay action.

@grod220 grod220 merged commit 2620d94 into master Dec 13, 2022
@grod220 grod220 deleted the liq-round-down branch December 13, 2022 09:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants