| 1 | { |
| 2 | "_readme": "Pinned vectors for the funding waterfall (docs/funding.md § The waterfall). Amounts are integer cents. These are the spec, not snapshots: if tools/waterfall.mjs disagrees, fix the implementation (or version the algorithm), never the vector. Run: node test/waterfall.test.mjs", |
| 3 | "vectors": [ |
| 4 | { |
| 5 | "name": "doc worked example — €40k revenue quarter over Series 1", |
| 6 | "ledger": { |
| 7 | "series": [{ "id": "S1", "closedAt": "2026-09-30", "capMultiple": 2, "seasoningMonths": 24 }], |
| 8 | "notes": [ |
| 9 | { "id": "S1-001", "series": "S1", "principal": 20000000, "remainingCap": 40000000 }, |
| 10 | { "id": "S1-002", "series": "S1", "principal": 10000000, "remainingCap": 20000000 } |
| 11 | ], |
| 12 | "quarters": [ |
| 13 | { "id": "2028-Q2", "floorMet": true }, |
| 14 | { "id": "2028-Q3", "floorMet": true } |
| 15 | ] |
| 16 | }, |
| 17 | "quarter": { "id": "2028-Q4", "asOf": "2028-12-31", "revenue": 4000000, "costs": 2800000, "reserveTopUp": 400000, "floorMet": true }, |
| 18 | "expected": { |
| 19 | "distributable": 800000, |
| 20 | "distributed": true, |
| 21 | "investorPool": 480000, |
| 22 | "teamPool": 200000, |
| 23 | "commonsPool": 120000, |
| 24 | "payments": [ |
| 25 | { "note": "S1-001", "amount": 320000 }, |
| 26 | { "note": "S1-002", "amount": 160000 } |
| 27 | ], |
| 28 | "retained": 0, |
| 29 | "residue": 0, |
| 30 | "extinguished": [], |
| 31 | "notes": [ |
| 32 | { "id": "S1-001", "remainingCap": 39680000 }, |
| 33 | { "id": "S1-002", "remainingCap": 19840000 } |
| 34 | ] |
| 35 | } |
| 36 | }, |
| 37 | { |
| 38 | "name": "negative surplus distributes nothing", |
| 39 | "ledger": { |
| 40 | "series": [{ "id": "S1", "closedAt": "2026-09-30", "capMultiple": 2, "seasoningMonths": 24 }], |
| 41 | "notes": [{ "id": "S1-001", "series": "S1", "principal": 20000000, "remainingCap": 40000000 }], |
| 42 | "quarters": [ |
| 43 | { "id": "2028-Q2", "floorMet": true }, |
| 44 | { "id": "2028-Q3", "floorMet": true } |
| 45 | ] |
| 46 | }, |
| 47 | "quarter": { "id": "2028-Q4", "asOf": "2028-12-31", "revenue": 1000000, "costs": 2800000, "reserveTopUp": 0, "floorMet": false }, |
| 48 | "expected": { |
| 49 | "distributable": -1800000, |
| 50 | "distributed": false, |
| 51 | "investorPool": 0, |
| 52 | "teamPool": 0, |
| 53 | "commonsPool": 0, |
| 54 | "payments": [], |
| 55 | "retained": 0, |
| 56 | "residue": 0, |
| 57 | "extinguished": [], |
| 58 | "notes": [{ "id": "S1-001", "remainingCap": 40000000 }] |
| 59 | } |
| 60 | }, |
| 61 | { |
| 62 | "name": "zero surplus distributes nothing", |
| 63 | "ledger": { |
| 64 | "series": [{ "id": "S1", "closedAt": "2026-09-30", "capMultiple": 2, "seasoningMonths": 24 }], |
| 65 | "notes": [{ "id": "S1-001", "series": "S1", "principal": 20000000, "remainingCap": 40000000 }], |
| 66 | "quarters": [ |
| 67 | { "id": "2028-Q2", "floorMet": true }, |
| 68 | { "id": "2028-Q3", "floorMet": true } |
| 69 | ] |
| 70 | }, |
| 71 | "quarter": { "id": "2028-Q4", "asOf": "2028-12-31", "revenue": 2800000, "costs": 2800000, "reserveTopUp": 0, "floorMet": true }, |
| 72 | "expected": { |
| 73 | "distributable": 0, |
| 74 | "distributed": false, |
| 75 | "payments": [], |
| 76 | "retained": 0, |
| 77 | "residue": 0 |
| 78 | } |
| 79 | }, |
| 80 | { |
| 81 | "name": "rounding cents land with the commons", |
| 82 | "ledger": { |
| 83 | "series": [{ "id": "S1", "closedAt": "2026-09-30", "capMultiple": 2, "seasoningMonths": 24 }], |
| 84 | "notes": [{ "id": "S1-001", "series": "S1", "principal": 20000000, "remainingCap": 40000000 }], |
| 85 | "quarters": [ |
| 86 | { "id": "2028-Q2", "floorMet": true }, |
| 87 | { "id": "2028-Q3", "floorMet": true } |
| 88 | ] |
| 89 | }, |
| 90 | "quarter": { "id": "2028-Q4", "asOf": "2028-12-31", "revenue": 10001, "costs": 0, "reserveTopUp": 0, "floorMet": true }, |
| 91 | "expected": { |
| 92 | "distributable": 10001, |
| 93 | "distributed": true, |
| 94 | "investorPool": 6000, |
| 95 | "teamPool": 2500, |
| 96 | "commonsPool": 1501, |
| 97 | "payments": [{ "note": "S1-001", "amount": 6000 }], |
| 98 | "retained": 0, |
| 99 | "residue": 0 |
| 100 | } |
| 101 | }, |
| 102 | { |
| 103 | "name": "remainder cents are deterministic — largest remainder, then note id", |
| 104 | "ledger": { |
| 105 | "series": [{ "id": "S1", "closedAt": "2026-09-30", "capMultiple": 2, "seasoningMonths": 24 }], |
| 106 | "notes": [ |
| 107 | { "id": "n-a", "series": "S1", "principal": 500, "remainingCap": 1000 }, |
| 108 | { "id": "n-b", "series": "S1", "principal": 500, "remainingCap": 1000 }, |
| 109 | { "id": "n-c", "series": "S1", "principal": 500, "remainingCap": 1000 } |
| 110 | ], |
| 111 | "quarters": [ |
| 112 | { "id": "2028-Q2", "floorMet": true }, |
| 113 | { "id": "2028-Q3", "floorMet": true } |
| 114 | ] |
| 115 | }, |
| 116 | "quarter": { "id": "2028-Q4", "asOf": "2028-12-31", "revenue": 167, "costs": 0, "reserveTopUp": 0, "floorMet": true }, |
| 117 | "expected": { |
| 118 | "distributable": 167, |
| 119 | "distributed": true, |
| 120 | "investorPool": 100, |
| 121 | "teamPool": 41, |
| 122 | "commonsPool": 26, |
| 123 | "payments": [ |
| 124 | { "note": "n-a", "amount": 34 }, |
| 125 | { "note": "n-b", "amount": 33 }, |
| 126 | { "note": "n-c", "amount": 33 } |
| 127 | ], |
| 128 | "retained": 0, |
| 129 | "residue": 0, |
| 130 | "notes": [ |
| 131 | { "id": "n-a", "remainingCap": 966 }, |
| 132 | { "id": "n-b", "remainingCap": 967 }, |
| 133 | { "id": "n-c", "remainingCap": 967 } |
| 134 | ] |
| 135 | } |
| 136 | }, |
| 137 | { |
| 138 | "name": "unseasoned series is excluded from the pro-rata", |
| 139 | "ledger": { |
| 140 | "series": [ |
| 141 | { "id": "S1", "closedAt": "2026-09-30", "capMultiple": 2, "seasoningMonths": 24 }, |
| 142 | { "id": "S2", "closedAt": "2028-06-30", "capMultiple": 2, "seasoningMonths": 24 } |
| 143 | ], |
| 144 | "notes": [ |
| 145 | { "id": "S1-001", "series": "S1", "principal": 20000000, "remainingCap": 40000000 }, |
| 146 | { "id": "S2-001", "series": "S2", "principal": 10000000, "remainingCap": 20000000 } |
| 147 | ], |
| 148 | "quarters": [ |
| 149 | { "id": "2028-Q2", "floorMet": true }, |
| 150 | { "id": "2028-Q3", "floorMet": true } |
| 151 | ] |
| 152 | }, |
| 153 | "quarter": { "id": "2028-Q4", "asOf": "2028-12-31", "revenue": 4000000, "costs": 2800000, "reserveTopUp": 400000, "floorMet": true }, |
| 154 | "expected": { |
| 155 | "distributed": true, |
| 156 | "investorPool": 480000, |
| 157 | "payments": [{ "note": "S1-001", "amount": 480000 }], |
| 158 | "retained": 0, |
| 159 | "notes": [ |
| 160 | { "id": "S1-001", "remainingCap": 39520000 }, |
| 161 | { "id": "S2-001", "remainingCap": 20000000 } |
| 162 | ] |
| 163 | } |
| 164 | }, |
| 165 | { |
| 166 | "name": "no seasoned notes — investor pool retained, team and commons still flow", |
| 167 | "ledger": { |
| 168 | "series": [{ "id": "S2", "closedAt": "2028-06-30", "capMultiple": 2, "seasoningMonths": 24 }], |
| 169 | "notes": [{ "id": "S2-001", "series": "S2", "principal": 10000000, "remainingCap": 20000000 }], |
| 170 | "quarters": [ |
| 171 | { "id": "2028-Q2", "floorMet": true }, |
| 172 | { "id": "2028-Q3", "floorMet": true } |
| 173 | ] |
| 174 | }, |
| 175 | "quarter": { "id": "2028-Q4", "asOf": "2028-12-31", "revenue": 4000000, "costs": 2800000, "reserveTopUp": 400000, "floorMet": true }, |
| 176 | "expected": { |
| 177 | "distributed": true, |
| 178 | "investorPool": 480000, |
| 179 | "teamPool": 200000, |
| 180 | "commonsPool": 120000, |
| 181 | "payments": [], |
| 182 | "retained": 480000, |
| 183 | "notes": [{ "id": "S2-001", "remainingCap": 20000000 }] |
| 184 | } |
| 185 | }, |
| 186 | { |
| 187 | "name": "a broken floor streak gates seasoning even when the calendar has passed", |
| 188 | "ledger": { |
| 189 | "series": [{ "id": "S1", "closedAt": "2026-09-30", "capMultiple": 2, "seasoningMonths": 24 }], |
| 190 | "notes": [{ "id": "S1-001", "series": "S1", "principal": 20000000, "remainingCap": 40000000 }], |
| 191 | "quarters": [ |
| 192 | { "id": "2028-Q2", "floorMet": true }, |
| 193 | { "id": "2028-Q3", "floorMet": false } |
| 194 | ] |
| 195 | }, |
| 196 | "quarter": { "id": "2028-Q4", "asOf": "2028-12-31", "revenue": 4000000, "costs": 2800000, "reserveTopUp": 400000, "floorMet": true }, |
| 197 | "expected": { |
| 198 | "distributed": true, |
| 199 | "investorPool": 480000, |
| 200 | "payments": [], |
| 201 | "retained": 480000 |
| 202 | } |
| 203 | }, |
| 204 | { |
| 205 | "name": "pool beyond every cap — notes fill, extinguish, and the excess is residue", |
| 206 | "ledger": { |
| 207 | "series": [{ "id": "S1", "closedAt": "2026-09-30", "capMultiple": 2, "seasoningMonths": 24 }], |
| 208 | "notes": [ |
| 209 | { "id": "S1-001", "series": "S1", "principal": 100000, "remainingCap": 200000 }, |
| 210 | { "id": "S1-002", "series": "S1", "principal": 50000, "remainingCap": 100000 } |
| 211 | ], |
| 212 | "quarters": [ |
| 213 | { "id": "2028-Q2", "floorMet": true }, |
| 214 | { "id": "2028-Q3", "floorMet": true } |
| 215 | ] |
| 216 | }, |
| 217 | "quarter": { "id": "2028-Q4", "asOf": "2028-12-31", "revenue": 4000000, "costs": 2800000, "reserveTopUp": 400000, "floorMet": true }, |
| 218 | "expected": { |
| 219 | "distributed": true, |
| 220 | "investorPool": 480000, |
| 221 | "payments": [ |
| 222 | { "note": "S1-001", "amount": 200000 }, |
| 223 | { "note": "S1-002", "amount": 100000 } |
| 224 | ], |
| 225 | "retained": 0, |
| 226 | "residue": 180000, |
| 227 | "extinguished": ["S1-001", "S1-002"], |
| 228 | "notes": [ |
| 229 | { "id": "S1-001", "remainingCap": 0 }, |
| 230 | { "id": "S1-002", "remainingCap": 0 } |
| 231 | ] |
| 232 | } |
| 233 | }, |
| 234 | { |
| 235 | "name": "seasoning boundary — one day short of 24 months is unseasoned", |
| 236 | "ledger": { |
| 237 | "series": [{ "id": "S1", "closedAt": "2026-09-30", "capMultiple": 2, "seasoningMonths": 24 }], |
| 238 | "notes": [{ "id": "S1-001", "series": "S1", "principal": 20000000, "remainingCap": 40000000 }], |
| 239 | "quarters": [ |
| 240 | { "id": "2028-Q1", "floorMet": true }, |
| 241 | { "id": "2028-Q2", "floorMet": true } |
| 242 | ] |
| 243 | }, |
| 244 | "quarter": { "id": "2028-Q3", "asOf": "2028-09-29", "revenue": 4000000, "costs": 2800000, "reserveTopUp": 400000, "floorMet": true }, |
| 245 | "expected": { |
| 246 | "distributed": true, |
| 247 | "payments": [], |
| 248 | "retained": 480000 |
| 249 | } |
| 250 | }, |
| 251 | { |
| 252 | "name": "seasoning boundary — exactly 24 months is seasoned", |
| 253 | "ledger": { |
| 254 | "series": [{ "id": "S1", "closedAt": "2026-09-30", "capMultiple": 2, "seasoningMonths": 24 }], |
| 255 | "notes": [{ "id": "S1-001", "series": "S1", "principal": 20000000, "remainingCap": 40000000 }], |
| 256 | "quarters": [ |
| 257 | { "id": "2028-Q1", "floorMet": true }, |
| 258 | { "id": "2028-Q2", "floorMet": true } |
| 259 | ] |
| 260 | }, |
| 261 | "quarter": { "id": "2028-Q3", "asOf": "2028-09-30", "revenue": 4000000, "costs": 2800000, "reserveTopUp": 400000, "floorMet": true }, |
| 262 | "expected": { |
| 263 | "distributed": true, |
| 264 | "payments": [{ "note": "S1-001", "amount": 480000 }], |
| 265 | "retained": 0 |
| 266 | } |
| 267 | } |
| 268 | ] |
| 269 | } |
| 270 | |