Omniscia fetchai Audit
LendingPool Code Style Findings
LendingPool Code Style Findings
LPL-01C: Duplication of Code
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | LendingPool.sol:L230-L236 |
Description:
The statements within the linked getUtilizationRatio
function replicate the statements of the argument-based getUtilizationRatio
function.
Example:
224function getUtilizationRatio() public view override returns (uint256) {225 uint256 iSCTotal = lendingPoolStorageContract.iSCTotal();226 uint256 xSCTotal = lendingPoolStorageContract.xSCTotal();227
228 (uint256 iSCValue, uint256 xSCValue) = getSnapshotTokenValues();229
230 uint256 iSCTotalValue = iSCTotal.mul(iSCValue);231 uint256 xSCTotalValue = xSCTotal.mul(xSCValue);232
233 if (iSCTotalValue == 0 || xSCTotalValue == 0) return 0;234
235 // This is legit because we have tested for xSCTotalValue == 0236 return (iSCTotalValue * (ONE_UNIT)) / xSCTotalValue;237}238
239function getUtilizationRatio(240 uint256 iSCTotal,241 uint256 xSCTotal,242 uint256 iSCValue,243 uint256 xSCValue244) public view override returns (uint256) {245 uint256 iSCTotalValue = iSCTotal.mul(iSCValue);246 uint256 xSCTotalValue = xSCTotal.mul(xSCValue);247
248 if (iSCTotalValue == 0 || xSCTotalValue == 0) return 0;249
250 // This is legit because we have tested for xSCTotalValue == 0251 return (iSCTotalValue * (ONE_UNIT)) / xSCTotalValue;252}
Recommendation:
We advise the argument-based getUtilizationRatio
to be utilized within the no-argument getUtilizationRatio
function to reduce the bytecode size of the contract and enforce standardization.
Alleviation:
The argumented getUtilizationRatio
function is now properly utilized by its no-argument counterpart.
LPL-02C: Function Mutability Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | LendingPool.sol:L239-L244 |
Description:
The getUtilizationRatio
function linked does not perform any state changes or read from the state of the contract.
Example:
239function getUtilizationRatio(240 uint256 iSCTotal,241 uint256 xSCTotal,242 uint256 iSCValue,243 uint256 xSCValue244) public view override returns (uint256) {245 uint256 iSCTotalValue = iSCTotal.mul(iSCValue);246 uint256 xSCTotalValue = xSCTotal.mul(xSCValue);247
248 if (iSCTotalValue == 0 || xSCTotalValue == 0) return 0;249
250 // This is legit because we have tested for xSCTotalValue == 0251 return (iSCTotalValue * (ONE_UNIT)) / xSCTotalValue;252}
Recommendation:
As a result, we advise its mutability specifier to be set to pure
rather than view
.
Alleviation:
The function was adjusted in both its interface and implementation to be pure
.
LPL-03C: Redundant msg.sender
Check
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | LendingPool.sol:L596 |
Description:
The function evaluates that the msg.sender
is not equivalent to the zero address, however, such a condition is close-to-impossible in manifesting.
Example:
595require(596 msg.sender != address(0) && lendingPoolWalletAddress != address(0),597 "LendingPool: Deposit ACT to zero address"598);
Recommendation:
We advise the check to be omitted, as currently over a billion in value assets sit at the zero-address and an account being able to transact on behalf of it would cause more widespread effects across the industry.
Alleviation:
The msg.sender
check of the require
comparison chain was safely omitted from the codebase.