Skip to main content

CompoundClient

The CompoundClient provides direct access to Compound V3 (Comet) markets on Base and Ethereum. Each Comet market has a single base (borrowable) asset and multiple collateral assets.
Compound V3’s architecture differs from Aave and Morpho. Each Comet contract is a standalone market with one borrowable asset. Supplying the base asset earns yield; supplying collateral enables borrowing.

Constructor

import { CompoundClient } from '@agether/sdk';

const compound = new CompoundClient({
  privateKey: process.env.AGENT_PRIVATE_KEY!,
  rpcUrl: 'https://base-rpc.publicnode.com',
  agentId: '42',
  chainId: 8453,
});

Configuration

ParameterTypeRequiredDescription
privateKeystringYesAgent wallet private key
rpcUrlstringYesRPC endpoint
agentIdstringNoERC-8004 agent ID
chainIdnumberNoChain ID (default: 8453)

Comet Markets

Each Comet contract is a standalone lending market with one base (borrowable) asset. Compound V3 dynamically discovers all available markets and their collateral assets on-chain.

Base (8453)

Base AssetComet Address
USDC0xb125E6687d4313864e53df431d5425969c15Eb2F
WETH0x46e6b214b524310239732D51387075E0e70970bf
AERO0x784efeB622244d2348d4F2522f8860B96fbEcE89
USDbC0x9c4ec768c28520B50860ea7a15ff6CBB6c323c

Ethereum (1)

Base AssetComet Address
USDC0xc3d688B66703497DAA19211EEdff47f25384cdc3
WETH0xA17581A9E3356d9A858b789D68B4d866e593aE94
USDS0x5D409e56D886231aDAf00c8775665AD0f9897b56

Methods

supplyCollateral(cometAddress, tokenAddress, amount)

Supply collateral to a specific Comet market.
await compound.supplyCollateral(
  '0xb125E6687d4313864e53df431d5425969c15Eb2F', // USDC Comet
  '0x4200000000000000000000000000000000000006', // WETH
  parseEther('0.1'),
);

withdrawCollateral(cometAddress, tokenAddress, amount)

Withdraw collateral from a Comet market.
await compound.withdrawCollateral(
  '0xb125E6687d4313864e53df431d5425969c15Eb2F',
  wethAddress,
  parseEther('0.05'),
);

borrow(cometAddress, amount)

Borrow the base asset from a Comet market against deposited collateral.
await compound.borrow(
  '0xb125E6687d4313864e53df431d5425969c15Eb2F', // USDC Comet
  parseUnits('100', 6), // 100 USDC
);

repay(cometAddress, amount)

Repay borrowed base asset.
await compound.repay(
  '0xb125E6687d4313864e53df431d5425969c15Eb2F',
  parseUnits('50', 6), // Repay 50 USDC
);

getPositions()

Get all positions across all Comet markets.
const positions = await compound.getPositions();
// Returns: { comet, baseToken, collateral, debt, ltv, healthFactor }[]

getMarkets()

Discover all Comet markets and their collateral assets dynamically.
const markets = await compound.getMarkets();
// Returns market info with base asset, collateral assets, APYs, utilization

Compound V3 vs Aave V3 vs Morpho Blue

FeatureCompound V3Aave V3Morpho Blue
ArchitecturePer-base-asset CometsSingle poolIsolated markets
Borrowable assets1 per CometMany1 per market
Collateral typesMultiple per CometMultiple (pooled)1 per market
Health FactorPer-CometGlobalPer-market
GovernanceCOMP governanceAAVE governanceNone (immutable)
RewardsCOMP tokenNone on BaseNone
LiquidationAbsorbed by protocolAuctionedOracle-based
Compound V3 uses an “absorption” model for liquidation. When an account is underwater, the protocol absorbs the collateral and debt — no third-party liquidators needed.

Using via Plugin

The unified plugin tools support Compound as a protocol option:
agether_deposit(protocol="compound", token="WETH", amount="0.1")
agether_borrow(protocol="compound", token="USDC", amount="100")
agether_repay(protocol="compound", token="USDC", amount="all")
agether_withdraw(protocol="compound", token="WETH", amount="all")
Compound is also included in cross-protocol aggregation tools:
  • agether_status — shows Compound positions alongside Morpho and Aave
  • agether_markets — includes Compound markets in rate comparison
  • agether_health — checks Compound positions for liquidation risk
  • agether_yield_spread — compares yield opportunities across all three protocols