Omniscia Tangible Audit

RealtyOracleV2 Code Style Findings

RealtyOracleV2 Code Style Findings

ROV-01C: Inefficient Fetching of First Entry

Description:

The RealtyOracleV2::marketPriceTotalNativeCurrency function will inefficiently fetch the first fingerprint's data twice.

Example:

contracts/priceOracles/RealtyOracleV2.sol
280currency = chainlinkRWAOracle.fingerprintData(fingerprints[0]).currency;
281
282for (uint256 i; i < length; ) {
283 IChainlinkRWAOracle.Data memory data = chainlinkRWAOracle.fingerprintData(
284 fingerprints[i]
285 );
286 require(currency == data.currency, "not same currency");
287
288 nativePrice += data.weSellAt + data.lockedAmount;
289
290 unchecked {
291 ++i;
292 }
293}

Recommendation:

We advise the code to properly utilize the first fetched instance outside the for loop and to adjust the for loop to begin at 1 instead of 0.

Alleviation (2ad448279d9e8e4b6edd94bcd2eb22129b6f7357):

The code was optimized per our recommendation, initializing nativePrice with the value of the first fingerprint data and iterating in the for loop with an initial index of 1.

ROV-02C: Redundant Ternary Operator

Description:

The evaluation of the referenced ternary operator is redundant as it will yield false in case its conditional is true and true if its conditional is false.

Example:

contracts/priceOracles/RealtyOracleV2.sol
137bool useFingerprint = _fingerprints.length == 0 ? false : true;

Recommendation:

We advise the ternary operator to be replaced by the conditional it evaluates in its negated form, optimizing its gas cost.

Alleviation (2ad448279d9e8e4b6edd94bcd2eb22129b6f7357):

The redundant ternary operator was replaced by a direct conversion of the conditional it used to evaluate. To note, the negation (!) can be assimilated in the comparison (==) to increase the legibility of the codebase (i.e. a != b is better than !(a == b)).

Despite of this, we consider the original recommendation applied and thus this exhibit as addressed.