Morpho
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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market the user wants to interact with. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market the user wants to interact with. |
_onBehalf | address | The address of the account whose positions will be updated. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market the user wants to interact with. |
_onBehalf | address | The address of the account whose positions will be updated. |
_amount | uint256 | The amount of token (in underlying) to supply. |
_maxGasForMatching | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market the user wants to interact with. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market the user wants to interact with. |
_amount | uint256 | The amount of token (in underlying). |
_maxGasForMatching | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market the user wants to interact with. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market the user wants to interact with. |
_amount | uint256 | The amount of tokens (in underlying) to withdraw from supply. |
_receiver | address | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market the user wants to interact with. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolToken | address | The address of the market the user wants to interact with. |
_onBehalf | address | The address of the account whose positions will be updated. |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_poolTokenBorrowed | address | The address of the pool token the liquidator wants to repay. |
_poolTokenCollateral | address | The address of the collateral pool token the liquidator wants to seize. |
_borrower | address | The address of the borrower to liquidate. |
_amount | uint256 | The 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;