-
Notifications
You must be signed in to change notification settings - Fork 113
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
Revo - Tokenized, Auto-Compounding Yield Farming & DeFi On-Ramp #51
Open
jophish
wants to merge
70
commits into
celo-org:master
Choose a base branch
from
revo-market:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chore: set up ts, yarn
chore: hardhat, mocha with typescript
hardhat configs
* Add ubelib * Remove emacs tempfile
* created farm-bot.sol, just has a withdraw method * fixes for farm-bot.sol * WIP added test file for farm-bot.ts * ube contracts * updated hardhat-ethers * updated .gitignore * tried implementing multi-user deposits, so far manual tests would require approving the smart contract from your wallet which will take some more effort. * wrote hacky script to approve farm bot for deposit of cusd * WIP trying to write test for multi token support * renamed 'approve' script, for clarity * fixes * finished tests * removed unrelated stuff * docs * fixed issue where contractkit is stopping us from compiling (ignoring dependencies on tsc... yolo!!) * switched to a hardcoded abi so you don't get weird errors if you forget to compile the contracts before running the test script
Also includes refactor of how balances are tracked (introduces "farm points" concept) Farm points are an abstraction that allows for gas-efficient balance tracking. If we just mapped user addresses to LP tokens, then every time we reinvest farming rewards into the liquidity pool, we'd need to update *every user's balance* of LP tokens. This would create gas costs that scale linearly with the number of users investing in the farm. Conceptually, all we need to track is a user's share of the total balance held by the farm. So if we know how much they put into farm bot, and how much farm bot was worth at that time, we should be able to grow their share appropriately as the total assets held by farm bot increase. The way I did that is with "Farm Points" (FP for short). Initially, farm points can be bought 1:1 for LP tokens. However, as Farm Bot's assets grow from harvesting rewards, the ratio of LP tokens held by farm bot to the LP tokens invested increases. Over time, a farm point will be worth much more than 1 LP token. The FP:LP ratio will be tracked with 3 fields: - fpBalances: maps user address to farm points they hold - lpTotalBalance: tracks the total number of LP tokens farm bot holds - fpTotalBalance: tracks the total number of FP points held by users The fields will be updated as follows: - on deposit, user "purchases" farm points at the current rate (1:1 if lpTotalBalance is 0, otherwise fpTotalBalance / lpTotalBalance). all 3 fields are updated. - on withdrawal, user "cashes out" at the current rate (calculated same as above). all 3 fields updated. - on reinvest, lpTotalBalance increases by whatever farm bot is able to purchase with rewards it has harvested. Only lpTotalBalance is updated (it increases) Deposit/withdrawal only affect the `fpBalances` entry for one user, and reinvest doesn't affect the `fpBalances` field at all. This makes it much more gas efficient than updating the LP balance of every user each time rewards are harvested. Notice that the only step where the fields don't grow together is `reinvest`. This is how the farm points will grow in value over time. Eventually we can issue FPs as ERC20 tokens, creating a marketplace of shares in farm bot. For now, a mapping will suffice. fixes #6
Working autocompounding draft (very hacky) + some deploy stuff
also separated out some farm bot contract utils for re-use with e2e tests and converted the e2e test file to typescript
jophish
changed the title
Revo - Tokenized Autocompounded Yield Farming & Defi On-Ramp
Revo - Tokenized,Auto-compounding Yield Farming & DeFi On-Ramp
Nov 28, 2021
jophish
changed the title
Revo - Tokenized,Auto-compounding Yield Farming & DeFi On-Ramp
Revo - Tokenized, Auto-compounding Yield Farming & DeFi On-Ramp
Nov 28, 2021
jophish
changed the title
Revo - Tokenized, Auto-compounding Yield Farming & DeFi On-Ramp
Revo - Tokenized, Auto-Compounding Yield Farming & DeFi On-Ramp
Nov 28, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Revo
Revo is a DeFi platform and protocol for fully decentralized auto-compounded yield farming at negligible cost. Users are able to directly swap any ERC20 token for tokenized shares representing an auto-compounded position in an underlying yield farm.
Traditionally, yield farming optimally required deep knowledge of the underlying DeFi platform; manual reinvestment of rewards is a cumbersome and painful process. Current auto-compounding solutions take a huge share of the yield as payment, and still require in-depth knowledge of the platform in order to even get started.
With Revo, you can swap any ERC20 token (think:
cUSD
,cEUR
,CELO
) directly for auto-compounding shares of a yield farm. As time goes on and your shares get auto-compounded, they'll be worth more and more of the underlying LP. This is perfect for crypto newbies who want access to high yield without deep knowledge of DeFi platforms. No daily claiming of rewards, swapping, minting LP, and re-staking into a farm. With Revo, anyone can "zap-in" to an auto-compounded yield farm with any ERC20 token they have.Because Revo's auto-compounding shares are implemented as ERC20 tokens themselves, Revo also allows users to swap directly between auto-compounding stakes in different underlying yield farms. This is incredibly desirable for crypto newbies and DeFi power users alike, since this was previously an immensely painful process. Want to chase auto-compounding yield between different farms or diversify your portfolio? No problem.
Check out a deep-dive on Revo's structure and protocol design here.
URLs