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

0x Permit2 send it #7648

Closed
twblack88 opened this issue Aug 28, 2024 · 5 comments · Fixed by #7977
Closed

0x Permit2 send it #7648

twblack88 opened this issue Aug 28, 2024 · 5 comments · Fixed by #7977
Assignees

Comments

@twblack88
Copy link
Contributor

twblack88 commented Aug 28, 2024

0x launched their new API. They sent us all this documentation about saving people gas and making the UX better. This ticket covers picking up a more secure pattern for token allowances on the 0x swapper.

It's basically: replace approval with permit2 for the 0x swapper.

Consider it low priority but worth picking up. Should only use the pattern for permit2 since we already have token-approval signature transaction flows (sign to approve) and then send the transaction. In our current app permit2 upgrades a current onchain siganture to an "offchain signature for limited approval and an onchain signature for the trade." Already better.

"If your integration doesn't support collecting offchain signatures, such as with smart contracts, we recommend using AllowanceHolder."

☝️ this is what we have to verify and account for.

from smart contract lore, a good overview: https://github.com/dragonfly-xyz/useful-solidity-patterns/tree/main/patterns/permit2

0x docs: https://0x.org/docs/upgrading/upgrading_to_swap_v2#step-1-get-indicative-price

Headless example: https://github.com/0xProject/0x-examples/blob/main/swap-v2-headless-example/index.ts#L62-L83

@twblack88
Copy link
Contributor Author

@reallybeard it's simple and we already have this, but a mock or two here would be super helpful.

0x is nagging us about upgrading to v2 so we might as well see where we're going. Just to round it out.

@woodenfurniture
Copy link
Member

woodenfurniture commented Sep 10, 2024

Questions to answer:

  • Can we wrap all of the swappers in Permit2 or does the protocol need to support Permit2 for it to work?

Contracts must be purposely written to support Permit2. We will have to support both flows.

@woodenfurniture woodenfurniture self-assigned this Sep 10, 2024
@twblack88
Copy link
Contributor Author

twblack88 commented Sep 10, 2024

@woodenfurniture going for extra credit. @reallybeard gonna get mocks .

vomited thoughts for now https://excalidraw.com/#room=57937cdcd3d70f535ad4,MgzvO8mKR_lRaC18ncX2-g

image

@woodenfurniture woodenfurniture moved this from Backlog to In progress in ShapeShift Dashboard Sep 16, 2024
@0xean 0xean changed the title 0x Permit2 Spike and then send it 0x Permit2 send it Sep 23, 2024
@woodenfurniture woodenfurniture moved this from In progress to Blocked in ShapeShift Dashboard Sep 30, 2024
@0xean
Copy link
Contributor

0xean commented Oct 7, 2024

waiting for UI help from @reallybeard

@reallybeard
Copy link
Contributor

Was having trouble getting this to run correctly on my local env. But I went through the different jams. Everything looks great, only small feedback is to move the instructions below the label. @woodenfurniture

Crappy screenshot attached.
Screenshot_2024-10-14_at_4 23 57_PM copy

@woodenfurniture woodenfurniture moved this from Blocked to In review in ShapeShift Dashboard Oct 14, 2024
@woodenfurniture woodenfurniture moved this from In review to In progress in ShapeShift Dashboard Oct 14, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in ShapeShift Dashboard Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants