Omniscia Bluejay Finance Audit

BondGovernor Code Style Findings

BondGovernor Code Style Findings

BGR-01C: Duplicate Application of Modifier

Description:

The policyExist modifier is applied twice in two instances redundantly, once at the top-level adjustPolicy call and once at the inner updateControlVariable call as well as once at the getPolicy top-level call and once in the getControlVariable call.

Example:

packages/contracts/contracts/BondGovernor.sol
73function adjustPolicy(
74 address asset,
75 uint256 targetControlVariable,
76 uint256 timeToTargetControlVariable,
77 uint256 minimumPrice
78) public override onlyOwner policyExist(asset) {
79 require(
80 targetControlVariable >= RAY,
81 "Target control variable less than 1"
82 );
83
84 updateControlVariable(asset);

Recommendation:

We advise it to be omitted from the top-level call as it is applied by the inner call.

Alleviation:

The redundant usage of the modifier at the top-level has been safely omitted.

BGR-02C: Inexistent Visibility Specifiers

Description:

The linked variables have no visibility specifiers explicitly set.

Example:

packages/contracts/contracts/BondGovernor.sol
10uint256 constant WAD = 10**18;
11uint256 constant RAY = 10**27;

Recommendation:

We advise them to be set to avoid potential compilation discrepancies in the future as the current behaviour is for the compiler to assign one automatically which may deviate between pragma versions.

Alleviation:

The linked variables have had a private visibility specifier explicitly set thereby alleviating this exhibit.

BGR-03C: Redundant Safe Arithmetics

Description:

The linked subtractions are guaranteed to never underflow based on the conditionals that surround them.

Example:

packages/contracts/contracts/BondGovernor.sol
45if (timeElapsed > policies[asset].timeToTargetControlVariable) {
46 policies[asset].timeToTargetControlVariable = 0;
47} else {
48 policies[asset].timeToTargetControlVariable -= timeElapsed;
49}

Recommendation:

We advise them to be wrapped to unchecked code blocks optimizing their gas cost.

Alleviation:

The unchecked code blocks have been applied to all relevant statements optimizing the codebase's gas cost.