Skip to content

Commit

Permalink
feat: allow equal starting end ending ticks
Browse files Browse the repository at this point in the history
  • Loading branch information
kinrezC committed Oct 18, 2024
1 parent 20d85ef commit 686c3e5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Doppler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,15 @@ contract Doppler is BaseHook {
/* Tick checks */
// Starting tick must be greater than ending tick if isToken0
// Ending tick must be greater than starting tick if isToken1
if (_isToken0 && _startingTick <= _endingTick) revert InvalidTickRange();
if (!_isToken0 && _startingTick >= _endingTick) revert InvalidTickRange();
if (_startingTick != endingTick) {
if (_isToken0 && _startingTick <= _endingTick) revert InvalidTickRange();
if (!_isToken0 && _startingTick >= _endingTick) revert InvalidTickRange();

int24 totalTickDelta = _isToken0 ? _startingTick - _endingTick : _endingTick - _startingTick;
int256 totalEpochs = int256((_endingTime - _startingTime) / _epochLength);
// DA worst case is starting tick - ending tick
if (_gamma * totalEpochs != totalTickDelta) revert InvalidGamma();
}
// Enforce maximum tick spacing
if (_poolKey.tickSpacing > MAX_TICK_SPACING) revert InvalidTickSpacing();

Expand All @@ -116,10 +123,6 @@ contract Doppler is BaseHook {

/* Gamma checks */
// Enforce that the total tick delta is divisible by the total number of epochs
int24 totalTickDelta = _isToken0 ? _startingTick - _endingTick : _endingTick - _startingTick;
int256 totalEpochs = int256((_endingTime - _startingTime) / _epochLength);
// DA worst case is starting tick - ending tick
if (_gamma * totalEpochs != totalTickDelta) revert InvalidGamma();
// Enforce that gamma is divisible by tick spacing
if (_gamma % _poolKey.tickSpacing != 0) revert InvalidGamma();

Expand Down

0 comments on commit 686c3e5

Please sign in to comment.