Core
WarpFactory
Source: packages/core/contracts/WarpFactory.sol
Responsibilities:
Deploys every
WarpPair(usingCREATE2) and records them in thegetPairmapping.Exposes
INIT_CODE_PAIR_HASH = 0x0904716a2e7c34f649f3837f2424539ef9f2c8cc5ba0d9d55ed439d013b94ce0deterministic pair address derivation.
Key functions:
function allPairsLength() external view returns (uint)
Count pairs for pagination.
function getPair(address tokenA, address tokenB) external view returns (address)
Query existing pair (tokens sorted internally).
function createPair(address tokenA, address tokenB) external returns (address pair)
Deploys a new pair. Reverts on identical/zero addresses or if the pair already exists.
Event: PairCreated(token0, token1, pair, pairIndex) fires whenever a new pool is deployed. Listen to this to surface freshly created pools without polling.
WarpPair
Source: packages/core/contracts/WarpPair.sol
Warp LP tokens implement IWarpPair + ERC-20 + EIP-2612 permit. Highlights:
Immutable token ordering:
token0,token1stored on initialization.getReserves()returns reserves and the timestamp of the last sync for TWAP calculations.MINIMUM_LIQUIDITY = 1_000LP tokens are permanently locked to prevent divide-by-zero on the initial liquidity event.Fees: 0.30% swap fee (997/1000 factor) with optional protocol fee (mints 1/6 of √k growth to
feeToif set).Flash swaps:
swap()accepts arbitrarydata; ifdata.length > 0, it callbacksIWarpCallee.warpCall(sender, amount0Out, amount1Out, data). Return the owed tokens before the function completes.Housekeeping helpers:
skim(address)sends any excess tokens (beyond reserves) toto,sync()forcibly updates reserves to match balances.
Key entrypoints and why integrators use them:
function mint(address to) external returns (uint liquidity)
Called by the router after tokens have been transferred in. Returns LP tokens minted to to.
function burn(address to) external returns (uint amount0, uint amount1)
Burns LP tokens held by the pair and sends out the underlying assets.
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data)
Core swap primitive. Either amount0Out or amount1Out must be > 0. Caller must have already sent the input tokens in.
function permit(...) external
Enables gasless approvals so removeLiquidityWithPermit can operate without a prior approve.
function getReserves() + price0CumulativeLast/price1CumulativeLast
Fetch raw reserves and cumulative price data for off-chain quoting/TWAPs.
Events worth indexing: Mint, Burn, Swap, Sync, and standard ERC-20 Transfer/Approval.
Last updated