PermissionedWETHGateway

PermissionedWETHGateway

The WETH Gateway contract is a helper contract, which wraps and unwraps ETH ( or any native cryptoasset of a network, e.g. MATIC for Polygon, AVAX for Avalanche) as necessary when interacting with the protocol.

The source code can be found on Github here.

Write Methods


depositETH()

Allows whitelisted depositors to deposit msg.value amount of ETH (or native crypto asset) into the protocol, minting the same amount of corresponding aWETH, and transferring them to the onBehalfOf address.

OnBehalfOf must be whitelisted for DEPOSITOR role.

permissionAdmin that whitelisted 👆🏻 must be still valid.

Call params

Params
Type
Description

lendingPool

address

address of the targeted underlying lending pool

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.

withdrawETH()

Withdraws amount of the WETH, unwraps it to ETH, and transfers the ETH to theto address.

Ensure you set the relevant aToken allowance, before calling this function, so the PermissionedWETHGateway contract can burn the associated aWETH.

Call params

Params
Type
Description

lendingPool

address

address of the targeted underlying lending pool

amount

uint256

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

to

address

address that will receive the unwrapped ETH

repayETH()

Repays onBehalfOf's debt amount of ETH which has a rateMode.

OnBehalfOf must be whitelisted for BORROWER role.

permissionAdmin that whitelisted 👆🏻 must be still valid.

Call params

Params
Type
Description

lendingPool

address

address of the targeted underlying lending pool

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.


borrowETH()

Allows whitelisted borrowers to borrow amount of ETH with interestRateMode.

The amount of ETH is sent to msg.sender.

msg.sender must be whitelisted for BORROWER role.

permissionAdmin that whitelisted 👆🏻 must be still valid.

Call params

Params
Type
Description

lendingPool

address

address of the targeted underlying lending pool

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 3rd party referral program integration. Use 0 for no referral.

Last updated