← All examples
07

Canonical Grid model

Treasury Control Plane

Large canonical model for liquidity monitoring, stress ladders, FX translation, and operations.

Scale
Very large
Source
07-treasury-control-plane.grid
Length
160 lines
Collection
Live data & operations
Level
Advanced
Runtime
External FX + rules
Version
1.1.0

Watch it in Grid

See this model in motion.

Watch the model respond in the product, then inspect the exact source and checkpoints on this page.

Companion film

The override ledger

Override a computed treasury value, see the funding stack reprice, then undo to recover the original formula.

20 secGrid 0.61.0
Open film page

What this model gives you

A treasury control plane combining a five-day cash ladder, haircut and FX-adjusted funding, coverage stress, operational classifications, and durable escalation rules.

40 min to study · Source reviewed 2026-08-26

Continue with guided practice

What to notice

  • Liquidity ladders and coverage stress
  • Fallback-safe external FX translation
  • Policy classifications over named controls
  • Resident rules, schedules, and missed-run policy

Requirements

  • Async worker runtime and network access for live FX_RATE values
  • Resident rules runtime with persisted state
  • Host clock and scheduler for EVERY and AT actions

Expected checkpoint

A known state for this walkthrough.

At initial evaluation with the authored controls, before any scheduled action has fired, and after unavailable FX providers select the 1.08 EUR/USD and 1.25 GBP/USD fallbacks. The values below are source-derived and not runtime-receipted; the current contract records only provider terminal status.

Opening liquidity
1,750,000A11
Minimum runway
1,680,000 / 0.96F1 / F3
Stressed USD funding
1,764,880K7, fallback-rate path
Funding cost / worst coverage
0.050372 / 3.3165M8 / O4
Initial policy
runway-stable; funding-healthy; contained-funding; coverage-comfortable; normal-opsP1:P5
01 · Ladder

Start with cash movement, not an alert

B1:C5 describe expected inflows and outflows, D1:D5 computes daily net movement, and E1:E5 carries the balance forward. F1:F3 then expose the minimum, maximum, and runway ratio used by policy.

02 · Fund

Separate haircuts, translation, and cost

G:H applies collateral haircuts locally, J selects the effective currency factor, K translates stressed value to USD, and M prices the resulting funding. This makes a live FX change traceable without hiding the continuity fallback.

03 · Classify

Name each control decision before orchestrating it

P1:P5 independently classify runway, haircut quality, funding cost, coverage, and operating mode. Operators can inspect a single failed control instead of reverse-engineering one compound alert.

04 · Operate

Use rules only for durable operational facts

Q:R:S record escalations when their conditions become true. T1:T6 handle interval, cron, and one-shot work with explicit SKIP MISSED or BACKFILL policy; production deployments must persist their target state and scheduler ledger.

07-treasury-control-plane.grid
Get Grid
MODEL "Treasury Control Plane"
DESCRIPTION "Large canonical model for liquidity monitoring, stress ladders, FX translation, and operations."
VERSION "1.1.0"
AUTHOR "Grid Team"
TAGS "canonical", "ts", "large", "treasury", "rules"

# Operating balances and control flags
A1 IS currency = 1850000
A2 IS currency = 720000
A3 IS currency = 410000
A4 IS currency = 265000
A5 IS currency = 145000
A6 IS currency = 980000
A7 IS percentage = 12pct
A8 IS percentage = 8pct
A9 = FALSE
A10 = "clear"
A11 IS currency = A1 + A2 - A3 - A4 - A5

# External FX inputs
N1 = FX_RATE("EUR", "USD")
N2 = FX_RATE("GBP", "USD")

# Five-day cash ladder
B1 = 220000
B2 = 180000
B3 = 240000
B4 = 205000
B5 = 215000

C1 = 190000
C2 = 225000
C3 = 210000
C4 = 260000
C5 = 245000

D1 = B1 - C1
D2 = B2 - C2
D3 = B3 - C3
D4 = B4 - C4
D5 = B5 - C5

E1 = A11 + D1
E2 = E1 + D2
E3 = E2 + D3
E4 = E3 + D4
E5 = E4 + D5

