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

# Swapping Through Hadron

Build a swap instruction.

```rust theme={null}
use hadron_sdk_v2::types::SwapParams;

let ix = pool.swap(&user, &SwapParams {
    is_x: true,            // true = sell X for Y, false = sell Y for X
    amount_in: 1_000_000,  // in atoms
    min_out: 950_000,      // minimum acceptable output — set this to protect against slippage
    fee_recipient,
    expiration: None,
});
```

| **Param**              | **Type**      | **Description**                                                                                                                                           |
| ---------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `user`                 | `&Pubkey`     | The user's wallet                                                                                                                                         |
| `params.is_x`          | `bool`        | Direction: `true` = X→Y, `false` = Y→X                                                                                                                    |
| `params.amount_in`     | `u64`         | Input amount in token atoms                                                                                                                               |
| `params.min_out`       | `u64`         | Minimum output amount. The transaction fails with `SlippageExceeded` (error 8) if the pool cannot fill at this level or better. Set to `0` only in tests. |
| `params.fee_recipient` | `Pubkey`      | Address that receives the operator's fee portion of the spread                                                                                            |
| `params.expiration`    | `Option<i64>` | Optional slot deadline — transaction fails with `Expired` (error 38) after this slot                                                                      |

> **Multi-pool routing** Hadron does not currently support native matching across multiple propAMMs for the same asset. For multi-pool routing, use one of the supported aggregators or contact the Hadron team.
