Compound III

Introduction

Compound III is an EVM compatible protocol that enables supplying of crypto assets as collateral in order to borrow the base asset. Accounts can also earn interest by supplying the base asset to the protocol.

The initial deployment of Compound III is on Ethereum and the base asset is USDC.

Please join the #development room in the Compound community Discord server as well as the forums at comp.xyz; Compound Labs and members of the community look forward to helping you build an application on top of Compound III. Your questions help us improve, so please don’t hesitate to ask if you can’t find what you are looking for here.

For documentation of the Compound v2 Protocol, see docs.compound.finance/v2.

Networks

The network deployment artifacts with contract addresses are available in the Comet repository deployments/ folder.

What does each protocol contract do?

cUSDCv3

This is the main proxy contract for interacting with the new market. The address should remain fixed and independent from future upgrades to the market. It is an OpenZeppelin TransparentUpgradeableProxy contract.

cUSDCv3 Implementation

This is the implementation of the market logic contract, as deployed by the Comet Factory via the Configurator.

cUSDCv3 Ext

This is an extension of the market logic contract which supports some auxiliary/independent interfaces for the protocol. This is used to add additional functionality without requiring contract space in the main protocol contract.

Configurator

This is a proxy contract for the configurator, which is used to set and update parameters of a Comet proxy contract. The configurator deploys implementations of the Comet logic contract according to its configuration. This pattern allows significant gas savings for users of the protocol by ‘constantizing’ the parameters of the protocol.

Configurator Implementation

This is the implementation of the Configurator contract, which can also be upgraded to support unforeseen changes to the protocol.

Proxy Admin

This is the admin of the Comet and Configurator proxy contracts. It is a ProxyAdmin as recommended/implemented by OpenZeppelin according to their upgradeability pattern.

Comet Factory

This is the factory contract capable of producing instances of the Comet implementation/logic contract, and invoked by the Configurator.

Rewards

This is a rewards contract which can hold rewards tokens (e.g. COMP, WETH) and allows claiming rewards by users, according to the core protocol tracking indices.

Bulker

This is an external contract that is not integral to Comet’s function. It allows accounts to bulk multiple operations into a single transaction. This is a useful contract for Compound III user interfaces. The following is an example of steps in a bulked transaction.

  • Wrap Ether to WETH
  • Supply WETH collateral
  • Supply WBTC collateral
  • Borrow USDC

In addition to supplying, borrowing, and wrapping, the bulker contract can also transfer collateral within the protocol and claim rewards.

How do I get the latest contract addresses?

Use the spider functionality in the Compound III repository. The addresses can then be found in the deployments/ folder.

git clone https://github.com/compound-finance/comet.git
cd comet/
yarn
npx hardhat spider --deployment mainnet

How do I call Comet methods?

Compound III has several contract files that make up the public Comet interface. The address of the Compound III upgradable proxy contract is used to call methods in Comet.sol, CometExt.sol, and CometCore.sol.

To get the ABI for Comet, run the build process in the Compound III repository. Look for the artifact of CometInterface.sol in the generated Hardhat artifacts folder.

## First, run the build command in the Compound III project repository
yarn run build
// Reference the Hardhat artifact in  the Compound III project build files
const abi = require('./artifacts/contracts/CometInterface.sol/CometInterface.json').abi;

const comet = new ethers.Contract(cometAddress, abi, provider);
pragma solidity 0.8.13;

import "./CometInterface.sol";

contract MyContract { //...

How do I deploy Compound III?

To deploy to a public blockchain, see the yarn deploy instructions in the README file of the Comet repository. Be sure to first use the spider command to pull in the network’s existing configuration and latest contract addresses.

Compound III can be deployed to EVM compatible blockchains. Here is an example for deploying to a locally run Ethereum node.

## In one command line window:
git clone https://github.com/compound-finance/comet.git
cd comet/
yarn install

## This runs the ethereum node locally
## The development mnemonic or private keys can be configured in hardhat.config.ts
npx hardhat node

## In another command line window:
cd comet/

## This deploys to the running local ethereum node
## It also writes deployment information to ./deployments/localhost/
yarn deploy --network localhost

Security

The security of the Compound protocol is our highest priority; our development team, alongside third-party auditors and consultants, has invested considerable effort to create a protocol that we believe is safe and dependable. All contract code and balances are publicly verifiable, and security researchers are eligible for a bug bounty for reporting undiscovered vulnerabilities.

We believe that size, visibility, and time are the true test for the security of a smart contract; please exercise caution, and make your own determination of security and suitability.

Audits

The Compound protocol has been reviewed & audited by OpenZeppelin and ChainSecurity.

  1. Compound III Audit by OpenZeppelin
  2. Compound III Security Audit by ChainSecurity

Code Examples

The Compound III Developer FAQ repository contains code examples for frequent Compound III developer tasks.

See contracts/MyContract.sol for Solidity examples, and also the individual JavaScript files in examples/ for helpful use cases.