Omniscia Steer Protocol Audit
TreasuryVester Code Style Findings
TreasuryVester Code Style Findings
TVR-01C: Inexistent Error Message
Type | Severity | Location |
---|---|---|
Code Style | TreasuryVester.sol:L65 |
Description:
The linked require
check has no error message explicitly defined.
Example:
65require(msg.sender == owner);
Recommendation:
We advise one to be set so to increase the legibility of the codebase and aid in validating the require
check's condition.
Alleviation (200f275c40cbd4798f4a416c044ea726755d4741):
An error message was properly introduced to the referenced require
check.
TVR-02C: Variable Mutability Specifiers (Immutable)
Type | Severity | Location |
---|---|---|
Gas Optimization | TreasuryVester.sol:L13, L15-L18 |
Description:
The linked variables are assigned to only once during the contract's constructor
.
Example:
22constructor(23 address steerToken_,24 address recipient_,25 address _owner, // Intended to be multisig. This address can cut off funding if user leaves Steer.26 uint256 vestingAmount_,27 uint256 vestingBegin_,28 uint256 vestingCliff_,29 uint256 vestingEnd_30) {31 require(vestingCliff_ >= vestingBegin_, "C");32 require(vestingEnd_ > vestingCliff_, "E");33
34 steerToken = steerToken_;35 recipient = recipient_;36 owner = _owner;37
38 vestingAmount = vestingAmount_;39 vestingBegin = vestingBegin_;40 vestingCliff = vestingCliff_;41 vestingEnd = vestingEnd_;42
43 lastUpdate = vestingBegin;44}
Recommendation:
We advise them to be set as immutable
greatly optimizing their read-access gas cost.
Alleviation (200f275c40):
All variables except for owner
have been properly set as immutable
, optimizing the codebase significantly.
Alleviation (0ed41ccc18):
The final owner
variable was set as immutable
optimizing the codebase to the fullest extent possible in this exhibit.
TVR-03C: Variable Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | TreasuryVester.sol:L16, L91 |
Description:
The vestingBegin
variable of the contract is utilized solely for the duration evaluation of the vesting period within _claim
.
Example:
81/// @dev Use this function to claim the claimable tokens.82function _claim() internal {83 require(block.timestamp >= vestingCliff, "T");84 uint256 amount;85 if (block.timestamp >= vestingEnd) {86 amount = IERC20(steerToken).balanceOf(address(this));87 } else {88 // Amount = accrued earnings since last update89 amount =90 (vestingAmount * (block.timestamp - lastUpdate)) /91 (vestingEnd - vestingBegin);92
93 // Update lastUpdate to current timestamp94 lastUpdate = block.timestamp;95 }96 IERC20(steerToken).safeTransfer(recipient, amount);97}
Recommendation:
We advise the delta to be stored as an immutable
variable instead of the vestingBegin
variable thus optimizing the execution cost of _claim
.
Alleviation (200f275c40cbd4798f4a416c044ea726755d4741):
The variable structure of the contract was optimized according to our recommendation, storing the vesting duration instead of the vesting beginning and optimizing _claim
function executions.