tendermint/liquidity

Decrease diffThreshold in invariant checks

hallazzang opened this issue · 0 comments

Current value of diffThreshold(20%) is way higher than acceptable:

diffThreshold = sdk.NewDecWithPrec(2, 1) // 20%

It's because for small values, like 1 and 2, the diff function will result in too high value, e.g.:

diff(sdk.NewDec(1), sdk.NewDec(2)) // => 0.5
diff(sdk.NewDec(2), sdk.NewDec(1)) // => 1.0

(Note that the order of parameters matters in result)

We need to use better diff functions, such as Percentage Difference and Percentage Error, then lower the diffThreshold.