Skip to main content

Automated Market Maker (AMM) Overview

INFORMATIONAL ONLY

This documentation explains the technical mechanics of the Hokusai AMM system. It is not investment advice. Trading tokens involves significant risk of loss. See the Investor Guide for complete risk disclosures.

The Hokusai AMM is a Constant Reserve Ratio (CRR) bonding curve that enables continuous buying and selling of model tokens using USDC. Each model has its own dedicated AMM pool, providing predictable pricing and always-available liquidity.

What is the Hokusai AMM?

The Hokusai AMM is an automated market maker built into every model token. It allows:

  • Buying tokens with USDC at a mathematically determined price
  • Selling tokens back to USDC (after the launch period)
  • API revenue integration that increases USDC reserves, supporting token value
  • Predictable pricing based on supply and reserve dynamics

Key Benefits

For Token HoldersFor Model ContributorsFor Investors
Always-available liquidityTokens have real market valueTransparent pricing
No need for order booksCan sell rewards for USDCContinuous price discovery
API fees increase valueFlexibility in compensationParticipate in launch period
Deterministic pricingLower transaction costsSupport promising models

Why CRR Instead of Other AMMs?

The Hokusai protocol uses a Constant Reserve Ratio (CRR) bonding curve rather than traditional AMM models like Uniswap's Constant Product formula. Here's why:

Comparison with Other AMM Types

FeatureHokusai CRRUniswap (x*y=k)Order Book
LiquidityAlways availableRequires LPsRequires orders
Price DiscoveryDeterministic formulaSupply/demandBid/ask spread
SlippagePredictableVariableDepends on depth
LP Needed?NoYesNo
Impermanent LossNone (single-sided)Yes (two-sided)N/A
API Fee IntegrationDirect to reservesGoes to LPsN/A

CRR Advantages

  1. Single-Sided Liquidity: Only USDC reserves needed, no token-USDC pairs
  2. Predictable Pricing: Mathematical formula makes prices deterministic
  3. API Revenue Integration: Fees directly increase reserve backing
  4. No Impermanent Loss: Single-asset model eliminates IL risk
  5. Always Available: No need to bootstrap liquidity providers

How It Works: Before vs After AMM

Before: Burn-Only Model

[Earn Tokens] → [Hold] → [Burn for API Access]

No Exit
  • ✅ Tokens earned for performance improvements
  • ❌ No way to sell tokens
  • ❌ No market price discovery
  • ❌ API fees just collected, didn't affect token value

After: CRR AMM Model

[Earn Tokens] → [Hold] ←→ [Buy/Sell on AMM] ←→ [USDC]
↓ ↓ ↓
Burn for Liquidity API Fees → Reserve ↑ → Price ↑
Access
  • ✅ Tokens earned for performance improvements
  • ✅ Can sell tokens for USDC anytime (after launch)
  • ✅ Market price based on reserves and supply
  • ✅ API fees increase reserves, raising token floor price

CRR Bonding Curve Mechanics

The AMM uses a Constant Reserve Ratio (CRR) formula where the ratio between USDC reserves and token market cap remains constant.

Visual: How Reserves Impact Price

Key Insight: API fee deposits increase reserves WITHOUT minting tokens, creating stronger price appreciation than buy orders.

Numerical Example: Reserve Impact

EventUSDC ReserveToken SupplySpot PriceChange
Initial$10,00010,000$0.333-
After $1,000 buy$11,00011,000$0.333+0%
After $1,000 fee deposit$11,00010,000$0.367+10%

Why the difference?

  • Buy order: Both R and S increase proportionally, price stays similar
  • Fee deposit: Only R increases, price rises significantly

Core Formula

Constant: k = R^w × S

Where:
R = USDC reserve balance
S = Token supply
w = Constant Reserve Ratio (CRR)
k = Invariant constant

Buy Formula

When you buy tokens by depositing USDC:

T = S × ((1 + E/R)^w - 1)

Where:
T = Tokens minted
S = Current supply before purchase
R = Current reserve before purchase
E = USDC deposited
w = CRR (typically 10-30%)

Example: Buying with 1,000 USDC when R=100,000, S=1,000,000, w=0.2:

T = 1,000,000 × ((1 + 1,000/100,000)^0.2 - 1)
T = 1,000,000 × ((1.01)^0.2 - 1)
T = 1,000,000 × (1.00199 - 1)
T ≈ 1,990 tokens

Sell Formula

When you sell tokens back for USDC:

F = R × (1 - (1 - T/S)^(1/w))

Where:
F = USDC returned
T = Tokens burned
S = Current supply before sale
R = Current reserve before sale
w = CRR

Example: Selling 1,990 tokens when R=101,000, S=1,001,990, w=0.2:

F = 101,000 × (1 - (1 - 1,990/1,001,990)^(1/0.2))
F = 101,000 × (1 - (0.998013)^5)
F ≈ 995 USDC (after fees)

Spot Price

The current price per token at any moment:

P = R / (w × S)

Where:
P = Spot price (USDC per token)
R = Current reserve
S = Current supply
w = CRR

Example: When R=100,000, S=1,000,000, w=0.2:

P = 100,000 / (0.2 × 1,000,000)
P = 100,000 / 200,000
P = 0.5 USDC per token

Seven-Day Launch Period

Every new model token starts with a seven-day bonding round:

Day 0: Deploy → Buy enabled, Sell disabled
Day 1-6: Bonding Round → Buy only
Day 7: Launch Complete → Buy & Sell enabled

