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

IndexStatusTerminal?
0none — no listing exists at this id
1openNo
2activeNo
3repaidYes
4defaultedYes
5cancelledYes

Invariants worth knowing

  • ids are never reused and never deleted — getListing(id) always returns something, even long after a listing is settled.
  • lender is the zero address for the entire time a listing is open. It's set exactly once, in fillListing, and never changes after.
  • collateralAmount and loanAmount are fixed at createListing and never change — there's no top-up, no partial repayment, no partial fill.
  • startTime is the source of truth for maturity, and it's set from the block timestamp of the transaction that called fillListing — not from createdAt. Two listings created at the same moment can mature at completely different times depending on when each gets filled.
  • aprBps and duration are set once at creation and used verbatim by interestOwed for 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.