Introduction
In decentralized finance (DeFi), incentives play a crucial role in driving user participation. Compound, one of the leading DeFi protocols, utilizes COMP token rewards to encourage both lending and borrowing activities. This post delves into how the Compound V3 rewards system works, comparing it with the MasterChef algorithm from yield farming protocols, and providing examples to illustrate the mechanisms.
High-Level Overview of Compound V3 Rewards
Compound V3 distributes COMP tokens to users who lend or borrow assets. The rewards are proportional to the user’s share of the total market’s lending and borrowing. The system uses two key indexes to track rewards:
trackingSupplyIndex
for lenderstrackingBorrowIndex
for borrowers.
These indices are analogous to the rewardPerTokenAcc
in MasterChef, which tracks the accumulated rewards per staked token.How Tracking Indices Wo
Detailed Calculation of Rewards
- Fetching Speeds and Scales:
- baseTrackingSupplySpeed: Speed at which rewards accumulate for suppliers.
- baseTrackingBorrowSpeed: Speed at which rewards accumulate for borrowers.
- baseIndexScale: Scale factor for the indexes.
- Daily Reward Calculation: The daily reward accumulation can be calculated as:
Example Calculation
Let’s calculate the trackingSupplyIndex
and trackingBorrowIndex
with more clarity:
- Initial Setup:
- Assume there are 1,000,000 USDC lent and 500,000 USDC borrowed in the Compound V3 protocol.
- The
baseTrackingSupplySpeed
is set to 2.979166666666e-03 COMP per second. - The
baseTrackingBorrowSpeed
is set to 4.414467592592e-03 COMP per second. baseIndexScale
is 1e15.- Number of seconds in a day: 86,400.
- Daily COMP Rewards Calculation:
- For lenders:
Plugging in the values: - For Borrowers:
Pluggin in the values:
- For lenders:
- Tracking Index Update:
- For lenders:
- For borrowers:
These numbers might seem very small due to the large scale of the indices and the small per-second reward rate. Let’s look at a larger time frame or total amount for a more substantial example:
- Example for a More Substantial Period (1 Year):
- For lenders over a year:
- For borrowers over a year:
- With these larger amounts, the index values over a year:
- For lenders:
- For borrowers:
Claiming Rewards Example
Using the yearly index values:
- A user who lent 10,000 USDC for one year would be entitled to:
- A user who borrowed 5,000 USDC for one year would be entitled to:
This illustrates how the reward mechanism works over a longer period with more substantial reward accumulations.
Comparison with MasterChef Algorithm
The MasterChef algorithm, widely used in yield farming protocols, operates on a similar principle but with some differences:
- accRewardsPerShare:
- In MasterChef,
accRewardsPerShare
is a key variable that tracks the accumulated rewards per staked token. It increases over time as more rewards are distributed.
- In MasterChef,
- Dilution of Rewards:
- Just like in Compound, the more tokens are staked, the less reward each token receives. This dilution ensures fair distribution among participants.
- Claiming Rewards:
- Rewards in MasterChef are not automatically distributed and need to be claimed, similar to Compound V3.
Conclusion
The Compound V3 rewards system, with its tracking indexes and threshold mechanisms, ensures fair and proportional distribution of COMP tokens to both lenders and borrowers. By understanding these mechanisms, users can better strategize their participation in the protocol to maximize their rewards. Comparing it with the MasterChef algorithm also highlights the common principles and unique features that govern DeFi reward systems.