SENIORCHAPTER 21

Cross-border payments: correspondent banks, FX, remittances, PAPSS

A £200 transfer is three currencies, two conversions and a bank in the middle that takes a fee. Book each leg, measure the cost the way the World Bank does, and find the exposure while the money is in flight

55 MINPAYMENTSUPDATED 2026-11-14
PREDICT

A sender is shown: send £200, fee £3. The rate the company gives is 3% below the mid-market rate, the rate at which banks trade with each other. By the World Bank's method, which counts the fee and the exchange-rate margin, what share of the £200 does the transfer cost?

Money moves between two countries the way it moves inside one: two records change, and someone has to settle. What is new is that the two records are in different currencies, in different banking systems, with no shared account between them. How money moves put the payer’s bank, the switch and the receiver’s bank between a payment and its settlement. A cross-border payment adds one or more banks in the middle, a currency conversion at each step, and clocks that do not agree. This chapter uses the lab’s books to show what that does to a ledger, then looks at the rules and at PAPSS, the African system built to shorten the chain.

One payment, four ways to cross a border

A cross-border retail payment is a funds transfer of low value and urgency where the payer and the payee are in different countries. Four designs carry most of them.

Design How the money crosses Who holds the risk while it moves What it costs you to run
Correspondent banking A chain of banks, each holding an account for the next: your bank’s account at another bank is your nostro (“ours” in Latin), and from the other bank’s side it is a vostro (“yours”) Each bank in the chain, until the next one credits Fees at each hop, taken from the payment or billed to you
Money transfer operator (MTO) The operator collects in one country and pays out in another from money it has already placed there, then settles the net between its two sides in bulk The operator, while its pools are unbalanced Pre-funded float in each country, and a licence in each
Network or wallet link A card scheme, a wallet network or a mobile-money link moves value between participants The network, within its rules Scheme fees, plus the network’s FX rate
Local-rail link Two national instant systems are connected and settle in bulk The settlement agent Joining the link, and pre-funding

The Committee on Payments and Market Infrastructures (CPMI), in its 2018 report Cross-border retail payments (CPMI Papers No 173), found these payments generally slower, costlier and more opaque than domestic ones, and that most clearing and settlement still runs through correspondent banks, which find high-volume, low-value retail payments hard to serve. That is a 2018 finding, read here from the BIS summary page and a search summary; read the report for the evidence and for what has changed sinceas of 2026-11.

The remittance company in this chapter is an MTO in the second row. It also uses the first row inside its own chain, which is the part that surprises engineers: to turn pounds into naira, it goes through dollars. A thin pair is often cheaper as two trades through a major currency than as one trade. The lab models that: pounds to dollars (leg 1), dollars to naira (leg 2), then a NIP payout to the beneficiary’s bank, the rail from Nigeria’s rails.

London (GBP)Sender pays£203.00GBP collected£3.00 stays as fee incomeFX dealerleg 1: £200 to $249the border: two banking systems, two clocksLagos (NGN)CorrespondentUSD account, takes $4Lagos bankleg 2: $245 to nairaBeneficiary₦388,000 by NIPEvery arrow is a posting. Three are conversions or fees, and each leaves a trace in the ledger.

The fees you do not choose

The correspondent in the middle is a bank with its own price list, and its fee comes out of your money on the way. The payment message that travels along the chain carries an instruction for who bears the charges. In the SWIFT MT103 customer-payment message it is field 71A, with three values that banks and payment-message guides describe the same way: OUR puts all charges on the sender, so the beneficiary should receive the full amount; SHA (shared) has the sender pay its own bank’s charge and lets intermediaries deduct theirs from the payment; BEN takes all charges from the beneficiary. In ISO 20022 the same choice is the charge-bearer field, with values DEBT, SHAR and CRED. The payment messages chapter in this module covers the two formats in full; here the point is the consequence. These are conventions described in bank and messaging guides, not one regulator’s rule, so your bank’s terms decide the details.

With SHA or BEN the amount that arrives is not the amount sent, and the shortfall is a fee you did not set. In the lab the company pays the correspondent’s fee itself (an OUR-style choice), so the beneficiary gets exactly ₦388,000 and the company sees a $4.00 expense. A fixed fee like that hurts small payments: $4.00 at the lab’s rates is ₦6,400, which is more than the £3 the sender pays as the fee. The next sections measure what that does.

Rates, spreads and the cost nobody shows

Four prices meet in one transfer. The mid-market rate is the midpoint between what the market will pay and what it will charge for a currency; it is a reference, not a price anyone is guaranteed. The spread is the distance between a counterparty’s buy and sell prices around mid. A dealer who gives you $249 for £200 when mid says $250 has taken a spread of 0.4%. The customer rate is what the sender’s quote uses. The margin is how far that rate sits from mid, on the sender’s side.

In the lab, every rate is an invented input, set at the top of xb.py so that you can change it:

Rate Mid What the company gets or gives Distance from mid
GBP to USD, leg 1 1.2500 1.2450 0.4% below
USD to NGN, leg 2 ₦1,600 ₦1,596 0.25% below
GBP to NGN, to the customer ₦2,000 ₦1,940 3.0% below

The mid rates are consistent with each other by construction: 1.25 × 1,600 = 2,000. They are not market rates; a real rate belongs to a date and a source, and none is used here.

