Skip to main content
The first wave of stablecoins was dollar-only. The next is multi-currency. Circle’s Arc ships with Circle StableFX, an FX engine for USDC, EURC, and regional partner stablecoins. Quotes are priced offchain through RFQ. Trades settle onchain through Circle’s FxEscrow contract on Arc. Onchain settlement gives a treasury something it has never had: every trade’s funding and payout, for every currency pair, as a queryable event stream. This guide turns that stream into FX flow analytics, a published rate oracle, and exposure controls.

What you’ll build

Step 1: Index settlement activity

FxEscrow’s events record each trade’s lifecycle: TradeRecorded, TakerFunded, MakerDelegateFunded, and TradeStatusChanged. They carry the trade ID and the parties, but not the currencies or amounts. The money moves as ordinary ERC-20 Transfer events into and out of FxEscrow. The pipeline below captures both and writes them to two ClickHouse tables that you join on transaction_hash. FxEscrow addresses (from Arc’s contract addresses):
stablefx-settlements.yaml
For mainnet, change arc_testnet to arc_mainnet and use the mainnet FxEscrow address, in lowercase, in both filters.
The ABI covers the four events FxEscrow emits during a trade. The decoder drops any event that isn’t in it, so add new events to the ABI if Circle adds them. Amounts are raw token units. Divide by the token’s decimals(): USDC and EURC use 6.

Step 2: Analyze FX flows

With trade events and token movements in your warehouse, flows per currency are SQL:
To tie a token movement to a trade, join on the transaction hash. Funding transfers share a transaction with the TakerFunded or MakerDelegateFunded event for that trade:
From the same tables you get corridor flows (net USDC→EURC movement), counterparty league tables, and the funding legs of each trade, grouped by trade_id. Maintain live per-token totals with the PostgreSQL aggregate sink.

Step 3: Publish an FX rate oracle

Other contracts and apps need an FX rate. A scheduled Compose task reads the rate your desk computes from these flows and publishes it onchain, the same mechanism as the NAV oracle, pointed at an FX pair.
src/tasks/publish-fx-rate.ts

Step 4: Monitor exposure and enforce limits

FX desks live and die by position limits. Because you have every funding and payout, net exposure per currency is a running sum, and a Compose task can watch it and act (alert, hedge, or halt quoting) when a limit is breached. Compose’s durable execution guarantees the control fires, and every decision is traced for the desk’s risk review. This is a live version of the circuit-breaker pattern.

Business outcomes

  • Every settlement is data: funding and payout flows per currency and corridor, not a dealer’s end-of-day summary.
  • Multi-currency treasury: real-time positions across USD, EUR, and regional stablecoins in one warehouse.
  • A rate you can publish and defend: an onchain FX oracle sourced from actual settlements, with an audit trail.
  • Automated limit enforcement: exposure breaches trigger controls in seconds.

Resources

Can’t find what you’re looking for? Reach out to us at support@goldsky.com for help.