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

How to manage multiple swaps within a single transaction? #16

Open
dev12375 opened this issue Jan 8, 2025 · 1 comment
Open

How to manage multiple swaps within a single transaction? #16

dev12375 opened this issue Jan 8, 2025 · 1 comment

Comments

@dev12375
Copy link

dev12375 commented Jan 8, 2025

Example 1

200 USDC => 200 USDT
200 USDT => 1 SOL
1 SOL => 5000 Coin

Perform as expected.

input 200 USDC
output 5000 Coin

Example 2

200 USDT => 1 SOL
300 USDT => 1.5 SOL

expect

input 500 USDT
output 2.5 SOL

actual

input 200 USDT
output 1.5 SOL

When handling []SwapData in ProcessSwapData, can it be divided into inputs and outputs?
Would collecting all inputs and outputs, then removing duplicates, achieve the desired result?

Example 1
Input. [ 200 USDC 200 USDT 1 SOL ]
Ouput [ 200 USDT 1 SOL 5000 Coin]

removing duplicates

input 200 USDC
output 5000 Coin

Example 2

Input. [ 200 USDT 300 USDT ]
Ouput [ 1 SOL 1.5 SOL]

removing duplicates

input 500 USDT
output 2.5 SOL

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