EntryPositionsManager

Git Source

Inherits: IEntryPositionsManager, PositionsManagerUtils

Author: Morpho Labs.

Morpho's entry points: supply and borrow.

Functions

supplyLogic

LOGIC ///

Implements supply logic.

function supplyLogic(address _poolToken, address _from, address _onBehalf, uint256 _amount, uint256 _maxGasForMatching)
    external;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the pool token the user wants to interact with.
_fromaddressThe address of the account sending funds.
_onBehalfaddressThe address of the account whose positions will be updated.
_amountuint256The amount of token (in underlying).
_maxGasForMatchinguint256The maximum amount of gas to consume within a matching engine loop.

borrowLogic

Peer-to-peer supply /// Pool supply ///

Implements borrow logic.

function borrowLogic(address _poolToken, uint256 _amount, uint256 _maxGasForMatching) external;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market the user wants to interact with.
_amountuint256The amount of token (in underlying).
_maxGasForMatchinguint256The maximum amount of gas to consume within a matching engine loop.

_borrowAllowed

Peer-to-peer borrow /// Pool borrow ///

Checks whether the user can borrow or not.

function _borrowAllowed(address _user, address _poolToken, uint256 _borrowedAmount) internal returns (bool);

Parameters

NameTypeDescription
_useraddressThe user to determine liquidity for.
_poolTokenaddressThe market to hypothetically borrow in.
_borrowedAmountuint256The amount of tokens to hypothetically borrow (in underlying).

Returns

NameTypeDescription
<none>boolWhether the borrow is allowed or not.

Events

Supplied

EVENTS ///

Emitted when a supply happens.

event Supplied(
    address indexed _from,
    address indexed _onBehalf,
    address indexed _poolToken,
    uint256 _amount,
    uint256 _balanceOnPool,
    uint256 _balanceInP2P
);

Borrowed

Emitted when a borrow happens.

event Borrowed(
    address indexed _borrower,
    address indexed _poolToken,
    uint256 _amount,
    uint256 _balanceOnPool,
    uint256 _balanceInP2P
);

Errors

BorrowingNotEnabled

ERRORS ///

Thrown when borrowing is impossible, because it is not enabled on pool for this specific market.

error BorrowingNotEnabled();

UnauthorisedBorrow

Thrown when the user does not have enough collateral for the borrow.

error UnauthorisedBorrow();

SupplyIsPaused

Thrown when someone tries to supply but the supply is paused.

error SupplyIsPaused();

BorrowIsPaused

Thrown when someone tries to borrow but the borrow is paused.

error BorrowIsPaused();

Structs

SupplyVars

STRUCTS ///

struct SupplyVars {
    uint256 remainingToSupply;
    uint256 poolBorrowIndex;
    uint256 toRepay;
}