This chapter is the map for engineers: every contract Elyra deploys, the programs that run around them, and the two paths data takes, a write from your wallet to a contract and a read from the chain back to a page. Every other chapter zooms into one part of it. Every name in code can be found with a search of the repository.
contracts/srcholds the liquidity-management layer (position tools, vaults, launch tracking, pre-market perps, fees), andcontracts/src/venueholds Elyra's own pools, routing and the $ELYRA buyback. One call,ElyraWiring.deployAll, deploys the fixed contracts; factories make the rest later: DLMM pairs, pool vaults, launch tokens and vault clones.- Your browser sends your transactions itself, through one hook (
useWrite) that simulates each call before your wallet opens. No Elyra server sends a transaction for you. - Pages read from the API. The API reads the indexer over GraphQL, Elysium over RPC, Hyperliquid's public market data and its own database. The browser never queries the indexer.
- Operator keys are named at deploy: an owner (cold, owns four venue admin contracts and Elyra's price feeds), three hot bot keys with one role each (a hedger, a vault keeper and a price feed keeper; the deploy refuses two roles on one key), and one funder per hedged vault (cold; takes that vault's margin to Hyperliquid, owns the account it lands in and names the vault's hedger). The signer also holds one Hyperliquid agent wallet per account, which can trade and cannot withdraw.
- The maths every page shows is written once, in
@elyra/core. ABIs, addresses and the deployment manifest are written once, in@elyra/abi.
The map
Read it from the top. The browser, the API and its bots, the indexer and the signer sit off chain; all of them reach the contracts through Elysium's RPC, and the signer and the hedger also talk to Hyperliquid. On chain, the contracts fall into two families. The liquidity-management contracts in contracts/src work on top of the official Uniswap v3 and v4 deployments on Elysium. The venue in contracts/src/venue is Elyra's own set of pools, router and fee path. They meet at one point: FeeRouter collects the fees of the first family and names the venue's FeeCollector as its treasury, so whatever referrers do not earn joins the pools' protocol fees on the way to the $ELYRA buyback.
Nothing in contracts/src is behind a proxy, and nothing can be upgraded. The liquidity-management contracts have no owner and no admin function. In the venue, ProtocolConfig, AssetRegistry, FeeCollector and BuybackV2 are Ownable2Step, and so is each of Elyra's price feeds (PushFeed). Their owner can tune parameters, steer fees, set a feed's bounds or write its answer, and pause swaps and new liquidity. Withdrawals never check the pause. Security model lists every power that key has.
Elysium is an Arbitrum Orbit chain that settles to HyperEVM, with blocks about every 100 ms. Inside a contract, block.number returns the HyperEVM block number, so Elyra's contracts measure time with timestamps.
Contracts by job
Each table names who creates the contract, what it is for and what it calls. "deployAll" means the contract is deployed once by ElyraWiring.deployAll. "deployVenue" means the venue half of that same call.
Position tools
| Contract | Created by | What it does | Calls |
|---|---|---|---|
ElyraZapV3 | deployAll | Takes one token, skims 25 bps, swaps the excess side, then mints or tops up a v3 position. Holds nothing between calls. | NPM, SwapRouter02, FeeRouter |
ElyraZapV4 | deployAll | The same over the v4 PoolManager, hooks included. | PoolManager, v4 PositionManager, Permit2, FeeRouter |
RangeOrders | deployAll | Holds a one-sided v3 position as a limit order that earns fees until the price crosses it. Anyone may fill; only the owner may cancel. | NPM, FeeRouter |
PositionKeeper | deployAll | Lets anyone harvest or rebalance an enrolled v3 position under the owner's policy, for a bounty of at most 300 bps. | NPM, SwapRouter02, FeeRouter |
Details: One-token deposits, Limit orders, Position automation.
Vaults
| Contract | Created by | What it does | Calls |
|---|---|---|---|
VaultFactory | deployAll | Clones the three vault implementations (EIP-1167) and initialises each clone in the same transaction. Anyone may create a vault, so the factory's list is not a recommendation. | the implementations |
LPVault | VaultFactory | ERC-4626 shares over one v3 range, priced behind a TWAP guard, harvested and rebalanced by anyone. | NPM, SwapRouter02, FeeRouter |
HedgedLPVault | VaultFactory | An LPVault whose price exposure is shorted on Hyperliquid, in its funder's account. The hedger reports the short; the funder moves margin. | USDC (through HedgeFunding), Elyra's price feed |
StructuredVault | VaultFactory | A dated note: an LPVault sleeve plus an off-chain long (Income) or a reserve token (Protected), unwound at maturity. Leaving early costs 50 bps. | its LPVault, the reserve pool, Elyra's price feed, FeeRouter |
Details: Vaults, Hedged vaults, Structured notes.
Launch tracking and pre-market perps
| Contract | Created by | What it does | Calls |
|---|---|---|---|
LaunchPipeline | deployAll | track records when a token's WHYPE pool was first seen. graduate clones an LPVault over it once the token is 3 days old and its pools hold MIN_LIQUIDITY. | v3 factory, VaultFactory |
PreMarketPerp | deployAll | A virtual-AMM perp for tokens no venue lists: USDC margin, 3x, an index price from a 30 min v3 TWAP times Elyra's HYPE/USD feed. Anyone may open a market. | v3 pools, Elyra's price feed, FeeRouter |
Details: Graduation and pre-market perps.
Elyra pools and routing
| Contract | Created by | What it does | Calls |
|---|---|---|---|
ProtocolConfig | deployVenue | The venue's switches: pause, the protocol share of every pool fee (2 000 bps at deploy, at most 5 000) and the FeeCollector address. | none |
AssetRegistry | deployVenue | The curated list of feed-priced assets (the EQX stock tokens) and the quotes they may pair with. USDC is $1; HYPE and WHYPE use Elyra's HYPE/USD feed. | Elyra's price feeds |
DammHook | deployVenue, at a mined CREATE2 address | Permissionless dynamic-fee v4 pools: a 5 to 100 bps base fee, an optional anti-snipe start fee and a volatility surcharge, capped at 500 bps outside the snipe window. | PoolManager, ProtocolConfig |
StockHook | deployVenue, at a mined CREATE2 address | v4 pools for registry assets. The fee follows the market session, and a swap must end inside the feed band or move the price toward it. | PoolManager, AssetRegistry, ProtocolConfig |
DlmmFactory, DlmmPair | deployVenue; pairs by anyone | Discrete-bin pools with a fixed price per bin, one pair per token pair and bin step. | ProtocolConfig |
DlmmPositionNFT | deployVenue | ERC-721 positions over a contiguous range of bins. | DlmmPair |
DlmmLimitOrders | deployVenue | Limit orders as single-bin liquidity, batched per bin. Anyone may execute a filled batch. | DlmmPair |
Router | deployVenue | Exact-in, multi-hop swaps across v4 pools (Elyra hooks and others) and DLMM pairs. Holds nothing and charges nothing. | PoolManager, DlmmPair |
Both hooks and every DLMM pair send the protocol share of each fee straight to FeeCollector. Details: Elyra pools, Swaps and routing.
Pool vaults and launches
| Contract | Created by | What it does | Calls |
|---|---|---|---|
DlmmVaultFactory, DlmmVault | deployVenue; vaults by the owner | ERC-20 shares over the bins around the active one. Only the factory's keeper (or the owner) rebalances, at most every 5 min. | DlmmPair |
DlmmVaultZap | deployVenue | One-token deposits into, and withdrawals out of, a DLMM vault. | Router |
StockVaultFactory, StockVault | deployVenue; vaults by the owner | Passive liquidity in one stock pool, centred on the feed price and wider while the market is closed. | PoolManager, StockHook |
LaunchPools, LaunchToken | deployVenue; tokens by launch | A fixed-supply token and its locked native-HYPE DAMM pool in one transaction, with an optional first buy. | PoolManager, DammHook |
LaunchVault | deployVenue | Pools HYPE before a launch, buys the token as the pool's first swap and shares it pro rata. | LaunchPools |
Details: Elyra pools, Launch a token.
Fees and $ELYRA
| Contract | Created by | What it does | Calls |
|---|---|---|---|
FeeRouter | deployAll | The sink for every protocol fee of the position tools, vaults, pre-market perps and the booked perp builder fees. 20 % is credited to the user's referrer; the rest belongs to the treasury, and anyone can flush it there. | ReferralRegistry, FeeCollector |
ReferralRegistry | deployAll | Write-once referral codes and write-once user-to-referrer links. | none |
FeeCollector | deployVenue | Receives the pools' protocol share and FeeRouter's flushes. Anyone can convert a token to HYPE along the owner's route; the HYPE goes to BuybackV2. | Router, AssetRegistry |
BuybackV2 | deployVenue | Spends up to its per-call cap of HYPE on $ELYRA in its native-HYPE v4 pool, burns every token bought and pays the caller 50 bps. poke moves its reference price. | PoolManager |
Details: Buyback and burn, Fees and referrals.
Who holds a key
| Role | Set from | Can | Cannot |
|---|---|---|---|
| Owner | OWNER, proposed by handOver, accepted with acceptOwnership | pause the venue, tune fees and price guards, list stocks and their feeds, set fee routes, sweep FeeCollector, create pool vaults, name their keeper; name each feed's keeper, set its bounds and write its answer (setAnswer) | touch a liquidity-management contract or a user position; block a withdrawal |
| Hedger | HEDGER, the address of the API's HEDGER_PRIVATE_KEY | reportHedge on hedged vaults and reportSleeve on Income notes, at most every 5 min; the vault believes a report only within 15 % of its hourly anchor | move vault funds; hold exits |
| Vault keeper | KEEPER, the address of the API's BOT_PRIVATE_KEY | rebalance DLMM and stock vaults as their factories' keeper | move vault funds |
| Price feed keeper | FEED_KEEPER, the address of the API's FEED_KEEPER_PRIVATE_KEY | update Elyra's price feeds: at most 10 % an update, a minute apart, within 15 % of the hour's anchor | move any funds |
| Funder, one per hedged vault | the deploy, one key per vault, never a hot key or each other | fundHedge: take margin to its own address, at most 10 % of on-chain assets per call out of an allowance of 25 % that refills over a day; returnHedge; name the vault's hedger (setHedger); believe a reported drop at once (acceptReport); off chain, withdraw that margin from Hyperliquid | report equity; raise the believed figure |
| Agent wallets | generated by the signer, one per account, approved by the account's wallet | place and cancel Hyperliquid orders | withdraw or transfer from Hyperliquid |
The deploy refuses to put two of the three bot roles on one key, and the API in production refuses a shared key.
The programs off chain
| Program | Code | Runs on | Job | Holds |
|---|---|---|---|---|
| Web app | apps/web | Next.js 15, wagmi, viem; Privy for email login, or browser wallets when no Privy app id is set | Every page and every user transaction | nothing; your wallet signs |
| API | apps/api | Fastify on :8796; Postgres, or memory when DATABASE_URL is unset | The routes pages read, the perp proxy, Ideas and points | SIGNER_SECRET, ADMIN_SECRET |
| Bots | apps/api/src/bots | inside the API process, only when enabled | feed keeper, keeper, hedger, graduator, the pool duties and the fee path | BOT_PRIVATE_KEY, FEED_KEEPER_PRIVATE_KEY, HEDGER_PRIVATE_KEY |
| Indexer | apps/indexer | Ponder on :42074; Postgres, or PGlite | Logs of Elyra's own contracts into tables, served as GraphQL to the API alone | nothing |
| Signer | services/signer | Node (TypeScript) on :8797, signing with @nktkas/hyperliquid | Hyperliquid agent wallets and order signing, with no code path that withdraws | agent wallet keys, encrypted |
Indexer, API and bots covers the first four in depth; Perpetuals covers the signer.
A write, from click to block
Every button that changes chain state calls useWrite().run(...) in apps/web/lib/tx.ts. There is no second path.
- 01Gate
canWritechecks for a connected wallet, chain 99901 (development builds also allow a local chain) and a deployment manifest. If one is missing, the button says which. - 02SimulateThe hook runs
simulateContract, aneth_callfrom your address. A revert stops here: it costs nothing and your wallet never opens. - 03Sign and sendYour wallet signs the simulated request and sends it through the RPC. A toast links the transaction on the explorer.
- 04RefreshThe query keys the write affects are refetched at 1.5 s, 4 s and 10 s, the time the indexer needs to see the new logs.
For anything a transaction must get exactly right, the browser reads the chain directly instead of asking the API: balances, allowances, vault previews, router quotes, the active DLMM bin. The API never sends a transaction for a user. Its POST routes store a signed Idea, forward a signed perp request to the signer, return a mirror plan for your wallet to send, record the contact form or, with the admin secret, recompute points.
A read, from chain to page
- A page hook in
apps/web/lib/data.tscalls a typed fetcher inapps/web/lib/api.tsagainstNEXT_PUBLIC_API_URL, with a 15 s stale time and no retry. - The API route answers from the indexer (GraphQL documents in
src/indexer/queries.ts), from chain reads batched through Multicall3, from Hyperliquid's market data or from its database. A cached route keeps its answer for 15 to 60 s. - The route maps its own model to the exact shape
api.tsdeclares (routes/wire.ts), and a test fails if either side renames a field. - If the API does not answer, the page shows its empty state and a status notice.
The indexer is fed by the chain alone. It subscribes to the Elyra contracts in the manifest and folds their logs into tables; Uniswap pools and positions outside them are read from the chain when a route needs them.
Shared packages
@elyra/core
Pure TypeScript with no I/O, imported by the web, the API and the indexer. It holds tick maths and range shapes, zap maths, impermanent loss, fee APR, the Seasoned screen (isEstablished), Carry (basis.ts), LP delta and hedge sizing (hedge.ts), keeper policy predictions (policy.ts), note payoffs, DLMM bin maths, the perp request message (perpAuth.ts), slippage, market hours, position sizing and backtests. A number on a card and the number a bot acts on come from the same function.
Two Foundry tests write fixtures when run with WRITE_FIXTURES=true: contracts/fixtures/zap.json, which packages/core/src/zapMath.test.ts asserts the TypeScript port against, and contracts/fixtures/payoff.json, eight points of each StructuredVault.payoffCurve mode that payoff.ts mirrors.
@elyra/abi and the manifest
src/generated/holds the compiler ABIs of every contract with an off-chain caller.contracts/export-abis.shwrites them, and they are committed, so no package needs Foundry to build.src/addresses.tsholds the fixed facts: chain 99901, the public RPC, the official Uniswap contracts, WHYPE, USDC, the EQX stock tokens, Elyra's price feeds and Multicall3.contracts/script/ElysiumAddresses.solholds the same addresses for the deploy scripts.src/manifest.tstypes the deployment manifest and validates it withloadManifest, which names the bad key when it throws.
The manifest is the one file that says where a deployment lives: chainId, deployBlock, the owner, treasury, hedger, keeper, feed keeper and funder, each hedged vault's funder (funders), the three vault implementations, addresses (with seed vaults by name) and venue. The API reads it from MANIFEST_PATH, the indexer from PONDER_MANIFEST, the web from apps/web/deployments/manifest.json or NEXT_PUBLIC_MANIFEST_URL. Without one, writes are disabled, the bots stay off, the manifest routes answer empty and the indexer has nothing to follow.
Deployed addresses
Read from the manifest this site loaded, so the table is always the deployment you are using:
Chain 99901, deployed from block 13,736,511. Each address opens on the explorer. $ELYRA has not launched yet, so it has no address here.
Deploying the stack
The Elysium deploy script and DeployLocal.s.sol both call deployAll in contracts/script/ElyraWiring.sol. It never starts a broadcast and never reads the environment, so the same sequence runs under a broadcast, a dry run and a fork test.
- 01The venue
VenueWiring.deployVenuedeploysAssetRegistry,BuybackV2,Router,FeeCollectorandProtocolConfig, then both hooks at CREATE2 addresses whose low bits are their permission flags, then the DLMM, launch and stock-vault contracts. It sets the quotes, lists every EQX stock with default risk parameters and names the vault keeper as keeper of both vault factories. - 02Fees
ReferralRegistry, thenFeeRouterwith the venue'sFeeCollectoras its treasury. - 03Position toolsBoth zaps,
RangeOrdersandPositionKeeper. - 04Vaults and launchesThe three vault implementations, then
VaultFactory, which takes them as constructor arguments because their combined creation code is over the initcode limit. ThenLaunchPipelineandPreMarketPerp. - 05Seed vaultsBest effort: the plain, hedged and note vaults the wiring names. A missing pool logs a line and skips that vault.
- 06Hand over
handOverproposes the owner for the four venue admin contracts, and_handOverFeedsfor every price feed. Until the owner callsacceptOwnership, the deployer still holds them.
writeManifest then records the result. DeployLocal also runs VenueSeed, which seeds pools, a deposit, a resting DLMM limit order and a launch on a local fork. Canary.s.sol is the post-deploy smoke test: a tiny zap, a range order placed and cancelled, and a harvest on a seed vault's pool.
Reference
Deploy values
| Name | Allowed | Default | Effect |
|---|---|---|---|
CURVE_HALF_TICKS | ticks | 2231 | Half-width of every seed vault range (about ±25 %), snapped to the pool spacing. |
HYSTERESIS_SPACINGS | spacings | 10 | Seed vault hysteresis, as a multiple of tick spacing. |
MIN_INTERVAL | seconds | 6 h | Least time between two keeper actions on a seed vault. |
MAX_SLIPPAGE_BPS | bps | 100 | Swap bound on a seed vault rebalance. |
BOUNTY_BPS | bps | 50 | Bounty the seed vault policy advertises to bots. |
NO_CAP | asset units | type(uint256).max | The cap of the plain and hedged seed vaults: none. |
MAX_HEDGE_AGE | seconds | 1 h | A hedge or sleeve report older than this counts as zero for exits and holds deposits. |
MAX_EQUITY_JUMP_BPS | bps | 1500 | The band around the hour's anchor the believed equity moves in; an Income note's band is the same share of its anchor plus its collateral. |
MAX_FUND_BPS_PER_CALL / PER_PERIOD | bps | 1000 / 2500 | fundHedge caps: 10 % of on-chain assets per call, out of an allowance of 25 % that refills over a day. |
FEED_MAX_DEVIATION_BPS / FEED_MIN_INTERVAL | bps / seconds | 1000 / 60 | A feed update moves the answer at most 10 %, a minute after the last. |
FEED_MAX_WINDOW_MOVE_BPS / FEED_WINDOW | bps / seconds | 1500 / 1 h | A feed answer stays within 15 % of the hour's anchor. |
FEED_HEARTBEAT / FEED_CLOSED_HEARTBEAT | seconds | 1 h / 4 days | Feed age the AssetRegistry accepts: HYPE always and a stock in session, and a stock while closed (ElysiumAddresses.sol). |
MIN_LIQUIDITY | liquidity | 10 ether | In-range liquidity LaunchPipeline needs before a graduation, summed over four fee tiers. |
STOCK_OPEN / CLOSED / STALE_FEE_BPS | bps | 30 / 150 / 500 | Default stock pool fee by session; the owner can tune each asset. |
STOCK_OPEN / CLOSED_MAX_DEV_BPS | bps | 200 / 50 | Default feed band of a stock pool, open and closed. |
Ports and environment
| Program | Local port | Points at |
|---|---|---|
| Local chain (anvil fork of Elysium) | 8549 | the fork RPC |
| API | 8796 | INDEXER_URL, RPC_URL, MANIFEST_PATH, SIGNER_URL |
| Signer | 8797 | SIGNER_SECRET, shared with the API |
| Indexer | 42074 | PONDER_RPC_URL, PONDER_MANIFEST, DATABASE_URL |
| Web | 3034 | NEXT_PUBLIC_API_URL, NEXT_PUBLIC_RPC_URL, NEXT_PUBLIC_CHAIN_ID, NEXT_PUBLIC_PRIVY_APP_ID |
| Landing | 3035 | built into the web app's public/landing/ |
Elyra