Skip to main content
Glama
README.md
<div align="center">

# ⚑ Grok World Orchestrator

**Autonomous DeFi Yield Autopilot for Worldcoin Mini Apps**

[![Status](https://img.shields.io/badge/status-production-BEFF00?style=for-the-badge)]()
[![World Chain](https://img.shields.io/badge/chain-World%20Chain-000000?style=for-the-badge)]()
[![License](https://img.shields.io/badge/license-MIT-FAFAFA?style=for-the-badge)]()

*Verified humans only. Zero-friction. AI-driven. 24/7 autonomous.*

</div>

---

## 🎯 What it does

Idle WLD/USDC in World App β†’ automatically deployed to the highest-yield, risk-adjusted Morpho Blue market on World Chain, continuously monitored and rebalanced by an autonomous Grok-powered worker.

Sign once. Earn forever. Verified by World ID. No bots. No seed phrases.

---

## πŸ—οΈ Architecture

```
World App (Mini App)
    ↓  MiniKit.signMessage (EIP-191)
Vercel Edge (Next.js 15)
    ↓  POST /api/inference
Railway API (Grok + Gemini fallback)
    ↓  DecisionZ β†’ BullMQ
Railway Worker (24/7)
    β”œβ”€ Morpho Blue executor (viem)
    β”œβ”€ APY monitor (60s loop)
    β”œβ”€ Auto-rebalance engine
    └─ Session-key withdrawals (ERC-4337)
    ↓
PostgreSQL + Redis + Prometheus + Grafana
```

---

## πŸš€ Quick Deploy (production)

```bash
# 1. Repo
gh repo create grok-world-orchestrator --private --clone && cd grok-world-orchestrator

# 2. Merge monorepo
git remote add fincloud ../fincloud-mono
git fetch fincloud
git merge fincloud/main --allow-unrelated-histories -m "chore: merge fincloud-mono"

# 3. Railway (API + Worker β€” set Root Directory per service)
railway link && railway up

# 4. Vercel (Mini App + Dashboard)
cd apps/web && vercel --prod
```

**Required env vars (Railway):** `EXECUTOR_PK`, `WORLD_CHAIN_RPC`, `DATABASE_URL`, `REDIS_URL`, `XAI_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`, `BACKEND_INTERNAL_KEY`, `CALLBACK_HMAC_SECRET`.

**Required env vars (Vercel):** `NEXT_PUBLIC_WORLD_APP_ID`, `NEXT_PUBLIC_API_URL`.

---

## πŸ” Security

| Layer | Defense |
|-------|---------|
| Auth | EIP-191 via `viem.verifyMessage` + nonce + 5min TTL |
| Rate | Redis 10 req/min per IP+address |
| Secrets | Railway/Vercel encrypted, never in code, rotated 90d |
| Contracts | Morpho Blue `0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb` (audited) |
| Exec | maxAmount cap, minAPY 4.5%, maxSlippage 0.5%, Safe + 48h timelock |
| CI | Slither + Mythril + Foundry invariants 100k runs + TruffleHog |
| Headers | CSP, XFO, XXSS, Referrer-Policy strict |
| Kill-switch | `GLOBAL_PAUSE=true` via Railway β†’ instant halt |

---

## πŸ“Š APIs

| Endpoint | Description |
|----------|--------------|
| `POST /api/inference` | Sign β†’ Grok decision β†’ auto-queue |
| `GET /api/health` | DB + Redis + LLM status |
| `GET /api/decisions/recent?risk=high&limit=10` | Recent decisions feed |
| `GET /api/decisions/:id` | Decision detail + execution result |
| `POST /api/decisions/:id/resolve` | Approve/block manual override |

---

## 🎨 Design System

```ts
font: PP Neue Montreal + SΓΆhne + JetBrains Mono
color: #0A0A0A / #FAFAFA / #BEFF00 (acid accent) / #FF2D75 (danger)
motion: Framer Motion spring (380/30), 160-240ms transitions
shadow: 0 0 80px rgba(190,255,0,0.15) glow
```

Reference tier: Linear Β· Arc Β· Rainbow Β· Phantom Β· Family.

---

## 🌏 Growth mechanics

- **Red envelopes (ηΊ’εŒ…)** β€” Friday 20:00 CET random WLD airdrop to top 100 active users
- **Group buying** β€” +0.5% APY boost when 3 World-ID-verified friends deposit
- **Lucky draw** β€” 1 ticket per $10 deposited, weekly $1K WLD prize
- **Live counter** β€” Server-Sent Events feed: "X users earned Y WLD today"
- **Super-app** β€” yield β†’ swap β†’ lend β†’ insurance in one mini app

---

## πŸ“ˆ Metrics & Observability

- Grafana dashboards: queue backlog, failed jobs, inference P95, risk distribution
- Prometheus alerts: backlog >20, failed >10%/h, latency >10s
- Pino structured logs with secret redaction

---

## πŸ—ΊοΈ Roadmap

| Phase | Milestone |
|-------|-----------|
| Week 1 | Mainnet launch, invite-only 1K verified users |
| Week 4 | Public launch + Layer3 quest + Galxe campaign |
| Month 2 | Featured in World App store |
| Month 3 | Multi-protocol expansion (Aave + Pendle + Re7) |
| Month 6 | Insurance vault + social yield boost |
| Month 12 | Full super-app: swap + lending + insurance |

---

## πŸ§ͺ Local development

```bash
pnpm install
pnpm --filter backend prisma generate
pnpm --filter backend prisma db push
pnpm --filter backend prisma db seed
docker compose up -d
curl localhost:3001/api/health  # βœ… healthy
```

---

## πŸ›‘ Emergency

```bash
railway variables set GLOBAL_PAUSE=true --service backend --service worker
# Smart contract: guardian.pause() via Safe (instant)
```

---

## πŸ“¦ Monorepo structure

```
grok-world-orchestrator/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ web/         β†’ Mini App (Vercel, Next.js 15)
β”‚   β”œβ”€β”€ api/         β†’ Backend (Railway, Route Handlers)
β”‚   β”œβ”€β”€ worker/      β†’ Autonomous executor (Railway, BullMQ)
β”‚   └── dashboard/   β†’ Ops dashboard (Vercel)
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ shared/      β†’ Zod schemas, prompts, verifySignature
β”‚   β”œβ”€β”€ ui/          β†’ Design tokens + components
β”‚   └── queue/       β†’ BullMQ wrappers
β”œβ”€β”€ infra/
β”‚   β”œβ”€β”€ prometheus/  β†’ metrics config
β”‚   └── grafana/     β†’ provisioning
β”œβ”€β”€ prisma/          β†’ schema + seed
β”œβ”€β”€ .github/workflows/ β†’ ci.yml + deploy.yml + audit.yml
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ turbo.json
└── README.md
```

---

## πŸ“œ License

MIT Β© 2026 Luis Felipe Vega Rodriguez

---

<div align="center">

**Built for the 25M+ verified humans on World App.**

[Worldcoin](https://worldcoin.org) Β· [Morpho](https://morpho.org) Β· [Railway](https://railway.app) Β· [Vercel](https://vercel.com)

</div>