Submitted by 0xNineDec, also found by adriro, Ruhum, joestakey, Ignite, bytes032, Ace-30, Ace-30, KingNFT, AlexCzm, SaeedAlipoor01988, ktg, rvierdiiev, cccz, SpicyMeatball and J4de.
Several (token, distribution period) couples are not feasible in BathBuddy, forcing the owner to set shorter distributions or providing more amount of tokens to be distributed.
In BathBuddy, the reward rate of a distribution is calculated following a linear distribution according to the amount of rewards to be distributed across the period:
The rate for each reward token spreads the reward amount across the rewardsDuration:
Because the SafeMath implementation asks for compiler versions over 0.8.0 to execute the legacy division a/b, the reward rate could be zero for some distribution configurations, forcing the owner to reduce the duration or increase the reward amount. Bear in mind, that the implementation of the BathBuddy allows using arbitrary tokens for rewards.
The following test refactors the bath-buddy.ts deploy fixture with the following:
And the test is the same as the one provided (should get rewards from both Comptroller and BathBuddy) only calculating the amount of rewards received by getting the balance before and after claiming them:
It can be seen that setting the distribution amount to 0.315e8 (slightly below the amount of seconds per year) yields in zero rewards:
And setting the distribution amount slightly over the seconds per year (0.3154e8) successfully yields in rewards:
Increase the precision scale of the reward rate calculation using a factor (e.g. 10**8) multiplied to to the amount when calculating the distributions rate.
daoio (Rubicon) confirmed
HickupHH3 (judge) commented:
