Compound Token and Price Oracle Explained

·

COMP Token: Distribution and Governance

Distribution Plan

Compound rewards users with COMP tokens for every deposit or borrow action, incentivizing platform participation and governance voting.

Daily COMP distribution totals approximately 2,312 tokens across various markets:

MarketCOMP Per Day
DAI880.38
Ether141.25
USDC880.38
USDT126.80

Key features:

Technical Implementation

The ComptrollerV6Storage contract tracks COMP distribution rates per block:

contract ComptrollerV6Storage {
    mapping(address => uint) public compBorrowSpeeds;  // COMP per block for borrowing
    mapping(address => uint) public compSupplySpeeds;  // COMP per block for supplying
}

Example calculation for cUSDC:

Mining Mechanics

Supply Mining

Triggered during deposit operations via mintAllowed():

  1. Index Update:

    function updateCompSupplyIndex(address cToken) internal {
        uint compAccrued = blocksElapsed × supplySpeed;
        Double memory ratio = compAccrued / totalSupply;
        supplyState.index += ratio;
    }

    Calculates COMP per cToken accrued since last update

  2. Distribution:

    function distributeSupplierComp(address cToken, address supplier) internal {
        uint deltaIndex = currentIndex - supplierIndex;
        uint accruedCOMP = supplierTokens × deltaIndex;
        compAccrued[supplier] += accruedCOMP;
    }

    Credits users proportionally to their cToken holdings

Borrow Mining

Follows similar logic but tracks debt shares instead of deposits.

Inflation Analysis

COMP exhibits ~27.5% annual inflation:

Category2021-11-052022-11-04Change
User Rewards1,473,5552,527,335+71.48%
Team Allocation866,2001,421,300+64.08%
Total5,883,8597,492,379+27.34%

👉 Explore COMP tokenomics in depth

Price Oracle Architecture

Compound employs a hybrid oracle system combining:

  1. Uniswap v2 TWAPs - Provides on-chain price anchors
  2. Chainlink v2 - Delivers off-chain price feeds

Validation Mechanism

Chainlink prices must stay within 15% of Uniswap prices:

function validate(int256 currentAnswer) external returns (bool) {
    uint chainlinkPrice = convertReportedPrice(config, currentAnswer);
    uint uniswapPrice = calculateAnchorPriceFromEthPrice(config);
    
    if (failoverActive) {
        // Use Uniswap price during emergencies
        prices[symbolHash] = uniswapPrice; 
    } else if (isWithinAnchor(chainlinkPrice, uniswapPrice)) {
        // Accept Chainlink price if within bounds
        prices[symbolHash] = chainlinkPrice;
        return true;
    }
    emit PriceGuarded(symbolHash, chainlinkPrice, uniswapPrice);
}

Price Calculation

  1. ETH/USDC Price: Fetched from Uniswap USDC-ETH pool

    function fetchEthAnchorPrice() returns (uint) {
        (uint priceCumulative,) = UniswapV2OracleLibrary.currentCumulativePrices();
        return priceCumulative.mul(1e6).div(ethBaseUnit);
    }
  2. Token/ETH Price: From respective Uniswap pool
  3. Final Price: ETH/USDC × Token/ETH, converted to 6 decimals

👉 Understand oracle security considerations

FAQ Section

Q: How often are COMP rewards distributed?

A: Rewards accrue every block (~15s) but are claimable at any time during user interactions.

Q: What happens if Chainlink and Uniswap prices diverge?

A: The system defaults to Uniswap prices if Chainlink feeds deviate beyond ±15% threshold.

Q: Can COMP inflation rate change?

A: Yes, through community governance votes that adjust distribution speeds or introduce new markets.

Q: Why use both Chainlink and Uniswap oracles?

A: Chainlink provides tamper-resistant off-chain data, while Uniswap offers fully on-chain verifiability - together they enhance security.

Q: How are oracle prices protected from manipulation?

A: TWAP mechanisms require sustained price changes over time, making short-term attacks economically impractical.