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. A controller mechanism ensures neutrality between Quai and Qi, preventing any inherent bias toward either token. This section details the mathematical formulations governing miner difficulty, conversion flow, exchange rate, and transaction adjustments within the protocol.

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:

  • 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, 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):

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:

  • 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:

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.

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

Where:

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

Normalized Difficulty

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

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.