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

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

Return Values

NameTypeDescription
supplyExchangePrice_uint256updated supplyExchangePrice
borrowExchangePrice_uint256updated 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

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)))
blockTimestamp_uint256simulated block.timestamp

Return Values

NameTypeDescription
revenueAmount_uint256collectable 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**