Smart contracts
Function reference
Every function and event on LendrMarket — signature, access, and effect.
State-changing functions
| Function | Caller | Precondition | Effect |
|---|---|---|---|
createListing(collateralToken, collateralAmount, loanToken, loanAmount, aprBps, duration) → id | Anyone | allowedCollateral(collateralToken) and loanToken is the market's loan asset | Pulls collateral from caller into the market; creates a listing with status = open |
cancelListing(id) | The listing's borrower | status == open | Returns collateralAmount to the borrower; sets status = cancelled |
fillListing(id) | Anyone except the borrower | status == open | Pulls loanAmount from caller, sends it to the borrower; sets lender, startTime = now, status = active |
repay(id) | The listing's borrower | status == active | Pulls loanAmount + interestOwed(id), sends it to the lender; returns collateral to the borrower; sets status = repaid |
claimCollateral(id) | The listing's lender | status == active and now >= startTime + duration | Sends collateralAmount to the lender; sets status = defaulted |
Read-only functions
| Function | Returns |
|---|---|
interestOwed(id) | uint256 — the exact amount repay would currently require in interest |
listingCount() | uint256 — the number of listings ever created, i.e. the highest valid id |
getListing(id) | The full MarketListing struct for that id |
allowedCollateral(token) | bool — whether token is in this deployment's collateral allow-list |
Events
| Event | Indexed fields | Emitted by |
|---|---|---|
ListingCreated(id, borrower, collateralToken, loanToken, collateralAmount, loanAmount, aprBps, duration) | id, borrower | createListing |
There's only one event
fillListing, repay, cancelListing, and claimCollateral don't emit anything of their own in this ABI. An indexer or UI tracking a listing's later lifecycle has to read getListing(id).status directly rather than subscribing to a dedicated event for each transition — which is exactly what the app's own polling does.
