In the getPoolReward function inside the NeoTokyoStaker contract there is an error in the calculation of the daoShare value which represents the part of rewards sent to the treasury, this means that the treasury will receive less rewards that what it is supposed to.
As you can see the first line calculates the user shares amount which is multiplied by the constant _PRECISION to avoid rounding errors, and in the second line the daoShare value is calculated this value represent a percentage of shares sent to the treasury and thus its formula should be :
Where the value of pool.daoTax is a percentage set in basis point of _DIVISOR == 100 (meaning that 100 ≈ 100%).
But there is an error in the actual formula used in the code as it contains a division by both _DIVISOR and 100 which is wrong because the resultant daoShare value will be very small and will not represent the correct percentage set by the protocol.
And thus the final value returned by the function will be wrong as it will give more rewards to the user and less to the treasury which was not intended.
Tools Used
Manual review
Recommended Mitigation Steps
Correct the formula used to calculate the daoShare value and replace it by :
Lines of code
https://github.com/code-423n4/2023-03-neotokyo/blob/main/contracts/staking/NeoTokyoStaker.sol#L1389
Vulnerability details
Impact
In the
getPoolReward
function inside theNeoTokyoStaker
contract there is an error in the calculation of thedaoShare
value which represents the part of rewards sent to the treasury, this means that the treasury will receive less rewards that what it is supposed to.Proof of Concept
The error occurs in the code below :
File: NeoTokyoStaker.sol Line 1388-1392
As you can see the first line calculates the user shares amount which is multiplied by the constant
_PRECISION
to avoid rounding errors, and in the second line thedaoShare
value is calculated this value represent a percentage of shares sent to the treasury and thus its formula should be :Where the value of
pool.daoTax
is a percentage set in basis point of_DIVISOR == 100
(meaning that 100 ≈ 100%).But there is an error in the actual formula used in the code as it contains a division by both
_DIVISOR
and100
which is wrong because the resultantdaoShare
value will be very small and will not represent the correct percentage set by the protocol.And thus the final value returned by the function will be wrong as it will give more rewards to the user and less to the treasury which was not intended.
Tools Used
Manual review
Recommended Mitigation Steps
Correct the formula used to calculate the
daoShare
value and replace it by :