Interactions
The pTokens contract handles core asset management operations such as supplying, borrowing, repaying, withdrawing, and liquidating. These functions form the backbone of user interaction with the lending protocol.
deposit
Supply assets to receive pTokens representing your share in the liquidity pool.
The sender supplies assets into the market, and in return, the minter receives pTokens as a representation of their deposit.
function deposit(uint256 mintAmount, address receiver)
external
returns (uint256);
Name
Type
Description
mintAmount
uint256
The amount of the underlying asset to supply
receiver
address
User whom the supply will be attributed to
User whom the supply will be attributed to
Returns
Name
Type
Description
none
uint256
amount of minted tokens
borrow
Borrow assets against your collateral.
Sender borrows assets from the protocol to their own address
function borrow(uint256 borrowAmount) external;
Parameters
Name
Type
Description
borrowAmount
uint256
The amount of the underlying asset to borrow
repayBorrow
Repay borrowed assets to reduce your outstanding debt.
Sender repays their own borrow
function repayBorrow(uint256 repayAmount) external;
Parameters
Name
Type
Description
repayAmount
uint256
The amount to repay, or type(uint256).max for the full outstanding amount
withdraw
Sender redeems pTokens in exchange for a specified amount of underlying asset
Accrues interest whether or not the operation succeeds, unless reverted
function withdraw(uint256 redeemAmount, address receiver, address owner)
external
returns (uint256);
Parameters
Name
Type
Description
redeemAmount
uint256
The amount of underlying to redeem
receiver
address
The address to receive underlying redeemed asset
owner
address
The address which account for redeem tokens
Returns
Name
Type
Description
<none>
uint256
amount of burnt tokens
mint
Similar to deposit
, but lets you specify the amount of pTokens to mint.
The sender supplies assets into the market and receives pTokens in exchange
function mint(uint256 tokenAmount, address receiver)
external
returns (uint256);
Parameters
Name
Type
Description
tokenAmount
uint256
The amount of token to mint for supply
receiver
address
User whom the supply will be attributed to
Returns
Name
Type
Description
<none>
uint256
amount of supplied underlying asset
redeem
The sender redeems pTokens in exchange for the underlying asset
function redeem(uint256 redeemTokens, address receiver, address owner)
external
returns (uint256);
Parameters
Name
Type
Description
redeemTokens
uint256
The number of pTokens to redeem into underlying
receiver
address
The address to receive underlying redeemed asset
owner
address
The address which account for redeem tokens
Returns
Name
Type
Description
<none>
uint256
amount of redeemed underlying asset
borrowOnBehalfOf
The sender borrows assets on behalf of some other address. This function is only available for senders, explicitly marked as delegates of the borrower using riskEngine.updateDelegate
function borrowOnBehalfOf(address onBehalfOf, uint256 borrowAmount)
external;
Parameters
Name
Type
Description
onBehalfOf
address
The borrower, on behalf of whom to borrow
borrowAmount
uint256
The amount of the underlying asset to borrow
repayBorrowOnBehalfOf
Sender repays a borrow belonging to borrower
function repayBorrowOnBehalfOf(address onBehalfOf, uint256 repayAmount)
external;
Name
Type
Description
onBehalfOf
address
the account with the debt being payed off
repayAmount
uint256
The amount to repay, or type(uint256).max for the full outstanding amount
liquidateBorrow
The sender liquidates the borrower's collateral. The collateral seized is transferred to the liquidator.
function liquidateBorrow(address borrower, uint256 repayAmount, IPToken pTokenCollateral)
external;
Parameters
Name
Type
Description
borrower
address
The borrower of this pToken to be liquidated
repayAmount
uint256
The amount of the underlying borrowed asset to repay
pTokenCollateral
IPToken
The market in which to seize collateral from the borrower
reduceReservesEmergency
Accrues interest and reduces reserves by transferring to emergency guardian
function reduceReservesEmergency(uint256 reduceAmount) external;
Parameters
reduceAmount
uint256
Amount of reduction to total reserves
reduceReservesOwner
Accrues interest and reduces reserves by transferring to protocol owner
function reduceReservesOwner(uint256 reduceAmount) external;
Parameters
reduceAmount
uint256
Amount of reduction to owner reserves
reduceReservesConfigurator
Accrues interest and reduces reserves by transferring to governor
function reduceReservesConfigurator(uint256 reduceAmount) external;
reduceReservesOwner
Parameters
reduceAmount
uint256
Amount of reduction to configurator reserves
sweepToken
A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to admin (timelock)
function sweepToken(IERC20 token) external;
Parameters
token
IERC20
The address of the ERC-20 token to sweep
setReserveFactor
Admin Functions
accrues interest and sets a new reserve factor for the protocol
Admin function to accrue interest and set a new reserve factor
functionsetReserveFactor(uint256 newReserveFactorMantissa) external;
setProtocolSeizeShare
sets a new seize share for the protocol
Admin function to set a new seize share
function setProtocolSeizeShare(uint256 newProtocolSeizeShareMantissa) external;
configureInterestRateModel
Configures the parameters for the interest rate model of the protocol.
This function sets the base rate, multipliers, and kink points for the interest rate model. All annualized rates are converted to per-second rates for internal calculations. Only callable by the configurator.
functionconfigureInterestRateModel(
uint256 baseRatePerYear,
uint256 multiplierPerYear,
uint256 firstJumpMultiplierPerYear,
uint256 secondJumpMultiplierPerYear,
uint256 firstKink,
uint256 secondKink
) external;
Parameters
baseRatePerYear
uint256
The base interest rate per year (scaled by 1e18) before utilization hits the first kink.
multiplierPerYear
uint256
The multiplier per year (scaled by 1e18) that increases the interest rate as utilization increases before the first kink.
firstJumpMultiplierPerYear
uint256
The additional multiplier applied after the first kink point (scaled by 1e18).
secondJumpMultiplierPerYear
uint256
The additional multiplier applied after second kink point (scaled by 1e18).
firstKink
uint256
The utilization rate (scaled by 1e18) at which the interest rate "jumps" according to the first jump multiplier.
secondKink
uint256
The utilization rate (scaled by 1e18) at which the interest rate "jumps" according to the second jump multiplier.
Last updated