# Quote and trade

This page describes the **standard generation 2 Pair Router**. Use the [ABI and deployments](contracts.md), verify identities, and keep all monetary amounts in integer base units.

## Direct-pair quote

```solidity
quote(address curveAddress, bool isBuy, uint256 amount)
    returns (uint256 amountOut, uint256 spent, bool graduated)
```

| Direction | Input amount | Output |
| --- | --- | --- |
| Buy | Pairing ERC20 base units | Launched-token base units, net of the route's token tax/pool calculation |
| Sell | Launched-token base units | Pairing ERC20 base units, net of the route's token tax/pool calculation |

For a final curve buy, `spent` can be less than the offered amount. `graduated` is the phase observed by the quote. Reject zero output; it is not a successful executable quote.

This call does not quote the separate HYPE conversion leg or prove a wallet has funds, allowance, eligible recipient or sufficient conversion inventory. It is a read, not an execution simulation.

## Direct pairing-asset execution

```solidity
buyQuote(address curve, uint256 amount, uint256 minToken,
         address recipient, uint256 deadline, bool expectedPhase)
    returns (uint256 quoteSpent, uint256 tokensReceived)

sellQuote(address curve, uint256 amount, uint256 minQuote,
          address recipient, uint256 deadline, bool expectedPhase)
    returns (uint256 quoteReceived)
```

For a buy, the payer approves the **pairing ERC20 to the Pair Router**. For a sell, the payer approves the **launched token to the Pair Router**. Approval is neither to the curve nor to an arbitrary `router` property from metadata. Output goes to `recipient`; buy change goes back to `msg.sender`.

Choose the user's slippage bound, then compute `minimum = floor(quotedOutput × (10000 − slippageBps) / 10000)`. Require a positive minimum. A tiny quote can round down to zero and must be refused rather than weakening protection.

The deadline must be no earlier than the execution block's timestamp and no more than **300 seconds** ahead. Account for expected inclusion time; re-quote expired requests. `expectedPhase` must equal the curve's `graduated()` state at entry.

Simulate from the real payer using the exact target, calldata, native value, recipient and allowances. Estimate gas with graduation possible. A successful simulation is not a guarantee against state changing before inclusion.

## Native HYPE execution

```solidity
buyHype(address curve, uint256 minQuote, uint256 minToken,
        address recipient, uint256 deadline, bool expectedPhase) payable
    returns (uint256 quoteSpent, uint256 tokensReceived, uint256 quoteRefund)

sellHype(address curve, uint256 amount, uint256 minQuote, uint256 minHype,
         address recipient, uint256 deadline, bool expectedPhase)
    returns (uint256 quoteReceived, uint256 hypeReceived)
```

`buyHype` spends `msg.value` in native HYPE. A WHYPE pair uses wrapping; another pair requires an admitted conversion route. Protect **both** the conversion with `minQuote` and the token fill with `minToken`.

`sellHype` sells launched tokens, protects the intermediate pairing output with `minQuote`, and protects final native HYPE output with `minHype`. A pairing-asset quote cannot be reused as a HYPE quote.

If the conversion route is unavailable, report that condition. Do not silently select an unrelated pool or change the input/output asset. On a final buy, see the [refund asset rules](graduation.md).

## Before handing off to a wallet

Revalidate chain 999, token and route identity, wallet, amount, recipient, slippage, deadline and phase. Discard the prepared request if any material input changes. Keep the requested allowance bounded to the intended asset and spend.

After submission, reconcile the transaction hash and nonce before considering a retry. The successful receipt and verified logs establish the fill, not the earlier quote or an elapsed timer.
