Skip to content

Instantly share code, notes, and snippets.

@sap-tlabs
Last active March 12, 2026 23:07
Show Gist options
  • Select an option

  • Save sap-tlabs/088fd2212e3038036aa799c5ab369638 to your computer and use it in GitHub Desktop.

Select an option

Save sap-tlabs/088fd2212e3038036aa799c5ab369638 to your computer and use it in GitHub Desktop.
BTC→Any on Ethereum — System Overview (btc-intents, btc-solver, T staking 0-conf, tBTC fulfillment vault)

BTC→Any on Ethereum — System Overview

Fast native BTC swaps to any Ethereum token via tBTC, solver competition, and intent protocol routing. T staking enables 0-conf BTC deposits for ~1-3 minute settlement.

Date: 2026-03-12 Status: PoC complete across three repos. Mainnet deployment pending.


What it does

A user with native BTC gets any Ethereum token (USDC, WETH, tBTC, etc.) in 1–3 minutes — versus 15–60 minutes via NEAR Intents or THORChain, or 1–5 hours via the standard tBTC bridge.

The system is three repos plus a staking mechanism:

                         ┌─────────────────────────┐
                         │       btc-solver         │  ← user-facing API
                         │  Quote → Deposit → Track │
                         │                         │
                         │  Protocol Adapters:      │
                         │  CoW · UniswapX · 1inch  │
                         │  ERC-7683                │
                         └────────────┬────────────┘
                                      │ creates intents, submits
                                      │ tBTC→dest orders
                         ┌────────────▼────────────┐
                         │       btc-intents        │  ← fulfillment layer
                         │  Orderbook · MM Bot ·    │
                         │  BTC Monitor             │
                         │                         │
                         │  Contracts:              │
                         │  TbtcLiquidityVault      │  ← ERC-4626 vault (vtBTC)
                         │  EscrowVault             │  ← per-intent tBTC escrow
                         └────────────┬────────────┘
                                      │ T stakers back
                                      │ 0-conf deposits
                         ┌────────────▼────────────┐
                         │    T Staking (0-conf)    │  ← economic security
                         │  Bond T → enable instant │
                         │  BTC settlement          │
                         └─────────────────────────┘

Repo 1: btc-solver

Location: ~/AI/sandbox/btc-solver/ Role: User-facing API gateway and orchestrator.

This is the layer users and integrators interact with. It sits on top of btc-intents and routes the tBTC→destination-token leg through established EVM intent/solver protocols.

How it works

  1. Quote — User calls POST /api/v1/quote with BTC amount, destination token, and chain. btc-solver creates an intent on the btc-intents orderbook and runs a MM auction (~5–15s). Multiple MMs compete on spread and confirmations. Best quote wins.

  2. Deposit — User calls POST /api/v1/deposit to accept the quote. Gets a BTC deposit address. Sends native BTC.

  3. Fulfillment — Once BTC is detected/confirmed:

    • btc-intents MM fills the intent (locks tBTC from the vault)
    • btc-solver submits a tBTC sell order to the chosen protocol adapter
    • External solver networks (CoW solvers, UniswapX fillers, 1inch resolvers) compete to fill tBTC→dest token
    • User receives destination token
  4. TrackGET /api/v1/status/:id or WebSocket for real-time phase updates.

Protocol Adapters

Adapter Protocol What it does
cow CoW Protocol Batch auctions, MEV-protected fills
uniswapx UniswapX RFQ-based, competitive filler network
oneinch 1inch Fusion+ Multi-solver competition
erc7683 ERC-7683 Standard cross-chain intent interface (Across, etc.)

The tBTC→dest swap runs through battle-tested solver networks with deep Ethereum liquidity, not a single DEX router. This means:

  • MEV protection (CoW)
  • Competitive pricing via solver competition
  • Access to institutional liquidity (UniswapX fillers)
  • Pluggable — new protocols added by implementing the ProtocolAdapter interface

Packages

Package Purpose
@btc-solver/types Shared interfaces, chain constants, tBTC addresses
@btc-solver/core Solver orchestrator — quote engine, intent lifecycle, phase management
@btc-solver/adapters CoW, UniswapX, 1inch, ERC-7683 adapter implementations
@btc-solver/api REST + WebSocket API gateway
@btc-solver/demo Minimal swap demo frontend

Supports Ethereum, Arbitrum, and Base (tBTC addresses configured for all three).


Repo 2: btc-intents

Location: ~/AI/sandbox/btc-intents/ Role: Fulfillment infrastructure — orderbook, MM competition, BTC monitoring, on-chain escrow and vault.

Components

Component What it does
Orderbook Intent API + WebSocket. MMs submit competing quotes. Auction selects winner.
MM Bot Evaluates intents, fills using tBTC (from vault or own inventory), monitors BTC deposits
Bitcoin Monitor Watches BTC addresses via Electrum. Reports mempool detection, confirmation count, RBF flags. Triggers escrow release.
EscrowVault (Solidity) Per-intent tBTC lockbox. MM locks tBTC → keeper releases after BTC confirms → atomic swap via Odos if needed. Deadline-based reclaim if BTC never arrives.
TbtcLiquidityVault (Solidity) ERC-4626 vault — the fulfillment vault. See below.

TbtcLiquidityVault — ERC-4626 Fulfillment Vault

The vault is how Threshold supplies tBTC inventory for its own MM bot, ensuring there's always baseline liquidity for conservative fills and bootstrapping the system before third-party MMs join. It is not the only source of liquidity — other MMs bring their own tBTC inventory and fill intents directly against the EscrowVault.

Two liquidity models coexist:

Threshold MM (vault-backed) Third-party MMs
Inventory source TbtcLiquidityVault (ERC-4626) MM's own tBTC balance
Who earns spread vtBTC holders (passive yield) The MM directly
Fill path vault.fill() → EscrowVault EscrowVault.lockTbtc() directly
Capital risk Shared across depositors MM bears own risk
Role Guaranteed baseline liquidity Competitive, tighter spreads

The vault ensures the system always has liquidity even before third-party MMs are active. As the MM ecosystem matures, external MMs compete on spread while the vault provides a reliable backstop.

Token: vtBTC (Vault tBTC)

Yield cycle:

  1. Depositor deposits tBTC → receives vtBTC shares
  2. Operator (Threshold's MM bot) calls fill() → vault locks tBTC into the EscrowVault for a specific intent
  3. User sends BTC → keeper releases escrowed tBTC to user (or swaps via protocol adapter)
  4. BTC bridge mints new tBTC back to the vault — the minted amount includes the MM spread
  5. Operator calls settleEscrow() → totalLocked decreases, vault balance increases, share price rises
totalAssets = tbtc.balanceOf(vault) + totalLocked

Spread accrues to all vtBTC holders proportionally via share price appreciation — passive yield on tBTC, backed by real BTC swap flow.

Protections:

  • Utilization cap — configurable max % of vault assets that can be locked in active escrows (e.g. 80%)
  • Settlement guard (V-01)settleEscrow() requires totalAssets post-settlement ≥ totalAssets at fill time, proving the mint has arrived. Prevents share price manipulation by settling before mint lands.
  • Terminal state check (V-02) — settlement only accepts explicit terminal escrow states (Released/Reclaimed/Replenished)
  • Inflation attack protection — 6-decimal offset for a high-value-per-unit asset (~$70K/tBTC)
  • Withdrawal cap — withdrawals capped at available (unlocked) tBTC. Locked tBTC can't be withdrawn until settled.

Deployed on Sepolia: EscrowVault at 0xfc359dCCC5cD882AF2FB6351229526f9Cf5348E4 (TbtcLiquidityVault deployment pending)


T Staking — 0-Confirmation BTC Settlement

Location: Personal GitHub (not yet in shared repos) Role: Economic security layer enabling instant BTC settlement.

The problem

Every cross-chain BTC swap protocol waits for Bitcoin confirmations (10–60+ minutes) because unconfirmed BTC transactions can be replaced via RBF (Replace-By-Fee). This is the single biggest latency bottleneck.

  • THORChain: 1–6 confirmations (dynamic by value). Never processes 0-conf.
  • NEAR Intents: PoA Bridge requires confirmations before minting btc.omft.near. Solvers can't override this.
  • Standard tBTC bridge: 1-hour optimistic minting delay.

The solution

T token stakers bond collateral that backs 0-conf BTC deposits. If a user's BTC deposit is subsequently RBF'd (reversed), the staker's bonded T is slashed to cover the vault's loss. This makes it:

  • Economically irrational to RBF — the attacker's potential gain is less than the slashing penalty
  • Instant for the user — funds release as soon as the BTC transaction hits the mempool (~seconds), no confirmation wait
  • Decentralised — security comes from the T staker set, not a single operator's risk tolerance

Settlement comparison

Protocol BTC deposit wait Total time (BTC → USDC on Ethereum)
This system (0-conf + T staking) ~0 min (mempool detection) ~1–3 min
NEAR Intents 10–30 min (confs required) ~17–50 min
THORChain 10–60 min (dynamic confs) ~15–90 min
Standard tBTC bridge N/A 1–5 hours

Neither competitor can replicate this without fundamental architectural changes. THORChain's validator consensus explicitly forbids 0-conf. NEAR's PoA Bridge can't mint without confirmations.


Full Swap Flow

Example: User swaps 0.5 BTC → USDC on Ethereum

User                    btc-solver              btc-intents             Ethereum
  │                         │                       │                       │
  ├─ POST /quote ──────────►│                       │                       │
  │  (0.5 BTC → USDC)      │── create intent ─────►│                       │
  │                         │                       │── MM auction (5-15s)  │
  │                         │◄─ winning quote ──────│                       │
  │◄─ quote response ───────│                       │                       │
  │  (spread, deposit addr) │                       │                       │
  │                         │                       │                       │
  ├─ POST /deposit ────────►│── accept quote ──────►│                       │
  │                         │                       │── MM fills:           │
  │                         │                       │   vault.fill() ──────►│ lock tBTC
  │◄─ deposit address ──────│                       │                       │
  │                         │                       │                       │
  ├─ send 0.5 BTC ─────────┼───────────────────────┼──► Bitcoin network    │
  │                         │                       │                       │
  │  [T staking: 0-conf]   │                       │── BTC in mempool ────►│
  │                         │                       │   release tBTC        │
  │                         │◄─ mm_filled ──────────│                       │
  │                         │                       │                       │
  │                         │── submit tBTC sell ───┼──────────────────────►│
  │                         │   order to CoW        │                       │ CoW solvers
  │                         │                       │                       │ fill tBTC→USDC
  │                         │◄─ order_filled ───────┼───────────────────────│
  │◄─ completed ────────────│                       │                       │
  │  (USDC in wallet)       │                       │                       │
  │                         │                       │                       │
  │  [1-5 hours later]      │                       │── bridge mints tBTC  │
  │                         │                       │   back to vault       │
  │                         │                       │── settleEscrow() ────►│ share price ↑

Total time: ~1–3 minutes (mempool detection + Ethereum transactions)


Competitive Positioning

The market

Cross-chain BTC swaps process $24M+/day across two dominant venues:

THORChain NEAR Intents This system
Daily BTC volume ~$17M ~$6.7M Target: $0.5–2.2M
Architecture Decentralised AMM Solver competition on NEAR Solver-backed tBTC + intent protocol routing
BTC custody Validator vaults Chain Signatures MPC (PoA Bridge) tBTC bridge (decentralised threshold MPC)
0-conf Never No (bridge blocks it) Yes (T staking)
Settlement 15–90 min 17–50 min 1–3 min
Swap execution THORChain pools (slip-based) Solvers on NEAR CoW / UniswapX / 1inch (Ethereum-native)
Ethereum delivery Direct but slow Needs MPC withdrawal from NEAR Native — already on Ethereum
Trust model 2/3 validator set Defuse Labs (PoA) Decentralised T staker set

Where we win

  1. Speed — Order of magnitude faster for Ethereum-destination swaps. 0-conf via T staking means we only wait for mempool detection, not block confirmations.

  2. Ethereum-native — tBTC is already on Ethereum. No bridge withdrawal step. Composable with the full DeFi stack from block 1. NEAR has to withdraw from an intermediate chain; we skip that entirely.

  3. Institutional swap execution — The tBTC→dest leg goes through CoW, UniswapX, 1inch — protocols with deep liquidity, MEV protection, and competitive solver networks. Not a single DEX router.

  4. ERC-4626 vault yield — Depositors earn passive tBTC yield from swap spread. This creates a flywheel: more vault deposits → more liquidity → more fills → more yield → more deposits.

  5. $1K–$25K sweet spot — Competitive all-in pricing in the segment that accounts for 54% of competitor BTC volume.

  6. BTC→tBTC corridor — Nobody else can do fast BTC→tBTC. Unique route for users deploying BTC into Ethereum DeFi.

  7. Trust model — Decentralised T staking vs NEAR's centralised PoA Bridge (Defuse Labs).

Where we don't win (yet)

  • Multi-chain — NEAR covers 28 chains. We're Ethereum/Arbitrum/Base. Not competitive for BTC→SOL or BTC→Cosmos.
  • Large swaps ($50K+) — tBTC DEX pool depth limits the swap leg. For large orders, direct tBTC delivery is the right answer.
  • Distribution — NEAR is in SwapKit (Ledger, Trust Wallet), Rango, Infinex. We need aggregator integration.

Current Status

Component Status
btc-intents: Orderbook, MM Bot, Monitor PoC complete, running on Sepolia + VPS
btc-intents: EscrowVault contract Deployed + verified on Sepolia
btc-intents: TbtcLiquidityVault (ERC-4626) Built + tested, not yet deployed
btc-solver: Core orchestrator + quote engine Built
btc-solver: CoW adapter Built
btc-solver: UniswapX, 1inch, ERC-7683 adapters Built
btc-solver: API gateway + demo frontend Built
T Staking 0-conf In development (personal GitHub)
Competitive intelligence (NEAR, THORChain) Complete
Parameter recommendations (tiered spreads, dynamic confs) Complete

Next steps

  • Mainnet deployment (EscrowVault + TbtcLiquidityVault + infrastructure)
  • T staking integration for 0-conf settlement
  • threshold-dapp integration (2 files + config)
  • Aggregator integration (SwapKit, Rango)
  • Mainnet testing with real BTC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment