# Bitcoin Data Availability

Each trading transaction includes the tokens from the **trading wallet** and **the pool**, **a sequence number**, and **Uniswap data**. Users can compare the balance change between transaction inputs and outputs with Uniswap data, and compare the Uniswap data with the EVM contract to verify the Bitcoin transaction. Below is the structure of each type of trading transaction:

## 1. Init Pool (Create a New Pool and Add Liquidity)

**Inputs:**

* **Input 0:** Pool init UTXO
* **Remaining Inputs:** UTXOs from the trading wallet to init the pool

**Outputs:**

* **Output 0:** New pool init UTXO
* **Outputs 1-10:** New pool liquidity UTXOs
* **Outputs 11 to m:** radFi`OP_12` outputs containing pool initialization data
* **Output m+1:** `Runestone OP_RETURN`
* **Output m+2:** Trading wallet’s rune change
* **Output m+3:** Trading wallet’s Bitcoin change

**Example:** [**Init Pool and Add Liquidity**](https://mempool.space/tx/f3c9652a0cdab3ed7e759db12f092899248806b08e4bd50c8a2b7b3f10eb7a75)

**Inputs:**

* **Input 0:** Pool init UTXO (from the previous pool init transaction)
* **Input 1:** Trading wallet’s UTXOs containing Bitcoin funds to provide liquidity for the new pool and cover the transaction fee
* **Input 2:** Trading wallet’s UTXO containing Rune tokens to provide liquidity for the new pool

**Outputs:**

* **Output 0:** New pool init UTXO (for use in the next pool init transaction)
* **Outputs 1-5:** New pool liquidity UTXOs containing the liquidity added for the new pool
* **Outputs 6-10:** Additional pool liquidity UTXOs, but containing no liquidity due to the limit on the `Runestone OP_RETURN` script size
* **Outputs 11-12:** Pool initialization data, combining two `ScriptPubKey` data that follow `OP_12`:
  * **Byte 0 (Flag):** 1 (indicates providing liquidity)
  * **Bytes 1-4 (UpperTick, big endian int32):** 887200
  * **Bytes 5-8 (LowerTick, big endian int32):** -887200
  * **Remaining Bytes:** Contain 11 `uvarint128` values:
    * **Amount0:** 10000964745485757151
    * **Amount1:** 1000
    * **InitPrice:** 792243410400884224932
    * **Token0Decimal:** 18
    * **Token1Decimal:** 8
    * **SequenceNumber:** 57
    * **Fee:** 100 (1%)
    * **Token0Id - Block:** 885548
    * **Token0Id - Tx:** 319
    * **Token1Id - Block:** 0
    * **Token1Id - Tx:** 0
* **Output 13:** `Runestone OP_RETURN` containing data for the liquidity token in the new UTXOs and Rune change for the trading wallet
* **Output 14:** Trading wallet’s Rune change UTXO, containing any remaining Rune tokens
* **Output 15:** Trading wallet’s Bitcoin change UTXO, containing any remaining Bitcoin

## 2. Add New Liquidity Position to an Existing Pool

**Inputs:**

* **n inputs (n <= 10):** Pool liquidity UTXOs
* **Remaining inputs:** Trading wallet’s UTXOs to add liquidity

**Outputs:**

* **n outputs:** New pool liquidity UTXOs containing the added liquidity
* **Outputs n to m:** radFi `OP_12` outputs containing added liquidity data
* **Output m+1:** `Runestone OP_RETURN`
* **Output m+2:** Trading wallet’s rune change
* **Output m+3:** Trading wallet’s Bitcoin change

**Example:** [**Add New Liquidity Position**](https://mempool.space/tx/27f9522159a4c13d01a42dca5658535dfb6c5adc26f92a4191d09292bbee5af7)

**Inputs:**

* **Inputs 0-3:** Pool liquidity UTXOs
* **Input 4:** Trading wallet’s UTXOs containing Bitcoin funds to provide liquidity for the pool and cover the transaction fee
* **Input 5:** Trading wallet’s UTXO containing Rune tokens to provide liquidity for the pool

**Outputs:**

* **Outputs 0-3:** New pool liquidity UTXOs containing the liquidity added for the pool
* **Output 4:** radFi `OP_12` script containing add liquidity data:
  * **Byte 0 (Flag):** 1 (Providing liquidity flag)
  * **Bytes 1-4 (UpperTick, big endian int32):** 887200
  * **Bytes 5-8 (LowerTick, big endian int32):** -887200
  * **Remaining bytes:** Contain 11 `uvarint128` values:
    * **Amount0:** 10000964745485757151
    * **Amount1:** 1000
    * **InitPrice:** 0
    * **Token0Decimal:** 18
    * **Token1Decimal:** 8
    * **SequenceNumber:** 58
    * **Fee:** 100 (1%)
    * **Token0Id - Block:** 885548
    * **Token0Id - Tx:** 319
    * **Token1Id - Block:** 0
    * **Token1Id - Tx:** 0
* **Output 5:** `Runestone OP_RETURN` containing data for the liquidity token in the new UTXOs and Rune change for the trading wallet
* **Output 6:** Trading wallet’s Rune change UTXO containing any remaining Rune tokens
* **Output 7:** Trading wallet’s Bitcoin change UTXO containing any remaining Bitcoin

## 3. Swap in One Pool:

**Inputs:**

* **n inputs (n <= 10):** Pool liquidity UTXOs
* **Remaining inputs:** Trading wallet’s UTXOs to swap

**Outputs:**

* **n outputs:** New pool liquidity UTXOs
* **Outputs n to m:** radFi `OP_12` outputs containing swap data
* **Output m+1:** `Runestone OP_RETURN`
* **Output m+2:** Trading wallet’s token swap output
* **Output m+3:** Trading wallet’s rune change
* **Output m+4:** Trading wallet’s Bitcoin change

**Example:** [**Swap Bitcoin to Rune**](https://mempool.space/tx/ebdb718ee21e96462885b0e86ea5142e490350119a2dde8ed2a8ecddfe60180d)[**s**](https://mempool.space/tx/ebdb718ee21e96462885b0e86ea5142e490350119a2dde8ed2a8ecddfe60180d)

**Inputs:**

* **Inputs 0-1:** Pool liquidity UTXOs
* **Input 2:** Trading wallet’s UTXOs containing Bitcoin funds to swap and cover the transaction fee

**Outputs:**

* **Outputs 0-1:** New pool liquidity UTXOs
* **Output 2:** radFi `OP_12` script containing swap data:
  * **Byte 0 (Flag):** 2 (Swap flag)
  * **Byte 1:**
    * **First bit (IsExactIn):** true
    * **Remaining 7 bits (PoolsCount, uint8):** 1
  * **Remaining bytes:** Contain 8 `uvarint128` values:
    * **AmountIn:** 1000
    * **AmountOut:** 7444327141368519190
    * **SequenceNumber:** 66
    * **Fee:** 100 (1%)
    * **Input TokenId - Block:** 0
    * **Input TokenId - Tx:** 0
    * **Output TokenId - Block:** 885548
    * **Output TokenId - Tx:** 319
* **Output 3:** `Runestone OP_RETURN` containing data for the liquidity in the new UTXOs and Rune output for the trading wallet
* **Output 4:** Trading wallet’s swap output UTXO
* **Output 5:** Trading wallet’s Rune change UTXO (contains no Rune in this example due to no trading wallet’s Rune input)
* **Output 6:** Trading wallet’s Bitcoin change UTXO containing the remaining Bitcoin for the user

**Example:** [**Swap Runes to Bitcoin**](https://mempool.space/tx/3cefd10c34ff9f619177312a181bdffdd58cd699f81d23620815d0a55dd2aafd)

**Inputs:**

* **Inputs 0-3:** Pool liquidity UTXOs
* **Input 4:** Trading wallet’s UTXOs containing Bitcoin funds to cover the transaction fee
* **Inputs 5-6:** Trading wallet’s UTXOs containing Rune funds to swap

**Outputs:**

* **Outputs 0-3:** New pool liquidity UTXOs
* **Output 4:** radFi `OP_12` script containing swap data:
  * **Byte 0 (Flag):** 2 (Swap flag)
  * **Byte 1:**
    * **First bit (IsExactIn):** true
    * **Remaining 7 bits (PoolsCount, uint8):** 1
  * **Remaining bytes:** Contain 8 `uvarint128` values:
    * **AmountIn:** 11000000000000000000
    * **AmountOut:** 1299
    * **SequenceNumber:** 69
    * **Fee:** 100 (1%)
    * **Input TokenId - Block:** 885548
    * **Input TokenId - Tx:** 319
    * **Output TokenId - Block:** 0
    * **Output TokenId - Tx:** 0
* **Output 5:** `Runestone OP_RETURN` containing data for the liquidity in the new UTXOs and Rune change for the trading wallet
* **Output 6:** Trading wallet’s swap output UTXO
* **Output 7:** Trading wallet’s Rune change UTXO
* **Output 8:** Trading wallet’s Bitcoin change UTXO containing the remaining Bitcoin for the user

## 4. Withdraw Liquidity From a Pool

**Inputs:**

* **n inputs (n <= 10):** Pool liquidity UTXOs
* **Remaining inputs:** Trading wallet’s Bitcoin UTXOs to pay the transaction fee

**Outputs:**

* **n outputs:** New pool liquidity UTXOs
* **Outputs n to m:** `radFi OP_12` outputs containing withdraw liquidity data
* **Output m+1:** `Runestone OP_RETURN`
* **Output m+2:** Trading wallet’s withdrawn Rune liquidity
* **Output m+3:** Trading wallet’s withdrawn Bitcoin liquidity and Bitcoin change

**Example:** [**Withdraw Liquidity From a Pool**](https://mempool.space/tx/fe618d63b0d6e67d515fafe3ba6079ff3218cdd2dc0835fcdde596a09d4e6eb3)

**Inputs:**

* **Inputs 0-3:** Pool liquidity UTXOs
* **Input 4:** Trading wallet’s UTXOs containing Bitcoin funds to cover the transaction fee

**Outputs:**

* **Outputs 0-3:** New pool liquidity UTXOs
* **Output 4:** radFi `OP_12` script containing withdraw liquidity data:
  * **Byte 0 (Flag):** 3 (Withdraw liquidity flag)
  * **Remaining bytes:** Contain 10 `uvarint128` values:
    * **LiquidityValue:** 100004823610
    * **NftId:** 8
    * **Amount0:** 9621866398363189269
    * **Amount1:** 1039
    * **SequenceNumber:** 94
    * **Fee:** 100 (1%)
    * **Token0Id - Block:** 885548
    * **Token0Id - Tx:** 319
    * **Token1Id - Block:** 0
    * **Token1Id - Tx:** 0
* **Output 5:** `Runestone OP_RETURN` containing data for the liquidity in the new UTXOs and withdrawn Rune for the trading wallet
* **Output 6:** Trading wallet’s Rune change UTXO
* **Output 7:** Trading wallet’s withdrawn Bitcoin liquidity and Bitcoin change UTXO

## 5. Collect Fees From a Pool

**Inputs:**

* **n inputs (n <= 10):** Pool liquidity UTXOs
* **Remaining inputs:** Trading wallet’s Bitcoin UTXOs to pay the transaction fee

**Outputs:**

* **n outputs:** New pool liquidity UTXOs
* **Outputs n to m:** radFi `OP_12` outputs containing collect fees data
* **Output m+1:** `Runestone OP_RETURN`
* **Output m+2:** Trading wallet’s collected Rune fees
* **Output m+3:** Trading wallet’s collected Bitcoin fees and Bitcoin change

**Example:** [**Collect Fees From a Pool**](https://mempool.space/tx/21f4a5c60696c7be6d02da66991c77bc936febceac0989f1d1ccb28aa5accb35)

**Inputs:**

* **Input 0:** Pool liquidity UTXO
* **Input 1:** Trading wallet’s UTXOs containing Bitcoin funds to cover the transaction fee

**Outputs:**

* **Output 0:** New pool liquidity UTXO
* **Output 1:** radFi `OP_12` script containing collect fees data:
  * **Byte 0 (Flag):** 4 (Collect fees flag)
  * **Remaining bytes:** Contain 9 `uvarint128` values:
    * **NftId:** 8
    * **Amount0:** 52894105064729815
    * **Amount1:** 6
    * **SequenceNumber:** 93
    * **Fee:** 100 (1%)
    * **Token0Id - Block:** 885548
    * **Token0Id - Tx:** 319
    * **Token1Id - Block:** 0
    * **Token1Id - Tx:** 0
* **Output 2:** `Runestone OP_RETURN` containing data of liquidity in the new UTXOs and collected Rune fees for the trading wallet
* **Output 3:** Trading wallet’s collected Rune fees UTXO
* **Output 4:** Trading wallet’s collected Bitcoin fees and Bitcoin change UTXO

## 6. Increase Liquidity of a Position in a Pool&#x20;

**Inputs:**

* **n inputs (n <= 10):** Pool liquidity UTXOs
* **Remaining inputs:** Trading wallet’s UTXOs to increase liquidity

**Outputs:**

* **n outputs:** New pool liquidity UTXOs
* **Outputs n to m:** radFi `OP_12` outputs containing increase liquidity data
* **Output m+1:** `Runestone OP_RETURN`
* **Output m+2:** Trading wallet’s Rune change
* **Output m+3:** Trading wallet’s Bitcoin change

**Example:** [**Increase Liquidity of a Position in a Pool** ](https://mempool.space/tx/0a095158af50538d37abbd62bcc5e4ff7361a71d797a81a163cc36df1c9d8363)

**Inputs:**

* **Inputs 0-3:** Pool liquidity UTXOs
* **Inputs 4-5:** Trading wallet’s UTXOs containing Bitcoin funds to increase liquidity for the pool’s position and cover the transaction fee
* **Input 6:** Trading wallet’s UTXO containing Rune token to increase liquidity for the pool’s position

**Outputs:**

* **Outputs 0-3:** New pool liquidity UTXOs
* **Output 4:** radFi `OP_12` script containing increase liquidity data:
  * **Byte 0 (Flag):** 5 (Increase liquidity flag)
  * **Remaining bytes:** Contain 11 `uvarint128` values:
    * **Min0:** 0
    * **Min1:** 0
    * **NftId:** 14
    * **Amount0:** 10000964745485757151
    * **Amount1:** 1000
    * **SequenceNumber:** 64
    * **Fee:** 5 (0.05%)
    * **Token0Id - Block:** 885548
    * **Token0Id - Tx:** 319
    * **Token1Id - Block:** 0
    * **Token1Id - Tx:** 0
* **Output 5:** `Runestone OP_RETURN` containing data of liquidity in the new UTXOs and Rune change for the trading wallet
* **Output 6:** Trading wallet’s Rune change UTXO
* **Output 7:** Trading wallet’s Bitcoin change UTXO

## 7. Migrate pool to new address

**Inputs:**

* **Inputs 0-9:** pool liquidity UTXOs from old address
* **Remain inputs:** admin wallet’s bitcoin UTXOs to pay transaction fee

**Outputs:**

* **Outputs 0-9:** new pool liquidity UTXOs for new address
* **Output 10:** radFi OP\_12 outputs contain pool migration data
* **Output 11:** runestone OP\_RETURN
* **Output 12:** admin wallet’s bitcoin change

**Example:** <https://mempool.space/tx/c269695a85fbbe672b46ece887fcb6753f9c6647541b6ef28d0161f0673164d8>

**Inputs:**

* **Inputs 0-9:** pool liquidity UTXOs from old address
* **Inputs 10-11:** admin wallet’s UTXOs contain bitcoin fund to cover the transaction fee

**Outputs:**

* **Outputs 0-9:** new pool liquidity UTXOs for new address
* **Output 10:** radFi OP\_12 script contain pool migration data:
  * **Byte 0 is Flag:** 7 (migrate pool flag)
  * **The remain bytes:** contain 5 uvarint128
    * **Fee:** 100 (mean 1%)
    * **Token0Id - Block:** 0
    * **Token0Id - Tx:** 0
    * **Token1Id - Block:** 867080
    * **Token1Id - Tx:** 468
* **Output 11:** runestone `OP_RETURN` contain data of liquidity in the new UTXOs

## 8. Migrate pool init UTXO to new address&#x20;

**Inputs:**

* **Input 0:** pool init UTXO from old address
* **Remain inputs:** admin wallet’s bitcoin UTXOs to pay transaction fee

**Outputs:**

* **Output 0:** new pool liquidity UTXOs for new address
* **Outputs 1:** radFi OP\_12 outputs contain pool migration data
* **Output 2:** runestone OP\_RETURN
* **Output 3:** admin wallet’s bitcoin change

**Example:** <https://mempool.space/tx/8962cecd385ba3c6ac6bc30634c4b233f925a580c0c5d2a47867c8986ef1609e>

**Inputs:**

* **Input 0:** pool init UTXO from old address
* **Input 1:** admin wallet’s UTXO contain bitcoin fund to cover the transaction fee

**Outputs:**

* **Output 0:** new pool init UTXO for new address
* **Output 1:** radFi OP\_12 script contain pool init UTXO migration data:
  * **Byte 0 is Flag:** 7 (migrate pool flag)
  * **The remain bytes:** contain 5 uvarint128
    * **Fee:** 0
    * **Token0Id - Block:** 0
    * **Token0Id - Tx:** 0
    * **Token1Id - Block:** 0
    * **Token1Id - Tx:** 0
* **Output 2:** admin wallet’s bitcoin change


---

# 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.radfi.co/technical-architecture/bitcoin-data-availability.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.
