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=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; - the quote’s amounts do not add up with its fee (an altered quote).
feeAccount or sends a different feeBps, the answer is 400 quote_mismatch.
Split routes take no fee: a quote with
platformFeeBps is never split.