Skip to main contentSkip to FAQSkip to contact
For TakersHands-on· 25 min

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#

SDKREST APISwapWidget
Setup time~1 day~2 days~1 hour
LanguagesTypeScript, PythonAny (HTTP)React only
CustomizationFullFullTheme only
ComplexityLowMediumNone
Best forStandard integrationCustom workflowsQuick PoC / embed

Settlement Timeline#

One-call settlement - accept best price, get a Settlement
rfq.acceptBest.ts
const settlement = await tetrafi.rfq.acceptBest(rfq.id);
console.log(`Settlement: {settlement.id}, state: {settlement.state}`);
3 linestypescript

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
Bash
1# Set environment variables
2export TETRAFI_API_KEY=tfk_test_...
3export TETRAFI_BASE_URL=https://sandbox.tetrafi.io/api/v1
4
5# Verify your API key
6curl -H "Authorization: Bearer $TETRAFI_API_KEY" \
7 TETRAFI_BASE_URL/health
7 linesbash

The 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:

TypeScript SDK
1import { TetraFi } from "@tetrafi/sdk";
2
3const tetrafi = new TetraFi({
4 apiKey: process.env.TETRAFI_API_KEY!,
5 environment: "sandbox",
6});
7
8const rfq = await tetrafi.rfq.create({
9 pair: "USDC/USDT",
10 side: "buy",
11 amount: "1000000.00", // 1M USDC
12 corridor: "ethereum-optimism",
13 maxSlippage: 0.001, // 0.1% max slippage
14});
15
16console.log(`RFQ created: {rfq.id}`);
17console.log(`Status: {rfq.status}`); // "quoting"
18console.log(`Auction ends: {rfq.expiresAt}`);
18 linestypescript

Want to see the flow execute? The sandbox below stubs the SDK client so you can watch the RFQ lifecycle without real credentials.

try-rfq.tstypescript
TypeScript
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}
13
14const tetrafi = new TetraFi({
15apiKey: "tfk_test_demo",
16environment: "sandbox",
17});
18
19const rfq = await tetrafi.rfq.create({
20pair: "USDC/USDT",
21side: "buy",
22amount: "1000000.00",
23corridor: "ethereum-optimism",
24maxSlippage: 0.001,
25});
26
27console.log("RFQ created:", rfq.id);
28console.log("Status:", rfq.status);
29console.log("Auction ends:", rfq.expiresAt);
29 linestypescript

Step 3: Receive Competing Quotes#

Solvers compete to offer you the best price. You can poll for quotes or subscribe via WebSocket:

TypeScript - Poll
1// Option 1: Poll for quotes
2const quotes = await tetrafi.rfq.getQuotes(rfq.id);
3console.log(`Received {quotes.length} quotes:`);
4
5quotes.forEach((q) => {
6 console.log(` {q.solverId}: {q.price} ({q.confidence * 100}% confidence)`);
7});
8
9// Option 2: Real-time via WebSocket
10tetrafi.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});
13 linestypescript

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:

TypeScript SDK
1// Automatic best-price selection
2const settlement = await tetrafi.rfq.acceptBest(rfq.id);
3console.log("Settlement initiated:", settlement.id);
4
5// OR manual selection for custom logic
6const 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);
8 linestypescript

Step 5: Monitor Settlement#

Track the settlement through to DvP completion:

TypeScript - Events
1// Subscribe to settlement events
2tetrafi.events.on("settlement.pending", (event) => {
3 console.log("Escrow locked:", event.settlement.escrowTxHash);
4 console.log("Settlement in progress...");
5});
6
7tetrafi.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});
13
14tetrafi.events.on("settlement.failed", (event) => {
15 console.error("Settlement failed:", event.settlement.error);
16 console.log("Refund TX:", event.settlement.refundTxHash);
17});
18
19// OR poll status
20const status = await tetrafi.settlements.get(settlement.id);
21// status.status: "pending" | "escrow_locked" | "filling" | "complete" | "failed"
21 linestypescript

Step 6: Receive Confirmation#

Verify DvP completion and retrieve the full audit trail:

TypeScript
1// Fetch WORM audit trail
2const audit = await tetrafi.audit.getTrail(settlement.id);
3console.log("Audit entries:", audit.length);
4
5for (const entry of audit) {
6 console.log(`[{entry.type}] {entry.timestamp}: {entry.hash}`);
7}
8
9// Settlement receipt for accounting
10const 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};
20
21await recordToAccountingSystem(receipt);
21 linestypescript

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#

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.

I'm a TakerStep 4 of 7

Related topics