Omniscia Evergon Labs Audit
LendingOracleFacetStorage Code Style Findings
LendingOracleFacetStorage Code Style Findings
LOS-01C: Combination of Logical Clauses
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | LendingOracleFacetStorage.sol:L213, L214 |
Description:
The referenced conditional clauses can be combined into a single one, permitting the inner else statement to be omitted.
Example:
213} else if (currentState != l.interferenceState) {214 if (StateFacetStorage.layout().stateHooksInfo[currentState].isStateTransitionSupported[l.interferenceState]) {215 // if the price is over the limit go to interference state and repeat all the checks.216 StateFacetStorage.layout().changeState(campaignId, currentState, l.interferenceState);217 currentState = l.interferenceState;218 campaignDetails.lastIndexSet = 0;219 index = length;220 } else {221 // else we stay forever in current state (should be final)222 break;223 }224} else {225 break;226}Recommendation:
We advise this optimization to be applied so as to reduce the code's gas cost.
Alleviation (71cda4ccfdcfa25fb96a4565f1f8143b350dd246):
The logical clauses have been collapsed as advised, optimizing the code's gas cost.
LOS-02C: Ineffectual Usage of Safe Arithmetics
| Type | Severity | Location |
|---|---|---|
| Language Specific | ![]() | LendingOracleFacetStorage.sol: • I-1: L121 • I-2: L129 • I-3: L238 |
Description:
The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.
Example:
123for (uint256 i; i < length; i++) {124 if (i == 0) {125 if (proportionsOverObligation[i] < l.minimumProportionOverObligation) {126 revert BelowMinimumProportion(proportionsOverObligation[i], l.minimumProportionOverObligation);127 }128 } else {129 if (proportionsOverObligation[i] < proportionsOverObligation[i - 1]) revert NonIncrementalProportions();130 }131}Recommendation:
Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statements to be wrapped in unchecked code blocks thereby optimizing their execution cost.
Alleviation (71cda4ccfdcfa25fb96a4565f1f8143b350dd246):
All referenced arithmetic operations have been wrapped in an unchecked code block as advised.
LOS-03C: Misleading Codebase Notions
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | LendingOracleFacetStorage.sol:L138, L139 |
Description:
The system defines that the LendingOracleFacetStorage::setPriceLimitsOnPostReceive function (i.e. post-receive) should be set as a before-hook of the buy back state.
Example:
136// This function should be registered as a before state hook on `FUNDED` state137// (i.e., after the creator (the address that gets the loan) receives the lended assets)138// So, should be a before hook on buyBackState139function setPriceLimitsOnPostReceive(Layout storage l, uint256 campaignId) internal {Recommendation:
We advise the system to utilize uniform and non-contradicting terminology across the codebase so as to better aid developers in adopting the ecosystem.
Alleviation (71cda4ccfdcfa25fb96a4565f1f8143b350dd246):
The Evergon Labs team opted to remove the documentation line above the function declaration, ensuring that the function's description by itself is cohesive and thus addressing this exhibit.
LOS-04C: Non-Standard Storage Slot Definition
| Type | Severity | Location |
|---|---|---|
| Standard Conformity | ![]() | LendingOracleFacetStorage.sol:L36 |
Description:
The referenced declaration will define a storage slot for use by a facet of the system's main EIP-2535 Diamond, however, the way it is declared does not adhere to the latest standards.
Example:
36bytes32 internal constant STORAGE_SLOT = keccak256("Evergonlabs.Tmi-Tokenizer.storage.LendingOracleFacetStorage");Recommendation:
We advise the EIP-7201 name-spaced layout approach to be adhered to similarly to OpenZeppelin and other relevant standard libraries, ensuring consistency among the ecosystem's widely utilized libraries and conforming to the latest standards.
Alleviation (71cda4ccfdcfa25fb96a4565f1f8143b350dd246):
The referenced slot definition has been updated to its standardized EIP-7201 representation, addressing this exhibit.
LOS-05C: Repetitive Value Literal
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | LendingOracleFacetStorage.sol:L39 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
39uint256 internal constant _ONE_MILLION = 1_000_000;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 (71cda4ccfd):
The Evergon Labs team evaluated this recommendation to be invalid due to the constant appearing once across the codebase, however, the same value is present in the FixedInterestBuybackAmountFacetStorage implementation rendering it to remain valid albeit open and thus acknowledged.
Alleviation (d7b20c134f):
The constant literal has been relocated to a contract-level declaration within the GeneralStorage common dependency, addressing this exhibit.
