# Redeem liquidity

`POST /dex/redeem` · Lithos client API · Lithos Dex · requires the `api_key` header

Source: https://lithosprotocol.org/docs/api/ld-redeem

Close a provision directly and return its share of the reserves. **Unclaimed fees are lost when the provision is spent** — claim them first, or set `acknowledgeUnclaimedFees` to accept that. `POST /dex/orders/redeem` places a redemption as an order.

## Request body

`LDRedeemRequest`, application/json.

- `provisionBoxId` (string, required)
- `minAmountX` (string): Least you will accept back on the ERG side. Decimal string.
- `minAmountY` (string): The same on the token side. Decimal string.
- `expectedPoolBoxId` (string): The pool box this was quoted against
- `acknowledgeUnclaimedFees` (boolean): Must be true to redeem a provision that still has unclaimed fees, which are lost when it is spent. Ignored when there are none. 

## Responses

### 200: Result of the redemption transaction

`LDRedeemResult`

- `outcome` (string, required, one of accepted, rejected, uncertain): Node submission outcome; uncertain retains the known transaction ID and input ownership.
- `shares` (string, required)
- `amountX` (string, required)
- `amountY` (string, required)
- `txId` (string, required)

### 400: Malformed body, or the provision has unclaimed fees and `acknowledgeUnclaimedFees` was not set. 

`ApiError`

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

### 404: No live provision with that id.

`ApiError`

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

### 409: The pool or provision moved. Re-read and quote again.

`LDStateChangedResponse`

- `error` (integer, required)
- `reason` (string, required)
- `detail` (string, required): What moved, and what it moved to
- `poolBoxId` (string): Current pool box id
- `vaultBoxId` (string): Current vault box id
- `provisionBoxId` (string): Current provision box id

### 422: Returns less than the given bounds, or the pool refuses the redemption.

`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 or wallet 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/redeem" \
  -H "api_key: $LITHOS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "provisionBoxId": "ce00d6e0f4fd3390c0519bb0d24824e1e6b06978163f4845a7cf2c1c7d8f1b65", "minAmountX": "53125000000", "minAmountY": "1605000000", "expectedPoolBoxId": "a1f4c2e8b7d93052416fbc8e07d21935a8c4f60b2e91d7385c06a4b1f2e83d97", "acknowledgeUnclaimedFees": false }'
```

## Example response

```json
{
  "outcome": "accepted",
  "shares": "12500000000",
  "amountX": "53125000000",
  "amountY": "1605000000",
  "txId": "40b7d045a858d537cdbf072e46ffbb86c0c9f6b0e93c369c1ffcba76797636d7"
}
```
