Split COMP rewards distribution and bug fixes
This proposal completes RFP 15: Dynamic COMP reward distribution as well as fixes a few bugs.
Split COMP rewards distribution
Problem
At the moment, the COMP rewards rate for any single market is applied at the same rate for both suppliers and borrowers. This creates undesirable market conditions such as, but not limited to, negative interest rates when borrowing various assets.
An example is the WBTC market - we want to distribute COMP rewards for suppliers, but since this distribution rate applies at the same rate for both borrowers and suppliers, we end up with WBTC being borrowed at a negative interest rate. The same applies to most non-stablecoin markets.
Solution
This proposal changes the Comptroller logic to have two different COMP distribution rates for each and every market - borrow-side (compBorrowSpeeds) rate and supply-side (compSupplySpeeds) rate.
The function Comptroller._setCompSpeeds(CToken[],uint256[],uint256[])
is introduced to enable governance to set these differing rates.
Example usage: Comptroller._setCompSpeeds([cUSDC],[0],[1e18])
- will set the COMP rewards for supplying USDC at 0 COMP per block, and for borrowing at 1 COMP per block.
COMP rewards distribution bug fixes
This proposal fixes the following bugs:
- Market state indices were not being set when COMP rewards are added to already active markets. [Bug 1]
- COMP rewards were distributed for periods preceding when the distribution rate is set. [Bug 2]
- Borrowers were having to poke their borrow to accrue rewards if they borrowed before rewards rates were set. [Bug 3]
Technical changes
Comptroller#compSpeeds
storage variable is no longer being used and has been effectively deleted. It’s replaced byComptroller#compBorrowSpeeds
andComptroller#compSupplySpeeds
. This proposal copies the current rates into the new storage variables.Comptroller#_setCompSpeed(CToken,uint256)
function has been removed and replaced byComptroller#_setCompSpeeds(CToken[],uint256[],uint256[])
. This new function allows COMP rewards rates for multiple markets to be set with a single call.- An upgrade hook initializes all non-initialized market state indices (initial index is 1e36).
- When new markets are added, their state indices are now properly initialized (used to use lazy initialization which caused many problems).
Other notable changes
- Depositing now uses slightly less gas after a user’s initial deposit.
- Calling
Comptroller#claimComp
unfortunately uses a lot more gas to account for uninitialized borrow state indices. It’s recommended to specify which markets (and which sides) to claim COMP in rather than claiming across all markets simultaneously. - Flywheel tests have been updated and expanded upon to prevent the bugs fixed in this proposal from occurring again.
- These changes have been live on the Ropsten testnet for nearly a month and everything is working as expected.
Credits
- Arr00: initial code supporting split COMP rewards; flywheel test re-writes
- Getty: bugs 1 and 2 diagnosis help and disclosure
- Elee: bugs 1 and 2 diagnosis help, fixing, and disclosure
- Coburn: bug 3 identification; test case
- Compound Labs (especially Jared): reviewing, guidance, general help, and coordination
- TylerEther (me): full implementation of split COMP rewards; testing infrastructure changes; bugs 1 and 2 identification, diagnosis, fixing, and disclosure; bug 3 fix; overall coordination; general testing; addition of many new test cases; proposal
References
Voter | Cast Power | Vote & Rationale |
---|---|---|
0xd544...C98772 | 305,957 | FOR |
0x6626...15c35c | 126,083 | FOR |
getty.gfxlabs.eth | 66,052 | FOR |
0x5BC9...26D76c | 63,306 | FOR |
0x10F8...Af1f92 | 52,157 | FOR |
VOTE POWER
Proposal Status
- Published Onchain
tyler.trilez.eth
- Fri September 24 2021, 01:52 amVoting Period Starts
- Mon September 27 2021, 02:57 amEnd Voting Period
- Mon September 27 2021, 07:48 pmQueue Proposal
- Wed September 29 2021, 08:24 pmExecute Proposal
Current Results
1-FOR
729,781.75
2-ABSTAIN
0.1
3-AGAINST
N/A Tokens