Lux Precompiles

DEX Precompiles

Uniswap v4-style native DEX operations

DEX Precompiles

Native EVM precompiles implementing Uniswap v4-style decentralized exchange with singleton architecture.

Address Range

DEX precompiles occupy addresses 0x0400 through 0x0403.

Core Precompiles

AddressPrecompileGasDescription
0x0400PoolManager2.26μsSingleton pool management
0x0401SwapRouterVariableOptimized swap routing
0x0402HooksRegistryVariableHook contract registry
0x0403FlashLoanVariableFlash loan facility

Extended Precompiles

AddressPrecompileGasDescription
0x0410LendingPool15,000Supply/borrow with collateral
0x0411InterestRate5,000Dynamic interest rate curves
0x0412Liquidator50,000Liquidation engine
0x0420PerpEngine25,000Perpetuals (up to 1111x leverage)
0x0421FundingRate10,000Funding rate calculation
0x0430LiquidVault20,000Self-repaying loans (90% LTV)

Performance Benchmarks (Apple M1 Max)

OperationLatencyThroughput
Swap2.26μs443K ops/sec
ModifyLiquidity2.87μs348K ops/sec
PoolKeyID439ns2.7M ops/sec

Usage

import {IPoolManager} from "@luxfi/precompile/dex/IPoolManager.sol";

contract SwapExample {
    IPoolManager constant POOL = IPoolManager(0x0400);

    function swap(
        PoolKey calldata key,
        IPoolManager.SwapParams calldata params
    ) external returns (BalanceDelta) {
        return POOL.swap(key, params, "");
    }
}

Architecture

The DEX precompile implements:

  • Singleton Architecture - All pools in single contract
  • Flash Accounting - Token transfers netted at transaction end
  • Hooks System - Modular contracts for custom pool logic
  • Native LUX Support - No wrapping required

On this page