Documentation

How Braid works

Braid is a front end for Uniswap's own contracts on Robinhood Chain. It holds no money, charges nothing, and has no contract of its own to trust.

1. The problem

A tokenized stock on this chain does not have one market. Uniswap runs two versions here, v3 with four fee tiers and v4 where anyone can open a pool with any fee and tick spacing, and both are in use. The result is that a single share trades in a dozen or twenty places at once, each holding a slice of the liquidity.

Sending the whole order to the deepest of them buys depth that is not there. The price walks away from you inside that one pool while the liquidity in the others goes untouched — and the larger the order, the larger the gap between what you got and what was available.

2. The rule

Money should keep going into a pool only for as long as that pool is the best home for the next dollar. At the best possible division, every pool used has been pushed to the same marginal price: the next dollar would buy the same number of shares wherever you put it. A pool whose price is already worse than that before you start gets nothing.

That turns a search over divisions into a search over one number — the marginal price the order finishes at. Braid bisects on it. For each candidate price, every pool answers exactly how much input it takes to get there; those are added up, and the price is moved until the total is your order.

3. Pricing it without asking the chain

Both Uniswap deployments ship a Quoter, and each quote is a network round trip. Searching for a split needs hundreds of quotes, so Braid does the arithmetic itself: a direct port of TickMath, SqrtPriceMath and SwapMath.computeSwapStep, in integers, with the same roundings the contracts use. The whole search then runs in the page in about a millisecond.

A simulator that is nearly right produces splits that are nearly right. The test suite requires Braid's arithmetic to equal Uniswap's own quoters exactly, in pools of both orientations, at sizes that cross many ticks.

One detail decides it. A pool does not step from one initialised tick to the next — it steps to the next initialised tick within one word of its bitmap, and when a word holds none it stops at the word's edge and starts again. Every one of those stops rounds separately. Taking one long stride where the pool takes six short ones was wrong by 38,343 units on a $50,000 order: small enough to look like floating-point noise, large enough to choose the wrong split.

4. The edge of the data

Braid reads enough tick data around each pool to cover a 50% move in its price, and no more — reading the whole tick space for twenty pools would be thousands of calls for every quote. If an order would walk a pool past that, Braid does not guess: that pool is dropped from the split and the page says so. An order that would move one pool by more than half its price should not be going into that pool anyway.

5. What the transaction does

Whatever the split looks like, it is one transaction:

  1. PERMIT2_PERMIT — your signature, for exactly this order's size and half an hour. Only when the existing allowance is short.
  2. PERMIT2_TRANSFER_FROM — the whole order is pulled into the Universal Router, once, however many ways it is about to be split.
  3. V3_SWAP_EXACT_IN / V4_SWAP — one per leg, each paid by the router out of what it is already holding.
  4. SWEEP — everything the legs produced goes to you, and the call reverts unless it is at least your minimum.

The minimum is on the total, not on a leg

Every leg is sent with a floor of zero, and the only floor is that last command. This is the right shape for a split rather than merely a convenient one: with per-leg minimums, one pool drifting between the quote and the mine would fail the entire order even in the case where the other legs had already made the difference up and you would have come out ahead. You are protected by exactly the promise you were shown — this many shares, or nothing at all.

Why the layouts are unusual

The Universal Router deployed on this chain is a newer build than the public documentation describes: V3_SWAP_EXACT_IN carries a trailing uint256[] minHopPriceX36, and v4's ExactInputSingleParams carries a uint256 minHopPriceX36 before hookData. Calldata built to the documented shape makes the router read past the end of its own input and revert — while every quote still works, so only the trade fails. Braid encodes against the verified source of the contract that is actually deployed.

6. Which tokens are listed

This chain carries hundreds of counterfeit tokens that copy the symbol and name of real ones — there are more than a dozen ERC-20s calling themselves “Global Dollar”, several with six-figure holder counts. So nothing in Braid starts from a name. A stock is listed only if all three are true:

  • Morpho Blue has a market whose loan token is the one real dollar in Braid's config and whose collateral is this token;
  • Uniswap's own factory reports a pool between that same dollar address and this token;
  • that pool holds liquidity right now.

The name is the last gate, not the first.

7. What Braid cannot do

  • It cannot custody anything. There is no Braid contract; the transaction goes from your wallet to Uniswap's router.
  • It cannot stop a pool moving between your signature and your transaction landing. That is what the minimum is for.
  • It routes only through pools with no hook attached. A hooked pool can change what a swap does at swap time, and the arithmetic above would no longer be the whole truth.
  • It is not a price oracle. It shows what the pools will pay for the size you are actually trading.

Braid is not affiliated with Robinhood, Uniswap or Morpho. Nothing here is financial advice.