Offer State Machine
Simplified P2P lending lifecycle from Simplicity lending docs and simplicity-lending.
Transitions at a glance
| From | Actor | Action | To |
|---|---|---|---|
| — | Borrower | Lock collateral + publish terms | Pending |
| Pending | Borrower | Cancel offer | Cancelled (collateral returned) |
| Pending | Lender | Send principal, accept terms | Active |
| Active | Borrower | Repay principal + loan fee | Repaid (collateral released) |
| Active | Lender | After lending term, claim collateral | Liquidated |
Reference implementation nuance
simplicity-lending tracks pending → active → repaid → claimed (lender withdraws from repayment vault) or liquidated or cancelled. When reviewing code, map names to these transitions — not every label appears in the official docs diagram.
What moves on-chain at each step
| Step | Asset B (principal) | Asset A (collateral) |
|---|---|---|
| Create offer | — | Locked in covenant |
| Accept | Lender → borrower | Stays locked |
| Repay | Borrower → lender (+ protocol fee) | Returned to borrower |
| Liquidate | Lender keeps unfunded portion | Lender receives collateral |