Skip to content

NativeTokenGateway

NativeTokenGateway contract facilitates interactions with a vToken market for native tokens (Native or wNativeToken)

Address of wrapped native token contract

contract IWrappedNative wNativeToken

Address of wrapped native token market

contract IVToken vWNativeToken

Constructor for NativeTokenGateway

constructor(contract IVToken vWrappedNativeToken) public
NameTypeDescription
vWrappedNativeTokencontract IVTokenAddress of wrapped native token market

To receive Native when msg.data is empty

receive() external payable

To receive Native when msg.data is not empty

fallback() external payable

Wrap Native, get wNativeToken, mint vWNativeToken, and supply to the market.

function wrapAndSupply(address minter) external payable
NameTypeDescription
minteraddressThe address on behalf of whom the supply is performed.
  • TokensWrappedAndSupplied is emitted when assets are supplied to the market
  • ZeroAddressNotAllowed is thrown if address of minter is zero address
  • ZeroValueNotAllowed is thrown if mintAmount is zero

Redeem vWNativeToken, unwrap to Native Token, and send to the user

function redeemUnderlyingAndUnwrap(uint256 redeemAmount) external
NameTypeDescription
redeemAmountuint256The amount of underlying tokens to redeem
  • TokensRedeemedAndUnwrapped is emitted when assets are redeemed from a market and unwrapped
  • ZeroValueNotAllowed is thrown if redeemAmount is zero

Redeem vWNativeToken, unwrap to Native Token, and send to the user

function redeemAndUnwrap(uint256 redeemTokens) external
NameTypeDescription
redeemTokensuint256The amount of vWNative tokens to redeem
  • TokensRedeemedAndUnwrapped is emitted when assets are redeemed from a market and unwrapped
  • ZeroValueNotAllowed is thrown if redeemTokens is zero

Wrap Native, repay borrow in the market, and send remaining Native to the user

function wrapAndRepay() external payable
  • TokensWrappedAndRepaid is emitted when assets are repaid to a market and unwrapped
  • ZeroValueNotAllowed is thrown if repayAmount is zero

Sweeps native assets (Native) from the contract and sends them to the owner

function sweepNative() external
  • SweepNative is emitted when assets are swept from the contract
  • Controlled by Governance

Sweeps the input token address tokens from the contract and sends them to the owner

function sweepToken(contract IERC20 token) external
NameTypeDescription
tokencontract IERC20Address of the token
  • SweepToken emits on success
  • Controlled by Governance