> ## Documentation Index
> Fetch the complete documentation index at: https://docs.raze.bot/llms.txt
> Use this file to discover all available pages before exploring further.

# Platform fee

> Charge a fee on the swaps you route. Priced into the quote, paid through the swap program.

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.

<Steps>
  <Step title="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.
  </Step>

  <Step title="Build with your fee wallet">
    Send `feeAccount`: the **wallet** that collects the fee. It is required when the quote priced a fee.
  </Step>
</Steps>

## 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`.

<Note>
  Split routes take no fee: a quote with `platformFeeBps` is never split.
</Note>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.