Auto-Staking, Explained
Automation is the core function of DeFiHelper (DFH). We have already covered the architecture of the platform and the details of its automation in a previous article. Now it is time to review the key feature of DFH — the auto-staking function.
The DFH auto-staking feature helps increase the profitability (APY) of staking contracts across other DeFi protocols. The logic behind the vast majority of protocols on the market is the same — the user receives a reward on a staking contract for each block. However, the reward is not automatically added to the deposit and does not increase overall profitability. Our algorithm evaluates the efficiency therein, collects the reward, transfers it through an exchange, and then returns it to the bulk of the deposit. As a result, the end APY grows substantially by up to 150%, and sometimes as much as tenfold. It all depends on the APY contract, the amount of the user’s contribution, and the network commission at the time of restaking.
The DFH auto-staking algorithm was developed by Ilya Munerman, a mathematician and lecturer at the New Economic School and HSE University. The mathematics behind auto-staking were already described in a dedicated article, but it is hardly understandable for every reader. In this article, we will describe the auto-staking algorithm in a more accessible form.
Let us provide a layout of the algorithm and review it step-by-step.
1. The user selects the contract they want to apply the auto-staking feature to. Then, the user replenishes their balance in DeFiHelper. The system will deduct the commission for blockchain transactions and the protocol commission from the user’s balance.
2. DFH is a non-custodial service and does not store users’ funds on general contracts. Instead, DFH deploys an individual contract for each user. The contract is then used for automating routine activities. The source code of the contract is open and anyone can see which functions are available to the owner of the contract and which are designed for the service. Here is an example of a contract. Pay attention to the onlyOwner modifier, since it is assigned to methods that can only be called by the owner of the contract — the user of DFH.
3. In order for the service to be able to manage the rewards, the user needs to transfer their LP-tokens (liquidity pool tokens) from the current contract or add new assets to it.
4. DFH checks several parameters on an hourly basis, namely — the amount of the deposit, the network commission, the number of tokens earned but not yet called, as well as the deviation of the blockchain commission rate from the “normal” mean over the course of the last week.
5. The data is then transferred to a special mathematical function. If the algorithm decides that it is time to act, DFH creates a blockchain transaction, divides the tokens earned over the period into two equal parts, exchanges them for LP tokens through an exchange, and then adds them to the bulk of the deposit. An example of such a transaction can be found here.
6. Upon completion of the transaction, DFH deducts its $1 commission and blockchain transaction commission from the user’s balance. The service’s commission is then distributed among DFH token holders.
The following is an illustration of the procedure.
A user deposits $200,000 at 100% APY. Suppose the APY does not change and the user has earned $400,000 after a year.
Ergo, the user earns 200,000/365/24 = ~ $23 per hour.
It would seem that under such conditions, it is necessary to launch a restaking contract literally every 10 minutes. However, the model we apply is much more complicated.
The generated $23 by itself will yield only $0.00262557 per hour, and the user will immediately spend $1 on commissions.
You can compare the results of several “simple” strategies after 360 days under the following conditions. A lump sum of $200,000 will generate the following returns under a restaking contact:
- Daily — $534,924.71
- Hourly — $521,502.75
- Every half hour — $506,789.67
It is clear that if it were not for the commission, the restaking function would have to be applied constantly. But the blockchain does retain a commission. With an increase in the commission, the time necessary until the moment of optimal restaking should increase as well, but with an increase in the amount of the contribution, that time decreases. Therefore, our model demonstrates that an effective restake under the given scenario will only occur 20 hours after the first deposit is made.
In total, with the help of DFH, users will be able to earn an additional $140,000. It will cost only $1,136. The service’s commission will be $568, plus another $568 as the blockchain commission. In a real situation, the APY and the network commission will change constantly, but that is why our model applies flexible solutions on an hourly basis.
If the blockchain commission is abnormally high, the algorithm will wait and try to save the user some money, leaving the user the option of using the available time for other purposes.
If you have any further questions, please feel free to ask them in our Discord or Telegram chat.
Links
DeFiHelper Website | Litepaper | News Channel (EN) | News Channel (RU) | Chat (EN) | Chat (RU) | Twitter | Discord | Github | Math Behind DeFiHelper