Skip to content

hackathemy/SuperNeutral

Repository files navigation

ETH Lending Protocol

A decentralized lending protocol that allows users to borrow PYUSD stablecoin using ETH as collateral, with automatic yield generation through LIDO staking.

🌟 Features

  • Borrow PYUSD: Use ETH as collateral to borrow PYUSD stablecoin
  • Flexible Liquidation Ratios: Choose between 50-80% liquidation ratio based on your risk tolerance
  • NFT Loan Positions: Each loan is represented as an ERC-721 NFT that can be transferred or traded
  • sPYUSD (Staked PYUSD): Interest-bearing token that automatically increases in value
  • Short Position Hedging: Optional 0-30% short position to hedge against ETH price drops
  • Automatic Yield: Deposited ETH generates staking rewards through LIDO
  • Liquidation Bonus: 0.1% bonus for liquidators to ensure healthy protocol operation

📊 Protocol Stats

  • Network: Sepolia Testnet
  • Total Value Locked: Dynamic
  • Exchange Rate: Real-time sPYUSD appreciation
  • Liquidation Bonus: 0.1%

🏗️ Architecture

Smart Contracts

  • EthereumLendingPool: Main lending pool contract

  • StakedPYUSD: Interest-bearing ERC-20 token

  • EthereumLoanNFT: ERC-721 loan position NFT

Technology Stack

  • Smart Contracts: Solidity 0.8.28, Hardhat 3.0.7, OpenZeppelin 5.0.1
  • Frontend: Next.js 15, React 19, TypeScript
  • Web3: wagmi v2, viem, RainbowKit
  • Oracle: Pyth Network
  • Staking: LIDO (Mock on testnet)

🚀 Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn
  • MetaMask or another Web3 wallet
  • Sepolia testnet ETH

Installation

# Clone the repository
git clone <repository-url>
cd eth-online

# Install dependencies
npm install

# Install frontend dependencies
cd frontend
npm install
cd ..

Configuration

  1. Copy .env.example to .env:
cp .env.example .env
  1. Fill in your environment variables:
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_API_KEY
PRIVATE_KEY=your_private_key_here
ETHERSCAN_API_KEY=your_etherscan_api_key

Compile Contracts

npm run compile

Deploy Contracts

# Deploy to Sepolia testnet
npm run deploy:updated

# Deploy locally for testing
npm run node  # In one terminal
npm run deploy:local  # In another terminal

Run Frontend

cd frontend
npm run dev

Visit http://localhost:3000 to interact with the protocol.

📖 How It Works

For Lenders (Liquidity Providers)

  1. Supply PYUSD: Deposit PYUSD into the protocol
  2. Receive sPYUSD: Get interest-bearing sPYUSD tokens
  3. Earn Interest: sPYUSD automatically increases in value as borrowers pay interest
  4. Withdraw: Burn sPYUSD to receive PYUSD + earned interest

Example:

Day 0:   Supply 10,000 PYUSD → Receive 10,000 sPYUSD
Day 30:  Exchange Rate = 1.05
         Your 10,000 sPYUSD = 10,500 PYUSD (5% gain)
Day 60:  Exchange Rate = 1.10
         Your 10,000 sPYUSD = 11,000 PYUSD (10% gain)

For Borrowers

  1. Deposit ETH: Provide ETH as collateral
  2. Choose Parameters:
    • Liquidation Ratio (50-80%)
    • Short Position Ratio (0-30%)
  3. Borrow PYUSD: Receive PYUSD stablecoin
  4. Repay + Interest: Pay back to retrieve collateral
  5. NFT Position: Your loan is an NFT you can transfer

Liquidation Example:

Loan: 1 ETH @ $2,000 = $2,000 collateral
Borrow: $1,000 PYUSD (50% LTV)
Liquidation Ratio: 50%

Safe Zone: ETH price > $1,000 (50% drop tolerance)
Liquidation: ETH price drops to $1,000
Result: Liquidator repays debt, receives collateral + 0.1% bonus

🔐 Security Features

  • ReentrancyGuard: Protection against reentrancy attacks
  • Pausable: Emergency pause functionality
  • Ownable: Admin access control
  • Input Validation: Comprehensive parameter checks
  • Safe Math: Solidity 0.8.28 overflow protection
  • Liquidation Bonus: Incentivizes healthy protocol operation

🧪 Testing

# Run tests (when plugins are available)
npm test

# Test on Sepolia
npm run test:sepolia
npm run test:borrow
npm run test:liquidation

📚 Documentation

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the ISC License.

⚠️ Disclaimer

This is a testnet deployment for educational and testing purposes only. Do not use with real funds on mainnet without proper auditing and testing.

🔗 Links

📞 Support

For questions and support, please open an issue in the repository.


Built with ❤️ for ETH Online Hackathon

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5