-
Notifications
You must be signed in to change notification settings - Fork 6
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
chore: Update with latest v4-core changes #32
Conversation
@@ -165,13 +166,13 @@ abstract contract CLSwapRouterBase is SwapRouterBase, ICLSwapRouterBase { | |||
); | |||
|
|||
if (zeroForOne) { | |||
reciprocalAmount = amountSpecified > 0 ? delta.amount1() : delta.amount0(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might need some 👀 on this reciprocalAmount
adf7baa
to
60aeb60
Compare
src/pool-cl/CLSwapRouterBase.sol
Outdated
reciprocalAmount = amountSpecified > 0 ? delta.amount1() : delta.amount0(); | ||
if (settle) _payAndSettle(poolKey.currency0, payer, delta.amount0()); | ||
if (take) vault.take(poolKey.currency1, recipient, uint128(-delta.amount1())); | ||
reciprocalAmount = amountSpecified < 0 ? -delta.amount1() : -delta.amount0(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it better to not have minus here and flip sign for line 28, 62, 92, 123 ?
Reason: the return value reciprocalAmount
is the delta of unspecified token according to the context, hence its sign should be aligned with BalanceDelta as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i created a PR to further update -- pancakeswap/pancake-v4-periphery#34 can you see if this PR make sense? will merge to this branch if it make sense
pancakeswap/pancake-v4-periphery@60aeb60 changes is fine |
@chef-omelette @ChefSnoopy @ChefCupcake feel free to continue leaving comment, will address them. context: theres still more PR to come to further optimise our codebase due to the changes in v4-core |
Context
In the latest v4-core, a few changes has been made that impacts v4-periphery
flip BalanceDelta
andflip amountIn
eg. exactInput is when amountSpecified is negative: refactor: flip the sign for balanceDelta pancake-v4-core#49migrate over to transient storage for vault reserve Refactor: reserve of transient pancake-v4-core#42
adding
salt()
concept to position: [PART-1] enable hooks to return deltas to influence pool behavior pancake-v4-core#44swap
returns 2 balanceDelta now: [PART-1] enable hooks to return deltas to influence pool behavior pancake-v4-core#44modifyLiquidity
to also return 2 balanceDeltaChanges
Example of optimization required down the road
bytes32(0)