Why Buy-Only?

The initial buy-only period:

  • ✅ Establishes initial price discovery
  • ✅ Prevents manipulation and front-running
  • ✅ Allows early supporters to accumulate
  • ✅ Builds initial USDC reserves
  • ⚠️ No selling allowed during this time

Learn more: Launch Period Guide

API Fee Integration

A key innovation of the Hokusai AMM is how API usage fees increase token value:

[Model Usage] → [API Fees Collected]

[Convert to USDC] → [depositFees() to AMM]

[Reserve Increases] → [Spot Price Increases]

[Token Holders Benefit]

How Fees Affect Price

When API fees are deposited:

  • Reserve (R) increases
  • Supply (S) stays constant
  • Spot price P = R / (w × S) increases proportionally

Example: Reserve increases by 10%:

Before: P = 100,000 / (0.2 × 1,000,000) = 0.5 USDC
After: P = 110,000 / (0.2 × 1,000,000) = 0.55 USDC
Result: +10% price increase

Learn more: API Fee Flow

Fee Structure

The system has two separate fee mechanisms - don't confuse them:

1. AMM Trading Fees (when buying/selling tokens on AMM)

Trade Fees:

  • Default: 0.25% per trade
  • Maximum: 10% (governance-controlled)
  • Applied to: Both buys and sells on the AMM
  • Purpose: AMM sustainability

Protocol Fees:

  • Default: 5% of trade fees
  • Maximum: 50% of trade fees (governance-controlled)
  • Applied to: Portion of trade fees only
  • Purpose: Treasury funding, future governance incentives

Example AMM Trade:

Buy: 1,000 USDC
Trade Fee (0.25%): 2.50 USDC
Protocol Fee (5% of 2.50): 0.125 USDC
Net Deposited to Reserve: 997.50 USDC
Tokens Received: ~1,985 (calculated from buy formula)

2. API Usage Fees (when using model API)

Separate from AMM trading fees, routed by UsageFeeRouter:

  • 20% to AMM Reserve: Increases token backing, raises price
  • 80% to Infrastructure: Covers compute, hosting, bandwidth

See API Fee Flow for complete details.

Security Features

The HokusaiAMM contract includes comprehensive security measures:

Slippage Protection

function buy(uint256 minTokens, uint256 deadline) external payable {
require(tokensReceived >= minTokens, "Slippage too high");
require(block.timestamp <= deadline, "Transaction expired");
// ...
}

Protects against:

  • ✅ Price movement during transaction
  • ✅ Front-running attacks
  • ✅ Stale transactions

Reentrancy Guards

All state-changing functions use OpenZeppelin's nonReentrant modifier to prevent reentrancy attacks.

Emergency Pause

Contract owner can pause trading in emergency situations while preserving user funds.

Parameter Bounds

  • CRR (w): 5% to 50%
  • Trade Fee: 0% to 10%
  • Protocol Fee: 0% to 50%

All parameters are governance-controlled with strict bounds.

User Personas and AMM

Data Suppliers

  • Earn: Tokens for improving model performance
  • Option 1: Hold tokens for long-term value
  • Option 2: Sell tokens on AMM for immediate USDC
  • Benefit: Flexible compensation choices

Model Developers

  • Launch: Deploy token with AMM
  • Benefit: Automatic liquidity for contributors
  • Control: Set initial parameters and launch period
  • Growth: API fees increase token value automatically

Investors

  • Participate: During seven-day launch period
  • Buy: Tokens at current bonding curve price
  • Support: Promising models with initial capital
  • Exit: Sell after launch period at market price

Learn more: Investor Guide

Getting Started

For Buyers

  1. Acquire USDC in your wallet
  2. Navigate to the model's AMM page
  3. Get a quote: How many tokens for X USDC?
  4. Set slippage tolerance (e.g., 1%)
  5. Execute buy transaction

Complete Buy Guide →

For Sellers

  1. Check if bonding round is complete (day 7+)
  2. Get a quote: How much USDC for Y tokens?
  3. Approve token spending
  4. Set slippage tolerance
  5. Execute sell transaction

Complete Sell Guide →

Technical Resources

Smart Contracts

  • HokusaiAMM: Core AMM implementation with buy/sell/depositFees
  • HokusaiAMMFactory: Deploys new AMM pools for models
  • UsageFeeRouter: Routes API fees to AMM reserves

Contract Reference →

Formulas

FAQ

Q: Can I lose money buying tokens?

Yes. Token prices can go down if:

  • Model usage decreases (fewer API fees)
  • More tokens are minted (supply increases)
  • Sellers exceed buyers

Q: What's the difference between "buying" and "minting"?

  • Minting: Creating new tokens as rewards for performance improvements (supply ↑)
  • Buying: Exchanging USDC for existing tokens via AMM (supply ↑, reserve ↑)

Q: Why can't I sell during the first 7 days?

The buy-only period prevents manipulation and ensures fair price discovery. After day 7, full trading is enabled.

Q: What happens to API fees?

API fees are converted to USDC and deposited into the AMM reserve using depositFees(). This increases the reserve without minting tokens, raising the spot price.

Q: Who controls the AMM parameters?

Initially the model owner, later potentially transitioned to token holder governance.

Q: Is there a minimum or maximum trade size?

Yes, to prevent manipulation. Exact limits are set per model and governance-controlled.

Next Steps

For additional support, contact our Support Team or join our Community Forum.