# Quote a swap

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

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

Quote a swap without sending a transaction. `protocolFee` goes to liquidity providers; `ammFee` stays in the pool.

## Request body

`LDSwapRequest`, application/json.

- `amountIn` (string, required): Total handed to the pool, fees included — this is what leaves the wallet. Decimal string. 
- `ergIn` (boolean, required): True to sell ERG for the token, false to sell the token for ERG

## Responses

### 200: Quote for the requested swap

`LDSwapQuote`

- `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. 

### 400: Malformed body, or a non-positive amount.

`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/swap/check" \
  -H "Content-Type: application/json" \
  -d '{ "amountIn": "1000000000", "ergIn": true }'
```

## Example response

```json
{
  "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
}
```
