Skip to content

vesper85/midnight-hack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Strix πŸ¦…

A privacy-preserving DeFi lending protocol built on Midnight Network that enables private lending and borrowing while maintaining user anonymity through zero-knowledge proofs.

What is Strix?

Strix is a decentralized lending protocol with privacy-first design that bridges traditional DeFi transparency requirements with user privacy needs. Built on Midnight Network's zero-knowledge capabilities, Strix enables users to access lending services without compromising their financial privacy.

Key Features

  • Private Identity System (zkID): Privacy-preserving identity tokens with selective revelation
  • Customizable Liquidity Pools: Private lending/borrowing with interest earning capabilities
  • Privacy-Preserving Transactions: All operations maintain user anonymity through zk-proofs
  • Debt Auction Mechanism: Failed repayments trigger debt auctions with controlled identity disclosure
  • Modern Development Stack:
    • Midnight Network for zero-knowledge blockchain infrastructure
    • Bun as the JavaScript runtime and package manager
    • Hono as the backend framework
    • React for the frontend UI
    • Turbo for monorepo build orchestration and caching

Project Structure

.
β”œβ”€β”€ contracts/            # Midnight Network smart contracts (Compact language)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ TestToken.compact      # ERC-20-like token contract
β”‚   β”‚   β”œβ”€β”€ LiquidityPool.compact  # Lending/borrowing pool contract
β”‚   β”‚   └── zkID.compact           # Privacy-preserving identity contract
β”‚   └── managed/          # Compiled contract artifacts
β”œβ”€β”€ cli/                  # Command-line interface for contract interaction
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ testtoken-api.ts       # TestToken contract API
β”‚   β”‚   β”œβ”€β”€ liquidity-pool-api.ts  # LiquidityPool contract API
β”‚   β”‚   β”œβ”€β”€ initialize-tokens-and-pools.ts  # Deployment scripts
β”‚   β”‚   └── query-contract-state.ts # Contract state querying
β”‚   └── standalone.yml    # Docker configuration for Midnight Network
β”œβ”€β”€ client/               # React frontend (UI mockups)
β”œβ”€β”€ server/               # Hono backend API
β”œβ”€β”€ shared/               # Shared TypeScript definitions
└── turbo.json            # Turbo configuration for build orchestration

Smart Contracts

Strix implements three core smart contracts using Midnight Network's Compact language:

TestToken Contract

Basic ERC-20-like functionality with privacy features:

  • Mint, burn, and faucet operations
  • Private balance tracking
  • Owner-based access control

LiquidityPool Contract

Comprehensive lending/borrowing system:

  • Liquidity provision and withdrawal
  • Collateral staking and borrowing
  • Health factor calculations and liquidation
  • Interest rate management
  • Reward distribution

zkID Contract

Privacy-preserving identity management:

  • KYC verification without revealing personal data
  • Credit score tracking
  • Selective identity revelation during liquidation
  • Authorized issuer management

CLI Interface

The command-line interface provides comprehensive contract management:

cli/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ testtoken-api.ts       # TestToken contract interactions
β”‚   β”œβ”€β”€ liquidity-pool-api.ts  # LiquidityPool contract interactions
β”‚   β”œβ”€β”€ initialize-tokens-and-pools.ts  # Deployment automation
β”‚   └── query-contract-state.ts # Contract state inspection
└── standalone.yml             # Docker configuration

Frontend (In Development)

The React frontend provides a modern web interface for interacting with Strix:

client/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ supply-market.tsx    # Supply market interface
β”‚   β”‚   β”œβ”€β”€ borrow-market.tsx    # Borrow market interface
β”‚   β”‚   β”œβ”€β”€ core-asset-table.tsx # Asset listing
β”‚   β”‚   └── ui/                  # Reusable UI components
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ index.tsx           # Main dashboard
β”‚   β”‚   β”œβ”€β”€ portfolio/          # User portfolio
β”‚   β”‚   └── transactions/       # Transaction history
β”‚   └── lib/
β”‚       └── token-api.ts        # Frontend API integration

Note: The frontend currently contains UI mockups and is not yet connected to the CLI backend. Integration is planned for future development.

Getting Started

Prerequisites

  • Bun: Version 1.2.4+ (package manager and runtime)
  • Docker & Docker Compose: For running Midnight Network standalone environment
  • Midnight Compact Compiler: For smart contract compilation

Quick Start

  1. Install Dependencies
bun install
  1. Start Midnight Network Environment
cd cli
docker compose -f standalone.yml up -d
  1. Compile Smart Contracts
cd contracts
bun run compact
  1. Deploy Tokens and Liquidity Pools
cd cli
bun run src/initialize-tokens-and-pools.ts
  1. Interact with Contracts
# Deploy new token
bun run src/simple-standalone-testtoken.ts

# Query contract states
bun run src/query-contract-state.ts

# List all tokens
bun run src/list-test-tokens.ts

Development Commands

# Run all services in development mode
bun run dev

# Build all packages
bun run build

# Lint code
bun run lint

# Type check
bun run type-check

Architecture Overview

Strix implements a privacy-preserving DeFi protocol with the following key components:

Privacy Model

  • Default Privacy: All transactions and balances are private by default
  • Selective Revelation: Identity is only revealed during liquidation events
  • Zero-Knowledge Proofs: Verify financial positions without revealing amounts
  • Controlled Disclosure: Authorized entities can access specific information when needed

Contract Interactions

  1. Token Deployment: Deploy TestToken contracts with private balances
  2. Pool Creation: Create LiquidityPool contracts linked to tokens
  3. Identity Issuance: Issue zkID tokens for KYC verification
  4. Lending Operations: Provide liquidity and earn interest privately
  5. Borrowing Operations: Stake collateral and borrow with private amounts
  6. Liquidation Process: Reveal identity only to debt collectors during default

Key Features Implemented

βœ… Smart Contracts: TestToken, LiquidityPool, and zkID contracts
βœ… CLI Interface: Comprehensive command-line tools for contract interaction
βœ… Contract Deployment: Automated token and pool initialization
βœ… State Querying: Contract state inspection and transaction history
βœ… Privacy Protection: Zero-knowledge proof integration
🚧 Frontend Integration: Web interface (in development)
🚧 Multi-Asset Support: Cross-asset collateralization (planned)

Documentation

Learn More

License

MIT License - see LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published