Omniscia Tokemak Audit
CurveControllerTemplate Code Style Findings
CurveControllerTemplate Code Style Findings
CCT-01C: Data Location Optimization
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | CurveControllerTemplate.sol:L41 |
Description:
The linked variable is declared as memory
in an external
function.
Example:
39function deploy(40 address poolAddress,41 uint256[N_COINS] memory amounts,42 uint256 minMintAmount43) 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
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | CurveControllerTemplate.sol:L194-L198 |
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:
189function _approve(190 IERC20 token,191 address spender,192 uint256 amount193) 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
Type | Severity | Location |
---|---|---|
Code Style | ![]() | CurveControllerTemplate.sol:L27, L30 |
Description:
The linked statements perform an interface type casting of an input address
argument.
Example:
24constructor(25 address manager,26 address addressRegistry,27 address curveAddressProvider28) 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.