Notes
- Must call
Comptroller.enterMarkets([cTokenAddress])before borrowing against a market - Return values: 0 = success, non-zero = error code (e.g. 3 = COMPTROLLER_REJECTION)
- cToken exchange rate grows over time — holding cTokens earns interest automatically
- Each asset has its own cToken contract (not a shared pool like Aave)
- Legacy protocol — consider Compound V3 (Comet) for new deployments
Its names in a program
On Ethereum,CompoundV2 is a namespace: its contracts need no import.
Deployments
ABI
CErc20ABI
import CErc20ABI from "./protocols/compound-v2/CErc20ABI.json"; Speaks for: cUSDC.
mint(uint256 mintAmount) returns (uint256)redeem(uint256 redeemTokens) returns (uint256)redeemUnderlying(uint256 redeemAmount) returns (uint256)borrow(uint256 borrowAmount) returns (uint256)repayBorrow(uint256 repayAmount) returns (uint256)balanceOfUnderlying(address owner) returns (uint256)borrowBalanceCurrent(address account) returns (uint256)
ComptrollerABI
import ComptrollerABI from "./protocols/compound-v2/ComptrollerABI.json"; Speaks for: comptroller.
enterMarkets(address[] cTokens) returns (uint256[])exitMarket(address cToken) returns (uint256)
Next steps
- Protocols: the other protocols, by what they do.
- Protocols and tokens: calling a contract by its namespace, or through its ABI.
- Glossary: the words these pages use, in plain terms.
