Raydium CP's swap_base_input function calculate the fee in the following way:
see: https://github.com/raydium-io/raydium-cp-swap/blob/87685cf221e7d0b06419c6c750bd963b6780dca9/programs/cp-swap/src/curve/calculator.rs#L102C13-L102C22
let trade_fee = Fees::trading_fee(source_amount, trade_fee_rate)?;
let protocol_fee = Fees::protocol_fee(trade_fee, protocol_fee_rate)?;
let fund_fee = Fees::fund_fee(trade_fee, fund_fee_rate)?;
If you look closely protocol_fee is some x percentage of trade_fee and fund_fee is also some percentage of trade_fee.
Here:
|
trade_fee + protocol_fee + fund_fee, |
We return the tuple 3rd item as trade_fee+protocol_fee+fund_fee it should be just trade_fee.
Raydium CP's swap_base_input function calculate the fee in the following way:
see: https://github.com/raydium-io/raydium-cp-swap/blob/87685cf221e7d0b06419c6c750bd963b6780dca9/programs/cp-swap/src/curve/calculator.rs#L102C13-L102C22
If you look closely
protocol_feeis some x percentage of trade_fee andfund_feeis also some percentage of trade_fee.Here:
autobahn/lib/dex-raydium-cp/src/edge.rs
Line 262 in f9e8f8b
We return the tuple 3rd item as
trade_fee+protocol_fee+fund_feeit should be justtrade_fee.