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

Raydium cp swap base output. #23

Open
SushantChandla opened this issue Oct 16, 2024 · 1 comment
Open

Raydium cp swap base output. #23

SushantChandla opened this issue Oct 16, 2024 · 1 comment

Comments

@SushantChandla
Copy link

SushantChandla commented Oct 16, 2024

The swap base output function returns the source_amount_swapped, which already includes the fees.
https://github.com/raydium-io/raydium-cp-swap/blob/87685cf221e7d0b06419c6c750bd963b6780dca9/programs/cp-swap/src/curve/calculator.rs#L150C13-L150C34

see:
https://github.com/raydium-io/raydium-cp-swap/blob/87685cf221e7d0b06419c6c750bd963b6780dca9/programs/cp-swap/src/curve/calculator.rs#L140

We are adding correct fee here:

result.source_amount_swapped as u64 + trade_fee + protocol_fee + fund_fee,

@SushantChandla
Copy link
Author

It is important to note that it does not include transfer_fee in the case of 2022 tokens, so we should add it to the amount. It is currently missing.

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