The sender never sees the first two rows. They see the third, and the third is where most of the cost sits. The World Bank’s Remittance Prices Worldwide database, the source for UN Sustainable Development Goal indicator 10.c.1, counts a transfer’s total cost as the fee plus the exchange-rate margin, where the margin is how far the rate charged to the sender sits above the current interbank rate, for a $200 send (the database also prices $500). The target in goal 10.c is to reduce remittance transaction costs to less than 3% and to eliminate corridors costing more than 5%, by 2030. These definitions are taken from the World Bank’s SDG metadata page as shown in search results; the live methodology page is at remittanceprices.worldbank.org/methodology, and the current average is a quarterly figure that you should read there, not hereas of 2026-11. In the lab, mid is the stand-in for the interbank rate.

The Financial Stability Board’s 2021 targets for the G20 roadmap restate the remittance cost goal (an average of no more than 3%, no corridor above 5%, by 2030) and add a speed goal: 75% of cross-border payments, remittances included, available to the recipient within one hour of initiation, by 2027. Read from search summaries; check the FSB’s latest progress report for revisionsas of 2026-11.

Total cost has two parts that behave differently. The fee is fixed in money, so its share falls as the amount grows. The margin is a fixed share, so it does not. Step 5 of the lab computes both from the ledger’s arithmetic:

Sent Fee share Margin share All-in cost
£20 15.0% 3.0% 18.0%
£50 6.0% 3.0% 9.0%
£200 1.5% 3.0% 4.5%
£1,000 0.3% 3.0% 3.3%

That is why a headline fee is the wrong number to advertise or to optimise. A sender of £20 pays a headline fee of 15% and a total of 18%. The company’s own costs have the same shape, because the correspondent’s $4.00 does not shrink either. At the lab’s rates a £20 transfer leaves the company ₦556.40 and a £1,000 one leaves it ₦46,636.00, which is why companies batch (see below).

Posting it: one ledger, three currencies

The money-in-software chapter ended on a rule for conversion: convert and round once, store the rate and its source, never keep a float. This chapter needs the rest of a multi-currency ledger. The design the lab uses is the common one.

  • One base currency. The books are kept in naira. Every entry carries its value in kobo at the book rate, the mid rate on the day. Debits equal credits in that base, so the checks of module 1 keep working unchanged.
  • The native amount beside it. Each entry also carries its currency and its amount in that currency’s minor units: pence, cents or kobo. That column is what lets you say how many pounds the company holds.
  • The rate, stored. A separate row records the mid and the applied rate for each conversion.
  • Conversions that do not trade at mid leave a difference. If a dealer pays $249 for £200 when mid says $250, the dollars arrive worth less in kobo than the pounds that left. The balance is realised FX gain or loss: realised because the trade is done. Revaluing a balance you still hold at a new mid, with no trade, gives an unrealised result; the lab does no revaluation, so the break at the end of the lab shows the same move as a realised loss.

The five postings of the lab’s £200 transfer, in kobo (₦1 is 100 kobo), are these. Each balances in the base column.

Step Debit Credit Why
1. Collect £203.00 GBP account ₦406,000 Owed to beneficiary ₦388,000; fee income ₦6,000; FX margin income ₦12,000 The naira owed is fixed at the customer rate: 20,000 pence × 1,940 = 38,800,000 kobo
2. Leg 1 USD account ₦398,400 ($249.00); FX loss ₦1,600 GBP account ₦400,000 20,000 pence at 1.2450 is 24,900 cents; at mid they are worth 24,900 × 1,600 = 39,840,000 kobo
3. Correspondent fee Fees expense ₦6,400 ($4.00) USD account ₦6,400 400 cents at 1,600
4. Leg 2 Naira float ₦391,020; FX loss ₦980 USD account ₦392,000 ($245.00) 24,500 cents at 1,596 is 39,102,000 kobo, against 39,200,000 at mid
5. NIP payout Owed to beneficiary ₦388,000 Naira float ₦388,000 The beneficiary is paid

Profit is what remains: income of ₦6,000 + ₦12,000, less FX losses of ₦1,600 + ₦980, less ₦6,400 of correspondent fees, is ₦9,020. The sender bore ₦18,000 of cost at mid (4.5% of ₦400,000), and ₦8,980 of it went to the dealer, the correspondent and the Lagos bank.

The margin line is income booked on the day the sender pays, before any dealer is paid. Keep it apart from the FX loss lines: a company that nets them cannot see a bad week.

The position you carry while the money moves

Between step 1 and step 4 the company owes naira that it does not yet have and holds pounds that it has not sold. In the lab, after step 1 its position is GBP +20,300 pence and NGN -38,800,000 kobo: long pounds and short naira. A position is what you hold in one currency, net of what you owe in it. If the pound weakens against the naira before leg 2, the company’s loss is the difference, because the beneficiary’s naira amount is already fixed.

That window is called the open position and it is the risk of the business. There are four ways to shrink it.

  1. Convert immediately. Each payment triggers its own trades. The position closes in minutes, but every trade pays a dealer’s spread and, if it goes through a correspondent, its fixed fee.
  2. Batch. Convert and send many payments’ worth at once. The fixed fee is shared, so the lab’s £200 payment keeps ₦14,765.60 in a batch of ten and ₦15,276.32 in a batch of fifty, against ₦9,020.00 alone. The position stays open until the batch runs, so batching trades fee for risk.
  3. Pre-fund. Hold naira in Lagos in advance and pay out at once, then replenish by buying naira in bulk. The position is now the other way round: the company is long naira for as long as the float lasts. Pre-funding is also the settlement model of the shared systems in the next section.
  4. Lock and hedge. Quote the customer a rate valid for a short time, and buy forward or at once the currency you will need. A hedge costs money too, and is outside this chapter.

