When to use it
- Each market (a Comet) has one base asset you can supply for interest or borrow, and a list of
collateral assets you supply to borrow it. The namespace names each Comet by its base asset
(
CUSDCv3,CWETHv3). - Choose it when you only need to borrow the base asset; for several borrowable assets against shared collateral, Aave V3.
Pitfalls for a program
- Approve the Comet before
supply. supply(asset, amount)credits its caller, the Pot: the position is then the Pot’s, not the user’s wallet’s.supplyTo(dst, asset, amount)creditsdst; choose which, passing the wallet as amainparameter fordst.- Supplying the base asset while you have a borrow repays the borrow first.
- Withdrawing more base asset than you supplied borrows the rest, if your collateral allows:
check
balanceOfandborrowBalanceOfbefore and after. - Collateral earns no interest, and each collateral asset has a supply cap.
balanceOfis the base supply with interest: it grows on its own.
In a Sauce program
Supply the Pot’s USDC to the USDC market foronBehalfOf (the user’s wallet, or pot to
keep the position in the Pot) and check it was credited:
Notes
- No separate borrow function — withdrawing more base than supplied automatically borrows
- Each Comet market has ONE base asset (e.g. USDC) and multiple collateral assets
- No interest rate mode selection — all borrows are variable rate
- Supply/withdraw of collateral does not earn interest, only the base asset earns
- Market names indicate the base asset: cUSDCv3 = USDC base, cWETHv3 = WETH base
- All supply operations require ERC-20 approval to the Comet address
Its names in a program
On Ethereum,CompoundV3 is a namespace: its contracts need no import.
Deployments
ABI
CometABI
import CometABI from "./protocols/compound-v3/CometABI.json"; Speaks for: cUSDCv3, cWETHv3, cUSDTv3.
supply(address asset, uint256 amount)supplyTo(address dst, address asset, uint256 amount)withdraw(address asset, uint256 amount)withdrawTo(address to, address asset, uint256 amount)balanceOf(address account) view returns (uint256)borrowBalanceOf(address account) view 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.
