Skip to content

Stake precision loss / truncation after many liquidations #310

@RickGriff

Description

@RickGriff

When a trove is created or updated, its stake is calculated by:

  1. stake = _coll.mul(totalStakesSnapshot).div(totalCollateralSnapshot);

Its stake is what earns rewards it ETH and LUSD debt rewards in distributions from liquidations, i.e. in liquidations where the LUSD in the Stability Pool is less than the liquidated debt, and the liquidated collateral and debt is redistributed to all active troves.

Problem:

When a series of liquidations occur that trigger redistributions, the stakes of the liquidated troves are removed from the system, but the ETH collateral of the liquidated troves remains in the system - it just moves from ActivePool to DefaultPool. Thus totalStakes decreases but totalCollateral remains constant (ignoring gas compensation).

Over time, as liquidations occur, due to equation 1), fresh stakes become smaller and smaller for a given trove collateral size. Eventually, stakes can get so small and close in magnitude to 1e-18, such that they lose significant precision. Eventually new stakes may be truncated to 0, which breaks the proportional reward distribution mechanism.

The rate of decline of new stakes depends on how much is liquidated at each step - liquidating 10% of the system's collateral causes new stakes to decrease more quickly than liquidating 1% of the system collateral.

This may or may not be a problem depending on what numbers are "realistic" - i.e. the real liquidation throughput relative to system size.

Initial simulations suggest that stakes become very small (~1e-16) after on the order of 1e4 or 1e5 liquidations, where 10-20% of system collateral is commonly liquidated. This seems like potential cause for concern.

Possible fix:

  • Represent stakes in a different numerical format, such that loss of precision or truncation to 0 is not an issue for a reasonable system lifetime, with realistic liquidation throughput.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions