yaxis-project / metavault

The MetaVault will allow users to take advantage of the best yield farming strategies while minimizing gas fees and transferring difficult management decisions to an incentivized community governance.
https://yaxis.io/
MIT License
33 stars 19 forks source link

Estimates and routerArray #114

Closed GainsGoblin closed 2 years ago

GainsGoblin commented 3 years ago

Fixes:

gpersoon commented 3 years ago

At the _harvest functions: Either use arrayCounter everywhere were applicable (more readable, but slightly more gas) Or (if you really want to save gas): Add comments where arrayCounter is replaced with constants (e.g. 0 / i+1) After the _extraRewardsLength loop, arrayCounter can be calculated directly: arrayCounter = _extraRewardsLength + 1; and no need to increase arrayCounter in the loop; The last increase "arrayCounter += 2;" for example in ETHConvexStrategy.sol isn't necessary

gpersoon commented 3 years ago

Why isn't getEstimates() using safemath consistently? (now it's mix of mul / sub / div / - )

gpersoon commented 3 years ago

I don't think the following constructions in getEstimates() are valid: function getEstimates() public view returns (uint256[] memory _estimates) { _estimates[0]= ... _estimates[_estimates.length] = ...

I can't get them working in remix. It does compile but I get an invalid opcode when executing the code. I think you should allocate memory first and then index the items, something like: _estimates = new uint[](crvRewards.extraRewardsLength() + 5);

gpersoon commented 3 years ago

in getEstimates() _slippage is always used as: ONE_HUNDRED_PERCENT - _slippage might as well calculate that directly to save some gas: uint256 _notSlippage = ONE_HUNDRED_PERCENT - IHarvester(manager.harvester()).slippage();

and then replace "ONE_HUNDRED_PERCENT - _slippage" with "_notSlippage"