Taker Integration Guide#
This guide walks institutional takers (asset managers, corporate treasuries, payment firms) through the complete trade flow: submit an order, receive competing quotes, select the best price, and execute settlement.
Integration Options#
| SDK | REST API | SwapWidget | |
|---|---|---|---|
| Setup time | ~1 day | ~2 days | ~1 hour |
| Languages | TypeScript, Python | Any (HTTP) | React only |
| Customization | Full | Full | Theme only |
| Complexity | Low | Medium | None |
| Best for | Standard integration | Custom workflows | Quick PoC / embed |
Settlement Timeline#
End-to-end latency
~50 seconds
<100ms
RFQ Submit
2-5s
Auction Window
~15s
Accept + Escrow
~30s
DvP Settlement
<5s
Confirmation
const settlement = await tetrafi.rfq.acceptBest(rfq.id);console.log(`Settlement: {settlement.id}, state: {settlement.state}`);Integration Checklist#
Integration Checklist
Going to production? The 6 steps below assume sandbox mode. Before flipping to mainnet, read the Common Pitfalls section at the bottom - three integration mistakes account for ~80% of first-week production incidents.
Step 1: Prerequisites#
Before integrating, ensure:
- Compliance attestation completed (KYC for individuals, KYB for entities)
- API key generated from the TetraFi dashboard
- Wallet funded with stablecoins on a supported chain
- Environment configured for sandbox testing
1# Set environment variables2export TETRAFI_API_KEY=tfk_test_...3export TETRAFI_BASE_URL=https://sandbox.tetrafi.io/api/v145# Verify your API key6curl -H "Authorization: Bearer $TETRAFI_API_KEY" \7 TETRAFI_BASE_URL/healthThe TetraFi attestation hash (X-TetraFi-Attestation) proves your identity has been verified. Include it on compliance-sensitive operations (e.g., POST /orders) to access the full order book. It is optional on public endpoints like POST /quotes.
Step 2: Submit an RFQ#
Broadcast your trade request to competing solvers:
1import { TetraFi } from "@tetrafi/sdk";23const tetrafi = new TetraFi({4 apiKey: process.env.TETRAFI_API_KEY!,5 environment: "sandbox",6});78const rfq = await tetrafi.rfq.create({9 pair: "USDC/USDT",10 side: "buy",11 amount: "1000000.00", // 1M USDC12 corridor: "ethereum-optimism",13 maxSlippage: 0.001, // 0.1% max slippage14});1516console.log(`RFQ created: {rfq.id}`);17console.log(`Status: {rfq.status}`); // "quoting"18console.log(`Auction ends: {rfq.expiresAt}`);Want to see the flow execute? The sandbox below stubs the SDK client so you can watch the RFQ lifecycle without real credentials.
1// Stubbed `@tetrafi/sdk` - swap for the real package once installed.2class TetraFi {3constructor(cfg) { this.cfg = cfg; }4rfq = {5 create: async (req) => ({6 id: "rfq_demo_" + Date.now().toString(36),7 status: "quoting",8 expiresAt: new Date(Date.now() + 5000).toISOString(),9 ...req,10 }),11};12}1314const tetrafi = new TetraFi({15apiKey: "tfk_test_demo",16environment: "sandbox",17});1819const rfq = await tetrafi.rfq.create({20pair: "USDC/USDT",21side: "buy",22amount: "1000000.00",23corridor: "ethereum-optimism",24maxSlippage: 0.001,25});2627console.log("RFQ created:", rfq.id);28console.log("Status:", rfq.status);29console.log("Auction ends:", rfq.expiresAt);Step 3: Receive Competing Quotes#
Solvers compete to offer you the best price. You can poll for quotes or subscribe via WebSocket:
1// Option 1: Poll for quotes2const quotes = await tetrafi.rfq.getQuotes(rfq.id);3console.log(`Received {quotes.length} quotes:`);45quotes.forEach((q) => {6 console.log(` {q.solverId}: {q.price} ({q.confidence * 100}% confidence)`);7});89// Option 2: Real-time via WebSocket10tetrafi.events.on("quote.received", (event) => {11 console.log(`New quote: {event.quote.price} from {event.quote.solverId}`);12 console.log(` TTL: {event.quote.ttl}s | Confidence: {event.quote.confidence * 100}%`);13});The auction window is typically 2-5 seconds. You can accept a quote as soon as it arrives or wait for all quotes before choosing. Waiting the full window usually yields better pricing.
Step 4: Accept Best Price#
Accept the winning quote to trigger escrow creation:
1// Automatic best-price selection2const settlement = await tetrafi.rfq.acceptBest(rfq.id);3console.log("Settlement initiated:", settlement.id);45// OR manual selection for custom logic6const sorted = quotes.sort((a, b) => parseFloat(b.price) - parseFloat(a.price));7const settlement = await tetrafi.quotes.accept(sorted[0].id);8console.log("Accepted quote:", sorted[0].id, "at price:", sorted[0].price);Step 5: Monitor Settlement#
Track the settlement through to DvP completion:
1// Subscribe to settlement events2tetrafi.events.on("settlement.pending", (event) => {3 console.log("Escrow locked:", event.settlement.escrowTxHash);4 console.log("Settlement in progress...");5});67tetrafi.events.on("settlement.complete", (event) => {8 const { settlement } = event;9 console.log("Settlement complete!");10 console.log(" Origin TX:", settlement.originTxHash);11 console.log(" Destination TX:", settlement.destinationTxHash);12});1314tetrafi.events.on("settlement.failed", (event) => {15 console.error("Settlement failed:", event.settlement.error);16 console.log("Refund TX:", event.settlement.refundTxHash);17});1819// OR poll status20const status = await tetrafi.settlements.get(settlement.id);21// status.status: "pending" | "escrow_locked" | "filling" | "complete" | "failed"Step 6: Receive Confirmation#
Verify DvP completion and retrieve the full audit trail:
1// Fetch WORM audit trail2const audit = await tetrafi.audit.getTrail(settlement.id);3console.log("Audit entries:", audit.length);45for (const entry of audit) {6 console.log(`[{entry.type}] {entry.timestamp}: {entry.hash}`);7}89// Settlement receipt for accounting10const receipt = {11 settlementId: settlement.id,12 pair: rfq.pair,13 side: rfq.side,14 amount: rfq.amount,15 executedPrice: accepted.price,16 originTx: settlement.originTxHash,17 destTx: settlement.destinationTxHash,18 settledAt: new Date().toISOString(),19};2021await recordToAccountingSystem(receipt);The WORM audit trail provides a complete, tamper-proof record of the trade for regulatory reporting. Each entry includes a cryptographic hash linking it to the previous entry, forming an unbreakable chain of evidence.
Common Pitfalls#
Next Steps#
TypeScript and Python type signatures, every method documented
Real-time quote and settlement event streams
Interactive OpenAPI explorer for every endpoint
How RFQ, escrow, compliance, and DvP fit together
Ready for production? Move from sandbox to mainnet by swapping the base URL (https://api.tetrafi.io/api/v1) and using your live API key. The same code works against both environments - no integration changes required.