Skip to main content
Each lending market deploys as an independent smart contract with upgradeable logic, role-based access control, and configurable risk parameters. Markets operate autonomously once deployed—handling loans, interest, and liquidations without manual intervention.
You can use any erc20 token to pair with your tokenized asset, USDC is only used as an example in this documentation.

Architecture Overview

Core Components

Lending Market

The main contract handling all lending operations:
FunctionDescription
addLiquidityDeposit USDC, receive LP shares
removeLiquidityBurn shares, withdraw USDC
openLoanDeposit collateral, borrow USDC
repayPay back debt, reduce interest
liquidateSeize collateral from unhealthy positions

Price Oracle

Provides real-time collateral valuations:
  • Supports signed price updates (gasless for users)
  • Configurable staleness thresholds
  • Multiple authorized price signers
  • Fallback to external price feeds

Interest Rate Model

Calculates borrow and supply rates based on utilization: Borrow Rate=Base Rate+Utilization×Multiplier\text{Borrow Rate} = \text{Base Rate} + \text{Utilization} \times \text{Multiplier} Above a configurable “kink” (typically 80% utilization), rates increase sharply to encourage repayments.

Insurance Fund

Absorbs losses from failed liquidations:
  • Funded by protocol fees (portion of interest revenue)
  • Covers bad debt when liquidation proceeds fall short
  • Automatically replenishes during normal operation

Liquidation Router

Routes liquidated collateral to trading venues for sale:
  • Receives seized collateral from markets
  • Forwards to configured trading venues
  • Returns USDC proceeds to lending pool
  • Supports multiple markets through single deployment

Access Control Roles

Admin

DEFAULT_ADMIN_ROLE
  • Pause/unpause market
  • Configure insurance fund
  • Upgrade contract logic
  • Grant/revoke other roles

Issuer

ISSUER_ROLE
  • Update market configuration
  • Set liquidation contract
  • Authorize oracle signers
  • Approve whitelabel access

Liquidator

LIQUIDATOR_ROLE
  • Trigger liquidations
  • Settle Dutch auctions
  • Handle timeout scenarios
Role assignment happens during market deployment. Ensure proper key management—these roles control critical market functions.

Market Configuration

Markets are highly configurable to match your risk appetite and regulatory requirements:

Risk Parameters

ParameterDescriptionTypical Range
Collateral FactorMaximum LTV for borrowing65-80%
Liquidation ThresholdLTV triggering liquidation80-90%
Liquidation PenaltyBonus for liquidators3-10%
Close FactorMax % liquidatable per tx25-50%
Min Borrow AmountMinimum loan size$100+

Supply Caps

Limit exposure at market and user levels:
Cap TypePurpose
Max Total CollateralLimits total market size
Max User CollateralPrevents concentration risk

Auction Settings

For Dutch auction liquidations:
SettingDescription
Auction DurationTime from start to minimum price
Start PremiumInitial price above oracle (e.g., 130%)
Minimum PremiumFloor price (e.g., 95% of oracle)

Security Model

Upgradeability

Markets use the UUPS (Universal Upgradeable Proxy Standard) pattern:
  • Logic upgrades require Admin role
  • Proxy address stays constant
  • State preserved across upgrades
  • Emergency fixes possible without redeployment

Reentrancy Protection

All state-changing functions protected against reentrancy attacks. External calls (token transfers, liquidation callbacks) happen after state updates.

Pausability

Admins can pause markets during emergencies:
  • Stops new loans and borrows
  • Repayments still allowed (users can exit)
  • Liquidations continue (protecting the pool)
  • Liquidity withdrawals permitted

Price Staleness

Oracle prices include timestamp validation:
  • Configurable maximum age (default: 24 hours)
  • Stale prices block new borrows
  • Protects against manipulation using old data

Contract Interactions

Opening a Loan

Liquidation Flow

Setup Guide

Deploy your first lending market

Liquidation Details

Liquidation modes and external integration