FluidRevenueResolver

Fluid Revenue resolver

LIQUIDITY

contract IFluidLiquidity LIQUIDITY

address of the liquidity contract

_NATIVE_TOKEN_ADDRESS

address _NATIVE_TOKEN_ADDRESS

address that is mapped to the chain native token

X64

uint256 X64

DEFAULT_EXPONENT_SIZE

uint256 DEFAULT_EXPONENT_SIZE

DEFAULT_EXPONENT_MASK

uint256 DEFAULT_EXPONENT_MASK

TokenRevenue

struct TokenRevenue {
  address token;
  uint256 revenueAmount;
}

constructor

constructor(contract IFluidLiquidity liquidity_) public

getRevenueCollector

function getRevenueCollector() public view returns (address)

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

getRevenue

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

gets the currently uncollected revenueAmount_ for a token_.

getRevenues

function getRevenues() public view returns (struct FluidRevenueResolver.TokenRevenue[] tokenRevenues_)

gets the currently uncollected revenues for all listed tokens at Liquidity

calcRevenue

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

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

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)))

Return Values

NameTypeDescription
revenueAmount_uint256collectable revenue amount

calcRevenueSimulatedTime

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

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

calcLiquidityExchangePricesSimulatedTime

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

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

Parameters

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

Return Values

NameTypeDescription
supplyExchangePrice_uint256updated supplyExchangePrice
borrowExchangePrice_uint256updated borrowExchangePrice

calcVaultExchangePricesSimulatedTime

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

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

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

Return Values

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

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

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.

calcLiquidityUserAmountsSimulatedTime

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

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.