DeltasLib

Git Source

Author: Morpho Labs

Library used to ease delta reads and writes.

Functions

increaseP2P

Increases the peer-to-peer amounts following a promotion.

function increaseP2P(
    Types.Deltas storage deltas,
    address underlying,
    uint256 promoted,
    uint256 amount,
    Types.Indexes256 memory indexes,
    bool borrowSide
) internal returns (uint256 p2pBalanceIncrease);

Parameters

NameTypeDescription
deltasTypes.DeltasThe market deltas to update.
underlyingaddressThe underlying address.
promoteduint256The amount to increase the promoted side peer-to-peer total (in underlying). Must be lower than or equal to amount.
amountuint256The amount to increase the opposite side peer-to-peer total (in underlying).
indexesTypes.Indexes256The current indexes.
borrowSideboolTrue if this follows borrower promotions. False for supplier promotions.

Returns

NameTypeDescription
p2pBalanceIncreaseuint256The scaled balance amount in peer-to-peer to increase.

decreaseP2P

Decreases the peer-to-peer amounts following a demotion.

function decreaseP2P(
    Types.Deltas storage deltas,
    address underlying,
    uint256 demoted,
    uint256 amount,
    Types.Indexes256 memory indexes,
    bool borrowSide
) internal;

Parameters

NameTypeDescription
deltasTypes.DeltasThe market deltas to update.
underlyingaddressThe underlying address.
demoteduint256The amount to decrease the demoted side peer-to-peer total (in underlying). Must be lower than or equal to amount.
amountuint256The amount to decrease the opposite side peer-to-peer total (in underlying).
indexesTypes.Indexes256The current indexes.
borrowSideboolTrue if this follows borrower demotions. False for supplier demotions.