MarketSideDeltaLib

Git Source

Author: Morpho Labs

Library used to ease increase or decrease deltas.

Functions

increaseDelta

Given variables from a market side, updates the market side delta according to the demoted amount.

function increaseDelta(
    Types.MarketSideDelta storage delta,
    address underlying,
    uint256 amount,
    Types.MarketSideIndexes256 memory indexes,
    bool borrowSide
) internal;

Parameters

NameTypeDescription
deltaTypes.MarketSideDeltaThe market deltas to update.
underlyingaddressThe underlying address.
amountuint256The amount to supply/borrow (in underlying).
indexesTypes.MarketSideIndexes256The current indexes.
borrowSideboolWhether the market side is borrow.

decreaseDelta

Given variables from a market side, matches the delta and calculates the amount to supply/borrow from delta. Updates the market side delta accordingly.

function decreaseDelta(
    Types.MarketSideDelta storage delta,
    address underlying,
    uint256 amount,
    uint256 poolIndex,
    bool borrowSide
) internal returns (uint256, uint256);

Parameters

NameTypeDescription
deltaTypes.MarketSideDeltaThe market deltas to update.
underlyingaddressThe underlying address.
amountuint256The amount to supply/borrow (in underlying).
poolIndexuint256The current pool index.
borrowSideboolWhether the market side is borrow.

Returns

NameTypeDescription
<none>uint256The amount left to process (in underlying) and the amount to repay/withdraw (in underlying).
<none>uint256