Aave V3 Wrapped Token Gateway
The Aave Protocol operates exclusively with ERC-20 reserve tokens. To accommodate network gas tokens, the Wrapped (previously called WETHGateway) is a helper contract that enables gas tokens (ETH, POL, etc.) to be wrapped or unwrapped to perform Aave Pool methods:
- Supply
- Borrow
- Repay
- Withdraw
The smart contract source code is available on GitHub.
Write Methods
The first address argument of each method is unused and kept for backward compatibility; the pool is fixed at deployment.
depositETH
function depositETH(
address,
address onBehalfOf,
uint16 referralCode
) external payable override
Wraps and supplies gas tokens to the Aave Protocol. A corresponding amount of the wrapped aTokens are minted to the on address.
Pass the gas token amount to supply in msg..
Input Parameters:
| Name | Type | Description |
|---|---|---|
| onBehalfOf | address | The address of the user who will receive the aTokens representing the supplied tokens |
| referralCode | uint16 | Inactive, can pass 0 as placeholder |
withdrawETH
function withdrawETH(
address,
uint256 amount,
address to
) external override
Withdraws amount of the supplied wrapped gas token, unwraps it and transfers to the to address. If the amount is type(uint256)., the entire balance is withdrawn.
First approve the WrappedTokenGateway to spend the user’s aWETH, for example
IERC20(a.
Input Parameters:
| Name | Type | Description |
|---|---|---|
| amount | uint256 | The amount of aWETH to withdraw and receive native ETH |
| to | address | The address of the user who will receive native ETH |
repayETH
function repayETH(
address,
uint256 amount,
address onBehalfOf
) external payable override
Repays a borrow position of on’s address for the specified amount (or for the whole amount, if amount of type(uint256). is passed).
Pass the gas token amount to repay in msg..
Input Parameters:
| Name | Type | Description |
|---|---|---|
| amount | uint256 | The amount to repay, or type(uint256). if the user wants to repay everything |
| onBehalfOf | address | The address for which msg. is repaying |
borrowETH
function borrowETH(
address,
uint256 amount,
uint16 referralCode
) external override
Borrows amount of unwrapped network gas tokens to msg..
First grant the WrappedTokenGateway credit
delegation on WETH (or the network’s
wrapped gas token), for example
IVariable.
Input Parameters:
| Name | Type | Description |
|---|---|---|
| amount | uint256 | The amount of ETH to borrow |
| referralCode | uint16 | Inactive, can pass 0 as placeholder |
withdrawETHWithPermit
function withdrawETHWithPermit(
address,
uint256 amount,
address to,
uint256 deadline,
uint8 permitV,
bytes32 permitR,
bytes32 permitS
) external override
Withdraws amount of the supplied wrapped gas token, unwraps it and transfers to the to address. If the amount is type(uint256)., the entire balance is withdrawn.
Input Parameters:
| Name | Type | Description |
|---|---|---|
| amount | uint256 | The amount of aWETH to withdraw and receive native ETH |
| to | address | The address of the user who will receive native ETH |
| deadline | uint256 | Timestamp of signature expiration |
| permitV | uint8 | V parameter of EIP-712 permit signature |
| permitR | bytes32 | R parameter of EIP-712 permit signature |
| permitS | bytes32 | S parameter of EIP-712 permit signature |
View Methods
getWETHAddress
function getWETHAddress() external view returns (address)
Get WETH address used by WrappedTokenGatewayV3.
Return Values:
| Type | Description |
|---|---|
address | The WETH address used by WrappedTokenGatewayV3 |