> 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/direct-allowance.md).

# Direct Swaps

Use Direct Allowance when one wallet supplies the tokens and submits the swap.

`prepareDirectSwap()` returns a `PreparedDirectSwap` with status `TRANSACTION_READY`. The payer and executor must be the same wallet; the recipient may differ.

<table><thead><tr><th width="300.625">Preparation input</th><th>Direct behavior</th></tr></thead><tbody><tr><td><code>from</code>, <code>target</code></td><td>Input and output token addresses, or the native BNB sentinel</td></tr><tr><td><code>amount</code></td><td>Positive exact input amount as <code>bigint</code></td></tr><tr><td><code>executor</code></td><td>Required address of the signer that will submit the swap</td></tr><tr><td><code>payer</code></td><td>Optional; defaults to <code>executor</code> and must equal it</td></tr><tr><td><code>recipient</code></td><td>Optional; defaults to <code>executor</code></td></tr><tr><td><code>slippageBps</code>, <code>deadlineSecs</code></td><td>Optional trade settings; omission uses service defaults</td></tr><tr><td><code>providers</code>, <code>depth</code>, <code>splitCount</code></td><td>Optional routing controls at the top level</td></tr><tr><td><code>customFeeBps</code>, <code>customFeeReceiver</code></td><td>Optional output fee; see <a href="https://docs.peach.ag/documentation/bsc/aggregator/editor/fees-slippage-and-settlement">Fees</a></td></tr></tbody></table>

`prepareSwap()` also returns a Direct result when payer and executor are equal. Use `prepareDirectSwap()` when your application requires this mode; it rejects different addresses before requesting preparation.

### Set the recipient

Use the client, signer and order inputs from [Quickstart](https://docs.peach.ag/documentation/bsc/aggregator/quickstart). Set `recipient` during fresh preparation to send the output directly to `destinationAddress` in the swap transaction:

```typescript
const prepared = await client.prepareDirectSwap({
  from: tokenIn, target: tokenOut, amount,
  executor: await signer.getAddress(),
  recipient: destinationAddress,
  slippageBps: 50, // 0.5%
  deadlineSecs: 300,
});
if (prepared.amountIn !== amount) throw new Error("Prepared input differs from the order");
```

The signer supplies input and pays gas; the recipient receives the output. Show the recipient, `prepared.expectAmountOut` and `prepared.tx.amountOutMin` for acceptance, then follow Quickstart's approval and submission steps.

Sending tokens to a protocol contract does not call its `deposit()` or `stake()` function. Combining a swap with such operations requires an outer contract call; that workflow has not been verified for this guide. `executeSwap()` sends directly to the Peach Execution Router.

### Token approval

For native input or sufficient allowance, `buildDirectApprovalRequest()` returns `undefined`. Otherwise it builds `approve(spender, MaxUint256)`. v0.3.0 has no exact-amount approval option on this helper. `gasPrice` and `gasLimit` affect the transaction envelope, not the allowance amount.

Applications choosing an exact allowance can build a separate ERC20 approval using `prepared.tokenIn`, `prepared.approvalSpender` and `prepared.amountIn`, then wait for its receipt. Do not approve an address from an earlier quote. Some tokens require a confirmed zero allowance before changing a nonzero allowance; this behavior is not automated by the helper.

### Simulate and execute

`simulateSwap()` calls the prepared transaction against current RPC state, using its executor and unchanged calldata. It requires sufficient input balance and, for ERC20 input, allowance. No state overrides are supplied. The returned `RouterExecutionReceipt` includes `userAmountOut`.

`executeSwap()` checks the executor signer and sends the transaction. It returns an ethers `TransactionResponse` without waiting for mining. `tx.wait()` may throw on revert or replacement; inspect the outcome before displaying success.

For expiry, input changes and artifact preservation, follow [Transaction Safety](https://docs.peach.ag/documentation/bsc/aggregator/editor/validation-approvals-and-expiry).

For BNB input or output, see [Native BNB](https://docs.peach.ag/documentation/bsc/aggregator/editor/direct-allowance/native-bnb).


---

# 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/direct-allowance.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.
