CompoundLens
CompoundLens is a stateless read-only aggregator that batches caToken metadata, prices, and per-account data into single calls. It lets integrators populate market dashboards without N+1 RPC round-trips.
Introduction
Why a Lens contract
Each CapyFi market exposes a number of view methods on its caToken contract. CompoundLens packages those into composite calls and adds queries that span all markets, plus account-level limits via the Comptroller — which keeps client RPC traffic small even as the number of markets grows.
Some Lens methods simulate state-changing calls via eth_call to compute "current" values (e.g., interest accrued through the latest block) — integrators should consume the full ABI rather than truncated signatures so return-tuple structs decode correctly.
cToken Metadata
Per-market and bulk reads
cTokenMetadata(cToken)
function cTokenMetadata(CToken cToken) returns (CTokenMetadata)Returns a struct containing: cToken, exchangeRateCurrent, supplyRatePerBlock, borrowRatePerBlock, reserveFactorMantissa, totalBorrows, totalReserves, totalSupply, totalCash, isListed, collateralFactorMantissa, underlyingAssetAddress, cTokenDecimals, underlyingDecimals, compSupplySpeed, compBorrowSpeed, borrowCap.
cTokenMetadataAll(cTokens[])
function cTokenMetadataAll(CToken[] cTokens) returns (CTokenMetadata[])Bulk variant. Pass the full list returned by comptroller.getAllMarkets() for a one-shot snapshot.
Underlying Prices
Batched oracle reads
cTokenUnderlyingPrice(cToken)
function cTokenUnderlyingPrice(CToken cToken) view returns (CTokenUnderlyingPrice)Returns { cToken, underlyingPrice }. underlyingPrice is scaled per the protocol's mantissa convention.
cTokenUnderlyingPriceAll(cTokens[])
function cTokenUnderlyingPriceAll(CToken[] cTokens) view returns (CTokenUnderlyingPrice[])Bulk variant — fetch oracle prices for every market in a single call.
Account Limits
Liquidity snapshot for an address
getAccountLimits(comptroller, account)
function getAccountLimits(Comptroller comptroller, address account) returns (AccountLimits)Returns { markets, liquidity, shortfall } in a single call. Equivalent to combining getAssetsIn + getAccountLiquidity on the Comptroller.
CompoundLens also exposes getCompBalanceMetadata* and governance-related helpers (getGovProposals, getGovReceipts, Bravo equivalents). These are inherited from the upstream Compound Lens and are not wired into the CapyFi protocol; they remain callable for any integrator that needs them.
Deployed Addresses
Per-network deployments
0x3ec15DCe6c1E03Bd77a6542E77ca0F23b8289eF80xA386F452af98062811c1794E0c91c9Fc480C5658