Lux Standard

AMM

Automated Market Maker pools for token swaps and liquidity provision

AMM (Automated Market Maker)

Uniswap-compatible AMM infrastructure for token swaps and liquidity provision. Includes v2 constant-product pools and v3 concentrated liquidity pools.

Overview

Architecture

┌─────────────────────────────────────────────────────────────────────────┐
│                           AMM Infrastructure                             │
├────────────────────────────┬────────────────────────────────────────────┤
│         V2 Pools           │              V3 Pools                      │
│   (Constant Product)       │        (Concentrated Liquidity)            │
├────────────────────────────┼────────────────────────────────────────────┤
│ • UniswapV2Factory         │ • UniswapV3Factory                         │
│ • UniswapV2Pair            │ • UniswapV3Pool                            │
│ • UniswapV2Router          │ • NonfungiblePositionManager               │
│ • x * y = k invariant      │ • Tick-based liquidity                     │
│ • 0.3% swap fee            │ • Multiple fee tiers (0.01-1%)             │
└────────────────────────────┴────────────────────────────────────────────┘


                    ┌───────────────────────────────┐
                    │         SwapRouter02          │
                    │   Unified v2 + v3 interface   │
                    └───────────────────────────────┘


                    ┌───────────────────────────────┐
                    │            WLUX               │
                    │   Wrapped LUX (ERC20)         │
                    └───────────────────────────────┘

Quick Start

import "@luxfi/standard/src/uni/swapRouter/SwapRouter02.sol";
import "@luxfi/standard/src/uni/WLUX.sol";

// Wrap LUX to WLUX
wlux.deposit{value: 1 ether}();

// Swap WLUX for LUXD via v2
router.swapExactTokensForTokens(
    amountIn,
    amountOutMin,
    [WLUX, LUXD],
    recipient,
    deadline
);

// Swap via v3 with exact input
router.exactInputSingle(
    ISwapRouter.ExactInputSingleParams({
        tokenIn: WLUX,
        tokenOut: LUXD,
        fee: 3000, // 0.3%
        recipient: msg.sender,
        amountIn: 1e18,
        amountOutMinimum: 0,
        sqrtPriceLimitX96: 0
    })
);

V2 vs V3 Comparison

FeatureV2V3
LiquidityFull rangeConcentrated
Capital EfficiencyLowHigh (up to 4000x)
Fee Tiers0.3% fixed0.01%, 0.05%, 0.3%, 1%
LP TokensERC20NFT (ERC721)
Price OracleTWAPEnhanced TWAP
ComplexitySimpleAdvanced

Fee Tiers (V3)

TierFeeUse Case
0.01%100Stablecoin pairs (LUXD/USDC)
0.05%500Correlated pairs (LETH/WLUX)
0.3%3000Standard pairs
1%10000Exotic/volatile pairs

Integration with DeFi

The AMM pools power other DeFi protocols:

  • Lending Pools: Swap collateral to debt assets
  • Flash Loans: Arbitrage between pools
  • Margin Trading: Swap execution for leveraged positions
  • Loans: Swap yield tokens for synthetic assets
  • Pools - V2 and V3 pool contracts
  • Router - SwapRouter02 interface
  • WLUX - Wrapped LUX token
  • Lending - Lending pools that use AMM swaps

On this page