AMM Pricing Formula

Deep dive into the Automated Market Maker (AMM) pricing mechanism used in Owna-DEX.


Core Concept: Constant Product Formula

Owna-DEX uses the Constant Product AMM formula, pioneered by Uniswap V2:

x × y = k

Where:

  • x = Reserve of Token 0 (e.g., YRT)

  • y = Reserve of Token 1 (e.g., USDC)

  • k = Constant product (must remain constant after trades, excluding fees)


How Pricing Works

Initial Pool Setup

When a property owner adds initial liquidity, the price is determined by the ratio:

Price = y / x = Reserve_USDC / Reserve_YRT

Example:

Initial Liquidity:
- 1000 YRT
- 1000 USDC

Initial Price:
- 1000 / 1000 = 1 USDC per YRT

Constant k:
- k = 1000 × 1000 = 1,000,000

Trading Mechanics

Buy Example: User Swaps USDC for YRT

Scenario: User wants to buy YRT with 100 USDC

Step 1: Calculate reserves before trade

Step 2: Apply fee (0.3%)

Step 3: Calculate output using constant product

Step 4: New state after trade

Result:

  • User paid: 100 USDC

  • User received: 90.66 YRT

  • Effective price: 1.103 USDC/YRT

  • Price impact: +20.9%

  • Fee collected: 0.3 USDC


Sell Example: User Swaps YRT for USDC

Scenario: User wants to sell 50 YRT

Step 1: Current reserves

Step 2: Apply fee (0.3%)

Step 3: Calculate output

Step 4: New state

Result:

  • User paid: 50 YRT

  • User received: 57.13 USDC

  • Effective price: 1.143 USDC/YRT

  • Price impact: -10.1%


Key Formulas

Price Calculation

Swap Output (Exact Input)

Swap Input (Exact Output)

Liquidity Provision


Price Impact

Price impact measures how much a trade changes the pool price.

Formula

Example Calculations

Trade Size (USDC)
Output (YRT)
Price Impact
Effective Price

10

9.90

+1.0%

1.010 USDC/YRT

50

47.62

+5.3%

1.050 USDC/YRT

100

90.66

+10.9%

1.103 USDC/YRT

500

333.33

+50.0%

1.500 USDC/YRT

1000

500.00

+100.0%

2.000 USDC/YRT

Key Insight: Large trades relative to pool size cause exponential price impact.


Slippage Protection

Slippage occurs when the execution price differs from the expected price due to:

  1. Price movement between quote and execution

  2. Front-running by other traders

  3. Low liquidity causing high price impact

Implementation

Router provides slippage protection via amountOutMin parameter:


Fee Mechanism

Fee Structure

Fee Distribution

Current Implementation:

  • 100% of fees go to feeRecipient wallet (property owner)

  • Fees are collected in the input token (USDC when buying YRT)

Fee Calculation Example


Liquidity Provider Economics

LP Token Value

Example: Adding Liquidity

Removing Liquidity


Advanced Concepts

Impermanent Loss

Impermanent loss occurs when token price ratio changes after providing liquidity.

Formula:

Example:

Mitigation: Fees can offset impermanent loss over time.

Minimum Liquidity Lock

First liquidity provider permanently locks MINIMUM_LIQUIDITY = 1000 LP tokens to prevent division by zero attacks.


Price Oracle

The pool reserves can serve as a simple price oracle:

Warning: Spot price is manipulatable via flash loans. For critical price feeds, use time-weighted average price (TWAP) or Chainlink oracles.


Gas Optimization

Batching Swaps

For multiple swaps, batch through router to save gas:

Liquidity Management

Add/remove liquidity during low gas periods:

  • Base network: typically ~0.0001 ETH per transaction

  • Gas cost is relatively constant regardless of liquidity size



Formula Reference Card:


Last Updated: October 2025

Last updated