Omniscia Swisscoast Audit
GasPool Code Style Findings
GasPool Code Style Findings
GPL-01C: Deprecated Empty Revert
Type | Severity | Location |
---|---|---|
Code Style | GasPool.sol:L33, L42 |
Description:
The referenced statements will issue an empty revert
statement.
Example:
packages/contracts/contracts/GasPool.sol
26constructor(address _hchfTokenAddress, address _troveManagerAddress, address _borrowerOperationsAddress) public {27 troveManagerAddress = _troveManagerAddress;28 borrowerOperationsAddress = _borrowerOperationsAddress;29 hchfToken = IHCHFToken(_hchfTokenAddress);30 int responseCode = HederaTokenService.associateToken(address(this), hchfToken.getTokenAddress());31
32 if (responseCode != HederaResponseCodes.SUCCESS) {33 revert ();34 }35}36
37function approveToken(address token, address spender, uint256 amount) external returns (int responseCode) {38 _requireCallerIsBorrowerOperationsOrTroveManager();39 responseCode = HederaTokenService.approve(token, spender, amount);40
41 if (responseCode != HederaResponseCodes.SUCCESS) {42 revert ();43 }44}
Recommendation:
We advise a require
check with an accompanying message to be introduced, increasing the legibility of the check.
Alleviation (04618e407bddce5b22e9cadd787fd3334bd3afe6):
The referenced if-revert
statements have been replaced by require
statements per our recommendation, optimizing their legibility.
GPL-02C: Variable Mutability Specifiers (Immutable)
Type | Severity | Location |
---|---|---|
Gas Optimization | GasPool.sol:L21, L23, L24 |
Description:
The linked variables are assigned to only once during the contract's constructor
.
Example:
packages/contracts/contracts/GasPool.sol
21IHCHFToken public hchfToken;22
23address troveManagerAddress;24address borrowerOperationsAddress;25
26constructor(address _hchfTokenAddress, address _troveManagerAddress, address _borrowerOperationsAddress) public {27 troveManagerAddress = _troveManagerAddress;28 borrowerOperationsAddress = _borrowerOperationsAddress;29 hchfToken = IHCHFToken(_hchfTokenAddress);30 int responseCode = HederaTokenService.associateToken(address(this), hchfToken.getTokenAddress());31
32 if (responseCode != HederaResponseCodes.SUCCESS) {33 revert ();34 }35}
Recommendation:
We advise them to be set as immutable
greatly optimizing their read-access gas cost.
Alleviation (30f7253f635f6015267b0fcdb5554d259b76e5db):
The Swisscoast team opted to acknowledge this exhibit instead of applying the described optimization in the current iteration of the codebase.