Omniscia Kanpeki Finance Audit
TokenRegistry Code Style Findings
TokenRegistry Code Style Findings
TRY-01C: Redundant Duplicate Lookup
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | TokenRegistry.sol:L105, L108 |
Description:
The unwhitelistToken
function performs a contains
and remove
operation on the EnumerableSet
in the same logic block.
Example:
contracts/TokenRegistry.sol
105require(_whitelistedTokens.contains(token), "!whitelisted");106
107
108_whitelistedTokens.remove(token);
Recommendation:
We advise the contains
lookup to instead be replaced by the result of the remove
invocation as it indicates whether an entry was actually removed by the operation.
Alleviation:
The code was updated to instead utilize the operation's result directly in all instances of addition and removal in the code.