> For the complete documentation index, see [llms.txt](https://docs.peach.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peach.ag/documentation/bsc/aggregator/editor/fees-slippage-and-settlement.md).

# Fees

Configure integrator fees and distinguish gross output from recipient output.

Custom fees are output-side integrator fees. Display quotes project the fee locally; preparation sends the settings to the Aggregator so they become part of the signed ExecutionPlan.

### Configure fees

| Display quote                  | Execution preparation |
| ------------------------------ | --------------------- |
| `options.customFee.feeAccount` | `customFeeReceiver`   |
| `options.customFee.feeBps`     | `customFeeBps`        |

One basis point is 0.01%; 20 bps is 0.2%. Omit the display fee object and set preparation fee to zero or omit it to request no custom fee. The quote fee object and preparation fields have different names in v0.3.0; use the mapping above for every preparation method, including `prepareDelegatedSwap()`.

Use `params` for the confirmed trade inputs (`from`, `target`, `amount`, `executor`, and any routing options). Define `fee` as `{ feeAccount: receiverAddress, feeBps: 20 }` for a 0.2% custom fee. Keep the preview and preparation in separate UI actions.

For preview:

```typescript
const quote = await client.getQuote({
  from: params.from, target: params.target, amountIn: params.amount,
  options: { providers: params.providers, depth: params.depth, splitCount: params.splitCount, customFee: fee },
});
```

After the user chooses to trade, carry the same fee and routing settings into preparation:

```typescript
const prepared = await client.prepareDirectSwap({
  ...params,
  customFeeBps: fee.feeBps, customFeeReceiver: fee.feeAccount,
  slippageBps: params.slippageBps ?? 50, // Explicit default: 0.5%
  deadlineSecs: params.deadlineSecs ?? 300,
});
```

Show the prepared expected output and minimum received, obtain acceptance, then follow [Quickstart](https://docs.peach.ag/documentation/bsc/aggregator/quickstart) for approval and submission. These examples use exact-input trades.

### Fee limits

<table><thead><tr><th width="277.89453125">Layer</th><th>v0.3.0 behavior</th></tr></thead><tbody><tr><td><code>getQuote()</code></td><td>A supplied <code>customFee</code> requires integer bps in <code>[1, 500]</code> and a nonzero receiver; violations throw <code>CustomFeeError</code></td></tr><tr><td>Preparation helpers</td><td>Integer <code>customFeeBps</code> in <code>[0, 10000]</code>; positive fees require a nonzero receiver; violations throw <code>ExecutionRouterValidationError</code></td></tr><tr><td>Deployed service and contracts</td><td>Can enforce additional rules or lower live limits</td></tr></tbody></table>

The preparation range is a local input bound, not a promise that a 100% fee is executable. For one UI that both previews and prepares, keep positive fees within the quote-supported range and the applicable live cap.

`getRouterConfig(routerAddress)` reads the underlying PeachRouter's `maxCustomFeeBps`, pause state and protocol split. This is the underlying router address, not the Execution Router. A prepared Direct result exposes it as `legacyRouterAddress`. `getProtocolFeeConfig(routerAddress)` reads the receiver and protocol share. These mutable values are display/configuration snapshots; they do not override the signed plan.

### Output amounts and fees

<table><thead><tr><th width="307.4921875">Value</th><th>Meaning</th></tr></thead><tbody><tr><td><code>quote.route.totalAmountOut</code></td><td>Gross display output</td></tr><tr><td><code>quote.customFee.feeAmount</code></td><td>Projected total custom fee, before protocol split</td></tr><tr><td><code>quote.amountOut</code></td><td>Display output after that fee</td></tr><tr><td><code>prepared.amountOut</code></td><td>Gross prepared output</td></tr><tr><td><code>prepared.expectAmountOut</code></td><td>Expected prepared recipient output after custom fee</td></tr><tr><td><code>ready.execution.plan.minAmountOut</code></td><td>Signed minimum; Direct prepared results are already ready</td></tr><tr><td><code>simulation.userAmountOut</code></td><td>Simulated actual recipient output</td></tr></tbody></table>

For a built Delegated result, the gross and expected prepared amounts remain in `ready.prepared.amountOut` and `ready.prepared.expectAmountOut`; the signed expected amount is `ready.execution.plan.expectedAmountOut`. A built result does not expose top-level `amountOut` or `expectAmountOut`.

Display projection uses integer arithmetic: `fee = gross * feeBps / 10000`, then `net = gross - fee`. `protocolCutBps` is a share of the custom fee, not of the whole swap output. Direct response fee metadata is available in `prepared.raw`; the SDK checks the total and split sums against the response.

Show `expectAmountOut` as the prepared output estimate. Do not label `prepared.amountOut` as the amount the recipient will receive.

See [Slippage](https://docs.peach.ag/documentation/bsc/aggregator/editor/slippage) for minimum received and positive-slippage settlement.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.peach.ag/documentation/bsc/aggregator/editor/fees-slippage-and-settlement.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
