IndexesLens

Git Source

Inherits: LensStorage

Author: Morpho Labs.

Intermediary layer exposing endpoints to query live data related to the Morpho Protocol market indexes & rates.

Functions

getCurrentP2PSupplyIndex

EXTERNAL ///

Returns the updated peer-to-peer supply index.

function getCurrentP2PSupplyIndex(address _poolToken) external view returns (uint256 p2pSupplyIndex);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market.

Returns

NameTypeDescription
p2pSupplyIndexuint256The virtually updated peer-to-peer supply index.

getCurrentP2PBorrowIndex

Returns the updated peer-to-peer borrow index.

function getCurrentP2PBorrowIndex(address _poolToken) external view returns (uint256 p2pBorrowIndex);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market.

Returns

NameTypeDescription
p2pBorrowIndexuint256The virtually updated peer-to-peer borrow index.

getIndexes

Returns the most up-to-date or virtually updated peer-to-peer and pool indexes.

If not virtually updated, the indexes returned are those used by Morpho for non-updated markets during the liquidity check.

function getIndexes(address _poolToken, bool _updated) external view returns (Types.Indexes memory indexes);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market.
_updatedboolWhether to compute virtually updated pool and peer-to-peer indexes.

Returns

NameTypeDescription
indexesTypes.IndexesThe given market's virtually updated indexes.

getCurrentPoolIndexes

Returns the virtually updated pool indexes of a given market.

Mimicks CToken.accrueInterest's calculations, without writing to the storage.

function getCurrentPoolIndexes(address _poolToken)
    external
    view
    returns (uint256 poolSupplyIndex, uint256 poolBorrowIndex);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market.

Returns

NameTypeDescription
poolSupplyIndexuint256The supply index.
poolBorrowIndexuint256The borrow index.

_getIndexes

Returns the most up-to-date or virtually updated peer-to-peer and pool indexes.

If not virtually updated, the indexes returned are those used by Morpho for non-updated markets during the liquidity check.

function _getIndexes(address _poolToken, bool _updated)
    internal
    view
    returns (Types.Delta memory delta, Types.Indexes memory indexes);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market.
_updatedboolWhether to compute virtually updated pool and peer-to-peer indexes.

Returns

NameTypeDescription
deltaTypes.DeltaThe given market's deltas.
indexesTypes.IndexesThe given market's updated indexes.

_accruePoolInterests

Returns the virtually updated pool indexes of a given market.

Mimicks CToken.accrueInterest's calculations, without writing to the storage.

function _accruePoolInterests(ICToken _poolToken)
    internal
    view
    returns (uint256 poolSupplyIndex, uint256 poolBorrowIndex, PoolInterestsVars memory vars);

Parameters

NameTypeDescription
_poolTokenICTokenThe address of the market.

Returns

NameTypeDescription
poolSupplyIndexuint256The supply index.
poolBorrowIndexuint256The borrow index.
varsPoolInterestsVars

_computeP2PIndexes

Returns the most up-to-date or virtually updated peer-to-peer indexes.

If not virtually updated, the indexes returned are those used by Morpho for non-updated markets during the liquidity check.

function _computeP2PIndexes(
    address _poolToken,
    bool _updated,
    uint256 _poolSupplyIndex,
    uint256 _poolBorrowIndex,
    Types.Delta memory _delta,
    Types.LastPoolIndexes memory _lastPoolIndexes
)
    internal
    view
    returns (uint256 _p2pSupplyIndex, uint256 _p2pBorrowIndex, Types.MarketParameters memory marketParameters);

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market.
_updatedboolWhether to compute virtually updated peer-to-peer indexes.
_poolSupplyIndexuint256The underlying pool supply index.
_poolBorrowIndexuint256The underlying pool borrow index.
_deltaTypes.DeltaThe given market's deltas.
_lastPoolIndexesTypes.LastPoolIndexesThe last pool indexes stored on Morpho.

Returns

NameTypeDescription
_p2pSupplyIndexuint256The given market's peer-to-peer supply index.
_p2pBorrowIndexuint256The given market's peer-to-peer borrow index.
marketParametersTypes.MarketParameters

Structs

PoolInterestsVars

INTERNAL ///

struct PoolInterestsVars {
    uint256 cash;
    uint256 totalBorrows;
    uint256 totalReserves;
    uint256 reserveFactorMantissa;
}