> For the complete documentation index, see [llms.txt](https://docs.usegimbal.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.usegimbal.app/mechanics/maturity-and-rollover.md).

# Maturity, grace and rollover

What happens at the end of a fixed term: the 24-hour grace window, the rising-rate rollover auction opened with openRefinance, and the default that follows a rollover nobody funds.

Fixed terms end, and under most designs a borrower with sound collateral but no cash on the day loses a healthy position. Gimbal offers two routes: a grace window after maturity, and a rollover auction before it. The auction, in the Blend pattern, prices one thing only, a rate, so no price feed, keeper's judgement or governance vote is involved. If no lender wants the position at any rate below the cap, the market has spoken and the loan goes to liquidation.

## Ahead of maturity: the rollover auction

### Opening

The borrower calls `openRefinance(loanId)` on `RolloverAuction`. The desk requires the caller to be the borrower, the loan to be Active, and `maturity` to lie in the future; a loan already inside its grace window cannot roll. The status becomes Refinancing and `RefinanceOpened` records the opening rate, the cap and the end time.

### The rate climbs

* The opening rate is the loan's blended APR: the principal-weighted average across its live slices.
* Over the window the rate rises in a straight line to the opening rate plus `capSpreadBps`. The defaults in `PolicyBoard` are a 400 basis point spread and a four-hour window.
* `currentRate(loanId)` reports the rate at any moment.

### Accepting

A lender funds part or all of the rollover with `accept(loanId, offer, signature)` and a signed lend offer. The offer's `aprBps` must be at or below the going rate, and the acceptance is booked at the going rate rather than the offer's, so lenders who commit at different moments hold different rates. The offer has to fit the loan: lend side, the loan's collateral token or its tier sentinel, the same loan token and term, a `maxLtvBps` at or above the loan's current LTV, and a `requestId` that is zero or the loan's rollover key. The maker needs a lender role.

The fill is the smaller of the offer's remaining capacity and the shortfall to target. Funds move on acceptance, from the maker's wallet or the parked vault for park-flagged offers, and sit in the auction contract until it clears or unwinds.

Any address may submit an offer, so a lender signs at the lowest rate they will take and lets a keeper or relayer submit it once the going rate gets there. Current lenders often roll their own slices this way.

### Clearing

`target(loanId)` is principal plus interest owed at that moment, plus the refinance fee of 0.10% of principal. Interest keeps accruing, so the target creeps upward through the window. When accepted funds reach it, the same `accept` call clears:

1. The auction sends the USDG to the desk and calls `clearRefinance`.
2. The outgoing slices are paid in full: principal, and interest less the 10% share. Their slice tokens are burned.
3. The fee, charged to the borrower, goes to the Treasury. See [Fees the protocol charges](/mechanics/fees.md).
4. The loan restarts with the same term length, counted from the clearing block; the new principal is the old debt with the fee added. The borrower's wallet is not touched for either.
5. New slice tokens are minted to the acceptors at their accepted rates.
6. The health factor is tested at the new principal. Below 1.0, the whole call reverts with `Unhealthy`.

Collateral stays in escrow throughout. `addCollateral` is allowed during the auction, to lift the health factor before that test; `repay` is not until the auction clears or is withdrawn.

### Failing and withdrawing

If the window ends short of the target, anyone may call `fail(loanId)`. Every acceptor is refunded, their offer capacity is restored, and the desk marks the loan Defaulted. A Defaulted loan can still be repaid and topped up, but its collateral may go to auction at any health factor.

The borrower can withdraw a running rollover with `cancelRefinance(loanId)` at any point before it clears, even after acceptances have arrived. Acceptors get their USDG back and the loan returns to Active on its original terms. A collateral auction opening mid-rollover cancels it the same way.

```mermaid
sequenceDiagram
  participant B as Borrower
  participant R as RolloverAuction
  participant D as TermDesk
  participant L0 as Current lenders
  participant L1 as Accepting lenders

  B->>R: openRefinance(loanId)
  Note over R: rate climbs from blended APR to cap over 4 h
  L1->>R: accept(loanId, offer, sig)
  R->>D: consumeOffer, USDG held by the auction
  Note over R: accepted >= debt + fee
  R->>D: clearRefinance(loanId, slices, term, fee)
  D-->>L0: principal + interest net of share, tokens burned
  D-->>L1: new slice tokens, new maturity
  Note over D: escrow untouched from start to finish
```

## After maturity: the grace window

When `block.timestamp` passes `maturity`, a 24-hour grace window (`graceWindow` in `PolicyBoard`) opens. Inside it:

* `repay` still works and still returns the collateral,
* every slice keeps accruing at its own APR,
* a health factor under 1.0 still opens a collateral auction, as before maturity.

After the window, an unpaid loan is past grace: its status stays Active, `isPastGrace(loanId)` on `CollateralAuction` returns true, and anyone may open an auction on it at any health factor. Repayment stays open until one does. [The collateral auction page](/mechanics/health-and-auctions.md) covers what follows.

## Worked example

Take a 20,000 USDG loan, blended rate 8.825%, three days to run. The borrower opens a rollover; the rate would reach 12.825% after four hours. About 35 minutes in, the going rate is 9.4%. One new lender and two of the existing ones accept, covering the target of 20,150.56 USDG: 20,000 principal, 130.56 of interest for 27 days, and a 20 USDG fee. The outgoing slices collect their 27 days' interest, three fresh slice tokens are minted at 9.4% with a new 30-day term on a principal of 20,150.56, and the collateral never left escrow.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.usegimbal.app/mechanics/maturity-and-rollover.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
