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
30 changes: 14 additions & 16 deletions Clarinet.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
[project]
name = "BitYield"
description = ""
name = 'BitYield'
description = ''
authors = []
telemetry = true
cache_dir = "./.cache"

# [contracts.counter]
# path = "contracts/counter.clar"

cache_dir = './.cache'
requirements = []
[contracts.bit-yield]
path = 'contracts/bit-yield.clar'
clarity_version = 3
epoch = 3.1
[repl.analysis]
passes = ["check_checker"]
check_checker = { trusted_sender = false, trusted_caller = false, callee_filter = false }
passes = ['check_checker']

# Check-checker settings:
# trusted_sender: if true, inputs are trusted after tx_sender has been checked.
# trusted_caller: if true, inputs are trusted after contract-caller has been checked.
# callee_filter: if true, untrusted data may be passed into a private function without a
# warning, if it gets checked inside. This check will also propagate up to the
# caller.
# More informations: https://www.hiro.so/blog/new-safety-checks-in-clarinet
[repl.analysis.check_checker]
strict = false
trusted_sender = false
trusted_caller = false
callee_filter = false
120 changes: 120 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# BitYield Pro Smart Contract Documentation

[![Clarity Version](https://img.shields.io/badge/Clarity-2.0-blue)](https://docs.stacks.co/docs/clarity/)

## Overview

BitYield Pro is a decentralized yield optimization protocol built on Stacks L2, enabling automated yield generation on Bitcoin-native assets through strategic allocation across multiple DeFi protocols while maintaining strict compliance with Bitcoin security standards.

## Key Features

- Multi-Protocol Yield Strategies
- Dynamic TVL Allocation Engine
- SIP-010 Token Standard Compliance
- Institutional-grade Risk Parameters
- Emergency Shutdown Mechanism
- Transparent Fee Structure (1% Platform Fee)
- Deposit Limits Enforcement ($50-$10M equivalent in sats)

## Technical Specifications

### Contract Architecture

- **Language**: Clarity 2.0
- **Base Token**: SATs (1:1 Bitcoin-pegged)
- **Key Variables**:
- `total-tvl`: Global Total Value Locked
- `platform-fee-rate`: 1% (100 basis points)
- `min-deposit`: 100,000 sats (~$50)
- `max-deposit`: 1,000,000,000 sats (~$10M)

### SIP-010 Integration

```clarity
(define-trait sip-010-trait
((transfer (uint principal principal (optional (buff 34))) (response bool uint))
(get-balance (principal) (response uint uint))
(get-decimals () (response uint uint))
(get-name () (response (string-ascii 32) uint))
(get-symbol () (response (string-ascii 32) uint))
(get-total-supply () (response uint uint))))
```

## Core Functionality

### 1. Deposit/Withdrawal Management

- **Deposit Flow**:

1. SIP-010 token validation
2. Min/max deposit checks
3. Cross-protocol allocation
4. TVL update
5. Auto-rebalancing

- **Withdrawal Process**:
- Instant redemptions
- Protocol-level liquidity checks
- Proportional claim calculation

### 2. Yield Strategy Management

```clarity
(define-map protocols
{ protocol-id: uint }
{ name: (string-ascii 64), active: bool, apy: uint })

(define-map strategy-allocations
{ protocol-id: uint }
{ allocation: uint }) ;; Basis points (100 = 1%)
```

### 3. Reward Calculation

- APY-based compounding
- Block-height weighted returns
- Fee-adjusted payouts:
```clarity
(/ (* (get amount user-deposit) weighted-apy blocks)
(* u10000 u144 u365))
```

### 4. Protocol Administration

- **Access Control**: Contract owner privileges
- **Protocol Lifecycle**:
```clarity
(define-public (add-protocol (protocol-id uint) (name (string-ascii 64)) (apy uint))
(asserts! (is-contract-owner) ERR-NOT-AUTHORIZED)
(map-set protocols { protocol-id: protocol-id }
{ name: name, active: true, apy: apy }))
```

## Security Architecture

### Risk Management

- **Emergency Shutdown**:
```clarity
(define-data-var emergency-shutdown bool false)
```
- **Protocol Whitelisting**:
```clarity
(define-map whitelisted-tokens
{ token: principal }
{ approved: bool })
```

### Validation Framework

- APY Range: 0-100% (0-10,000 bps)
- Protocol ID Validation: 1-100
- Deposit Sanity Checks:
```clarity
(asserts! (>= amount (var-get min-deposit)) ERR-MIN-DEPOSIT-NOT-MET)
(asserts! (<= amount (var-get max-deposit)) ERR-MAX-DEPOSIT-REACHED)
```

```

```
Loading