FeedProjects
Developers
Settings
🎉 A new chapter begins: Boardroom has joined Agora
Learn more
protocol logo
Explore / Projects
Compound

Insights

Proposals

Discussions

Members

Information

Reports

Create Proposal

Compound

InsightsProposalsDiscussionsMembersInformationReports
Proposal
Back to Proposals
executedEnded 4 years ago Â·  Onchain

Split COMP rewards distribution and bug fixes

By tyler.trilez.eth

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 by Comptroller#compBorrowSpeeds and Comptroller#compSupplySpeeds. This proposal copies the current rates into the new storage variables.
  • Comptroller#_setCompSpeed(CToken,uint256) function has been removed and replaced by Comptroller#_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

  • GitHub PR
  • Proposal simulation
  • Comptroller compSpeed bug disclosure
  • Forums discussion
  • Etherscan - contract
Continue Reading
Connect Wallet to Add Note
0
Votes 29
VoterCast PowerVote & 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

SHOW MORE
VOTE POWER
0
Connect Wallet
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

0%

3-AGAINST

N/A Tokens

0%
DocumentationBrandingContact Us