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

Revo - Tokenized, Auto-Compounding Yield Farming & DeFi On-Ramp #51

Open
wants to merge 70 commits into
base: master
Choose a base branch
from

Conversation

jophish
Copy link

@jophish jophish commented Nov 28, 2021

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

cajubelt and others added 30 commits October 16, 2021 22:20
chore: hardhat, mocha with typescript
* 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
@jophish 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 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 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants