Omniscia BlazeSwap Audit

BlazeSwapRouter Code Style Findings

BlazeSwapRouter Code Style Findings

BSR-01C: Incorrect Assumptions of Gas Usage

Description:

The linked statements labelled as "gas savings" are incorrect as they are caching an immutable value (which is swapped as a literal by the compiler) to a local variable, thus ultimately incurring an increase in gas.

Example:

contracts/periphery/BlazeSwapRouter.sol
113address _wNat = wNat; // gas savings

Recommendation:

We advise the statements to be omitted and the wNat variable to be used directly in all instances to properly optimize the codebase.

Alleviation:

All incorrect gas optimizations have been properly reverted from the codebase as advised.

BSR-02C: Ineffectual Usage of Safe Arithmetics

Description:

The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.

Example:

contracts/periphery/BlazeSwapRouter.sol
127if (msg.value > amountNAT) TransferHelper.safeTransferNAT(msg.sender, msg.value - amountNAT);

Recommendation:

Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statements to be wrapped in unchecked code blocks thereby optimizing their execution cost.

Alleviation:

The BlazeSwap team considered this exhibit but opted not to apply a remediation for it as they have stated they will not remediate any issues of minor severity and below.

BSR-03C: Inexplicable Code Deviation

Description:

The linked statement invokes the pairFor function of BlazeSwapLibrary whilst in all other instances the public function pairFor is invoked instead which performs the same statement.

Example:

contracts/periphery/BlazeSwapRouter.sol
122address pair = BlazeSwapLibrary.pairFor(factory, token, _wNat);

Recommendation:

We advise the pairFor function to be invoked in this instance as well to streamline the codebase's style.

Alleviation:

The proper pairFor function similarly to the rest of the contract's code is now invoked in the referenced statement alleviating this exhibit.