Skip to content

Architecture

Overview

Interest Exchange uses a modular architecture with three main layers:

┌─────────────────────────────────────┐
│           Frontend (Web)            │
├─────────────────────────────────────┤
│     Orderbook (Off-chain API)       │
├─────────────────────────────────────┤
│        Smart Contracts              │
│  ┌───────────┬──────────────────┐   │
│  │ OrderBook │ PositionManager  │   │
│  └───────────┴──────────────────┘   │
│  ┌──────────────────────────────┐   │
│  │    Protocol Adapters         │   │
│  │  Morpho │ Aave │ Silo │ ... │   │
│  └──────────────────────────────┘   │
│  ┌──────────────────────────────┐   │
│  │   Underlying DeFi Protocols  │   │
│  └──────────────────────────────┘   │
└─────────────────────────────────────┘

Smart Contracts

OrderBook

The on-chain orderbook contract manages order creation, matching, and execution. It coordinates with position managers to open and close positions.

PositionManager

Each position gets its own PositionManager contract (deployed via factory). The PositionManager:

  • Holds the borrower's position on the underlying protocol via delegatecall to adapters
  • Tracks fixed rate agreements
  • Handles settlement between borrower and backer

Protocol Adapters

Adapters implement the IProtocolAdapter interface and are called via delegatecall from PositionManagers. Each adapter handles the specifics of interacting with one lending protocol.

Interest ExchangeFactory

Deploys new PositionManager instances and registers supported adapters.

Off-chain Components

Orderbook API

A centralized matching engine that maintains the order book off-chain for gas efficiency. Orders are signed messages that can be executed on-chain when matched.

Indexer

An Envio-based indexer that tracks on-chain events for the frontend and API.

Interest Exchange Protocol