This repository contains the Soroban smart contracts and related resources for the StellarLend protocol.
Contents:
- Overview
- Modules and Features
- Admin Operations
- Monitoring & Analytics
- Upgrade & Configuration
- Cross-Chain Bridge
- Social Recovery & Multisig
StellarLend is a lending and borrowing protocol built on Soroban. It features cross-asset accounting, risk management, governance, AMM integration, flash loans, and more.
- Interest rate model with smoothing
- Risk config and scoring
- Cross-asset positions and oracle support
- Flash loans with configurable fees
- AMM integration hooks (swap, add/remove liquidity)
- Cross-chain bridge interface with fees and events
- Analytics: global and per-user metrics, daily snapshots
- Monitoring: health, performance, and security alerts
- Social recovery: guardians, timelock approvals, execution
- Multisig for admin min-collateral changes
- Upgrade: propose/approve/execute/rollback and status
- Data management: generic data store, backup/restore, migration
- Configuration: versioned param store with backup/restore
Key admin entrypoints (see contract for full list):
initialize(admin)set_min_collateral_ratio(caller, ratio)set_risk_params(...),set_pause_switches(...)set_price_cache_ttl(caller, ttl)register_bridge(caller, network_id, bridge, fee_bps)set_bridge_fee(caller, network_id, fee_bps)upgrade_propose/approve/execute/rollbackconfig_set/config_backup/config_restorems_set_admins,ms_propose_set_min_cr,ms_approve,ms_execute
record_user_action(user, action)updates risk and emits events- Analytics auto-update on deposit/borrow/repay/withdraw
- Monitoring entrypoints:
monitor_report_health/performance/security,monitor_get
get_protocol_report()&get_user_report(address)surface typed structs (ProtocolReport,UserReport) containing current metrics, active-user counts, and the latest activity feed snapshot time.get_asset_report(asset)returnsAssetReportwith per-asset analytics and historical bucketed data.get_recent_activity(limit)supplies anActivityFeedwith newest-first entries, atotal_availablecounter (capped at 1,000 retained records), and thegenerated_atledger timestamp for indexers.- Activity entries include
user,activity_type,amount, optionalasset, and a metadata map for extended tags. - Example payloads:
protocol_report.jsonanduser_report.jsondemonstrate the serialized shape returned by the contract. Monetary totals are raw integers in the protocol’s smallest units, and percentage-style fields (e.g., utilization, success rate, health score) are exported as fixed-point integers scaled by1e6(333333≈ 33.3333%). - Field hints:
total_value_locked,total_deposits,total_borrows, etc. are cumulative atomic units across all assets.- Percentage-like values (e.g.,
avg_utilization_rate,protocol_risk_score,uptime_percentage,collateralization_ratio) use the same1e6scaling; divide by 1_000_000 to obtain human-readable percentages. - User analytics expose running totals plus derived scores (
activity_score,loyalty_tier) that map to reward tiers.
- Example Soroban call:
Returns a feed where
soroban contract invoke \ --id <contract-id> \ --fn get_recent_activity \ --arg limit=50
entries[0]is the most recent action; setlimitto0for metadata-only responses.
upgrade_statusreturns current, previous, pending version and metadata- Config supports version bumps, validation, and easy backup/restore
- Register networks and fees, and use
bridge_deposit/bridge_withdrawto move balances with transparent fees
- Set guardians per-user and execute timelocked recoveries
- Multisig supports proposing and executing admin changes with threshold