Omniscia Tokemak Network Audit
EthPool Code Style Findings
EthPool Code Style Findings
EPL-01C: Redundant Nested Minimum
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | EthPool.sol:L77-L81 |
Description:
The require
conditional of withdraw
guarantees that requestedAmount
will be less-than-or-equal to requestedWithdrawals[msg.sender].amount
and as such, the minimum between requestedAmount
and underlyer.balanceOf(address(this))
will also uphold this condition.
Example:
contracts/pools/EthPool.sol
72ire(73requestedAmount <= requestedWithdrawals[msg.sender].amount,74"WITHDRAW_INSUFFICIENT_BALANCE"75
76
77256 amount =78Math.min(79 requestedWithdrawals[msg.sender].amount,80 Math.min(weth.balanceOf(address(this)), requestedAmount)81);
Recommendation:
We advise the outer Math.min
invocation to be dropped entirely.
Alleviation:
The Math.min
invocation was dropped in favor of manual require
checks that also provide more descriptive error messages, thereby alleviating this exhibit.