In Harvester.sol, harvestNextStrategy harvests the first strategy then shifts the array such that the second strategy becomes the first (so on future calls, all the strategy get harvested sequentially).
A more efficient way (in terms of gas) to do this would be to have a state variable uint256 lastStrategyHarvest that starts at 0 and acts like an index for the last used strategy.
Tools Used
editor
Recommended Mitigation Steps
harvestNextStrategy would be rewritten like the following. Also removeStrategy may need some modifications depending on index.
Handle
0xsanson
Vulnerability details
Impact
In Harvester.sol,
harvestNextStrategy
harvests the first strategy then shifts the array such that the second strategy becomes the first (so on future calls, all the strategy get harvested sequentially). A more efficient way (in terms of gas) to do this would be to have a state variableuint256 lastStrategyHarvest
that starts at0
and acts like an index for the last used strategy.Tools Used
editor
Recommended Mitigation Steps
harvestNextStrategy
would be rewritten like the following. AlsoremoveStrategy
may need some modifications depending onindex
.