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

Refactor swap examples #510

Merged
merged 14 commits into from
Dec 12, 2024
Merged

Refactor swap examples #510

merged 14 commits into from
Dec 12, 2024

Conversation

MattPereira
Copy link
Member

@MattPereira MattPereira commented Dec 1, 2024

Closes #339

My suggestion for re-shaping examples. Feel free to critique, modify, ect.

Summary

  • setup simple example fork hoping to make process easier to follow along and modify to prep for other examples
  • split swap queries into discrete / re-usable examples
  • pnpm example ./examples/swaps/swapV2.ts uses SOR path with old school v2 approval of vault
  • pnpm example ./examples/swaps/swapV3.ts uses custom path with permit2 approval

Console Logs

image

examples/swaps/swapV3.ts Outdated Show resolved Hide resolved
Copy link
Member

@brunoguerios brunoguerios left a comment

Choose a reason for hiding this comment

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

I like this new flow!

Splitting query/transaction examples + reusing them is nice!
And the fact that you're not relying on manipulating storage slots for adding token balance to test accounts feels better as well.
setupExampleFork will get a bit more complex once you swap + add liquidity to prepare for other examples, but I'd say it's quite straightforward to follow.

One thing that came to my mind is that I'm used to leverage examples as debugging tools, where I simply adapt chains/pools/tokens to a different scenario to see if everything is working as expected. This new flow is a bit less flexible in that sense, but I'd say it makes sense to create separate debug files and use those instead of trying to reuse examples for that purpose.

@MattPereira MattPereira marked this pull request as ready for review December 5, 2024 20:38
Copy link
Member

@brunoguerios brunoguerios left a comment

Choose a reason for hiding this comment

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

I think this works great! 👏
I'd say we should follow this pattern with other actions (add/remove/etc..)
And it would be nice to sync so we make sure we're covering everything we need to provide good DX.

@MattPereira MattPereira merged commit bead884 into main Dec 12, 2024
3 of 4 checks passed
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.

Update docs SDK examples/guides
2 participants