Omniscia Swisscoast Audit

SupraCaller Code Style Findings

SupraCaller Code Style Findings

SCR-01C: Improper Return Arguments

TypeSeverityLocation
Code StyleSupraCaller.sol:L41, L42

Description:

Per the official Supra documentation, the referenced functions are expected to yield a PriceFeed structure.

Example:

packages/contracts/contracts/Dependencies/SupraCaller.sol
41(uint256 roundHBARUSD, uint256 decimalsHBARUSD, uint256 _timeHBARUSD, uint256 _priceHBARUSD) = supra.getSvalue(_priceIndexHBARUSD);
42(uint256 roundUSHCHF, uint256 decimalsUSHCHF, uint256 _timeUSHCHF, uint256 _priceUSHCHF) = supra.getSvalue(_priceIndexUSDCH);

Recommendation:

We advise the relevant struct to be defined in the codebase and utilized as the return argument of the call, optimizing the code's legibility.

Alleviation (04618e407bddce5b22e9cadd787fd3334bd3afe6):

The feature the exhibit describes is not available in the Solidity compiler version that the Swisscoast team wishes to utilize with the codebase, rendering the recommendation inapplicable.

SCR-02C: Inefficient Integration of Supra

Description:

The referenced statements will perform two unique calls to the ISupra::getSvalue function.

Example:

packages/contracts/contracts/Dependencies/SupraCaller.sol
41(uint256 roundHBARUSD, uint256 decimalsHBARUSD, uint256 _timeHBARUSD, uint256 _priceHBARUSD) = supra.getSvalue(_priceIndexHBARUSD);
42(uint256 roundUSHCHF, uint256 decimalsUSHCHF, uint256 _timeUSHCHF, uint256 _priceUSHCHF) = supra.getSvalue(_priceIndexUSDCH);

Recommendation:

We advise the code to instead integrate the ISupra::getSvalues function which would permit prices for both feeds to be yielded in a single call.

Alleviation (04618e407bddce5b22e9cadd787fd3334bd3afe6):

The feature the exhibit describes is not available in the Solidity compiler version that the Swisscoast team wishes to utilize with the codebase, rendering the recommendation inapplicable.

SCR-03C: Optimization of Returned Arguments

Description:

The referenced code block will inefficiently implement two different return statements.

Example:

packages/contracts/contracts/Dependencies/SupraCaller.sol
51if (hbarChfPrice > 0) {
52 uint256 positiveValue = hbarChfPrice;
53 return (true, positiveValue, publishTime);
54}
55return (false, 0, publishTime);

Recommendation:

We advise a single return statement to be present, with the first argument being the result of hbarChfPrice > 0, the second argument being the hbarChfPrice result itself, and the final argument being the publishTime.

Alleviation (04618e407bddce5b22e9cadd787fd3334bd3afe6):

The referenced return statements were optimized into one as advised.

SCR-04C: Variable Mutability Specifier (Immutable)

Description:

The linked variable is assigned to only once during the contract's constructor.

Example:

packages/contracts/contracts/Dependencies/SupraCaller.sol
18ISupra public supra;
19
20constructor (address _supraMasterAddress) public {
21 supra = ISupra(_supraMasterAddress);
22}

Recommendation:

We advise it to be set as immutable greatly optimizing its read-access gas cost.

Alleviation (04618e407bddce5b22e9cadd787fd3334bd3afe6):

The supra contract-level variable of the contract has been set as immutable, optimizing its read-access gas cost significantly.