The Relativity of Price in Decentralized Exchanges
To properly grasp ghostDAO’s business logic, we must first examine the foundational mechanics of DEX V2 (hereafter referred to simply as DEX). At its core, DEX price discovery for any Token X operates on the principle of relativity to Token Y. This elegant alignment of supply-demand dynamics makes decentralized price discovery uniquely compelling.
In traditional markets, we’ve grown accustomed to pricing everything in national currencies:
- Oil priced in USD
- Gold quoted in EUR
- Stocks valued in JPY
- Consumer goods measured in CNY
We often overlook that these prices simply represent relative values to local fiat currencies.
For example, as of May 8, 2025, one ounce of gold was trading at $3,300 USD. That same ounce could be purchased or sold for 24,000 CNY. Same ounce of gold, different relative values of local currencies (e.g. USD and CNY).
This same principle of relative valuation governs DEX price discovery.
The Mathematics of Constant Product Markets
Consider a liquidity pool containing:
- x₁: quantity of Token X
- y₁: quantity of Token Y
The pool maintains a constant product k defined as:
The price of Token X in terms of Token Y is:
as the price of Token X is defined solely by how much Token Y has been supplied to the pair.
Similarly, the price of Token Y in terms of Token X is:
as the price of Token Y is defined solely by how much Token X has been supplied to the pair.
DEX Mechanics Without Fees
What’s the quantity of Token Y that a user will be able to purchase with x2 of Token X?
When a user swaps x2 of Token X for y2 of Token Y (assuming zero fees), the constant product relationship persists:
where x2 is how much of Token X will be added to the DEX in exchange for y2 of Token Y, which will be removed from the DEX into user’s wallet.
If we expand the equation above, we receive the following:
Let’s try to solve for y2:
And, finally:
There are three final formulas that can be equally used for solving for y2 from the above:
Practical Example: eGHST-DAI Pair
Consider a DEX pool with:
- QD(DAI)e1 = 100,000 DAI
- QD(eGHST)e1 = 10,000 eGHST
The product constant calculates as:
Key observations about k:
- Increases when liquidity is added to the pool
- Decreases when liquidity is removed
- Remains constant during fee-less swaps
The initial eGHST price:
Price Impact Calculation
Scenario: User swaps 1,000 DAI for eGHST.
How much eGHST can a user purchase with 1000 DAI?
Post-swap pool balances:
- QD(DAI)e1,final = 101,000 DAI
- QD(eGHST)e1,final = 9,900.99 eGHST
New price calculation:
Key outcomes:
- Price impact: 2% increase (from $10.00 DAI to $10.20 DAI per eGHST)
- Slippage Relationship:
- 1% of total DAI reserves (1,000 DAI swap to 100,000 DAI reserves) caused 2% price slippage
- Larger pools exhibit less price impact
- Illiquid pairs experience greater slippage
This example demonstrates how DEX mechanics naturally creates price elasticity based on pool depth, a fundamental concept that ghostDAO leverages in its business logic.