MarketLens

MarketLens is a contract that is primarily used by dApps and frontends to fetch data from Market.xyz pools. It is non-essential to the protocol, and its existence doesn't impact the protocol in any meaningful way.

It has methods that might not have the view modifier, hence it is suggested that all methods be called using the eth_call rpc-method.

Structs

PoolAsset

struct PoolAsset {
    address cToken;
    address underlyingToken;
    string underlyingName;
    string underlyingSymbol;
    uint256 underlyingDecimals;
    uint256 underlyingBalance;
    uint256 supplyRatePerBlock;
    uint256 borrowRatePerBlock;
    uint256 totalSupply;
    uint256 totalBorrow;
    uint256 supplyBalance;
    uint256 borrowBalance;
    uint256 liquidity;
    bool membership;
    uint256 exchangeRate; // Price of cTokens in terms of underlying tokens
    uint256 underlyingPrice; // Price of underlying tokens in ETH (scaled by 1e18)
    address oracle;
    uint256 collateralFactor;
    uint256 reserveFactor;
    uint256 adminFee;
    uint256 fuseFee;
    bool borrowGuardianPaused;
}

The PoolAsset struct contains a lot of highly detailed metadata for a given asset in a pool.

PoolUser

struct PoolUser {
    address account;
    uint256 totalBorrow;
    uint256 totalCollateral;
    uint256 health;
    PoolAsset[] assets;
}

The PoolUser struct contains details about the participation of a user / account in a pool.

Methods

getPoolSummary(address) -> (uint, uint, address[], string[])

function getPoolSummary(address comptroller) external
    returns (
        uint256, // totalBorrow
        uint256, // totalSupply
        address[] memory, // underlyingTokens
        string[] memory // underlyingSymbols
    );

Aggregates multiple read calls and returns the summary of a given pool

  • comptroller - the comptroller address of a pool

  • returns -

    • totalBorrow (total value of funds borrowed denominated in ETH)

    • totalSupply (total value of funds supplied denominated in ETH)

    • underlying token addresses

    • underlying token symbols

getPoolAssetsWithData(address) -> PoolAsset[]

function getPoolAssetsWithData(address comptroller) external returns (
    PoolAsset[] memory
);

Fetches all the supported assets in a given pool with highly detailed metadata for it

  • comptroller - the comptroller address of a pool

  • returns - a list containing PoolAsset struct that contains the asset details

getPoolUsersWithData(address, uint) -> (PoolUser[], uint, uint)

function getPoolUsersWithData(
    address comptroller, 
    uint256 maxHealth
) external returns(
    PoolUser[] memory,
    uint256, // close factor
    uint256 // liquidation incentive
);

Fetches all the users that have positions in a given pool below a certain maxHealth threshold, where health implies totalCollateral/totalBorrow

  • comptroller - the comptroller address of a pool

  • returns -

    • PoolUser[] (list of the filtered users)

    • close factor of the pool

    • liquidation incentive of the pool

getPoolUserSummary(address, address) -> (uint, uint)

function getPoolUserSummary(address comptroller, address account)
        external returns (uint256, uint256) // (supplyBalance, borrowBalance)

Fetches summary of a user account in a given pool

  • comptroller - the comptroller address of a pool

  • returns -

    • supplyBalance (the value of funds supplied by the user denominated in ETH)

    • borrowBalance (the value of funds borrowed by the user denominated in ETH)

Last updated