CalcsSimulatedTime ​
this is the exact same code as LiquidityCalcs
library, just that it supports a simulated block.timestamp to expose historical calculations.
State Variables ​
EXCHANGE_PRICES_PRECISION ​
constants as from Liquidity variables.sol
solidity
uint256 internal constant EXCHANGE_PRICES_PRECISION = 1e12;
SECONDS_PER_YEAR ​
Ignoring leap years
solidity
uint256 internal constant SECONDS_PER_YEAR = 365 days;
DEFAULT_EXPONENT_SIZE ​
solidity
uint256 internal constant DEFAULT_EXPONENT_SIZE = 8;
DEFAULT_EXPONENT_MASK ​
solidity
uint256 internal constant DEFAULT_EXPONENT_MASK = 0xFF;
FOUR_DECIMALS ​
solidity
uint256 internal constant FOUR_DECIMALS = 1e4;
TWELVE_DECIMALS ​
solidity
uint256 internal constant TWELVE_DECIMALS = 1e12;
X14 ​
solidity
uint256 internal constant X14 = 0x3fff;
X15 ​
solidity
uint256 internal constant X15 = 0x7fff;
X16 ​
solidity
uint256 internal constant X16 = 0xffff;
X18 ​
solidity
uint256 internal constant X18 = 0x3ffff;
X24 ​
solidity
uint256 internal constant X24 = 0xffffff;
X33 ​
solidity
uint256 internal constant X33 = 0x1ffffffff;
X64 ​
solidity
uint256 internal constant X64 = 0xffffffffffffffff;
Functions ​
calcExchangePrices ​
calculates interest (exchange prices) for a token given its' exchangePricesAndConfig from storage.
solidity
function calcExchangePrices(uint256 exchangePricesAndConfig_, uint256 blockTimestamp_)
internal
pure
returns (uint256 supplyExchangePrice_, uint256 borrowExchangePrice_);
Parameters
Name | Type | Description |
---|---|---|
exchangePricesAndConfig_ | uint256 | exchange prices and config packed uint256 read from storage |
blockTimestamp_ | uint256 | simulated block.timestamp |
Returns
Name | Type | Description |
---|---|---|
supplyExchangePrice_ | uint256 | updated supplyExchangePrice |
borrowExchangePrice_ | uint256 | updated borrowExchangePrice |
calcRevenue ​
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.
solidity
function calcRevenue(
uint256 totalAmounts_,
uint256 exchangePricesAndConfig_,
uint256 liquidityTokenBalance_,
uint256 blockTimestamp_
) internal pure 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))) |
blockTimestamp_ | uint256 | simulated block.timestamp |
Returns
Name | Type | Description |
---|---|---|
revenueAmount_ | uint256 | collectable revenue amount |
getTotalSupply ​
reads the total supply out of Liquidity packed storage totalAmounts_
for supplyExchangePrice_
solidity
function getTotalSupply(uint256 totalAmounts_, uint256 supplyExchangePrice_)
internal
pure
returns (uint256 totalSupply_);
getTotalBorrow ​
reads the total borrow out of Liquidity packed storage totalAmounts_
for borrowExchangePrice_
solidity
function getTotalBorrow(uint256 totalAmounts_, uint256 borrowExchangePrice_)
internal
pure
returns (uint256 totalBorrow_);
Errors ​
FluidCalcsSimulatedTimeError ​
solidity
error FluidCalcsSimulatedTimeError(uint256 errorId_);
FluidCalcsSimulatedTimeInvalidTimestamp ​
solidity
error FluidCalcsSimulatedTimeInvalidTimestamp();