Some functions copy the given array-type parameters to local variables first and provide the local variables to other functions as parameters afterward. The array copying operation can be omitted to save gas.
Proof of Concept
For example, consider the _stableToLp function in Buoy3Pool. A more gas-efficient implementation is to directly provide tokenAmounts to curvePool, as follows:
Handle
shw
Vulnerability details
Impact
Some functions copy the given array-type parameters to local variables first and provide the local variables to other functions as parameters afterward. The array copying operation can be omitted to save gas.
Proof of Concept
For example, consider the
_stableToLp
function inBuoy3Pool
. A more gas-efficient implementation is to directly providetokenAmounts
tocurvePool
, as follows:Similarly, we can also optimize the following functions to save gas.
Referenced code: Buoy3Pool.sol#L184-L191 Buoy3Pool.sol#L174-L182 Buoy3Pool.sol#L153-L163 Insurance.sol#L160-L169 Insurance.sol#L316-L320
Recommended Mitigation Steps
It is shown as above.