Badger-Finance / gitcoin

Repo for gitcoin hack-a-thons,bonunties and code snippets.
7 stars 0 forks source link

Optimize Convex Strategy Harvests #29

Closed dapp-whisperer closed 2 years ago

dapp-whisperer commented 3 years ago

Badger uses Convex to earn yield on users' Curve LP tokens via the StrategyConvexStakingOptimizer contract. The harvest function needs to process a number of tokens, leading to an expensive harvest() operation.

The contract was designed for clarity over efficiency, though as it matures it makes sense to optimize it as these harvests represents a significant ETH spend. See this recent harvest transaction for reference.

Badger vaults are based off of the Yearn V1 architecture. If you're not familiar with that, you can learn more via the strategy mix docs.

Task

Optimize the harvest function of the StrategyConvexStakingOptimizer using the strategy mix. There is no requirement as to the level of optimization as long as the changes are well-considered and well-documented.

There will be payouts to the top three submissions, measured in terms of objective optimization and subjective architectural quality.

Optimization Ideas

  1. Avoid processing certain rewards tokens unless sufficient value of that token is accumulated.
  2. Consider how to reduce SLOAD and STORE operations in general.

Requirements

  1. Record the gas costs of a harvest operation in a forked environment for both current and optimized contract.
  2. All events and the return value must be retained.
  3. Do not remove any security sanity checks
  4. Provide plaintext documentation of the optimizations applied and the reasoning behind them.
  5. Provide a diff of strategy code.

Bounty

We will pay 300 BADGER split between the top 3 contributions. We will pay an additional 300 BADGER to any submission we deploy and use.

Questions

Find us on our dev discord: https://discord.gg/Tf2PucrXcE

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 600.0 BADGER (11916.0 USD @ $19.86/BADGER) attached to it.

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 3 weeks from now. Please review their action plans below:

1) antonyip has started work.

Optimization of harvest().. Might not finish tho :P

Learn more on the Gitcoin Issue Details page.

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 600.0 BADGER (11082.00 USD @ $19.07/BADGER) has been submitted by:


Fihariyanto commented 3 years ago

Ok

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 600.0 BADGER (9522.00 USD @ $14.94/BADGER) has been submitted by:

  1. @antonyip

@tritium-vlk please take a look at the submitted work: