fTokenNativeUnderlyingOverrides

overrides certain methods from the inherited fToken used as base contract to make them compatible with the native token being used as underlying.

NATIVE_TOKEN_ADDRESS

address NATIVE_TOKEN_ADDRESS

address that is mapped to the chain native token at Liquidity

_getLiquiditySlotLinksAsset

function _getLiquiditySlotLinksAsset() internal view virtual returns (address)

gets asset address for liquidity slot links, overridden to set native token address

_getLiquidityUnderlyingBalance

function _getLiquidityUnderlyingBalance() internal view virtual returns (uint256)

Gets current Liquidity underlying token balance

rescueFunds

function rescueFunds(address token_) external virtual

sends any potentially stuck funds to Liquidity contract. Only callable by LendingFactory auths.

rebalance

function rebalance() external payable virtual returns (uint256 assets_)

Balances out the difference between fToken supply at Liquidity vs totalAssets(). Deposits underlying from rebalancer address into Liquidity but doesn't mint any shares -> thus making deposit available as rewards. Only callable by rebalancer.

Return Values

NameTypeDescription
assets_uint256amount deposited to Liquidity

_depositToLiquidity

function _depositToLiquidity(uint256 assets_, bytes liquidityCallbackData_) internal virtual returns (uint256 exchangePrice_)

_Deposit assets_ amount of tokens to Liquidity_

Parameters

NameTypeDescription
assets_uint256The amount of tokens to deposit
liquidityCallbackData_bytescallback data passed to Liquidity for liquidityCallback

Return Values

NameTypeDescription
exchangePrice_uint256liquidity exchange price for token

_executeDeposit

function _executeDeposit(uint256 assets_, address receiver_, bytes liquidityCallbackData_) internal virtual returns (uint256 sharesMinted_)

_deposits assets_into liquidity and mints shares forreceiver*. Returns amount of sharesMinted*._

_executeDepositNative

function _executeDepositNative(address receiver_) internal virtual returns (uint256 sharesMinted_)

_deposits msg.value amount of native token into liquidity and mints shares for receiver_. Returns amount of sharesMinted*.*

_withdrawFromLiquidity

function _withdrawFromLiquidity(uint256 assets_, address receiver_) internal virtual returns (uint256 exchangePrice_)

_Withdraw assets_amount of tokens from Liquidity directly toreceiver**

Parameters

NameTypeDescription
assets_uint256The amount of tokens to withdraw
receiver_addressthe receiver address of withdraw amount

Return Values

NameTypeDescription
exchangePrice_uint256liquidity exchange price for token

_executeWithdraw

function _executeWithdraw(uint256 assets_, address receiver_, address owner_) internal virtual returns (uint256 sharesBurned_)

_withdraws assets_from liquidity toreceiver*and burns shares fromowner*. Returns amount of sharesBurned*. requires nonReentrant! modifier on calling method otherwise ERC777s could reenter!*

_executeWithdrawNative

function _executeWithdrawNative(uint256 assets_, address receiver_, address owner_) internal virtual returns (uint256 sharesBurned_)

_withdraws assets_from liquidity toreceiver*and burns shares fromowner*. Returns amount of sharesBurned*.*

fTokenNativeUnderlyingActions

implements deposit / mint / withdraw / redeem actions with Native token being used as interaction token.

depositNative

function depositNative(address receiver_) public payable returns (uint256 shares_)

deposits msg.value amount of native token for receiver_. msg.value must be at least minDeposit() amount; reverts otherwise. Recommended to use depositNative() with a minAmountOut_ param instead to set acceptable limit.

Return Values

NameTypeDescription
shares_uint256actually minted shares

depositNative

function depositNative(address receiver_, uint256 minAmountOut_) external payable returns (uint256 shares_)

same as {depositNative} but with an additional setting for minimum output amount. reverts with fToken__MinAmountOut() if minAmountOut_ of shares is not reached

mintNative

function mintNative(uint256 shares_, address receiver_) public payable returns (uint256 assets_)

mints shares_ for receiver_, paying with underlying native token. shares_ must at least be minMint() amount; reverts otherwise. shares_ set to type(uint256).max not supported. Note there might be tiny inaccuracies between requested shares_ and actually received shares amount. Recommended to use depositNative() over mint because it is more gas efficient and less likely to revert. Recommended to use mintNative() with a minAmountOut_ param instead to set acceptable limit.

Return Values

NameTypeDescription
assets_uint256deposited assets amount

mintNative

function mintNative(uint256 shares_, address receiver_, uint256 maxAssets_) external payable returns (uint256 assets_)

same as {mintNative} but with an additional setting for minimum output amount. reverts with fToken__MaxAmount() if maxAssets_ of assets is surpassed to mint shares_.

withdrawNative

function withdrawNative(uint256 assets_, address receiver_, address owner_) public returns (uint256 shares_)

withdraws assets_ amount in native underlying to receiver_, burning shares of owner_. If assets_ equals uint256.max then the whole fToken balance of owner_ is withdrawn.This does not consider withdrawal limit at liquidity so best to check with maxWithdraw() before. Note there might be tiny inaccuracies between requested assets_ and actually received assets amount. Recommended to use withdrawNative() with a maxSharesBurn_ param instead to set acceptable limit.

Return Values

NameTypeDescription
shares_uint256burned shares

withdrawNative

function withdrawNative(uint256 assets_, address receiver_, address owner_, uint256 maxSharesBurn_) external returns (uint256 shares_)

same as {withdrawNative} but with an additional setting for minimum output amount. reverts with fToken__MaxAmount() if maxSharesBurn_ of shares burned is surpassed.

redeemNative

function redeemNative(uint256 shares_, address receiver_, address owner_) public returns (uint256 assets_)

redeems shares_ to native underlying to receiver_, burning shares of owner_. If shares_ equals uint256.max then the whole balance of owner_ is withdrawn.This does not consider withdrawal limit at liquidity so best to check with maxRedeem() before. Recommended to use withdrawNative() over redeem because it is more gas efficient and can set specific amount. Recommended to use redeemNative() with a minAmountOut_ param instead to set acceptable limit.

Return Values

NameTypeDescription
assets_uint256withdrawn assets amount

redeemNative

function redeemNative(uint256 shares_, address receiver_, address owner_, uint256 minAmountOut_) external returns (uint256 assets_)

same as {redeemNative} but with an additional setting for minimum output amount. reverts with fToken__MinAmountOut() if minAmountOut_ of assets is not reached.

fTokenNativeUnderlyingEIP2612Withdrawals

fTokens support EIP-2612 permit approvals via signature so withdrawals are possible with signature. This contract implements those withdrawals for a native underlying asset.

withdrawWithSignatureNative

function withdrawWithSignatureNative(uint256 sharesToPermit_, uint256 assets_, address receiver_, address owner_, uint256 maxSharesBurn_, uint256 deadline_, bytes signature_) external returns (uint256 shares_)

withdraw amount of assets_ in native token with ERC-2612 permit signature for fToken approval. owner_ signs ERC-2612 permit signature_ to give allowance of fTokens to msg.sender. Note there might be tiny inaccuracies between requested assets_ and actually received assets amount. allowance via signature should cover previewWithdraw(assets_) plus a little buffer to avoid revert. Inherent trust assumption that msg.sender will set receiver_ and minAmountOut_ as owner_ intends (which is always the case when giving allowance to some spender).

Parameters

NameTypeDescription
sharesToPermit_uint256shares amount to use for EIP2612 permit(). Should cover previewWithdraw(assets_) + small buffer.
assets_uint256amount of assets to withdraw
receiver_addressreceiver of withdrawn assets
owner_addressowner to withdraw from (must be signature signer)
maxSharesBurn_uint256maximum accepted amount of shares burned
deadline_uint256deadline for signature validity
signature_bytespacked signature of signing the EIP712 hash for ERC-2612 permit

Return Values

NameTypeDescription
shares_uint256burned shares amount

redeemWithSignatureNative

function redeemWithSignatureNative(uint256 shares_, address receiver_, address owner_, uint256 minAmountOut_, uint256 deadline_, bytes signature_) external returns (uint256 assets_)

redeem amount of shares_ as native token with ERC-2612 permit signature for fToken approval. owner_ signs ERC-2612 permit signature_ to give allowance of fTokens to msg.sender. Note there might be tiny inaccuracies between requested shares_ to redeem and actually burned shares. allowance via signature must cover shares_ plus a tiny buffer. Inherent trust assumption that msg.sender will set receiver_ and minAmountOut_ as owner_ intends (which is always the case when giving allowance to some spender). Recommended to use withdrawNative() over redeem because it is more gas efficient and can set specific amount.

Parameters

NameTypeDescription
shares_uint256amount of shares to redeem
receiver_addressreceiver of withdrawn assets
owner_addressowner to withdraw from (must be signature signer)
minAmountOut_uint256minimum accepted amount of assets withdrawn
deadline_uint256deadline for signature validity
signature_bytespacked signature of signing the EIP712 hash for ERC-2612 permit

Return Values

NameTypeDescription
assets_uint256withdrawn assets amount

fTokenNativeUnderlying

Same as the {fToken} contract but with support for native token as underlying asset. Actual underlying asset is the wrapped native ERC20 version (e.g. WETH), which acts like any other fToken. But in addition the fTokenNativeUnderlying also has methods for doing all the same actions via the native token.

constructor

constructor(contract IFluidLiquidity liquidity_, contract IFluidLendingFactory lendingFactory_, contract IWETH9 weth_) public

Parameters

NameTypeDescription
liquidity_contract IFluidLiquidityliquidity contract address
lendingFactory_contract IFluidLendingFactorylending factory contract address
weth_contract IWETH9address of wrapped native token (e.g. WETH)

liquidityCallback

function liquidityCallback(address, uint256, bytes) external virtual

transfers amount_ of token_ to liquidity. Only callable by liquidity contract.

this callback is used to optimize gas consumption (reducing necessary token transfers).

receive

receive() external payable