# SigmaFi

> What SigmaFi bonds are, who does what in a loan, and where to read next as a borrower, lender, trader or developer.

Source: https://lithosprotocol.org/docs/sigmafi/overview

**Level:** Standard

*For anyone who wants to borrow, lend or trade on SigmaFi. No Ergo experience needed for this page.*

SigmaFi is a set of peer-to-peer lending contracts on Ergo. A borrower locks collateral and asks for a
loan, a lender funds it, and the loan becomes a **bond**: a token the lender holds, can sell, or can split
into shares. No company stands between the two sides. The contracts hold the collateral and decide who
gets paid.

This page explains the idea and the words used everywhere else. It does not cover how to take each
action, which is on the pages under [Next steps](#next-steps). The contracts behind SigmaFi are called
the **ZC Standard**, and the rules clients follow on top of them are called **zcs1**.

## What a SigmaFi loan is

Every SigmaFi loan is a **zero-coupon bond**. The borrower receives the **principal** now and pays back
one fixed **repayment** by the **maturity**, a block height. Nothing is paid in between. The lender
earns the difference between the two amounts.

A loan is lent and repaid in one currency, its **market**. Two markets exist:

| Market | You borrow and repay in | Example |
|---|---|---|
| ERG | ERG | Borrow 100 ERG now, repay 105 ERG in about 60 days |
| SigUSD | SigUSD, the SigmaUSD stablecoin | Borrow 500 SigUSD now, repay 520 SigUSD in about 90 days |

**Collateral** can be ERG and up to 30 kinds of token. The collateral stays locked until the loan is
repaid or **liquidated**. A liquidation sends the collateral to whoever holds the bond.

## Who does what

The following roles appear in every SigmaFi page:

| Role | What they do |
|---|---|
| Borrower | Posts an **order** with collateral and terms. Repays, adds collateral, or closes the loan early |
| Lender | Funds an order directly, or posts a **lend offer** that buys loans automatically at the yields it names |
| Holder | Whoever holds the bond token or its shares now. Claims the money when the loan ends |
| Seller and buyer | Trade bonds and shares through **asks** before the loan ends |
| Batcher | Anyone running software that performs work the contracts leave open, such as matching offers, liquidating due loans and returning expired orders. A batcher earns the fee the user committed for that work |

Every Lithos client is a batcher by default. You never need to stay online after posting: a batcher
finishes every step for the fee you set when you posted.

## The life of a loan

A loan moves through the following steps:

1. **Order.** The borrower locks collateral and names the principal, repayment, maturity and
   liquidation rule. The order waits until a lender fills it or it expires.
2. **Fill.** A lender pays the principal to the borrower. The fill creates the bond and three units of
   a new **bond token**. Two units stay locked with the bond. The lender receives the third, the
   **circulating unit**.
3. **Live bond.** Until maturity the borrower can repay, add collateral, or close the loan early by
   holding the circulating unit. The holder can sell the unit or split it into 100 shares.
4. **Settlement.** The bond ends one of two ways. It is **repaid**: the repayment goes to a vault and
   the collateral back to the borrower. Or it is **liquidated**: the collateral goes to the vault.
5. **Claim.** Whoever holds the circulating unit, or its shares, claims the vault.

The circulating unit is the claim itself. Whoever holds it at settlement is paid, so selling the unit
sells the loan.

## How liquidation works

A loan has one of two **liquidation rules**, chosen by the borrower:

| Rule | When anyone may liquidate |
|---|---|
| Maturity | From maturity on, if the loan has not been repaid |
| Oracle | From maturity on, and also before it whenever the collateral's value falls below the borrower's chosen **collateral ratio** of the repayment, measured with the ERG/USD oracle |

A liquidation always sends **all** the collateral to the holder, however much it is worth. As a
borrower, choose a ratio and collateral that leave room for the price to move, and repay before
maturity.

## Reading a yield

SigmaFi quotes every rate as a **simple yield per 262,800 blocks**, which is about one year at Ergo's
2-minute block time. A bond paying 105 for 100 with half a year left is a 10% yield:
`(105 / 100 - 1) × 262,800 / 131,400`.

A yield is a return over blocks, not over calendar days, and it is never compounded. It assumes the
loan is repaid in full. It is not a guarantee: a liquidated loan pays the collateral instead.

## Where you can use SigmaFi

SigmaFi runs on Ergo mainnet. You can reach it in the following ways:

- **The Lithos web panel.** Every Lithos client serves a SigmaFi panel under **Extensions > SigmaFi**,
  signing with the client's own wallet. See [The Lithos client and panel](https://lithosprotocol.org/docs/extensions/sigmafi-bonds).
- **The Lithos API.** Every action in the panel is an API call you can script. See
  [Building on the Lithos API](https://lithosprotocol.org/docs/sigmafi/api).
- **Other clients.** The contracts are open, so any client that follows the
  [zcs1 off-chain standard](https://lithosprotocol.org/docs/sigmafi/offchain-standard) works with the same orders, offers and bonds.

## Safety in brief

The following facts matter more than any other on these pages:

- **Check the token, not its name.** Anyone can mint a token named like a bond. A genuine bond token is
  proven by the chain, and the Lithos panel shows that proof for every listing.
- **A liquidation takes all the collateral.** Over-collateralize, and watch an oracle loan's cover.
- **Repay before maturity.** From the maturity height on, anyone may liquidate an unpaid loan.
- **Fees are committed up front.** Each order, offer and ask carries the fees that pay batchers to
  finish it. Your client shows every fee before you sign.

## Next steps

- [Borrowing](https://lithosprotocol.org/docs/sigmafi/borrowing): posting an order, repaying, adding collateral and closing a loan early.
- [Lending](https://lithosprotocol.org/docs/sigmafi/lending): filling an order, standing lend offers, and claiming when a loan ends.
- [Trading bonds and shares](https://lithosprotocol.org/docs/sigmafi/trading): asks, shares, auctions and wraps.
- [The Lithos client and panel](https://lithosprotocol.org/docs/extensions/sigmafi-bonds): the SigmaFi panel, batching and arbitrage on your client.
- [Contracts](https://lithosprotocol.org/docs/sigmafi/contracts), [the zcs1 off-chain standard](https://lithosprotocol.org/docs/sigmafi/offchain-standard) and [pricing](https://lithosprotocol.org/docs/sigmafi/pricing): the reference for developers.
