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

[POC]: Example of permit2 support on swap router #22

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ChefMist
Copy link
Collaborator

@ChefMist ChefMist commented Apr 24, 2024

This is a POC

  • lot of test cases will fail, so deleted most of them.
  • can't just forge install https://github.com/pancakeswap/permit2 as its on a fixed solidity version 0.8.17 and somehow has via_ir=true -- so copied over some code for now.

see BinSwapRouter.t.sol on how to use SwapRouter if permit2 is integrated.

Old flow
Assume swap token X for token Y and a new user.

  1. txn 1: approve token X to swap router
  2. txn 2: call swap router to swap token X to Y

New flow
Assume swap token X for token Y and a new user.

  1. txn 1: approve token X to Permit2.
  2. txn 2: sign permit message and call swap router.multiCall (index 0 is permit, index 1 is swap)

Assume swap token X for token Y and user have approved to permit2 in other PCS product prior eg. universal router v3

  1. txn 1: sign permit message and call swap router.multiCall (index 0 is permit, index 1 is swap)

@ChefMist
Copy link
Collaborator Author

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.

1 participant