Tenbin

Self-custodial index wallet that Uniswap v4 and 1inch Aqua trade at one price and nobody's watching

Tenbin

Created At

ETHGlobal Mumbai

Project Description

Tenbin (天秤, the Japanese balance scale) lets Uniswap v4 and 1inch Aqua trade one wallet at one price

PROBLEM : Earn trading fees on more than one exchange today, a market maker splits its coins into one pile per venue. Each pile gets its own price, the prices drift apart, and arbitrageurs live off the gap at the maker's expense while rebalancing is a job of its own, and every RPC provider the maker uses learns which book it runs and what it watches

Tenbin removes the split. You hold a weighted index in your own wallet, for example 40% ETH / 30% BTC / 30% USDC while both Uniswap v4 and 1inch Aqua trade against that same wallet, priced by one function over its real balances, so both venues quote the same trade 0 wei apart

A fill on one venue changes the balances, so the other venue's next quote already knows. There is nothing to sync and no oracle.

Think of it as one water tank with two taps: the tank is your wallet, Uniswap and 1inch are the taps, and one gauge sets the price for both.

What you get:

  • One inventory on two venues: your whole wallet, not half on each.
  • Same price everywhere: 0 wei apart in every direction, exact-in and exact-out.
  • Can't be gamed: every loop across both venues loses (a 1 ETH loop comes back -0.81%).
  • Self-rebalancing: when prices move, traders buy what's cheap until the wallet is back on target, and pay the 0.30% fee for it (ETH +25% restores 40.01 / 29.99 / 29.99).
  • Cheap re-weighting: glide 40/30/30 to 50/25/25 on $100k for $25 instead of $1,991.
  • Self-custody: coins never leave your wallet; the only approval is to 1inch Aqua, which caps each venue.
  • Private: every chain read in the app goes through the Ethereum Foundation's Anon-RPC.

It's for market makers, DAO treasuries and anyone holding a basket of coins who wants it to earn fees on more than one venue without splitting it.

Honest limit: Tenbin doesn't reduce LVR. When the outside price jumps, the traders who rebalance you keep the move and you earn the fee. The app says so.

Live on Base Sepolia with a working app: swap, launch your own index, live order book, arbitrage tester, privacy log and a guided six-step demo with real transactions.

How it's Made

"One price function, two venues, one wallet"

Quant Knowledge: TenbinMath implements Balancer's weighted-pool formula (spot, exact-in, exact-out) in fixed point, using Balancer v3's LogExpMath for pow, with every rounding step in the maker's favour. It's checked against 111 vectors from an 80-digit Python reference. TenbinHook.quote() runs it over the wallet's real ERC-20 balances plus pending claims

Uniswap v4: TenbinHook is a custom-curve hook. In beforeSwap it prices the trade from the wallet and returns a delta that cancels the pool's own curve, so the pool holds nothing. Output is paid straight from the wallet (sync, then Aqua.pull into the PoolManager, then settle). The trader's input is minted as ERC-6909 claims for the maker, counted as inventory immediately, and pushed into the wallet via Aqua.push on the next swap or a permissionless flush(). LP deposits are blocked and only the maker can open pools. A CREATE2 factory deploys one hook per maker, and the app mines the hook address in the browser. The official V4Quoter and Universal Router on Base Sepolia work unchanged; fork tests prove the quoter returns exactly the hook's quote

1inch Aqua + SwapVM: we wrote a new SwapVM instruction, PortfolioPrice (opcode 0xd0, in the unallocated bank), and added it to the official AquaSwapVMRouter without changing anything else (22.8 KB, under the 24 KB limit). It calls the same hook's quoteAndLock(), so both venues price identically, and it uses Aqua's virtual balance as that venue's selling limit. The maker's only approval is to Aqua. Aqua and SwapVM aren't on any testnet, so we deploy their official source on Base Sepolia

The hacky part: our v4 hook also acts as an Aqua app. Aqua keys balances by the calling app, so the hook ships its own strategy and calls pull and push from inside the Uniswap swap. One inventory serves two protocols that were never designed to share one

Security: our own audit found a critical cross-venue reentrancy bug (SwapVM calls the taker back after pricing but before moving coins, so a nested trade could price on stale balances; the PoC made $752.92). We fixed it with a fail-closed fill lock shared by both venues, and the PoC is kept as a test. 59 contract tests in total, including fuzzing, a 64-run invariant suite and 2 fork tests against live Uniswap v4

EF Anon-RPC: web/src/lib/anon.ts is the app's only read path, a viem transport built on @anon-rpc/browser-harness. It uses Tor by default and falls back to Nym if Tor can't start (the EF Tor gateway was down during the hackathon), and never silently to a non-private route. Each maker, pair and trader gets its own isolation key so the RPC can't link them. The Privacy page lists every read with its route, key and latency, and a small logging proxy shows requests arriving from anonymity-network exits

App: Next.js 15 + viem, plain-SVG charts, static export to GitHub Pages. Tested with 18 Playwright browser specs, 27 headless user flows and 36 on-chain smoke checks. ./scripts/demo.sh forks Base Sepolia, deploys, launches a 40/30/30 index, trades on both venues and opens the app

background image mobile

Join the mailing list

Get the latest news and updates