> 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/interest-and-settlement.md).

# Interest, repayment and settlement

Simple interest per second on every slice, the three-day minimum, and what a full or partial call to repay does to the slices, the collateral and the fee.

## What the borrower owes

Debt on a Gimbal loan is the sum of two figures across every slice: principal outstanding and interest accrued so far. `debtOf(loanId)` returns both, projected to the current second without writing storage. Each slice's rate was fixed when it was minted and nothing can move it afterwards: no utilisation curve, no compounding, no later adjustment. Slices at different APRs accrue separately.

## The accrual formula

The `Accrual` library computes linear interest:

```
interest = principal × aprBps × elapsed / (10_000 × 31_536_000)
```

`elapsed` runs in seconds from the slice's `lastAccrual` stamp to `block.timestamp`, and a year is 365 days. The product is formed before the division, so rounding happens once, downward. Block numbers are never used as a clock: on Arbitrum-stack chains they track L1 blocks, not local time.

## The minimum interest period

Each slice records a `minInterest` figure at minting: the interest its principal would earn at its APR over the policy's `minInterestPeriod`, set to 3 days. Interest owed is the larger of booked interest and that floor, less anything already paid. Repaying on day one is allowed, but the lender still collects three days of interest. The floor keeps standing offers from working as free intraday liquidity, and gives lenders a reason to leave them open.

## One repayment function

`repay(loanId, amount)` handles partial and full repayment alike. The desk accrues every slice, works out the total owed, and clamps `amount` to it, so sending more than the debt never overpays. Exactly the clamped amount is pulled from the caller in USDG and applied to interest before principal.

Repayment is accepted while a loan is Active or Defaulted: the whole term, the grace window after maturity and the time after a failed rollover. It is refused while a rollover or collateral auction is running, and once the loan has closed. See [Every state a loan can hold](/mechanics/loan-states.md).

No pause reaches `repay`. The guardian's flags stop originations and liquidations only.

### When the payment clears the debt

1. Interest is split across slices by each slice's share of interest owed, and principal by each slice's share of principal outstanding.
2. Each lender receives principal plus interest, less the protocol's 10% interest share, which is sent to the Treasury.
3. Every slice token is burned and the slice record deleted.
4. The status becomes Repaid and the whole escrow goes back to the borrower.
5. The desk emits `LoanRepaid(loanId, interest, principal)`.

A lender whose slice carries the park flag is paid back into the vault, not a wallet; see [Capital parked between fills](/mechanics/parked-capital.md).

### When it does not

A smaller payment clears interest first, then principal, allocated across slices in the same proportions. Collateral stays in escrow. Debt has fallen and collateral has not, so LTV drops and the health factor rises. The event is `LoanPartiallyRepaid(loanId, interest, principal)`. Together with `addCollateral`, this is one of the two moves open to a borrower once the health factor warning fires.

## Repaying through the L1 inbox

If the sequencer stops or censors, `repay` can be sent via the L1 delayed inbox on Arbitrum, where it is force-included after 24 hours. The one-hour liquidation grace after an outage makes that route practical. See [When the sequencer stops](/risk/sequencer.md).

## Worked example

A 20,000 USDG loan funded by three slices is repaid in full on day 30.

| Slice | APR   | Principal | 30-day interest |
| ----- | ----- | --------- | --------------- |
| 1     | 8.50% | 5,000     | 34.93           |
| 2     | 8.90% | 10,000    | 73.15           |
| 3     | 9.00% | 5,000     | 36.99           |
| All   |       | 20,000    | 145.07          |

The borrower sends 20,145.07 USDG. The Treasury's 10% share of interest comes to 14.51 USDG. Lender 1 receives 5,031.44, lender 2 receives 10,065.83 and lender 3 receives 5,033.29: principal plus 90% of what their own slice earned. The collateral leaves escrow in the same call.


---

# 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/interest-and-settlement.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.
