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

Claims rewards for the given assets.

The incentives vault will never be implemented. Thus the second parameter of this function becomes useless.

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

Parameters

NameTypeDescription
_cTokenAddressesaddress[]The cToken addresses to claim rewards from.
<none>bool

Returns

NameTypeDescription
amountOfRewardsuint256The amount of rewards claimed (in COMP).

receive

Allows to receive ETH.

receive() external payable;

_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;

Events

RewardsClaimed

EVENTS ///

Emitted when a user claims rewards.

event RewardsClaimed(address indexed _user, uint256 _amountClaimed, bool indexed _traded);

Errors

ClaimRewardsPaused

ERRORS ///

Thrown when claiming rewards is paused.

error ClaimRewardsPaused();