Closed TheNewAutonomy closed 2 years ago
I've been trying an alternative approach: Instead of going through every block I created a script that fetches pool events and goes through them. It is still accurate but is much faster because it needs less RPC requests. I'm already able to get all CPT balances for all pools quite fast.
I just need to know what the script should exactly return.
The current reward payout system works by running a collection of reward scripts that walk the blockchain, calculating value distribution across pools and between wallets for each block increment. This is a highly accurate way to calculate rewards since it's checking value distribution every few blocks which ensures price changes throughout the cater are catered for.
The PoolsUI interface works differently, taking the previous 24 hours of overall TVL and pool TVL and using this to calculate a reward distribution and APR.
Since this is using two different approaches, the dashboard does not accurately match the output of the rewards script and so we say that the dashboard is providing an approximation while the reward script is paying a more detailed payout.
As well as differences between the UI and script, another major issue is that the reward script process is very labour intensive. The scripts take a long time to run each day and the output has to then go through a lengthy manual process at the end of each week to convert the script output format and then calculate a reward split between the Celo and xDai network. This process is manual, takes a whole day to complete including safety checks but still is prone to manual error.
This task is to change this reward model to a more optimised process that solves these problems.
The dashboard already calculates token distributions for each network, to each pool based on 24 hours of data. A separate task has been raised to add an additional column that shows personal rewards which is a simple calculation using the pools TVL, the users personal TVL and the token rewards for the pool. Since this calculation is being performed here then the results can be recorded and used for reward payouts. This ensures that what the dashboard displays matches the actual reward payouts. This also removes the need to run reward scripts and removes at least one day of error prone manual processes. This could go on to allow more frequent payouts and with the live data being recorded, it could form the source for new analytics displays.