← Protocols
Compound
01Description

Compound III (Comet): a single-borrowable-asset money market per deployment with multi-asset collateral. Lean, audited, and gas-efficient.

02Best for
  • 01single-asset borrowing (USDC, WETH, USDT)
  • 02multi-collateral leverage
  • 03passive base-asset yield
  • 04well-audited on-chain credit
03Install
  • pnpm add @compound-finance/compound-js ethers
04Environment variables
VariableScopeDescription
NEXT_PUBLIC_COMET_ADDRESSClientComet proxy address for the market you target (e.g. cUSDCv3 on Ethereum: 0xc3d688B66703497DAA19211EEdff47f25384cdc3).
RPC_URLServerEVM RPC endpoint for the chain.
05Prompt snippet
Integrate Compound III (Comet). Each market is a separate `Comet` proxy keyed by base asset (cUSDCv3, cWETHv3, cUSDTv3, etc.) — pick one per chain. Core flow with `@compound-finance/compound-js`: `Compound.comet.supply(cometAddress, asset, amount)` to deposit either base asset (earn supply APR) or collateral (does not earn yield, unlocks borrowing). Borrow by calling `Compound.comet.withdraw(cometAddress, baseAsset, amount)` against your collateral. Repay with `supply` of the base asset. Read positions via `Comet.userBasic(account)`, `Comet.collateralBalanceOf(account, asset)`, and `Comet.getAssetInfo(i)`. Use `Comet.allow(manager, true)` to authorize a smart-contract manager to act on the user's behalf.
06Gotchas
  • In Comet, only the base asset is borrowable; collateral assets earn ZERO yield — different from Compound v2 cTokens.
  • Each (chain, base asset) is a separate Comet deployment — supplying USDC on Ethereum is unrelated to USDC on Base.
  • Liquidation penalty (`liquidationFactor`) is per-collateral; check `getAssetInfo` before sizing leverage.
  • Borrow position incurs interest in base-asset terms; `userBasic.principal` is signed (negative = borrower, positive = supplier).
  • Compound v2 (cTokens like cDAI, cUSDC) is deprecated/legacy — use Comet for new integrations.
  • Price feeds are Chainlink; an oracle outage can pause borrows and freeze withdrawals.
  • `allow`/`allowBySig` is the only way another contract can move a user's position — there is no infinite ERC20 allowance shortcut on Comet itself.
07Alternatives