# Place a deposit order

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

Source: https://lithosprotocol.org/docs/api/place-ld-deposit-order

Lock a deposit in an order that any miner can fill for `executorFee`. It fills only if the offer buys at least `minShares` against the pool when it executes, and waits otherwise. The fill sends the owner the new provision's `ownerNFT` and whatever the pool did not take.

## Request body

`LDDepositOrderExecuteRequest`, application/json.

- `amountX` (string, required): Most nanoERG the order offers to the reserves, not counting the provision box. Decimal string. 
- `amountY` (string, required): Raw token units the order offers. Decimal string.
- `minShares` (string, required): Fewest shares the order accepts, checked against the pool when it fills. Required and must be positive. A floor far under the quote's `shares` lets a pool moved earlier in the same block take the difference. Decimal string. 
- `executorFee` (string): nanoERG paid to whoever fills the order. 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: The placement transaction and the order it created

`LDOrderPlacementResult`

- `outcome` (string, required, one of accepted, rejected, uncertain): Node submission outcome; uncertain retains the known transaction ID and input ownership.
- `txId` (string, required)
- `order` (LDOrder, required): An outstanding LithosDex order owned by this wallet. Which term fields are present depends on `type`. 
  - `boxId` (string, required): Order box id. Pass it to `POST /dex/orders/{boxId}/cancel`.
  - `type` (string, required, one of SWAP, DEPOSIT, REDEEM)
  - `status` (string, required, one of PENDING, OPEN, FILLING, CANCELLING): PENDING: the placement is unconfirmed. OPEN: placed and waiting for a fill. FILLING: an unconfirmed transaction fills it. CANCELLING: an unconfirmed transaction cancels it. Only PENDING and OPEN orders can be cancelled. 
  - `placementTxId` (string, required): Transaction that created the order box
  - `placedHeight` (integer · int32): Height the placement confirmed at. Absent while it is unconfirmed.
  - `spendingTxId` (string): The unconfirmed transaction filling or cancelling the order. Present when FILLING or CANCELLING.
  - `owner` (string, required): Address that receives the fill, and the only key that can cancel
  - `value` (string, required): nanoERG held by the order box. Decimal string.
  - `executorFee` (string, required): nanoERG the order pays whoever fills it. Decimal string.
  - `maxMinerFee` (string, required): Most nanoERG a fill may pay as a miner fee, out of `executorFee`. Decimal string.
  - `ergIn` (boolean): SWAP only. True when selling ERG for the token.
  - `tokenIn` (string): A token/token SWAP only: the token sold.
  - `amountIn` (string): SWAP only. nanoERG or raw token units sold into the pool. Decimal string.
  - `minOutput` (string): SWAP only. Least the owner receives: tokens when selling ERG, or nanoERG after `executorFee` when selling the token. Decimal string. 
  - `amountX` (string): DEPOSIT only. Most nanoERG offered to the reserves. Decimal string.
  - `amountY` (string): DEPOSIT only. Raw token units offered. Decimal string.
  - `minShares` (string): DEPOSIT only. Fewest shares the order accepts. Decimal string.
  - `ownerNFT` (string): REDEEM only. Ownership NFT of the provision the order closes.
  - `provisionBoxId` (string): REDEEM only. Current box of that provision. Absent when it cannot be found.
  - `fillableNow` (boolean, required): Whether the order would fill against the current pool. False when the pool cannot meet the order's minimum or refuses it; the order waits until that changes or it is cancelled. Always true while `FILLING` and false while `CANCELLING`. 
- `claimedX` (string): REDEEM only. Settled ERG fees the placement claimed. Decimal string.
- `claimedY` (string): REDEEM only. Token side of `claimedX`. Decimal string.

### 400: Malformed body, a non-positive amount or `minShares`, 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

### 422: The pool has no provision tokens left, or the wallet cannot cover the order.

`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/orders/deposit" \
  -H "api_key: $LITHOS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "amountX": "5000000000", "amountY": "152000000", "minShares": "1170587", "executorFee": "3000000", "maxMinerFee": "1000000" }'
```

## Example response

```json
{
  "outcome": "accepted",
  "txId": "40b7d045a858d537cdbf072e46ffbb86c0c9f6b0e93c369c1ffcba76797636d7",
  "order": {
    "boxId": "5035b2e112b4f5b873dd3444c01df1e7e697807fd84fe96790eacb128e46428d",
    "type": "SWAP",
    "status": "OPEN",
    "placementTxId": "40b7d045a858d537cdbf072e46ffbb86c0c9f6b0e93c369c1ffcba76797636d7",
    "placedHeight": 484719,
    "spendingTxId": "9f3c1ab7d2e45806c91f7b3ad4e2091856cbf740e3a92d5178cc0b46e21f5d38",
    "owner": "3WwbzR34YmLRy3Z6WLON5hBBkX8Zm1gUHmC7tEXDNRJfHBqhsZr",
    "value": "1004000000",
    "executorFee": "3000000",
    "maxMinerFee": "1000000",
    "ergIn": true,
    "tokenIn": true,
    "amountIn": "1000000000",
    "minOutput": "29974258",
    "amountX": "5000000000",
    "amountY": "152000000",
    "minShares": "1170587",
    "ownerNFT": "a1f4c2e8b7d93052416fbc8e07d21935a8c4f60b2e91d7385c06a4b1f2e83d97",
    "provisionBoxId": "ce00d6e0f4fd3390c0519bb0d24824e1e6b06978163f4845a7cf2c1c7d8f1b65",
    "fillableNow": true
  },
  "claimedX": "253000000",
  "claimedY": "7690000"
}
```
