# Quote a swap order

`POST /dex/orders/swap/check` · Lithos client API · Lithos Dex

Source: https://lithosprotocol.org/docs/api/check-ld-swap-order

Quote a swap order against the current pool without placing it. The executor fee is paid on top of `amountIn` when selling ERG, and out of the ERG received when selling the token.

## Request body

`LDSwapOrderRequest`, application/json.

- `amountIn` (string, required): Total handed to the pool, pool fees included. The executor fee is separate. Decimal string. 
- `ergIn` (boolean, required): True to sell ERG for the token, false to sell the token for ERG
- `executorFee` (string): nanoERG paid to whoever fills the order. A fill broadcast to the mempool pays its miner fee out of this. Miners skip orders paying less than they accept. Omit for the client's default. Decimal string. 
- `maxMinerFee` (string): Most nanoERG a fill may pay as a miner fee, out of `executorFee`. Must be below `executorFee`. Omit for the client's default. Decimal string. 

## Responses

### 200: Quote for the requested swap order

`LDSwapOrderQuote`

- `swap` (LDSwapQuote, required): Quote for a LithosDex swap
  - `ergIn` (boolean, required)
  - `amountIn` (string, required): Total handed to the pool, fees included. Decimal string.
  - `protocolFee` (string, required): Taken out of the input and set aside for liquidity providers. Decimal string.
  - `ammFee` (string, required): The curve's own fee on the remainder; stays in the pool. Decimal string.
  - `tradedIn` (string, required): What actually reaches the curve — amountIn less protocolFee. Decimal string.
  - `amountOut` (string, required): What comes back. Decimal string.
  - `totalFee` (string, required): Every fee the swap pays, on the input side. Decimal string.
  - `spotBefore` (number · double, required): Pre-trade price, ignoring fees and depth
  - `spotAfter` (number · double, required): Price once the swap lands, ignoring fees
  - `executionPrice` (number · double, required): Output per unit of input, fees and depth included
  - `priceImpact` (number · double, required): How far execution fell short of the pre-trade price, as a fraction
  - `isExecutable` (boolean, required): False when the pool would reject the swap — nothing reaches the curve, or the output would meet or exceed the reserve it is drawn from. 
- `executorFee` (string, required): The executor fee applied, the request's or the client's default. Decimal string.
- `maxMinerFee` (string, required): The miner fee cap applied. Decimal string.
- `netOutput` (string, required): What the owner receives if the order fills against the current pool: `swap.amountOut`, less `executorFee` when selling the token. Negative when the fee exceeds the output, and such an order cannot fill. Decimal string. 
- `totalErgRequired` (string, required): nanoERG locked in the order box: `ergReturned`, plus `amountIn` and `executorFee` when selling ERG. Decimal string. 
- `ergReturned` (string, required): nanoERG of `totalErgRequired` returned to the owner with the fill. Decimal string.
- `networkFee` (string, required): nanoERG paid to place the order. Decimal string.

### 400: Malformed body, a non-positive `amountIn`, or a `maxMinerFee` not below `executorFee`.

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

### 503: Node unavailable. Retry.

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

### default: Error

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

## Example request

```bash
curl -X POST "http://localhost:9000/dex/orders/swap/check" \
  -H "Content-Type: application/json" \
  -d '{ "amountIn": "1000000000", "ergIn": true, "executorFee": "3000000", "maxMinerFee": "1000000" }'
```

## Example response

```json
{
  "swap": {
    "ergIn": true,
    "amountIn": "1000000000",
    "protocolFee": "1500000",
    "ammFee": "1497750",
    "tradedIn": "998500000",
    "amountOut": "30124883",
    "totalFee": "2997750",
    "spotBefore": 0.0302,
    "spotAfter": 0.0301,
    "executionPrice": 0.0301,
    "priceImpact": 0.0031,
    "isExecutable": true
  },
  "executorFee": "3000000",
  "maxMinerFee": "1000000",
  "netOutput": "30124883",
  "totalErgRequired": "1004000000",
  "ergReturned": "1000000",
  "networkFee": "2000000"
}
```
