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

feat: Support cyclic swaps #102

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

Conversation

royvardhan
Copy link
Contributor

@royvardhan royvardhan commented Mar 5, 2025

While adding a cyclic swap test, I discovered that we are adding the amountIn to amountOut when tokenInIndex and tokenOutIndex are same. I added a cyclicSwapAmountOut tracker to track amountOut in case of cyclic swap, and added both sequential and split swap tests that circles back to USDC(the start token of the swap)

@royvardhan royvardhan force-pushed the router/hr/ENG-4290-cyclic-swap branch 2 times, most recently from b4154b6 to 8fe9c4f Compare March 6, 2025 13:40
@royvardhan royvardhan changed the title test: add testCyclicSwapWithTwoPools to test cyclic swaps fix: remove amountIn addition to amountOut in _swap for cyclic swaps, add test Mar 6, 2025
@royvardhan royvardhan force-pushed the router/hr/ENG-4290-cyclic-swap branch from 8fe9c4f to 5577b5a Compare March 6, 2025 13:48
@royvardhan royvardhan marked this pull request as ready for review March 6, 2025 13:48
@royvardhan royvardhan changed the title fix: remove amountIn addition to amountOut in _swap for cyclic swaps, add test fix: remove amountIn addition to amountOut in _swap for cyclic swaps, add tests Mar 6, 2025
Copy link
Contributor

@tamaralipows tamaralipows left a comment

Choose a reason for hiding this comment

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

Just one major comment, the other one more minor. Please have a look!

Copy link
Collaborator

@dianacarvalho1 dianacarvalho1 left a comment

Choose a reason for hiding this comment

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

thank you @royvardhan ! Can we improve the PR name a bit please? the first part of the name doesn't mean much without more context. it should be a feat and something like: feat: Support cyclic swaps

@royvardhan royvardhan changed the title fix: remove amountIn addition to amountOut in _swap for cyclic swaps, add tests feat: Support cyclic swaps Mar 6, 2025
@royvardhan royvardhan force-pushed the router/hr/ENG-4290-cyclic-swap branch from 62a66ff to ecf425a Compare March 6, 2025 16:34
Copy link
Contributor

@tamaralipows tamaralipows left a comment

Choose a reason for hiding this comment

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

Thanks! It's looking good. Just a little request.

@royvardhan royvardhan force-pushed the router/hr/ENG-4290-cyclic-swap branch from c29eaea to ae99f80 Compare March 6, 2025 17:31
Copy link
Collaborator

@dianacarvalho1 dianacarvalho1 left a comment

Choose a reason for hiding this comment

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

Thank you 🙏🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants