Corvex

Uniswap v4 hook that queues stock-token orders while markets are shut, clears them at one price

Corvex

Created At

ETHGlobal Mumbai

Project Description

Stock markets close every Friday evening, but tokenized stocks keep trading on-chain all weekend. Liquidity providers sell into a stale price, and on Monday morning the first bot to arrive buys the whole overnight gap from the pool. Corvex is a Uniswap v4 hook that fixes this.

While a stock's reference price is dark (weekend, holiday, halt, split pause or stale feed), trades that keep the pool within a 2% band still fill, and bigger trades are taken as claims and queued instead of filling at a stale price. When the price returns, anyone can run one cross. It clears the whole queue at a single fair price, matches buyers against sellers directly, swaps only the net imbalance against the pool and never past that price, and donates the surplus to liquidity providers. A falling-fee auction then closes what is left of the gap.

Every open and close is also recorded as a Session Print, sent to Arbitrum and Base over Chainlink CCIP, and checked against the official exchange price by a Chainlink CRE workflow, so other chains can trust the price a stock opened at. Cross-chain buyers can queue orders from Arbitrum or Base, and their fills come back to their own chain.

In our replay of one weekend with a 6% gap at the open, a pool with no hook loses 115.75 USDG and a Corvex pool loses nothing. With no queued orders, the falling fee takes an LP loss of 157.47 USDG down to 2.93. It runs live on Robinhood Chain Testnet, Arbitrum Sepolia and Base Sepolia, with a console where you can close the market, queue orders, run the cross and withdraw your fills.

How it's Made

Contracts are Solidity 0.8.26 with Foundry (104 tests, including fuzzing of cross settlement across four pool orientations). The core is a Uniswap v4 hook using beforeSwap with a return delta (to take a large trade as a claim instead of filling it), afterSwap as a band safety net, a per-swap dynamic fee for the gap auction, the queue held as ERC-6909 claims in the PoolManager, an unlock callback that runs the cross, and donate() to pay LPs. The hook address is mined with CREATE2 so its permission bits are right, and we kept the code under the EIP-170 size limit. The pool leg of the cross uses a price limit equal to the cross price and a zero stored LP fee, so it can never cost more than the cross price. Anything above liabilities afterwards is the surplus donated to LPs.

Chainlink does three jobs. Data Feeds give the reference price and the staleness and plausibility checks, and the cross only runs when the session is open, the oracle is unpaused, the feed is fresh and any announced split multiplier matches. CCIP 2.0 carries Session Prints to Arbitrum and Base (one failing destination never blocks the hook), carries schedules and orders to Robinhood Chain, and sends fills back to the buyer's source chain; each cross-chain user owns their orders through a small CREATE2 vault so credits stay attributable. A CRE workflow (TypeScript, cron plus EVM log triggers) fetches the official price from an external API, takes the median across nodes, compares it split-adjusted, and writes Attested or Disputed on-chain. We ran it with cre workflow simulate --broadcast, which wrote real attestations on Arbitrum Sepolia.

The frontend is Next.js 16, Tailwind 4 and viem, with a three.js clay scene, a live replay chart whose P&L numbers follow the graph, and a one-screen console. 13 CRE logic tests and 5 Playwright tests walk a whole weekend through the UI on a local chain.

Hacky parts worth knowing: Robinhood's testnet has no Uniswap v4, so we deployed the real v4-core PoolManager ourselves. The tokens, the price feed and the market-status keeper are mocks (in production the status would come from a Chainlink Data Streams adapter), and a localhost-only API route lets the console's Close and Reopen buttons act as that keeper without exposing the key. Uniswap wraps hook reverts, so we decode the real reason for users. We also documented what is not done: the fork replay of a real weekend, a CCIP token lane for the mock USDG, and a minimum order size to stop queue spam at the band edge.

background image mobile

Join the mailing list

Get the latest news and updates

Corvex | ETHGlobal