# Remove Liquidity

## Decrease Liquidity Message

> Generates a message hash for decreasing liquidity from a position, which the user should sign.

```json
{"openapi":"3.1.0","info":{"title":"@saturnbtcio/api","version":"0.0.1"},"tags":[{"name":"Liquidity"}],"servers":[{"url":"https://api-dev.saturnbtc.io","description":"Development Server"},{"url":"https://api.saturnbtc.io","description":"Production Server"}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"apiKey","name":"x-api-key","in":"header"}},"schemas":{"BasicDecreaseLiquidityRequestUserInforecentBlockhashstringpaymentMethodDecreaseLiquidityPaymentMethodIApiRequest":{"type":"object","properties":{"poolId":{"type":"string","pattern":"^[0-9a-fA-F]+$","minLength":64,"maxLength":66,"title":"The pubkey of the pool","description":"The pubkey of the pool."},"positionPubKey":{"type":"string","pattern":"^[0-9a-fA-F]+$","minLength":64,"maxLength":66,"title":"The pubkey of the position","description":"The pubkey of the position."},"liquidityAmount":{"type":"string","pattern":"^[1-9][0-9]*$","title":"The amount of liquidity to withdraw","description":"The amount of liquidity to withdraw."},"minToken0":{"type":"string","pattern":"^[0-9][0-9]*$","title":"The minimum amount of the first token to withdraw","description":"The minimum amount of the first token to withdraw."},"minToken1":{"type":"string","pattern":"^[0-9][0-9]*$","title":"The minimum amount of the second token to withdraw","description":"The minimum amount of the second token to withdraw."},"withdrawAddressToken0":{"type":"string","title":"The address to withdraw the first token to","description":"The address to withdraw the first token to."},"withdrawAddressToken1":{"type":"string","title":"The address to withdraw the second token to","description":"The address to withdraw the second token to."},"feeRate":{"type":"integer","minimum":1,"title":"The fee rate for the transaction (in sats per byte)","description":"The fee rate for the transaction (in sats per byte)."},"runePubkey":{"type":"string","pattern":"^[0-9a-fA-F]+$","minLength":64,"maxLength":66,"title":"The public key of the rune address of the user initiating the request","description":"The public key of the rune address of the user initiating the request."},"paymentPubkey":{"type":"string","pattern":"^[0-9a-fA-F]+$","minLength":64,"maxLength":66,"title":"The public key of the bitcoin address of the user initiating the request","description":"The public key of the bitcoin address of the user initiating the request.\nIf the user doesn't have a bitcoin address, the runePubkey will be used"},"recentBlockhash":{"type":"string","title":"The recent blockhash of the transaction","description":"The recent blockhash of the transaction."},"paymentMethod":{"oneOf":[{"type":"object","properties":{"type":{"const":"fee_utxo"},"feeUtxo":{"$ref":"#/components/schemas/UtxoMetaData"}},"required":["type","feeUtxo"]},{"type":"object","properties":{"type":{"const":"signed_psbt"},"signedPsbt":{"type":"string"}},"required":["type","signedPsbt"]},{"type":"object","properties":{"type":{"const":"none"}},"required":["type"]}],"title":"The payment method for transaction fees","description":"The payment method for transaction fees."},"runeAddress":{"type":"string","title":"The rune address of the user. It must be a taproot address. (P2TR)","description":"The rune address of the user. It must be a taproot address. (P2TR).\nIf no bitcoin address is provided, the rune address will be used for bitcoin too."},"paymentAddress":{"type":"string","title":"The bitcoin address of the user","description":"The bitcoin address of the user."}},"required":["poolId","positionPubKey","liquidityAmount","minToken0","minToken1","withdrawAddressToken0","withdrawAddressToken1","feeRate","runePubkey","recentBlockhash","paymentMethod","runeAddress"]},"UtxoMetaData":{"type":"object","properties":{"txid":{"type":"string"},"vout":{"type":"number"}},"required":["txid","vout"]},"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"]}}},"paths":{"/v0/pool/decrease-liquidity/message":{"post":{"summary":"Decrease Liquidity Message","description":"Generates a message hash for decreasing liquidity from a position, which the user should sign.","tags":["Liquidity"],"parameters":[],"requestBody":{"description":"The request body containing the liquidity decrease details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BasicDecreaseLiquidityRequestUserInforecentBlockhashstringpaymentMethodDecreaseLiquidityPaymentMethodIApiRequest"}}},"required":true},"responses":{"201":{"description":"A hexadecimal string representing the hash of the message to be signed by the user.","content":{"application/json":{"schema":{"type":"string"}}}},"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"}]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"string"}}}},"403":{"description":"User not found","content":{"application/json":{"schema":{"type":"string"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"string"}}}}}}}}}
```

## Decrease Liquidity

> Finalizes the decrease of liquidity from a position by submitting the signed message and executing the transaction on the network.

