Skip to content

Sneekyboots/Stakra

Repository files navigation

Stakra: Decentralized Non-Custodial Credit Lines

Stakra (built by Verisafe Protocol) is a decentralized lending protocol providing non-custodial credit lines and Buy Now, Pay Later (BNPL) functionality on the BNB Chain. It leverages isolated smart vaults and a proprietary ZK-verified price oracle.

Ask Wiki for more technical details https://deepwiki.com/Sneekyboots/Stakra

🏗 System Overview

Stakra implements an isolated vault pattern where every user receives a dedicated CollateralVault contract instance. This eliminates shared pool risks and ensures that one user's liquidation or bad debt does not affect the rest of the protocol.

Core Architecture Components

Component Purpose Contract
Vault Factory The entry point that deploys isolated vaults for each user. VaultFactory.sol
Collateral Vaults Individual smart contracts holding BNB collateral and managing credit. CollateralVault.sol
Credit NFTs Portable ERC-721 tokens representing active credit lines (on opBNB). CreditNFT.sol
Price Oracle ZK-verified BNB/USD price feeds via commit-reveal schemes. VerisOracle.sol
Liquidation Engine Monitors vault health and executes swaps via PancakeSwap. LiquidationEngine.sol

🚀 Key Features

  • Isolated Vaults: Per-user contract deployment to mitigate contagion risk.
  • ZK-Oracle Technology: Powered by Veris, a proprietary ZK-style oracle for tamper-proof price data.
  • Non-Custodial: Users maintain control of collateral with an emergencyWithdraw() function.
  • Portable Credit: Credit lines are minted as NFTs on opBNB, allowing for ultra-low gas ($0.001) merchant payments.

📉 Risk Parameters & Numbers

  • LTV (Loan-to-Value) Ratio: 70% (Max credit issued against collateral).
  • Liquidation Threshold: 85% (Triggered when collateral value drops).
  • Protocol Fees: 0.5% on credit lines | 0.1% on liquidations.
  • Example: 0.5 BNB @ $350 ($175 collateral) → $122.50 Max Credit.

🛠 Developer Setup & Deployment

1. Installation

# Install Foundry
curl -L https://foundry.paradigm.xyz | bash && foundryup

# Clone and install dependencies
git clone <repo_url>
cd verisafe
forge install OpenZeppelin/openzeppelin-contracts

2. Deployment (BSC Testnet)

forge build
forge script script/Deploy.s.sol --rpc-url bsc_testnet --private-key $PRIVATE_KEY --broadcast --verify

3. Oracle Agent

cd agent
npm install ethers

# Submit live price or simulate a crash
node oracle-agent.js --price 210

🔄 User Flow

  1. Deploy Vault: User creates their personal vault via VaultFactory.
  2. Deposit: User locks BNB collateral into their specific vault.
  3. Request Credit: System verifies price via VerisOracle and issues a Credit NFT.
  4. Spend: Use the Credit NFT for BNPL/payments on opBNB.
  5. Liquidation: If LTV exceeds 85%, the LiquidationEngine swaps collateral on PancakeSwap to make the lender whole.

Note: Currently deployed on BSC Testnet (Chain 97). Frontend is built with Next.js; Liquidations utilize PancakeSwap pools.

Would you like me to create a technical deep-dive into the Veris ZK-Oracle logic next?

Verisafe Protocol

Non-custodial smart collateral for Web3 credit & BNPL on BNB Chain. Powered by Veris — our proprietary ZK event oracle.


Contracts

Contract Chain Purpose
VerisOracle.sol BSC ZK-style price oracle
CreditNFT.sol opBNB Portable credit guarantee NFT
VaultFactory.sol BSC Deploys one vault per user
CollateralVault.sol BSC Per-user isolated collateral vault
LiquidationEngine.sol BSC Auto-liquidation via PancakeSwap

Setup

# 1. Install Foundry
curl -L https://foundry.paradigm.xyz | bash && foundryup

# 2. Clone and install
git clone <your-repo>
cd verisafe
forge install OpenZeppelin/openzeppelin-contracts

# 3. Environment
cp .env.example .env
# Fill in PRIVATE_KEY and BSCSCAN_API_KEY

# 4. Get testnet BNB
# BSC:   https://testnet.bnbchain.org/faucet-smart
# opBNB: https://opbnb-testnet-faucet.bnbchain.org

Deploy

# Compile
forge build

# Deploy to BSC testnet
forge script script/Deploy.s.sol \
  --rpc-url bsc_testnet \
  --private-key $PRIVATE_KEY \
  --broadcast \
  --verify

# Copy the printed addresses into your .env

Oracle Agent

cd agent
npm install ethers

# Submit live BNB price to oracle
node oracle-agent.js

# DEMO: Simulate price crash to $210 (triggers liquidation)
node oracle-agent.js --price 210

# Continuous mode (60s updates)
node oracle-agent.js --continuous

Demo Flow (60 seconds)

1. forge script Deploy.s.sol --broadcast          # Deploy all contracts
2. node agent/oracle-agent.js                     # Seed price ($350)
3. [Frontend] Connect wallet → deployVault()      # Personal vault deployed
4. [Frontend] deposit(0.5 BNB)                    # BNB into vault
5. [Frontend] requestCredit(12250)                # $122.50 credit → NFT minted
6. [Frontend] creditNFT.spend(tokenId, 6000, merchant)  # Pay $60
7. node agent/oracle-agent.js --price 210         # Simulate crash
8. [Frontend] liquidationEngine.checkAndLiquidate(vault) # Auto-liquidation fires

Key Numbers

  • LTV ratio: 70% (credit issued at 70% of collateral value)
  • Liquidation threshold: 85% (auto-liquidates when LTV hits 85%)
  • BNB deposit: 0.5 BNB @ $350 = $175 collateral → $122.50 max credit
  • Liquidation trigger: BNB drops to ~$294 (35% crash)
  • opBNB gas per merchant check: $0.001
  • Protocol fee: 0.5% of credit lines + 0.1% of liquidations

Architecture

User Wallet
    │
    │ deployVault()
    ▼
VaultFactory ──deploys──► CollateralVault (per user)
                                │
                    deposit()   │   requestCredit()
                                │
                          VerisOracle
                          (ZK price proof)
                                │
                          CreditNFT minted
                          (on opBNB, $0.001)
                                │
                    [IF DEFAULT]│
                                ▼
                        LiquidationEngine
                        PancakeSwap swap
                        Lender made whole
                        Surplus → user

About

The smart lending protocol backed by Veri protocol

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors