Omniscia Tokemak Audit

CurveControllerTemplate Code Style Findings

CurveControllerTemplate Code Style Findings

CCT-01C: Data Location Optimization

Description:

The linked variable is declared as memory in an external function.

Example:

contracts/controllers/CurveControllerTemplate.sol
39function deploy(
40 address poolAddress,
41 uint256[N_COINS] memory amounts,
42 uint256 minMintAmount
43) external onlyManager {

Recommendation:

We advise it to be set as calldata optimizing the codebase.

Alleviation:

The variable is now properly set as calldata optimizing its read access gas cost.

CCT-02C: Ineffectual Extraneous Approval Logic

Description:

The _approve function of the contract performs multiple contract calls redundantly as the chain of operations it performs results in the same state as a single approve call would.

Example:

contracts/controllers/CurveControllerTemplate.sol
189function _approve(
190 IERC20 token,
191 address spender,
192 uint256 amount
193) internal {
194 uint256 currentAllowance = token.allowance(address(this), spender);
195 if (currentAllowance > 0) {
196 token.safeDecreaseAllowance(spender, currentAllowance);
197 }
198 token.safeIncreaseAllowance(spender, amount);
199}

Recommendation:

We advise the approve function to be utilized directly as the code currently reads the allowance, sets it to zero if it is positive and then re-sets it to the new value essentially overwriting it which is the exact behaviour of approve.

Alleviation:

The Tokemak team considered this exhibit but opted not to apply a remediation for it in the current iteration of the codebase.

CCT-03C: Redundant Type Casting

Description:

The linked statements perform an interface type casting of an input address argument.

Example:

contracts/controllers/CurveControllerTemplate.sol
24constructor(
25 address manager,
26 address addressRegistry,
27 address curveAddressProvider
28) public BaseController(manager, addressRegistry) {
29 require(curveAddressProvider != address(0), "INVALID_CURVE_ADDRESS_PROVIDER");
30 addressProvider = IAddressProvider(curveAddressProvider);
31}

Recommendation:

We advise the input type to be changed directly, optimizing the code's legibility.

Alleviation:

The variable is now directly set as an IAddressProvider input alleviating this exhibit.