F1 = MIN(E1:E5)
F2 = MAX(E1:E5)
F3 = ROUND(F1 / A11, 4)

# Funding sources: amount, haircut, local stressed value, fx factor, stressed_usd, cost_rate, annual_cost
G1 = 350000
G2 = 280000
G3 = 410000
G4 = 190000
G5 = 260000
G6 = 315000

H1 = 0.98
H2 = 0.95
H3 = 0.93
H4 = 0.88
H5 = 0.91
H6 = 0.85

I1 = ROUND(G1 * H1, 2)
I2 = ROUND(G2 * H2, 2)
I3 = ROUND(G3 * H3, 2)
I4 = ROUND(G4 * H4, 2)
I5 = ROUND(G5 * H5, 2)
I6 = ROUND(G6 * H6, 2)
I7 = ROUND(SUM(I1:I6), 2)
I8 = ROUND(SUM(G1:G6), 2)
I9 = ROUND(I7 / I8, 4)

J1 = 1
J2 = 1
J3 = N1 DEFAULT 1.08
J4 = N1 DEFAULT 1.08
J5 = N2 DEFAULT 1.25
J6 = 1

K1 = ROUND(I1 * J1, 2)
K2 = ROUND(I2 * J2, 2)
K3 = ROUND(I3 * J3, 2)
K4 = ROUND(I4 * J4, 2)
K5 = ROUND(I5 * J5, 2)
K6 = ROUND(I6 * J6, 2)
K7 = ROUND(SUM(K1:K6), 2)

L1 = 0.041
L2 = 0.045
L3 = 0.052
L4 = 0.057
L5 = 0.061
L6 = 0.049

M1 = ROUND(K1 * L1, 2)
M2 = ROUND(K2 * L2, 2)
M3 = ROUND(K3 * L3, 2)
M4 = ROUND(K4 * L4, 2)
M5 = ROUND(K5 * L5, 2)
M6 = ROUND(K6 * L6, 2)
M7 = ROUND(SUM(M1:M6), 2)
M8 = ROUND(M7 / K7, 6)

# Coverage stress: mild, base, severe
N3 = ROUND(K7 * 0.97, 2)
N4 = ROUND(K7 * 0.92, 2)
N5 = ROUND(K7 * 0.85, 2)

O1 = ROUND((A11 + N3) / A6, 4)
O2 = ROUND((A11 + N4) / A6, 4)
O3 = ROUND((A11 + N5) / A6, 4)
O4 = MIN(O1:O3)
O5 = MAX(O1:O3)

# Summary classifications
P1 = F3 < (1 - A7) THEN "runway-at-risk" ELSE "runway-stable"
P2 = I9 < (1 - A8) THEN "haircut-heavy" ELSE "funding-healthy"
P3 = M8 > 0.055 THEN "expensive-funding" ELSE "contained-funding"
P4 = O4 < 1.15 THEN "coverage-tight" ELSE "coverage-comfortable"
P5 = A9 THEN "manual-freeze" ELSE A10 = "degraded" THEN "degraded-mode" ELSE "normal-ops"
P6 = `coverage={O4} cost={M8} runway={P1}`

# Reactive rules
WHEN F3 < (1 - A7) OR I9 < (1 - A8) THEN
  Q1 = "liquidity-escalation"
  Q2 = NOW()
  Q3:Q5 = ROW_INDEX
END

WHEN A9 = TRUE OR A10 = "degraded" THEN
  R1 = "freeze-nonessential-payments"
  R2 = NOW()
END

WHEN M8 > 0.055 AND O4 < 1.15 THEN
  S1 = "rebalance-funding"
  S2 = NOW()
END

EVERY duration"PT15M" SKIP MISSED THEN
  T1 = T1 + 1
  T2 = NOW()
END

EVERY cron"0 * * * *" BACKFILL THEN
  T3 = T3 + 1
  T4 = "hourly-liquidity-pack"
END

AT dt"2026-12-31T23:59:00Z" BACKFILL THEN
  T5 = TRUE
  T6 = "year-end-close"
END

END MODEL