Skip to content

FluidRevenueResolver ​

Git Source

Fluid Revenue resolver

State Variables ​

LIQUIDITY ​

address of the liquidity contract

solidity
IFluidLiquidity public immutable LIQUIDITY;

_NATIVE_TOKEN_ADDRESS ​

address that is mapped to the chain native token

solidity
address internal constant _NATIVE_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

X64 ​

solidity
uint256 internal constant X64 = 0xffffffffffffffff;

DEFAULT_EXPONENT_SIZE ​

solidity
uint256 internal constant DEFAULT_EXPONENT_SIZE = 8;

DEFAULT_EXPONENT_MASK ​

solidity
uint256 internal constant DEFAULT_EXPONENT_MASK = 0xFF;

Functions ​

constructor ​

solidity
constructor(IFluidLiquidity liquidity_);

getRevenueCollector ​

address of contract that gets sent the revenue. Configurable by governance

solidity
function getRevenueCollector() public view returns (address);

getRevenue ​

gets the currently uncollected revenueAmount_ for a token_.

solidity
function getRevenue(address token_) public view returns (uint256 revenueAmount_);

getRevenues ​

gets the currently uncollected revenues for all listed tokens at Liquidity

solidity
function getRevenues() public view returns (TokenRevenue[] memory tokenRevenues_);

calcRevenue ​

gets the revenueAmount_ for a token given its' totalAmounts and exchangePricesAndConfig from stacked uint256 storage slots and the balance of the Fluid liquidity contract for the token.

exposed for advanced revenue calculations

solidity
function calcRevenue(uint256 totalAmounts_, uint256 exchangePricesAndConfig_, uint256 liquidityTokenBalance_)
    public
    view
    returns (uint256 revenueAmount_);

Parameters

NameTypeDescription
totalAmounts_uint256total amounts packed uint256 read from storage
exchangePricesAndConfig_uint256exchange prices and config packed uint256 read from storage
liquidityTokenBalance_uint256current balance of Liquidity contract (IERC20(token_).balanceOf(address(this)))

Returns

NameTypeDescription
revenueAmount_uint256collectable revenue amount

calcRevenueSimulatedTime ​

same as calcRevenue, but for a simulated block.timestamp set via simulatedTimestamp_.

solidity
function calcRevenueSimulatedTime(
    uint256 totalAmounts_,
    uint256 exchangePricesAndConfig_,
    uint256 liquidityTokenBalance_,
    uint256 simulatedTimestamp_
) public pure returns (uint256 revenueAmount_);

calcLiquidityExchangePricesSimulatedTime ​

calculates interest (exchange prices) at Liquidity for a token given its' exchangePricesAndConfig from storage for a simulated block.timestamp set via simulatedTimestamp_.

solidity
function calcLiquidityExchangePricesSimulatedTime(uint256 exchangePricesAndConfig_, uint256 simulatedTimestamp_)
    public
    pure
    returns (uint256 supplyExchangePrice_, uint256 borrowExchangePrice_);

Parameters

NameTypeDescription
exchangePricesAndConfig_uint256exchange prices and config packed uint256 read from storage
simulatedTimestamp_uint256simulated block.timestamp

Returns

NameTypeDescription
supplyExchangePrice_uint256updated supplyExchangePrice
borrowExchangePrice_uint256updated borrowExchangePrice

calcVaultExchangePricesSimulatedTime ​

Calculates new vault exchange prices based on storage data for a simulated block.timestamp set via simulatedTimestamp_.

solidity
function calcVaultExchangePricesSimulatedTime(
    uint256 vaultVariables2_,
    uint256 vaultRates_,
    uint256 liquiditySupplyExchangePricesAndConfig_,
    uint256 liquidityBorrowExchangePricesAndConfig_,
    uint256 simulatedTimestamp_
)
    public
    pure
    returns (
        uint256 liqSupplyExPrice_,
        uint256 liqBorrowExPrice_,
        uint256 vaultSupplyExPrice_,
        uint256 vaultBorrowExPrice_
    );

Parameters

NameTypeDescription
vaultVariables2_uint256vaultVariables2 read from storage for the vault (VaultResolver.getRateRaw)
vaultRates_uint256rates read from storage for the vault (VaultResolver.getVaultVariables2Raw)
liquiditySupplyExchangePricesAndConfig_uint256exchange prices and config packed uint256 read from storage for supply token
liquidityBorrowExchangePricesAndConfig_uint256exchange prices and config packed uint256 read from storage for borrow token
simulatedTimestamp_uint256simulated block.timestamp

Returns

NameTypeDescription
liqSupplyExPrice_uint256latest liquidity's supply token supply exchange price
liqBorrowExPrice_uint256latest liquidity's borrow token borrow exchange price
vaultSupplyExPrice_uint256latest vault's supply token exchange price
vaultBorrowExPrice_uint256latest vault's borrow token exchange price

calcLiquidityTotalAmountsSimulatedTime ​

returns the totalSupply_ and totalBorrow_ at Liquidity at a certain point in time given the stacked uint256 storage data for total amounts and exchange prices and config.

solidity
function calcLiquidityTotalAmountsSimulatedTime(
    uint256 totalAmounts_,
    uint256 exchangePricesAndConfig_,
    uint256 simulatedTimestamp_
)
    public
    pure
    returns (uint256 totalSupply_, uint256 totalBorrow_, uint256 supplyExchangePrice_, uint256 borrowExchangePrice_);

calcLiquidityUserAmountsSimulatedTime ​

returns the supply_ and borrow_ for a user (protocol) at Liquidity at a certain point in time given the stacked uint256 storage data for total amounts and exchange prices and config.

solidity
function calcLiquidityUserAmountsSimulatedTime(
    uint256 userSupplyData_,
    uint256 userBorrowData_,
    uint256 liquiditySupplyExchangePricesAndConfig_,
    uint256 liquidityBorrowExchangePricesAndConfig_,
    uint256 simulatedTimestamp_
) public pure returns (uint256 supply_, uint256 borrow_, uint256 supplyExchangePrice_, uint256 borrowExchangePrice_);

Structs ​

TokenRevenue ​

solidity
struct TokenRevenue {
    address token;
    uint256 revenueAmount;
}