@@ -17,6 +17,7 @@ import {FixedPoint96} from "v4-periphery/lib/v4-core/src/libraries/FixedPoint96.
17
17
import {TransientStateLibrary} from "v4-periphery/lib/v4-core/src/libraries/TransientStateLibrary.sol " ;
18
18
import {FixedPointMathLib} from "solady/utils/FixedPointMathLib.sol " ;
19
19
import {ProtocolFeeLibrary} from "v4-periphery/lib/v4-core/src/libraries/ProtocolFeeLibrary.sol " ;
20
+ import {SafeCastLib} from "solady/utils/SafeCastLib.sol " ;
20
21
21
22
struct SlugData {
22
23
int24 tickLower;
@@ -52,6 +53,8 @@ contract Doppler is BaseHook {
52
53
using TransientStateLibrary for IPoolManager;
53
54
using BalanceDeltaLibrary for BalanceDelta;
54
55
using ProtocolFeeLibrary for * ;
56
+ using SafeCastLib for int256 ;
57
+ using SafeCastLib for uint256 ;
55
58
56
59
bytes32 constant LOWER_SLUG_SALT = bytes32 (uint256 (1 ));
57
60
bytes32 constant UPPER_SLUG_SALT = bytes32 (uint256 (2 ));
@@ -372,7 +375,7 @@ contract Doppler is BaseHook {
372
375
int24 tauTick = startingTick + int24 (state.tickAccumulator / 1e18 );
373
376
374
377
// Safe from overflow since the result is <= gamma which is an int24 already
375
- int24 computedRange = int24 (_getGammaShare () * gamma / 1e18 );
378
+ int24 computedRange = (_getGammaShare () * gamma / 1e18 ). toInt24 ( );
376
379
int24 upperSlugRange = computedRange > key.tickSpacing ? computedRange : key.tickSpacing;
377
380
378
381
// The expectedTick is where the upperSlug.tickUpper is/would be placed in the previous epoch
@@ -407,7 +410,7 @@ contract Doppler is BaseHook {
407
410
}
408
411
409
412
currentTick =
410
- _alignComputedTickWithTickSpacing (upSlug.tickLower + int24 (accumulatorDelta / 1e18 ), key.tickSpacing);
413
+ _alignComputedTickWithTickSpacing (upSlug.tickLower + (accumulatorDelta / 1e18 ). toInt24 ( ), key.tickSpacing);
411
414
412
415
(int24 tickLower , int24 tickUpper ) = _getTicksBasedOnState (newAccumulator, key.tickSpacing);
413
416
@@ -523,7 +526,7 @@ contract Doppler is BaseHook {
523
526
524
527
/// @notice Computes the gamma share for a single epoch, used as a measure for the upper slug range
525
528
function _getGammaShare () internal view returns (int256 ) {
526
- return int256 ( FullMath.mulDiv (epochLength, 1e18 , (endingTime - startingTime)));
529
+ return FullMath.mulDiv (epochLength, 1e18 , (endingTime - startingTime)). toInt256 ( );
527
530
}
528
531
529
532
/// @notice If offset == 0, retrieves the expected amount sold by the end of the last epoch
@@ -602,7 +605,7 @@ contract Doppler is BaseHook {
602
605
view
603
606
returns (int24 lower , int24 upper )
604
607
{
605
- int24 accumulatorDelta = int24 (accumulator / 1e18 );
608
+ int24 accumulatorDelta = (accumulator / 1e18 ). toInt24 ( );
606
609
int24 adjustedTick = startingTick + accumulatorDelta;
607
610
lower = _alignComputedTickWithTickSpacing (adjustedTick, tickSpacing);
608
611
@@ -784,7 +787,7 @@ contract Doppler is BaseHook {
784
787
/// @param num The numerator
785
788
/// @param denom The denominator
786
789
function _computeTargetPriceX96 (uint256 num , uint256 denom ) internal pure returns (uint160 ) {
787
- return uint160 ( FullMath.mulDiv (num, FixedPoint96.Q96, denom));
790
+ return FullMath.mulDiv (num, FixedPoint96.Q96, denom). toUint160 ( );
788
791
}
789
792
790
793
/// @notice Computes the single sided liquidity amount for a given price range and amount of tokens
0 commit comments