# Swap Quotes

### Swap Details Endpoint

* **Endpoint:** `/swap/details`
* **Description:** This endpoint allows you to obtain the best exchange rate between two tokens and identify the best pool to perform the swap.
* **Response Includes:**
  * Best pool for performing the swap.
  * `amountIn` and `amountOut` values.
  * Network fees and liquidity provider fees.
  * Price impact of the swap.

#### Important Notes:

* **Swap from Rune to BTC:**
  * The `amountOut` provided by the `/swap/details` endpoint does not account for the network fees.
  * You need to subtract the network fees from the `amountOut` to get the correct amount to send to the endpoint.

## Get Swap Details

> Retrieves detailed information about a potential swap, including expected amounts and fees.

```json
{"openapi":"3.1.0","info":{"title":"@saturnbtcio/api","version":"0.0.1"},"tags":[{"name":"Swap"}],"servers":[{"url":"https://api-dev.saturnbtc.io","description":"Development Server"},{"url":"https://api.saturnbtc.io","description":"Production Server"}],"paths":{"/v0/pool/swap/details":{"get":{"summary":"Get Swap Details","description":"Retrieves detailed information about a potential swap, including expected amounts and fees.","tags":["Swap"],"parameters":[{"name":"feeRate","in":"query","schema":{"type":"integer","minimum":1},"required":true,"title":"The fee rate for the transaction (in sats per byte)","description":"The fee rate for the transaction (in sats per byte)."},{"name":"token0","in":"query","schema":{"type":"string"},"required":true,"description":"The identifier of the first token. Format: `0:0`"},{"name":"token1","in":"query","schema":{"type":"string"},"required":true,"description":"The identifier of the second token. Usually '0:0: (Bitcoin)"},{"name":"zeroToOne","in":"query","schema":{"type":"boolean"},"required":true,"title":"A boolean indicating whether to swap from token0 to token1","description":"A boolean indicating whether to swap from token0 to token1."},{"name":"exactIn","in":"query","schema":{"type":"boolean"},"required":true,"title":"A boolean indicating whether the swap is exact in","description":"A boolean indicating whether the swap is exact in."},{"name":"amount","in":"query","schema":{"type":"string","pattern":"^[1-9][0-9]*$"},"required":true}],"responses":{"200":{"description":"An object containing detailed swap information such as expected amounts, price, price impact, fees, and pool ID.","content":{"application/json":{"schema":{"type":"object","properties":{"amountIn":{"type":"string","title":"The amount of input token to swap","description":"The amount of input token to swap."},"amountOut":{"type":"string","title":"The amount of output token expected","description":"The amount of output token expected."},"price":{"type":"string","title":"The price of the swap","description":"The price of the swap."},"priceImpact":{"type":"string","title":"The price impact of the swap","description":"The price impact of the swap."},"fees":{"type":"object","properties":{"makers":{"type":"string","title":"The fee paid to the makers","description":"The fee paid to the makers."},"network":{"type":"string","title":"The fee paid to the network","description":"The fee paid to the network."}},"required":["makers","network"],"title":"The fees paid for the swap","description":"The fees paid for the swap."},"poolId":{"type":"string","title":"The identifier of the pool","description":"The identifier of the pool."}},"required":["amountIn","amountOut","price","priceImpact","fees","poolId"]}}}},"400":{"description":"Pool error","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/PoolNotFoundErrorByPoolId"},{"$ref":"#/components/schemas/PoolNotFoundErrorByToken"},{"$ref":"#/components/schemas/PoolAlreadyExistsError"},{"$ref":"#/components/schemas/InvalidFeeRateError"},{"$ref":"#/components/schemas/InvalidUtxoError"},{"$ref":"#/components/schemas/InvalidTokenError"},{"$ref":"#/components/schemas/NotEnoughFundsError"},{"$ref":"#/components/schemas/NotEnoughFundsForSplittingRuneError"},{"$ref":"#/components/schemas/ShardPubkeysRequiredError"},{"$ref":"#/components/schemas/RequestExpiredError"},{"$ref":"#/components/schemas/FailedToSendArchTransactionError"},{"$ref":"#/components/schemas/InvalidAddress"},{"$ref":"#/components/schemas/InvalidNumericValue"},{"$ref":"#/components/schemas/InvalidTxSizeError"},{"$ref":"#/components/schemas/InvalidRunestoneError"},{"$ref":"#/components/schemas/InvalidSignatureError"},{"$ref":"#/components/schemas/InvalidPsbtError"},{"$ref":"#/components/schemas/InvalidAmountBelowMinError"},{"$ref":"#/components/schemas/InvalidAmountError"},{"$ref":"#/components/schemas/InsufficientLiquidityError"},{"$ref":"#/components/schemas/ShardsUnavailableError"},{"$ref":"#/components/schemas/InvalidAssetPairError"},{"$ref":"#/components/schemas/InvalidFeeTierError"},{"$ref":"#/components/schemas/InvalidPubkeyError"}]}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"string"}}}}}}}},"components":{"schemas":{"PoolNotFoundErrorByPoolId":{"type":"object","properties":{"type":{"const":"PoolNotFound"},"poolId":{"type":"string"},"message":{"type":"string"}},"required":["type","poolId","message"]},"PoolNotFoundErrorByToken":{"type":"object","properties":{"type":{"const":"PoolNotFound"},"token0":{"type":"string"},"token1":{"type":"string"},"feeTier":{"type":"number"},"message":{"type":"string"}},"required":["type","token0","token1","message"]},"PoolAlreadyExistsError":{"type":"object","properties":{"type":{"const":"PoolAlreadyExists"},"poolId":{"type":"string"},"message":{"type":"string"}},"required":["type","poolId","message"]},"InvalidFeeRateError":{"type":"object","properties":{"type":{"const":"InvalidFeeRate"},"minFeeRate":{"type":"number"},"message":{"type":"string"}},"required":["type","minFeeRate","message"]},"InvalidUtxoError":{"type":"object","properties":{"type":{"const":"InvalidUtxo"},"utxos":{"type":"array","items":{"type":"string"}},"message":{"type":"string"}},"required":["type","utxos","message"]},"InvalidTokenError":{"type":"object","properties":{"type":{"const":"InvalidToken"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","token","message"]},"NotEnoughFundsError":{"type":"object","properties":{"type":{"const":"NotEnoughFunds"},"maxAmount":{"type":"string"},"minAmount":{"type":"string"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","maxAmount","minAmount","token","message"]},"NotEnoughFundsForSplittingRuneError":{"type":"object","properties":{"type":{"const":"NotEnoughFundsForSplittingRune"},"recommendedRuneAmount":{"type":"string"},"currentSatsAmount":{"type":"string"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","recommendedRuneAmount","currentSatsAmount","token","message"]},"ShardPubkeysRequiredError":{"type":"object","properties":{"type":{"const":"ShardPubkeysRequired"},"message":{"type":"string"}},"required":["type","message"]},"RequestExpiredError":{"type":"object","properties":{"type":{"const":"RequestExpired"},"message":{"type":"string"}},"required":["type","message"]},"FailedToSendArchTransactionError":{"type":"object","properties":{"type":{"const":"FailedToSendArchTransaction"},"message":{"type":"string"}},"required":["type","message"]},"InvalidAddress":{"type":"object","properties":{"type":{"const":"InvalidAddress"},"message":{"type":"string"}},"required":["type","message"]},"InvalidNumericValue":{"type":"object","properties":{"type":{"const":"InvalidNumericValue"},"message":{"type":"string"}},"required":["type","message"]},"InvalidTxSizeError":{"type":"object","properties":{"type":{"const":"InvalidTxSize"},"message":{"type":"string"}},"required":["type","message"]},"InvalidRunestoneError":{"type":"object","properties":{"type":{"const":"InvalidRunestone"},"message":{"type":"string"}},"required":["type","message"]},"InvalidSignatureError":{"type":"object","properties":{"type":{"const":"InvalidSignature"},"message":{"type":"string"}},"required":["type","message"]},"InvalidPsbtError":{"type":"object","properties":{"type":{"const":"InvalidPsbt"},"message":{"type":"string"}},"required":["type","message"]},"InvalidAmountBelowMinError":{"type":"object","properties":{"type":{"const":"InvalidAmountBelowMin"},"token":{"type":"string"},"minAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","minAmount","message"]},"InvalidAmountError":{"type":"object","properties":{"type":{"const":"InvalidAmount"},"token":{"type":"string"},"expectedAmount":{"type":"string"},"actualAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","expectedAmount","actualAmount","message"]},"InsufficientLiquidityError":{"type":"object","properties":{"type":{"const":"InsufficientLiquidity"},"token":{"type":"string"},"maxAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","maxAmount","message"]},"ShardsUnavailableError":{"type":"object","properties":{"type":{"const":"ShardsUnavailable"},"reason":{"oneOf":[{"const":"MempoolConstraints"},{"const":"NoBalance"}]},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","reason","token","message"]},"InvalidAssetPairError":{"type":"object","properties":{"type":{"const":"InvalidAssetPair"},"message":{"type":"string"}},"required":["type","message"]},"InvalidFeeTierError":{"type":"object","properties":{"type":{"const":"InvalidFeeTier"},"feeTier":{"type":"number"},"message":{"type":"string"}},"required":["type","feeTier","message"]},"InvalidPubkeyError":{"type":"object","properties":{"type":{"const":"InvalidPubkey"},"pubkey":{"type":"string"},"message":{"type":"string"}},"required":["type","pubkey","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.saturnbtc.io/builders/saturn-api/pool-api/swap-quotes.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.
