# Initialize pool

## Initialize Pool PSBT

> Generates a partially signed Bitcoin transaction (PSBT) for creating the needed UTXOs for creating the accounts\
> for a pool.\
> \
> The request body containing details for creating accounts PSBT.

OpenAPI:

```json
{"openapi":"3.1.0","info":{"title":"@saturnbtcio/api","version":"0.0.1"},"tags":[{"name":"Pool"}],"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"}}},"paths":{"/v0/pool/initialize-pool/psbt":{"post":{"summary":"Initialize Pool PSBT","description":"Generates a partially signed Bitcoin transaction (PSBT) for creating the needed UTXOs for creating the accounts\nfor a pool.\n\nThe request body containing details for creating accounts PSBT.","tags":["Pool"],"parameters":[],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"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)."},"shardsLength":{"type":"number","title":"The number of accounts to create. Maximum is 10","description":"The number of accounts to create. Maximum is 10."},"token0":{"type":"string","title":"The first token's identifier","description":"The first token's identifier."},"token1":{"type":"string","title":"The second token's identifier","description":"The second token's identifier."},"feeTier":{"type":"number","title":"The fee tier for the pool","description":"The fee tier for the pool."},"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"},"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":["feeRate","shardsLength","token0","token1","feeTier","runePubkey","runeAddress"]}}},"required":true},"responses":{"201":{"description":"An object containing the PSBT, fee, utxos to sign, and the created accounts.","content":{"application/json":{"schema":{"type":"object","properties":{"psbt":{"type":"string","description":"Psbt base64 encoded to sign"},"fee":{"type":"number","description":"Raw fees in satoshis of the transaction"},"utxosToSign":{"type":"array","items":{"type":"object","properties":{"address":{"type":"string","description":"Address that should sign the transaction"},"signingIndexes":{"type":"array","items":{"type":"number"},"description":"Indexes of the inputs to sign"},"sigHash":{"type":"number","description":"Sig hash type"},"utxo":{"type":"string","title":"Utxo id (txid:vout) of the utxo used in the psbt","description":"Utxo id (txid:vout) of the utxo used in the psbt."}},"required":["address","signingIndexes","utxo"]},"description":"Inputs to sign"}},"required":["psbt","fee","utxosToSign"]}}}},"400":{"description":"Pool error","content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"type":{"const":"PoolNotFound"},"poolId":{"type":"string"},"message":{"type":"string"}},"required":["type","poolId","message"]},{"type":"object","properties":{"type":{"const":"PoolNotFound"},"token0":{"type":"string"},"token1":{"type":"string"},"feeTier":{"type":"number"},"message":{"type":"string"}},"required":["type","token0","token1","message"]},{"type":"object","properties":{"type":{"const":"PoolAlreadyExists"},"poolId":{"type":"string"},"message":{"type":"string"}},"required":["type","poolId","message"]},{"type":"object","properties":{"type":{"const":"InvalidFeeRate"},"minFeeRate":{"type":"number"},"message":{"type":"string"}},"required":["type","minFeeRate","message"]},{"type":"object","properties":{"type":{"const":"InvalidUtxo"},"utxos":{"type":"array","items":{"type":"string"}},"message":{"type":"string"}},"required":["type","utxos","message"]},{"type":"object","properties":{"type":{"const":"InvalidToken"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","token","message"]},{"type":"object","properties":{"type":{"const":"NotEnoughFunds"},"maxAmount":{"type":"string"},"minAmount":{"type":"string"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","maxAmount","minAmount","token","message"]},{"type":"object","properties":{"type":{"const":"NotEnoughFundsForSplittingRune"},"recommendedRuneAmount":{"type":"string"},"currentSatsAmount":{"type":"string"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","recommendedRuneAmount","currentSatsAmount","token","message"]},{"type":"object","properties":{"type":{"const":"ShardPubkeysRequired"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"RequestExpired"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"FailedToSendArchTransaction"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidAddress"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidNumericValue"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidTxSize"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidRunestone"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidSignature"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidPsbt"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidAmountBelowMin"},"token":{"type":"string"},"minAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","minAmount","message"]},{"type":"object","properties":{"type":{"const":"InvalidAmount"},"token":{"type":"string"},"expectedAmount":{"type":"string"},"actualAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","expectedAmount","actualAmount","message"]},{"type":"object","properties":{"type":{"const":"InsufficientLiquidity"},"token":{"type":"string"},"maxAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","maxAmount","message"]},{"type":"object","properties":{"type":{"const":"InvalidAssetPair"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidFeeTier"},"feeTier":{"type":"number"},"message":{"type":"string"}},"required":["type","feeTier","message"]},{"type":"object","properties":{"type":{"const":"InvalidPubkey"},"pubkey":{"type":"string"},"message":{"type":"string"}},"required":["type","pubkey","message"]}]}}}},"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"}}}}}}}}}
```

