System-level contracts
Data Compressor

DataCompressor

The DataCompressor (opens in a new tab) is a contract that returns a large amount of data on a specified Pool, Credit Manager or Credit Account (or all Pools / Credit Managers / Accounts).

Credit Account data

There are four functions that return data on Credit Accounts:

    /// @dev Returns CreditAccountData for all opened accounts for particular borrower
    /// @param borrower Borrower address
    /// @param priceUpdates Price updates for price on demand oracles
    function getCreditAccountsByBorrower(address borrower, PriceOnDemand[] memory priceUpdates)
        external
        returns (CreditAccountData[] memory);
 
    /// @dev Returns CreditAccountData for all opened accounts for particular borrower
    /// @param creditManager Address
    /// @param priceUpdates Price updates for price on demand oracles
    function getCreditAccountsByCreditManager(address creditManager, PriceOnDemand[] memory priceUpdates)
        external
        returns (CreditAccountData[] memory);
 
    /// @dev Returns CreditAccountData for all accounts with hf <1
    /// @param priceUpdates Price updates for price on demand oracles
    function getLiquidatableCreditAccounts(PriceOnDemand[] memory priceUpdates)
        external
        returns (CreditAccountData[] memory result);
 
    /// @dev Returns CreditAccountData for a particular Credit Account account, based on creditManager and borrower
    /// @param creditAccount Address of credit account
    /// @param priceUpdates Price updates for price on demand oracles
    function getCreditAccountData(address creditAccount, PriceOnDemand[] memory priceUpdates)
        external
        returns (CreditAccountData memory);
  1. getCreditAccountsByBorrower returns data for Credit Accounts that belong to a certain borrower;
  2. getCreditAccountsByCreditManager returns data for Credit Accounts opened in a certain Credit Manager;
  3. getLiquidatableCreditAccounts returns data for Credit Accounts that can currently be liquidated;
  4. getCreditAccountData returns data for a particular Credit Account;

As a result, an array of (or a single) CreditAccountData is returned.

struct CreditAccountData {
    bool isSuccessful;
    address[] priceFeedsNeeded;
    address addr;
    address borrower;
    address creditManager;
    string cmName;
    address creditFacade;
    address underlying;
    uint256 debt;
    uint256 cumulativeIndexLastUpdate;
    uint128 cumulativeQuotaInterest;
    uint256 accruedInterest;
    uint256 accruedFees;
    uint256 totalDebtUSD;
    uint256 totalValue;
    uint256 totalValueUSD;
    uint256 twvUSD;
    uint256 enabledTokensMask;
    ///
    uint256 healthFactor;
    uint256 baseBorrowRate;
    uint256 aggregatedBorrowRate;
    TokenBalance[] balances;
    uint64 since;
    uint256 cfVersion;
    // V3 features
    uint40 expirationDate;
    address[] activeBots;
    uint256 maxApprovedBots;
}
ParameterDescription
isSuccessfulWhether the data was successfully retrieved. The retrieval can fail if the price feeds for some of the account's assets need to be updated.
priceFeedsNeededThe list of tokens that need their price feeds updated. Empty if isSuccessful is true.
addrAddress of the Credit Account.
borrowerAddress of the Credit Account owner.
creditManagerAddress of the Credit Manager that the Credit Account is connected to.
cmNameDescriptor for the Credit Manager the account is connected to.
creditFacadeAddress of the Credit Facade connected to the manager.
underlyingThe underlying of the Credit Manager.
debtThe debt principal of the account.
cumulativeIndexLastUpdateThe interest index of the Credit Account at last debt update.
cumulativeQuotaInterestThe total unpaid quota interest of the Credit Account.
accruedInterestThe total unpaid interest on principal of the Credit Account.
accruedFeesThe total unpaid fees of the Credit Account.
totalDebtUSDThe total debt of the Credit Account, in USD (10**8 precision).
totalValueThe total value of collateral on the Credit Account, in underlying.
totalValueUSDThe total value of collateral on the Credit Account, in USD (10**8 precision).
twvUSDThe total weighted value of collateral on the Credit Account, in USD (10**8 precision).
enabledTokensMaskThe mask of enabled collateral tokens on the account.
healthFactorThe ratio of total weighted value to debt of the Credit Account.
baseBorrowRateThe base borrow rate that is paid by the Credit Account based on pool utilization.
aggregatedBorrowRateThe total borrow rate (including quota rates) that is paid by the Credit Account.
balancesThe list of TokenBalance (see below) structs for each collateral token with non-zero balance (even if disabled).
sinceThe block of the last debt update (V3) or account opening (V2).
cfVersionVersion of the Credit Facade connected to the Credit Account.
expirationDateDate of Credit Facade expiration (0 if none).
activeBotsBots with non-zero permissions from the Credit Account.
maxApprovedBotsThe maximum number of connected bots.

