Morpho

Git Source

Inherits: MorphoGovernance

Author: Morpho Labs.

Main Morpho contract handling user interactions and pool interactions.

Functions

supply

EXTERNAL ///

Supplies underlying tokens to a specific market.

msg.sender must have approved Morpho's contract to spend the underlying _amount.

function supply(address _poolToken, uint256 _amount) external nonReentrant;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market the user wants to interact with.
_amountuint256The amount of token (in underlying) to supply.

supply

Supplies underlying tokens to a specific market, on behalf of a given user.

msg.sender must have approved Morpho's contract to spend the underlying _amount.

function supply(address _poolToken, address _onBehalf, uint256 _amount) external nonReentrant;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market the user wants to interact with.
_onBehalfaddressThe address of the account whose positions will be updated.
_amountuint256The amount of token (in underlying) to supply.

supply

Supplies underlying tokens to a specific market, on behalf of a given user, specifying a gas threshold at which to cut the matching engine.

msg.sender must have approved Morpho's contract to spend the underlying _amount.

function supply(address _poolToken, address _onBehalf, uint256 _amount, uint256 _maxGasForMatching)
    external
    nonReentrant;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market the user wants to interact with.
_onBehalfaddressThe address of the account whose positions will be updated.
_amountuint256The amount of token (in underlying) to supply.
_maxGasForMatchinguint256The gas threshold at which to stop the matching engine.

borrow

Borrows underlying tokens from a specific market.

function borrow(address _poolToken, uint256 _amount) external nonReentrant;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market the user wants to interact with.
_amountuint256The amount of token (in underlying).

borrow

Borrows underlying tokens from a specific market, specifying a gas threshold at which to stop the matching engine.

function borrow(address _poolToken, uint256 _amount, uint256 _maxGasForMatching) external nonReentrant;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market the user wants to interact with.
_amountuint256The amount of token (in underlying).
_maxGasForMatchinguint256The gas threshold at which to stop the matching engine.

withdraw

Withdraws underlying tokens from a specific market.

function withdraw(address _poolToken, uint256 _amount) external nonReentrant;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market the user wants to interact with.
_amountuint256The amount of tokens (in underlying) to withdraw from supply.

withdraw

Withdraws underlying tokens from a specific market.

function withdraw(address _poolToken, uint256 _amount, address _receiver) external nonReentrant;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market the user wants to interact with.
_amountuint256The amount of tokens (in underlying) to withdraw from supply.
_receiveraddressThe address to send withdrawn tokens to.

repay

Repays the debt of the sender, up to the amount provided.

msg.sender must have approved Morpho's contract to spend the underlying _amount.

function repay(address _poolToken, uint256 _amount) external nonReentrant;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market the user wants to interact with.
_amountuint256The amount of token (in underlying) to repay from borrow.

repay

Repays debt of a given user, up to the amount provided.

msg.sender must have approved Morpho's contract to spend the underlying _amount.

function repay(address _poolToken, address _onBehalf, uint256 _amount) external nonReentrant;

Parameters

NameTypeDescription
_poolTokenaddressThe address of the market the user wants to interact with.
_onBehalfaddressThe address of the account whose positions will be updated.
_amountuint256The amount of token (in underlying) to repay from borrow.

liquidate

Liquidates a position.

function liquidate(address _poolTokenBorrowed, address _poolTokenCollateral, address _borrower, uint256 _amount)
    external
    nonReentrant;

Parameters

NameTypeDescription
_poolTokenBorrowedaddressThe address of the pool token the liquidator wants to repay.
_poolTokenCollateraladdressThe address of the collateral pool token the liquidator wants to seize.
_borroweraddressThe address of the borrower to liquidate.
_amountuint256The amount of token (in underlying) to repay.

claimRewards

Deprecated.

function claimRewards(address[] calldata, bool) external returns (uint256);

_supply

INTERNAL ///

function _supply(address _poolToken, address _onBehalf, uint256 _amount, uint256 _maxGasForMatching) internal;

_borrow

function _borrow(address _poolToken, uint256 _amount, uint256 _maxGasForMatching) internal;

_withdraw

function _withdraw(address _poolToken, uint256 _amount, address _receiver, uint256 _maxGasForMatching) internal;

_repay

function _repay(address _poolToken, address _onBehalf, uint256 _amount, uint256 _maxGasForMatching) internal;