fTokenActions

Git Source

Inherits:fTokenCore, fTokenViews

fToken public executable actions: deposit, mint, mithdraw and redeem. All actions are optionally also available with an additional param to limit the maximum slippage, e.g. maximum assets used for minting x amount of shares.

Functions

_revertIfBelowMinAmountOut

reverts if amount_ is < minAmountOut_. Used to reduce bytecode size.

function _revertIfBelowMinAmountOut(uint256 amount_, uint256 minAmountOut_) internal pure;

_revertIfAboveMaxAmount

reverts if amount_ is > maxAmount_. Used to reduce bytecode size.

function _revertIfAboveMaxAmount(uint256 amount_, uint256 maxAmount_) internal pure;

deposit

If assets_ equals uint256.max then the whole balance of msg.sender is deposited. assets_ must at least be minDeposit() amount; reverts fToken__DepositInsignificant() if not. Recommended to use deposit() with a minAmountOut_ param instead to set acceptable limit.

function deposit(uint256 assets_, address receiver_) public virtual override nonReentrant returns (uint256 shares_);

Returns

NameTypeDescription
shares_uint256actually minted shares

deposit

same as fToken-deposit but with an additional setting for minimum output amount. reverts with fToken__MinAmountOut() if minAmountOut_ of shares is not reached

function deposit(uint256 assets_, address receiver_, uint256 minAmountOut_) external returns (uint256 shares_);

mint

If shares_ equals uint256.max then the whole balance of msg.sender is deposited. shares_ must at least be minMint() amount; reverts fToken__DepositInsignificant() if not. Note there might be tiny inaccuracies between requested shares_ and actually received shares amount. Recommended to use deposit() over mint because it is more gas efficient and less likely to revert. Recommended to use mint() with a minAmountOut_ param instead to set acceptable limit.

function mint(uint256 shares_, address receiver_) public virtual override nonReentrant returns (uint256 assets_);

Returns

NameTypeDescription
assets_uint256deposited assets amount

mint

same as fToken-mint but with an additional setting for maximum assets input amount. reverts with fToken__MaxAmount() if maxAssets_ of assets is surpassed to mint shares_.

function mint(uint256 shares_, address receiver_, uint256 maxAssets_) external returns (uint256 assets_);

withdraw

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 withdraw() with a minAmountOut_ param instead to set acceptable limit.

function withdraw(uint256 assets_, address receiver_, address owner_)
    public
    virtual
    override
    nonReentrant
    returns (uint256 shares_);

Returns

NameTypeDescription
shares_uint256burned shares

withdraw

same as fToken-withdraw but with an additional setting for maximum shares burned. reverts with fToken__MaxAmount() if maxSharesBurn_ of shares burned is surpassed.

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

redeem

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 withdraw() over redeem because it is more gas efficient and can set specific amount. Recommended to use redeem() with a minAmountOut_ param instead to set acceptable limit.

function redeem(uint256 shares_, address receiver_, address owner_)
    public
    virtual
    override
    nonReentrant
    returns (uint256 assets_);

Returns

NameTypeDescription
assets_uint256withdrawn assets amount

redeem

same as fToken-redeem but with an additional setting for minimum output amount. reverts with fToken__MinAmountOut() if minAmountOut_ of assets is not reached.

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