Logo
Build
  • Explore Buildathon
  • Project Archive
Hack
Hack Coming Soon
  • Explore IRL Hackhouse
  • How to Qualify
  • Past Events

SlemanFi

A comprehensive DeFi lending protocol built using Solidity (Foundry) and Arbitrum Stylus (Rust)

Videos

Description

SlemanFi Protocol - Project Summary

A comprehensive DeFi lending protocol with cross-chain capabilities built using Solidity (Foundry) and Arbitrum Stylus (Rust)


๐Ÿ“‹ Executive Summary

SlemanFi is a modular, upgradeable DeFi lending protocol that enables:

  • Isolated lending pools for risk separation between token pairs

  • Collateral management with multiple token support

  • Dynamic interest rate models with configurable parameters

  • Liquidation mechanisms to maintain protocol health

  • DEX integration to repay loans using collateral (no need for borrow token)

The project consists of two technology stacks:

  1. sleman-sc - Solidity smart contracts (Foundry)

  2. sleman-stylus - Rust smart contracts (Arbitrum Stylus SDK)


๐Ÿ—๏ธ Project Architecture

โ”œโ”€โ”€ sleman-sc/ # Main Solidity contracts (Foundry)

โ”‚ โ”œโ”€โ”€ src/ # Core protocol contracts

โ”‚ โ”‚ โ”œโ”€โ”€ LendingPool.sol # Main lending operations

โ”‚ โ”‚ โ”œโ”€โ”€ LendingPoolStorage.sol # Storage & accounting

โ”‚ โ”‚ โ”œโ”€โ”€ Router.sol # Central coordination hub

โ”‚ โ”‚ โ”œโ”€โ”€ TokenDataStream.sol # Oracle/price feed system

โ”‚ โ”‚ โ”œโ”€โ”€ InterestRateModel.sol # Interest calculations

โ”‚ โ”‚ โ”œโ”€โ”€ IsHealthy.sol # Health factor calculations

โ”‚ โ”‚ โ”œโ”€โ”€ Pricefeed.sol # Price feed aggregator

โ”‚ โ”‚ โ”œโ”€โ”€ WrappedNative.sol # Native token wrapper

โ”‚ โ”‚ โ”œโ”€โ”€ hooks/ # Protocol hook contracts

โ”‚ โ”‚ โ”œโ”€โ”€ interfaces/ # Contract interfaces

โ”‚ โ”‚ โ””โ”€โ”€ mocks/ # Mock tokens for testing

โ”‚ โ”œโ”€โ”€ script/ # Deployment scripts

โ”‚ โ”‚ โ”œโ”€โ”€ DeploySlemanCore.s.sol # Base deployment logic

โ”‚ โ”‚ โ””โ”€โ”€ steps/ # 15 modular deployment steps

โ”‚ โ””โ”€โ”€ test/ # Unit and integration tests

โ”‚

โ”œโ”€โ”€ sleman-stylus/ # Rust smart contracts (Stylus SDK)

โ”‚ โ”œโ”€โ”€ src/ # Rust source code

โ”‚ โ”œโ”€โ”€ abi/ # Exported ABIs

โ”‚ โ”œโ”€โ”€ tests/ # Rust tests

โ”‚ โ””โ”€โ”€ examples/ # Usage examples

โ”‚

โ””โ”€โ”€ nitro-devnode/ # Local development node


๐Ÿ”ง Core Contracts

1. LendingPool.sol (471 lines)

The main entry point for user interactions:

  • supplyCollateral() - Deposit tokens as collateral

  • withdrawCollateral() - Withdraw collateral tokens

  • supplyLiquidity() - Provide liquidity to earn interest

  • withdrawLiquidity() - Withdraw liquidity position

  • borrow() - Borrow tokens from liquidity pool

  • repay() - Repay borrowed tokens

  • repayWithCollateral() - Swap collateral to repay debt

  • liquidation() - Liquidate unhealthy positions

Features:

  • UUPS Upgradeable pattern

  • Role-based access control (OWNER_ROLE, ADMIN_ROLE)

  • Pausable for emergency situations

  • Reentrancy protection

  • Native token (ETH/native) support

2. LendingPoolStorage.sol (589 lines)

Separated storage contract for upgradeable patterns:

  • Manages all state variables and accounting

  • Tracks user collateral, supply shares, and borrow shares

  • Handles interest accrual

  • Validates health factors before operations

  • Calculates share-to-asset conversions

Key Mappings:

mapping(address => mapping(address => uint256)) userCollateral;

mapping(address => uint256) userSupplyShares;

mapping(address => uint256) userBorrowShares;

3. Router.sol (221 lines)

Central configuration and routing contract:

  • Manages lending pool registrations

  • Stores external contract addresses (Oracle, DEX, etc.)

  • Handles protocol fee configuration

  • Controls wrapped native token address

  • Manages reserve factors

4. Supporting Contracts

