Core concepts
Listings & the order book
The MarketListing shape, its status enum, and the invariants each field guarantees.
A listing is the only object Lendr has. There are no separate "market" or "vault" records — the entire protocol state is a growing array of MarketListing structs, indexed by an incrementing id starting at 1.
MarketListing
struct MarketListing {
address borrower;
address lender; // zero address until filled
address collateralToken;
address loanToken; // always USDG today
uint256 collateralAmount;
uint256 loanAmount;
uint16 aprBps; // APR in basis points, e.g. 800 = 8%
uint32 duration; // seconds
uint64 createdAt;
uint64 startTime; // 0 until filled, then the fill block's timestamp
uint8 status; // see the status enum below
}The status enum
| Index | Status | Terminal? |
|---|---|---|
| 0 | none — no listing exists at this id | — |
| 1 | open | No |
| 2 | active | No |
| 3 | repaid | Yes |
| 4 | defaulted | Yes |
| 5 | cancelled | Yes |
Invariants worth knowing
ids are never reused and never deleted —getListing(id)always returns something, even long after a listing is settled.lenderis the zero address for the entire time a listing isopen. It's set exactly once, infillListing, and never changes after.collateralAmountandloanAmountare fixed atcreateListingand never change — there's no top-up, no partial repayment, no partial fill.startTimeis the source of truth for maturity, and it's set from the block timestamp of the transaction that calledfillListing— not fromcreatedAt. Two listings created at the same moment can mature at completely different times depending on when each gets filled.aprBpsanddurationare set once at creation and used verbatim byinterestOwedfor the life of the loan, regardless of when — or whether — it's repaid.
No order book depth
Because a listing is filled in one shot for its exact size, "the order book" is really just the full list of open listings, each independently priced by whoever created it. The UI groups and sorts them by collateral category, APR, and duration — the contract has no concept of aggregating or matching multiple listings together.