Each TokenBalance struct has the following fields:

struct TokenBalance {
    address token;
    uint256 balance;
    bool isForbidden;
    bool isEnabled;
    bool isQuoted;
    uint256 quota;
    uint16 quotaRate;
    uint256 quotaCumulativeIndexLU;
}
ParameterDescription
tokenAddress of the token.
balanceThe asset balance of the Credit Account.
isForbiddenWhether the asset is forbidden.
isEnabledWhether the asset is enabled.
isQuotedWhether the asset is quoted.
quotaThe quota amount for the asset.
quotaRateThe quota rate currently paid by the account.
quotaCumulativeIndexLUThe value of quota interest index at last update.

Credit Manager data

To retrieve the list of V3 Credit Managers:

/// @dev Returns CreditManagerData for all Credit Managers
function getCreditManagersV3List() external view returns (CreditManagerData[] memory);

Then, data on each individual Credit Manager can be retrieved with:

/// @dev Returns CreditManagerData for a particular _creditManager
/// @param creditManager CreditManager address
function getCreditManagerData(address creditManager) external view returns (CreditManagerData memory);

The CreditManagerData struct is returned as a result:

struct CreditManagerData {
    address addr;
    string name;
    uint256 cfVersion;
    address creditFacade;
    address creditConfigurator;
    address underlying;
    address pool;
    uint256 totalDebt;
    uint256 totalDebtLimit;
    uint256 baseBorrowRate;
    uint256 minDebt;
    uint256 maxDebt;
    uint256 availableToBorrow;
    address[] collateralTokens;
    ContractAdapter[] adapters;
    uint256[] liquidationThresholds;
    bool isDegenMode;
    address degenNFT;
    uint256 forbiddenTokenMask;
    uint8 maxEnabledTokensLength;
    uint16 feeInterest;
    uint16 feeLiquidation;
    uint16 liquidationDiscount;
    uint16 feeLiquidationExpired;
    uint16 liquidationDiscountExpired;
    // V3 Fileds
    QuotaInfo[] quotas;
    LinearModel lirm;
    bool isPaused;
}
ParameterDescription
addrAddress of the Credit Manager.
nameString descriptor of the Credit Manager.
cfVersionVersion of the connected Credit Facade.
creditFacadeAddress of the connected Credit Facade.
creditConfiguratorAddress of the connected Credit Configurator.
underlyingAddress of the CM's underlying token.
poolAddress of the pool the Credit Manager is borrowing from.
totalDebtThe total debt across the Credit Manager, in underlying.
totalDebtLimitThe cap on the total debt for the Credit Manager.
baseBorrowRateThe base borrow rate paid to the pool.
minDebtMinimal debt principal per-account.
maxDebtMaximal debt principal per-account.
availableToBorrowThe amount that is currently available to borrow from the pool.
collateralTokensList of collateral tokens supported by the Credit Manager.
adaptersThe list of (contract, adapter) pairs supported by the protocol.
liquidationThresholdsList of collateral liquidation thresholds (in the same order as collateralTokens).
isDegenModeWhether a DegenNFT is required to open an account.
forbiddenTokenMaskMask of tokens forbidden in the CM.
maxEnabledTokensLengthThe max number of tokens that can be enabled as collateral on a Credit Account.
feeInterestThe rate of DAO fees paid on debt interest.
feeLiquidationThe rate of DAO fees paid on the liquidation premium.
liquidationDiscountThe discount applied to total funds on liquidation (1 - liquidationPremium)
feeLiquidationExpiredThe rate of DAO fees paid on the liquidation premium, when liquidating due to expiration.
liquidationDiscountExpiredThe discount applied to total funds on liquidation (1 - liquidationPremium), when liquidating due to expiration.
quotasArray of QuotaInfo (see below) objects for each quoted token in the Credit Manager.
lirmThe address of the interest rate model for the pool.
isPausedWhether the Credit Manager is paused.

QuotaInfo structs encode data specific to quoted tokens:

struct QuotaInfo {
    address token;
    uint16 rate;
    uint16 quotaIncreaseFee;
    uint96 totalQuoted;
    uint96 limit;
    bool isActive;
}
ParameterDescription
tokenAddress of the token.
rateThe rate paid on quotas.
quotaIncreaseFeeFees paid on each quota increase.
totalQuotedThe total sum of quotas for the token.
limitThe limit on total quotas.
isActiveWhether the quoted token is active and the quota can be increased.

Pool data

To retrieve the list of all pools:

/// @dev Returns PoolData for all registered pools
function getPoolsV3List() external view returns (PoolData[] memory);

Then, data on individual pools can be retrieved with:

/// @dev Returns PoolData for a particular pool
/// @param _pool Pool address
function getPoolData(address _pool) external view returns (PoolData memory);

This will return a PoolData struct:

struct PoolData {
    address addr;
    address underlying;
    address dieselToken;
    string symbol;
    string name;
    ///
    uint256 baseInterestIndex;
    uint256 availableLiquidity;
    uint256 expectedLiquidity;
    //
    uint256 totalBorrowed;
    uint256 totalDebtLimit;
    CreditManagerDebtParams[] creditManagerDebtParams;
    uint256 totalAssets;
    uint256 totalSupply;
    uint256 supplyRate;
    uint256 baseInterestRate;
    uint256 dieselRate_RAY;
    uint256 withdrawFee;
    uint256 lastBaseInterestUpdate;
    uint256 baseInterestIndexLU;
    uint256 version;
    address poolQuotaKeeper;
    address gauge;
    QuotaInfo[] quotas;
    ZapperInfo[] zappers;
    LinearModel lirm;
    bool isPaused;
}
ParameterDescription
addrAddress of the Pool.
underlyingAddress of the pool's underlying.
dieselTokenThe address of the pool's LP token.
symbolSymbol of the pool's LP token.
nameName of the pool's LP token.
baseInterestIndexInterest index of the utilization-based interest.
availableLiquidityLiquidity available for borrowing.
expectedLiquidityExpected liquidity after repaying all debt.
totalBorrowedTotal amount borrowed from the pool.
totalDebtLimitThe limit on the total amount borrowed from the pool.
creditManagerDebtParamsAn array of CreditManagerDebtParams structs with per-CM borrowing data.
totalAssetsSame as expectedLiquidity.
totalSupplyThe total supply of the pool's LP token.
supplyRateAnnualized rate of return for LPs (in 10**27 format).
baseInterestRateRate of utilization-based interest.
dieselRate_RAYConversion rate between pool LP and underlying (in 10**27 format).
withdrawFeePool withdrawal fee in basis points.
lastBaseInterestUpdateTimestamp at which the borrow rate was last updated.
baseInterestIndexLUBase interest index at last update.
versionPool version.
poolQuotaKeeperAddress of the connected PoolQuotaKeeper.
gaugeAddress of the associated Gauge.
quotasArray of QuotaInfo (see previous section) objects for each quoted token in the pool.
zappersArray of ZapperInfo (see below) objects for each zapper connected to the pool.
lirmThe address of the interest rate model for the pool.
isPausedWhether the pool is paused.

CreditManagerDebtParams structs contain information on per-CM debt metrics:

struct CreditManagerDebtParams {
    address creditManager;
    uint256 borrowed;
    uint256 limit;
    uint256 availableToBorrow;
}
ParameterDescription
creditManagerAddress of the Credit Manager.
borrowedTotal amount borrowed by the Credit Manager.
limitThe limit on the total amount borrowed.
availableToBorrowHow much more the Credit Manager can borrow.

LinearModel struct contains information on the borrow rate model:

struct LinearModel {
    address interestModel;
    uint256 version;
    uint16 U_1;
    uint16 U_2;
    uint16 R_base;
    uint16 R_slope1;
    uint16 R_slope2;
    uint16 R_slope3;
    bool isBorrowingMoreU2Forbidden;
}
ParameterDescription
interestModelAddress of the interest rate model.
versionVersion of the interest rate model.
U_1The first kink point.
U_2The second kink point.
R_baseThe base rate.
R_slope1The slope of the [0; U_1] segment.
R_slope2The slope of the [U_1; U_2] segment.
R_slope3The slope of the [U_2; 1] segment.
isBorrowingMoreU2ForbiddenWhether it is forbidden to borrow more than U_2

ZapperInfo structs carry information on zappers connected to pool:

struct ZapperInfo {
    address zapper;
    address tokenIn;
    address tokenOut;
}
ParameterDescription
zapperAddress of the zapper.
tokenInThe input token of the zapper.
tokenOutThe output token of the zapper.
Last updated on November 17, 2023