The precompile previously gated native (asset == address(0)) behind
ErrNativeUnsupported, claiming it could not read msg.value. That was wrong:
the EVM moves msg.value into the precompile address BEFORE Run, so native is
handled by the exact observed-balance idiom dex/settle_custody.go already
uses. Native is now a first-class asset, fully symmetric to ERC-20:
- lock: delivered = GetBalance(swapAddr) - reserve[native]; require == amount
exactly (rejects value==0, short, and over-delivery — the native analog of
the ERC-20 transferFrom-delta in pullExact). Never mints; the value was
moved by the caller's frame.
- claim/refund: real SubBalance(swapAddr)/AddBalance(to) via the single payOut
dispatcher, underflow-guarded (SubBalance is uint256-modular from a
precompile). Conservation balanceOf(swapAddr) == reserve[asset] holds for
native exactly as for ERC-20.
No interface change, no new capability — uses contract.StateDB's existing
GetBalance/Add/SubBalance. ErrNativeUnsupported removed. LXSwapHTLC.sol doc
corrected (both legs custody native symmetrically). go test -race ./swap/...
green (21 tests incl. native lock/claim/refund + conservation).
The off-Lux mirror of the LP-90A0 swap precompile, deployable on any EVM
chain that is not Lux (Ethereum, an L2). Bound to the precompile leg ONLY
by a shared SHA-256 hashlock: one 32-byte preimage claims both legs, so
revealing it on one chain exposes it for the counterparty on the other.
Mirrors the precompile bit-for-bit — SHA-256 hashlock, 32-byte preimage,
exact-delta ERC-20 pull (rejects fee-on-transfer), disjoint claim/refund
windows, effects-before-interaction under a non-reentrant guard, no owner /
pause / mint / upgrade selector (non-custody is structural). Adds native-ETH
custody via msg.value, the precompile's gated case (ErrNativeUnsupported).
Compiles clean under solc 0.8.24 (zero warnings).
Rename the mock external perps venue in the integration test to a neutral
name and reword NatSpec/docs to Lux's own terms (native HFT surface,
single-entrypoint execute() dispatch, robust index methodology).
Behavior-preserving: integration test passes; no ABI changes.