You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change internal math reference precision from 1e9 to 1e27 to make the PositiveTokenRebaseLimiter library more robust against unusual input data
Context:
As a part of the Repovation initiative the PositiveTokenRebase library (contracts/0.8.9/lib/PositiveTokenRebaseLimiter.sol) has been covered with an extensive fuzzing test suite.
What:
Turns out the internal math precision with a reference 1 == 1e9 is insufficient to maintain wide (or even unconstrainted) data boundaries, see the relevant code in lidofinance/core#88, the method is testFuzz_getSharesToBurnLimit. When the values are out of range, the allowed theoretical positive rebase start diverging from the calculated one due to the weak precision math.
It should be possible to maintain the accuracy for the following assumptions:
allow near zero protocol TVL not sacrificing on the estimation precision (the current model uses 1 ether, better to allow 1 gwei at least)
require more accuracy for max rebase calculation (the current model requires 0.1 basis point, wish it was 0.001 basis point)
allow more outrageous share rates for the model (0.001 ≤ shareRate ≤ 1000 ⇒ 1e-6 ≤ shareRate ≤ 1e6)
allow more drastically changes for decreaseEther to be passed
Possible fix:
Implement getSharesToBurnLimit with the internal 1e27 precision model.
The text was updated successfully, but these errors were encountered:
tl;dr
Change internal math reference precision from
1e9
to1e27
to make thePositiveTokenRebaseLimiter
library more robust against unusual input dataContext:
As a part of the Repovation initiative the
PositiveTokenRebase
library (contracts/0.8.9/lib/PositiveTokenRebaseLimiter.sol
) has been covered with an extensive fuzzing test suite.What:
Turns out the internal math precision with a reference
1 == 1e9
is insufficient to maintain wide (or even unconstrainted) data boundaries, see the relevant code in lidofinance/core#88, the method istestFuzz_getSharesToBurnLimit
. When the values are out of range, the allowed theoretical positive rebase start diverging from the calculated one due to the weak precision math.It should be possible to maintain the accuracy for the following assumptions:
1 ether
, better to allow1 gwei
at least)0.1 basis point
, wish it was0.001 basis point
)0.001 ≤ shareRate ≤ 1000
⇒1e-6 ≤ shareRate ≤ 1e6
)decreaseEther
to be passedPossible fix:
Implement
getSharesToBurnLimit
with the internal1e27
precision model.The text was updated successfully, but these errors were encountered: