Omniscia Bluejay Finance Audit
StablecoinEngine Code Style Findings
StablecoinEngine Code Style Findings
SEE-01C: Assignment Statement Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | StablecoinEngine.sol:L272-L277 |
Description:
The linked assignments can be optimized as they perform an additional double assignment redundantly.
Example:
272(uint256 reserve0, uint256 reserve1, ) = pool.getReserves();273if (info.stablecoinIsToken0) {274 (stablecoinReserve, reserveReserve) = (reserve0, reserve1);275} else {276 (stablecoinReserve, reserveReserve) = (reserve1, reserve0);277}
Recommendation:
We advise the stablecoinReserve
and reserveReserve
variables to be utilized for the assignment by the pool.getReserves()
function return and the conditional that follows it to only be executed if info.stablecoinIsToken0
is false
as otherwise the values will already be correct. Solidity supports value swapping in a single statement (i.e. uint256 foo; uint256 bar; (foo, bar) = (bar, foo);
is valid).
Alleviation:
The assignment statements have been optimized as advised.
SEE-02C: Inexistent Error Messages
Type | Severity | Location |
---|---|---|
Code Style | StablecoinEngine.sol:L97, L98 |
Description:
The linked require
checks have no error messages explicitly defined.
Example:
97require(pools[reserve][stablecoin] == address(0));98require(poolFactory.getPair(reserve, stablecoin) == address(0));
Recommendation:
We advise them to be set so to aid in the validation of the require
's condition as well as the legibility of the codebase.
Alleviation:
Error messages have been introduced for all relevant require
checks.
SEE-03C: Inexistent Visibility Specifier
Type | Severity | Location |
---|---|---|
Code Style | StablecoinEngine.sol:L20 |
Description:
The linked variable has no visibility specifier explicitly set.
Example:
20uint256 constant WAD = 10**18;
Recommendation:
We advise one to be set so to avoid potential compilation discrepancies in the future as the current behaviour is for the compiler to assign one automatically which may deviate between pragma
versions.
Alleviation:
The private
visibility specifier has been introduced for the referenced variable alleviating this exhibit.