# Payment Waterfall Checker

A matching total is not enough.

- Author: [Konstantinos Toulis](https://ktoulis.com/#about)
- Role: Business Technology & AI Solutions Architect
- Category: AI & intelligence; Data & decisions
- Project type: Fintech prototype, source-available
- Canonical page: https://ktoulis.com/work/payment-waterfall.html

## Overview

Fin Waterfall checks payments on asset-backed securities against payment rules that a reviewer has approved. AI drafts each rule from the contract, a person approves it, and deterministic code calculates who should be paid what.

## The business challenge

When a securitisation pays its investors, the contract sets who is paid first. A payment run can pay the right total to the wrong tranche, and neither a check of the total nor a match against past reports will notice.

## The connected solution

An analyst selects the clause of the contract that governs the payment. A language model proposes a structured rule and cites the source paragraph for each step. A reviewer compares the draft with the source and approves that exact draft; the approval stores a SHA-256 digest of the rule, so any change needs a new approval. A Python engine then applies the approved rule in integer cents: the model calculates no payouts. Each review returns PASS, BLOCK or HOLD with the difference for each tranche, and completed reviews can be downloaded as PDF reports. In the bundled stress case, a synthetic one built on a real auto-loan indenture filed with the SEC, $50,000 of cash must go to senior Class A principal, but a faulty payment model pays the same $50,000 as Class B interest. The totals match, and the tool returns BLOCK. The same faulty model matches all 70 class-level amounts in five filed monthly reports, because no first-priority principal was due in those months; a search over synthetic cash amounts finds the error from the first cent. A second example is retrospective: it checks a June 2006 distribution of a mortgage-loan trust against the figure in the later amended filing and finds the $55,861.12 shortfall, which the trust paid afterwards.

## The workflow

1. Select the clause
2. AI drafts the rule
3. A reviewer approves
4. Code checks the payment

The workflow is an illustration. Project scope and limitations are described below.

## Built with / focus areas

- Python
- Qwen on llama.cpp
- Gemini on Vertex AI
- PostgreSQL
- ReportLab

## Focus

- Source available
- Structured finance
- Human-approved AI rules
- Deterministic checks

## Scope and disclosure

The code is public to read, but the repository has no licence yet, so it is source-available, not open source. It is a prototype: there is no public hosted demo and no customer use is claimed. A local Qwen model has drafted both example rules; the hosted edition’s drafting with Gemini is so far tested only against a fake Vertex AI service. In the stress case the cash and the principal due are hypothetical, on a real indenture. The 2006 example uses a figure that became available after the distribution, so it shows what a later check finds, not what could have been caught on the day. Amounts due come from the statement: the tool does not calculate interest, fees or principal formulas, and its search and stress tests cover two single-clause rules only. A PASS means agreement within the tested scope, not legal or investment advice.

## Explore further

- [Explore the source](https://github.com/toul10/fin-waterfall)

## Contact

[Discuss a similar project by email](mailto:kt@ktoulis.com).

[All selected work](https://ktoulis.com/#work) · [Professional profile](https://ktoulis.com/index.md)
