PermissionedLendingPool

PermissionedLendingPool

The PermissionedLendingPool contract is the main contract adding the "permissions" layer to Aave Arc. It exposes all the user-oriented actions that can be invoked using either Solidity or Web3 libraries.

The source code can be found on Github here.

Pool methods deposit, borrow, withdraw and repay are only for ERC20. For ETH , use PermissionedWETHGateway

Contract API reference

Write Methods

deposit()

Allows whitelisted depositors to deposit amount of an asset into the market, minting the same amount of corresponding aTokens, and transferring them to the onBehalfOf address.

OnBehalfOf must be whitelisted for DEPOSITOR role.

permissionAdmin that whitelisted onBehalfOf must be still valid.

When depositing, the PermissionedLendingPool contract must have allowanceto spend funds on behalf of msg.sender at-least for amount of the asset being deposited. This can be done via the standard ERC20 approve() method.

ParamsTypeDescription

asset

address

address of the underlying asset

amount

uint256

amount deposited, expressed in wei units

onBehalfOf

address

address whom will receive the aTokens. Use msg.sender when the aTokens should be sent to the caller.

referralCode

uint16

referral code for 3rd party referral program integration. Use 0 for no referral.

withdraw()

Allows whitelisted depositors to withdraw amount of the underlying asset, i.e. burn aToken to redeem the underlying token.

msg.sender must be whitelisted for DEPOSITOR role.

When withdrawing to another address, msg.sendershould have aToken that will be burned by lendingPool .

ParamsTypeDescription

asset

address

address of the underlying asset, not the aToken

amount

uint256

amount deposited, expressed in wei units. Use type(uint).max to withdraw the entire balance.

to

address

address that will receive the asset

borrow()

Allows whitelisted Borrowers amount of asset with interestRateMode, sending the borrowed amount to msg.sender and the debt incurred by onBehalfOf.

msg.sender and onBehalfOf must be whitelisted for BORROWER role. permissionAdmin that whitelisted onBehalfOf must be still valid.

onBehalfOf must have enough collateral supplied to the pool via deposit() or have delegated credit to msg.sender via approveDelegation()

ParamsTypeDescription

asset

address

address of the underlying asset

amount

uint256

amount to be borrowed, expressed in wei units

interestRateMode

uint256

the type of borrow debt. Stable: 1, Variable: 2

referralCode

uint16

referral code for our referral program. Use 0 for no referral code.

onBehalfOh

address

address of user who will incur the debt. Use msg.sender when not calling on behalf of a different user.

repay()

Repays onBehalfOf's debtamount of asset which has a rateMode.

OnBehalfOf must be whitelisted for BORROWER role.

permissionAdmin that whitelisted onBehalfOf must be still valid.

ParamsTypeDescription

asset

address

address of the underlying asset

amount

uint256

amount to be borrowed, expressed in wei units. Use uint(-1) to repay the entire debt, ONLY when the repayment is not executed on behalf of a 3rd party. In case of repayments on behalf of another user, it's recommended to send an _amount slightly higher than the current borrowed amount.

rateMode

uint256

the type of borrow debt. Stable: 1, Variable: 2

onBehalfOf

address

address of user who will incur the debt. Use msg.sender when not calling on behalf of a different user.

swapBorrowRateMode()

Swaps the msg.sender's borrow rate modes between stable and variable.

msg.sender must be whitelisted for BORROWER role.

permissionAdmin that whitelisted msg.sender must be still valid.

ParamsType

asset

address

address of the underlying asset

rateMode

uint256

the rate mode the user is swapping from. Stable: 1, Variable: 2

setUserUseReserveAsCollateral()

Sets the asset of msg.sender to be used as collateral or not.

msg.sender must be whitelisted for DEPOSITOR role.

permissionAdmin that whitelisted msg.sender must be still valid.

ParamsTypeDescription

asset

address

address of the underlying asset

useAsCollateral

bool

true if the asset should be used as collateral

liquidationCall()

Allows, whitelisted liquidators to liquidate positions with health factor below 1.

msg.sender must be whitelisted for LIQUIDATOR role.

permissionAdmin that whitelisted msg.sender must be still valid.

Also, see our Liquidations guide and LendingPool liquidationCall for more details.

Error Codes

In order to reduce gas usage and code size, Aave contracts return numbered errors. If you are making calls to the protocol and receive numbered errors, you can use our error code reference guide to know what the error number means. Alternatively, you can also find what the numbers represent by checking the Errors.sol

Last updated