Skip to content

Latest commit

 

History

History
58 lines (32 loc) · 4.45 KB

README.md

File metadata and controls

58 lines (32 loc) · 4.45 KB

AfEthsolidity

About

AfEth is an ERC20 token collateralized by 2 underlying "strategy" tokens in an adjustable ratio. AfEth can be thought of as a "manager" that collateralizes the 2 tokens into a new token. (see AbstractErc20Strategy.sol)

Token 1, safEth:

  • safeth is our flagship liquid staking token consisting of 6 underling lsds (Lido, rocketpool, staked frax, etc...). It is a simple "price go up" token with immediate liquidity via its "stake" and "unstake" functions.

Token 2, votium strategy:

  • The votium strategy utilizes votium incentives in the convex finance ecosystem in order to make a token whos price only goes up in relation to convex token's price (in eth).

  • To mint votium strategy tokens, convex tokens are purchased, locked in the vote locked cvx contract, and delegated to votium, and strategy tokens are minted at the current strategy token price in votium cvxPerVotium().

  • Votium rewards are claimed with claimRewards() using merkle proofs published by votium every 2 weeks. applyRewards() sells rewards on 0x and deposits them back into afEth (and ultimately back into the safEth & votium strategies), making the afEth price go up.

  • There is an unlock period to withdraw (up to 16 weeks) because votium strategy tokens are collateralized by many different vote locked convex positions. requestWithdraw() burns the strategy tokens, calculates how much cvx they is owed based on cvxPerVotium() price, marks this amount to be unlocked on subsequent calls to processExpiredLocks(), calculates unlock time and returns withdrawId to later be used in withdraw().

AfEth

  • When minting, afEth purchases each underlying strategy token (safEth & votium strategy) according to ratio.

  • depositRewards() is called by the votium strategy upon claiming rewards to make the afEth price go up by distributing funds into both strategies according to ratio.

  • requestWithdraw() is called to calculate how much time is required to unlock all underlying vote locked convex before the user can call withdraw().

A note about varying unlock times

  • When a user calls requestWithdraw() the contract looks at who has requested to withdraw before them, calculates the date at which enough vlcvx can be unlocked to close their position along with everyone in front of them, and marks that amount of convex to be unlocked asap.

  • Because of this, the withdraw time will be contantly changing for users that havent called requestWithdraw(). This could cause users to "race" to enter the unlock queue under certain unqiue market conditions.

  • While this isnt ideal, we do not believe it to be exploitable in a harmful way because the maximum unlock time is 16 weeks regardless of state of the unlock queue.

Local Development

To use the correct node version run

nvm use

To install dependencies and compile run

yarn && yarn compile

Testing

yarn test to run test suite.

Architecture Diagrams

Coming soon