> For the complete documentation index, see [llms.txt](https://docs.liqd.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.liqd.ag/liquidswap-integration/execution.md).

# Execution

Execute swaps by sending the ready-to-use `calldata` from the [route finding](/liquidswap-integration/route-finding.md) API to the `RouterV2` contract. That calldata encodes a call to `executeSwaps` or `executeSwapsWithData`.

Always use the `execution.to` address from the route response.

| Chain                    | RouterV2                                     |
| ------------------------ | -------------------------------------------- |
| HyperEVM (`999`)         | `0x744489ee3d540777a66f2cf297479745e0852f7a` |
| Robinhood Chain (`4663`) | `0xfc020bBCe0365f56bbBb78Ce504cE2a2b24E0ae6` |

## Using Calldata from the Route API

```javascript
const response = await fetch(
  'https://api.liqd.ag/v2/route?tokenIn=0x5555...&tokenOut=0xB8CE...&amountIn=100&chainId=999'
);
const routeData = await response.json();

if (routeData.success && routeData.execution) {
  const transaction = {
    to: routeData.execution.to,
    data: routeData.execution.calldata,
    value: 0, // set if swapping from the chain's native token
  };

  const result = await signer.sendTransaction(transaction);
}
```

Fees and positive slippage are already encoded in the calldata when you pass `feeBps` / `feeRecipient` on the route request. See [Revenue Sharing](/liquidswap-integration/overview.md#revenue-sharing).

## executeSwaps

Primary execution function. Provides positive slippage capture (50% capture rate) and custom fee collection:

```solidity
function executeSwaps(
    address[] calldata tokens,
    uint256 amountIn,
    uint256 minAmountOut,
    uint256 expectedAmountOut,
    Swap[][] calldata hopSwaps,
    uint256 feeBps,
    address feeRecipient
) external payable nonReentrant returns (uint256 userAmountOut)
```

| Name                | Type       | Description                                  |
| ------------------- | ---------- | -------------------------------------------- |
| `tokens`            | address\[] | Token addresses representing the swap path   |
| `amountIn`          | uint256    | Amount of input tokens to swap               |
| `minAmountOut`      | uint256    | Minimum output (slippage protection)         |
| `expectedAmountOut` | uint256    | Expected output (used for positive slippage) |
| `hopSwaps`          | Swap\[]\[] | Swap configurations for each hop             |
| `feeBps`            | uint256    | Fee in basis points (capped at 100 = 1%)     |
| `feeRecipient`      | address    | Receives 97.5% of the fee (2.5% to protocol) |

```solidity
struct Swap {
    address tokenIn;
    address tokenOut;
    uint8 routerIndex;
    uint24 fee;
    uint256 amountIn;
    bool stable;
}
```

## executeSwapsWithData

Same fee and slippage model as `executeSwaps`, but each hop can carry an opaque per-pool `data` blob for sources that need more than `(fee, stable)` to identify a pool. Legs with empty `data` behave like legacy `Swap` legs.

```solidity
function executeSwapsWithData(
    address[] calldata tokens,
    uint256 amountIn,
    uint256 minAmountOut,
    uint256 expectedAmountOut,
    SwapV2[][] calldata hopSwaps,
    uint256 feeBps,
    address feeRecipient
) external payable nonReentrant returns (uint256 userAmountOut)
```

```solidity
struct SwapV2 {
    address tokenIn;
    address tokenOut;
    uint8 routerIndex;
    uint24 fee;
    uint256 amountIn;
    bool stable;
    bytes data;
}
```

You do not need to call these functions manually — use the returned `execution.calldata` instead.

## Native Token Unwrapping

Set `unwrapNative=true` on the route request to receive the chain's native token instead of its wrapped form — HYPE on HyperEVM, ETH on Robinhood Chain. The returned calldata handles unwrapping automatically in the same transaction.

When unwrapping is enabled, the final output token in the path is the dead address `0x000000000000000000000000000000000000dEaD`, which `RouterV2` treats as the native token.


---

# 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.liqd.ag/liquidswap-integration/execution.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.
