InterestRatesLib

Git Source

Author: Morpho Labs

Library helping to compute the new peer-to-peer indexes.

Functions

computeP2PIndexes

Computes and returns the new peer-to-peer indexes of a market given its parameters.

function computeP2PIndexes(Types.IndexesParams memory params)
    internal
    pure
    returns (uint256 newP2PSupplyIndex, uint256 newP2PBorrowIndex);

Returns

NameTypeDescription
newP2PSupplyIndexuint256The peer-to-peer supply index.
newP2PBorrowIndexuint256The peer-to-peer borrow index.

computeGrowthFactors

Computes and returns the new growth factors associated to a given pool's supply/borrow index & Morpho's peer-to-peer index.

function computeGrowthFactors(
    uint256 newPoolSupplyIndex,
    uint256 newPoolBorrowIndex,
    uint256 lastPoolSupplyIndex,
    uint256 lastPoolBorrowIndex,
    uint256 p2pIndexCursor,
    uint256 reserveFactor
) internal pure returns (Types.GrowthFactors memory growthFactors);

Parameters

NameTypeDescription
newPoolSupplyIndexuint256The pool's current supply index.
newPoolBorrowIndexuint256The pool's current borrow index.
lastPoolSupplyIndexuint256The pool's last supply index.
lastPoolBorrowIndexuint256The pool's last borrow index.
p2pIndexCursoruint256The peer-to-peer index cursor for the given market.
reserveFactoruint256The reserve factor of the given market.

Returns

NameTypeDescription
growthFactorsTypes.GrowthFactorsThe market's indexes growth factors (in ray).

computeP2PIndex

Computes and returns the new peer-to-peer index of a market given its parameters.

function computeP2PIndex(
    uint256 poolGrowthFactor,
    uint256 p2pGrowthFactor,
    Types.MarketSideIndexes256 memory lastIndexes,
    uint256 scaledDelta,
    uint256 scaledP2PTotal,
    uint256 proportionIdle
) internal pure returns (uint256);

Parameters

NameTypeDescription
poolGrowthFactoruint256The pool growth factor.
p2pGrowthFactoruint256The peer-to-peer growth factor.
lastIndexesTypes.MarketSideIndexes256The last pool & peer-to-peer indexes.
scaledDeltauint256The last scaled peer-to-peer delta (pool unit).
scaledP2PTotaluint256The last scaled total peer-to-peer amount (P2P unit).
proportionIdleuint256

Returns

NameTypeDescription
<none>uint256newP2PIndex The updated peer-to-peer index (in ray).