Morpho CompoundV2 Optimizer
Entrypoint of the Morpho Optimizer protocol build on top of CompoundV2.
Functions
supply
function supply(
address _poolToken,
uint256 _amount
) external;
Creates a supply position for the sender.
msg.sender
must have approved Morpho's contract to spend the underlying _amount
.
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 on behalf
function supply(
address _poolToken,
address _onBehalf,
uint256 _amount
) external;
Creates a supply position for a given user, spending sender tokens.
msg.sender
must have approved Morpho's contract to spend the underlying _amount
.
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 on behalf with matching management
function supply(
address _poolToken,
address _onBehalf,
uint256 _amount,
uint256 _maxGasForMatching
) external;
Creates a supply position for a given user, spending sender tokens, and controlling the gas consumed for matching.
msg.sender
must have approved Morpho's contract to spend the underlying _amount
.
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
function borrow(
address _poolToken,
uint256 _amount
) external;
Borrows underlying tokens from a specific market.
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 borrow. |
borrow with matching management
function borrow(
address _poolToken,
uint256 _amount,
uint256 _maxGasForMatching
) external;
Borrows underlying tokens from a specific market, by controlling the gas consumed for matching.
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 borrow. |
_maxGasForMatching | uint256 | The gas threshold at which to stop the matching engine. |
withdraw
function withdraw(
address _poolToken,
uint256 _amount
) external;
Withdraws underlying tokens from a specific market.
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 withdraw. |
withdraw to a specific user
function withdraw(
address _poolToken,
uint256 _amount,
address _receiver
) external;
Withdraws underlying tokens from a specific market to a given user.
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 withdraw. |
_receiver | address | The address to send withdrawn tokens to. |
repay
function repay(
address _poolToken,
uint256 _amount
) external;
Repays underlying tokens from a specific market.
msg.sender
must have approved Morpho's contract to spend the underlying _amount
.
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 on behalf
function repay(
address _poolToken,
address _onBehalf,
uint256 _amount
) external;
Repays underlying tokens from a specific market to a given user.
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
function liquidate(
address _poolTokenBorrowed,
address _poolTokenCollateral,
address _borrower,
uint256 _amount
) external;
Liquidates a position.
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
function claimRewards(address[] calldata _cTokenAddresses, bool)
external
returns (uint256 amountOfRewards);
Claims rewards from the underlying pool.
This function is specific to Morpho CompoundV2 Optimizer.
Parameters:
Name | Type | Description |
---|---|---|
_cTokenAddresses | address[] | The addresses of the cTokens to claim rewards from. |
Return values:
Name | Type | Description |
---|---|---|
amountOfRewards | uint256 | The amount of rewards claimed (in COMP for CompoundV2). |