# Quotes & Swaps

##

This guide explains how to get exact swap quotes and find the best trading paths (multi-hop) using the Dozer Pool Manager.

### Contract IDs

* **Mainnet**: `000080350ca5ef204bc29b3232bb197e12bec6b473f5e6bdb749a6921197e83c`
* **Testnet**: `00000eecf6a990576c12bfa9e12ee089a5b1ea65e6de1456687ba1f4dc7fd463`

***

### 1. Best Swap Path (Quote)

Calculate the optimal swap path and expected output amount for a given input. This method checks direct pools and multi-hop paths to find the best price.

**Method**: `find_best_swap_path(amount_in, token_in, token_out, max_hops)`\
**Args**:

* `amount_in` (Integer): The input amount (remember to include decimals).
* `token_in` (Hex String): UID of the token being sold.
* `token_out` (Hex String): UID of the token being bought.
* `max_hops` (Integer): Maximum trading pairs to route through (e.g., 2 or 3).

#### Example Request

Get a quote for swapping **100 HTR** (`00`) to **hUSDC**.

* `amount_in` = 100 \* 10^0 = 100 (HTR is 2 decimals? No, native HTR is handled as integer cents usually? Actually contract uses 8 decimals for pricing but reserves are native. Let's assume input is 100 units).
* *Wait, HTR decimals on Hathor are 2, but the contract might use raw integer values. Always check token decimals.*

```bash
# Example: Swap 1000 HTR (10.00) for hUSDC
AMOUNT_IN=1000
TOKEN_IN="00"
TOKEN_OUT="00008035..." # hUSDC UID
MAX_HOPS=2

curl -s -G "https://node1.mainnet.hathor.network/v1a/nano_contract/state" \
  --data-urlencode "id=000080350ca5ef204bc29b3232bb197e12bec6b473f5e6bdb749a6921197e83c" \
  --data-urlencode "calls[]=find_best_swap_path($AMOUNT_IN, \"$TOKEN_IN\", \"$TOKEN_OUT\", $MAX_HOPS)" \
  | jq
```

#### Response Structure

Returns a `SwapPathInfo` object.

```json
{
  "return": [
    "00/UID.../80",   // path (string of pool keys joined by +?)
    [100, 200],       // amounts (List of amounts for each hop)
    95000,            // amount_out (The final output amount)
    50                // price_impact (Basis points, 50 = 0.5%)
  ]
}
```

***

### 2. Simple Quote (No Fees)

Get a simple `k = x * y` quote for a single pair without considering fees or liquidity depths. Useful for quick estimations but **not** for actual execution.

**Method**: `quote(amount_a, reserve_a, reserve_b)`\
**Args**: Inputs for the constant product formula.

**Note**: You must fetch reserves first using `get_reserves` to use this method effectively. We recommend using `find_best_swap_path` instead for accuracy.


---

# Agent Instructions: 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:

```
GET https://docs.dozer.finance/apis/quotes-and-swaps.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
