Smart Contracts
Technical specifications for the RevvFi core smart contracts.
1. RevvFiLendingEngine
The central registry and factory for the protocol.
Key Functions
createMarket(address borrower, MarketParams params): Deploys a newLendingMarketfor a borrower.updateReputation(address borrower, int256 delta): Adjusts borrower reputation score.getMarket(address borrower): Returns the market address for a specific borrower.
2. LendingMarket
The primary interaction point for lenders and the borrower. Each borrower has a unique market.
State Variables
borrower: The owner of this market who can request loans.offerBook: A mapping of active lender offers.activePositions: A mapping of current loan NFTs.
Core Logic
submitOffer(...): Lenders provide liquidity terms.requestLoan(uint256 amount): Borrower triggers the matching engine.repay(uint256 positionId): Borrower settles debt + accrued interest.
3. CollateralEscrow
Manages the safety of the protocol through asset custody and liquidation logic.
Mechanisms
- Escrow: Holds assets deposited by the borrower.
- Health Factor (HF): Monitored to prevent undercollateralization.
- Liquidation: If
HF < 1, thestartAuctionfunction is exposed.
4. LenderPosition (NFT)
An ERC721 token representing a lender’s claim to principal and interest.
5. ReputationRegistry
A standalone contract managing the global Reputation Score (0-1000).
| Event | Score Adjustment |
|---|---|
| New Borrower | +500 (Baseline) |
| Successful Repayment | +1 |
| Default (Liquidation) | -50 |
| Early Repayment | +2 |
6. OracleHub
Integrates with Chainlink to provide secure price feeds for collateral valuation.
- Fallback mechanism: Uses a TWAP-based oracle if Chainlink feeds are stale.
- Circuit Breaker: Halts market matching if price volatility exceeds 20% in a 1-hour window.