blockworks-foundation / autobahn

Dex aggregator on Solana
https://autobahn.ag/
GNU Affero General Public License v3.0
68 stars 17 forks source link

Raydium cp swap base output. #23

Open SushantChandla opened 1 month ago

SushantChandla commented 1 month ago

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:

https://github.com/blockworks-foundation/autobahn/blob/f9e8f8bf7cbdb886c23b72fb9ba67d700bd6f91f/lib/dex-raydium-cp/src/edge.rs#L260

SushantChandla commented 1 month ago

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.