IndexesLens
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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market. |
Returns
Name | Type | Description |
---|---|---|
p2pSupplyIndex | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market. |
Returns
Name | Type | Description |
---|---|---|
p2pBorrowIndex | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market. |
_updated | bool | Whether to compute virtually updated pool and peer-to-peer indexes. |
Returns
Name | Type | Description |
---|---|---|
indexes | Types.Indexes | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market. |
Returns
Name | Type | Description |
---|---|---|
poolSupplyIndex | uint256 | The supply index. |
poolBorrowIndex | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market. |
_updated | bool | Whether to compute virtually updated pool and peer-to-peer indexes. |
Returns
Name | Type | Description |
---|---|---|
delta | Types.Delta | The given market's deltas. |
indexes | Types.Indexes | The 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
Name | Type | Description |
---|---|---|
_poolToken | ICToken | The address of the market. |
Returns
Name | Type | Description |
---|---|---|
poolSupplyIndex | uint256 | The supply index. |
poolBorrowIndex | uint256 | The borrow index. |
vars | PoolInterestsVars |
_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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market. |
_updated | bool | Whether to compute virtually updated peer-to-peer indexes. |
_poolSupplyIndex | uint256 | The underlying pool supply index. |
_poolBorrowIndex | uint256 | The underlying pool borrow index. |
_delta | Types.Delta | The given market's deltas. |
_lastPoolIndexes | Types.LastPoolIndexes | The last pool indexes stored on Morpho. |
Returns
Name | Type | Description |
---|---|---|
_p2pSupplyIndex | uint256 | The given market's peer-to-peer supply index. |
_p2pBorrowIndex | uint256 | The given market's peer-to-peer borrow index. |
marketParameters | Types.MarketParameters |
Structs
PoolInterestsVars
INTERNAL ///
struct PoolInterestsVars {
uint256 cash;
uint256 totalBorrows;
uint256 totalReserves;
uint256 reserveFactorMantissa;
}