WETHGateway
Last updated
Last updated
The WETH Gateway contract is a helper to easily wrap and unwrap ETH (or native currency of chain eg. MATIC, AVAX etc) as necessary when interacting with the protocol.
function depositETH(address pool, address onBehalfOf, uint16 referralCode)
Supplies the msg.value
amount of ETH (or native chain token) into the Themis pool, minting the same amount of corresponding tWETH and transferring them to the onBehalfOf
address.
Ensure that the depositETH()
transaction also includes the amount of ETH you are supplying in the msg.value
.
Name | Type | Description |
---|---|---|
function withdrawETH(address pool, uint256 amount, address to)
Withdraws amount
of the WETH (or wrapped native chain token), unwraps it and transfers ETH (or native chain token) to the to address.
💡 Ensure you set the relevant aToken
allowance, before calling this function, so the WETHGateway
contract can transfer the associated aWETH.
function repayETH(address pool, uint256 amount, uint256 rateMode, address onBehalfOf)
Repays onBehalfOf
's debt amount of ETH () which has a rateMode
.
Ensure that the repayETH() transaction also includes the amount of ETH you are repaying in the msg.value .
function borrowETH(address pool, uint256 amount, uint256 interestRateMode, uint16 referralCode)
Borrows amount
of WETH with interestRateMode , sending the amount of unwrapped WETH to msg.sender .
function withdrawETHWithPermit(address pool, uint256 amount, address to, uint256 deadline, uint8 permitV, bytes32 permitR, bytes32 permitS)
Withdraws amount
of the WETH (or wrapped native chain token) without a separate approval tx. The ETH (or native chain token) is sent to the to address.
function emergencyTokenTransfer(address Token, address to, uint256 amount)
Method for ERC20 recovery in case of stuck tokens due direct transfers to the contract address.
Can be called only by the owner of the contract i.e. Themis Governance
function emergencyEtherTransfer(address to, uint256 amount)
Method for ETH (or native chain token) recovery in case of stuck ETH due selfdestruct or transfer ether to pre-computated contract address before deployment.
Can be called only by the owner of the contract i.e. Governance.
function getWETHAddress()
Returns the WETH address used by the WETHGateway.
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
pool
address
address of the targeted pool
onBehalfOf
address
address who will receive the aWETH. Use msg.sender when the tTokens should be sent to the caller.
referralCode
uint16
unique code for 3rd party referral program integration. 0 for no referra
pool
address
address of the targeted 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
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.
pool
address
address of the targeted pool
amount
uint256
amount to be borrowed, expressed in wei units
interestRateMode
uint256
the type of borrow debt. Stable: 1, Variable: 2
referralCode
uint16
unique code for 3rd party referral program integration. 0 for no referral code.
pool
address
address of the targeted pool
amount
uint256
amount of tWETH (or aToken corresponding to native token of chain) that will be burnt to withdraw ETH (or native chain token)
to
address
address that will receive the ETH (or native chain token)
deadline
uint256
unix timestamp till which the signature is valid
permitV
uint8
Signature parameter v
permitR
bytes32
Signature parameter r
permitS
bytes32
Signature parameter s