FluidLendingResolver ​
Inherits:IFluidLendingResolver, Structs
Fluid Lending protocol (fTokens) resolver Implements various view-only methods to give easy access to Lending protocol data.
Constants ​
_NATIVE_TOKEN_ADDRESS ​
address that is mapped to the chain native token
address internal constant _NATIVE_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeEMODEL_RATE_SCALE_FACTOR ​
On-chain model rates use 1e12 = 1%; resolver APR fields use Liquidity scale (100 = 1%).
uint256 internal constant MODEL_RATE_SCALE_FACTOR = 1e10LENDING_FACTORY ​
returns the lending factory address
IFluidLendingFactory public immutable LENDING_FACTORYLIQUIDITY_RESOLVER ​
returns the liquidity resolver address
IFluidLiquidityResolver public immutable LIQUIDITY_RESOLVERFunctions ​
constructor ​
constructor sets the immutable LENDING_FACTORY and LIQUIDITY_RESOLVER address
constructor(IFluidLendingFactory lendingFactory_, IFluidLiquidityResolver liquidityResolver_) ;isLendingFactoryAuth ​
reads if a certain auth_ address is an allowed auth or not. Owner is auth by default.
function isLendingFactoryAuth(address auth_) external view returns (bool);isLendingFactoryDeployer ​
reads if a certain deployer_ address is an allowed deployer or not. Owner is deployer by default.
function isLendingFactoryDeployer(address deployer_) external view returns (bool);getAllFTokenTypes ​
returns all fToken types at the LENDING_FACTORY
function getAllFTokenTypes() public view returns (string[] memory);getAllFTokens ​
returns all created fTokens at the LENDING_FACTORY
function getAllFTokens() public view returns (address[] memory);computeFToken ​
computes deterministic token address for asset_ for a lending protocol
function computeFToken(address asset_, string calldata fTokenType_) external view returns (address);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() |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | token_ detemrinistic address of the computed token |
getDeploymentName ​
returns the factory deployment name when present (permissioned stack); empty string on production factories.
Permissioned-stack factories expose deploymentName(); production factories do not → empty string.
function getDeploymentName() external view returns (string memory deploymentName_);getFTokenDetails ​
gets all public details for a certain fToken_, such as fToken type, name, symbol, decimals, underlying asset, total amounts, convertTo values, and APR fields. 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.
All resolver APR fields use Liquidity scale (100 = 1%, divide by 100 for % display).
function getFTokenDetails(IFToken fToken_) public view virtual returns (FTokenDetails memory fTokenDetails_);Parameters
| Name | Type | Description |
|---|---|---|
fToken_ | IFToken | the fToken to get the details for |
Returns
| Name | Type | Description |
|---|---|---|
fTokenDetails_ | FTokenDetails | retrieved FTokenDetails struct |
getFTokenInternalData ​
returns config, rewards and exchange prices data of an fToken.
function getFTokenInternalData(IFToken fToken_)
public
view
returns (
IFluidLiquidity liquidity_,
IFluidLendingFactory lendingFactory_,
IFluidLendingRewardsRateModel lendingRewardsRateModel_,
IAllowanceTransfer permit2_,
address rebalancer_,
bool rewardsActive_,
uint256 liquidityBalance_,
uint256 liquidityExchangePrice_,
uint256 tokenExchangePrice_
);Parameters
| Name | Type | Description |
|---|---|---|
fToken_ | IFToken | the fToken to get the data for |
Returns
| Name | Type | Description |
|---|---|---|
liquidity_ | IFluidLiquidity | address of the Liquidity contract. |
lendingFactory_ | IFluidLendingFactory | address of the Lending factory contract. |
lendingRewardsRateModel_ | IFluidLendingRewardsRateModel | address of the rewards rate model contract. changeable by LendingFactory auths. |
permit2_ | 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 ​
gets all public details for all itokens, such as fToken type, name, symbol, decimals, underlying asset, total amounts, convertTo values, rewards
function getFTokensEntireData() public view returns (FTokenDetails[] memory);getUserPositions ​
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
function getUserPositions(address user_) external view returns (FTokenDetailsUserPosition[] memory);getFTokenRewards ​
All APR fields use Liquidity resolver scale (100 = 1%). Streaming totalRate_ is liquidityRate_ + relativeModelRate_ (additive per fToken exchange-price math, not multiplicative). Static staticModelRate_ is the signed Liquidity offset; totalRate_ = max(0, liquidityRate_ + staticModelRate_). rewardsActive_ is true while the wired program is currently accruing (false after stop/natural end even if the model remains wired — e.g. isStaticRate_ may still be true).
function getFTokenRewards(IFToken fToken_)
public
view
virtual
returns (
IFluidLendingRewardsRateModel rewardsRateModel_,
uint256 relativeModelRate_,
int256 staticModelRate_,
bool isStaticRate_,
uint256 liquidityRate_,
uint256 totalRate_,
bool rewardsActive_
);getFTokenRewardsRateModelConfig ​
gets rewards rate model config constants.
Tuple shape is shared for streaming and static models. All fields are raw on-chain values (1e12 = 1% for rate fields), unlike APR fields on getFTokenDetails (100 = 1%). maxRateOrStaticRate_: streaming = model max-rate ceiling (>= 0); static = signed Liquidity offset from getStaticConfig().staticRate (may be negative). Static |offset| ceiling remains getStaticConfig().maxRate. Static: startTvl_ and rewardAmount_ are 0.
function getFTokenRewardsRateModelConfig(IFToken fToken_)
public
view
returns (
uint256 duration_,
uint256 startTime_,
uint256 endTime_,
uint256 startTvl_,
int256 maxRateOrStaticRate_,
uint256 rewardAmount_,
address configurator_
);_streamingRateModelConfig ​
Maps streaming getConfig() into the signed config tuple (maxRate is always >= 0).
function _streamingRateModelConfig(IFluidLendingRewardsRateModel model_)
private
view
returns (
uint256 duration_,
uint256 startTime_,
uint256 endTime_,
uint256 startTvl_,
int256 maxRateOrStaticRate_,
uint256 rewardAmount_,
address configurator_
);getUserPosition ​
gets a user_ position for an fToken_.
function getUserPosition(IFToken fToken_, address user_) public view returns (UserPosition memory userPosition);Returns
| Name | Type | Description |
|---|---|---|
userPosition | UserPosition | user position struct |
getPreviews ​
gets fToken_ preview amounts for assets_ or shares_.
function getPreviews(IFToken fToken_, uint256 assets_, uint256 shares_)
public
view
returns (uint256 previewDeposit_, uint256 previewMint_, uint256 previewWithdraw_, uint256 previewRedeem_);Returns
| 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_ |
_isNativeUnderlyingFToken ​
function _isNativeUnderlyingFToken(IFToken fToken_) internal view returns (bool isNativeUnderlying_);_supportsEIP2612Deposits ​
a permit-capable underlying is not sufficient: the fToken must also be able to consume a signature. Beacon-proxy fTokens (permissioned stack) revert the whole ERC20Permit surface with DisabledSelector and expose no *WithSignature* entrypoint, so nonces reverting rules them out.
function _supportsEIP2612Deposits(IFToken fToken_, address underlying_)
internal
view
returns (bool supportsEIP2612Deposits_);_buildFTokenDetails ​
function _buildFTokenDetails(
IFToken fToken_,
address underlying_,
bool isNativeUnderlying_,
bool supportsEIP2612Deposits_,
int256 rawModelRate_,
bool isStaticRate_,
bool rewardsActive_
) internal view returns (FTokenDetails memory fTokenDetails_);_getAccessType ​
function _getAccessType(address target_) internal view returns (uint8 accessType_);_getFTokenRewardsData ​
function _getFTokenRewardsData(IFToken fToken_)
internal
view
returns (
IFluidLendingRewardsRateModel rewardsRateModel_,
int256 rawModelRate_,
bool isStaticRate_,
bool rewardsActive_
);_scaleModelRate ​
Converts on-chain model APR (1e12 = 1%) to resolver APR scale (100 = 1%, same as Liquidity supplyRate).
function _scaleModelRate(int256 modelRate_) internal pure returns (int256);_computeHolderRates ​
All returned APR fields use Liquidity resolver scale (100 = 1%, divide by 100 for % display). Streaming / static are both additive on Liquidity yield in the fToken share price. staticModelRate_ is the signed offset directly (not derived from totalRate_).
function _computeHolderRates(
int256 scaledModelRate_,
bool isStaticRate_,
bool rewardsActive_,
uint256 liquidityRate_
) internal pure returns (uint256 relativeModelRate_, int256 staticModelRate_, uint256 totalRate_);Errors ​
FluidLendingResolver__AddressZero ​
thrown if an input param address is zero
error FluidLendingResolver__AddressZero();