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 avgSupplyRatePerYear,
        uint256 avgBorrowRatePerYear,
        uint256 p2pSupplyAmount,
        uint256 p2pBorrowAmount,
        uint256 poolSupplyAmount,
        uint256 poolBorrowAmount
    );

Parameters

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

Returns

NameTypeDescription
avgSupplyRatePerYearuint256The average supply rate experienced on the given market.
avgBorrowRatePerYearuint256The 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 lastUpdateTimestamp, uint256 p2pSupplyDelta, uint256 p2pBorrowDelta);

Parameters

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

Returns

NameTypeDescription
indexesTypes.IndexesThe given market's updated indexes.
lastUpdateTimestampuint32The timestamp of the block 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 isP2PDisabled,
        bool isPaused,
        bool isPartiallyPaused,
        uint16 reserveFactor,
        uint16 p2pIndexCursor,
        uint256 loanToValue,
        uint256 liquidationThreshold,
        uint256 liquidationBonus,
        uint256 decimals
    );

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market of which to get the configuration.

Returns

NameTypeDescription
underlyingaddressThe underlying token address.
isCreatedboolWhether the market is created or not.
isP2PDisabledboolWhether 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.
loanToValueuint256The ltv of the given market, set by AAVE.
liquidationThresholduint256The liquidation threshold of the given market, set by AAVE.
liquidationBonusuint256The liquidation bonus of the given market, set by AAVE.
decimalsuint256The number of decimals of the underlying token.

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

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

function getTotalMarketSupply(address _poolToken)
    external
    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)
    external
    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).

_getTotalMarketSupply

INTERNAL ///

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

function _getTotalMarketSupply(address _poolToken)
    internal
    view
    returns (address underlyingToken, uint256 p2pSupplyAmount, uint256 poolSupplyAmount);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market to check.

Returns

NameTypeDescription
underlyingTokenaddressThe address of the underlying ERC20 token of the given market.
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)
    internal
    view
    returns (address underlyingToken, uint256 p2pBorrowAmount, uint256 poolBorrowAmount);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market to check.

Returns

NameTypeDescription
underlyingTokenaddressThe address of the underlying ERC20 token of the given market.
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).