Omniscia Tokemak Network Audit

BalancerController Code Style Findings

BalancerController Code Style Findings

BCE-01C: Inefficient Data Type

TypeSeverityLocation
Gas OptimizationInformationalBalancerController.sol:L71, L75, L82

Description:

The linked data types utilized for the for loop evaluations are inefficient given that the EVM is better suited dealing with 256-bit length data types and any type less than that requires extra gas to operate on.

Example:

contracts/controllers/BalancerController.sol
71uint8 tokensLength = uint8(tokens.length);
72
73uint256[] memory balancesBefore = new uint256[](tokensLength);
74
75for (uint8 i = 0; i < tokensLength; i++) {
76 balancesBefore[i] = IERC20(tokens[i]).balanceOf(address(this));
77}
78
79_approve(IERC20(poolAddress), poolAddress, poolAmountIn);
80pool.exitPool(poolAmountIn, minAmountsOut);
81
82for (uint8 i = 0; i < tokensLength; i++) {
83 uint256 balanceAfter = IERC20(tokens[i]).balanceOf(address(this));
84 require(balanceAfter > balancesBefore[i], "MUST_INCREASE");
85}

Recommendation:

We advise all linked uint8 data types to be set as uint256 to optimize the codebase.

Alleviation:

Proper uint256 data types are now utilized across the loops.