MarketsLens

Git Source

Inherits: RatesLens

Author: Morpho Labs.

Intermediary layer exposing endpoints to query live data related to the Morpho Protocol markets.

Functions

isMarketCreated

EXTERNAL ///

Checks if a market is created.

function isMarketCreated(address _poolToken) external view returns (bool);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market to check.

Returns

NameTypeDescription
<none>booltrue if the market is created and not paused, otherwise false.

isMarketCreatedAndNotPaused

Deprecated.

function isMarketCreatedAndNotPaused(address) external pure returns (bool);

isMarketCreatedAndNotPausedNorPartiallyPaused

Deprecated.

function isMarketCreatedAndNotPausedNorPartiallyPaused(address) external pure returns (bool);

getAllMarkets

Returns all created markets.

function getAllMarkets() external view returns (address[] memory marketsCreated);

Returns

NameTypeDescription
marketsCreatedaddress[]The list of market addresses.

getMainMarketData

For a given market, returns the average supply/borrow rates and amounts of underlying asset supplied and borrowed through Morpho, on the underlying pool and matched peer-to-peer.

The returned values are not updated.

function getMainMarketData(address _poolToken)
    external
    view
    returns (
        uint256 avgSupplyRatePerBlock,
        uint256 avgBorrowRatePerBlock,
        uint256 p2pSupplyAmount,
        uint256 p2pBorrowAmount,
        uint256 poolSupplyAmount,
        uint256 poolBorrowAmount
    );

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market of which to get main data.

Returns

NameTypeDescription
avgSupplyRatePerBlockuint256The average supply rate experienced on the given market.
avgBorrowRatePerBlockuint256The average borrow rate experienced on the given market.
p2pSupplyAmountuint256The total supplied amount matched peer-to-peer, subtracting the supply delta (in underlying).
p2pBorrowAmountuint256The total borrowed amount matched peer-to-peer, subtracting the borrow delta (in underlying).
poolSupplyAmountuint256The total supplied amount on the underlying pool, adding the supply delta (in underlying).
poolBorrowAmountuint256The total borrowed amount on the underlying pool, adding the borrow delta (in underlying).

getAdvancedMarketData

Returns non-updated indexes, the block at which they were last updated and the total deltas of a given market.

function getAdvancedMarketData(address _poolToken)
    external
    view
    returns (Types.Indexes memory indexes, uint32 lastUpdateBlockNumber, uint256 p2pSupplyDelta, uint256 p2pBorrowDelta);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market of which to get advanced data.

Returns

NameTypeDescription
indexesTypes.IndexesThe given market's virtually updated indexes.
lastUpdateBlockNumberuint32The block number at which pool indexes were last updated.
p2pSupplyDeltauint256The total supply delta (in underlying).
p2pBorrowDeltauint256The total borrow delta (in underlying).

getMarketConfiguration

Returns the given market's configuration.

function getMarketConfiguration(address _poolToken)
    external
    view
    returns (
        address underlying,
        bool isCreated,
        bool p2pDisabled,
        bool isPaused,
        bool isPartiallyPaused,
        uint16 reserveFactor,
        uint16 p2pIndexCursor,
        uint256 collateralFactor
    );

Returns

NameTypeDescription
underlyingaddressThe underlying token address.
isCreatedboolWhether the market is created or not.
p2pDisabledboolWhether the peer-to-peer market is enabled or not.
isPausedboolDeprecated.
isPartiallyPausedboolDeprecated.
reserveFactoruint16The reserve factor applied to this market.
p2pIndexCursoruint16The p2p index cursor applied to this market.
collateralFactoruint256The pool collateral factor also used by Morpho.

getMarketPauseStatus

Returns the given market's pause statuses.

function getMarketPauseStatus(address _poolToken) external view returns (Types.MarketPauseStatus memory);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market of which to get pause statuses.

Returns

NameTypeDescription
<none>Types.MarketPauseStatusThe market status struct.

getTotalMarketSupply

PUBLIC ///

Computes and returns the total distribution of supply for a given market, using virtually updated indexes.

function getTotalMarketSupply(address _poolToken)
    public
    view
    returns (uint256 p2pSupplyAmount, uint256 poolSupplyAmount);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market to check.

Returns

NameTypeDescription
p2pSupplyAmountuint256The total supplied amount matched peer-to-peer, subtracting the supply delta (in underlying).
poolSupplyAmountuint256The total supplied amount on the underlying pool, adding the supply delta (in underlying).

getTotalMarketBorrow

Computes and returns the total distribution of borrows for a given market, using virtually updated indexes.

function getTotalMarketBorrow(address _poolToken)
    public
    view
    returns (uint256 p2pBorrowAmount, uint256 poolBorrowAmount);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market to check.

Returns

NameTypeDescription
p2pBorrowAmountuint256The total borrowed amount matched peer-to-peer, subtracting the borrow delta (in underlying).
poolBorrowAmountuint256The total borrowed amount on the underlying pool, adding the borrow delta (in underlying).