Skip to content

Conversation

@gretzke
Copy link
Contributor

@gretzke gretzke commented Sep 10, 2025

No description provided.

@gretzke gretzke requested a review from snreynolds September 10, 2025 22:03
amountOut = _swap(poolKey, zeroForOne, -int256(uint256(amountIn)), pathKey.hookData).toUint128();

if (perHopSlippageLength != 0) {
uint256 price = amountIn * PRECISION / amountOut;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically slippage tolerance is in pure amounts rather than ratio - curious why we went with ratio here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isolates the slippage per hop. If we have two hops and we define a 1% total slippage (in pure amounts) and 0.5% slippage in pure amounts per hop, if the first swap only incurs a 0.1% slippage for example, the second hop could incur up to 0.9% slippage now. But if we have ratio based slippages of 0.5% per hop, regardless of how the first hop performs, the second hop cannot incur more than 0.5% slippage

@gretzke gretzke merged commit 3779387 into main Nov 5, 2025
5 checks passed
@gretzke gretzke deleted the per-hop-slippage branch November 5, 2025 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants