> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Conversions

> An explanation of the conversion mechanism between the Quai and Qi tokens.

Token conversions represent one of Quai Network's most innovative features, enabling seamless exchange between its two native tokens at mathematically determined rates. The conversion system serves as both a market mechanism and a stability tool, allowing supply to adjust dynamically to demand while maintaining economic equilibrium between the tokens. Understanding the conversion mechanism is essential for grasping how Quai Network creates a self-regulating monetary system.

The Quai Network Protocol employs two tokens: **Quai**, the native token of an Ethereum Virtual Machine (EVM)-compatible ledger, and **Qi**, the native token of a fixed-denomination Unspent Transaction Output (UTXO) ledger. Both tokens are mineable and interconvertible by holders at a protocol-defined exchange rate that reflects their underlying economic relationship. A sophisticated controller mechanism ensures neutrality between Quai and Qi, preventing any inherent bias toward either token and maintaining fair conversion rates.

This section details the mathematical formulations governing miner difficulty, conversion flow, exchange rate, and transaction adjustments within the protocol. The conversion system operates through multiple interconnected mechanisms that work together to create stability and responsiveness in the dual-token economy.

> **Note**\
> All conversion transactions are locked up for 2 weeks

***

## Core Components

### Miner Difficulty

Miner difficulty at block `i`, denoted `minerDifficulty_i`, is calculated as an Exponential Moving Average (EMA) of prime block difficulty over a 4000-block window. This balances responsiveness to network changes with long-term stability:

<Frame>
  <img src="https://mintcdn.com/dominantstrategies/X4sucm2SYhI37-ls/images/minerDifficulty.png?fit=max&auto=format&n=X4sucm2SYhI37-ls&q=85&s=70e2424dfd7dbe68a5d546664c9fba50" width="627" height="54" data-path="images/minerDifficulty.png" />
</Frame>

* `minerDifficulty_{i-1}`: Difficulty at the previous block.
* `blockDifficulty_i`: Difficulty of the current prime block.

This averaging smooths short-term fluctuations while adapting to evolving network conditions.

***

### Block Rewards and `k_Qi`

Block rewards are distributed in Quai or Qi, scaled by coefficients `k_Quai` and `k_Qi`, respectively:

* **Quai Block Reward**:\
  `reward_Quai = k_Quai × log2(blockDifficulty_i)`

* **Qi Block Reward**:\
  `reward_Qi = k_Qi × blockDifficulty_i`

The protocol treats `k_Qi` as a dynamic parameter tied to hashrate efficiency, which evolves with GPU performance improvements. Based on research from [Epoch AI](https://epoch.ai/blog/predicting-gpu-performance), GPU efficiency (measured in flops) doubles every 2.69 years due to smaller transistors and increased core counts, plateauing after 2030. Assuming saturation after two doublings, `k_Qi` adjusts with block height (`number`):

<Frame>
  <img src="https://mintcdn.com/dominantstrategies/X4sucm2SYhI37-ls/images/kQi.png?fit=max&auto=format&n=X4sucm2SYhI37-ls&q=85&s=08c5611a70554694120591606dc398df" width="974" height="65" data-path="images/kQi.png" />
</Frame>

Where:

* `baseKqi = 1 / (8 × 10^9)`
* `doublingPeriodInBlocks = (365 × BlocksPerDay × 2.69)`
* `doublingCount = floor(number / doublingPeriodInBlocks)`
* `remainingBlocks = number - doublingCount × doublingPeriodInBlocks`
* `BlocksPerDay`: Constant number of blocks mined per day.

Unlike `k_Qi`, which adjusts to technological trends, `k_Quai` is actively controlled by the protocol to maintain token neutrality. All exchange rate references below pertain to `k_Quai`.

***

### Conversion Flow Amount and Discounts

The conversion flow amount at block `i`, `conversionFlowAmount_i`, is an EMA of Quai conversion amounts, adjusted by two discounts: a **cubic conversion flow discount** and a **K-Quai discount**. It includes a minimum threshold:

<Frame>
  <img src="https://mintcdn.com/dominantstrategies/X4sucm2SYhI37-ls/images/conversionFlowAmount.png?fit=max&auto=format&n=X4sucm2SYhI37-ls&q=85&s=56e63d70cdddafdd98f2db15897ce479" width="826" height="52" data-path="images/conversionFlowAmount.png" />
</Frame>

* `conversionFlowAmount_{i-1}`: Previous block’s conversion flow amount.
* `currentFlowAmount_i`: Current block’s conversion amount before the discounts.

The 100 Quai minimum conversion flow amount is maintained to keep a baseline flow. The adjusted conversion flow is also capped at 2× the previous amount.

#### Cubic Conversion Flow Discount

Each conversion transaction receives a cubic discount:

<Frame>
  <img src="https://mintcdn.com/dominantstrategies/X4sucm2SYhI37-ls/images/flowDiscount.png?fit=max&auto=format&n=X4sucm2SYhI37-ls&q=85&s=937cfea0615697c38bdbf0533b6aa0a8" width="1357" height="107" data-path="images/flowDiscount.png" />
</Frame>

#### K-Quai Discount

K-Quai Discount applies to only one type of conversion at any point depending on the direction of the controller adjustment over the 4000 block window.
If exchange rate is increasing, then the discount applies to Quai to Qi conversions and if exchange rate is decreasing, the discount applies to
only Qi to Quai conversions.

<Frame>
  <img src="https://mintcdn.com/dominantstrategies/X4sucm2SYhI37-ls/images/kQuaiDiscount.png?fit=max&auto=format&n=X4sucm2SYhI37-ls&q=85&s=e4dc4931dae05df8257982e07f0cf40d" width="755" height="138" data-path="images/kQuaiDiscount.png" />
</Frame>

#### Discount Cap

`finalValue ≥ 0.1 × originalValue`

#### Max Slip Specification

* **Quai-to-Qi**:
  * Max Slip default: 90% (9000 basis points)
  * Specified in first two bytes of the Data field
  * Refunds happen via `etx` in next zone block

* **Qi-to-Quai**:
  * Data field must be 22 bytes: Bytes 0–1 for slip, 2–21 for refund address
  * Refunds are locked for two weeks, 1 Qi precision

***

### Exchange Rate Calculation

<Frame>
  <img src="https://mintcdn.com/dominantstrategies/X4sucm2SYhI37-ls/images/exchangeRate.png?fit=max&auto=format&n=X4sucm2SYhI37-ls&q=85&s=62bebce392ee23ec60c152e1ad3c4551" width="407" height="55" data-path="images/exchangeRate.png" />
</Frame>

Where:

* `kQuai_{i-1}`: Previous rate
* `α = 0.001`
* `d`: Normalized difficulty
* `d*`: Target difficulty

#### Normalized Difficulty

<Frame>
  <img src="https://mintcdn.com/dominantstrategies/X4sucm2SYhI37-ls/images/normalizedDifficulty.png?fit=max&auto=format&n=X4sucm2SYhI37-ls&q=85&s=8da714fd40b5f3d364d5bc1a872633ab" width="260" height="51" data-path="images/normalizedDifficulty.png" />
</Frame>

#### Target Difficulty

Simple average of adjusted difficulty over last 4000 blocks.

***

### Transaction Processing and Adjusted Difficulty

1. **Coinbase Transactions**: Add a choice to Quai or Qi
2. **Conversion Transactions**: Normalize by destination block reward

<Frame>
  <img src="https://mintcdn.com/dominantstrategies/yCY9rv1lNNAsH8Tn/images/adjDifficulty.png?fit=max&auto=format&n=yCY9rv1lNNAsH8Tn&q=85&s=5aec69a97d5a898ac1441e6ba3a623f9" width="1137" height="82" data-path="images/adjDifficulty.png" />
</Frame>

Sign depends on token choice majority.

***

## Summary

The Quai/Qi controller maintains equilibrium through interconnected mechanisms: miner difficulty adjusts to network effort, conversion flow applies stabilizing discounts, and the exchange rate evolves with normalized and target difficulties. Transaction-based adjustments further refine the system, ensuring fairness and stability in a dual-token framework. These dynamics adapt to miner behavior, conversion trends, and network activity, upholding the protocol’s neutral design.

With the emissions of Qi adjusting to technological trends and all other mechanisms seeking token neutrality between Qi and Quai, Qi becomes a tokenized representation of energy (hashes spent) with stable value over time compared to Quai which becomes a store of value.
