# Payments & EMI

Trilobyte uses an **Equated Monthly Instalment (EMI)** model for loan repayments. Each payment is a fixed amount calculated at disbursement, covering both principal and interest.

## EMI Calculation

The EMI is calculated using the standard amortisation formula:

$$
EMI = P \times \frac{r(1+r)^n}{(1+r)^n - 1}
$$

Where:

* $P$ = Principal (loan amount)
* $r$ = Monthly interest rate (annual rate ÷ 12)
* $n$ = Number of monthly payments (loan term)

{% hint style="info" %}
All math is **integer-only** — Soroban has no floating-point support. Trilobyte uses 10¹² internal precision scaling and ceiling-rounds the final EMI to ensure the borrower always repays at least the full amount owed.
{% endhint %}

## Payment Split

Each payment is split into two pools based on the vault's **split ratio**:

| Pool          | Purpose                                                 | Accessible By                |
| ------------- | ------------------------------------------------------- | ---------------------------- |
| **EMI Pool**  | Investor yield — proportional to split ratio (e.g. 80%) | Investors via `claim_yield`  |
| **Cash Pool** | Borrower operating capital — remainder (e.g. 20%)       | Borrower via `withdraw_cash` |

For example, with a split ratio of 80 and a payment of 10,000 USDC (after fees):

* **8,000 USDC** → EMI pool (investor yield)
* **2,000 USDC** → Cash pool (borrower operating capital)

## Payment Schedule

* Payments are due every **30 days** (30/360 day-count convention)
* The first payment is due 30 days after disbursement
* Each payment advances the `next_due` date by 30 days
* The total number of payments equals the loan term in months

## Principal Amortisation

Each EMI payment contains both an interest component and a principal component:

$$
\text{interest} = \text{outstanding} \times \frac{\text{annual\_rate}}{12}
$$

$$
\text{principal} = \text{EMI} - \text{interest}
$$

The outstanding principal decreases with each payment. Early payments are interest-heavy, while later payments are principal-heavy — standard amortisation behaviour.

## Protocol Fee

A **0.5% protocol fee** is deducted from every payment before the split:

1. Payment received (e.g. 10,000 USDC)
2. Protocol fee deducted (50 USDC → treasury)
3. Remainder split by ratio (9,950 USDC → EMI + Cash pools)

## Yield Claiming

Investors claim their share of the EMI pool proportionally:

$$
\text{claimable} = \frac{\text{balance}}{\text{total\_supply}} \times \text{emi\_pool} - \text{already\_claimed}
$$

* `balance` = Investor's debt token balance
* `total_supply` = Total debt token supply
* `emi_pool` = Total accumulated EMI pool
* `already_claimed` = Amount the investor has already claimed

Claims can be made at any time during the **Active** or **FullyRepaid** phases.

## Token Precision

All amounts use **7 decimal places** (Stellar standard). For example:

* 1 USDC = `10_000_000` (10⁷)
* 0.5% fee = `50_000` in 7-decimal format


---

# Agent Instructions: 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:

```
GET https://docs.trilobyte.finance/protocol-mechanics/payments-and-emi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
