Omniscia Bonq Audit

trove Code Style Findings

trove Code Style Findings

TRO-01C: Ineffectual Value Assignment

TypeSeverityLocation
Gas Optimizationtrove.sol:L37

Description:

The TOKEN_PRECISION value is overwritten during the contract's constructor execution thereby making any assignment to it during declaration redundant.

Example:

contracts/trove.sol
37uint256 public TOKEN_PRECISION = 1e18;

Recommendation:

We advise the assignment to be omitted.

Alleviation:

The Bonq Protocol team has omitted the ineffectual value assignment

TRO-02C: Variable Mutability Specifiers (Immutable)

TypeSeverityLocation
Gas Optimizationtrove.sol:L27, L28, L37

Description:

The linked variables are assigned to only once during the contract's constructor.

Example:

contracts/trove.sol
54// solhint-disable-next-line func-visibility
55constructor(
56 address _factory,
57 address _token,
58 address _troveOwner
59) Ownable() {
60 _transferOwnership(_troveOwner);
61 _grantRole(OWNER_ROLE, _troveOwner);
62 _grantRole(OWNER_ROLE, _factory);
63 factory = ITroveFactory(_factory);
64 token = IERC20(_token);
65 TOKEN_PRECISION = 10**(IERC20Metadata(_token).decimals());
66 liqTokenRateSnapshot = factory.liquidationPool(_token).liqTokenRate();
67 // allow the fee recipient contract to transfer as many tokens as it wants from the trove
68 factory.stableCoin().approve(address(factory.feeRecipient()), MAX_INT);
69}

Recommendation:

We advise them to be set as immutable greatly optimizing their read-access gas cost.

Alleviation:

The Bonq Protocol team has marked the factory, token and TOKEN_PRECISION variables as immutable.