AnyStake Reward Model: Take 2
This model has been iterated on since release and is no longer accurate. Please refer to the updated AnyStake Mechanics here: https://defiat.medium.com/anystake-ecosystem-mechanics-4542d3763232
Dear DeFiat Community,
As we all see, ETH is reaching all time highs on a weekly basis. We are at the beginning of a massive bull run, “experts” say could peak between May and September.
Until then, this blessing is also a curse: GAS PRICES have been skyrocketing.
It’s common to see the network demanding 250 to 300 Gwei to prioritize a transaction on the chain. This is cool for miners, not users like us.
Our New Approach
The main goal of this “Take 2” on AnyStake Reward Model is to limit gas costs as much as possible, and ideally… to pay for them. (Yeah, you read that correctly!!)
In our previous AnyStake model, we wanted to make extensive use of Uniswap functions’ calls to perform token buybacks. Calling a swap() function requires ~300,000 gas, which is something between $50 and $80 in today’s prices.
This doesn’t make sense.
As a result, we have analyzed several different design approaches and redesigned the contracts (yes… multiple ones) in a way that should optimize gas usage.
A New Ecosystem
Anystake’s new structure will be composed of 3 contracts.
- AnyStake (ERC-20 Farms)
- Vault (Rewards Collection & Distribution)
- Regulator (DeFiat Price Stabilization)
We will speak about this “Regulator” at a later stage, but long story short: DFTP will be used in the Regulator to generate passive income for farmers… while working to stabilize DFT price through on-chain purchases too ;-)
Towards Better Gas Efficiency
AnyStake’s main functions are Deposit, Withdraw, and Claim.
- Deposit: During deposits, we want to alleviate the cost of gas for users. As a result, we re-designed this function to be the simplest possible (ie: no call to Uniswap for buyback) and will REWARD each deposit with some DFTP tokens (which can then be staked in the Regulator).
- Withdraw: The idea is to put the gas burden on this function. After all, we want people to stay in the game as long as possible. As a result, buybacks on Uniswap will only happen during withdrawals. On withdrawal, a small percentage of the user’s stake will be taken as a fee and used to buy DFT on Uniswap, pumping the price of your favorite token. This will of course cost gas, but as said, we would rather put this on the exit side than the entry side.
- Claim: Rewards will automatically be claimed on each deposit and withdrawal. Additionally, this function can be called by itself to simply claim any pending DFT rewards.
A New Token Price Management
Originally, AnyStake would weigh rewards based on the price of the total tokens being staked. Each Deposit, Withdraw or Claim would call a function that mass updates all pools and adapts their weights based on the token price.
We saw multiple issues with this method:
- Safety: Token prices could be manipulated by attacking the price oracle. Specifically, pricing LP tokens (UNI-V2) pose significant issues in the event of a flash loan attack.
- Gas Prices: The more work you perform in a function, the more it costs in gas. If you have 10 or 20 pools to update, this method becomes expensive… fast.
Enters Game Theory: your stake will drive your rewards. Each pool will initially pay out the SAME share of rewards (with the exception of the DFT-ETH and DFTP-ETH pools… these will receive a massive boost!). This incentivizes users to stake in ALL pools, especially the smaller pools, as they payout similar rewards to the larger ones but amongst fewer people! All in all the bottom line remains, you receive rewards based on your stake vs. the individual pool total stake. Put 1 wBTC or 1000 LINK, you will have a significant weight in either pool... alongside a high APY. The simplest and leanest method is to let the market arbitrage and the pool distribution will fall in line with the staked token prices and popularity.
Other Under the Hood Improvements:
Not entering too much into details, but the main idea is to avoid mass updating pools like you see in typical farming contracts (CORE). Quant is working on an idea to allow each pool to be updated separately. There’s a bit of math here, but gas savings should be significant.
We had to rework our copy. Gas prices were killing the idea of staking. Why would you pay $80 in ETH to get $200 in rewards? This doesn’t make sense.
As a result, we streamlined the contracts and simplified their content. We are confident that this will create the best staking experience with the lowest fees possible.
This Medium post is a tad “technical” and we hope we managed to explain it in the simplest terms possible: After all, we all are learning in this space.
Occam’s Razor, “The simpler… the better”, doesn’t only apply to smart contracts.
Speaking of contracts: Check our GitHub and newly added NPM packages, that’s the pulse of our daily grind (and each commit/release is worth 10 Tweets if you want our opinion). They are being finalized and tested as we talk/write.
We will be moving to the testnet ASAP!
— The DeFiat Team