fTokenEIP2612Withdrawals
Inherits:fTokenActions
fTokens support EIP-2612 permit approvals via signature so this contract implements withdrawals (withdraw / redeem) with signature used for approval of the fToken shares.
Functions
_allowViaPermitEIP2612
creates sharesToPermit_
allowance for owner_
via EIP2612 deadline_
and signature_
function _allowViaPermitEIP2612(address owner_, uint256 sharesToPermit_, uint256 deadline_, bytes calldata signature_)
internal;
withdrawWithSignature
withdraw amount of assets_
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 (sharesToPermit_
) should cover previewWithdraw(assets_)
plus a little buffer to avoid revert.
Inherent trust assumption that msg.sender
will set receiver_
and maxSharesBurn_
as owner_
intends
(which is always the case when giving allowance to some spender).
function withdrawWithSignature(
uint256 sharesToPermit_,
uint256 assets_,
address receiver_,
address owner_,
uint256 maxSharesBurn_,
uint256 deadline_,
bytes calldata signature_
) external virtual nonReentrant returns (uint256 shares_);
Parameters
Name | Type | Description |
---|---|---|
sharesToPermit_ | uint256 | shares amount to use for EIP2612 permit(). Should cover previewWithdraw(assets_) + small buffer. |
assets_ | uint256 | amount of assets to withdraw |
receiver_ | address | receiver of withdrawn assets |
owner_ | address | owner to withdraw from (must be signature signer) |
maxSharesBurn_ | uint256 | maximum accepted amount of shares burned |
deadline_ | uint256 | deadline for signature validity |
signature_ | bytes | packed signature of signing the EIP712 hash for ERC-2612 permit |
Returns
Name | Type | Description |
---|---|---|
shares_ | uint256 | burned shares amount |
redeemWithSignature
redeem amount of shares_
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 withdraw()
over redeem because it is more gas efficient and can set specific amount.
function redeemWithSignature(
uint256 shares_,
address receiver_,
address owner_,
uint256 minAmountOut_,
uint256 deadline_,
bytes calldata signature_
) external virtual nonReentrant returns (uint256 assets_);
Parameters
Name | Type | Description |
---|---|---|
shares_ | uint256 | amount of shares to redeem |
receiver_ | address | receiver of withdrawn assets |
owner_ | address | owner to withdraw from (must be signature signer) |
minAmountOut_ | uint256 | minimum accepted amount of assets withdrawn |
deadline_ | uint256 | deadline for signature validity |
signature_ | bytes | packed signature of signing the EIP712 hash for ERC-2612 permit |
Returns
Name | Type | Description |
---|---|---|
assets_ | uint256 | withdrawn assets amount |