No option is free. Each sets who bears the rate risk, which is a pricing decision as much as an engineering one, and a ledger that cannot show the position by currency cannot show it.

The rules around it

Cross-border payments run through rules on three sides: the country that pays, the country that receives, and the rules of the rail.

The Nigerian rules for this business are those for international money transfer operators (IMTOs). Law-firm commentaries found by search describe the CBN’s revised Guidelines on International Money Transfer Services in Nigeria, approved on 31 January 2024 and replacing the 2014 guidelines, as limiting IMTOs to inbound transfers (outbound is not permitted), requiring beneficiaries to be paid in naira through a bank account or in cash, and requiring a head office in Nigeria. They also say banks may act as agents of licensed IMTOs, though the summaries differ on fintech companies. The CBN’s own text was not found by search, so these points rest on commentary. Search summaries disagree on how banks and fintechs may act as agents. Read the CBN’s current text before you rely on any detail hereas of 2026-11. For the engineer: the payout leg is naira, so a payout that fails cannot be settled in dollars instead, and the policy for a failed payout (see the failures below) has to be decided in advance.

A June 2024 CBN circular on naira liquidity for diaspora remittances is summarised in a law-firm article as giving eligible IMTOs access to naira through a CBN window or through authorised dealer banks, with same-day settlement for trades confirmed before noon, and daily returns to the CBN. Coverage of the circular also says the CBN reminded IMTOs that diaspora remittances are expected to end in naira. This is a secondary summary of a circular that may have been superseded, so check the CBN’s latest circulars on the foreign exchange marketas of 2026-11.

The sending country has its own rules, which depend on the licence the company holds there. This chapter did not research the UK’s, so it says nothing about them. Screening payers and beneficiaries against sanctions lists and money-laundering rules sits across both sides; the Compliance course covers it, and this chapter links it in plain text because that course is not yet written. One engineering fact is worth knowing now. Name matching on Nigerian names, with Yoruba, Igbo and Hausa spellings and varied ordering of given and family names, produces both false alarms and misses. A payout held for screening is a position you still carry.

PAPSS: a different shape

A shared system changes the chain. The Pan-African Payment and Settlement System (PAPSS), a pan-African system associated with Afreximbank, is described on its own page, and in search summaries of it, as built on three processes: instant payment, pre-funding and net settlement. The summaries say it settles on a multilateral net basis, with Afreximbank acting as the main settlement agent. Each day it works out the net position of each participating central bank in local currency, settles all positions at the same time (11:00 UTC), and Afreximbank then issues a hard-currency settlement instruction, Sources differ on the currency mechanics: one says inter-bank settlement is in US dollars, others stress local-currency settlement. Participants, corridors and rules change; check PAPSS’s own pages for who can use it todayas of 2026-11.

Compare that with the chain above. The payer’s bank does not hold dollars at a correspondent for each corridor. A participant is pre-funded, payments are instant between participants’ systems, and the bank owes or is owed the net of everything for the day. Settlement and payouts taught netting inside Nigeria. PAPSS does the same across countries. Fewer hops can mean fewer fixed fees. The conversion and the pre-funded float remain. Instead of a USD nostro per correspondent you hold one settlement position with an operator, and the reconciliation target is its daily net statement.

Where it goes wrong

Name the failures first. Each one looks fine until the month end.

Advertising or optimising the headline fee. The fee is 1.5% on £200 and 15% on £20. The margin does not move. Measure total cost by amount band, the way the table above does.

Rates in the wrong direction. A rate “from pounds to naira” and “from naira to pounds” are reciprocals, and both can be quoted. A table that stores one without its direction will apply the wrong one to a refund. Store the pair, the direction, the mid, the applied rate and the source.

Rounding twice. Converting £200.00 to dollars and rounding, then converting the dollars to naira and rounding again, can drift by a kobo from converting once. The lab rounds once per conversion, half to even, as in money in software, and keeps each leg’s rounding visible.

Booking at the wrong rate. An entry valued at last night’s mid, when the trade went at today’s, makes the gain or loss land on the wrong day, or in the wrong account.

A payout that fails after the conversions. The beneficiary’s bank is down (the lab switch’s 91), but the company has already bought the naira. The sender asks for their pounds back. Refunding at today’s rate may cost more than the margin earned, and refunding at the original rate leaves the company with a loss. Decide the policy before it happens, and book the refund as its own transaction with its own rate.

A correspondent fee that nobody books. The amount that arrives is short by a fee the ledger never saw. The nostro statement and the ledger disagree by exactly that amount on every payment. Reconciliation applies: match the USD statement line against the USD ledger line, in dollars, and classify the gap.

LAB Post a £200 remittance through two legs, read the position, and measure the cost ~45 MIN
YOU NEEDPython 3.9 or later (standard library only)labs/finance with the data generated (python3 generate.py)A second terminal for the mock switch in step 4No Docker, no packages

You work in labs/finance. You create six small files there: xb.py, setup_fx.py, remit.py, report.py, payout_switch.py and sizes.py. You never touch data/finance.sqlite: step 1 copies it to data/xborder.sqlite, and everything after runs on the copy. Owoleaf does not send remittances. Its books stand in for the remittance company’s because they give you a working ledger and a checker, and the accounts you add are the ones a remittance business needs. Every rate, fee and the correspondent’s charge in xb.py is invented for this lab. All queries run through Python’s sqlite3 module; no sqlite3 program is needed.

