Tokemak Vault - ERC4626
ERC4626 Tokenized vault implementation to auto-compound Toke LP rewards.
A brief on Tokemak LP reactors:
Tokemak acts as a generalized liquidity aggregator for decentralized exchanges (DEXs) and DeFi. The Tokemak protocol is designed to allow users to choose where liquidity is allocated and used, providing a cheaper, more efficient method for liquidity provisioning and sourcing.
The traditional pool 2 liquidity mining incentives attract temporary capital with the goal of extracting short-term value, without concern for the long-term success of a project. Tokemak helps find the right kind of liquidity providers - those that plan on holding your DAOs token long term but may be risk-averse due to impermanent loss when providing liquidity in the traditional 50/50 manner.
ERC4626 Tokenized vault implementation
In this vault example, we intend to automate the process of claiming the toke rewards given by provisioning liquidity to Sushiswap and staking them into the TOKEMAK reactor. The rewards will come in the form of the TOKE token, which gets rewarded on a cycle of 7 days and from transactions made on the token pair TOKE/WETH on Sushiswap.
The auto compound function of the xTokemakVault contract will claim the rewards available for the total assets staked into TOKE/ETH sushi pool.
It will sell the tokamak in the sushi swap market for more of the Vault's underlying assets. And lastly, it will stake this Sushi lp token into the Tokamak pool for more Toke rewards.
The rewards get harvested every 7 days and in the meantime, each investor holds a certain amount of shares equivalent to the amount provided to the vault initially.
Github Vault source code...
The user deposits the sushi lp token "vault underlying token" into the vault.
Vault issues the shares equivalent to the deposit.
Vault stakes user deposit into TOKEMAK SUSHI LP Reactor.
Vault Claims TOKE rewards every 7 days from the TOKEMAK rewards contract.
TOKE rewards are swapped for more sushi lp tokens "vault underlying token".
The cycle of points 4 & 5 repeats every 7 days.
From Sushiswap we get 0.25% of all trades in the TOKE-WETH liquidity pool.
From the TOKEMAK REACTOR contract, we have 16.4% APY in the form of TOKE tokens.
Redeem Vault shares/withdrawals
The user calls "requestWithdrawal(amount)" function with the amount of shares to redeem or withdraw for the underlying token.
The user approves the number of shares to Vault via a wallet or smart contract.
If the shares balance of the user is less o equal to the amount, Tokemak will queue this request on the withdrawals queue to allow the Vault to withdraw.
User shares will be converted to the equivalent underlying token amount and become available to withdraw
To mitigate an inflation attack on the vault, the deployer of this contract will need to deposit a substantial amount of the underlying token and mint initial shares.
To mitigate front running on the swapping of the rewards, a minimum amount out is passed to the autoCompound function.
It is the responsibility of the deployer to ensure that any off-chain system that calls the auto compound function, calculates the number of rewards against the current price of the TOKE token.
The Tokemak Vault is just another brief example of how composability works on ethereum and how it can enable the matching of APY's and percentages of rewards to create an easy way to generate passive income.
Please check tokemaks website for further details on the reward schedules and its other possibilities as a liquidity provider, or liquidity director.