WETH Gateway

If you need to use native ETH (MATIC / AVAX in case of side chain market) in the protocol, it must first be wrapped into WETH (or WMATIC / WAVAX). The WETH Gateway contract is a helper contract to easily wrap and unwrap ETH (or MATIC / AVAX) as necessary when interacting with the protocol, since only ERC20 is used within protocol interactions.

Methods

depositETH()

function depositETH(uint256 reserveId, address onBehalfOf, uint16 referralCode)

Deposits the msg.value amount of ETH into the protocol, minting the same amount of corresponding fWETH, and transferring them to the onBehalfOf address.

Parameter Name
Type
Description

reserveId

uint256

id of the targeted lending pool reserve

onBehalfOf

address

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

referralCode

uint16

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

batchDepositETH()

function batchDepositETH(uint256[] calldata reserveIds, address[] calldata onBehalfOfs, uint16[] calldata referralCodes)

Deposits the msg.value amount of ETH into the protocol, minting the same amount of corresponding fWETH, and transferring them to the onBehalfOfs addresses.

Parameter Name
Type
Description

reserveIds

uint256[] calldata

ids of the targeted lending pool reserves

onBehalfOfs

address[] calldata

addresses whom will receive the fWETH. Use msg.sender when the fTokens should be sent to the caller.

referralCodes

uint16[] calldata

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

withdrawETH()

function withdrawETH(uint256 amount, uint256 reserveId, address to)

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

Parameter Name
Type
Description

amount

uint256

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

reserveId

uint256

id of the targeted lending pool reserve

to

address

address that will receive the unwrapped ETH

batchWithdrawETH()

function batchWithdrawETH(uint256[] calldata amounts, uint256[] calldata reserveIds, address[] calldata tos)

Batch withdraws amounts of the WETH, unwraps it to ETH, and transfers the ETH to the tos addresses.

Parameter Name
Type
Description

amounts

uint256[] calldata

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

reserveIds

uint256[] calldata

ids of the targeted lending pool reserves

tos

address[] calldata

addresses that will receive the unwrapped ETH

borrowETH()

function borrowETH(uint256 amount, uint256 tokenId, uint256 tokenValue, uint256 reserveId, uint256 duration, address onBehalfOf, uint16 referralCode)

Borrows amount of ETH, sending the amount of ETH to msg.sender.

Parameter Name
Type
Description

amount

uint256

amount to be borrowed, expressed in wei units

tokenId

uint256

tokenId of the NFT used as collateral

tokenValue

uint256

value of ERC1155 tokens collateralised, 0 if ERC721

reserveId

uint256

the id of the targeted reserve

duration

uint256

the duration of the loan, 0 if open-ended

onBehalfOf

address

addresses whom will receive the loan

referralCode

uint16

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

batchBorrowETH()

function batchBorrowETH(uint256[] calldata amounts, uint256[] calldata tokenIds, uint256[] calldata tokenValues, uint256[] calldata reserveIds, uint256 duration, address onBehalfOf, uint16 referralCode)

Batch borrows amounts of ETH, sending the amounts of ETH to msg.sender. Note: distinct durations are unsupported.

Parameter Name
Type
Description

amounts

uint256[] calldata

amounts to be borrowed, expressed in wei units

tokenIds

uint256[] calldata

tokenIds of the NFT(s) used as collateral

tokenValues

uint256[] calldata

values of ERC1155 tokens collateralised, 0 if ERC721

reserveIds

uint256[] calldata

the ids of the targeted reserves

duration

uint256

the duration of the loan, 0 if open-ended

onBehalfOf

address

addresses whom will receive the loan

referralCode

uint16

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

repayETH()

function repayETH(uint256 borrowId, uint256 amount)

Repays debt of a targeted borrowId an amount of ETH.

Parameter Name
Type
Description

borrowId

uint256

id of the targeted borrow

amount

uint256

amount to be repaid, expressed in wei units.

Use type(uint256).max 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.

batchRepayETH()

function batchRepayETH(uint256[] calldata borrowIds, uint256[] calldata amounts)

Batch repays debts of targeted borrowIds amounts of ETH.

Parameter Name
Type
Description

borrowIds

uint256[] calldata

ids of the targeted borrows

amounts

uint256[] calldata

amounts to be repaid, expressed in wei units.

Use type(uint256).max 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.

refinanceETH()

function refinanceETH(uint256 borrowId, uint256 amount, uint256 duration)

Refinances a targeted borrowId with more or less amount of ETH, and an updated duration.

Parameter Name
Type
Description

borrowId

uint256

id of the targeted borrow

amount

uint256

new loan amount, expressed in wei units.

duration

uint256

new loan duration, from time of refinancing

batchRefinanceETH()

function batchRefinanceETH(uint256[] calldata borrowIds, uint256[] calldata amounts, uint256[] calldata durations)

Batch refinances targeted borrowIds with more or less amounts of ETH, and updated durations.

Parameter Name
Type
Description

borrowIds

uint256[] calldata

ids of the targeted borrows

amounts

uint256[] calldata

new loan amounts, expressed in wei units.

durations

uint256[] calldata

new loan durations, from time of refinancing

bidETH()

function bidETH(address asset, uint256 amount, uint256 borrowId, address onBehalfOf)

Purchases the underlying collateral of a defaulted loan in auction.

Parameter Name
Type
Description

asset

address

address of the payment currency

amount

uint256

bid / purchase amount

borrowId

uint256

id of the targeted borrow

onBehalfOf

address

address to receive the underlying collateral

batchBidETH()

function batchBidETH(address[] calldata assets, uint256[] calldata amounts, uint256[] calldata borrowIds, address[] calldata onBehalfOfs)

Batch purchases the underlying collaterals of a defaulted loans in auction.

Parameter Name
Type
Description

assets

address[] calldata

addresses of the payment currencies

amounts

uint256[] calldata

bid / purchase amounts

borrowIds

uint256[] calldata

ids of the targeted borrows

onBehalfOfs

address[] calldata

addresses to receive the underlying collateral

View Methods

getWETHAddress()

function getWETHAddress()

Returns the WETH address used by the WETHGateway.

ABI

WETH Gateway ABI

Last updated