Types

Git Source

Author: Morpho Labs

Library exposing all Types used in Morpho.

Structs

MarketSideDelta

Contains the market side delta data.

struct MarketSideDelta {
    uint256 scaledDelta;
    uint256 scaledP2PTotal;
}

Deltas

Contains the delta data for both supply and borrow.

struct Deltas {
    MarketSideDelta supply;
    MarketSideDelta borrow;
}

MarketSideIndexes

Contains the market side indexes.

struct MarketSideIndexes {
    uint128 poolIndex;
    uint128 p2pIndex;
}

Indexes

Contains the indexes for both supply and borrow.

struct Indexes {
    MarketSideIndexes supply;
    MarketSideIndexes borrow;
}

PauseStatuses

Contains the different pauses statuses possible in Morpho.

struct PauseStatuses {
    bool isP2PDisabled;
    bool isSupplyPaused;
    bool isSupplyCollateralPaused;
    bool isBorrowPaused;
    bool isWithdrawPaused;
    bool isWithdrawCollateralPaused;
    bool isRepayPaused;
    bool isLiquidateCollateralPaused;
    bool isLiquidateBorrowPaused;
    bool isDeprecated;
}

Market

Contains the market data that is stored in storage.

This market struct is able to be passed into memory.

struct Market {
    Indexes indexes;
    Deltas deltas;
    address underlying;
    PauseStatuses pauseStatuses;
    bool isCollateral;
    address variableDebtToken;
    uint32 lastUpdateTimestamp;
    uint16 reserveFactor;
    uint16 p2pIndexCursor;
    address aToken;
    address stableDebtToken;
    uint256 idleSupply;
}

MarketBalances

Contains storage-only dynamic arrays and mappings.

struct MarketBalances {
    LogarithmicBuckets.Buckets poolSuppliers;
    LogarithmicBuckets.Buckets p2pSuppliers;
    LogarithmicBuckets.Buckets poolBorrowers;
    LogarithmicBuckets.Buckets p2pBorrowers;
    mapping(address => uint256) collateral;
}

Iterations

Contains the minimum number of iterations for a repay or a withdraw.

struct Iterations {
    uint128 repay;
    uint128 withdraw;
}

LiquidityData

Contains the data related to the liquidity of a user.

struct LiquidityData {
    uint256 borrowable;
    uint256 maxDebt;
    uint256 debt;
}

IndexesParams

The paramaters used to compute the new peer-to-peer indexes.

struct IndexesParams {
    MarketSideIndexes256 lastSupplyIndexes;
    MarketSideIndexes256 lastBorrowIndexes;
    uint256 poolSupplyIndex;
    uint256 poolBorrowIndex;
    uint256 reserveFactor;
    uint256 p2pIndexCursor;
    Deltas deltas;
    uint256 proportionIdle;
}

GrowthFactors

Contains the data related to growth factors as part of the peer-to-peer indexes computation.

struct GrowthFactors {
    uint256 poolSupplyGrowthFactor;
    uint256 p2pSupplyGrowthFactor;
    uint256 poolBorrowGrowthFactor;
    uint256 p2pBorrowGrowthFactor;
}

MarketSideIndexes256

Contains the market side indexes as uint256 instead of uint128.

struct MarketSideIndexes256 {
    uint256 poolIndex;
    uint256 p2pIndex;
}

Indexes256

Contains the indexes as uint256 instead of uint128.

struct Indexes256 {
    MarketSideIndexes256 supply;
    MarketSideIndexes256 borrow;
}

Signature

Contains the v, r and s parameters of an ECDSA signature.

struct Signature {
    uint8 v;
    bytes32 r;
    bytes32 s;
}

MatchingEngineVars

Variables used in the matching engine.

struct MatchingEngineVars {
    address underlying;
    MarketSideIndexes256 indexes;
    uint256 amount;
    uint256 maxIterations;
    bool borrow;
    function (address, address, uint256, uint256, bool) returns (uint256, uint256) updateDS;
    bool demoting;
    function(uint256, uint256, MarketSideIndexes256 memory, uint256)
            pure returns (uint256, uint256, uint256) step;
}

LiquidityVars

Variables used in the liquidity computation process of a user.

Used to avoid stack too deep.

struct LiquidityVars {
    address user;
    IAaveOracle oracle;
    DataTypes.EModeCategory eModeCategory;
}

BorrowWithdrawVars

Variables used during a borrow or withdraw.

Used to avoid stack too deep.

struct BorrowWithdrawVars {
    uint256 onPool;
    uint256 inP2P;
    uint256 toWithdraw;
    uint256 toBorrow;
}

SupplyRepayVars

Variables used during a supply or repay.

Used to avoid stack too deep.

struct SupplyRepayVars {
    uint256 onPool;
    uint256 inP2P;
    uint256 toSupply;
    uint256 toRepay;
}

LiquidateVars

Variables used during a liquidate.

Used to avoid stack too deep.

struct LiquidateVars {
    uint256 closeFactor;
    uint256 seized;
}

AmountToSeizeVars

Variables used to compute the amount to seize during a liquidation.

Used to avoid stack too deep.

struct AmountToSeizeVars {
    uint256 liquidationBonus;
    uint256 borrowedTokenUnit;
    uint256 collateralTokenUnit;
    uint256 borrowedPrice;
    uint256 collateralPrice;
}

Enums

Position

Enumeration of the different position types in the protocol.

enum Position {
    POOL_SUPPLIER,
    P2P_SUPPLIER,
    POOL_BORROWER,
    P2P_BORROWER
}