1. Copy the books and add the currencies. Save xb.py, the library the other files share, and setup_fx.py. The library holds the inputs, a conversion function that rounds once, half to even, and a posting function that refuses an entry set that does not balance in kobo. setup() adds a currency column and a native-amount column to entries in the copy, eight accounts, and a table for rates.

"""Shared pieces for the cross-border lab: illustrative inputs, rounding, and a posting function.

Every rate below is ILLUSTRATIVE, invented for this lab. Money is integer minor units:
pence (GBP), cents (USD), kobo (NGN). Rates are ratios, so they are Decimals, never floats.
"""
import shutil
import sqlite3
from decimal import Decimal as D, ROUND_HALF_EVEN

SRC, DB = "data/finance.sqlite", "data/xborder.sqlite"

# Mid-market reference rates (the book rates the ledger values everything at).
GBPUSD_MID, USDNGN_MID = D("1.25"), D("1600")
GBPNGN_MID = GBPUSD_MID * USDNGN_MID                 # 2,000: the cross rate, consistent by construction

# What the company's counterparties and customers actually get.
CUSTOMER_RATE = D("1940")      # naira the beneficiary gets per GBP sent (mid is 2,000)
LEG1_RATE = D("1.2450")        # USD the FX dealer gives per GBP (mid is 1.25)
LEG2_RATE = D("1596")          # naira the Lagos bank gives per USD (mid is 1,600)
CORR_FEE_CENTS = 400           # the correspondent's fee, taken from the USD on its way: $4.00
FEE_PENCE = 300                # the headline transfer fee the sender sees: £3.00
SEND_PENCE = 20_000            # £200.00 sent

MID_TO_NGN = {"NGN": D(1), "USD": USDNGN_MID, "GBP": GBPNGN_MID}


def conv(minor, rate):
    """Convert minor units of one currency to another at `rate`, rounding once, half to even.
    All three currencies here have two decimals, so minor-to-minor needs no exponent change."""
    return int((D(minor) * rate).quantize(D(1), rounding=ROUND_HALF_EVEN))


def base(minor, currency):
    """The kobo value of an amount at the book (mid) rate."""
    return conv(minor, MID_TO_NGN[currency])


NEW_ACCOUNTS = [  # code, name, type, currency
    ("collect_gbp", "GBP collected from senders, held at the UK bank", "asset", "GBP"),
    ("nostro_usd", "USD account at the correspondent bank", "asset", "USD"),
    ("payout_ngn", "Naira float at the Lagos partner bank", "asset", "NGN"),
    ("remit_payable", "Naira owed to beneficiaries of remittances", "liability", "NGN"),
    ("remit_fee_income", "Transfer fees charged to senders", "income", "NGN"),
    ("fx_margin_income", "Spread between mid and the customer rate", "income", "NGN"),
    ("fx_gain_loss", "Realised FX result on conversions", "income", "NGN"),
    ("correspondent_fees", "Fees taken by correspondent banks", "expense", "NGN"),
]


def setup():
    shutil.copy(SRC, DB)
    db = sqlite3.connect(DB)
    db.execute("ALTER TABLE entries ADD COLUMN currency TEXT NOT NULL DEFAULT 'NGN'")
    db.execute("ALTER TABLE entries ADD COLUMN amount_minor INTEGER")
    db.execute("UPDATE entries SET amount_minor = amount_kobo")
    db.execute("""CREATE TABLE fx_rates (transaction_id INTEGER, pair TEXT, mid TEXT, applied TEXT, source TEXT)""")
    for code, name, typ, cur in NEW_ACCOUNTS:
        db.execute("INSERT INTO accounts (code, name, type, customer_id, currency, opened_at) VALUES (?,?,?,NULL,?,?)",
                   (code, name, typ, cur, "2026-06-30T08:00:00+01:00"))
    db.commit()
    return db


def post(db, ts, kind, ref, legs, rate=None, rail="internal", bank=None):
    """legs: (account code, 'debit'|'credit', currency, minor units, kobo value at the book rate).
    The kobo values must balance, exactly as in every other transaction in the ledger."""
    dr = sum(k for _, d, _, _, k in legs if d == "debit")
    cr = sum(k for _, d, _, _, k in legs if d == "credit")
    if dr != cr:
        raise ValueError(f"{kind} does not balance in kobo: debits {dr}, credits {cr}")
    cur = db.execute("""INSERT INTO transactions (kind, status, failure_reason, customer_id, counterparty_customer_id,
                        amount_kobo, fee_kobo, rail, external_ref, counterparty_bank, related_transaction_id, created_at)
                        VALUES (?, 'succeeded', NULL, NULL, NULL, ?, 0, ?, ?, ?, NULL, ?)""", (kind, dr, rail, ref, bank, ts))
    tid = cur.lastrowid
    for code, direction, currency, minor, kobo in legs:
        acct = db.execute("SELECT id FROM accounts WHERE code = ?", (code,)).fetchone()[0]
        db.execute("""INSERT INTO entries (transaction_id, account_id, direction, amount_kobo, posted_at, currency, amount_minor)
                      VALUES (?,?,?,?,?,?,?)""", (tid, acct, direction, kobo, ts, currency, minor))
    if rate:
        db.execute("INSERT INTO fx_rates VALUES (?,?,?,?,?)", (tid, *rate))
    return tid
import xb

db = xb.setup()
print("accounts now:", db.execute("SELECT COUNT(*) FROM accounts").fetchone()[0])
print("entries with a currency:", db.execute("SELECT currency, COUNT(*) FROM entries GROUP BY currency").fetchall())
print("GBPNGN mid:", xb.GBPNGN_MID, "(1.25 x 1600)")
cd labs/finance
ls data/finance.sqlite >/dev/null 2>&1 || (python3 generate.py && python3 cards.py)
python3 setup_fx.py
accounts now: 2013
entries with a currency: [('NGN', 191103)]
GBPNGN mid: 2000.00 (1.25 x 1600)

