Skip to content

CalcsSimulatedTime ​

this is the exact same code as LiquidityCalcs library, just that it supports a simulated block.timestamp to expose historical calculations.

FluidCalcsSimulatedTimeError ​

solidity
error FluidCalcsSimulatedTimeError(uint256 errorId_)

FluidCalcsSimulatedTimeInvalidTimestamp ​

solidity
error FluidCalcsSimulatedTimeInvalidTimestamp()

EXCHANGE_PRICES_PRECISION ​

solidity
uint256 EXCHANGE_PRICES_PRECISION

constants as from Liquidity variables.sol

SECONDS_PER_YEAR ​

solidity
uint256 SECONDS_PER_YEAR

Ignoring leap years

DEFAULT_EXPONENT_SIZE ​

solidity
uint256 DEFAULT_EXPONENT_SIZE

DEFAULT_EXPONENT_MASK ​

solidity
uint256 DEFAULT_EXPONENT_MASK

FOUR_DECIMALS ​

solidity
uint256 FOUR_DECIMALS

TWELVE_DECIMALS ​

solidity
uint256 TWELVE_DECIMALS

X14 ​

solidity
uint256 X14

X15 ​

solidity
uint256 X15

X16 ​

solidity
uint256 X16

X18 ​

solidity
uint256 X18

X24 ​

solidity
uint256 X24

X33 ​

solidity
uint256 X33

X64 ​

solidity
uint256 X64

calcExchangePrices ​

solidity
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 ​

solidity
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 ​

solidity
function getTotalSupply(uint256 totalAmounts_, uint256 supplyExchangePrice_) internal pure returns (uint256 totalSupply_)

_reads the total supply out of Liquidity packed storage totalAmounts_forsupplyExchangePrice**

getTotalBorrow ​

solidity
function getTotalBorrow(uint256 totalAmounts_, uint256 borrowExchangePrice_) internal pure returns (uint256 totalBorrow_)

_reads the total borrow out of Liquidity packed storage totalAmounts_forborrowExchangePrice**