FluidLendingResolver
Fluid Lending protocol (fTokens) resolver Implements various view-only methods to give easy access to Lending protocol data.
_NATIVE_TOKEN_ADDRESS
address _NATIVE_TOKEN_ADDRESS
address that is mapped to the chain native token
LENDING_FACTORY
contract IFluidLendingFactory LENDING_FACTORY
returns the lending factory address
LIQUIDITY_RESOLVER
contract IFluidLiquidityResolver LIQUIDITY_RESOLVER
returns the liquidity resolver address
FluidLendingResolver__AddressZero
error FluidLendingResolver__AddressZero()
thrown if an input param address is zero
constructor
constructor(contract IFluidLendingFactory lendingFactory_, contract IFluidLiquidityResolver liquidityResolver_) public
constructor sets the immutable LENDING_FACTORY
and LIQUIDITY_RESOLVER
address
isLendingFactoryAuth
function isLendingFactoryAuth(address auth_) external view returns (bool)
reads if a certain auth_
address is an allowed auth or not. Owner is auth by default.
isLendingFactoryDeployer
function isLendingFactoryDeployer(address deployer_) external view returns (bool)
reads if a certain deployer_
address is an allowed deployer or not. Owner is deployer by default.
getAllFTokenTypes
function getAllFTokenTypes() public view returns (string[])
returns all fToken types at the LENDING_FACTORY
getAllFTokens
function getAllFTokens() public view returns (address[])
returns all created fTokens at the LENDING_FACTORY
computeFToken
function computeFToken(address asset_, string fTokenType_) external view returns (address)
computes deterministic token address for asset_
for a lending protocol
Parameters
Name | Type | Description |
---|---|---|
asset_ | address | address of the asset |
fTokenType_ | string | type of fToken: - if underlying asset supports EIP-2612, the fToken should be type EIP2612Deposits - otherwise it should use Permit2Deposits - if it's the native token, it should use NativeUnderlying - could be more types available, check fTokenTypes() |
Return Values
Name | Type | Description |
---|---|---|
0 | address | token_ detemrinistic address of the computed token |
getFTokenDetails
function getFTokenDetails(contract IFToken fToken_) public view returns (struct Structs.FTokenDetails fTokenDetails_)
gets all public details for a certain fToken_
, such as
fToken type, name, symbol, decimals, underlying asset, total amounts, convertTo values, rewards.
Note it also returns whether the fToken supports deposits / mints via EIP-2612, but it is not a 100% guarantee!
To make sure, check for the underlying if it supports EIP-2612 manually.
Parameters
Name | Type | Description |
---|---|---|
fToken_ | contract IFToken | the fToken to get the details for |
Return Values
Name | Type | Description |
---|---|---|
fTokenDetails_ | struct Structs.FTokenDetails | retrieved FTokenDetails struct |
getFTokenInternalData
function getFTokenInternalData(contract IFToken fToken_) public 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 of an fToken.
Parameters
Name | Type | Description |
---|---|---|
fToken_ | contract IFToken | the fToken to get the data for |
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) |
getFTokensEntireData
function getFTokensEntireData() public view returns (struct Structs.FTokenDetails[])
gets all public details for all itokens, such as fToken type, name, symbol, decimals, underlying asset, total amounts, convertTo values, rewards
getUserPositions
function getUserPositions(address user_) external view returns (struct Structs.FTokenDetailsUserPosition[])
gets all public details for all itokens, such as fToken type, name, symbol, decimals, underlying asset, total amounts, convertTo values, rewards and user position for each token
getFTokenRewards
function getFTokenRewards(contract IFToken fToken_) public view returns (contract IFluidLendingRewardsRateModel rewardsRateModel_, uint256 rewardsRate_)
gets rewards related data: the rewardsRateModel_
contract and the current rewardsRate_
for the fToken_
getFTokenRewardsRateModelConfig
function getFTokenRewardsRateModelConfig(contract IFToken fToken_) public view returns (uint256 duration_, uint256 startTime_, uint256 endTime_, uint256 startTvl_, uint256 maxRate_, uint256 rewardAmount_, address initiator_)
gets rewards rate model config constants
getUserPosition
function getUserPosition(contract IFToken fToken_, address user_) public view returns (struct Structs.UserPosition userPosition)
gets a user_
position for an fToken_
.
Return Values
Name | Type | Description |
---|---|---|
userPosition | struct Structs.UserPosition | user position struct |
getPreviews
function getPreviews(contract IFToken fToken_, uint256 assets_, uint256 shares_) public view returns (uint256 previewDeposit_, uint256 previewMint_, uint256 previewWithdraw_, uint256 previewRedeem_)
gets fToken_
preview amounts for assets_
or shares_
.
Return Values
Name | Type | Description |
---|---|---|
previewDeposit_ | uint256 | preview for deposit of assets_ |
previewMint_ | uint256 | preview for mint of shares_ |
previewWithdraw_ | uint256 | preview for withdraw of assets_ |
previewRedeem_ | uint256 | preview for redeem of shares_ |