MechanicsOverview

Mechanics Overview

This section details the operational flows of the RevvFi lending protocol, from market creation to debt settlement.

The Protocol Lifecycle

Phase 1: Market Creation

  • Action: A registered borrower calls RevvFiFactory.deployMarket(...), specifying the borrow asset, collateral asset, Chainlink oracle, decimals, min collateral ratio, and liquidation threshold.
  • Cost: A one-time deployment fee is paid to the Factory’s fee recipient.
  • Result: A dedicated Market, CollateralEscrow, OfferBook, and LiquidityQueue are cloned and wired together for this borrower.

Phase 2: Offer Submission

  • Action: Lenders call submitOffer(amount, apr, seniority, duration) on the market’s OfferBook.
  • Flexibility: Each lender picks their own amount, APR, and seniority (senior or junior) independently — there’s no pooled rate to opt into.
  • State: Offer funds sit in the OfferBook contract, unmatched and not yet accruing interest, until a borrower draws against them.

Phase 3: Borrowing & Matching

  • Action: The borrower deposits collateral, then calls borrow(amount, useSeniorOnly, maxApr).
  • Matching: The OfferBook fills the request from active offers sorted lowest-APR-first (optionally senior-only), minting one RevvFiPositionNFT per lender filled.
  • Accrual: From that block onward, each resulting position accrues interest independently, at that position’s own APR.

Phase 4: Servicing & Repayment

  • Action: The borrower calls repay(amount) (partial) or repayFull() (settles everything).
  • Distribution: A partial repayment is split across all active positions proportional to each position’s own share of total debt, crediting each lender’s claimable balance — it does not transfer tokens to lenders directly.
  • Claiming: Lenders call claimFunds(positionId) themselves to pull their credited balance.
  • Reputation: On full settlement, the borrower’s on-chain reputation score is recalculated.

Phase 5 (if needed): Liquidation

  • Trigger: Anyone can trigger liquidation once a position’s collateral ratio falls below the market’s liquidation threshold.
  • Auction: RevvFiLiquidator runs a declining-price auction (100% of debt down to an 80% reserve), which bidders can still outbid each other on until it ends.
  • Settlement: Proceeds are routed back to the market for lender distribution; any shortfall is recorded as bad debt against the borrower’s reputation.

Technical Guides