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 fee calculation #22

Open
SushantChandla opened this issue Oct 16, 2024 · 0 comments
Open

Raydium cp fee calculation #22

SushantChandla opened this issue Oct 16, 2024 · 0 comments

Comments

@SushantChandla
Copy link

SushantChandla commented Oct 16, 2024

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.

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