Closed sherlock-admin closed 6 months ago
bareli
medium
We have implemented a wrong implementation of correctRState().As here we can see that it will implement the same code for different _Rstate.
we should use a or gate for simple implementation.
https://github.com/sherlock-audit/2023-12-dodo-gsp/blob/main/dodo-gassaving-pool/contracts/GasSavingPool/impl/GSPVault.sol#L140 function correctRState() public { if (RState == uint32(PMMPricing.RState.BELOW_ONE) && _BASERESERVE<_BASETARGET) { RState = uint32(PMMPricing.RState.ONE); _BASETARGET = _BASERESERVE; _QUOTETARGET = _QUOTERESERVE; } if (RState == uint32(PMMPricing.RState.ABOVE_ONE) && _QUOTERESERVE<_QUOTETARGET) { RState = uint32(PMMPricing.RState.ONE); _BASETARGET = _BASERESERVE; _QUOTETARGET = _QUOTERESERVE; } }
Manual Review
if (RState == uint32(PMMPricing.RState.BELOW_ONE) && _BASERESERVE<_BASETARGET)||(RState == uint32(PMMPricing.RState.ABOVE_ONE) && _QUOTERESERVE<_QUOTETARGET) { RState = uint32(PMMPricing.RState.ONE); _BASETARGET = _BASERESERVE; _QUOTETARGET = _QUOTERESERVE; }
Invalid, no impact/issue highlighted
bareli
medium
wrong implementation of correctRState() function
Summary
We have implemented a wrong implementation of correctRState().As here we can see that it will implement the same code for different _Rstate.
Vulnerability Detail
we should use a or gate for simple implementation.
Impact
Code Snippet
https://github.com/sherlock-audit/2023-12-dodo-gsp/blob/main/dodo-gassaving-pool/contracts/GasSavingPool/impl/GSPVault.sol#L140 function correctRState() public { if (RState == uint32(PMMPricing.RState.BELOW_ONE) && _BASERESERVE<_BASETARGET) { RState = uint32(PMMPricing.RState.ONE); _BASETARGET = _BASERESERVE; _QUOTETARGET = _QUOTERESERVE; } if (RState == uint32(PMMPricing.RState.ABOVE_ONE) && _QUOTERESERVE<_QUOTETARGET) { RState = uint32(PMMPricing.RState.ONE); _BASETARGET = _BASERESERVE; _QUOTETARGET = _QUOTERESERVE; } }
Tool used
Manual Review
Recommendation
if (RState == uint32(PMMPricing.RState.BELOW_ONE) && _BASERESERVE<_BASETARGET)||(RState == uint32(PMMPricing.RState.ABOVE_ONE) && _QUOTERESERVE<_QUOTETARGET) { RState = uint32(PMMPricing.RState.ONE); _BASETARGET = _BASERESERVE; _QUOTETARGET = _QUOTERESERVE; }