Skip to content
Back to skills

Clawtrade Bnb

ASecurity

Autonomous DeFi trading agent for BNB Chain with multi-strategy engine, network switching, and reinforced learning.

  • 33 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 5, 2026
devopsbashreactnodegitapidatabasefrontendsecurityperformancedocumentation

Works with

  • terminal
  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 21 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add dvcrn/openclaw-skills-marketplace --skill clawtrade-bnb --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Clawtrade Bnb?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Clawtrade Bnb
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dvcrn-clawtrade-bnb-openclaw-skills-marketplace/badge)](https://www.skillsdirectory.com/skills/dvcrn-clawtrade-bnb-openclaw-skills-marketplace)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: clawtrade-bnb
description: "Autonomous DeFi trading agent for BNB Chain with multi-strategy engine, network switching, and reinforced learning."
---

# CawTrade BNB - Autonomous DeFi Trading Agent v1.1.0

**Production-ready autonomous trading agent** for BNB Chain testnet & mainnet. Features 3 intelligent strategies, real-time performance analytics, on-chain event logging, and self-improving reinforced learning.

## Core Features

### šŸ¤– Three Autonomous Strategies
1. **Compound Yield** - Auto-reinvest harvested rewards for exponential growth
2. **Rebalance** - Move capital from low-APR to high-APR vaults automatically
3. **Dynamic Harvest** - Intelligent harvesting based on gas cost optimization

### 🌐 Network Switching
- Instant testnet ↔ mainnet toggle (no restart)
- Separate configs per network (gas, thresholds, RPCs)
- Contract address mapping per chain
- Persistent network preferences

### šŸ“Š Real-Time Analytics
- Realized APR (actual, based on historical yields)
- Per-vault performance breakdown
- Strategy effectiveness scoring
- Success rate tracking (target: >90%)
- Failure pattern detection

### 🧠 Reinforced Learning
- Auto-learns from past failures
- Dynamically optimizes strategy parameters
- Adjusts thresholds based on success rates
- Confidence scoring per strategy
- Self-improving over time

### ā›“ļø On-Chain Event Logging
- All actions logged with TX hashes
- Auditable blockchain trail
- BNB Testnet Scanner links
- Complete execution history

### šŸŽ® Control Panel CLI
- Interactive command-line interface
- Network management commands
- Performance metrics dashboard
- Learning progress tracking
- Real-time optimization

## Installation & Setup

### 1. Install Skill
```bash
clawhub install clawtrade-bnb
cd ~/.openclaw/workspace/skills/clawtrade-bnb
npm install
```

### 2. Configure Environment
```bash
# Copy example config
cp config.deployed.json config.live.json

# Edit with your settings
nano config.live.json
# Set RPC endpoint, contract addresses, wallet
```

### 3. Set Private Key (Secure)
```bash
# Option A: Environment variable (recommended)
export PRIVATE_KEY="your_testnet_private_key"

# Option B: .env file (git-ignored)
echo "PRIVATE_KEY=your_key" >> .env

# NOTE: Never commit private keys!
```

### 4. Verify Setup
```bash
# Test connection and contracts
node agent-cli.js network status

# Check wallet balance
npm run verify
```

## Quick Start - 3 Commands

```bash
# Terminal 1: Run strategy engine (60-second cycles)
node strategy-scheduler.js

# Terminal 2: Real-time dashboard
npm run dev:dashboard
# → Open http://localhost:5173

# Terminal 3: Control panel
node agent-cli.js

# Example commands:
node agent-cli.js network testnet        # Switch network
node agent-cli.js perf summary           # See performance
node agent-cli.js learn now              # Optimize strategies
```

## Architecture

```
DeFi Strategy Engine
ā”œā”€ Compound Yield Strategy
│  └─ Harvest when pending > $25 → Re-deposit
ā”œā”€ Rebalance Strategy
│  └─ Move 20% from low-APR to high-APR vault
└─ Dynamic Harvest Strategy
   └─ Harvest only if pending > 2x gas cost

         ↓ (runs every 60 seconds)

Strategy Scheduler
ā”œā”€ Read vault APRs & pending rewards
ā”œā”€ Execute all 3 strategies
└─ Log actions + TX hashes

         ↓ (logs to blockchain)

On-Chain Logger
ā”œā”€ execution-log.jsonl (append-only)
ā”œā”€ performance-metrics.json (cumulative)
└─ learning-state.json (optimization history)

         ↓ (analyzes continuously)

Reinforced Learning System
ā”œā”€ Tracks success rates per strategy
ā”œā”€ Detects failure patterns
ā”œā”€ Auto-adjusts thresholds
└─ Generates improvement reports

         ↓ (displays real-time)

Dashboard + Control Panel
ā”œā”€ React dashboard (http://localhost:5173)
ā”œā”€ Agent CLI (network, perf, learn commands)
└─ Performance API (/api/logs, /api/health)
```

## Configuration Files

**config.deployed.json** - Contract addresses & ABIs
```json
{
  "chainId": 97,
  "network": "BNB Testnet",
  "contracts": [
    {
      "vaultId": "vault_eth_staking_001",
      "address": "0x588eD88A145144F1E368D624EeFC336577a4276b",
      "strategy": "Ethereum 2.0 Staking",
      "risk_score": 0.3
    }
  ]
}
```

**config.scheduler.json** - Strategy thresholds
```json
{
  "scheduler": {
    "execution_interval_seconds": 60,
    "enabled": true
  },
  "agent": {
    "harvest_threshold_usd": 25,
    "rebalance_apr_delta": 2.0,
    "max_allocation_percent": 0.35,
    "min_confidence": 0.6
  }
}
```

## Strategy Decision Logic

Each 60-second cycle:

1. **COMPOUND YIELD**
   - Check pending rewards per vault
   - If pending ≄ $25 → Harvest + Re-deposit
   - Log action with TX hash

2. **REBALANCE**
   - Compare APRs across all vaults
   - If top APR > bottom APR by ≄ 2% → Rebalance
   - Move 20% from worst to best vault
   - Log action with TX hash

3. **DYNAMIC HARVEST**
   - Estimate gas cost per harvest
   - Only harvest if pending > 2x gas cost
   - Maximize profitability per action
   - Log action with TX hash

**Example Output:**
```
Cycle #42 @ 2026-02-18T18:00:00Z
āœ“ vault_eth_staking_001: COMPOUND ($45.50 harvested)
āœ“ vault_high_risk_001: REBALANCE (2.1% APR delta)
āœ“ vault_link_oracle_001: HARVEST ($12.30 pending)
āœ… Total Rewards: $57.80 | Compounded: $45.50
```

## CLI Commands

### Network Management
```bash
node agent-cli.js network status      # Current network config
node agent-cli.js network testnet     # Switch to testnet
node agent-cli.js network mainnet     # Switch to mainnet (āš ļø production)
```

### Performance Monitoring
```bash
node agent-cli.js perf summary        # Quick stats
node agent-cli.js perf report         # Detailed analysis
node agent-cli.js perf vaults         # Per-vault breakdown
node agent-cli.js perf strategies     # Strategy effectiveness
```

### Reinforced Learning
```bash
node agent-cli.js learn now           # Analyze & optimize
node agent-cli.js learn report        # View improvements
node agent-cli.js learn reset         # Reset learning state
```

## Supported Networks

| Network | Chain ID | Use Case | Harvest Min | Gas Multiplier |
|---------|----------|----------|-------------|----------------|
| BNB Testnet | 97 | Development | $25 | 1.2x |
| BNB Mainnet | 56 | Production | $100 | 1.5x |

## Network Switching

Switch instantly without restarting:
```bash
# Current config
node agent-cli.js network status
# → BNB Testnet

# Switch to production
node agent-cli.js network mainnet
# → Updated RPC, contract addresses, and thresholds

# All settings updated automatically
```

## Security & Safety

### On-Chain Auditing
- āœ… Every action logged with transaction hash
- āœ… Blockchain verification via BNB Testnet/Mainnet Scanner
- āœ… Append-only execution log (execution-log.jsonl)
- āœ… Complete audit trail for compliance

### Risk Management
- āœ… Deterministic decision logic (reproducible, auditable)
- āœ… Success rate monitoring (>90% target)
- āœ… Confidence thresholds per strategy
- āœ… Graceful error handling & recovery
- āœ… Automatic parameter optimization via learning

### Private Key Security
- āœ… Never hardcoded - use environment variables only
- āœ… .env file git-ignored
- āœ… Testnet for development, mainnet when ready
- āœ… For production: use hardware wallet support (future)

## File Structure

```
clawtrade-bnb/
ā”œā”€ā”€ defi-strategy-engine.js          # 3 strategies (compound, rebalance, harvest)
ā”œā”€ā”€ on-chain-logger.js                # Event logging with TX hashes
ā”œā”€ā”€ strategy-scheduler.js              # Main loop (60s cycles)
ā”œā”€ā”€ network-switcher.js                # Testnet ↔ mainnet toggle
ā”œā”€ā”€ performance-analytics.js           # Real APR & metrics
ā”œā”€ā”€ reinforced-learning.js             # Self-improving parameters
ā”œā”€ā”€ agent-cli.js                       # Control panel
ā”œā”€ā”€ dashboard/                         # React frontend (real-time)
ā”œā”€ā”€ contracts/                         # Vault smart contracts
ā”œā”€ā”€ config.deployed.json               # Contract addresses & ABIs
ā”œā”€ā”€ config.scheduler.json              # Strategy thresholds
ā”œā”€ā”€ execution-log.jsonl                # Action history (generated)
ā”œā”€ā”€ performance-metrics.json           # Metrics (generated)
ā”œā”€ā”€ learning-state.json                # Learning progress (generated)
ā”œā”€ā”€ README.md                          # User guide
ā”œā”€ā”€ README_STRATEGY.md                 # Strategy details
ā”œā”€ā”€ README_ADVANCED.md                 # Network switching & learning
ā”œā”€ā”€ SKILL.md                           # This file
└── package.json                       # Dependencies
```

## Integration with Other Skills

This is a **standalone, complete skill**. It can also integrate with:

- **Telegram Notifications** - Send alerts to OpenClaw users
- **Email Reports** - Daily performance summaries
- **Database Logging** - Store metrics in persistent DB
- **Webhook Integrations** - Trigger external services

## Documentation

| File | Purpose |
|------|---------|
| `README.md` | Complete user guide |
| `README_STRATEGY.md` | Strategy details & examples |
| `README_ADVANCED.md` | Network switching & reinforced learning |
| `SKILL.md` | This installation & architecture guide |

## What You Get

āœ… **Production-ready code** (tested, documented, error-handling)
āœ… **3 profitable strategies** (auto-optimizing, self-learning)
āœ… **Real-time dashboard** (React, live updates)
āœ… **CLI control panel** (manage from terminal)
āœ… **On-chain logging** (auditable, transparent)
āœ… **Network switching** (testnet → mainnet in seconds)
āœ… **Self-improvement** (learns from failures automatically)
āœ… **Complete documentation** (guides, examples, FAQ)

## Replicating This Skill

For someone else to replicate:

1. **Install**
   ```bash
   clawhub install clawtrade-bnb
   npm install
   ```

2. **Configure**
   ```bash
   # Edit config files with your contracts & RPC
   nano config.deployed.json
   ```

3. **Deploy Contracts** (if using new vaults)
   ```bash
   cd contracts && npm run deploy:testnet
   ```

4. **Run**
   ```bash
   node strategy-scheduler.js      # Main engine
   npm run dev:dashboard           # Dashboard
   node agent-cli.js               # Control panel
   ```

5. **Monitor**
   - Dashboard: http://localhost:5173
   - Logs: execution-log.jsonl
   - Analytics: node agent-cli.js perf report

**Total setup time: ~15 minutes**

## Support & Community

- GitHub Issues: https://github.com/open-web-academy/clawtrade-bnb-bnb
- ClawHub: https://clawhub.com (search: clawtrade-bnb)
- Discord: https://discord.com/invite/clawd

## Version History

- **v1.1.0** (2026-02-18) - Network switcher, analytics, reinforced learning, CLI
- **v1.0.0** (2026-02-17) - Initial release, 3 strategies, on-chain logging

## License

MIT - Free to use, modify, and distribute

Files in this skill

  • COMPLETION_REPORT.md10.3 KB
  • DASHBOARD_IMPLEMENTATION_PLAN.md4.3 KB
  • DEPLOYMENT.md2.8 KB
  • DEPLOYMENT_READY.md5.9 KB
  • EXAMPLES.md7 KB
  • FILES_MANIFEST.md7.5 KB
  • FINAL_CHECKLIST.md8.3 KB
  • FINAL_SUMMARY.md16 KB
  • INTEGRATION_GUIDE.md11.5 KB
  • INTEGRATION_MANIFEST.md12.9 KB
  • LIVE_EXECUTION_GUIDE.md11.1 KB
  • QUICKSTART.md5.9 KB
  • QUICK_TEST.md1.9 KB
  • README.md8.9 KB
  • README_ADVANCED.md9.3 KB
  • README_SKILL.md8.4 KB
  • README_STRATEGY.md6.1 KB
  • REDESIGN_DELIVERY.md14.4 KB
  • REPLICATION_GUIDE.md11.6 KB
  • RESPUESTAS_PREGUNTAS.md12.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…