The 191,103 existing entries are all naira, so their native amount is their kobo amount. Rerunning setup_fx.py rebuilds the copy from scratch, which is how you start again.

2. Post the remittance. Save remit.py and run it, then run check.py on the copy. The five postings are the table in the chapter: collect, leg 1, the correspondent’s fee, leg 2, the payout. Read each one against the table before you run it.

"""Post one GBP 200 remittance, paid out in naira, through two conversion legs."""
import sqlite3
import xb
from xb import base, conv

DB = sqlite3.connect(xb.DB)
ref = "REM-0001"

# 1. The sender pays GBP 203.00: GBP 200.00 to send and the GBP 3.00 fee. We now owe the beneficiary
#    naira at the customer's rate. The gap between that and the mid-market value is the margin.
owed = conv(xb.SEND_PENCE, xb.CUSTOMER_RATE)                      # kobo the beneficiary will get
t1 = xb.post(DB, "2026-06-30T09:00:00+01:00", "remit_collect", ref, [
    ("collect_gbp", "debit", "GBP", xb.SEND_PENCE + xb.FEE_PENCE, base(xb.SEND_PENCE + xb.FEE_PENCE, "GBP")),
    ("remit_payable", "credit", "NGN", owed, owed),
    ("remit_fee_income", "credit", "GBP", xb.FEE_PENCE, base(xb.FEE_PENCE, "GBP")),
    ("fx_margin_income", "credit", "NGN", base(xb.SEND_PENCE, "GBP") - owed, base(xb.SEND_PENCE, "GBP") - owed),
])

# 2. Leg 1: sell GBP 200.00 to a dealer for USD. The dealer's rate is below mid; the difference is a loss.
usd = conv(xb.SEND_PENCE, xb.LEG1_RATE)                           # cents received
loss1 = base(xb.SEND_PENCE, "GBP") - base(usd, "USD")
t2 = xb.post(DB, "2026-06-30T09:30:00+01:00", "fx_leg1_gbp_usd", ref, [
    ("nostro_usd", "debit", "USD", usd, base(usd, "USD")),
    ("fx_gain_loss", "debit", "NGN", loss1, loss1),
    ("collect_gbp", "credit", "GBP", xb.SEND_PENCE, base(xb.SEND_PENCE, "GBP")),
], rate=("GBPUSD", str(xb.GBPUSD_MID), str(xb.LEG1_RATE), "illustrative"))

# 3. The correspondent takes its fee from the USD before the money reaches the Lagos bank.
t3 = xb.post(DB, "2026-06-30T10:00:00+01:00", "correspondent_fee", ref, [
    ("correspondent_fees", "debit", "USD", xb.CORR_FEE_CENTS, base(xb.CORR_FEE_CENTS, "USD")),
    ("nostro_usd", "credit", "USD", xb.CORR_FEE_CENTS, base(xb.CORR_FEE_CENTS, "USD")),
])

# 4. Leg 2: sell the USD that is left to the Lagos bank for naira.
left = usd - xb.CORR_FEE_CENTS
naira = conv(left, xb.LEG2_RATE)
loss2 = base(left, "USD") - naira
t4 = xb.post(DB, "2026-06-30T10:30:00+01:00", "fx_leg2_usd_ngn", ref, [
    ("payout_ngn", "debit", "NGN", naira, naira),
    ("fx_gain_loss", "debit", "NGN", loss2, loss2),
    ("nostro_usd", "credit", "USD", left, base(left, "USD")),
], rate=("USDNGN", str(xb.USDNGN_MID), str(xb.LEG2_RATE), "illustrative"))

# 5. The payout: the beneficiary's bank is paid by NIP, the rail from module 1.
t5 = xb.post(DB, "2026-06-30T11:00:00+01:00", "remit_payout", ref, [
    ("remit_payable", "debit", "NGN", owed, owed),
    ("payout_ngn", "credit", "NGN", owed, owed),
], rail="nip", bank="B03")
DB.commit()

for name, k in [("collected GBP", xb.SEND_PENCE + xb.FEE_PENCE), ("owed to beneficiary NGN", owed), ("leg 1 USD cents", usd),
                ("leg 1 loss NGN", loss1), ("USD after correspondent", left), ("leg 2 NGN received", naira), ("leg 2 loss NGN", loss2)]:
    print(f"{name:26} {k:>12,}")
print("transactions posted:", [t1, t2, t3, t4, t5])
python3 remit.py
python3 check.py --db data/xborder.sqlite
collected GBP                    20,300
owed to beneficiary NGN      38,800,000
leg 1 USD cents                  24,900
leg 1 loss NGN                  160,000
USD after correspondent          24,500
leg 2 NGN received           39,102,000
leg 2 loss NGN                   98,000
transactions posted: [83888, 83889, 83890, 83891, 83892]
card book: 10,680 card attempts, 109 disputes for 91,728,900 kobo; checks 12-15 run
accounts by type (debit-positive kobo): {'asset': 17355956889, 'equity': -5000000000, 'expense': 111230267, 'income': -223324321, 'liability': -12243862835}
settlement_bank in ledger 17,189,646,589 kobo; on the statement 17,192,741,324 kobo
OK: all invariants hold

check.py still says OK because every posting balances in kobo, and the existing checks do not care about currencies. The asset total rose by 902,000 kobo against the original books (17,355,054,889 to 17,355,956,889), which is the remittance’s ₦9,020.00 profit.

3. Read the position, the profit and the all-in cost. Save report.py. It reads the five postings back from the ledger, prints the open position in each currency’s own units after each step, adds up profit and loss, and computes the sender’s cost the World Bank way.

"""Read the remittance back out of the ledger: open positions after each step, profit, and the all-in cost."""
import sqlite3
from decimal import Decimal as D
import xb

db = sqlite3.connect(xb.DB)
rows = db.execute("""SELECT t.id, t.kind, a.code, a.type, e.direction, e.currency, e.amount_minor, e.amount_kobo
                     FROM entries e JOIN accounts a ON a.id = e.account_id JOIN transactions t ON t.id = e.transaction_id
                     WHERE t.external_ref = 'REM-0001' ORDER BY e.id""").fetchall()

print("Open position after each step (assets minus liabilities, in each currency's own minor units)")
pos, last = {"GBP": 0, "USD": 0, "NGN": 0}, None
for tid, kind, code, typ, d, cur, minor, kobo in rows:
    if last is not None and tid != last[0]:
        print(f"  after {last[1]:18} GBP {pos['GBP']:>8,}  USD {pos['USD']:>8,}  NGN {pos['NGN']:>12,}")
    if typ in ("asset", "liability"):
        pos[cur] += minor if d == "debit" else -minor     # debit-positive: a liability's credit is a short position
    last = (tid, kind)
print(f"  after {last[1]:18} GBP {pos['GBP']:>8,}  USD {pos['USD']:>8,}  NGN {pos['NGN']:>12,}")

pl = {}
for tid, kind, code, typ, d, cur, minor, kobo in rows:
    if typ in ("income", "expense"):
        pl[code] = pl.get(code, 0) + (kobo if d == "credit" else -kobo)    # credits raise profit, debits lower it
print("\nProfit and loss for REM-0001, kobo (income positive, cost negative)")
for code, v in pl.items():
    print(f"  {code:20} {v:>10,}")
print(f"  {'profit':20} {sum(pl.values()):>10,}")

