# Liquidity

Liquidity provider operations.

## Get liquidity withdrawal quote

> Calculate how much of each token the user will receive when redeeming LP tokens.

```json
{"openapi":"3.0.3","info":{"title":"Tradecraft AMM HTTP API","version":"0.1.8.7"},"tags":[{"name":"Liquidity","description":"Liquidity provider operations."}],"servers":[{"url":"https://api.tradecraft.fi/v1","description":"Mainnet"}],"paths":{"/quoteLPWithdrawal/{tokenA}/{tokenB}":{"get":{"summary":"Get liquidity withdrawal quote","description":"Calculate how much of each token the user will receive when redeeming LP tokens.","operationId":"getQuoteLiquidityWithdrawal","tags":["Liquidity"],"parameters":[{"$ref":"#/components/parameters/tokenA"},{"$ref":"#/components/parameters/tokenB"},{"name":"lpTokenAmount","in":"query","required":true,"description":"The amount of LP tokens to redeem","schema":{"type":"number","format":"double","minimum":0,"exclusiveMinimum":true}}],"responses":{"200":{"description":"Liquidity withdrawal quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuoteLPWithdrawalResponse"}}}},"400":{"description":"Invalid parameters or liquidity pool not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"parameters":{"tokenA":{"name":"tokenA","in":"path","required":true,"description":"The name/symbol of the first token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}},"tokenB":{"name":"tokenB","in":"path","required":true,"description":"The name/symbol of the second token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}}},"schemas":{"QuoteLPWithdrawalResponse":{"type":"object","required":["amount_instrument_1","amount_instrument_2"],"properties":{"amount_instrument_1":{"type":"number","format":"double","description":"Amount of instrument 1 to receive."},"amount_instrument_2":{"type":"number","format":"double","description":"Amount of instrument 2 to receive."}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message"}}}}}}
```

## Get liquidity deposit quote

> Calculate the maximum LP tokens that can be minted given the provided amounts of both instruments.\
> Returns the optimal deposit amounts maintaining the pool ratio.<br>

```json
{"openapi":"3.0.3","info":{"title":"Tradecraft AMM HTTP API","version":"0.1.8.7"},"tags":[{"name":"Liquidity","description":"Liquidity provider operations."}],"servers":[{"url":"https://api.tradecraft.fi/v1","description":"Mainnet"}],"paths":{"/quoteLPDeposit/{tokenA}/{tokenB}":{"get":{"summary":"Get liquidity deposit quote","description":"Calculate the maximum LP tokens that can be minted given the provided amounts of both instruments.\nReturns the optimal deposit amounts maintaining the pool ratio.\n","operationId":"getQuoteLiquidityDeposit","tags":["Liquidity"],"parameters":[{"$ref":"#/components/parameters/tokenA"},{"$ref":"#/components/parameters/tokenB"},{"name":"instrument1Amount","in":"query","required":true,"description":"The amount of instrument 1 available for deposit","schema":{"type":"number","format":"double","minimum":0}},{"name":"instrument2Amount","in":"query","required":true,"description":"The available amount of instrument 2 available for deposit","schema":{"type":"number","format":"double","minimum":0}}],"responses":{"200":{"description":"Liquidity deposit quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuoteLPDepositResponse"}}}},"400":{"description":"Invalid parameters or liquidity pool not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"parameters":{"tokenA":{"name":"tokenA","in":"path","required":true,"description":"The name/symbol of the first token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}},"tokenB":{"name":"tokenB","in":"path","required":true,"description":"The name/symbol of the second token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}}},"schemas":{"QuoteLPDepositResponse":{"type":"object","required":["lp_tokens_to_mint","instrument_1_to_deposit","instrument_2_to_deposit"],"properties":{"lp_tokens_to_mint":{"type":"number","format":"double","description":"Amount of LP tokens that will be minted."},"instrument_1_to_deposit":{"type":"number","format":"double","description":"Amount of instrument 1 required for deposit."},"instrument_2_to_deposit":{"type":"number","format":"double","description":"Amount of instrument 2 required for deposit."}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message"}}}}}}
```

## Get pool yield/APY

> Returns annualized percentage yield (APY) calculations for the pool across multiple time periods.\
> APY is calculated based on the growth of value per LP token (k / lpSupply) over time.\
> Requires Apollo DB connection for historical data; returns empty yield data if unavailable.<br>

```json
{"openapi":"3.0.3","info":{"title":"Tradecraft AMM HTTP API","version":"0.1.8.7"},"tags":[{"name":"Liquidity","description":"Liquidity provider operations."}],"servers":[{"url":"https://api.tradecraft.fi/v1","description":"Mainnet"}],"paths":{"/yield/{tokenA}/{tokenB}":{"get":{"summary":"Get pool yield/APY","description":"Returns annualized percentage yield (APY) calculations for the pool across multiple time periods.\nAPY is calculated based on the growth of value per LP token (k / lpSupply) over time.\nRequires Apollo DB connection for historical data; returns empty yield data if unavailable.\n","operationId":"getPoolYield","tags":["Liquidity"],"parameters":[{"$ref":"#/components/parameters/tokenA"},{"$ref":"#/components/parameters/tokenB"}],"responses":{"200":{"description":"Pool yield data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PoolYieldResponse"}}}},"400":{"description":"AMM not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"parameters":{"tokenA":{"name":"tokenA","in":"path","required":true,"description":"The name/symbol of the first token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}},"tokenB":{"name":"tokenB","in":"path","required":true,"description":"The name/symbol of the second token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}}},"schemas":{"PoolYieldResponse":{"type":"object","required":["pool_id","yield"],"properties":{"pool_id":{"type":"string","description":"The AMM pool identifier"},"yield":{"type":"object","additionalProperties":{"type":"number","format":"double"},"description":"Map of time period labels to annualized percentage yield (APY) values.\nKeys are time periods (1h, 4h, 12h, 1d, 2d, 3d, 7d, 14d, 30d).\nValues are APY as decimals (e.g., 0.05 = 5% APY).\nA value of 0 indicates insufficient data for that period.\n"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message"}}}}}}
```

## Get historical yield/APY over time

> Returns an array of timestamped APY data points for the pool.\
> Each data point represents the annualized yield during that time interval,\
> calculated based on the growth of value per LP token (sqrt(k) / lpSupply).\
> Timestamps are aligned to interval boundaries (e.g., top of minute, top of hour, midnight).\
> \
> Available windows:\
> \- hour: 60 data points at 1-minute intervals\
> \- day: 288 data points at 5-minute intervals\
> \- week: 168 data points at 1-hour intervals\
> \
> Requires Apollo DB connection for historical data.<br>

```json
{"openapi":"3.0.3","info":{"title":"Tradecraft AMM HTTP API","version":"0.1.8.7"},"tags":[{"name":"Liquidity","description":"Liquidity provider operations."}],"servers":[{"url":"https://api.tradecraft.fi/v1","description":"Mainnet"}],"paths":{"/yield_history/{tokenA}/{tokenB}":{"get":{"summary":"Get historical yield/APY over time","description":"Returns an array of timestamped APY data points for the pool.\nEach data point represents the annualized yield during that time interval,\ncalculated based on the growth of value per LP token (sqrt(k) / lpSupply).\nTimestamps are aligned to interval boundaries (e.g., top of minute, top of hour, midnight).\n\nAvailable windows:\n- hour: 60 data points at 1-minute intervals\n- day: 288 data points at 5-minute intervals\n- week: 168 data points at 1-hour intervals\n\nRequires Apollo DB connection for historical data.\n","operationId":"getPoolYieldHistory","tags":["Liquidity"],"parameters":[{"$ref":"#/components/parameters/tokenA"},{"$ref":"#/components/parameters/tokenB"},{"name":"window","in":"query","required":true,"description":"The time window for the yield history","schema":{"type":"string","enum":["hour","day","week"]}}],"responses":{"200":{"description":"Historical yield data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PoolYieldHistoryResponse"}}}},"400":{"description":"AMM not found or invalid window","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"parameters":{"tokenA":{"name":"tokenA","in":"path","required":true,"description":"The name/symbol of the first token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}},"tokenB":{"name":"tokenB","in":"path","required":true,"description":"The name/symbol of the second token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}}},"schemas":{"PoolYieldHistoryResponse":{"type":"object","required":["pool_id","window","history"],"properties":{"pool_id":{"type":"string","description":"The AMM pool identifier"},"window":{"type":"string","description":"The requested time window","enum":["hour","day","week"]},"history":{"type":"array","description":"Array of timestamped APY data points, ordered from oldest to newest","items":{"$ref":"#/components/schemas/YieldHistoryDataPoint"}}}},"YieldHistoryDataPoint":{"type":"object","required":["timestamp","apy"],"properties":{"timestamp":{"type":"string","format":"date-time","description":"The start of the time interval (RFC3339 format)"},"apy":{"type":"number","format":"double","description":"Annualized percentage yield during this interval (e.g., 0.05 = 5% APY)"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message"}}}}}}
```

## Get pool trading volume in USD

> Returns USD-denominated trading volume for the pool across multiple time periods.\
> Volume is calculated by tracking changes in AMM reserves between consecutive states.\
> Each swap is converted to USD at the exchange rate that was active at the time of that swap.\
> USD conversion is performed using:\
> \- Stablecoins (SBC, USDCx): 1:1 with USD\
> \- CC (Canton Coin): Historical exchange rate from OpenMiningRound contracts via Scan ACS API\
> Returns an error if neither token can be converted to USD.<br>

```json
{"openapi":"3.0.3","info":{"title":"Tradecraft AMM HTTP API","version":"0.1.8.7"},"tags":[{"name":"Liquidity","description":"Liquidity provider operations."}],"servers":[{"url":"https://api.tradecraft.fi/v1","description":"Mainnet"}],"paths":{"/volume/{tokenA}/{tokenB}":{"get":{"summary":"Get pool trading volume in USD","description":"Returns USD-denominated trading volume for the pool across multiple time periods.\nVolume is calculated by tracking changes in AMM reserves between consecutive states.\nEach swap is converted to USD at the exchange rate that was active at the time of that swap.\nUSD conversion is performed using:\n- Stablecoins (SBC, USDCx): 1:1 with USD\n- CC (Canton Coin): Historical exchange rate from OpenMiningRound contracts via Scan ACS API\nReturns an error if neither token can be converted to USD.\n","operationId":"getPoolVolume","tags":["Liquidity"],"parameters":[{"$ref":"#/components/parameters/tokenA"},{"$ref":"#/components/parameters/tokenB"}],"responses":{"200":{"description":"Pool volume data in USD","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PoolVolumeResponse"}}}},"400":{"description":"AMM not found or cannot calculate USD volume","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"parameters":{"tokenA":{"name":"tokenA","in":"path","required":true,"description":"The name/symbol of the first token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}},"tokenB":{"name":"tokenB","in":"path","required":true,"description":"The name/symbol of the second token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}}},"schemas":{"PoolVolumeResponse":{"type":"object","required":["pool_id","volume_usd"],"properties":{"pool_id":{"type":"string","description":"The AMM pool identifier"},"volume_usd":{"type":"object","additionalProperties":{"type":"number","format":"double"},"description":"Map of time period labels to USD-denominated trading volume.\nKeys are time periods (1h, 4h, 12h, 1d, 2d, 3d, 7d, 14d, 30d).\nValues are the total swap volume in USD for that period.\nUSD conversion uses stablecoin rates (1:1) or CC exchange rate from Scan API.\n"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message"}}}}}}
```

## Get historical trading volume over time

> Returns an array of timestamped volume data points for the pool.\
> Each data point represents the USD-denominated trading volume during that time interval.\
> Timestamps are aligned to interval boundaries (e.g., top of minute, top of hour, midnight).\
> \
> Available windows:\
> \- hour: 60 data points at 1-minute intervals\
> \- day: 288 data points at 5-minute intervals\
> \- week: 168 data points at 1-hour intervals\
> \
> Volume calculation uses the same methodology as /volume endpoint.<br>

```json
{"openapi":"3.0.3","info":{"title":"Tradecraft AMM HTTP API","version":"0.1.8.7"},"tags":[{"name":"Liquidity","description":"Liquidity provider operations."}],"servers":[{"url":"https://api.tradecraft.fi/v1","description":"Mainnet"}],"paths":{"/volume_history/{tokenA}/{tokenB}":{"get":{"summary":"Get historical trading volume over time","description":"Returns an array of timestamped volume data points for the pool.\nEach data point represents the USD-denominated trading volume during that time interval.\nTimestamps are aligned to interval boundaries (e.g., top of minute, top of hour, midnight).\n\nAvailable windows:\n- hour: 60 data points at 1-minute intervals\n- day: 288 data points at 5-minute intervals\n- week: 168 data points at 1-hour intervals\n\nVolume calculation uses the same methodology as /volume endpoint.\n","operationId":"getPoolVolumeHistory","tags":["Liquidity"],"parameters":[{"$ref":"#/components/parameters/tokenA"},{"$ref":"#/components/parameters/tokenB"},{"name":"window","in":"query","required":true,"description":"The time window for the volume history","schema":{"type":"string","enum":["hour","day","week"]}}],"responses":{"200":{"description":"Historical volume data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PoolVolumeHistoryResponse"}}}},"400":{"description":"AMM not found, invalid window, or cannot calculate USD volume","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"parameters":{"tokenA":{"name":"tokenA","in":"path","required":true,"description":"The name/symbol of the first token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}},"tokenB":{"name":"tokenB","in":"path","required":true,"description":"The name/symbol of the second token (URL encoded).","schema":{"type":"string","enum":["CC","USDCx","CBTC","CETH","HANDL"]}}},"schemas":{"PoolVolumeHistoryResponse":{"type":"object","required":["pool_id","window","history"],"properties":{"pool_id":{"type":"string","description":"The AMM pool identifier"},"window":{"type":"string","description":"The requested time window","enum":["hour","day","week"]},"history":{"type":"array","description":"Array of timestamped volume data points, ordered from oldest to newest","items":{"$ref":"#/components/schemas/VolumeHistoryDataPoint"}}}},"VolumeHistoryDataPoint":{"type":"object","required":["timestamp","volume_usd"],"properties":{"timestamp":{"type":"string","format":"date-time","description":"The start of the time interval (RFC3339 format)"},"volume_usd":{"type":"number","format":"double","description":"Trading volume in USD during this interval"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message"}}}}}}
```


---

# 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.tradecraft.fi/api/routes/liquidity.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.
