Skip to main content
Your platform can take a fee of up to 10% on every swap it routes. The fee is part of the quote’s numbers and is paid inside the swap, through the swap program.
1

Quote with a fee

Add platformFeeBps to the quote (up to 1000; higher values are capped at 1000). The quote answers platformFee {amount, feeBps, feeMint} and amounts that already account for it.
2

Build with your fee wallet

Send feeAccount: the wallet that collects the fee. It is required when the quote priced a fee.

Which side pays

feeOnInput chooses the token the fee is taken in:
  • by default, the input when the input is SOL, USDC, USDT or USD1, otherwise the output;
  • an ExactOut always takes it on the input (feeOnInput=false with ExactOut is a 400).
On the input, the route swaps amount − fee. On the output, outAmount is already net of the fee. Either way, the quote’s numbers are what the user gets.

Where the fee goes

feeAccount is a wallet, not a token account:
  • a fee in a token goes to that wallet’s associated token account for feeMint, created by the build if missing;
  • a fee in SOL is paid to the wallet itself.

When a fee build is refused

The build answers 400 with "error": "declined", "reason": "platform_fee" when:
  • feeAccount is the user’s own wallet;
  • the fee is on the output and the output goes to another wallet (destinationTokenAccount);
  • a SOL fee is below the rent-exempt minimum and the fee wallet does not exist on chain yet;
  • your deploy pins fees to its fee authority and feeAccount is another wallet;
  • the quote’s amounts do not add up with its fee (an altered quote).
If the quote priced a fee and the build omits feeAccount or sends a different feeBps, the answer is 400 quote_mismatch.
Split routes take no fee: a quote with platformFeeBps is never split.