Omniscia Tren Finance Audit
FeeCollector Code Style Findings
FeeCollector Code Style Findings
FCR-01C: Inefficient Data Location
Type | Severity | Location |
---|---|---|
Gas Optimization | FeeCollector.sol:L169 |
Description:
The data location specifier of the referenced variable is set as memory
even though only one member of it is read.
Example:
160/// @inheritdoc IFeeCollector161function liquidateDebt(162 address _borrower,163 address _asset164)165 external166 override167 onlyTrenBoxManager168{169 FeeRecord memory mRecord = feeRecords[_borrower][_asset];170 if (mRecord.amount != 0) {171 _closeExpiredOrLiquidatedFeeRecord(_borrower, _asset, mRecord.amount);172 }173}
Recommendation:
We advise the member to be read directly and stored to a local uint256
variable, significantly optimizing the gas cost of the function.
Alleviation (f6f1ad0b8f24a96ade345db1dd05a1878eb0f761):
The referenced code block has been optimized as advised utilizing a local uint256
variable instead of a full memory
structure.
FCR-02C: Repetitive Value Literal
Type | Severity | Location |
---|---|---|
Code Style | FeeCollector.sol:L97, L125, L151, L156, L237, L264 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
97uint256 minFeeAmount = (MIN_FEE_FRACTION * _feeAmount) / 1 ether;
Recommendation:
We advise it to be set to a constant
variable instead, optimizing the legibility of the codebase.
In case the constant
has already been declared, we advise it to be properly re-used across the code.
Alleviation (f6f1ad0b8f24a96ade345db1dd05a1878eb0f761):
The referenced value literal 1 ether
has been properly relocated to a contract-level constant
declaration labelled DENOMINATOR
, optimizing the code's legibility.