> For the complete documentation index, see [llms.txt](https://docs.native.org/native-dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.native.org/native-dev/build-with-native/swap-aggregators/firmquote-swap-apis/miscellaneous/compose-with-amm.md).

# Compose with AMM

### Flexible Input Amount

Since AMM swaps’ output amount is only fixed upon onchain execution, Native Relay RFQ is designed to handle flexible input (+10% or -50% of the original quoted input amount) to facilitate multi-hop routing with AMMs or other liquidity sources.

You may also use this feature to perform over-quote then under-fill in some solving cases.

To utilise this feature, there are two `uint256` in the final `tradeRFQT` interface:

* `actualSellerAmount`
* `actualMinOutputAmount`

By default, they are `0`, meaning the Native Router will execute the order with the exact input amount quoted. If the balance in your caller address is lower, the call will revert due to insufficient balance. This is common when the previous hop is an AMM and the output amount is impacted by slippage.

To avoid this, simply override the `actualSellerAmount` in the contract logic when executing the call.

You may choose to leave `actualMinOutputAmount` as 0. Native Router should automatically adapt based on the original quoted slippage control parameter.

{% hint style="warning" %}
Please note that in some rare cases, when the actual amount is greater than the original quoted amount, the Native Credit Pool may fail to facilitate the swap, as the actual amount is now larger than the original quote and is unexpected by the Native quoting backend.
{% endhint %}

### Locate the Parameters

To locate the parameters in calldata, you may decode the call using the Native Router ABI (all are verified on explorers), or use two fields in the `/firm-quote` return:

* `amountInOffset`
* `amountOutMinimumOffset`

They indicate the offset position (in bytes) of the `actualSellerAmount` and `actualMinOutputAmount` parameters within the returned calldata.

### Examples

#### Swap Tx Examples

* Native Swap without actual amount override:

  [Simulated Transaction | Tenderly](https://www.tdly.co/shared/simulation/4f93cb05-e1f6-487f-930b-b6ef2e28c319)
* The same Native Swap but with actual amount override:

  [Simulated Transaction | Tenderly](https://www.tdly.co/shared/simulation/92009070-2de3-4b27-b27e-21b7bf205da4)

  `4629988946865908500000` → `4167453051074000000000` (-9.99% underfill)

#### Parameters Locating Example

From this decoded swap tx: <https://www.tdly.co/shared/simulation/a378d5e6-f3d4-439d-a203-798c94c05136>

We see the override value being `73684281000000000000`.

From `/firm-quote` the `amountInOffset` is `36`.

According to the offset value we may extract the encoded data from location 72 to 136 (64 characters), excluding the leading `0x`.

The extracted value is `000000000000000000000000000000000000000000000003fe93272c67109000` which represents the `actualSellerAmount` value `73684281000000000000`


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.native.org/native-dev/build-with-native/swap-aggregators/firmquote-swap-apis/miscellaneous/compose-with-amm.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
