Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use safe sqrtPrice computation #135

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Doppler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,12 @@ contract Doppler is BaseHook {
} else {
targetPriceX96 = _computeTargetPriceX96(totalTokensSold_, totalProceeds_);
}
// TODO: Consider whether this can revert due to InvalidSqrtPrice check
// TODO: Consider whether the target price should actually be tickUpper
// We multiply the tick of the regular price by 2 to get the tick of the sqrtPrice
// This should probably be + tickSpacing in the case of !isToken0
slug.tickLower = _alignComputedTickWithTickSpacing(
TickMath.getTickAtSqrtPrice(targetPriceX96) / 2, key.tickSpacing
// We compute the sqrtPrice as the integer sqrt left shifted by 48 bits to convert to Q96
TickMath.getTickAtSqrtPrice(uint160(FixedPointMathLib.sqrt(uint256(targetPriceX96)) << 48)), key.tickSpacing
) + (isToken0 ? -key.tickSpacing : key.tickSpacing);
slug.tickUpper = isToken0 ? slug.tickLower + key.tickSpacing : slug.tickLower - key.tickSpacing;
slug.liquidity = _computeLiquidity(
Expand Down
Loading