Skip to content

papadking/opusd-protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OPUSD — Bitcoin-Native Stablecoin Protocol

OPUSD is a Liquity-inspired CDP (Collateralized Debt Position) stablecoin protocol built natively on Bitcoin L1 via OPNet.

Users deposit OP20 collateral tokens, mint OPUSD stablecoins at a minimum 150% collateral ratio, and face automated liquidations when undercollateralized. The protocol uses a pull-oracle model with ML-DSA signed price feeds.

Live demo: http://46.225.141.46

Architecture

Smart Contracts (AssemblyScript → WASM, deployed on OPNet testnet)
├── TestBTC     — OP20 test collateral token
├── OPUSD       — Stablecoin token (mint/burn controlled by VaultManager)
├── PriceFeed   — Pull oracle with ML-DSA signature verification
└── VaultManager — Core protocol: vaults, liquidation, redemption

Off-Chain Services
├── Price Signer  — Fetches BTC/USD from Binance/CoinGecko/Coinbase, signs with ML-DSA
└── Liquidator Bot — Monitors vault health, flags and liquidates undercollateralized positions

Frontend (React + Vite)
└── Dashboard, Vault Management, Liquidations, Redemptions

Deployed Contracts (OPNet Testnet)

Contract Address
TestBTC opt1sqrke7nyr4n80w5mmzj9jnp5jfk4cpyappudkd95q
OPUSD opt1sqrfm9yvlx5euseap7ks3686mchzsudgnvudk7qfe
PriceFeed opt1sqrnlmcwxa3hsyy6gvkpergcyyldemp5pxgphhhrd
VaultManager opt1sqr3gjs3ys2l73nsq27uju7dyngmtn73lkczunhmr

How It Works

  1. Deposit collateral — Lock OP20 tokens in a vault
  2. Mint OPUSD — Borrow stablecoins against your collateral (min 150% ratio)
  3. Oracle prices — Frontend fetches signed BTC/USD price from the price signer API and includes it in transaction calldata
  4. Liquidation — If a vault drops below 110% collateral ratio, it can be flagged. After a 3-block grace period (~30 min), a Dutch auction liquidation begins
  5. Redemption — OPUSD can be redeemed for $1 worth of collateral from the lowest-ratio vault (hard peg mechanism)

Protocol Parameters

Parameter Value
Min Collateral Ratio 150%
Liquidation Threshold 110%
Liquidation Grace Period 3 blocks (~30 min)
Auction Duration 6 blocks (~1 hour)
Max Liquidation Discount 10%
Origination Fee 0.5%
Redemption Fee 0.5%
Min Debt 100 OPUSD
Oracle Staleness 12 blocks (~2 hours)
Price Precision 6 decimals

Project Structure

opusd-protocol/
├── contracts/          # AssemblyScript smart contracts
│   └── src/
│       ├── testbtc/        # Test collateral token
│       ├── opusd/          # Stablecoin token
│       ├── pricefeed/      # Pull oracle
│       └── vaultmanager/   # Core protocol logic
├── services/
│   ├── price-signer/   # Off-chain price signing service
│   └── liquidator-bot/ # Off-chain liquidation bot
├── frontend/           # React frontend
├── deploy/             # Deployment scripts
└── PLAN.md             # Full technical specification

Running Locally

Contracts

cd contracts && npm install && npm run build

Price Signer

cd services/price-signer && npm install
MNEMONIC="your mnemonic here" npm start

Frontend

cd frontend && npm install && npm run dev

Key Design Decisions

  • Pull oracle — Users submit signed prices with transactions (zero ongoing oracle cost)
  • ML-DSA signatures — Post-quantum secure price attestations
  • Slow liquidation — Grace period + Dutch auction embraces Bitcoin's 10-min blocks
  • Liquity-style redemption — Hard peg mechanism targeting lowest-ratio vaults
  • Single collateral v1 — Designed for multi-collateral upgrade path

Tech Stack

  • Smart contracts: AssemblyScript (compiled to WASM) on OPNet
  • Cryptography: ML-DSA (post-quantum) via @btc-vision/transaction
  • Frontend: React 19 + Vite + @btc-vision/walletconnect
  • Price feeds: Binance, CoinGecko, Coinbase (median price)
  • Network: OPNet Testnet (networks.opnetTestnet)

Security

  • All arithmetic uses u256 SafeMath (no floating point)
  • Checks-Effects-Interactions pattern on all state mutations
  • ML-DSA signature verification with staleness and deviation bounds
  • Reentrancy guards on VaultManager
  • Domain-separated price hashing (prevents cross-contract replay)

Built for the vibecode.finance Week 3 hackathon — #opnetvibecode

About

OPUSD Protocol Specifications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages