Library / Blogs

Swift Engineering Blog

Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.

By Swift engineers · Swift · Added 2026-10-12

Open original source

All content belongs to Swift engineers / Swift. We only link to it and give credit. Report a problem

Learn this article

About 37 min left. Your work is saved as you go.

What you are about to study

Swift wrote this to explain how they thought about a problem. You should know the basics: caching, queues and replication.

Ideas you will meet

Distributed Systems
Consensus, time, failure and the fundamentals of scale-out.

What we already know about this

Our own lessons on these ideas. Read them here before you start, so it makes sense.

  • Real-World Systems · 9 minCross-border payments: SWIFT and foreign exchangeHow money moves between countries and currencies, what SWIFT actually is, and why international transfers are slow and costly.Read here

    The problem

    Paying someone across borders or currencies is harder than paying next door. Different banks, rules, currencies and time zones are involved, and there is no single global bank.

    Messages versus money

    Two things happen and they are often confused:

    • Messaging: telling the other bank what to do. SWIFT (the Society for Worldwide Interbank Financial Telecommunication) is a secure messaging network with standard message formats. It does not hold or move money.
    • Settlement: actually moving the value, by adjusting balances in accounts that banks hold with each other, or at a central bank.

    Figure SDA-RWS-08-1 · A payment message crossing a messaging network · © forcsguy.com

    Correspondent banking

    If your bank has no direct relationship with the recipient's bank, it uses correspondent banks. Banks hold accounts with each other:

    • A nostro account: "our money held at your bank, in your currency".
    • A vostro account: the mirror view, "your money held at our bank".

    Figure SDA-RWS-08-2 · Correspondent banking chain · © forcsguy.com

    Each additional hop can add fees, delay, and a chance of error or manual review, and the sender often cannot see where the payment is.

    Foreign exchange

    Paying in another currency needs currency conversion:

    • Rates come from the FX market (banks and liquidity providers). A provider quotes you a rate that includes a spread (their margin) over the market rate.
    • A quote can be locked for a short time, since rates move constantly, so the system must record the quoted rate and its expiry.
    • The cost of a transfer is fees plus spread, so a "free" transfer may still be expensive.
    • Hedging and netting (offsetting payments in opposite directions) reduce a provider's risk and cost.

    Figure SDA-RWS-08-3 · A currency conversion inside a transfer · © forcsguy.com

    The layers of the currency market

    Behind a single conversion sit three layers. A payment company's own funding pool serves retail needs and is usually topped up in advance. When the pool runs low it trades with wholesale providers, who batch many such orders. Those wholesalers in turn trade with the large international banks at the top. Pre-buying currency in bulk is why a customer's conversion can feel instant even though the settlement happens later.

    Compliance

    Cross-border payments pass sanctions screening, anti-money-laundering (AML) monitoring and know-your-customer (KYC) checks. Suspicious payments are held for manual review, which causes much of the delay. A design must keep full audit trails and be able to stop and explain any payment.

    Faster alternatives

    • Local payment rails (for example SEPA in Europe, Faster Payments in the UK, UPI in India, Pix in Brazil) are cheap and quick domestically. Some services pre-fund local accounts in each country, so a transfer becomes two local payments with the FX done in between, without moving money across borders each time.
    • Instant, standards-based schemes and new interbank initiatives aim to shorten the chain and improve tracking.
    • Some systems use stablecoins or other digital rails for settlement, with their own regulatory and operational risks.

    Designing a system that sends money abroad

    • Treat each transfer as a long-running workflow with states (quoted, submitted, in review, settled, failed, returned).
    • Store the quote (rate, fees, expiry) and show the customer the total up front.
    • Use idempotency keys and a ledger (previous lesson), with separate accounts per currency.
    • Handle returns and rejections: money can come back days later, and the workflow must refund and notify correctly.
    • Reconcile with every partner bank or provider daily, in each currency.

    Real-world reading

    Open this lesson with its quiz and exercise

Go deeper on this

A path through videos, articles, other case studies and code on the same ideas as Swift Engineering Blog.

  1. Warm upGet the vocabulary first.

  2. WatchHow others solve the same problem, on video.

    Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)

  3. ReadEngineers explain it in their own words.

  4. See it in another companyThe same ideas, a different system.

  5. Read the codeSee how it looks when it is real.

Keep learning

Loading community…