Skip to content

collinsville22/privacybridge

Repository files navigation

Privacy Bridge

A DeFi platform that connects Zcash (ZEC) to multiple blockchain ecosystems. Privacy Bridge enables users to use ZEC for lending, staking, payments, and trading across chains via NEAR Protocol.

Prototype Notice: This project is currently a prototype and is not production-ready. It is intended for educational purposes, testing, and development.


Demo

Privacy Bridge Demo

Click the image above to watch the demo video


Features

ZEC/USDC Lending

Use ZEC as collateral to borrow USDC on NEAR Protocol.

  • Deposit ZEC via Defuse Bridge
  • ZEC held in NEAR Intents contract
  • Real-time pricing via Pyth Oracle
  • Automated liquidation system

Staking

Stake ZEC into various DeFi protocols across chains.

  • Marinade (Solana) - Liquid staking for SOL
  • Jito (Solana) - MEV-powered staking
  • Lido (Ethereum) - Liquid staking for ETH
  • Linear (NEAR) - NEAR liquid staking
  • Automatic conversion via OneClick SDK

Payments

Accept crypto payments and receive ZEC.

  • Create payment requests with USD amounts
  • Accept 100+ tokens across multiple chains
  • Automatic conversion to ZEC shielded addresses
  • QR codes and shareable payment links

Polymarket Trading

Trade on prediction markets using ZEC.

  • Access Polymarket from NEAR account
  • Derived Polygon addresses via Chain Signatures
  • Buy/sell outcome tokens
  • Withdraw winnings to ZEC

Hyperliquid Trading

Trade perpetual futures using ZEC.

  • Access Hyperliquid from NEAR account
  • Derived Arbitrum addresses via Chain Signatures
  • Leverage trading up to 50x
  • Deposit ZEC, withdraw to ZEC

Architecture

                              ┌─────────────────────────────────────┐
                              │          Privacy Bridge             │
                              │           (NEAR-based)              │
                              └─────────────────────────────────────┘
                                              │
           ┌──────────────┬─────────────┬─────┴─────┬─────────────┬──────────────┐
           │              │             │           │             │              │
           ▼              ▼             ▼           ▼             ▼              ▼
    ┌────────────┐ ┌────────────┐ ┌──────────┐ ┌─────────┐ ┌───────────┐ ┌────────────┐
    │   Defuse   │ │   NEAR     │ │  Staking │ │Polymarket│ │Hyperliquid│ │  Payments  │
    │   Bridge   │ │  Intents   │ │ Protocols│ │ (Polygon)│ │ (Arbitrum)│ │  (Multi)   │
    └────────────┘ └────────────┘ └──────────┘ └─────────┘ └───────────┘ └────────────┘
         │              │             │           │             │              │
         ▼              ▼             ▼           ▼             ▼              ▼
       Zcash         Lending      Marinade    Prediction    Perpetual      OneClick
      Network        Markets       Jito        Markets       Futures         SDK
                                   Lido
                                  Linear

Core Technologies

Component Technology Purpose
Defuse Bridge Cross-chain bridge ZEC deposits to NEAR
NEAR Intents Token standard Unified ZEC tokens on NEAR
Chain Signatures MPC signing Cross-chain transaction signing
OneClick SDK Swap aggregator Cross-chain token conversions
Pyth Oracle Price feeds Real-time asset prices

Technology Stack

Backend

  • Runtime: Node.js 20 LTS
  • Framework: Fastify with rate limiting and CORS
  • Database: PostgreSQL 16 with Prisma ORM
  • Queue: Redis with BullMQ
  • Logging: Pino for structured JSON logs

Frontend

  • Framework: Next.js 14 with App Router
  • UI: React 18, TailwindCSS, Lucide icons
  • State: Zustand for client state, React Query for server state
  • Wallets: NEAR Wallet Selector, Wagmi, Solana Wallet Adapter

Smart Contracts

  • Language: Rust with NEAR SDK v5.5
  • Standards: NEP-141 (Fungible Token)
  • Testing: Workspaces-based integration tests

Getting Started

Prerequisites

  • Node.js 20 or higher
  • Docker and Docker Compose
  • Rust toolchain (for contracts)
  • PostgreSQL 16