## Initialize Pool Message

> Generates a message hash required to initialize a pool.

OpenAPI:

```json
{"openapi":"3.1.0","info":{"title":"@saturnbtcio/api","version":"0.0.1"},"tags":[{"name":"Pool"}],"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"}}},"paths":{"/v0/pool/initialize-pool/message":{"post":{"summary":"Initialize Pool Message","description":"Generates a message hash required to initialize a pool.","tags":["Pool"],"parameters":[],"requestBody":{"description":"The request body containing pool initialization details.","content":{"application/json":{"schema":{"type":"object","properties":{"token0":{"type":"string","title":"The first token's identifier","description":"The first token's identifier."},"token1":{"type":"string","title":"The second token's identifier","description":"The second token's identifier."},"feeTier":{"type":"number","title":"The fee tier for the pool","description":"The fee tier for the pool."},"shardsLength":{"type":"number","title":"The number of accounts to create. Maximum is 10","description":"The number of accounts to create. Maximum is 10."},"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)."},"signedPsbt":{"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 signed PSBT in base64 format","description":"The signed PSBT in base64 format."},"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"},"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":["token0","token1","feeTier","shardsLength","feeRate","signedPsbt","runePubkey","runeAddress"]}}},"required":true},"responses":{"201":{"description":"A hexadecimal string representing the hash of the initialization message.","content":{"application/json":{"schema":{"type":"string"}}}},"400":{"description":"Pool error","content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"type":{"const":"PoolNotFound"},"poolId":{"type":"string"},"message":{"type":"string"}},"required":["type","poolId","message"]},{"type":"object","properties":{"type":{"const":"PoolNotFound"},"token0":{"type":"string"},"token1":{"type":"string"},"feeTier":{"type":"number"},"message":{"type":"string"}},"required":["type","token0","token1","message"]},{"type":"object","properties":{"type":{"const":"PoolAlreadyExists"},"poolId":{"type":"string"},"message":{"type":"string"}},"required":["type","poolId","message"]},{"type":"object","properties":{"type":{"const":"InvalidFeeRate"},"minFeeRate":{"type":"number"},"message":{"type":"string"}},"required":["type","minFeeRate","message"]},{"type":"object","properties":{"type":{"const":"InvalidUtxo"},"utxos":{"type":"array","items":{"type":"string"}},"message":{"type":"string"}},"required":["type","utxos","message"]},{"type":"object","properties":{"type":{"const":"InvalidToken"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","token","message"]},{"type":"object","properties":{"type":{"const":"NotEnoughFunds"},"maxAmount":{"type":"string"},"minAmount":{"type":"string"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","maxAmount","minAmount","token","message"]},{"type":"object","properties":{"type":{"const":"NotEnoughFundsForSplittingRune"},"recommendedRuneAmount":{"type":"string"},"currentSatsAmount":{"type":"string"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","recommendedRuneAmount","currentSatsAmount","token","message"]},{"type":"object","properties":{"type":{"const":"ShardPubkeysRequired"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"RequestExpired"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"FailedToSendArchTransaction"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidAddress"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidNumericValue"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidTxSize"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidRunestone"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidSignature"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidPsbt"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidAmountBelowMin"},"token":{"type":"string"},"minAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","minAmount","message"]},{"type":"object","properties":{"type":{"const":"InvalidAmount"},"token":{"type":"string"},"expectedAmount":{"type":"string"},"actualAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","expectedAmount","actualAmount","message"]},{"type":"object","properties":{"type":{"const":"InsufficientLiquidity"},"token":{"type":"string"},"maxAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","maxAmount","message"]},{"type":"object","properties":{"type":{"const":"InvalidAssetPair"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidFeeTier"},"feeTier":{"type":"number"},"message":{"type":"string"}},"required":["type","feeTier","message"]},{"type":"object","properties":{"type":{"const":"InvalidPubkey"},"pubkey":{"type":"string"},"message":{"type":"string"}},"required":["type","pubkey","message"]}]}}}},"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"}}}}}}}}}
```

## Initialize Pool

> Finalizes the pool initialization process.

OpenAPI:

```json
{"openapi":"3.1.0","info":{"title":"@saturnbtcio/api","version":"0.0.1"},"tags":[{"name":"Pool"}],"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"}}},"paths":{"/v0/pool/initialize-pool":{"post":{"summary":"Initialize Pool","description":"Finalizes the pool initialization process.","tags":["Pool"],"parameters":[],"requestBody":{"description":"The request body containing the initialization request and signature.","content":{"application/json":{"schema":{"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 initialization message","description":"The user's signature of the initialization message."},"token0":{"type":"string","title":"The first token's identifier","description":"The first token's identifier."},"token1":{"type":"string","title":"The second token's identifier","description":"The second token's identifier."},"feeTier":{"type":"number","title":"The fee tier for the pool","description":"The fee tier for the pool."},"shardsLength":{"type":"number","title":"The number of accounts to create. Maximum is 10","description":"The number of accounts to create. Maximum is 10."},"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)."},"signedPsbt":{"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 signed PSBT in base64 format","description":"The signed PSBT in base64 format."},"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"},"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","token0","token1","feeTier","shardsLength","feeRate","signedPsbt","runePubkey","runeAddress"]}}},"required":true},"responses":{"201":{"description":"The Arch Network transaction ID of the pool creation.","content":{"application/json":{"schema":{"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"]}}}},"400":{"description":"Pool error","content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"type":{"const":"PoolNotFound"},"poolId":{"type":"string"},"message":{"type":"string"}},"required":["type","poolId","message"]},{"type":"object","properties":{"type":{"const":"PoolNotFound"},"token0":{"type":"string"},"token1":{"type":"string"},"feeTier":{"type":"number"},"message":{"type":"string"}},"required":["type","token0","token1","message"]},{"type":"object","properties":{"type":{"const":"PoolAlreadyExists"},"poolId":{"type":"string"},"message":{"type":"string"}},"required":["type","poolId","message"]},{"type":"object","properties":{"type":{"const":"InvalidFeeRate"},"minFeeRate":{"type":"number"},"message":{"type":"string"}},"required":["type","minFeeRate","message"]},{"type":"object","properties":{"type":{"const":"InvalidUtxo"},"utxos":{"type":"array","items":{"type":"string"}},"message":{"type":"string"}},"required":["type","utxos","message"]},{"type":"object","properties":{"type":{"const":"InvalidToken"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","token","message"]},{"type":"object","properties":{"type":{"const":"NotEnoughFunds"},"maxAmount":{"type":"string"},"minAmount":{"type":"string"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","maxAmount","minAmount","token","message"]},{"type":"object","properties":{"type":{"const":"NotEnoughFundsForSplittingRune"},"recommendedRuneAmount":{"type":"string"},"currentSatsAmount":{"type":"string"},"token":{"type":"string"},"message":{"type":"string"}},"required":["type","recommendedRuneAmount","currentSatsAmount","token","message"]},{"type":"object","properties":{"type":{"const":"ShardPubkeysRequired"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"RequestExpired"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"FailedToSendArchTransaction"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidAddress"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidNumericValue"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidTxSize"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidRunestone"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidSignature"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidPsbt"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidAmountBelowMin"},"token":{"type":"string"},"minAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","minAmount","message"]},{"type":"object","properties":{"type":{"const":"InvalidAmount"},"token":{"type":"string"},"expectedAmount":{"type":"string"},"actualAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","expectedAmount","actualAmount","message"]},{"type":"object","properties":{"type":{"const":"InsufficientLiquidity"},"token":{"type":"string"},"maxAmount":{"type":"string"},"message":{"type":"string"}},"required":["type","token","maxAmount","message"]},{"type":"object","properties":{"type":{"const":"InvalidAssetPair"},"message":{"type":"string"}},"required":["type","message"]},{"type":"object","properties":{"type":{"const":"InvalidFeeTier"},"feeTier":{"type":"number"},"message":{"type":"string"}},"required":["type","feeTier","message"]},{"type":"object","properties":{"type":{"const":"InvalidPubkey"},"pubkey":{"type":"string"},"message":{"type":"string"}},"required":["type","pubkey","message"]}]}}}},"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"}}}}}}}}}
```