```json
{"openapi":"3.1.0","info":{"title":"@saturnbtcio/api","version":"0.0.1"},"tags":[{"name":"Liquidity"}],"servers":[{"url":"https://api-dev.saturnbtc.io","description":"Development Server"},{"url":"https://api.saturnbtc.io","description":"Production Server"}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"apiKey","name":"x-api-key","in":"header"}},"schemas":{"DecreaseLiquidityRequestIApiRequest":{"type":"object","properties":{"signature":{"type":"string","pattern":"^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}={2})$","title":"The user's signature of the decrease liquidity message","description":"The user's signature of the decrease liquidity message."},"poolId":{"type":"string","pattern":"^[0-9a-fA-F]+$","minLength":64,"maxLength":66,"title":"The pubkey of the pool","description":"The pubkey of the pool."},"positionPubKey":{"type":"string","pattern":"^[0-9a-fA-F]+$","minLength":64,"maxLength":66,"title":"The pubkey of the position","description":"The pubkey of the position."},"liquidityAmount":{"type":"string","pattern":"^[1-9][0-9]*$","title":"The amount of liquidity to withdraw","description":"The amount of liquidity to withdraw."},"minToken0":{"type":"string","pattern":"^[0-9][0-9]*$","title":"The minimum amount of the first token to withdraw","description":"The minimum amount of the first token to withdraw."},"minToken1":{"type":"string","pattern":"^[0-9][0-9]*$","title":"The minimum amount of the second token to withdraw","description":"The minimum amount of the second token to withdraw."},"withdrawAddressToken0":{"type":"string","title":"The address to withdraw the first token to","description":"The address to withdraw the first token to."},"withdrawAddressToken1":{"type":"string","title":"The address to withdraw the second token to","description":"The address to withdraw the second token to."},"feeRate":{"type":"integer","minimum":1,"title":"The fee rate for the transaction (in sats per byte)","description":"The fee rate for the transaction (in sats per byte)."},"runePubkey":{"type":"string","pattern":"^[0-9a-fA-F]+$","minLength":64,"maxLength":66,"title":"The public key of the rune address of the user initiating the request","description":"The public key of the rune address of the user initiating the request."},"paymentPubkey":{"type":"string","pattern":"^[0-9a-fA-F]+$","minLength":64,"maxLength":66,"title":"The public key of the bitcoin address of the user initiating the request","description":"The public key of the bitcoin address of the user initiating the request.\nIf the user doesn't have a bitcoin address, the runePubkey will be used"},"recentBlockhash":{"type":"string","title":"The recent blockhash of the transaction","description":"The recent blockhash of the transaction."},"paymentMethod":{"oneOf":[{"type":"object","properties":{"type":{"const":"fee_utxo"},"feeUtxo":{"$ref":"#/components/schemas/UtxoMetaData"}},"required":["type","feeUtxo"]},{"type":"object","properties":{"type":{"const":"signed_psbt"},"signedPsbt":{"type":"string"}},"required":["type","signedPsbt"]},{"type":"object","properties":{"type":{"const":"none"}},"required":["type"]}],"title":"The payment method for transaction fees","description":"The payment method for transaction fees."},"runeAddress":{"type":"string","title":"The rune address of the user. It must be a taproot address. (P2TR)","description":"The rune address of the user. It must be a taproot address. (P2TR).\nIf no bitcoin address is provided, the rune address will be used for bitcoin too."},"paymentAddress":{"type":"string","title":"The bitcoin address of the user","description":"The bitcoin address of the user."}},"required":["signature","poolId","positionPubKey","liquidityAmount","minToken0","minToken1","withdrawAddressToken0","withdrawAddressToken1","feeRate","runePubkey","recentBlockhash","paymentMethod","runeAddress"]},"UtxoMetaData":{"type":"object","properties":{"txid":{"type":"string"},"vout":{"type":"number"}},"required":["txid","vout"]},"InstructionResponse":{"type":"object","properties":{"archTxId":{"type":"string","title":"Transaction id of the transaction in Arch","description":"Transaction id of the transaction in Arch."},"bitcoinTxIds":{"type":"array","items":{"type":"string"},"description":"Some bitcoin transactions ids that we have broadcasted. The Arch Network will\nsubmit a new bitcoin transaction after these ones."}},"required":["archTxId","bitcoinTxIds"]},"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"]}}},"paths":{"/v0/pool/decrease-liquidity":{"post":{"summary":"Decrease Liquidity","description":"Finalizes the decrease of liquidity from a position by submitting the signed message and executing the transaction on the network.","tags":["Liquidity"],"parameters":[],"requestBody":{"description":"The request body containing the liquidity decrease request and signature.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecreaseLiquidityRequestIApiRequest"}}},"required":true},"responses":{"201":{"description":"The Arch Network transaction ID of the liquidity decrease.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InstructionResponse"}}}},"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"}]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"string"}}}},"403":{"description":"User not found","content":{"application/json":{"schema":{"type":"string"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"string"}}}}}}}}}
```


---

# 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/remove-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.
