FluidRevenueResolver ​
Fluid Revenue resolver
State Variables ​
LIQUIDITY ​
address of the liquidity contract
IFluidLiquidity public immutable LIQUIDITY;
_NATIVE_TOKEN_ADDRESS ​
address that is mapped to the chain native token
address internal constant _NATIVE_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
X64 ​
uint256 internal constant X64 = 0xffffffffffffffff;
DEFAULT_EXPONENT_SIZE ​
uint256 internal constant DEFAULT_EXPONENT_SIZE = 8;
DEFAULT_EXPONENT_MASK ​
uint256 internal constant DEFAULT_EXPONENT_MASK = 0xFF;
Functions ​
constructor ​
constructor(IFluidLiquidity liquidity_);
getRevenueCollector ​
address of contract that gets sent the revenue. Configurable by governance
function getRevenueCollector() public view returns (address);
getRevenue ​
gets the currently uncollected revenueAmount_
for a token_
.
function getRevenue(address token_) public view returns (uint256 revenueAmount_);
getRevenues ​
gets the currently uncollected revenues for all listed tokens at Liquidity
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
function calcRevenue(uint256 totalAmounts_, uint256 exchangePricesAndConfig_, uint256 liquidityTokenBalance_)
public
view
returns (uint256 revenueAmount_);
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))) |
Returns
Name | Type | Description |
---|---|---|
revenueAmount_ | uint256 | collectable revenue amount |
calcRevenueSimulatedTime ​
same as calcRevenue
, but for a simulated block.timestamp
set via simulatedTimestamp_
.
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_
.
function calcLiquidityExchangePricesSimulatedTime(uint256 exchangePricesAndConfig_, uint256 simulatedTimestamp_)
public
pure
returns (uint256 supplyExchangePrice_, uint256 borrowExchangePrice_);
Parameters
Name | Type | Description |
---|---|---|
exchangePricesAndConfig_ | uint256 | exchange prices and config packed uint256 read from storage |
simulatedTimestamp_ | uint256 | simulated block.timestamp |
Returns
Name | Type | Description |
---|---|---|
supplyExchangePrice_ | uint256 | updated supplyExchangePrice |
borrowExchangePrice_ | uint256 | updated borrowExchangePrice |
calcVaultExchangePricesSimulatedTime ​
Calculates new vault exchange prices based on storage data for a simulated block.timestamp
set via simulatedTimestamp_
.
function calcVaultExchangePricesSimulatedTime(
uint256 vaultVariables2_,
uint256 vaultRates_,
uint256 liquiditySupplyExchangePricesAndConfig_,
uint256 liquidityBorrowExchangePricesAndConfig_,
uint256 simulatedTimestamp_
)
public
pure
returns (
uint256 liqSupplyExPrice_,
uint256 liqBorrowExPrice_,
uint256 vaultSupplyExPrice_,
uint256 vaultBorrowExPrice_
);
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 |
Returns
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 ​
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.
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.
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 ​
struct TokenRevenue {
address token;
uint256 revenueAmount;
}