Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 58 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# StackLend Protocol 🚀
# Hayy Protocol👋

**Cross-Chain Lending Protocol between Stacks and EVM Networks**
**Cross-Chain Money Market between Stacks and Sui Blockchain**

StackLend is a revolutionary decentralized finance (DeFi) protocol that enables seamless cross-chain lending by using STX as collateral on Stacks blockchain to borrow tokens on EVM-compatible networks. The protocol bridges Bitcoin's security through Stacks with the liquidity of Ethereum-based ecosystems.
Hayy Protocol is a revolutionary decentralized finance (DeFi) protocol that enables seamless cross-chain lending by using STX or sBTC as collateral on Stacks L2 blockchain to borrow tokens on Sui blockchain. The protocol bridges Bitcoin's security through Stacks with Sui's high-performance blockchain.

## 🌟 Features

- **Cross-Chain Lending**: Use STX as collateral to borrow tokens on multiple EVM networks
- **Stacks Integration**: Leverage Bitcoin's security through Stacks blockchain
- **Multi-Network Support**: Currently supports Scroll Sepolia with plans for more networks
- **Cross-Chain Lending**: Use STX or sBTC as collateral to borrow USDC on Sui blockchain
- **Stacks Integration**: Leverage Bitcoin's security through Stacks L2 blockchain
- **Sui Integration**: High-performance blockchain with low transaction fees for borrowing
- **Real-Time Relayer**: Automated cross-chain transaction processing
- **User-Friendly Interface**: Modern React frontend with wallet integration
- **Secure Smart Contracts**: Audited and battle-tested contract architecture
- **EVM Support**: Coming soon - will enable borrowing on EVM-compatible networks

## 🏗️ Architecture

Expand All @@ -20,45 +21,43 @@ The protocol consists of four main components:
```mermaid
graph TB
A[Frontend dApp] --> B[Stacks Contracts]
A --> C[EVM Contracts]
A --> C[Sui Contracts]
B --> D[Cross-Chain Relayer]
D --> C

B --> E[STX Collateral]
C --> F[Token Borrowing]
B --> E[STX/sBTC Collateral]
C --> F[USDC Borrowing]
D --> G[Event Processing]
```

### Components

1. **Frontend (`stacklend-fe`)**: React-based user interface with Stacks and EVM wallet integration
2. **Stacks Contracts (`stacklend-stacks`)**: Clarity smart contracts for collateral management
3. **EVM Contracts (`stacklend-evm`)**: Solidity contracts for token borrowing and lending
4. **Relayer (`stacklend-relayer`)**: Node.js service for cross-chain event processing
1. **Frontend (`hayyprotocol-fe`)**: React-based user interface with Stacks and Sui wallet integration
2. **Stacks Contracts (`hayyprotocol-stacks`)**: Clarity smart contracts for collateral management
3. **Sui Contracts (`hayyprotocol-sui`)**: Move smart contracts for token borrowing and lending
4. **Backend/Relayer (`hayyprotocol-backend`)**: Node.js service for cross-chain event processing

## 📋 Contract Addresses

### Stacks Testnet

| Contract | Address |
|----------|---------|
| **Collateral V1** | `STBGS8Y6KHWQ3D2P9BTQ83VBD3ZCK7BDTWMGJY5Z.collateral-v1` |
| **Lending V1** | `STBGS8Y6KHWQ3D2P9BTQ83VBD3ZCK7BDTWMGJY5Z.lending-v1` |
| **Money Market Core** | `STBGS8Y6KHWQ3D2P9BTQ83VBD3ZCK7BDTWMGJY5Z.collateral-v1` |

### Scroll Sepolia (Testnet)
### Sui Testnet

