Omniscia Olympus DAO Audit
sOlympusERC20 Code Style Findings
sOlympusERC20 Code Style Findings
OEC-01C: Deprecated Representation Style
Type | Severity | Location |
---|---|---|
Code Style | Informational | sOlympusERC20.sol:L54 |
Description:
The maximum of uint256
representation in use (~uint256(0)
) has been deprecated in favor of the special type
operator.
Example:
54uint256 private constant MAX_UINT256 = ~uint256(0);
Recommendation:
We advise the operator to be used to instead assign the maximum (type(uint256).max
).
Alleviation:
The representation of the maximum was adjusted according to our recommendation.
OEC-02C: Inefficient Code Structure
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | sOlympusERC20.sol:L174, L175, L185, L186, L191, L192, L198-L203, L210-L213 |
Description:
All approve
style functions can internally use the _approve
function.
Example:
184function approve( address spender, uint256 value ) public override returns (bool) {185 _allowedValue[ msg.sender ][ spender ] = value;186 emit Approval( msg.sender, spender, value );187 return true;188}189
190function increaseAllowance( address spender, uint256 addedValue ) public override returns (bool) {191 _allowedValue[ msg.sender ][ spender ] = _allowedValue[ msg.sender ][ spender ].add( addedValue );192 emit Approval( msg.sender, spender, _allowedValue[ msg.sender ][ spender ] );193 return true;194}195
196function decreaseAllowance( address spender, uint256 subtractedValue ) public override returns (bool) {197 uint256 oldValue = _allowedValue[ msg.sender ][ spender ];198 if (subtractedValue >= oldValue) {199 _allowedValue[ msg.sender ][ spender ] = 0;200 } else {201 _allowedValue[ msg.sender ][ spender ] = oldValue.sub( subtractedValue );202 }203 emit Approval( msg.sender, spender, _allowedValue[ msg.sender ][ spender ] );204 return true;205}206
207/* ========== INTERNAL FUNCTIONS ========== */208
209// called in a permit210function _approve( address owner, address spender, uint256 value ) internal override virtual {211 _allowedValue[owner][spender] = value;212 emit Approval( owner, spender, value );213}
Recommendation:
We advise them to do so to signficantly reduce the bytecode size of the contract.
Alleviation:
The code was refactored to properly utilize _approve
in all instances possible.
OEC-03C: Inexistent Error Messages
Type | Severity | Location |
---|---|---|
Code Style | Informational | sOlympusERC20.sol:L80, L81, L86, L87, L88, L94, L96 |
Description:
The linked require
checks contain no descriptive error messages.
Example:
79function setIndex( uint _INDEX ) external {80 require( msg.sender == initializer );81 require( INDEX == 0 );82 INDEX = gonsForBalance( _INDEX );83}84
85function setgOHM( address _gOHM ) external {86 require( msg.sender == initializer );87 require( address( gOHM ) == address(0) );88 require( _gOHM != address(0) );89 gOHM = IgOHM( _gOHM );90}91
92// do this last93function initialize( address stakingContract_ ) external {94 require( msg.sender == initializer );95
96 require( stakingContract_ != address(0) );97 stakingContract = stakingContract_;98 _gonBalances[ stakingContract ] = TOTAL_GONS;99
100 emit Transfer( address(0x0), stakingContract, _totalSupply );101 emit LogStakingContractUpdated( stakingContract_ );102 103 initializer = address(0);104}
Recommendation:
We advise them to be set so to aid in the debugging of the application and to also enable more accurate validation of the require
conditions.
Alleviation:
Error messages were introduced in all linked require
checks.
OEC-04C: Inexistent Variable Visibility Specifiers
Type | Severity | Location |
---|---|---|
Code Style | Informational | sOlympusERC20.sol:L45, L47 |
Description:
The linked variables have no visibility specifier explicitly set.
Example:
45address initializer;46
47uint INDEX; // Index Gons - tracks rebase growth
Recommendation:
We advise one to be set so to avoid potential compilation discrepancies in the future as the current compiler behaviour is to assign a specifier automatically.
Alleviation:
The Olympus DAO team considered this exhibit but opted not to apply any remediation for it.
OEC-05C: Redundant Event Argument
Type | Severity | Location |
---|---|---|
Code Style | Informational | sOlympusERC20.sol:L20, L118, L159 |
Description:
The current timestamp
that a LogSupply
event emits is already attached to each event emittance by the blockchain itself.
Example:
20event LogSupply(uint256 indexed epoch, uint256 timestamp, uint256 totalSupply );
Recommendation:
We advise the timestamp
member to be omitted from the event as it is redundant.
Alleviation:
The redundant event argument was safely omitted from the codebase.