IFTokenAdmin
updateRewards
function updateRewards(contract IFluidLendingRewardsRateModel rewardsRateModel_) external
updates the rewards rate model contract. Only callable by LendingFactory auths.
Parameters
Name | Type | Description |
---|---|---|
rewardsRateModel_ | contract IFluidLendingRewardsRateModel | the new rewards rate model contract address. can be set to address(0) to set no rewards (to save gas) |
rebalance
function rebalance() external payable 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
Name | Type | Description |
---|---|---|
assets_ | uint256 | amount deposited to Liquidity |
updateRates
function updateRates() external returns (uint256 tokenExchangePrice_, uint256 liquidityExchangePrice_)
gets the liquidity exchange price of the underlying asset, calculates the updated exchange price (with reward rates) and writes those values to storage. Callable by anyone.
Return Values
Name | Type | Description |
---|---|---|
tokenExchangePrice_ | uint256 | exchange price of fToken share to underlying asset |
liquidityExchangePrice_ | uint256 | exchange price at Liquidity for the underlying asset |
rescueFunds
function rescueFunds(address token_) external
sends any potentially stuck funds to Liquidity contract. Only callable by LendingFactory auths.
updateRebalancer
function updateRebalancer(address rebalancer_) external
Updates the rebalancer address (ReserveContract). Only callable by LendingFactory auths.
IFToken
minDeposit
function minDeposit() external view returns (uint256)
returns minimum amount required for deposit (rounded up)
getData
function getData() external view returns (contract IFluidLiquidity liquidity_, contract IFluidLendingFactory lendingFactory_, contract IFluidLendingRewardsRateModel lendingRewardsRateModel_, contract IAllowanceTransfer permit2_, address rebalancer_, bool rewardsActive_, uint256 liquidityBalance_, uint256 liquidityExchangePrice_, uint256 tokenExchangePrice_)
returns config, rewards and exchange prices data in a single view method.
Return Values
Name | Type | Description |
---|---|---|
liquidity_ | contract IFluidLiquidity | address of the Liquidity contract. |
lendingFactory_ | contract IFluidLendingFactory | address of the Lending factory contract. |
lendingRewardsRateModel_ | contract IFluidLendingRewardsRateModel | address of the rewards rate model contract. changeable by LendingFactory auths. |
permit2_ | contract IAllowanceTransfer | address of the Permit2 contract used for deposits / mint with signature |
rebalancer_ | address | address of the rebalancer allowed to execute rebalance() |
rewardsActive_ | bool | true if rewards are currently active |
liquidityBalance_ | uint256 | current Liquidity supply balance of address(this) for the underyling asset |
liquidityExchangePrice_ | uint256 | (updated) exchange price for the underlying assset in the liquidity protocol (without rewards) |
tokenExchangePrice_ | uint256 | (updated) exchange price between fToken and the underlying assset (with rewards) |
liquidityCallback
function liquidityCallback(address token_, uint256 amount_, bytes data_) external
transfers amount_
of token_
to liquidity. Only callable by liquidity contract.
this callback is used to optimize gas consumption (reducing necessary token transfers).
depositWithSignature
function depositWithSignature(uint256 assets_, address receiver_, uint256 minAmountOut_, struct IAllowanceTransfer.PermitSingle permit_, bytes signature_) external returns (uint256 shares_)
deposit assets_
amount with Permit2 signature for underlying asset approval.
reverts with fToken__MinAmountOut()
if minAmountOut_
of shares is not reached.
assets_
must at least be minDeposit()
amount; reverts otherwise.
Parameters
Name | Type | Description |
---|---|---|
assets_ | uint256 | amount of assets to deposit |
receiver_ | address | receiver of minted fToken shares |
minAmountOut_ | uint256 | minimum accepted amount of shares minted |
permit_ | struct IAllowanceTransfer.PermitSingle | Permit2 permit message |
signature_ | bytes | packed signature of signing the EIP712 hash of permit_ |
Return Values
Name | Type | Description |
---|---|---|
shares_ | uint256 | amount of minted shares |
mintWithSignature
function mintWithSignature(uint256 shares_, address receiver_, uint256 maxAssets_, struct IAllowanceTransfer.PermitSingle permit_, bytes signature_) external returns (uint256 assets_)
mint amount of shares_
with Permit2 signature for underlying asset approval.
Signature should approve a little bit more than expected assets amount (previewMint()
) to avoid reverts.
shares_
must at least be minMint()
amount; reverts otherwise.
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.
Parameters
Name | Type | Description |
---|---|---|
shares_ | uint256 | amount of shares to mint |
receiver_ | address | receiver of minted fToken shares |
maxAssets_ | uint256 | maximum accepted amount of assets used as input to mint shares_ |
permit_ | struct IAllowanceTransfer.PermitSingle | Permit2 permit message |
signature_ | bytes | packed signature of signing the EIP712 hash of permit_ |
Return Values
Name | Type | Description |
---|---|---|
assets_ | uint256 | deposited assets amount |
IFTokenNativeUnderlying
NATIVE_TOKEN_ADDRESS
function NATIVE_TOKEN_ADDRESS() external view returns (address)
address that is mapped to the chain native token at Liquidity
depositNative
function depositNative(address receiver_) external 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
Name | Type | Description |
---|---|---|
shares_ | uint256 | actually 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_) external 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
Name | Type | Description |
---|---|---|
assets_ | uint256 | deposited 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_) external 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
Name | Type | Description |
---|---|---|
shares_ | uint256 | burned 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_) external 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
Name | Type | Description |
---|---|---|
assets_ | uint256 | withdrawn 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.
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
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 |
Return Values
Name | Type | Description |
---|---|---|
shares_ | uint256 | burned 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
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 |
Return Values
Name | Type | Description |
---|---|---|
assets_ | uint256 | withdrawn assets amount |