Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compound v2.8: COMP Distribution System
* Pre-release branch for Flywheel (#40) 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]> * All markets bugfix; add scens (#60) This patch tracks all markets instead of just COMP markets, since we need to be able to iterate over the superset of markets in most cases, to ensure that toggling COMP-enabled on markets always clears out speeds and re-initializes state correctly. The initial upgrade should take all the existing markets as a parameter, and new markets are initialized via the call to `_supportMarket`. * Post-audit fixes, more scenarios, and auxiliary improvements fixes (#63) * Compare boolean values numerically to 1, not string 0x01 * Remove the short-circuits for market NEVER initialized (#64) These were intended to be short-circuits if not a COMP market, but in fact only take effect if *never* a COMP market. Removing the short-circuit avoids this confusion, and enables us to poke all borrowers once, instead of after every time a market becomes a COMP market for the first time. * add checkIsComped, add isComped to markets storageAt getter (#65) * Ensure updating COMP indices only takes 1 SSTORE (#66) * Set claim threshold; scen code for forks (#69) * Add events for changing comp rate and adding/dropping comped markets (#70) * Rename dripper -> reservoir; add fauceteer (#72) * Rename dripper -> reservoir * Add Fauceteer and Add Timelock Harness Features (#71) This patch adds the Fauceteer, which is a simple contract that can hold Erc20 tokens and will give away a small percentage every time you poke it. The idea is that it replaces the need for "FaucetToken" as we now just make Fauceteer own some amount of tokens and you can poke _it_ if you need test tokens. This gives us the ability to use real Dai, etc, on testnets *and* have a faucet available to users. As the Fauceteer only gives away 0.01% of what it has, it will effectively never run out, but instead just give away less and less each time you poke it. The raw number of tokens isn't that important for test-nets, so this is acceptable. We also add some functions to the TimelockTest harness. We allow it to change admin without going through timelocking, and we add the ability for it to call `_acceptAdmin` without timelocking. This significantly makes the flow of setting up a test-net easier. Co-authored-by: Max Wolff <[email protected]> Co-authored-by: Geoff Hayes <[email protected]> * Release revisions and network configurations (#73) * Allow Fauceteer to handle non-standard EIP-20 Tokens * Add the new eureka Kovan config with flywheel * Add (old) new DSR rate model to mainnet config * Final polish [COMP-1037] (#74) This patch adds some improvements based on discoveries from the testnet phase of the release. The `claimComp` function has been enhanced in several ways to make it far more gas-efficient and versatile. In particular, it no longer refreshes speeds and allows specifying multiple accounts to claim, the markets in which to claim, and whether to claim the supply side and/or the borrow side independently. The `NewCompRate` event parameter names were changed to reflect that the arguments are not actually mantissas (even though COMP per block units have 18 decimals). When we `transferComp` and check if the COMP accrued is above the threshold, we now also check if the accrued amount is exactly 0, in order to short-circuit unnecessary transfers. Finally, this patch extends the COMP Balance Metadata Lens to include COMP Allocated (that is, what is owed to you but not yet received). This is useful for showing users on an interface how much COMP they have earned, since it can be 'called' to return the differential value. A future version may implement this as a pure-view function, though it is more complex and requires detailed understanding about the way COMP is accrued, so the simpler approach is favored initially. Co-authored-by: Max Wolff <[email protected]> Co-authored-by: Geoff Hayes <[email protected]> * Final deployments (#83) This patch adds the final deployments for the COMP distribution system (aka flywheel) to mainnet, kovan, and ropsten. It includes testnet harnesses, as well as the scripts that will be used to initialize all the pre-existing borrower COMP indices. Co-authored-by: Max Wolff <[email protected]> Co-authored-by: Geoff Hayes <[email protected]> Co-authored-by: Max Wolff <[email protected]> Co-authored-by: Geoffrey Hayes <[email protected]>
- Loading branch information