Skip to content

Helpers ​

Git Source

Inherits:ImmutableVariables

Functions ​

_readDexKeyAtIndex ​

solidity
function _readDexKeyAtIndex(uint256 index) internal view returns (DexKey memory);

_calculateDexId ​

solidity
function _calculateDexId(DexKey memory dexKey_) internal pure returns (bytes8);

_calculatePoolStateSlot ​

solidity
function _calculatePoolStateSlot(bytes8 dexId, uint256 baseSlot) internal pure returns (bytes32);

_readPoolState ​

solidity
function _readPoolState(bytes8 dexId_)
    internal
    view
    returns (uint256 dexVariables_, uint256 centerPriceShift_, uint256 rangeShift_, uint256 thresholdShift_);

_unpackDexVariables ​

solidity
function _unpackDexVariables(uint256 dexVariables_) internal view returns (DexVariables memory);

_unpackCenterPriceShift ​

solidity
function _unpackCenterPriceShift(uint256 centerPriceShift_) internal pure returns (CenterPriceShift memory);

_unpackRangeShift ​

solidity
function _unpackRangeShift(uint256 rangeShift_) internal pure returns (RangeShift memory);

_unpackThresholdShift ​

solidity
function _unpackThresholdShift(uint256 thresholdShift_) internal pure returns (ThresholdShift memory);

_calculateReservesOutsideRange ​

getting reserves outside range.

solidity
function _calculateReservesOutsideRange(uint256 gp_, uint256 pa_, uint256 rx_, uint256 ry_)
    internal
    pure
    returns (uint256 xa_, uint256 yb_);

Parameters

NameTypeDescription
gp_uint256is geometric mean pricing of upper percent & lower percent
pa_uint256price of upper range or lower range
rx_uint256real reserves of token0 or token1
ry_uint256whatever is rx_ the other will be ry_

_calcShiftingDone ​

solidity
function _calcShiftingDone(uint256 current_, uint256 old_, uint256 timePassed_, uint256 shiftDuration_)
    internal
    pure
    returns (uint256);

_calcRangeShifting ​

solidity
function _calcRangeShifting(uint256 upperRange_, uint256 lowerRange_, uint256 rangeShift_)
    internal
    returns (uint256, uint256);

_calcThresholdShifting ​

solidity
function _calcThresholdShifting(uint256 upperThreshold_, uint256 lowerThreshold_, uint256 thresholdShift_)
    internal
    returns (uint256, uint256);

_calcCenterPrice ​

solidity
function _calcCenterPrice(DexKey memory dexKey_, uint256 dexVariables_, uint256 centerPriceShift_)
    internal
    returns (uint256 newCenterPrice_);

_getPricesAndReserves ​

Calculates and returns the current prices and exchange prices for the pool

solidity
function _getPricesAndReserves(
    DexKey memory dexKey_,
    uint256 dexVariables_,
    uint256 centerPriceShift_,
    uint256 rangeShift_,
    uint256 thresholdShift_,
    uint256 token0Supply_,
    uint256 token1Supply_
) internal returns (Prices memory prices_, Reserves memory reserves_);

Parameters

NameTypeDescription
dexKey_DexKey
dexVariables_uint256The first set of DEX variables containing various pool parameters
centerPriceShift_uint256
rangeShift_uint256
thresholdShift_uint256
token0Supply_uint256
token1Supply_uint256