Contracts overview
Pearcurve's contracts aren't upgradeable. Users and integrations go through one entry point, Main, which keeps the user as the caller for every order they own.
These pages describe behaviour and the call surface builders use today. Contract source is not verified on the explorer yet; see Deployed addresses.
The contracts#
| Contract | What it does |
|---|---|
| Main | The entry point: post and cancel orders, match, repay, refinance, Earn deposits and withdrawals, claiming payouts, pausing. |
| IntentRegistry | Stores lend and borrow orders (called intents onchain) and how much of each is filled. Lend orders are kept in a list sorted by rate for each loan asset. |
| IntentRegistryViews | Read-only views of the orderbook: one order, active lend orders for an asset, available capacity, required collateral. |
| MatchingEngine | Pairs orders and opens loans: manual matches, auto-match, solver batches and auto-refinance. |
| LoanManager | Holds loans and their collateral, and settles them (repay and liquidation). |
| LoanPositionToken | The ERC-721 a lender receives for each loan. Its holder is paid when the loan ends. |
| SecondaryMarket | Fixed-price listings, auctions and offers for loan positions. |
| PriceOracle | Collateral and loan asset prices, with a staleness limit per asset. |
| FeeManager | Protocol fees and their hard caps. |
| LoanMarketCaps | Supply and borrow caps per market and per wallet. |
| Registries | Approved loan assets, collateral, Earn sources and post-match strategies. |
| Earn sources | Adapters that hold lenders' idle assets in Aave or Compound. |
| ProtocolViewer, LoanHealthViewer | Read helpers: paged loan summaries, and a loan's health and whether it can be liquidated. |
Order fields and match paths are on Orders and matching.
Approvals#
Before an action moves tokens, the user approves the contract that pulls them:
| Action | Approve |
|---|---|
| A lend order funded from the wallet | The loan asset to LoanManager, for at least the order plus the user's other open wallet-funded orders |
| Collateral for a borrow | The collateral to LoanManager |
| Auto-refinance (borrower shortfall) | The loan asset to LoanManager, about full-term interest (new lender funds principal) |
| Repaying a loan | The loan asset to LoanManager |
| Depositing into Earn | The loan asset to Main |
Design notes#
- Interest is simple: principal × rate × elapsed / (10,000 × 365 days), with the rate in basis points. No compounding and no 360-day year, so offchain quotes must use the same formula.
- Collateral is sized against the principal plus the interest for the full term at the loan's rate.
- Pausing follows the order protocol, then market, then feature. Repaying, withdrawing from Earn, cancelling an order, claiming a payout, adding collateral, delisting a position, transferring a position NFT and settling an auction never check the pause (while trading is paused, settling an auction refunds the bidder instead of completing the sale). Repay and withdraw can't be paused. See Who controls what.
- Liquidation isn't routed through Main. The liquidator calls LoanManager directly, pays the debt and receives the collateral themselves.
- A generic multicall bundle can't stand in for Main's combined calls (for example post-and-match): the inner calls would see the multicall contract as the caller and fail ownership checks.
Lender callbacks#
Lenders who want lifecycle hooks must deploy a contract that implements ILenderCallback (the hook functions
below), then call LenderCallbackDispatcher.register(callback) once with that contract's address (unregister with
the zero address). Pearcurve notifies the current lender owner's registered callback when a loan is created
(match), repaid, liquidated or refinanced. Vaults, curators and treasuries use this to react without polling. Hooks are
not set on the lend order itself.
From the SDK: encodeRegisterLenderCallback(callback) (send to the dispatcher address) or
getLenderCallbackDispatcher(address, signer).register(callback).
| Hook | When |
|---|---|
onLoanCreated | After the loan exists (match or refinance new loan) |
onLoanRepaid | When the loan is repaid |
onLoanLiquidated | When the loan is liquidated |
onLoanRefinanced | When the loan is refinanced (old lender; new lender gets onLoanCreated) |
After a secondary NFT sale, the buyer must register their own callback; the seller's registration does not follow the NFT.
More detail for integrators (interface shape, examples and SDK helpers) is coming soon.
Rules for receivers#
- Gas is capped per call (default 250,000; governor sets via
setCallbackGas, hard max 1,000,000). Keep hooks small. - Failures are ignored, so a reverting receiver can't block borrowers, lenders or solvers. Don't rely on a hook having run.
- Don't assume you're the only external call in the transaction, and avoid calling back into Pearcurve unless you've carefully reviewed that path.
- After create, the loan already exists and is active. Prefer read-only reactions; any state you change is your own contract's.