Sub topic 9
Optional repayment and the cash sweep
This chapter covers voluntary prepayment of debt and the cash sweep that automates it. It assumes you can build a balance roll-forward, calculate interest on opening and average balances, and have a mandatory repayment schedule and a cash available for debt repayment (CADR) line, which the previous chapters cover.
What a cash sweep is
Mandatory repayment is the amount the lender requires each period. Optional repayment is any extra principal the borrower pays early. A cash sweep is a rule that sends a fixed share of surplus cash to optional repayment. Many credit agreements require this, often 50% to 100% of excess cash flow. In other models the sweep is a modeling choice that assumes management uses spare cash to cut debt.
Three things decide the sweep amount each period:
- How much cash is left after mandatory repayment and after holding the minimum cash balance.
- The sweep percentage.
- The balance still outstanding on the tranche.
The sweep can never exceed the balance, and it can never be negative. A negative number means a cash shortfall, and the revolver covers that, not the sweep.
The waterfall position of the sweep
The sweep sits after mandatory repayment in the cash waterfall. Order matters because mandatory payments are contractual and the sweep is not.
| Step | Item | Example |
|---|---|---|
| 1 | Opening cash | 40 |
| 2 | Plus: cash flow before debt service (after interest and tax) | 90 |
| 3 | Less: mandatory repayment | (25) |
| 4 | Less: minimum cash balance | (20) |
| 5 | Cash available for sweep | 85 |
| 6 | Sweep percentage | 100% |
| 7 | Sweep, capped at balance after mandatory repayment | min(85, 120) = 85 |
The cap in step 7 uses the balance after mandatory repayment, not the opening balance. If you cap at the opening balance, the model can repay more than remains once the scheduled payment has been made, and the closing balance goes negative.
The core formula
For a single term loan, the sweep in period t is:
sweep = MAX(0, MIN(sweep % × cash available for sweep, balance after mandatory repayment))
The closing balance is then:
closing = opening − mandatory − sweep
In a spreadsheet, write the MAX and MIN explicitly. Do not rely on the numbers to behave. A loan that is fully repaid in year 3 must show zero sweep in years 4 and 5, and the MIN against the remaining balance guarantees that.
Sweep percentage and what is left over
With a sweep of less than 100%, the unswept cash stays on the balance sheet. That cash raises next period's opening cash, so it is available again next period, where the sweep rule applies to it a second time. This is correct if the sweep is defined on total available cash. It overstates repayment if the contract defines the sweep on that period's excess cash flow only. Check which definition the credit agreement uses. If it uses excess cash flow, base the sweep on the period's cash flow after mandatory repayment, not on the cash stock including opening cash.
Sweeping with a revolver in the model
When a model has a revolver and a term loan, the revolver comes first. A drawn revolver is usually the most expensive and most flexible debt to hold, and the borrower repays it before prepaying a term loan. So surplus cash is applied in this order:
- Repay the revolver, up to its drawn balance.
- Apply the sweep percentage to what remains and prepay the term loan.
The revolver code from the previous chapter already handles step 1. The remainder passes to the sweep.
def waterfall(cash_open, cash_flow, mandatory, min_cash,
rev_open, commitment, tl_open, sweep_pct):
# tl_open is the term loan balance before this period's mandatory repayment
tl_after_mandatory = tl_open - mandatory
surplus = cash_open + cash_flow - mandatory - min_cash
if surplus < 0:
rev_change = min(-surplus, commitment - rev_open) # draw
else:
rev_change = -min(surplus, rev_open) # repay
surplus_after_rev = surplus + rev_change # zero after a draw
sweep = max(0.0, min(sweep_pct * surplus_after_rev, tl_after_mandatory))
rev_close = rev_open + rev_change
tl_close = tl_after_mandatory - sweep
cash_close = cash_open + cash_flow - mandatory + rev_change - sweep
return rev_close, tl_close, sweep, cash_close
# Surplus of 85, revolver drawn 30, term loan 145 before mandatory repayment of 25
print(waterfall(40, 90, 25, 20, 30, 100, 145, 1.0))
# (0, 65.0, 55.0, 20.0)Here the surplus of 85 first clears the 30 revolver balance. The remaining 55 sweeps the term loan from 120 to 65. Closing cash lands exactly on the 20 minimum. With a sweep percentage of 1.0, cash always ends at the minimum while debt remains.
When surplus is negative, rev_change is a draw and surplus_after_rev is zero (or still negative if the commitment is exhausted). The max(0.0, ...) then forces the sweep to zero. If the commitment is exhausted, closing cash falls below the minimum. Your model should flag that as a liquidity problem, not hide it.
Interest and the circularity link
The sweep depends on cash flow after interest. Interest depends on the average balance, which depends on the closing balance, which depends on the sweep. That loop is the circularity covered in a later chapter. The Python example below shows the iteration used to resolve it.
def sweep_with_average_interest(open_bal, rate, cash_before_interest, tol=1e-9, max_iter=100):
interest = open_bal * rate # first guess uses the opening balance
close = open_bal
for _ in range(max_iter):
sweep = max(0.0, min(open_bal, cash_before_interest - interest))
close = open_bal - sweep
new_interest = rate * (open_bal + close) / 2
if abs(new_interest - interest) < tol:
interest = new_interest
break
interest = new_interest
return interest, close
interest, close = sweep_with_average_interest(100, 0.10, 30)
print(round(interest, 4), round(close, 4)) # 8.9474 78.9474You can check the answer by hand. The closing balance is 100 − (30 − I), and I = 0.10 × (100 + close) / 2. Substituting gives I = 0.05 × (270 + I) − ... which solves to I = 8.9474. The sweep is 30 − 8.9474 = 21.0526, so the closing balance is 78.9474.
Common errors
- Sweeping before mandatory repayment. This lets the sweep use cash that the contract has already assigned to the scheduled payment, and the two repayments together can exceed the balance.
- Capping against the opening balance. The closing balance goes negative when mandatory and sweep payments together exceed the opening balance.
- Ignoring the minimum cash balance. The sweep then drains cash to zero, and the revolver draws in the next period for no real reason.
- Applying the sweep to a negative surplus. Without MAX(0, ...), a shortfall becomes a negative repayment, which silently borrows more term debt.
- Sweeping the wrong tranche first. Senior and shorter-dated tranches are repaid first unless the agreement says otherwise. Multiple tranches are the subject of a later chapter.
- Forgetting that a sweep percentage below 100% re-sweeps retained cash. See the earlier section on what is left over.
Checks to build into the model
- The closing balance of each tranche is never negative.
- Sweep is zero once the balance reaches zero.
- Closing cash equals the minimum cash balance whenever the sweep percentage is 100% and debt remains.
- Closing cash on the balance sheet equals closing cash from the waterfall.
Exercise
A term loan opens the period at 200 with a mandatory repayment of 30. Opening cash is 25, cash flow before debt service is 110, the minimum cash balance is 20, the revolver is undrawn, and the sweep is 50%. What are the sweep, the closing term loan balance and the closing cash?
Show answer
Surplus = 25 + 110 − 30 − 20 = 85. The revolver is undrawn, so all 85 is available. Sweep = min(50% × 85, 200 − 30) = 42.5. Closing term loan = 200 − 30 − 42.5 = 127.5. Closing cash = 25 + 110 − 30 − 42.5 = 62.5, which is the 20 minimum plus the 42.5 of unswept surplus.
Exercise
Why must the sweep be capped at the balance after mandatory repayment and not at the opening balance?
Show answer
Mandatory repayment is paid first and reduces what is outstanding. If the cap used the opening balance, the sweep plus the mandatory payment could exceed the opening balance and push the closing balance below zero.