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

Multi swap for custom paths #475

Open
MattPereira opened this issue Nov 4, 2024 · 0 comments
Open

Multi swap for custom paths #475

MattPereira opened this issue Nov 4, 2024 · 0 comments

Comments

@MattPereira
Copy link
Member

Overview

  • We want to add support for swapping multiple tokens in a single tx
  • This will only work for custom paths. The SOR does not support multi swap
  • Currently this feature is prevented by the path validation below

const tokenIn = paths[0].tokens[0].address.toLowerCase();
const tokenOut =
paths[0].tokens[paths[0].tokens.length - 1].address.toLowerCase();
if (
!paths.every(
(p) =>
p.tokens[0].address.toLowerCase() === tokenIn &&
p.tokens[p.tokens.length - 1].address.toLowerCase() ===
tokenOut,
)
) {
throw new Error(
'Unsupported swap: all paths must start/end with same token.',
);
}
}

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

No branches or pull requests

1 participant