Links

L2Pool

The L2Pool.sol is the contract for the L2 optimized user facing methods of the protocol that takes byte encoded input arguments. It exposes the liquidity management methods that can be invoked using either Solidity or Web3 libraries.\
Pool methods not exposed in L2Pool.sol (such as flashLoan, setUserEMode etc.) are same on L2 as on other versions of protocol. Refer Pool docs for rest of the methods.
Since we have a limited set of supported assets that are already given individual id, we use the 16 bit asset id in the encoded arguments instead of 160 bit asset address.

Methods

supply

function supply(bytes32 args) external
Supplies asset into the protocol, minting the same amount of corresponding aTokens, and transferring them to msg.sender.
You can use data returned from encodeSupplyParams method in L2Encoder helper contract to pass to this method.
Call Params
Name
Type
Description
args
bytes32
Encoded supply params bit 0-15: id of the reserve. based on its position in the list of the active reserves bit 16-143: uint128 Shortened amount from original uint256 bit 144-159: uint16 referral code used for 3rd party integrations

supplyWithPermit

function supplyWithPermit(bytes32 args, bytes32 r, bytes32 s) external
Supply with transfer approval of supplied asset via permit function. This method removes the need for separate approval tx before supplying asset to the pool.
You can use data returned from encodeSupplyWithPermitParams method in L2Encoder helper contract to pass to this method.
Name
Type
Description
args
bytes32
Encoded supply with permit params bit 0-15: id of the reserve. based on its position in the list of the active reserves bit 16-143: uint128 shortened amount from original uint256 bit 144-159: uint16 referral code used for 3rd party integrations bit 160-191: uint32 shortened deadline from original uint256 bit 192-199: Signature parameter v
r
bytes32
Signature parameter r
s
bytes32
Signature parameter s

withdraw

function withdraw(bytes32 args) external
Withdraws amount of the underlying asset, i.e. redeems the underlying token and burns the aTokens.
If user has any existing debt backed by the underlying token, then the max amount available to withdraw is the amount that will not leave user health factor < 1 after withdrawal.
You can use data returned from encodeWithdrawParams method in L2Encoder helper contract to pass to this method.
Name
Type
Description
args
bytes32
Encoded supply params bit 0-15: id of the reserve. based on its position in the list of the active reserves bit 16-143: uint128 Shortened amount from original uint256

borrow

function borrow(bytes32 args) external
Borrows amount of asset with interestRateMode, sending the amount to msg.sender, with the debt being incurred by onBehalfOf.
You can use data returned from encodeBorrowParams method in L2Encoder helper contract to pass to this method.
Name
Type
Description
args
bytes32
Encoded supply params bit 0-15: id of the reserve. based on its position in the list of the active reserves bit 16-143: uint128 Shortened amount from original uint256 bit 144 - 151: uint8 shortened InterestRateMode bit 152 - 167: uint16 referral code used for 3rd party integrations

repay

function repay(bytes32 args) external returns (uint256)
Repays debt of an asset for the given rateMode.
You can use data returned from encodeRepayParams method in L2Encoder helper contract to pass to this method.
Name
Type
Description
args
bytes32
Encoded supply params bit 0-15: id of the reserve. based on its position in the list of the active reserves bit 16-143: uint128 Shortened amount from original uint256 bit 144 - 151: uint8 shortened InterestRateMode

repayWithPermit

function repayWithPermit(bytes32 args, bytes32 r, bytes32 s) external returns (uint256)
Repay with transfer approval of borrowed asset via permit function. This method removes the need for separate approval tx before repaying asset to the pool.
You can use data returned from encodeRepayWithPermitParams method in L2Encoder helper contract to pass to this method.​
Name
Type
Description
args
bytes32
Encoded supply with permit params bit 0-15: id of the reserve. based on its position in the list of the active reserves bit 16-143: uint128 shortened amount from original uint256 bit 144-151: uint8 shortened InterestRateMode bit 152-183: uint32 shortened deadline from original uint256 bit 184-191: Signature parameter v
r
bytes32
Signature parameter r
s
bytes32
Signature parameter s

repayWithATokens

function repayWithATokens(bytes32 args) external override returns (uint256)
Allows user to repay with aTokens of the underlying debt asset without any approvals eg. Pay DAI debt using aDAI tokens.
You can use data data returned from encodeRepayWithATokensParams method in L2Encoder helper contract to pass to this method.
Name
Type
Description
args
bytes32
Encoded supply params bit 0-15: id of the reserve. based on its position in the list of the active reserves bit 16-143: uint128 Shortened amount from original uint256 bit 144 - 151: uint8 shortened InterestRateMode

swapBorrowRateMode

function swapBorrowRateMode(bytes32 args) external
Swaps msg.sender's borrow rate mode between stable and variable.
You can use data returned from encodeSwapBorrowRateMode method in L2Encoder helper contract to pass to this method.​
Name
Type
Description
args
bytes32
Encoded params bit 0-15: id of the reserve. based on its position in the list of the active reserves bit 16-23: uint8 shortened InterestRateMode

rebalanceStableBorrowRate

function rebalanceStableBorrowRate(bytes32 args) external
Rebalances stable borrow rate of the user for given asset. In case of liquidity crunches on the protocol, stable rate borrows might need to be rebalanced to bring back equilibrium between the borrow and supply rates.
You can use data returned from encodeRebalanceStableBorrowRate method in L2Encoder helper contract to pass to this method.​
Name
Type
Description
args
bytes32
Encoded params bit 0-15: id of the reserve. based on its position in the list of the active reserves bit 16-175: user address

setUserUseReserveAsCollateral

function setUserUseReserveAsCollateral(bytes32 args) external
Sets the asset of msg.sender to be used as collateral or not.
You can use data returned from encodeSetUserUseReserveAsCollateral method in L2Encoder helper contract to pass to this method.​
Name
Type
Description
args
bytes32
Encoded params bit 0-15: id of the reserve. based on its position in the list of the active reserves bit 16: 0=> enable use as collateral, 1=> disable use as collateral

liquidationCall

function liquidationCall(bytes32 args1, bytes32 args2) external
Liquidate positions with a health factor below 1.
You can use data returned from encodeLiquidationCall method in L2Encoder helper contract to pass to this method.​
Name
Type
Description
args1
bytes32
Encoded params bit 0-15: id of the collateral reserve. based on its position in the list of the active reserves bit 16-31: id of the debt reserve. based on its position in the list of the active reserves bit 32-191: address of user being liquidated
args2
bytes32
Encoded params bit 0-127: uint128 shortened debt to cover from the original uint256 bit 128: 0=> receive aToken, 1=> receive underlying asset

ABI

L2Pool ABI