> 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). Agents can also search and read this documentation through its [MCP server](https://docs.peach.ag/~gitbook/mcp).

# Fees

Configure integrator fees and distinguish gross output from recipient output.

Custom fees are output-side integrator fees bound into the signed ExecutionPlan. Set `customFeeBps` and `customFeeReceiver` directly on `swapAllowance()` or `swapPermit2()`.

### Configure fees

One basis point is 0.01%; 20 bps is 0.2%. Omit the fee or use zero to request no custom fee. Use `params` for trade inputs (`from`, `target`, `amount`, real `executor` and optional route controls), and `fee = { feeAccount: receiverAddress, feeBps: 20 }` in this example.

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

Use the returned net output and minimum for confirmation, then follow [Quickstart](https://docs.peach.ag/documentation/bsc/aggregator/quickstart) for submission. In Permit2, set fees during preparation; signing and build preserve that plan.

### Fee limits

| Layer                          | v0.5.0 behavior                                                                                                                     |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| Preparation helpers            | Integer `customFeeBps` in `[0, 10000]`; positive fees require a nonzero receiver; violations throw `ExecutionRouterValidationError` |
| Deployed service and contracts | Can enforce additional rules or lower live limits                                                                                   |

The preparation range is a local input bound, not a promise that a 100% fee is executable. Apply the live service and contract 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

| Value                               | Meaning                                                   |
| ----------------------------------- | --------------------------------------------------------- |
| `prepared.amountOut`                | Gross prepared output                                     |
| `prepared.expectAmountOut`          | Expected prepared recipient output after custom fee       |
| `ready.execution.plan.minAmountOut` | Signed minimum; Direct prepared results are already ready |
| `simulation.userAmountOut`          | Simulated actual recipient output                         |

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.

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

### Legacy quote fees

For `getQuote()`, pass `options.customFee = { feeAccount, feeBps }`. A supplied fee requires integer bps in `[1, 500]` and a nonzero receiver; invalid values throw `CustomFeeError`. `quote.amountOut` is net, `quote.route.totalAmountOut` is gross, and `quote.customFee.feeAmount` is the projected total fee before protocol split. See [Migration Guide](https://docs.peach.ag/documentation/bsc/aggregator/editor/migration-guide) when replacing this display-only API.


---

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