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
| Category | Range | Typical Gas |
|---|---|---|
| Curve operations | 3,000-10,000 | Low |
| Signature verification | 25,000-100,000 | Medium |
| ZK proof verification | 200,000-500,000 | High |
| FHE operations | 500,000 | Very 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/...