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

Fee calculation per block does not sum to fee calculation on liquidation #320

Closed
rhuairahrighairidh opened this issue Jan 19, 2020 · 4 comments
Assignees

Comments

@rhuairahrighairidh
Copy link
Member

  • Total fees are calculated per block, based on the block interval, and rounded.
  • Fees on liquidation are calculated based on the total time since last update, and rounded.

The rounding per block means that total fees summed over blocks is < the fees calculated at liquidation.
Since new fees are minted per block, there ends up not being enough to transfer at liquidation.

@karzak
Copy link
Member

karzak commented Jan 20, 2020

The main way this could pose a problem is when there are very few (or one) CDPs in the system, and they all get liquidated simultaneously.

Short term, I think the fix is to limit the debt amount sent to auction to min(debt in the cdp, debt held by the cdp module account)

Long term, we should remove the source of precision loss, which I believe requires something like cosmos/cosmos-sdk#4399

What are your thoughts @rhuairahrighairidh?

@rhuairahrighairidh
Copy link
Member Author

Doing a min would fix the immediate problem. Though I’d be concerned that since the errors compound over time they may cause other problems.

@rhuairahrighairidh
Copy link
Member Author

Currently we have sort of have two versions of the same calculation.
One that calculates fees for one long period, the other that calculates total fees by summing over many smaller periods.
Both of which are “wrong” to some degree because of rounding. I believe maker gets around this by only doing the calculation once, when the global accumulator thing is updated. That keeps the two wrong by the same amount.

@karzak
Copy link
Member

karzak commented Jan 22, 2020

Closed via #326

A new issue can be created addressing overall issue of precision loss.

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

No branches or pull requests

2 participants