Stabrix puts every stablecoin on one curve, straight from idle wallets on 1inch Aqua. The same coins also stand ready to buy any coin that depegs, and Chainlink CRE decides when that happens.
THE PROBLEM
Hundreds of billions of dollars of stablecoins sit in wallets, treasuries and DAOs earning nothing. Earning swap fees today means locking them in a pool, where your coins leave your wallet and can do only one job. When one coin depegs, traders dump it into the pool and drain the healthy coins, so LPs are left holding the broken coin and the market loses its liquidity exactly when it needs it most.
ONE BALANCE, TWO JOBS
Stabrix gives one wallet balance two jobs at once, and the coins never leave the wallet. Both jobs are 1inch Aqua strategies over the same balance.
- FX range (new SwapVM instruction, opcode 34)
- One strategy prices 8 stablecoins on a single curve, 56 swap directions in all:
- USDC, USDT, DAI, USDS and USDe at $1
- EURC, BRZ and IDRX at live euro, real and rupiah rates
- It uses the sphere AMM from Paradigm's research paper on AMMs for many stablecoins, computed in closed form inside SwapVM.
- Liquidity is concentrated up to 301x.
- Every swap is checked onchain so the LP can never lose value.
- Peg backstop (new SwapVM instruction, opcode 35)
- Dormant while coins are healthy.
- The moment Chainlink CRE flags a depeg, it buys the broken coin at market price minus a discount the LP chose in advance.
- It pays only in healthy coins and never pays above face value.
- At the same instant every FX range refuses the broken coin, so LPs are never dumped on and healthy pairs keep trading.
The result is something no pool can offer: a buyer of last resort for every stablecoin, funded by idle wallets. Every day the coins earn FX fees. On the day a coin breaks, they are the liquidity that stays.
BUILT ON 1INCH AQUA AND SWAPVM
- Stabrix only works because of Aqua. Anywhere else a backstop is idle capital waiting for a crisis, and nobody funds it. On Aqua it costs nothing to keep, because the same coins earn fees every day until they are needed.
- Two new SwapVM instructions, packed under SwapVM's 255-byte argument limit for 8 coins.
- Both instructions also run on 1inch's official AquaSwapVMRouter, without changing a single 1inch contract.
- One swap fills makers on our router and 1inch's router in a single transaction.
- A maker opens a strategy with one Aqua ship call and closes it with dock. There are no deposits, withdrawals or LP tokens.
CHAINLINK CRE
A Go workflow is the brain of the system. It sets the FX rate every swap uses and decides when a coin is broken. Every 30 seconds it:
- reads every Chainlink feed in one call;
- checks those prices against CoinGecko and DefiLlama, with consensus across nodes;
- writes a signed report onchain.
No single API can halt or un-halt a coin. The onchain oracle accepts reports only from the CRE forwarder and the registered workflow, and rejects any rate that drifts from Chainlink's feed.
LIVE
- On Base Sepolia, USDe was crashed to $0.93 and every FX range refused it instantly. A fresh wallet sold 5,000 USDe to the backstops for 4,549.25 USDC, in one transaction across our router and 1inch's.
- Every swap through the app receives exactly what was quoted, to the wei.
- Real CRE CLI runs halted a coin, resumed it, and wrote live prices onchain.
- Every one of the 56 swap directions was filled with real tokens on 1inch's official Aqua and router.
The repo has 80 Foundry tests with fuzzing, a TypeScript SDK with 145 tests that matches the Solidity math byte for byte, and a 21-test CRE workflow. The full app covers swapping, opening ranges and backstops from your own wallet, live pool depth, an activity feed of every CRE report, and a depeg lab that crashes a coin and runs the real workflow.
Stabrix has four parts that fit together: Solidity contracts on 1inch Aqua and SwapVM, a Chainlink CRE workflow in Go, a TypeScript SDK, and a Next.js app.
CONTRACTS (Solidity 0.8.30, Foundry)
1inch Aqua is the liquidity layer, and SwapVM is where the pricing runs. A maker never deposits. Opening a strategy is one Aqua.ship call that records an allowance per coin, and closing it is dock. On a fill, Aqua pulls the input token into the maker's wallet and pushes the output to the taker in the same call. Because Aqua only tracks allowances, one wallet balance backs several strategies at once.
We wrote two new SwapVM v1.0.2 instructions:
- StabrixTick (opcode 34) is the sphere AMM from Paradigm's research paper on AMMs for many stablecoins, built for Aqua:
- Each coin's virtual balance is v = x·ρ + m, where x is the maker's live Aqua balance, ρ is the oracle's USD price, and m is a virtual floor that sets the concentration (301x on the Tight preset).
- The invariant is Σ(r − v)² = r².
- The pool keeps no state: the radius r is re-derived from live Aqua balances on every swap, so the curve always prices what the maker really holds.
- Swaps are closed form, two integer square roots and no iterative solver.
- After every swap the contract re-checks r' ≥ r, so a trade can never make the LP poorer.
- Non-dollar coins (EURC, BRZ, IDRX) sit on the same curve by scaling with ρ, which turns a multi-stablecoin AMM into a multi-currency FX market.
- StabrixBackstop (opcode 35) asks the oracle for a depeg price, and the oracle reverts until the coin is halted.
- The discount grows linearly as the cap fills.
- It is priced at the midpoint of the trade, d = d0 + (d1 − d0)(A + a/2)/C, so splitting a sale into pieces never gets a better price than selling it whole.
- It pays at min(market, face value), and only in coins that are not halted.
Notable engineering:
- Configs packed under 255 bytes. SwapVM caps an instruction's arguments at 255 bytes, so we bit-packed the configs. Eight coins, their decimals, the oracle, the floor, the edge, the fee and the exposure cap fit in 219 bytes for a range and 209 for a backstop.
- Running on 1inch's official router without modifying it. We use its Extruction opcode, which hands pricing to an external contract. The exact same pricing library runs natively on our router and on 1inch's deployed AquaSwapVMRouter, and tests assert both quote identically.
- One transaction across both routers. StabrixBatchTaker fills makers on both routers in a single transaction, with a minimum output and a deadline.
- Wallet check per fill. checkWallet confirms the maker still holds the output coin, so a maker who spends their coins elsewhere is skipped instead of breaking the swap.
- Rounding always favours the maker. Ceiling division on inputs plus a 1-wei buffer on outputs means split trades can never beat a whole trade. Fuzzing proves it.
- StabrixLens reads every strategy, balance and quote in one call for the app.
80 Foundry tests, fuzzed at 2,000 runs, check that:
- the LP never loses value;
- round trips never profit;
- splits never beat the whole trade;
- the router never drains an LP;
- the backstop never pays above the discounted market.
Nine more tests run against a Base mainnet fork with real USDC, USDT, DAI, USDS, USDe, EURC, BRZ and IDRX on 1inch's official Aqua and router, and every pair fills.
How 1inch helped: Aqua is the reason the backstop can exist. In any pool, standby depeg liquidity is idle capital nobody would fund. With Aqua's shared liquidity, the same wallet balance earns FX fees in ranges every day and backs the depeg market at no extra cost, without ever leaving the wallet. SwapVM let us ship the whole AMM as two instructions instead of a new protocol, and Extruction let those instructions run on 1inch's official router, so Stabrix liquidity is fillable by any taker of 1inch's AquaSwapVMRouter from day one.
CHAINLINK CRE (Go, cre-sdk-go)
The workflow depeg-sentinel is the orchestration layer. It sets the FX rates and decides when a coin is broken. Every 30 seconds a cron trigger runs one Multicall3 read that returns every Chainlink feed and the oracle's current status per coin in a single EVM call. Then two HTTP fetches, CoinGecko at full precision and DefiLlama, are aggregated across nodes with median consensus, plus a check that every node saw the same set of prices.
The policy is pure Go and unit-tested:
- Halt: at 3% off peg. An offchain halt needs every API to agree; a Chainlink feed can halt alone. If both sources are past 0.75%, that also halts.
- Resume: only when every source is back within 0.25%, so one lagging API cannot lift a halt.
- FX rate push: on a 2 bp move, or every 10 minutes as a heartbeat.
The report goes through the CRE forwarder to StabrixOracle.onReport, which accepts only the forwarder plus the registered workflow owner. It uses a CRE rate only when it is fresh and within 0.5% of the Chainlink feed, refuses to trade on a stale feed, and takes the lower of the CRE price and the market feed for depeg purchases.
Chainlink made this possible in two ways. The feeds give us trustworthy FX rates for euro, real and rupiah stablecoins. CRE gives us a decentralized, consensus-checked signal for "this coin is broken", which is exactly what a backstop needs before it can safely buy.
To simulate on a Base fork, we deployed the oracle with Chainlink's CRE simulation forwarder and the simulator's workflow owner. cre workflow simulate --broadcast then writes real reports onchain, and the halt and resume runs are logged in the repo. The same workflow also wrote live CoinGecko and DefiLlama prices to the oracle on Base Sepolia.
SDK (TypeScript, viem)
The SDK has a bigint port of the curve and the backstop math, checked byte for byte against Solidity using generated test vectors (145 tests). Its router splits a trade into 64 slices. Each slice goes to the strategy with the best marginal price across every maker on both routers. Slices are halved near a range edge, and strategies the trader owns are skipped. The result is executed through the batch taker. Quotes equal the amount received onchain to the wei.
APP (Next.js 15, Tailwind v4, React Query, viem)
The app has six pages:
- Swap: live routing across both routers.
- Liquidity: open FX ranges and pledge backstops straight from your wallet.
- Pool: reserves and depth by depeg tolerance.
- Activity: swaps, strategies and every CRE report read straight from chain logs, with Basescan links.
- Docs.
- Depeg lab: crashes a coin through a local price API, runs the real CRE workflow, and charts backstops buying it.
Other details:
- Wallets: any wallet connects through EIP-6963 discovery and is switched to the right network automatically.
- One site, both networks: a single deployment serves both networks with a switch in the header.
Hacky bits worth mentioning:
- Test coins in one click. "Get test coins" mints $10,000 of all 8 test stablecoins in one transaction by batching the mint calls through Multicall3's aggregate3.
- Frozen feeds on a fork. A Base fork freezes Chainlink feeds while block time follows the clock, so the fork oracle is deployed with a 30-day feed age and the demo never goes stale.
- Working around the public RPC. Base Sepolia's public RPC caps eth_getLogs at 200 blocks, which breaks strategy discovery, so everything reads through a public RPC with a larger range.
- Deploying 1inch on Sepolia ourselves. 1inch has not deployed Aqua on Base Sepolia, so our deploy script deploys 1inch's unmodified Aqua and AquaSwapVMRouter source next to Stabrix. The official-router path then works identically on testnet.