Omniscia Swisscoast Audit
SupraCaller Code Style Findings
SupraCaller Code Style Findings
SCR-01C: Improper Return Arguments
Type | Severity | Location |
---|---|---|
Code Style | SupraCaller.sol:L41, L42 |
Description:
Per the official Supra documentation, the referenced functions are expected to yield a PriceFeed
structure.
Example:
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
Type | Severity | Location |
---|---|---|
Gas Optimization | SupraCaller.sol:L41, L42 |
Description:
The referenced statements will perform two unique calls to the ISupra::getSvalue
function.
Example:
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
Type | Severity | Location |
---|---|---|
Gas Optimization | SupraCaller.sol:L51-L55 |
Description:
The referenced code block will inefficiently implement two different return
statements.
Example:
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)
Type | Severity | Location |
---|---|---|
Gas Optimization | SupraCaller.sol:L18 |
Description:
The linked variable is assigned to only once during the contract's constructor
.
Example:
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.