Compressors
Compressor contracts are read-only data aggregation contracts. Instead of dozens of individual calls, a single compressor call returns complete protocol state. The SDK uses compressors internally.
Discovering Compressor Addresses
Use AddressProvider to find compressor addresses:
address compressor = addressProvider.getLatestAddressByContractType( AP_MARKET_COMPRESSOR, VERSION_RANGE_310 );
const [compressor] = sdk.addressProvider.mustGetLatest( AP_MARKET_COMPRESSOR, VERSION_RANGE_310 );
MarketCompressor
Aggregates complete market state including pools, credit managers, and price oracles.
View Methods
getMarkets
Returns market data for all markets matching the filter.
function getMarkets(MarketFilter memory filter) external view returns (MarketData[] memory);
| Parameter | Type | Description |
|---|---|---|
filter | MarketFilter | Filter criteria (see below) |
Returns: Array of MarketData structs.
getMarketData
Returns complete data for a single market identified by its pool address.
function getMarketData(address pool) external view returns (MarketData memory);
| Parameter | Type | Description |
|---|---|---|
pool | address | Pool address identifying the market |
getPoolState
Returns the pool state for a given pool.
function getPoolState(address pool) external view returns (PoolState memory);
| Parameter | Type | Description |
|---|---|---|
pool | address | Pool address |
Data Structures
MarketFilter
struct MarketFilter { address[] configurators; // Filter by Risk Curator addresses address[] pools; // Filter by specific pool addresses address underlying; // Filter by underlying token (e.g., USDC) }
Pass empty arrays and address(0) for no filtering.
MarketData
struct MarketData { PoolState pool; QuotaKeeperState quotaKeeper; CreditSuiteData[] creditManagers; PriceOracleState priceOracle; TokenData[] tokens; }
PoolState (key fields)
| Field | Type | Description |
|---|---|---|
baseParams.addr | address | Pool contract address |
availableLiquidity | uint256 | Borrowable liquidity |
dieselRate | uint256 | Share price (RAY) |
supplyRate | uint256 | Lender APY (RAY) |
baseInterestRate | uint256 | Borrower APR (RAY) |
totalAssets | uint256 | Total pool value |
CreditSuiteData (key fields)
| Field | Type | Description |
|---|---|---|
creditManager | address | Credit Manager address |
creditFacade | address | Credit Facade address |
creditConfigurator | address | Configurator address |
debtLimits | DebtLimits | Min/max debt per account |
collateralTokens | CollateralToken[] | Allowed tokens + LTs |
CreditAccountCompressor
Fetches credit account data with filtering and pagination.
View Methods
getCreditAccountData
Returns complete data for a single credit account. The account's Credit Manager is resolved automatically.
function getCreditAccountData(address creditAccount) external view returns (CreditAccountData memory);
| Parameter | Type | Description |
|---|---|---|
creditAccount | address | Account to query |
getCreditAccounts
Returns credit accounts matching the filter with pagination support.
function getCreditAccounts( address creditManager, CreditAccountFilter memory caFilter, uint256 offset ) external view returns (CreditAccountData[] memory data, uint256 nextOffset); function getCreditAccounts( CreditManagerFilter memory cmFilter, CreditAccountFilter memory caFilter, uint256 offset ) external view returns (CreditAccountData[] memory data, uint256 nextOffset);
| Parameter | Type | Description |
|---|---|---|
creditManager / cmFilter | address / CreditManagerFilter | Credit Manager(s) to query |
caFilter | CreditAccountFilter | Filter criteria (see below) |
offset | uint256 | Pagination offset |
Returns: Matching accounts and nextOffset. A non-zero nextOffset means the call stopped near the gas limit; call again starting from it. Overloads with a trailing uint256 limit parameter cap the number of accounts processed per call.
countCreditAccounts
Returns the count of credit accounts matching the filter.
function countCreditAccounts( address creditManager, CreditAccountFilter memory caFilter ) external view returns (uint256);
Data Structures
CreditAccountFilter
struct CreditAccountFilter { address owner; // Filter by owner (address(0) = any) bool includeZeroDebt; // Include accounts with no debt uint256 minHealthFactor; // Minimum HF (0 = no min) uint256 maxHealthFactor; // Maximum HF (type(uint256).max = no max) bool reverting; // Only accounts whose state computation reverts }
CreditManagerFilter
struct CreditManagerFilter { address[] configurators; // Filter by market configurators address[] creditManagers; // Filter by specific Credit Managers address[] pools; // Filter by pools address underlying; // Filter by underlying token (address(0) = any) }
CreditAccountData (key fields)
| Field | Type | Description |
|---|---|---|
creditAccount | address | Credit Account address |
owner | address | Account owner |
creditManager | address | Parent Credit Manager |
creditFacade | address | Credit Facade address |
underlying | address | Underlying token |
debt | uint256 | Principal, in underlying |
accruedInterest | uint256 | Accrued interest, in underlying |
accruedFees | uint256 | Accrued fees, in underlying |
totalDebtUSD | uint256 | Total debt, USD |
totalValueUSD | uint256 | Total account value, USD |
twvUSD | uint256 | Threshold-weighted value, USD |
enabledTokensMask | uint256 | Bitmask of enabled tokens |
healthFactor | uint256 | Current HF (10000 = 1.0; below is liquidatable) |
success | bool | False if account state could not be computed |
tokens | TokenInfo[] | Token balances and quotas |
PriceFeedCompressor
Aggregates price feed state for oracle monitoring and updates.
View Methods
getUpdatablePriceFeeds
Returns all price feeds that may need updating for a given price oracle.
function getUpdatablePriceFeeds(address priceOracle) external view returns (PriceFeedData[] memory);
| Parameter | Type | Description |
|---|---|---|
priceOracle | address | PriceOracle contract to query |
Returns: Array of price feed data including staleness information.
loadPriceFeedTree
Returns the full price feed dependency tree for a specific token.
function loadPriceFeedTree(address priceOracle, address token) external view returns (PriceFeedTreeNode memory);
| Parameter | Type | Description |
|---|---|---|
priceOracle | address | PriceOracle contract |
token | address | Token to query |
When to Use Compressors vs SDK
| Scenario | Approach |
|---|---|
| General market data | SDK marketRegister |
| Credit account queries | SDK services |
| One-off account lookup | Direct compressor call |
| Custom filtering logic | Direct compressor calls |
| Liquidation bots | Direct compressor (one call, many accounts) |
| Real-time monitoring | Direct compressor with specific filters |
Compressors are view contracts designed for off-chain eth_call reads. They are not gas-optimized, so avoid calling them from on-chain contracts.
Related Pages
- Pool (PoolV3) -- Pool state returned by MarketCompressor
- Credit Manager -- Credit accounts queried by CreditAccountCompressor
- Quota Keeper -- Quota data included in MarketData
- Smart Contracts Overview -- Full contract architecture