fTokenCore
Inherits:Error, IERC4626, IFToken, Variables, Events, ReentrancyGuard
internal methods for fToken contracts
Functions
_getLiquidityExchangePrice
Gets current (updated) Liquidity supply exchange price for the underyling asset
function _getLiquidityExchangePrice() internal view returns (uint256 supplyExchangePrice_);
_getLiquidityBalance
Gets current Liquidity supply balance of address(this)
for the underyling asset
function _getLiquidityBalance() internal view returns (uint256 balance_);
_getLiquidityUnderlyingBalance
Gets current Liquidity underlying token balance
function _getLiquidityUnderlyingBalance() internal view virtual returns (uint256);
_getLiquidityWithdrawable
Gets current withdrawable amount at Liquidity withdrawalLimit_
(withdrawal limit or balance).
function _getLiquidityWithdrawable() internal view returns (uint256 withdrawalLimit_);
_calculateNewTokenExchangePrice
Calculates new token exchange price based on the current liquidity exchange price newLiquidityExchangePrice_
and rewards rate.
function _calculateNewTokenExchangePrice(uint256 newLiquidityExchangePrice_)
internal
view
returns (uint256 newTokenExchangePrice_, bool rewardsEnded_);
Parameters
Name | Type | Description |
---|---|---|
newLiquidityExchangePrice_ | uint256 | new (current) liquidity exchange price |
_updateRates
calculates new exchange prices, updates values in storage and returns new tokenExchangePrice (with reward rates)
function _updateRates(uint256 liquidityExchangePrice_, bool forceUpdateStorage_)
internal
returns (uint256 tokenExchangePrice_);
_splitSignature
splits a bytes signature sig
into v
, r
, s
.
Taken from https://docs.soliditylang.org/en/v0.8.17/solidity-by-example.html
function _splitSignature(bytes memory sig) internal pure returns (uint8 v, bytes32 r, bytes32 s);
_depositToLiquidity
Deposit assets_
amount of tokens to Liquidity
function _depositToLiquidity(uint256 assets_, bytes memory liquidityCallbackData_)
internal
virtual
returns (uint256 exchangePrice_);
Parameters
Name | Type | Description |
---|---|---|
assets_ | uint256 | The amount of tokens to deposit |
liquidityCallbackData_ | bytes | callback data passed to Liquidity for liquidityCallback |
Returns
Name | Type | Description |
---|---|---|
exchangePrice_ | uint256 | liquidity exchange price for token |
_withdrawFromLiquidity
Withdraw assets_
amount of tokens from Liquidity directly to receiver_
function _withdrawFromLiquidity(uint256 assets_, address receiver_) internal virtual returns (uint256 exchangePrice_);
Parameters
Name | Type | Description |
---|---|---|
assets_ | uint256 | The amount of tokens to withdraw |
receiver_ | address | the receiver address of withdraw amount |
Returns
Name | Type | Description |
---|---|---|
exchangePrice_ | uint256 | liquidity exchange price for token |
_executeDeposit
deposits assets_
into liquidity and mints shares for receiver_
. Returns amount of sharesMinted_
.
function _executeDeposit(uint256 assets_, address receiver_, bytes memory liquidityCallbackData_)
internal
virtual
validAddress(receiver_)
returns (uint256 sharesMinted_);
_executeWithdraw
withdraws assets_
from liquidity to receiver_
and burns shares from owner_
.
Returns amount of sharesBurned_
.
requires nonReentrant! modifier on calling method otherwise ERC777s could reenter!
function _executeWithdraw(uint256 assets_, address receiver_, address owner_)
internal
virtual
validAddress(receiver_)
returns (uint256 sharesBurned_);