Skip to content

FluidDexT1Shift ​

constructor ​

solidity
constructor(address deployerContract_) public

_onlyDelegateCall ​

solidity
modifier _onlyDelegateCall()

_calcShiftingDone ​

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

This function calculates the new value of a parameter after a shifting process.

Parameters ​

NameTypeDescription
current_uint256The current value is the final value where the shift ends
old_uint256The old value from where shifting started.
timePassed_uint256The time passed since shifting started.
shiftDuration_uint256The total duration of the shift when old* reaches current*

Return Values ​

NameTypeDescription
[0]uint256The new value of the parameter after the shift.

_calcRangeShifting ​

solidity
function _calcRangeShifting(uint256 upperRange_, uint256 lowerRange_, uint256 dexVariables2_) public returns (uint256, uint256, uint256)

This function handles the gradual shifting of range values over time If the shift is complete, it updates the state and clears the shift data

Calculates the new upper and lower range values during an active range shift

Parameters ​

NameTypeDescription
upperRange_uint256The target upper range value
lowerRange_uint256The target lower range value
dexVariables2_uint256needed in case shift is ended and we need to update dexVariables2

Return Values ​

NameTypeDescription
[0]uint256The updated upper range, lower range, and dexVariables2
[1]uint256
[2]uint256

_calcThresholdShifting ​

solidity
function _calcThresholdShifting(uint256 upperThreshold_, uint256 lowerThreshold_, uint256 thresholdTime_) public returns (uint256, uint256, uint256)

This function handles the gradual shifting of threshold values over time If the shift is complete, it updates the state and clears the shift data

Calculates the new upper and lower threshold values during an active threshold shift

Parameters ​

NameTypeDescription
upperThreshold_uint256The target upper threshold value
lowerThreshold_uint256The target lower threshold value
thresholdTime_uint256The time passed since shifting started

Return Values ​

NameTypeDescription
[0]uint256The updated upper threshold, lower threshold, and threshold time
[1]uint256
[2]uint256

_calcCenterPrice ​

solidity
function _calcCenterPrice(uint256 dexVariables_, uint256 dexVariables2_) public returns (uint256 newCenterPrice_)

This function gradually shifts the center price towards a new target price over time It uses an external price source (via ICenterPrice) to determine the target price The shift continues until the current price reaches the target, or the shift duration ends Once the shift is complete, it updates the state and clears the shift data The shift rate is dynamic and depends on:

  • Time remaining in the shift duration
  • The new center price (fetched externally, which may change)
  • The current (old) center price This results in a fuzzy shifting mechanism where the rate can change as these parameters evolve The externally fetched new center price is expected to not differ significantly from the last externally fetched center price

Calculates the new center price during an active price shift

Parameters ​

NameTypeDescription
dexVariables_uint256The current state of dex variables
dexVariables2_uint256Additional dex variables

Return Values ​

NameTypeDescription
newCenterPrice_uint256The updated center price