# The cost the sender bore, measured the World Bank way: fee plus exchange-rate margin, as a share of the amount sent.
sent = xb.base(xb.SEND_PENCE, "GBP")
fee = xb.base(xb.FEE_PENCE, "GBP")
margin = sent - xb.conv(xb.SEND_PENCE, xb.CUSTOMER_RATE)
print(f"\nAmount sent at mid: {sent:,} kobo | fee: {fee:,} | margin: {margin:,}")
print("headline fee   ", (D(fee) / D(sent) * 100).quantize(D("0.01")), "%")
print("exchange margin", (D(margin) / D(sent) * 100).quantize(D("0.01")), "%")
print("all-in cost    ", (D(fee + margin) / D(sent) * 100).quantize(D("0.01")), "%")
python3 report.py
Open position after each step (assets minus liabilities, in each currency's own minor units)
  after remit_collect      GBP   20,300  USD        0  NGN  -38,800,000
  after fx_leg1_gbp_usd    GBP      300  USD   24,900  NGN  -38,800,000
  after correspondent_fee  GBP      300  USD   24,500  NGN  -38,800,000
  after fx_leg2_usd_ngn    GBP      300  USD        0  NGN      302,000
  after remit_payout       GBP      300  USD        0  NGN      302,000

Profit and loss for REM-0001, kobo (income positive, cost negative)
  remit_fee_income        600,000
  fx_margin_income      1,200,000
  fx_gain_loss           -258,000
  correspondent_fees     -640,000
  profit                  902,000

Amount sent at mid: 40,000,000 kobo | fee: 600,000 | margin: 1,200,000
headline fee    1.50 %
exchange margin 3.00 %
all-in cost     4.50 %

After step 1 the company is long 20,300 pence and short 38,800,000 kobo: that is the exposure the chapter describes. After leg 2 it holds the £3.00 fee and ₦3,020.00 of naira, which is the difference between the naira the Lagos bank paid and the naira owed. The profit, 902,000 kobo, agrees with the asset total’s movement in step 2. The headline fee is 1.50%; the cost is 4.50%.

4. Pay the beneficiary on the switch. The last posting is an ordinary NIP payout, so run it on the mock switch and compare. In a second terminal start the switch; in this one, save and run payout_switch.py. The switch’s wallet account and bank codes are the lab’s, not real ones.

python3 mock_switch.py --fresh
"""Pay the beneficiary on the mock switch and compare it with what the ledger says we owed."""
import json
import sqlite3
import urllib.request

SW, KEY = "http://127.0.0.1:8102", "sw_test_owoleaf_mock"


def call(path, body=None):
    req = urllib.request.Request(SW + path, data=json.dumps(body).encode() if body is not None else None,
                                 headers={"Authorization": "Bearer " + KEY, "Content-Type": "application/json"})
    with urllib.request.urlopen(req, timeout=10) as r:
        return json.load(r)


db = sqlite3.connect("data/xborder.sqlite")
owed = db.execute("""SELECT e.amount_kobo FROM entries e JOIN accounts a ON a.id = e.account_id
                     JOIN transactions t ON t.id = e.transaction_id
                     WHERE t.kind = 'remit_payout' AND a.code = 'remit_payable' AND e.direction = 'debit'""").fetchone()[0]

ne = call("/name-enquiry", {"bank_code": "B03", "account_number": "0123456781"})
tr = call("/transfers", {"payment_reference": "REM-0001", "name_enquiry_ref": ne["name_enquiry_ref"],
                         "sender_account": "9000000001", "amount_kobo": owed, "narration": "REMITTANCE REM-0001"})
q = call("/tsq", {"payment_reference": "REM-0001"})
print("beneficiary:", ne["account_name"], "| ledger owed:", f"{owed:,}", "kobo")
print("transfer:", tr["response_code"], tr["status"], "| session id length:", len(tr["session_id"]))
print("requery:", q["response_code"], q["status"], f"{q['amount_kobo']:,}", "kobo | same as ledger:", q["amount_kobo"] == owed)
python3 payout_switch.py
beneficiary: HOLDER B03-6781 | ledger owed: 38,800,000 kobo
transfer: 00 successful | session id length: 30
requery: 00 successful 38,800,000 kobo | same as ledger: True

The switch took 38,800,000 kobo, ₦388,000, which is exactly what the ledger says the company owed. A requery by the payment reference finds it, as in the idempotency chapter. Stop the switch with Ctrl+C when you are done.

5. See why small transfers cost more. Save sizes.py. It reuses the same arithmetic for four amounts, then shares the correspondent’s fee across a batch.

"""All-in cost to the sender, and profit to the company, by amount sent; then the effect of batching."""
from decimal import Decimal as D
import xb
from xb import base, conv


def economics(send_pence, batch=1):
    fee = base(xb.FEE_PENCE, "GBP")
    sent = base(send_pence, "GBP")
    margin = sent - conv(send_pence, xb.CUSTOMER_RATE)
    usd = conv(send_pence, xb.LEG1_RATE)
    loss1 = sent - base(usd, "USD")
    corr = base(xb.CORR_FEE_CENTS, "USD") // batch                 # a batched transfer shares one fixed fee
    left = usd - xb.CORR_FEE_CENTS // batch
    loss2 = base(left, "USD") - conv(left, xb.LEG2_RATE)
    return sent, fee, margin, fee + margin - loss1 - loss2 - corr


pct = lambda a, b: (D(a) / D(b) * 100).quantize(D("0.1"))
print(f"{'sent':>8} {'fee %':>7} {'margin %':>9} {'all-in %':>9} {'profit (naira)':>15}")
for pence in (2_000, 5_000, 20_000, 100_000):
    sent, fee, margin, profit = economics(pence)
    print(f"£{pence // 100:>7,} {pct(fee, sent):>7} {pct(margin, sent):>9} {pct(fee + margin, sent):>9} {D(profit) / 100:>15,.2f}")

print("\n£200 sends, correspondent fee shared across a batch")
for batch in (1, 10, 50):
    print(f"  batch of {batch:>2}: profit per payment ₦{D(economics(20_000, batch)[3]) / 100:,.2f}")
python3 sizes.py
    sent   fee %  margin %  all-in %  profit (naira)
£     20    15.0       3.0      18.0          556.40
£     50     6.0       3.0       9.0        1,967.00
£    200     1.5       3.0       4.5        9,020.00
£  1,000     0.3       3.0       3.3       46,636.00

£200 sends, correspondent fee shared across a batch
  batch of  1: profit per payment ₦9,020.00
  batch of 10: profit per payment ₦14,765.60
  batch of 50: profit per payment ₦15,276.32

The margin is 3.0% on every row. The fee share falls from 15.0% to 0.3%, so the all-in cost falls from 18.0% to 3.3%. The £20 transfer leaves the company ₦556.40, because the correspondent’s ₦6,400 is nearly all of what it earns. Batching ten payments raises the profit on a £200 transfer from ₦9,020.00 to ₦14,765.60.

Move the rate before leg 2. In xb.py change LEG2_RATE = D("1596") to D("1572"), a dealer rate 24 naira lower, as if the market moved while the payment waited. Run python3 setup_fx.py, python3 remit.py, python3 report.py and python3 check.py --db data/xborder.sqlite again.

python3 setup_fx.py && python3 remit.py && python3 report.py && python3 check.py --db data/xborder.sqlite

What to look for: leg 2 pays 38,514,000 kobo against 38,800,000 owed, so the naira float ends at -286,000 kobo. The ledger still balances and check.py still says OK, because nothing in module 1’s checks knows that a bank account should not go negative, and the profit falls from 902,000 kobo to 314,000, the loss at leg 2 growing from 98,000 to 686,000. A move of 1.5% in the dealer’s rate has taken most of the profit. Restore 1596 when you are done. Then decide which of the four ways to shrink the open position would have kept this payment’s profit.

ARTEFACT Write a corridor cost and disclosure note ~45 MIN
YOU PRODUCECorridor cost and disclosure note

Template

# Corridor cost and disclosure note: <origin> to <destination>, <send amount>
Written by <corridor or product manager> · Figures from <engineer> · Signed by <compliance> and <head of payments> · Date

## Corridor and amount
<Currencies, the route and rail, the send amount this note prices, and why that amount>

## Total cost to the sender
| Part | Pounds | Share of amount sent | Where the figure comes from |
|---|---|---|---|
| Fee | | | |
| Exchange-rate margin (mid minus the customer's rate) | | | |
| Total | | | |
Rates used: <mid, customer's rate, source and date>
Cost by amount band: <what happens at smaller and larger sends>

## Time, and where the money waits
| Step | Money sits at | In which currency | Position the company carries |
|---|---|---|---|
Time quoted to the customer: <a figure and the measured payouts behind it, or 'not yet measured'>

## Failure and return cases
| Case | Customer sees | Books do | Refund rule and rate | Owner |
|---|---|---|---|---|

## Wording shown before the customer pays
<The exact text, where on the screen it appears, and any old wording it replaces>

## What this note cannot see
<Rates that move, rules not checked, one way the note could be wrong and what would show it>

## Decision needed
<What compliance and the head of payments are asked to sign, and by when>
WORKED EXAMPLE

At a real company the corridor or product manager writes this note, and compliance and the head of payments sign it. At the 80-person remittance company, Dapo wrote it as corridor owner, with Bilkisu reading the figures from the ledger, after a customer asked where ₦12,000 went.

Corridor. UK to Nigeria, pounds to naira through dollars, paid out by NIP. Priced at £200.

Cost. The sender pays £203.00. The fee is £3.00, 1.50%. The customer’s rate is ₦1,940 against a mid of ₦2,000, a margin of ₦12,000 or £6.00, 3.00%. Total cost £9.00, 4.50% (step 3). A £20 send costs 18.0% and £1,000 costs 3.3% (step 5).

Time. The lab’s clock times are invented, so the screen promises no duration until real payouts are measured. Money sits as pounds at the UK bank, then $249.00 and $245.00 at the correspondent, then ₦391,020 in the Lagos float. After collection the company is long £203 and short ₦388,000; after leg 2 it holds £3.00 and ₦3,020.

Failures.

  • The beneficiary’s bank answers 91 after both conversions. The customer sees a failed payout. The refund is booked as its own transaction at its own rate, still undecided. Owner: Dapo.
  • The dealer rate falls to ₦1,572 before leg 2. The customer sees nothing; profit falls from ₦9,020 to ₦3,140 (the break). Owner: Lagos treasury.
  • NIP answers pending. The customer sees ‘on its way’; no payout is posted until confirmed; requery by payment reference and never pay twice. Owner: Bilkisu.

Wording, replacing ‘No hidden charges’:

You send £200.00. Our fee is £3.00. You pay £203.00. Our rate is ₦1,940 for £1. The mid-market rate is ₦2,000, so our rate is 3.0% lower. Your recipient gets ₦388,000. Total cost to you: £9.00, or 4.5% of the amount sent.

Cannot see. The rates are invented, and no UK or Nigerian disclosure rule was checked. If the mid on screen differs from the stored source, the margin shown is wrong; the daily rates table would show it.

Decision. Compliance and Dapo’s head of payments sign the wording and the refund rule by 4 December 2026.

Now you

A month later you are the corridor manager at an unnamed 30-person remittance company in Manchester, sending pounds to Nigeria by the lab’s route at the lab’s rates (assume the same). Most customers send £50. Marketing wants a banner reading ‘Send £50 for a £3 fee’. Write the cost and disclosure note for the £50 send with your engineer. Use step 5 for the £50 row and the profit it leaves, step 3 for the method, step 4 for the switch’s answers and the break for what a rate move does. Assume you have no measured payout times, and say what that means for the time line. Work out the naira the recipient gets and quote the exact wording. The compliance lead and the head of payments read it, and decide whether the banner and the £50 quote go live.

Self-check

DECIDE

Dapo and Bilkisu's company quotes the customer's rate when the sender taps send. Treasury in Lagos buys naira twice a day. In the last quarter a few sharp moves in the naira erased a month of margin on the payments in between. The sales team wants to keep the quote instant, and Dapo wants the risk to stop being a surprise. What do you build first?

READING
  1. DOC
    Cross-border retail payments (CPMI Papers No 173) CPMI (BIS), 2018

    The Committee on Payments and Market Infrastructures' 2018 survey of how retail cross-border payments clear and settle, and why they are slower, costlier and less transparent than domestic ones. Read the sections that describe the correspondent, MTO and network models; skip the survey tables on a first pass.

  2. DOC
    Enhancing cross-border payments: building blocks of a global roadmap (CPMI Papers No 193) CPMI (BIS), 2020

    The CPMI's 2020 list of 19 building blocks for faster, cheaper, more transparent and more inclusive cross-border payments, under the G20 roadmap. Read the summary of the frictions and the building blocks on payment messages and data; skip the detail of the later focus areas first.

  3. DOC
    Targets for addressing the four challenges of cross-border payments (FSB, 2021) Financial Stability Board, 2021

    The FSB's announcement of the cost, speed, access and transparency targets for the G20 roadmap, which this chapter takes from search summaries. Read it for the exact wording of each target and its end date, then check the FSB's latest progress report for what has moved.

  4. DOC
    Remittance Prices Worldwide: methodology World Bank

    The World Bank's own description of how it collects and computes the total cost of sending money. Read it for the definition of the margin and the standard send amounts. It was not read in this build, only seen in search results, so check the wording.

  5. DOC
    SDG indicator 10.c.1: remittance costs as a proportion of the amount remitted World Bank

    The World Bank's metadata for the indicator behind the 3% and 5% targets, with the definition of total cost. Read the definition and the computation sections; skip the country-level notes.

  6. DOC
    How PAPSS works PAPSS

    The operator's own description of PAPSS's pre-funding, instant payment and net settlement. It is a description from the operator, so treat claims about reach and speed as its own. Read it with the chapter's note that sources differ on settlement currency.

  7. POST
    CBN revised guidelines for international money transfer services in Nigeria (Aluko and Oyebode) Aluko and Oyebode, 2024

    A law firm's summary of the 2024 revision: inbound-only operation, naira payout and the licensing stages. Commentary, not the rule. Read it to know what to look for in the CBN's own text.

All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.
NEXT: Card tokenisation, card-on-file and recurring payments →