Lux Docs
Precompile

Precompile API

How to call Lux precompiles from Solidity contracts

Precompiles are called like regular contracts at their fixed addresses. No deployment needed.

Calling Convention

Use a Solidity interface targeting the precompile address:

interface IPoolManager {
    struct PoolKey {
        address currency0; address currency1;
        uint24 fee; int24 tickSpacing; address hooks;
    }
    struct SwapParams {
        bool zeroForOne; int256 amountSpecified; uint160 sqrtPriceLimitX96;
    }
    function swap(PoolKey calldata key, SwapParams calldata params,
        bytes calldata hookData) external returns (int256, int256);
}

IPoolManager constant POOL_MANAGER = IPoolManager(address(0x0400));

Post-Quantum Verification

interface IMLDsa {
    function verify(bytes calldata message, bytes calldata signature,
        bytes calldata publicKey) external view returns (bool);
}

IMLDsa constant ML_DSA = IMLDsa(address(0x0600));

Gas Costs

CategoryRangeTypical Gas
Curve operations3,000-10,000Low
Signature verification25,000-100,000Medium
ZK proof verification200,000-500,000High
FHE operations500,000Very high

Error Handling

Precompiles revert with standard EVM revert data on invalid input: wrong signature length, malformed public key, failed proof verification, or unsupported parameter set.

Testing

go test -v github.com/luxfi/precompile/...
go test -bench=. -benchmem github.com/luxfi/precompile/dex/...

On this page