CalcsSimulatedTime
this is the exact same code as LiquidityCalcs
library, just that it supports a simulated
block.timestamp to expose historical calculations.
FluidCalcsSimulatedTimeError
error FluidCalcsSimulatedTimeError(uint256 errorId_)
FluidCalcsSimulatedTimeInvalidTimestamp
error FluidCalcsSimulatedTimeInvalidTimestamp()
EXCHANGE_PRICES_PRECISION
uint256 EXCHANGE_PRICES_PRECISION
constants as from Liquidity variables.sol
SECONDS_PER_YEAR
uint256 SECONDS_PER_YEAR
Ignoring leap years
DEFAULT_EXPONENT_SIZE
uint256 DEFAULT_EXPONENT_SIZE
DEFAULT_EXPONENT_MASK
uint256 DEFAULT_EXPONENT_MASK
FOUR_DECIMALS
uint256 FOUR_DECIMALS
TWELVE_DECIMALS
uint256 TWELVE_DECIMALS
X14
uint256 X14
X15
uint256 X15
X16
uint256 X16
X18
uint256 X18
X24
uint256 X24
X33
uint256 X33
X64
uint256 X64
calcExchangePrices
function calcExchangePrices(uint256 exchangePricesAndConfig_, uint256 blockTimestamp_) internal pure returns (uint256 supplyExchangePrice_, uint256 borrowExchangePrice_)
calculates interest (exchange prices) for a token given its' exchangePricesAndConfig from storage.
Parameters
Name | Type | Description |
---|---|---|
exchangePricesAndConfig_ | uint256 | exchange prices and config packed uint256 read from storage |
blockTimestamp_ | uint256 | simulated block.timestamp |
Return Values
Name | Type | Description |
---|---|---|
supplyExchangePrice_ | uint256 | updated supplyExchangePrice |
borrowExchangePrice_ | uint256 | updated borrowExchangePrice |
calcRevenue
function calcRevenue(uint256 totalAmounts_, uint256 exchangePricesAndConfig_, uint256 liquidityTokenBalance_, uint256 blockTimestamp_) internal pure returns (uint256 revenueAmount_)
_gets the revenueAmount_
for a token given its' totalAmounts and exchangePricesAndConfig from storage
and the current balance of the Fluid liquidity contract for the token._
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))) |
blockTimestamp_ | uint256 | simulated block.timestamp |
Return Values
Name | Type | Description |
---|---|---|
revenueAmount_ | uint256 | collectable revenue amount |
getTotalSupply
function getTotalSupply(uint256 totalAmounts_, uint256 supplyExchangePrice_) internal pure returns (uint256 totalSupply_)
_reads the total supply out of Liquidity packed storage totalAmounts_
forsupplyExchangePrice*
*
getTotalBorrow
function getTotalBorrow(uint256 totalAmounts_, uint256 borrowExchangePrice_) internal pure returns (uint256 totalBorrow_)
_reads the total borrow out of Liquidity packed storage totalAmounts_
forborrowExchangePrice*
*