Pool API
The Pools API allows you to interact with the program's instructions for managing liquidity pools, performing swaps, and more.
The general process for most instructions consists of three main steps:
General Process Overview
Generate a PSBT (Partially Signed Bitcoin Transaction):
Endpoint:
/{instruction}/psbt
Description: Call this endpoint to generate a PSBT along with additional information such as fees, inputs to sign, and other necessary data.
Response Includes:
The PSBT in base64 format.
Fee details.
Inputs that need to be signed.
Any additional necessary data.
Obtain a Message to Sign:
Endpoint:
/{instruction}/message
Description: After generating and signing the PSBT, send it along with the required parameters for the instruction to this endpoint. It will return a message in hexadecimal format that you need to sign with your wallet.
Requirements:
Use BIP322 for signing.
Use a Taproot address for the signature.
Submit the Signed Message and Execute the Instruction:
Endpoint:
/{instruction}
Description: Once you have the signed message, send the signature along with the necessary parameters for the instruction to this endpoint. All parameters will be validated, and if everything matches, the message will be broadcast to the Arch network.
Notes:
In some instructions, such as Swap, the signed PSBT is included in the message sent to the program. The program will then complete the PSBT with its relevant inputs and outputs and broadcast it to the network.
In other instructions, like Increase Liquidity, Open Position, Initialize Pool, and Decrease Liquidity, the PSBT is broadcast to the network in the third step, and immediately after, the program instruction is called.
The general process is similar across all instructions, but there are specific differences in some cases.
Specific Instructions and Notes
Decrease Liquidity
Optional PSBT Creation: Creating a PSBT is optional for this instruction.
Purpose of PSBT: The PSBT is used to pay transaction fees in case the BTC withdrawn from the pool is not sufficient to cover the network fees.
Process: If you choose to create a PSBT, follow the general process. If not, you can proceed directly to obtaining the message to sign.
Swap from Rune to BTC
Additional PSBT (
splitRunePsbt
): When swapping from Rune to BTC, the/{instruction}/psbt
endpoint may return an additional PSBT calledsplitRunePsbt
.Purpose of
splitRunePsbt
: This PSBT is necessary to create a transaction that generates a UTXO with the required amount of Runes to trade.Process:
If the endpoint responds with a
splitRunePsbt
, you need to sign both thesplitRunePsbt
and the main PSBT for trading.Send both signed PSBTs to the
/{instruction}/message
endpoint.
Additional Considerations
Signing Requirements:
BIP322: Ensure you are using BIP322 for signing messages. This standard allows for message signing in a way that is compatible with Bitcoin's consensus rules.
Taproot Addresses: Signatures for Arch Network messages must come from a Taproot address.
Start building now
If you want to get a hands-on experience now and stop reading docs, check out these options and start building with the Pools API:
Typescript SDK: A fully-featured SDK, allowing for easy and type-safe interactions with the API.
Swagger Documentation: An OpenAPI specification is available, providing detailed information about each endpoint, request, and response format.
Stackblitz Environment: We've deployed a Stockblitz environment where you can experiment with the API in a live setting, enabling you to test queries and see real-time data without setting up your own backend.
Last updated