HikariSwapDocs

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 glanceFactory deploys Pairs via CREATE2 · Router is the user-facing entry point · TokenFactory is a permissionless LC20 deployer · Locker time-locks LP and arbitrary ERC-20s · FeeCollector accrues the 0.10% protocol fee and creation fees.

System overview

ContractRoleWhat it owns
HikariFactoryCREATE2 pair deployerINIT_CODE_PAIR_HASH, the canonical pair registry, the protocol-fee switch.
HikariPairConstant-product pool (xy = k)Reserves, LP token (built in), mint / burn / swap / skim / sync.
HikariRouterUser-facing entry pointWraps LCAI ↔ WLCAI, sequences multi-hop swaps, enforces deadlines & slippage.
HikariTokenFactoryPermissionless LC20 deployerCharges a creation fee in LCAI, forwards it to the FeeCollector.
HikariTokenDeployerTemplate bytecode for the 4 archetypesBound 1:1 to TokenFactory via a one-shot initFactory.
HikariFeeCollectorProtocol-revenue sinkHolds protocol-fee LP tokens + creation fees, owner-withdrawable.
HikariLockerTime-lock vaultLocks LP tokens or any ERC-20 with a unix unlock timestamp.

Lightchain Mainnet — chainId 9200

Explorer: lightscan.app · RPC: https://rpc.mainnet.lightchain.ai

INIT_CODE_PAIR_HASH

0x489397703d8f5ae7e08810ec5022c496f70c1e4b3b5c4d056c76ae0d590ee723

Lightchain Testnet — chainId 8200

Explorer: testnet.lightscan.app · RPC: https://rpc.testnet.lightchain.ai

INIT_CODE_PAIR_HASH

0x489397703d8f5ae7e08810ec5022c496f70c1e4b3b5c4d056c76ae0d590ee723

On testnet the HikariTokenFactory is configured with MIN_PRICE = 0 and 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.