emj
shrx

Lesson 1 · ~10 min · Mission

What is being lent, and who moves what?

Before reading any wallet code, nail the economic story: two assets, two parties, one deadline.

Two assets, two roles

The protocol is peer-to-peer collateralized lending on Liquid. Docs illustrate USDT (loan asset) against LBTC (collateral), but any tokenized pair works.

RoleStarts withWants
BorrowerCollateral (asset A)Principal (asset B) now; collateral back later
LenderPrincipal (asset B)Interest/fee on asset B; collateral if borrower defaults

Terms are agreed before acceptance: collateral amount, principal amount, lending term (deadline), loan fee (fixed interest), optional origination fee, protocol fee share.

The lifecycle in plain language

  1. Propose — Borrower locks collateral and publishes terms. Offer is visible to lenders (via indexer / demo UI).
  2. Cancel — While still pending, borrower can abort and recover collateral.
  3. Accept — A lender sends principal; loan becomes active.
  4. Repay — Before the deadline, borrower returns principal + loan fee; collateral is released.
  5. Liquidate — After the deadline without full repayment, lender claims the collateral.

See the diagram in Offer state machine or try the live demo as a lender browsing pending offers.

On-chain vs off-chain Smart contracts enforce who can spend which UTXO when. Discovery — listing open offers, showing your loans — needs an indexer that watches the chain. Wallet libraries (LWK) build and sign transactions; they do not replace the indexer.

Terms you will see in code reviews

  • Pending offer — collateral locked, waiting for a lender
  • Active loan — principal delivered, clock running
  • Covenant — Simplicity program locking a UTXO until a valid witness path is provided
  • Loan fee / interest — in the simplified contract, a fixed fee on repayment (reference impl: basis points on principal)

Full definitions: Glossary.

Check your understanding

Pick the best answer. Options are equal length on purpose.

1. When a lender accepts a pending offer, what happens?

2. After the lending term expires without repayment, who gets the collateral?

3. What is the indexer’s main job for lenders?

Ask your teacher
Anything unclear? Ask in chat — e.g. “what’s the difference between loan fee and origination fee?” or “walk me through the demo as a borrower.”