Skip to main contentSkip to FAQSkip to contact
5 min read

Architecture Overview#

TetraFi is a non-custodial, compliance-first settlement protocol for institutional stablecoin OTC. Competing solvers bid on orders via sealed RFQ auctions. Funds never touch TetraFi's wallets - all settlement executes through on-chain escrow with atomic DvP.

Intent Execution Stack#

TetraFi is an intent coordination layer - it accepts user intents, runs competitive solver auctions, enforces compliance, and coordinates settlement. How solvers source liquidity is the solver's problem, not TetraFi's.

Protocol Stack

@tetrafi/sdk (TypeScript)

Typed SDK with RFQ submission, WebSocket quote streaming, and settlement tracking.

Python SDK

Async Python client for institutional trading desks and algorithmic strategies.

SwapWidget

Embeddable React component for instant OTC swap integration.

REST API Client

Direct HTTP interface for any language - full endpoint coverage.

REST API (axum)

High-throughput Rust HTTP handlers for RFQ submission, quote retrieval, and order management.

WebSocket Server

Real-time quote streaming and event notifications to solvers and takers.

Auction Engine

UCCP-based quote ranking with compliance filtering and fair pricing guarantees.

Corridor Router

Maps token pairs to directed corridors and routes to qualified solver sets.

Order Manager

ERC-7683 StandardOrder parsing, validation, and lifecycle tracking.

Fill Engine

Executes fills on destination chain OutputSettler contracts.

Settlement Monitor

Watches for oracle proofs and triggers claim/refund on escrow.

Pricing Engine

Real-time price feeds with gas estimation for competitive quoting.

ComplianceRegistry

On-chain attestation storage. Per-chain deployment. Checked pre-trade.

KYC/KYB Adapters

Vendor adapters for Chainalysis, Elliptic, and other identity providers.

Travel Rule Engine

IVMS101 message construction and VASP-to-VASP transmission.

Evidence Ledger (WORM)

Append-only audit trail. Write-Once Read-Many for regulatory compliance.

InputSettler (Escrow)

Origin chain deposit locking. Two modes: Permit2Escrow and CompactEscrow (ResourceLock).

OutputSettler

Destination chain fill recording. Resolves limit, dutch auction, and exclusive order types.

Oracle Contracts

Cross-chain attestation verification via Hyperlane ISM integration.

Permit2 / Compact

Token approval infrastructure - gasless approvals and allocator-based locking.

Client SDK & UI
RFQ Aggregator
Solver Network
Compliance Layer
Smart Contracts
LayerConcernTetraFi Scope
Intent Expression (WHAT)User declares desired outcome via ERC-7683 StandardOrderYes - accepts and validates
Orderflow Auction (WHO)Solvers compete via RFQ or Dutch auction for best executionYes - runs auction, ranks quotes
Settlement Primitive (HOW)ResourceLock, Permit2Escrow - orthogonal to intent formatYes - coordinates settlement
Solver LiquidityHow solver sources funds - inventory, OTC, DEX, bridgesNo - outside scope

Each layer evolves independently. New settlement primitives or solver networks plug in without changing the intent format.

Protocol Economics#

Platform - All-in Cost

< 3 bps

$1M–$10M stablecoin transfers, under 10 min

Platform - TetraFi Take Rate

0.15–0.20 bps

~15–30% of execution fee

Solvers - Solver Share

70–85%

Maximizes competitive pool to compress spreads

Solvers - Settlement Guarantee

DvP

Funds leave escrow only once solver has verifiably delivered

Settlement Lifecycle#

Six stages: RFQ & AuctionEscrow LockSolver FillOracle ProofClaim / RefundWORM Audit (Compliant path only).

See Settlement Flows for the canonical lifecycle with diagrams, state machine, and per-stage contract calls.

Settlement Intent (ERC-7683)#

ERC-7683 Open Intents Framework - TetraFi implements the open standard for cross-chain settlement intents. Any solver or application can interoperate using the same typed StandardOrder format, enabling a permissionless solver ecosystem.

Every trade is a typed StandardOrder - inputs on origin chain, desired outputs on destination chain. Orders are signed off-chain via EIP-712 and submitted on-chain to trigger escrow.

TypeScript
1interface StandardOrder {
2 user: string; // Taker wallet
3 originChainId: number; // Origin chain
4 expires: number; // Refund deadline
5 fillDeadline: number; // Solver must fill before this
6 inputs: [string, string][]; // [token, amount] on origin
7 outputs: MandateOutput[]; // Desired outputs on destination
8}
8 linestypescript

See Smart Contracts for full StandardOrder and MandateOutput interfaces.

Aggregator Pipeline#

The TetraFi aggregator (POST /api/v1/quotes) fans out each RFQ to all registered solvers simultaneously with configurable timeout and early termination (once min_quotes received). Quotes are ranked, the winning solver's settlement path is injected (Compliant or Direct based on API key presence), and the order is returned ready for on-chain submission.

Compliance Layer#

The ComplianceRegistry is an on-chain smart contract that stores compliance attestations for all participants. Both solvers and takers must have valid entries before trading.

Each attestation stores: jurisdiction, tier (Retail / Professional / Institutional), expiry, and KYC vendor hash. Non-compliant addresses are rejected at the contract level. Every trade generates an immutable WORM audit record - hash-chained, append-only, tamper-proof. See Compliance Architecture for full details including settlement path routing, Travel Rule, and KYC/KYB onboarding.

Cross-Chain Architecture#

TetraFi supports cross-chain settlement via ERC-7683 settlement intents:

InputSettler

Origin Chain

Locks taker's funds via escrow or ResourceLock

OutputSettler

Destination Chain

Records solver's fill and delivers funds to taker

Oracle

Cross-chain

Attests fill proof (Hyperlane, LayerZero, Wormhole, Polymer)

ComplianceRegistry

Per-chain

Validates participant KYC attestation on every chain

Supported Networks#

  • Ethereum (mainnet + Sepolia testnet)
  • Optimism (mainnet + Sepolia testnet)
  • Base (mainnet + Sepolia testnet)
  • Arbitrum (One mainnet + Sepolia testnet)

Cross-chain pairs are identified by corridor (e.g., ethereum-optimism) and must have solver coverage on both sides.

Oracles#

7 oracle implementations: Hyperlane (default for EVM L2 corridors), LayerZero, Wormhole (cross-VM), Polymer (ZK-proof), PolymerMapped, Broadcaster (ERC-7888), and Bitcoin (SPV). All implement the same IInputOracle interface - drop-in replacement per corridor.

See Cross-Chain Settlement for oracle comparison and corridor recommendations.

State Machine#

On-Chain Escrow State Machine

deposit()finalise()refund()NoneDepositedClaimedRefunded
initial
normal
success
error
Hover a state to explore

On-chain: NoneDepositedClaimed | Refunded (4 states, enforced by InputSettler contract).

Off-chain solver engine tracks a 9-state lifecycle for operational monitoring - from Discovered through Completed. Each transition emits a SolverEvent. See Settlement Flows for the full order lifecycle diagram.

Security Model#

TetraFi is non-custodial. The protocol operator never holds, controls, or has access to user funds. All fund movements are governed by smart contract logic.

Security PropertyMechanism
DvP AtomicityBoth legs settle or neither does (oracle-attested escrow)
Non-custodialFunds move directly between counterparties via escrow
Escrow TimeoutAutomatic refund if fill deadline expires
Sealed BidsEIP-712 typed signing prevents solver information leakage
On-Chain ComplianceComplianceRegistry checks enforced at contract level

Lock Types#

Three lock mechanisms for escrowing funds: ResourceLock (output-first via The Compact, 0xff), Permit2Escrow (input-first, 0x00), and EIP-3009Escrow (gasless stablecoins, 0x01). Funds are released only when the oracle proves the fill - or refunded on timeout.

See Settlement Flows for the full lock type comparison, settlement path routing, and order types.

See Also#

Just exploringStep 2 of 6

Related topics