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
getCreditAccounts
Returns credit accounts matching the filter with pagination support.
function getCreditAccounts( address creditManager, CreditAccountFilter memory filter, uint256 offset ) external view returns (CreditAccountData[] memory accounts, uint256 total);
| Parameter | Type | Description |
|---|---|---|
creditManager | address | Credit Manager to query |
filter | CreditAccountFilter | Filter criteria (see below) |
offset | uint256 | Pagination offset |
Returns: Matching accounts and total count.
countCreditAccounts
Returns the count of credit accounts matching the filter.
function countCreditAccounts( address creditManager, CreditAccountFilter memory filter ) external view returns (uint256);
getCreditAccountData
Returns complete data for a single credit account.
function getCreditAccountData( address creditManager, address creditAccount ) external view returns (CreditAccountData memory);
| Parameter | Type | Description |
|---|---|---|
creditManager | address | Parent Credit Manager |
creditAccount | address | Account to query |
Data Structures
CreditAccountFilter
struct CreditAccountFilter { address owner; // Filter by owner (address(0) = any) uint256 minHealthFactor; // Minimum HF (0 = no min) uint256 maxHealthFactor; // Maximum HF (type(uint256).max = no max) bool includeZeroDebt; // Include accounts with no debt bool reverting; // Include reverting accounts }
CreditAccountData (key fields)
| Field | Type | Description |
|---|---|---|
addr | address | Credit Account address |
owner | address | Account owner |
creditManager | address | Parent Credit Manager |
debt | uint256 | Total debt (principal + interest) |
enabledTokensMask | uint256 | Bitmask of enabled tokens |
healthFactor | uint256 | Current HF (10000 = 1.0) |
tokens | TokenInfo[] | Token balances and values |
isLiquidatable | bool | Whether account can be liquidated |
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 |
| Custom filtering logic | Direct compressor calls |
| Liquidation bots | Direct compressor (gas-optimized) |
| On-chain integration | Direct compressor (no SDK in contracts) |
| Real-time monitoring | Direct compressor with specific filters |
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