Omniscia Kanpeki Finance Audit

BorrowManager Code Style Findings

BorrowManager Code Style Findings

BMR-01C: Duplicate ERC20 Transfer

TypeSeverityLocation
Gas OptimizationInformationalBorrowManager.sol:L589-L590, L596-L600

Description:

The liquidate function can perform two transfers of the same asset and with the same sender and recipient arguments, thereby rendering two executions redundant.

Example:

contracts/managers/BorrowManager.sol
589// fee: collateral vault -> fee burner
590IERC20(debt.collateralToken).safeTransferFrom(collateralVault, burner, defaultFee);
591
592// liquidator compensation: collateral vault -> liquidator
593IERC20(debt.collateralToken).safeTransferFrom(collateralVault, msg.sender, compensation);
594
595
596if ((debt.collateral - compensation) > 0)
597{
598 // excess collateral: collateral vault -> fee burner; related to KAE's extension utility
599 IERC20(debt.collateralToken).safeTransferFrom(collateralVault, burner, debt.collateral - compensation);
600}

Recommendation:

We advise the if block to be optimized to execute either one or the other transfer to significantly reduce the gas cost of the function.

Alleviation:

The code was optimized to perform one ERC-20 transfer instead of two redundantly.

BMR-02C: Out of Date Documentation

TypeSeverityLocation
Code StyleInformationalBorrowManager.sol:L369, L370

Description:

The linked documentation line and ensuing statements differ as the documentation states that a value of 100 is being used whereas a value of 75 is actually applied.

Example:

contracts/managers/BorrowManager.sol
369// 100 = 1% in basis point; not using getBorrowFeeOnDebt as the Debt.token is what's being tx'd in this function
370uint256 debtFee = _calcPercentOf(debt.amount, 75);

Recommendation:

We advise the canonical value to be enforced by either updating the documentation or statement, depending on which of the two is incorrect.

Alleviation:

The documentation was updated to reflect the statements of the code.

BMR-03C: Redundant Visibility Specifiers

TypeSeverityLocation
Gas OptimizationInformationalBorrowManager.sol:L38, L39

Description:

The linked variables are meant to be internally accessible constant ones yet are declared as public.

Example:

contracts/managers/BorrowManager.sol
38bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
39bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

Recommendation:

We advise them to be set as private or internal to reduce the bytecode and gas cost of the contract's deployment.

Alleviation:

The Kanpeki Finance team opted not to apply this exhibit.