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
Name | Type | Description |
---|---|---|
totalAmounts_ | uint256 | total amounts packed uint256 read from storage |
exchangePricesAndConfig_ | uint256 | exchange prices and config packed uint256 read from storage |
liquidityTokenBalance_ | uint256 | current balance of Liquidity contract (IERC20(token_).balanceOf(address(this))) |
Return Values
Name | Type | Description |
---|---|---|
revenueAmount_ | uint256 | collectable 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
Name | Type | Description |
---|---|---|
exchangePricesAndConfig_ | uint256 | exchange prices and config packed uint256 read from storage |
simulatedTimestamp_ | uint256 | simulated block.timestamp |
Return Values
Name | Type | Description |
---|---|---|
supplyExchangePrice_ | uint256 | updated supplyExchangePrice |
borrowExchangePrice_ | uint256 | updated 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
Name | Type | Description |
---|---|---|
vaultVariables2_ | uint256 | vaultVariables2 read from storage for the vault (VaultResolver.getRateRaw) |
vaultRates_ | uint256 | rates read from storage for the vault (VaultResolver.getVaultVariables2Raw) |
liquiditySupplyExchangePricesAndConfig_ | uint256 | exchange prices and config packed uint256 read from storage for supply token |
liquidityBorrowExchangePricesAndConfig_ | uint256 | exchange prices and config packed uint256 read from storage for borrow token |
simulatedTimestamp_ | uint256 | simulated block.timestamp |
Return Values
Name | Type | Description |
---|---|---|
liqSupplyExPrice_ | uint256 | latest liquidity's supply token supply exchange price |
liqBorrowExPrice_ | uint256 | latest liquidity's borrow token borrow exchange price |
vaultSupplyExPrice_ | uint256 | latest vault's supply token exchange price |
vaultBorrowExPrice_ | uint256 | latest 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.