WETHGateway

WETH

contract IWETH WETH

weth

address weth

pool

address pool

constructor

constructor(address _weth, address _pool) public

Sets the WETH address and the PoolAddressesProvider address. Infinite approves pool.

Parameters

Name
Type
Description

_weth

address

Address of the Wrapped Ether contract

_pool

address

Address of the proxy pool of this contract

initialize

function initialize() external

depositETH

function depositETH(address onBehalfOf, uint16 referralCode) external payable

deposits WETH into the reserve, using native ETH. A corresponding amount of the overlying asset (xTokens) is minted.

Parameters

Name
Type
Description

onBehalfOf

address

address of the user who will receive the xTokens representing the deposit

referralCode

uint16

integrators are assigned a referral code and can potentially receive rewards.

withdrawETH

function withdrawETH(uint256 amount, address to) external

_withdraws the WETH reserves of msg.sender.

Parameters

Name
Type
Description

amount

uint256

amount of pWETH to withdraw and receive native ETH

to

address

address of the user who will receive native ETH

repayETH

function repayETH(uint256 amount, address onBehalfOf) external payable

repays a borrow on the WETH reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified).

Parameters

Name
Type
Description

amount

uint256

the amount to repay, or uint256(-1) if the user wants to repay everything

onBehalfOf

address

the address for which msg.sender is repaying

borrowETH

function borrowETH(uint256 amount, uint16 referralCode) external

borrow WETH, unwraps to ETH and send both the ETH and DebtTokens to msg.sender, via approveDelegation and onBehalf argument in Pool.borrow.

Parameters

Name
Type
Description

amount

uint256

the amount of ETH to borrow

referralCode

uint16

integrators are assigned a referral code and can potentially receive rewards

withdrawETHWithPermit

function withdrawETHWithPermit(uint256 amount, address to, uint256 deadline, uint8 permitV, bytes32 permitR, bytes32 permitS) external

_withdraws the WETH reserves of msg.sender.

Parameters

Name
Type
Description

amount

uint256

amount of pWETH to withdraw and receive native ETH

to

address

address of the user who will receive native ETH

deadline

uint256

validity deadline of permit and so depositWithPermit signature

permitV

uint8

V parameter of ERC712 permit sig

permitR

bytes32

R parameter of ERC712 permit sig

permitS

bytes32

S parameter of ERC712 permit sig

_safeTransferETH

function _safeTransferETH(address to, uint256 value) internal

transfer ETH to an address, revert if it fails.

Parameters

Name
Type
Description

to

address

recipient of the transfer

value

uint256

the amount to send

emergencyTokenTransfer

function emergencyTokenTransfer(address token, address to, uint256 amount) external

transfer ERC20 from the utility contract, for ERC20 recovery in case of stuck tokens due direct transfers to the contract address.

Parameters

Name
Type
Description

token

address

token to transfer

to

address

recipient of the transfer

amount

uint256

amount to send

emergencyEtherTransfer

function emergencyEtherTransfer(address to, uint256 amount) external

transfer native Ether from the utility contract, for native Ether recovery in case of stuck Ether due selfdestructs or transfer ether to pre-computated contract address before deployment.

Parameters

Name
Type
Description

to

address

recipient of the transfer

amount

uint256

amount to send

getWETHAddress

function getWETHAddress() external view returns (address)

Get WETH address used by WETHGateway

receive

receive() external payable

Only WETH contract is allowed to transfer ETH here. Prevent other addresses to send Ether to this contract.

fallback

fallback() external payable

Revert fallback calls

Last updated