Contract

Purpose

InterestRateModel.sol

Dynamic interest rate calculations

IsHealthy.sol

Health factor & liquidation threshold calculations

TokenDataStream.sol

Oracle/price feed aggregation

Pricefeed.sol

Price feed interface


๐Ÿ”Œ Hook System (7 Contracts)

The protocol uses a hook pattern for extensibility:

Hook

Description

LendingPoolHook.sol

Events, errors, constants for LendingPool

LendingPoolStorageHook.sol

Events, errors, constants for Storage

RouterHook.sol

Events, errors, constants for Router

InterestRateModelHook.sol

Interest rate configuration

IsHealthyHook.sol

Health/liquidation parameters

TokenDataStreamHook.sol

Oracle configuration

PricefeedHook.sol

Price feed settings


๐Ÿ“ก Interface Contracts (11)

โ”œโ”€โ”€ ILendingPool.sol # Main lending operations

โ”œโ”€โ”€ ILendingPoolStorage.sol # Storage access

โ”œโ”€โ”€ IRouter.sol # Router configuration

โ”œโ”€โ”€ IInterestRateModel.sol # Interest calculations

โ”œโ”€โ”€ IIsHealthy.sol # Health checks

โ”œโ”€โ”€ ITokenDataStream.sol # Oracle data

โ”œโ”€โ”€ IOracle.sol # External oracle interface

โ”œโ”€โ”€ IAerodromeRouter.sol # DEX (Aerodrome) integration

โ”œโ”€โ”€ ILiquidator.sol # Liquidation logic

โ”œโ”€โ”€ INusaVault.sol # Vault integration

โ””โ”€โ”€ IWrapped.sol # Wrapped token interface


๐Ÿš€ Modular Deployment Pattern

The project features a 14-step modular deployment system:

Phase 8: IntegrationPhase 7: ParametersPhase 6: Lending ConfigPhase 5: Core LendingPhase 4: Router ConfigPhase 3: UtilitiesPhase 2: Oracle ConfigPhase 1: Infrastructure0. Deploy Mock Tokens1. Deploy Router2. Deploy TokenDataStream3. Set Price Feed4. Deploy IsHealthy5. Deploy InterestRateModel6. Config Router7. Deploy LendingPoolStorage8. Deploy LendingPool9. Config Router For LendingPool10. Config LendingPoolStorage11. Tweaking InterestRateModel12. Tweaking IsHealthy13. Set DEX Router14. Set Protocol

Benefits:

  • โœ… Granular Control: Deploy/re-run only needed steps

  • โœ… Easy Debugging: Identify issues at specific steps

  • โœ… Fast Iteration: Skip successful steps

  • โœ… Reusability: Works across networks (testnet/mainnet)

  • โœ… Self-Documenting: Folder structure shows deployment order


๐Ÿงช Mock Tokens for Testing

Located in src/mocks/:

  • MOCKWBTC, MOCKWETH, MOCKUSDC, MOCKUSDT

  • MOCKARB

All mocks have public mint() and burn() functions for testing.


๐Ÿ”ง Development Commands

Solidity (Foundry)

# Build

forge build

# Run tests

forge test

# Deploy single step

forge script script/steps/1.DeployRouter.s.sol --broadcast -vvv

# Deploy with verification

forge script ScriptName --broadcast -vvv \

--verify --verifier etherscan \

--etherscan-api-key $ETHERSCAN_API_KEY

Stylus (Rust)

# Check compilation

cargo stylus check

# Export ABI

cargo stylus export-abi

# Deploy

cargo stylus deploy --private-key-path=<PATH>

# Run tests

cargo test


๐Ÿ“Š Technology Stack

Layer

Technology

Smart Contracts

Solidity 0.8.20, Rust (Stylus)

Framework

Foundry, cargo-stylus

Upgradability

UUPS Proxy Pattern

Access Control

OpenZeppelin AccessControl

Security

ReentrancyGuard, Pausable

Cross-chain

LayerZero (OApp)

DEX Integration

Aerodrome Router

Oracle

Custom TokenDataStream + External oracles


๐ŸŽฏ Key Differentiators

  1. Isolated Pool Design: Risk separation between token pairs, no contagion

  2. Collateral Repayment: Repay loans using collateral via DEX integration

  3. Dual Technology Stack: Solidity + Stylus for optimal gas efficiency

  4. Modular Architecture: Hook-based extensibility pattern

  5. Professional Deployment: 14-step modular deployment with dependency tracking

  6. Upgradeable Design: UUPS pattern with separated storage


Project: SlemanFi Protocol
Status: Active Development

Progress During Hackathon

90

Tech Stack

StylusNextWeb3SolidityReactFoundryChainlinkPonder

Fundraising Status

Hackathon Phase

Team Leader
HHafsidee
GitHub Link
github

GitHub

https://github.com/SlemanFi
Product Category
DeFi