Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize harvest #4

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jazinheira
Copy link

Optimized the harvest function by trying to:

  1. Remove extra variables like those regarding the treeVaultPosition
  2. Limit the amount of balance checks (these are expensive!) and reuse/calculate when possible
  3. Consolidate to limit balance checks and extra ifs

I added minimums for some of the harvests and the want deposit, since in the example transaction the amount removed from 3curve costs less than the gas! Initially these vars should be 0 but can be updated by governance using the setMinPoolHarvest() function. Note about the minimums, they are actually right below the minimum; harvests run if the amount to harvest is greater than it. These vars are:

  • minCvxCrvRewardsPoolHarvest
  • minCvxRewardsPoolHarvest
  • minThreeCrvHarvest
  • minWantToDeposited

Gas Usage (using tests/test_custom.py and running tx.gas_usage):

Original - 5,547,060
Optimized0 - 5,503,783
Optimized* - 81,216

0 Setting all minimums to 0 so all harvests and deposits proceed. This shows a minimum savings of ~45,000 wei

  • Setting all minimums to max uint256 - 1; nothing is harvested and nothing is deposited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant