fTokenNativeUnderlyingEIP2612Withdrawals

Git Source

Inherits:fTokenNativeUnderlyingActions

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

Functions

withdrawWithSignatureNative

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).

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

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

Returns

NameTypeDescription
shares_uint256burned shares amount

redeemWithSignatureNative

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.

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

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

Returns

NameTypeDescription
assets_uint256withdrawn assets amount