audit-flywheel
jflatow
tagged this
08 May 23:18
This patch adds a COMP distribution mechanism to the Comptroller nicknamed the 'flywheel'. Whenever a user interacts with the protocol, the *Allowed hooks now trigger tracking of a COMP supply and borrow index, and a distribution of COMP to user's whose supply or borrow balances may have changed, proportional to the fraction of total protocol interest they have accumulated. Tracking interest between markets is accomplished via COMP 'speeds', which are a fraction of a total COMP rate being distributed, proportional to that market's share of total borrow interest (per block, at the time of recalculation). Anyone may trigger a recalculation of speeds at any time. Tracking interest for a user is accomplished via per-market indices which track the amount of COMP that should have been distributed to the market, given the COMP speeds, the total COMP rate, and the number of blocks that have elapsed since the last update. This patch also adds a Dripper, which distributes Comp (or any token) to a target (Comptroller) at some fixed rate. The goal of Dripper is to be simple and immutable. Anyone can poke the Dripper at any time to move Comp to the Comptroller as per the scheduled rate. If there is not enough Comp in the Dripper, we drip as much as we can and will try to drip the complete expected sum next time. Co-authored-by: Max Wolff <[email protected]> Co-authored-by: Geoffrey Hayes <[email protected]>