# W Swap LP Price API

### Endpoint

* Method: `GET`
* Path: `/api/w-swap/lp-value/:id`

### Purpose

* Returns the latest price of the pair.
* Returns the estimated USD value of one LP token for the pair.
* Also returns the pair name for convenience.

### Request

* Path parameter `id` (number): The `trade_pairs.id` of the pair.

#### Example

```
GET /api/w-swap/lp-value/2
```

### Success Response

* Status: `200 OK`
* Body:

```json
{
  "latestPrice": 1.2345,
  "lpPriceInUsd": 0.5678,
  "pair": "USDT/WCO"
}
```

#### Field Details

* `latestPrice` (number): The latest exchange rate of the pair (token1 per token0 or vice versa depending on pair configuration).
* `lpPriceInUsd` (number): The estimated value of 1 LP token in USD.
* `pair` (string): The human-readable pair name from `trade_pairs.name`.

### Error Responses

* `400 Bad Request`: Missing `id` path parameter.

```json
{
  "statusCode": 400,
  "statusMessage": "Missing id parameter"
}
```

* `404 Not Found`: Price or pair not found (no matching `trade_pairs.id` or missing price data).

```json
{
  "statusCode": 404,
  "statusMessage": "Price not found"
}
```

### Supported Trade Pairs

The following trade pairs are supported by this API. Use the corresponding `ID` in the request URL.

| ID | Pair Name |
| -- | --------- |
| 1  | WAVE/WCO  |
| 2  | USDT/WCO  |
| 3  | USDC/WCO  |
| 4  | SOL/WCO   |
| 5  | DOGE/WCO  |
| 6  | XRP/WCO   |

### Implementation Notes

* The endpoint fetches the latest price and pair name in a single query for efficiency.
* Results are cached for 60 seconds (`maxAge: 60`, `swr: true`) to reduce database load and improve response times.
* Authentication is not required for this public endpoint.

### Related Endpoints

* `GET /api/w-swap/volume/:id` — returns the last 24 hours of traded volume (in USD).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.w-chain.com/advanced-features/w-swap-lp-price-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
