Lux Docs
Standard

Lux Standard Library

Production Solidity contracts for the Lux Network - DeFi, governance, identity, privacy, and 39 precompiles

The Lux Standard Library (@luxfi/contracts) is the canonical Solidity contracts package for the Lux Network ecosystem. It provides production-ready contracts for DeFi protocols, governance, identity, cross-chain bridges, post-quantum cryptography, and FHE confidential computing.

Installation

npm install @luxfi/contracts

For Foundry projects:

forge install luxfi/standard

Add to remappings.txt:

@luxfi/contracts/=lib/standard/contracts/

Contract Categories

CategoryDirectoryDescription
AMMamm/V2 constant-product, V3 concentrated liquidity, StableSwap
Lendingmarkets/Morpho-style isolated lending markets
Perpetualsperps/GMX-style leveraged perpetual futures
Liquidliquid/Yield-bearing bridge tokens (LETH, LBTC, LUSD), xLUX vault
Governancegovernance/Governor, Timelock, vLUX, Karma, DLUX, GaugeController
Identityidentity/W3C DID Registry, Soulbound NFTs, Reputation
NFT AMMlssvm/sudoswap-style bonding curve NFT trading
Optionsoptions/European options with ERC-1155 positions
Streamingstreaming/Sablier-style linear and cliff token vesting
Insuranceinsurance/Protocol coverage with underwriter staking
Privacyprivacy/Z-Chain UTXO notes with Poseidon2 and STARK proofs
FHEfhe/Fully Homomorphic Encryption for confidential contracts
Precompilesprecompile/39 EVM precompiles (PQ crypto, DeFi, ZK, attestation)
Bridgebridge/Cross-chain Warp messaging and LRC20B tokens
Tokenstokens/LRC20, WLUX, AI, and token extensions

Quick Start

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@luxfi/contracts/tokens/LRC20.sol";

contract MyToken is LRC20 {
    constructor() LRC20("My Token", "MTK") {
        _mint(msg.sender, 1_000_000e18);
    }
}

Architecture

The library is organized by protocol domain. Each module is self-contained with its own interfaces, and cross-module imports use the @luxfi/contracts/ prefix. All contracts compile with Solidity 0.8.31, EVM target Cancun, and 200 optimizer runs.

contracts/
  amm/           # V2, V3, StableSwap factories and routers
  markets/       # Isolated lending (Morpho-style)
  perps/         # Perpetual futures vault, router, LLP
  liquid/        # LiquidLUX (xLUX), bridge tokens (LETH, LBTC...)
  governance/    # Governor, vLUX, Karma, DLUX, GaugeController
  identity/      # DIDRegistry, DIDResolver, PremiumDID
  lssvm/         # NFT AMM with linear and exponential curves
  options/       # European options (ERC-1155)
  streaming/     # Token streaming and vesting
  insurance/     # Protocol insurance pools
  privacy/       # ZNote, ZNotePQ, PrivateTeleport
  fhe/           # FHE.sol, ConfidentialERC20, Gateway
  precompile/    # Interfaces for 39 EVM precompiles
  bridge/        # Warp-based cross-chain transfers
  tokens/        # LRC20, WLUX, AI, LUX
  oracle/        # Multi-source price aggregation
  treasury/      # FeeSplitter, ValidatorVault, FeeGov

Build and Test

# Build all contracts
forge build

# Run full test suite (761 tests)
forge test

# Gas reporting
forge test --gas-report

# Coverage
forge coverage

On this page