InterestRatesLib
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
Name | Type | Description |
---|---|---|
newP2PSupplyIndex | uint256 | The peer-to-peer supply index. |
newP2PBorrowIndex | uint256 | The 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
Name | Type | Description |
---|---|---|
newPoolSupplyIndex | uint256 | The pool's current supply index. |
newPoolBorrowIndex | uint256 | The pool's current borrow index. |
lastPoolSupplyIndex | uint256 | The pool's last supply index. |
lastPoolBorrowIndex | uint256 | The pool's last borrow index. |
p2pIndexCursor | uint256 | The peer-to-peer index cursor for the given market. |
reserveFactor | uint256 | The reserve factor of the given market. |
Returns
Name | Type | Description |
---|---|---|
growthFactors | Types.GrowthFactors | The 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
Name | Type | Description |
---|---|---|
poolGrowthFactor | uint256 | The pool growth factor. |
p2pGrowthFactor | uint256 | The peer-to-peer growth factor. |
lastIndexes | Types.MarketSideIndexes256 | The last pool & peer-to-peer indexes. |
scaledDelta | uint256 | The last scaled peer-to-peer delta (pool unit). |
scaledP2PTotal | uint256 | The last scaled total peer-to-peer amount (P2P unit). |
proportionIdle | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | newP2PIndex The updated peer-to-peer index (in ray). |