Omniscia Swisscoast Audit

PythCaller Code Style Findings

PythCaller Code Style Findings

PCR-01C: Deprecated Revert Pattern

TypeSeverityLocation
Code StylePythCaller.sol:L66

Description:

The referenced statement will issue an empty revert.

Example:

packages/contracts/contracts/Dependencies/PythCaller.sol
65if (price < 0 || expo > 0 || expo < -255) {
66 revert();
67}

Recommendation:

We advise a require check with an accompanying message to be introduced, increasing the legibility of the check.

Alleviation (04618e407bddce5b22e9cadd787fd3334bd3afe6):

As part of alleviations for PCR-01M, the code will issue a return statement instead of a revert indirectly addressing this exhibit.

PCR-02C: Optimization of Returned Arguments

Description:

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

Example:

packages/contracts/contracts/Dependencies/PythCaller.sol
56if (hbarChfPrice > 0) return (true, hbarChfPrice, publishTime);
57return (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.

PCR-03C: Repetitive Value Literal

TypeSeverityLocation
Code StylePythCaller.sol:L48, L49

Description:

The linked value literal is repeated across the codebase multiple times.

Example:

packages/contracts/contracts/Dependencies/PythCaller.sol
48uint256 basePriceHBARUSD = convertToUint(priceHBARUSD, expoHBARUSD, 8);

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 (04618e407bddce5b22e9cadd787fd3334bd3afe6):

The Swisscoast team evaluated this exhibit but opted to acknowledge it in the current iteration of the codebase

PCR-04C: Variable Mutability Specifier (Immutable)

Description:

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

Example:

packages/contracts/contracts/Dependencies/PythCaller.sol
20IPyth public pyth;
21
22constructor (address _pythAddress) public {
23 pyth = IPyth(_pythAddress);
24}

Recommendation:

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

Alleviation (04618e407bddce5b22e9cadd787fd3334bd3afe6):

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