Quick Start

# Clone the repository
git clone https://github.com/collinsville22/privacybridge.git
cd privacy-bridge

# Run setup script
./scripts/setup-testnet.sh

# Start backend
cd backend && npm run dev

# Start frontend (new terminal)
cd frontend && npm run dev

The frontend will be available at http://localhost:3000 and the API at http://localhost:3005.


API Reference

Lending

Method Endpoint Description
GET /api/lending/markets Get lending markets
GET /api/lending/prices Get asset prices
GET /api/lending/accounts/:id/positions Get user positions

Staking

Method Endpoint Description
GET /api/staking/protocols List staking protocols
POST /api/staking/positions Create staking position
GET /api/staking/positions/:account Get user positions
POST /api/staking/unstake Initiate unstake

Payments

Method Endpoint Description
POST /api/payments/create Create payment request
GET /api/payments/:id Get payment details
GET /api/payments/tokens List accepted tokens
POST /api/payments/prepare-deposit Prepare deposit address

Polymarket

Method Endpoint Description
GET /api/polymarket/events Get prediction events
GET /api/polymarket/markets/:id Get market details
POST /api/polymarket/orders Place order
GET /api/polymarket/balances/:account Get balances

Hyperliquid

Method Endpoint Description
GET /api/hyperliquid/meta Get exchange metadata
GET /api/hyperliquid/prices Get all prices
POST /api/hyperliquid/orders Place order
POST /api/hyperliquid/deposit Create deposit
POST /api/hyperliquid/withdraw Create withdrawal

Defuse/Intents

Method Endpoint Description
POST /api/defuse/deposit-address Get ZEC deposit address
GET /api/intents/balance Get ZEC balance on NEAR
POST /api/intents/collateral-tx Deposit to lending
POST /api/intents/withdrawal-tx Withdraw ZEC

Project Structure

privacy-bridge/
├── backend/                 # API server
│   ├── src/
│   │   ├── config/          # Configuration
│   │   ├── routes/          # API endpoints
│   │   │   ├── lending.ts
│   │   │   ├── staking.ts
│   │   │   ├── payments.ts
│   │   │   ├── polymarket.ts
│   │   │   ├── hyperliquid.ts
│   │   │   ├── defuse.ts
│   │   │   └── intents.ts
│   │   ├── services/        # Business logic
│   │   │   ├── lending/     # Lending market
│   │   │   ├── staking/     # Staking protocols
│   │   │   ├── polymarket/  # Prediction markets
│   │   │   ├── hyperliquid/ # Perpetual futures
│   │   │   ├── defuse/      # Defuse bridge
│   │   │   ├── intents/     # NEAR Intents
│   │   │   ├── chain-signatures/  # MPC signing
│   │   │   ├── oneclick/    # Cross-chain swaps
│   │   │   └── liquidator/  # Lending liquidation
│   │   └── workers/         # Background jobs
│   └── prisma/              # Database schema
├── frontend/                # Web application
│   ├── app/
│   │   ├── lending/         # Lending page
│   │   ├── staking/         # Staking page
│   │   ├── trading/         # Trading page
│   │   ├── payment/         # Create payment
│   │   └── pay/[id]/        # Pay request
│   ├── components/          # React components
│   └── lib/                 # Utilities
├── contracts/               # NEAR smart contracts
│   ├── lending-common/      # Shared lending types
│   └── lending-market/      # Lending market
├── docker/                  # Docker configs
└── scripts/                 # Setup scripts

Configuration

Environment Variables

Variable Description
NETWORK Network: testnet or mainnet
PORT API server port
DATABASE_URL PostgreSQL connection
REDIS_URL Redis connection
NEAR_OPERATOR_PRIVATE_KEY NEAR operator key
ONECLICK_JWT OneClick API token

See .env.example for complete list.


Testnet Resources

Chain Faucet Explorer
Zcash TAZ Faucet Explorer
NEAR Testnet Faucet NearBlocks
Solana Devnet Faucet Explorer

License

This project is licensed under the MIT License - see the LICENSE file for details.


Disclaimer

This software is provided "as is" without warranty of any kind. This is a prototype implementation intended for educational and testing purposes. Do not use with real funds without proper security audits.


Contact

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages