When _prevCumulativeValuation is big enough, _updateTWAV() will revert due to overflow.
Impact
Since _updateTWAV() is used in NibblVault.sol#buy() and NibblVault.sol#sell(), when it reverts due to overflow, the NibblVault contract as a whole will malfunction, and users' funds may be frozen in the contract.
Lines of code
https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Twav/Twav.sol#L21-L31
Vulnerability details
Because the solidity version used by the current implementation is
0.8.10
, and there are some breaking changes in Solidity v0.8.0:Ref: https://docs.soliditylang.org/en/v0.8.13/080-breaking-changes.html#silent-changes-of-the-semantics
When
_prevCumulativeValuation
is big enough,_updateTWAV()
will revert due to overflow.Impact
Since
_updateTWAV()
is used inNibblVault.sol#buy()
andNibblVault.sol#sell()
, when it reverts due to overflow, theNibblVault
contract as a whole will malfunction, and users' funds may be frozen in the contract.Recommendation
Change to: