> For the complete documentation index, see [llms.txt](https://docs.tradecraft.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tradecraft.fi/api/routes/quotes.md).

# Quotes

Trade quote calculations.

## Get trade quote for fixed input

> Calculate how much of token B the user will receive when providing a fixed amount of token A.\
> Uses the constant product formula with double-sided fees.\
> &#x20;Note that token A and token B do not always correlate to the first and second tokens in the pool name.<br>

```json
{"openapi":"3.0.3","info":{"title":"Tradecraft AMM HTTP API","version":"1.29.0"},"tags":[{"name":"Quotes","description":"Trade quote calculations."}],"servers":[{"url":"https://api.tradecraft.fi/v1","description":"Mainnet"},{"url":"https://tradecraft.validator.test.canton.obsidian.systems/amm-http-api","description":"Testnet"},{"url":"https://tradecraft.validator.dev.canton.obsidian.systems/amm-http-api","description":"Devnet"}],"paths":{"/quoteForFixedInput/{tokenA}/{tokenB}":{"get":{"summary":"Get trade quote for fixed input","description":"Calculate how much of token B the user will receive when providing a fixed amount of token A.\nUses the constant product formula with double-sided fees.\n Note that token A and token B do not always correlate to the first and second tokens in the pool name.\n","operationId":"getQuoteTradeFixedInput","tags":["Quotes"],"parameters":[{"$ref":"#/components/parameters/tokenA"},{"$ref":"#/components/parameters/tokenB"},{"name":"givingAmount","in":"query","required":true,"description":"The amount of token A the user is giving","schema":{"type":"number","format":"double","minimum":0,"exclusiveMinimum":true}}],"responses":{"200":{"description":"Trade quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuoteTradeFixedInputResponse"}}}},"400":{"description":"Invalid parameters or 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","EDELx","SBC"]}},"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","EDELx","SBC"]}}},"schemas":{"QuoteTradeFixedInputResponse":{"type":"object","required":["user_gets"],"properties":{"user_gets":{"type":"number","format":"double","description":"The amount of output token the user will receive."}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message"}}}}}}
```

## Get trade quote for fixed output

> Calculate how much of token A the user must provide to receive a fixed amount of token B.\
> Uses the constant product formula with double-sided fees.\
> &#x20;Note that token A and token B do not always correlate to the first and second tokens in the pool name.<br>

```json
{"openapi":"3.0.3","info":{"title":"Tradecraft AMM HTTP API","version":"1.29.0"},"tags":[{"name":"Quotes","description":"Trade quote calculations."}],"servers":[{"url":"https://api.tradecraft.fi/v1","description":"Mainnet"},{"url":"https://tradecraft.validator.test.canton.obsidian.systems/amm-http-api","description":"Testnet"},{"url":"https://tradecraft.validator.dev.canton.obsidian.systems/amm-http-api","description":"Devnet"}],"paths":{"/quoteForFixedOutput/{tokenA}/{tokenB}":{"get":{"summary":"Get trade quote for fixed output","description":"Calculate how much of token A the user must provide to receive a fixed amount of token B.\nUses the constant product formula with double-sided fees.\n Note that token A and token B do not always correlate to the first and second tokens in the pool name.\n","operationId":"getQuoteTradeFixedOutput","tags":["Quotes"],"parameters":[{"$ref":"#/components/parameters/tokenA"},{"$ref":"#/components/parameters/tokenB"},{"name":"gettingAmount","in":"query","required":true,"description":"The amount of token B the user wants to receive","schema":{"type":"number","format":"double","minimum":0,"exclusiveMinimum":true}}],"responses":{"200":{"description":"Trade quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuoteTradeFixedOutputResponse"}}}},"400":{"description":"Invalid parameters or 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","EDELx","SBC"]}},"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","EDELx","SBC"]}}},"schemas":{"QuoteTradeFixedOutputResponse":{"type":"object","required":["user_gives"],"properties":{"user_gives":{"type":"number","format":"double","description":"The amount of input token the user must provide."}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message"}}}}}}
```

## Get V7 concentrated-liquidity swap quote

> Computes an exact-input swap quote for a V7 concentrated-liquidity pool.\
> Given an input token, an output token, and an input amount, returns how\
> much output the caller would receive at the current pool state.\
> \
> The quote runs the full tick-traversal math against a live snapshot of\
> the pool fetched from Apollo, so the result reflects the current sqrt\
> price, active liquidity, and all initialized tick shards.\
> \
> \`amount\` is a scale-10 decimal string. Whole numbers ("100") and\
> decimals ("100.5") are both accepted; the engine pads to ten decimal\
> places internally.\
> \
> \`partial\` is true when the pool ran out of liquidity before the full\
> input was consumed. In that case \`remaining\` reports the unconsumed\
> portion and \`input\` reflects what was actually swapped.<br>

```json
{"openapi":"3.0.3","info":{"title":"Tradecraft AMM HTTP API","version":"1.29.0"},"tags":[{"name":"Quotes","description":"Trade quote calculations."}],"servers":[{"url":"https://api.tradecraft.fi/v1","description":"Mainnet"},{"url":"https://tradecraft.validator.test.canton.obsidian.systems/amm-http-api","description":"Testnet"},{"url":"https://tradecraft.validator.dev.canton.obsidian.systems/amm-http-api","description":"Devnet"}],"paths":{"/v7/swap/quote/{inputToken}/{outputToken}":{"get":{"summary":"Get V7 concentrated-liquidity swap quote","description":"Computes an exact-input swap quote for a V7 concentrated-liquidity pool.\nGiven an input token, an output token, and an input amount, returns how\nmuch output the caller would receive at the current pool state.\n\nThe quote runs the full tick-traversal math against a live snapshot of\nthe pool fetched from Apollo, so the result reflects the current sqrt\nprice, active liquidity, and all initialized tick shards.\n\n`amount` is a scale-10 decimal string. Whole numbers (\"100\") and\ndecimals (\"100.5\") are both accepted; the engine pads to ten decimal\nplaces internally.\n\n`partial` is true when the pool ran out of liquidity before the full\ninput was consumed. In that case `remaining` reports the unconsumed\nportion and `input` reflects what was actually swapped.\n","operationId":"getSwapQuoteV7","tags":["Quotes"],"parameters":[{"name":"inputToken","in":"path","required":true,"description":"Instrument id of the token being sold (e.g. \"USDC\", \"BTC\").","schema":{"type":"string"}},{"name":"outputToken","in":"path","required":true,"description":"Instrument id of the token being bought (e.g. \"BTC\", \"ETH\").","schema":{"type":"string"}},{"name":"amount","in":"query","required":true,"description":"Amount of the input token to sell, as a scale-10 decimal string.\nExamples: \"100\", \"100.5\", \"0.0001\".\n","schema":{"type":"string"}}],"responses":{"200":{"description":"Swap quote result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwapQuoteV7Response"}}}},"400":{"description":"Invalid parameters, pool not found, or quote math error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No V7 pool found for the given token pair","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal error fetching pool state or computing the quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"SwapQuoteV7Response":{"type":"object","required":["input","output","feeAmount","remaining","partial","state","tickUpdates","debit","credit","fee"],"properties":{"input":{"type":"string","description":"Settled input amount including fees, as a scale-10 decimal string."},"output":{"type":"string","description":"Settled output amount, as a scale-10 decimal string."},"feeAmount":{"type":"string","description":"Total LP and protocol fee charged, as a scale-20 raw decimal string."},"remaining":{"type":"string","description":"Unconsumed input, as a scale-20 raw decimal string. Non-zero only\nwhen the pool ran out of liquidity before the full input was swapped.\n"},"partial":{"type":"boolean","description":"True when remaining > 0, meaning the swap was only partially filled."},"state":{"$ref":"#/components/schemas/V7PoolState"},"tickUpdates":{"type":"array","description":"Tick states that changed during the swap (crossed ticks with updated fee growth).","items":{"$ref":"#/components/schemas/V7TickUpdate"}},"debit":{"type":"string","description":"Total the trader pays, including an operator fee on the input leg, as a scale-10 decimal string."},"credit":{"type":"string","description":"Net the trader receives, after an operator fee on the output leg, as a scale-10 decimal string."},"fee":{"type":"string","description":"Operator fee charged, as a scale-10 decimal string. Zero when the pool has no single-instrument fee source."}}},"V7PoolState":{"type":"object","description":"Pool state after the hypothetical swap.","required":["sqrtPrice","currentTick","liquidity","feeGrowthGlobal1","feeGrowthGlobal2","protocolFees1","protocolFees2"],"properties":{"sqrtPrice":{"type":"string","description":"Square root of the new pool price, as a scale-20 decimal string."},"currentTick":{"type":"integer","format":"int64","description":"Tick index corresponding to the new sqrt price."},"liquidity":{"type":"string","description":"Active liquidity after the swap, as a scale-10 decimal string."},"feeGrowthGlobal1":{"type":"string","description":"Cumulative fee growth per unit of liquidity for instrument 1, scale-20."},"feeGrowthGlobal2":{"type":"string","description":"Cumulative fee growth per unit of liquidity for instrument 2, scale-20."},"protocolFees1":{"type":"string","description":"Accrued protocol fees for instrument 1, scale-20."},"protocolFees2":{"type":"string","description":"Accrued protocol fees for instrument 2, scale-20."}}},"V7TickUpdate":{"type":"object","description":"Updated state of one tick crossed during the swap.","required":["shardKey","tick"],"properties":{"shardKey":{"type":"integer","format":"int64","description":"Shard key of the tick's containing shard."},"tick":{"type":"object","required":["index","liquidityGross","liquidityNet","feeGrowthOutside1","feeGrowthOutside2"],"properties":{"index":{"type":"integer","format":"int64","description":"Tick index."},"liquidityGross":{"type":"string","description":"Total liquidity referencing this tick, scale-10."},"liquidityNet":{"type":"string","description":"Liquidity delta when crossing this tick upward, scale-10."},"feeGrowthOutside1":{"type":"string","description":"Fee growth outside this tick for instrument 1, scale-20."},"feeGrowthOutside2":{"type":"string","description":"Fee growth outside this tick for instrument 2, scale-20."}}}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tradecraft.fi/api/routes/quotes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
