How solendprotocol/suilend-public works
Project Type and Purpose
• This is a full-stack DeFi dApp monorepo for the “Suilend” protocol.
• frontend: Next.js/React TypeScript UI for on-chain lending, borrowing, swapping and sends
• sdk: TypeScript client library auto-generated from Move modules, published as @suilend/sdk
• liquidator: Node.js standalone service (bot skeleton) for monitoring/triggering liquidations
• scripts: ad-hoc CSV-processing scripts for airdrop/quest data
• Core use case: UI → SDK → Sui blockchain; off-chain bot → SDK → blockchain + Redis.
File-Structure Highlights
• Top level: package.json, bun.lock, eslint, shared configuration.
• frontend/: Next.js app
• src/pages & API routes (serverless edge & client)
• src/components, contexts, hooks, fetchers
• public assets including move_bytecode_template_bg.wasm
• sdk/:
• src/_generated: types & call bindings for Suilend Move modules
• src/api, src/lib, parsers, utils
• published package
• liquidator/:
• src/index.ts & liquidator.ts core logic
• src/swappers/cetus integration
• src/utils: Redis client, constants
• docker-compose.yml to run bot + Redis
• scripts/: small TypeScript scripts for CSV generation & quest logic
Architectural Components
A. Frontend (Next.js / React)
• UI components, contexts & hooks
• Uses @suilend/sdk to build transactions & fetch on-chain data
• Serverless API routes (e.g. ip-address-country)
• Fetches from Sui RPC / Indexer endpoints
B. SDK (@suilend/sdk)
• Auto-generated bindings to on-chain Move modules
• Exposes typed classes & functions: markets, obligations, reserves, rate limiter, events
• Underlying HTTP/JSON-RPC client to Sui node
C. Sui Blockchain (External Service)
• Suilend Move program (deployed contracts)
• JSON-RPC node & Indexer for queries
D. Liquidator Bot
• Polls markets via SDK, calculates under-collateralized positions
• Connects to Redis for state/tracking
• Submits liquidation transactions
E. Scripts
• Standalone CLI tasks leveraging SDK or raw CSV processing
• Not part of runtime; for governance/airdrop data preparation
F. Infrastructure
• Redis (for liquidator state)
• Docker-Compose orchestration for liquidator + Redis
• bun/Node.js runtimes
Relationships & Data Flows
• Frontend → SDK → Sui JSON-RPC Node (read & write)
• Frontend → API routes → edge functions (geolocation service)
• SDK → Sui blockchain → Move modules
• Liquidator → SDK → Sui blockchain
• Liquidator ↔ Redis (state management)
• Scripts → SDK / filesystem → CSV output
Architectural Patterns & Principles
• Separation of concerns: UI vs client library vs bot vs scripts
• Code-gen driven SDK: ensures parity with on-chain types
• Containerization: liquidator + Redis in Docker for easy deployment
• Serverless functions within Next.js for lightweight backend tasks