| Contract | Address | Explorer |
|----------|---------|----------|
| **BorrowController** | `0xD2b0838ff0818E9aa185a712576Cb3EE0885deda` | [View on Scrollscan](https://sepolia.scrollscan.com/address/0xD2b0838ff0818E9aa185a712576Cb3EE0885deda) |
| **MockUSDC** | `0x953E5610c73C989fE7C75D3D67bE0A1e44a8e797` | [View on Scrollscan](https://sepolia.scrollscan.com/address/0x953E5610c73C989fE7C75D3D67bE0A1e44a8e797) |
| **MockUSDT** | `0x13cF4E3e284d34C575CeeCCb0791Ca535A657da2` | [View on Scrollscan](https://sepolia.scrollscan.com/address/0x13cF4E3e284d34C575CeeCCb0791Ca535A657da2) |
| **MockWBTC** | `0xf12cd252CA50781EC88c2d8832cA4f9c4bF11D82` | [View on Scrollscan](https://sepolia.scrollscan.com/address/0xf12cd252CA50781EC88c2d8832cA4f9c4bF11D82) |
| **USDC Lending Pool** | `Coming Soon` | [View on Sui Explorer](https://testnet.suivision.xyz/package/0xf13ad32a2d462fd5afebf3a844a437b7b97046ebb1d181782b2f11216213ecca) |
| **sBTC Lending Pool** | `Coming Soon` | [View on Sui Explorer](https://testnet.suivision.xyz/object/) |
| **Borrow Controller** | `Coming Soon` | [View on Sui Explorer](https://testnet.suivision.xyz/object/) |

## 🔗 Explorer Links

- **Stacks Testnet Collateral-V1**: [Stacks Explorer](https://explorer.hiro.so/txid/STBGS8Y6KHWQ3D2P9BTQ83VBD3ZCK7BDTWMGJY5Z.collateral-v1?chain=testnet)
- **Stacks Testnet Lending-V1**: [Stacks Explorer](https://explorer.hiro.so/txid/STBGS8Y6KHWQ3D2P9BTQ83VBD3ZCK7BDTWMGJY5Z.lending-v1?chain=testnet)
- **Scroll Sepolia**: [Scrollscan Testnet](https://sepolia.scrollscan.com/)
- **Sui Testnet**: [Sui Explorer](https://explorer.sui.io/)

## 🚀 Quick Start

Expand All @@ -67,67 +66,71 @@ graph TB
- Node.js 18+ and npm/pnpm
- Git
- Stacks wallet (Hiro Wallet, Leather, etc.)
- MetaMask or compatible EVM wallet
- Sui wallet (Sui Wallet, Suiet, etc.)

### Installation

1. **Clone the repository**
```bash
git clone https://github.com/xfajarr/stacklend.git
cd stacklend
git clone https://github.com/xfajarr/hayy-protocol.git
cd hayy-protocol
```

2. **Install dependencies for each component**
```bash
# Frontend
cd stacklend-fe
cd hayyprotocol-fe
npm install

# Relayer
cd ../stacklend-relayer
# Backend/Relayer
cd ../hayyprotocol-backend
npm install

# Stacks contracts (optional, for development)
cd ../stacklend-stacks
cd ../hayyprotocol-stacks
npm install

# Sui contracts (optional, for development)
cd ../hayyprotocol-sui
npm install
```

3. **Configure environment variables**
```bash
# In stacklend-relayer/
# In hayyprotocol-backend/
cp .env.example .env
# Edit .env with your RPC URLs and private keys
```

4. **Start the development servers**
```bash
# Terminal 1: Start relayer
cd stacklend-relayer
# Terminal 1: Start backend/relayer
cd hayyprotocol-backend
npm start

# Terminal 2: Start frontend
cd stacklend-fe
cd hayyprotocol-fe
npm run dev
```

5. **Access the application**
- Frontend: http://localhost:5173
- Relayer API: http://localhost:3000
- Backend API: http://localhost:3000

## 💡 How It Works

1. **Deposit Collateral**: Users deposit STX tokens as collateral on Stacks blockchain
2. **Request Borrow**: Users specify the token and amount they want to borrow on EVM networks
1. **Deposit Collateral**: Users deposit STX or sBTC tokens as collateral on Stacks blockchain
2. **Request Borrow**: Users specify the amount of USDC they want to borrow on Sui blockchain
3. **Cross-Chain Processing**: The relayer monitors Stacks events and processes requests
4. **Token Minting**: EVM contracts mint/transfer requested tokens to user's EVM address
5. **Repayment**: Users repay borrowed tokens on EVM to unlock their STX collateral
4. **Token Minting**: Sui contracts mint/transfer requested USDC to user's Sui address
5. **Repayment**: Users repay borrowed USDC on Sui to unlock their STX/sBTC collateral

## 🛠️ Development

### Frontend Development

```bash
cd stacklend-fe
cd hayyprotocol-fe
npm run dev # Start development server
npm run build # Build for production
npm run lint # Run linting
Expand All @@ -137,24 +140,24 @@ npm run lint # Run linting

**Stacks Contracts:**
```bash
cd stacklend-stacks
cd hayyprotocol-stacks
clarinet check # Check contract syntax
clarinet test # Run tests
clarinet deploy # Deploy to testnet
```

**EVM Contracts:**
**Sui Contracts:**
```bash
cd stacklend-evm
forge build # Compile contracts
forge test # Run tests
forge script script/Deploy.s.sol --rpc-url $RPC_URL --broadcast # Deploy
cd hayyprotocol-sui
sui move build # Build contracts
sui client test # Run tests
sui client publish # Deploy to testnet
```

### Relayer Development
### Backend/Relayer Development

```bash
cd stacklend-relayer
cd hayyprotocol-backend
npm run dev # Start with hot reload
npm test # Run tests
npm run docker # Build Docker image
Expand All @@ -166,47 +169,24 @@ npm run docker # Build Docker image

1. **Get Testnet Tokens**
- STX: [Stacks Testnet Faucet](https://explorer.hiro.so/sandbox/faucet?chain=testnet)
- Scroll Sepolia ETH: [Scroll Faucet](https://sepolia.scroll.io/bridge)
- SUI: [Sui Testnet Faucet](https://faucet.sui.io/)

2. **Connect Wallets**
- Configure Stacks wallet for testnet
- Add Scroll Sepolia network to MetaMask
- Network Details:
- Name: Scroll Sepolia
- RPC URL: https://sepolia-rpc.scroll.io/
- Chain ID: 534351
- Currency: ETH
- Explorer: https://sepolia.scrollscan.com/
- Configure Sui wallet for testnet

3. **Test Flow**
- Deposit STX collateral
- Request token borrow
- Verify token receipt on EVM
- Deposit STX or sBTC collateral on Stacks
- Request USDC borrow on Sui
- Verify USDC receipt on Sui
- Test repayment flow

## 📚 Documentation

- [Frontend Integration Guide](./stacklend-fe/STACKS_INTEGRATION_README.md)
- [Stacks Contract Documentation](./stacklend-stacks/STACKS_INTEGRATION.md)
- [EVM Deployment Guide](./stacklend-evm/DEPLOYMENT.md)
- [Relayer Setup Guide](./stacklend-relayer/README.md)

## 🤝 Contributing

We welcome contributions! Please read our contributing guidelines and submit pull requests for any improvements.

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request

## 🔒 Security

- All smart contracts have been tested extensively
- Cross-chain transactions are validated by the relayer
- Multi-signature support for critical operations
- Regular security audits and updates
- [Frontend Integration Guide](./hayyprotocol-fe/README.md)
- [Stacks Contract Documentation](./hayyprotocol-stacks/README.md)
- [Sui Contract Documentation](./hayyprotocol-sui/README.md)
- [Backend Setup Guide](./hayyprotocol-backend/README.md)

## 📄 License

Expand Down
14 changes: 0 additions & 14 deletions hayyprotocol-fe/.env.example

This file was deleted.

18 changes: 17 additions & 1 deletion hayyprotocol-stacks/Clarinet.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
[project]
name = "stacklend"
name = "hayyprotocol"
description = ""
authors = []
telemetry = true
cache_dir = "./.cache"

<<<<<<< HEAD
[contracts.mock-sbtc-v1]
path = "contracts/mock-sbtc-v1.clar"
clarity_version = 3
epoch = "3.0"

[contracts.mock-oracle-v1]
path = "contracts/mock-oracle-v1.clar"
clarity_version = 3
epoch = "3.0"

[contracts.money-market-core]
path = "contracts/money-market-core.clar"
clarity_version = 3
=======
[contracts.collateral-v1]
path = "contracts/collateral-v1.clar"
clarity_version = 2
>>>>>>> 5a9a85724588c9f8cf2e1b0c0a39972081b8d1cd
epoch = "3.0"

[repl.analysis]
Expand Down
Loading