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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
ABI
L2Pool ABI
[
{
"inputs": [
{
"internalType": "contract IPoolAddressesProvider",
"name": "provider",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "backer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "fee",
"type": "uint256"
}
],
"name": "BackUnbacked",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "onBehalfOf",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "enum DataTypes.InterestRateMode",
"name": "interestRateMode",
"type": "uint8"
},
{
"indexed": false,
"internalType": "uint256",
"name": "borrowRate",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint16",
"name": "referralCode",
"type": "uint16"
}
],
"name": "Borrow",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "target",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "initiator",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "enum DataTypes.InterestRateMode",
"name": "interestRateMode",
"type": "uint8"
},
{
"indexed": false,
"internalType": "uint256",
"name": "premium",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint16",
"name": "referralCode",
"type": "uint16"
}
],
"name": "FlashLoan",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "totalDebt",
"type": "uint256"
}
],
"name": "IsolationModeTotalDebtUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "collateralAsset",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "debtAsset",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "debtToCover",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "liquidatedCollateralAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "liquidator",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "receiveAToken",
"type": "bool"
}
],
"name": "LiquidationCall",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "onBehalfOf",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint16",
"name": "referralCode",
"type": "uint16"
}
],
"name": "MintUnbacked",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountMinted",
"type": "uint256"
}
],
"name": "MintedToTreasury",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "RebalanceStableBorrowRate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "repayer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "bool",
"name": "useATokens",
"type": "bool"
}
],
"name": "Repay",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "liquidityRate",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "stableBorrowRate",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "variableBorrowRate",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "liquidityIndex",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "variableBorrowIndex",
"type": "uint256"
}
],
"name": "ReserveDataUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "ReserveUsedAsCollateralDisabled",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "ReserveUsedAsCollateralEnabled",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "onBehalfOf",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint16",
"name": "referralCode",
"type": "uint16"
}
],
"name": "Supply",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": false,
"internalType": "enum DataTypes.InterestRateMode",
"name": "interestRateMode",
"type": "uint8"
}
],
"name": "SwapBorrowRateMode",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": false,
"internalType": "uint8",
"name": "categoryId",
"type": "uint8"
}
],
"name": "UserEModeSet",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "reserve",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "Withdraw",
"type": "event"
},
{
"inputs": [],
"name": "ADDRESSES_PROVIDER",
"outputs": [
{
"internalType": "contract IPoolAddressesProvider",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "BRIDGE_PROTOCOL_FEE",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "FLASHLOAN_PREMIUM_TOTAL",
"outputs": [
{
"internalType": "uint128",
"name": "",
"type": "uint128"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "FLASHLOAN_PREMIUM_TO_PROTOCOL",
"outputs": [
{
"internalType": "uint128",
"name": "",
"type": "uint128"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MAX_NUMBER_RESERVES",
"outputs": [
{
"internalType": "uint16",
"name": "",
"type": "uint16"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MAX_STABLE_RATE_BORROW_SIZE_PERCENT",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "POOL_REVISION",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "fee",
"type": "uint256"
}
],
"name": "backUnbacked",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "interestRateMode",
"type": "uint256"
},
{
"internalType": "uint16",
"name": "referralCode",
"type": "uint16"
},
{
"internalType": "address",
"name": "onBehalfOf",
"type": "address"
}
],
"name": "borrow",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "args",
"type": "bytes32"
}
],
"name": "borrow",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint8",
"name": "id",
"type": "uint8"
},
{
"components": [
{
"internalType": "uint16",
"name": "ltv",
"type": "uint16"
},
{
"internalType": "uint16",
"name": "liquidationThreshold",
"type": "uint16"
},
{
"internalType": "uint16",
"name": "liquidationBonus",
"type": "uint16"
},
{
"internalType": "address",
"name": "priceSource",
"type": "address"
},
{
"internalType": "string",
"name": "label",
"type": "string"
}
],
"internalType": "struct DataTypes.EModeCategory",
"name": "category",
"type": "tuple"
}
],
"name": "configureEModeCategory",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "address",
"name": "onBehalfOf",
"type": "address"
},
{
"internalType": "uint16",
"name": "referralCode",
"type": "uint16"
}
],
"name": "deposit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "dropReserve",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "balanceFromBefore",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "balanceToBefore",
"type": "uint256"
}
],
"name": "finalizeTransfer",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiverAddress",
"type": "address"
},
{
"internalType": "address[]",
"name": "assets",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "amounts",
"type": "uint256[]"
},
{
"internalType": "uint256[]",
"name": "interestRateModes",
"type": "uint256[]"
},
{
"internalType": "address",
"name": "onBehalfOf",
"type": "address"
},
{
"internalType": "bytes",
"name": "params",
"type": "bytes"
},
{
"internalType": "uint16",
"name": "referralCode",
"type": "uint16"
}
],
"name": "flashLoan",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiverAddress",
"type": "address"
},
{
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "params",
"type": "bytes"
},
{
"internalType": "uint16",
"name": "referralCode",
"type": "uint16"
}
],
"name": "flashLoanSimple",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "getConfiguration",
"outputs": [
{
"components": [
{
"internalType": "uint256",
"name": "data",
"type": "uint256"
}
],
"internalType": "struct DataTypes.ReserveConfigurationMap",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint8",
"name": "id",
"type": "uint8"
}
],
"name": "getEModeCategoryData",
"outputs": [
{
"components": [
{
"internalType": "uint16",
"name": "ltv",
"type": "uint16"
},
{
"internalType": "uint16",
"name": "liquidationThreshold",
"type": "uint16"
},
{
"internalType": "uint16",
"name": "liquidationBonus",
"type": "uint16"
},
{
"internalType": "address",
"name": "priceSource",
"type": "address"
},
{
"internalType": "string",
"name": "label",
"type": "string"
}
],
"internalType": "struct DataTypes.EModeCategory",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint16",
"name": "id",
"type": "uint16"
}
],
"name": "getReserveAddressById",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "getReserveData",
"outputs": [
{
"components": [
{
"components": [
{
"internalType": "uint256",
"name": "data",
"type": "uint256"
}
],
"internalType": "struct DataTypes.ReserveConfigurationMap",
"name": "configuration",
"type": "tuple"
},
{
"internalType": "uint128",
"name": "liquidityIndex",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "currentLiquidityRate",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "variableBorrowIndex",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "currentVariableBorrowRate",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "currentStableBorrowRate",
"type": "uint128"
},
{
"internalType": "uint40",
"name": "lastUpdateTimestamp",
"type": "uint40"
},
{
"internalType": "uint16",
"name": "id",
"type": "uint16"
},
{
"internalType": "address",
"name": "aTokenAddress",
"type": "address"
},
{
"internalType": "address",
"name": "stableDebtTokenAddress",
"type": "address"
},
{
"internalType": "address",
"name": "variableDebtTokenAddress",
"type": "address"
},
{
"internalType": "address",
"name": "interestRateStrategyAddress",
"type": "address"
},
{
"internalType": "uint128",
"name": "accruedToTreasury",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "unbacked",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "isolationModeTotalDebt",
"type": "uint128"
}
],
"internalType": "struct DataTypes.ReserveData",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "getReserveNormalizedIncome",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "getReserveNormalizedVariableDebt",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getReservesList",
"outputs": [
{
"internalType": "address[]",
"name": "",
"type": "address[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "getUserAccountData",
"outputs": [
{
"internalType": "uint256",
"name": "totalCollateralBase",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "totalDebtBase",
"type": "uint256"
},
{