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. The deploy’s on-chain config can cap fees lower (max_fee_bps); a build above that cap is refused.2
Build with your fee wallet
Send
feeAccount: the wallet that collects the fee. It is required when the quote priced a fee.quoteResponse (pair mode) quotes and builds in one call: there the fee is feeBps together with feeAccount, priced like platformFeeBps (which a build body ignores). feeBps without feeAccount takes no fee.
A build of a quote that priced no fee can still add one with feeAccount and feeBps. It is then taken at build time, outside the quote’s numbers: on an ExactIn it comes out of the slippage floor (up to feeBps less than the quoted outAmount can arrive), on an ExactOut it raises the input.
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=falsewith ExactOut is a400).
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 answers400 with "error": "declined", "reason": "platform_fee" when:
feeAccountis 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
feeAccountis another wallet; feeBpsis above your deploy’s on-chainmax_fee_bps;- a fee is added at build time to a split quote;
- the quote’s amounts do not add up with its fee (an altered quote).
feeAccount, or sends a different feeBps or feeOnInput, the answer is 400 quote_mismatch.
Split routes take no fee: a quote with
platformFeeBps is never split.