RevenueHandler.checkpoint isn't correctly when tokenConfig.poolAdapter is 0, which cause epochRevenues record wrong number, so some users will claim more token than expected, and other user can't claim the tokens
Vulnerability Details
RevenueHandler.checkpoint isn't correctly when tokenConfig.poolAdapter is 0, which cause epochRevenues record wrong number, so some users will claim more token than expected, and other user can't claim the tokens
Vulnerability Details
In RevenueHandler.checkpoint, if tokenConfig.poolAdapter is zero, epochRevenues[currentEpoch][token] += amountReceived; is used to update value, and thisBalance is equal to IERC20(token).balanceOf(address(this))The issue is that IERC20(token).balanceOf(address(this)) may contains the token that hasn't been claimed. In such case, it means that the amount will be added twice.
228functioncheckpoint() public {229// only run checkpoint() once per epoch230if (block.timestamp >= currentEpoch + WEEK /* && initializer == address(0) */) {231 currentEpoch = (block.timestamp / WEEK) * WEEK;232233uint256 length = revenueTokens.length;234for (uint256 i =0; i < length; i++) { ...244245uint256 thisBalance =IERC20(token).balanceOf(address(this));246247// If poolAdapter is set, the revenue token is an alchemic-token248if (tokenConfig.poolAdapter !=address(0)) { ...258 } else {259// If the revenue token doesn't have a poolAdapter, it is not an alchemic-token260 amountReceived = thisBalance; <<<--- thisBalance is IERC20(token).balanceOf(address(this));261262// Update amount of non-alchemic-token revenue received for this epoch263 epochRevenues[currentEpoch][token] += amountReceived; <<<---+= is used here264 }265266emitRevenueRealized(currentEpoch, token, tokenConfig.debtToken, amountReceived, treasuryAmt);267 }268 }269 }
Impact Details
epochRevenues isn't updated correctly in some case, so some users will claim more token than expected, and other user can't claim the tokens
References
Add any relevant links to documentation or code
Proof of Concept
Put the following code in src/test/RevenueHandler.t.sol and run