Contracts
HikariSwap is a seven-contract system deployed on Lightchain Mainnet (chainId 9200) and Lightchain Testnet (chainId 8200). The core AMM is an audited Uniswap V2 fork; the token factory and time-lock are first-party additions for builders shipping on Lightchain.
At a glance —
FactorydeploysPairs via CREATE2 ·Routeris the user-facing entry point ·TokenFactoryis a permissionless LC20 deployer ·Lockertime-locks LP and arbitrary ERC-20s ·FeeCollectoraccrues the 0.10% protocol fee and creation fees.
System overview
| Contract | Role | What it owns |
|---|---|---|
HikariFactory | CREATE2 pair deployer | INIT_CODE_PAIR_HASH, the canonical pair registry, the protocol-fee switch. |
HikariPair | Constant-product pool (xy = k) | Reserves, LP token (built in), mint / burn / swap / skim / sync. |
HikariRouter | User-facing entry point | Wraps LCAI ↔ WLCAI, sequences multi-hop swaps, enforces deadlines & slippage. |
HikariTokenFactory | Permissionless LC20 deployer | Charges a creation fee in LCAI, forwards it to the FeeCollector. |
HikariTokenDeployer | Template bytecode for the 4 archetypes | Bound 1:1 to TokenFactory via a one-shot initFactory. |
HikariFeeCollector | Protocol-revenue sink | Holds protocol-fee LP tokens + creation fees, owner-withdrawable. |
HikariLocker | Time-lock vault | Locks LP tokens or any ERC-20 with a unix unlock timestamp. |
Lightchain Mainnet — chainId 9200
Explorer: lightscan.app · RPC: https://rpc.mainnet.lightchain.ai
| Contract | Address |
|---|---|
WLCAI | 0xeBf97f16d843bFD9d9E6B1857B4C00d94ca7e2B2 |
HikariFactory | 0x5f4f2076dbada2D8335854DFcff9D493f2e69EaE |
HikariRouter | 0xF90CbB10099898e47c389550F3A5d4dD145a0794 |
HikariTokenFactory | 0x1ffcf7bDCD96885f1456C2f9ac181D77152A0834 |
HikariTokenDeployer | 0xA6fD5fE0E655b7DF4435232C961Bf8Bd3B2fF690 |
HikariFeeCollector | 0xbf357c921fD7dc02F536C949E01906113De339A4 |
HikariLocker | 0xb1Ba9C9a6f6E80CFDB7bf2F77C630DC420c3A558 |
INIT_CODE_PAIR_HASH
0x489397703d8f5ae7e08810ec5022c496f70c1e4b3b5c4d056c76ae0d590ee723
Lightchain Testnet — chainId 8200
Explorer: testnet.lightscan.app · RPC: https://rpc.testnet.lightchain.ai
| Contract | Address |
|---|---|
WLCAI | 0x4E31781fa4d3A7970B01d6b2C4357fDa6B6fE243 |
HikariFactory | 0x5f4f2076dbada2D8335854DFcff9D493f2e69EaE |
HikariRouter | 0x8765311ea529048FBD9D2578f8f1E4f71E6164Cd |
HikariTokenFactory | 0x0f4fFFd5864e41dB5f3aa8132e372e379FFe5f96 |
HikariTokenDeployer | 0x7cF3c8Bf167dCFDd49E397aA27476470556A8b4a |
HikariFeeCollector | 0xbf357c921fD7dc02F536C949E01906113De339A4 |
HikariLocker | 0xb1Ba9C9a6f6E80CFDB7bf2F77C630DC420c3A558 |
INIT_CODE_PAIR_HASH
0x489397703d8f5ae7e08810ec5022c496f70c1e4b3b5c4d056c76ae0d590ee723
On testnet the
HikariTokenFactoryis configured withMIN_PRICE = 0and all archetype prices= 0, so token creation is free. Mainnet retains the 1,000 LCAI creation floor.
Wrapped LCAI (WLCAI)
Native LCAI is wrapped to WLCAI for ERC-20-compatible routing. The Router handles wrapping and unwrapping transparently — callers can pay in or receive native LCAI without touching WLCAI directly. WLCAI is a standard WETH9-pattern wrapper: deposit() mints 1:1, withdraw(amount) burns 1:1.
Pair-address derivation
Pair addresses are deterministic. Compute them off-chain without an RPC round-trip:
pair = CREATE2(
factory,
salt = keccak256(token0, token1),
initCodeHash = INIT_CODE_PAIR_HASH
)
Cache INIT_CODE_PAIR_HASH once (the value above) and you can derive every pair address client-side. The hash is identical on Mainnet and Testnet because the HikariPair creation bytecode is identical.
ABIs & source
The frontend ships pre-extracted ABIs in packages/contracts/src/abis. They are written straight from forge build artifacts — no hand editing.
To regenerate after a contract change:
node scripts/export-abis.mjs
The script reads from ../swap/out/ (the contracts repo) and writes to packages/contracts/src/abis/.
Events for indexers
The two events any subgraph or indexer needs to ingest the protocol firehose:
// HikariFactory — one event per new pool
event PairCreated(
address indexed token0,
address indexed token1,
address pair,
uint
);
// HikariTokenFactory — one event per new LC20
event TokenCreated(
address indexed token,
address indexed creator,
TokenType tokenType,
string name,
string symbol,
uint8 decimals,
uint256 totalSupply,
uint256 nonce
);
HikariPair emits the standard Uniswap V2 events: Mint, Burn, Swap, Sync. HikariLocker emits LockCreated / LockReleased.
Until a subgraph is live, the UI uses direct on-chain reads.
Verification & security
All deployments are source-verified on Lightscan — click any address above to see the verified source and matching bytecode. The AMM is a fork of Uniswap V2 with no behavioral changes; see Security for the audit posture and known-trust assumptions.