code-423n4 / 2021-06-gro-findings

0 stars 1 forks source link

Uneccessary loop in Buoy3Pool._stableToLp #89

Closed code423n4 closed 3 years ago

code423n4 commented 3 years ago

Handle

GalloDaSballo

Vulnerability details

Impact

Detailed description of the impact of this finding.

_stableToLp in Buoy3Pool.sol: https://github.com/code-423n4/2021-06-gro/blob/091660467fc8d13741f8aafcec80f1e8cf129a33/contracts/pools/oracle/Buoy3Pool.sol#L184

Receives a list of N_COINS, as such there's no need to loop again to essentially re-declare the same variable

Proof of Concept

You can refactor to:

    function _stableToLp(uint256[N_COINS] memory tokenAmounts, bool deposit) internal view returns (uint256) {
        require(tokenAmounts.length == N_COINS, "deposit: !length");
        return curvePool.calc_token_amount(tokenAmounts, deposit);
    }

Tools Used

Recommended Mitigation Steps

kitty-the-kat commented 3 years ago

27

ghoul-sol commented 3 years ago

Duplicate of #27