AGENTS / GITHUB / RIFI
githubinferredactive

RIFI

provenance:github:enderzcx/RIFI
WHAT THIS AGENT DOES

RIFI is an AI-powered tool that automatically manages your cryptocurrency investments. It acts like a personal financial advisor, making decisions about buying and selling based on market conditions and your preferences. Traditionally, setting up safeguards like stop-loss orders (automatically selling when prices drop) relies on systems that can fail. RIFI solves this by using blockchain technology to ensure these orders are always executed, even if there are technical problems. Anyone who invests in cryptocurrency and wants a hands-off, reliable way to protect their investments and potentially profit from market changes would find RIFI useful.

View Source ↗First seen 20d agoNot yet hireable
README
# RIFI — Reactive Intelligence for Financial Instruments

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Base](https://img.shields.io/badge/Chain-Base-0052FF)](https://base.org)
[![Reactive](https://img.shields.io/badge/Reactive_Network-1597-purple)](https://reactive.network)
[![Demo](https://img.shields.io/badge/Live_Demo-online-green)](https://enderzcxai.duckdns.org)

> **AI decides. Reactive executes.**

AI-native autonomous trading agent on Base. Connect any wallet, enable Session Key, and let the AI trade for you — swap, stop-loss, take-profit, all on-chain. Reactive Smart Contracts execute your orders 24/7, even if the frontend goes offline.

**Live Demo:** [enderzcxai.duckdns.org](https://enderzcxai.duckdns.org)

---

## Problem

Traditional DEX stop-loss requires a centralized backend to monitor prices. Server down = orders don't execute.

**Reactive Smart Contracts fix this.** They subscribe to on-chain events and autonomously trigger callbacks — no backend, no keeper, no bot.

---

## How It Works

### Two Modes of Operation

```
┌─────────────────────────────────────────────────────┐
│              USER CONNECTS WALLET                    │
│                      │                               │
│         ┌────────────┴────────────┐                  │
│         ▼                         ▼                  │
│   No Session Key            Session Key Active       │
│   (Manual Mode)             (Auto Mode)              │
│         │                         │                  │
│   AI returns unsigned tx    AI executes directly     │
│   User signs in MetaMask    No signature needed      │
│         │                         │                  │
│         └────────────┬────────────┘                  │
│                      ▼                               │
│            On-chain execution                        │
│         Uniswap V2 / Reactive SL/TP                  │
└─────────────────────────────────────────────────────┘
```

### Sentinel Mode (Autonomous Trading)

```
Every 15 min — Intelligence Pipeline
         │
         ├── Crucix (27+ OSINT sources)
         ├── OpenNews / 6551.io (AI-scored crypto news)
         ├── OnchainOS (on-chain analytics)
         └── LLM: analyze → { action, confidence, push_worthy }
                    │
                    ├── Conservative: FLASH signals only, confidence > 70
                    └── Aggressive: PRIORITY+ signals, confidence > 50
                    │
                    ▼
         SessionManager.executeSwap() on-chain
         SSE push → Chat displays decision + TX hash
```

### Reactive Stop-Loss / Take-Profit

```
User: "Set stop-loss at $1800"
         │
         ├── Approve WETH to Callback (Base)
         └── AI deploys Reactive contract (RNK 1597, client = user)
                    │
                    │ Monitors Uniswap WETH/USDC Sync events forever
                    │ Every swap: "Is price <= $1800?"
                    │
                    └── YES → StopOrderCallback.execute() on Base
                                   ├── Re-verify price (double check)
                                   ├── Swap WETH → USDC
                                   └── Send to user wallet
```

---

## Intelligence Sources

RIFI aggregates multiple real-time data sources to power AI trading decisions:

| Source | Repository / Link | Data | Required |
|--------|-------------------|------|----------|
| **Crucix** | [github.com/enderzcx/Crucix](https://github.com/enderzcx/Crucix) | 27+ OSINT sources: FRED (VIX/CPI/yields), GDELT/ACLED (geopolitics), energy (WTI/gas), Reddit, Telegram, satellite, weather | Optional — AI uses fallback signals without it |
| **OpenNews** | [6551.io](https://ai.6551.io) | AI-scored crypto news with sentiment (0-100) and directional signal (long/short/neutral) | Optional — requires API token |
| **OnchainOS** | [OKX OnchainOS](https://www.okx.com/web3/discover/cryptopedia/onchain-os) | On-chain analytics: whale movements, holder distribution, smart money flows | Optional — basic data from Crucix fallback |
| **Uniswap V2** | On-chain (Base) | Real-time WETH/USDC price from pool reserves | Built-in — no config needed |
| **Reactive Network** | [reactive.network](https://reactive.network) | Cross-chain event monitoring for decentralized order execution | Built-in — contracts pre-deployed |

---

## AI Tools (14 total)

| Tool | Source | Purpose |
|------|--------|---------|
| `get_market_signals` | Crucix + OpenNews → LLM | 27-source AI-analyzed market summary |
| `get_crypto_news` | OpenNews / 6551.io | Raw AI-scored crypto news with clickable links |
| `get_crucix_data` | Crucix OSINT Engine | Raw macro data: VIX, BTC, oil, conflicts, TG alerts |
| `get_onchain_data` | OnchainOS | On-chain analytics: whales, holders, smart money |
| `get_price` | Uniswap V2 (Base) | Real-time WETH/USDC price + pool reserves |
| `get_portfolio` | Base RPC | User wallet balances (WETH, USDC, ETH) |
| `market_swap` | Uniswap V2 | Execute swap (auto or manual signing) |
| `session_swap` | SessionManager | Autonomous swap within budget |
| `set_stop_loss` | Reactive Network | Deploy decentralized stop-loss contract |
| `set_take_profit` | Reactive Network | Deploy decentralized take-profit contract |
| `get_active_orders` | OrderRegistry | List active SL/TP orders |
| `cancel_order` | OrderRegistry | Cancel specific order |
| `get_session` | SessionManager | Check session budget and status |
| `update_memory` | Local storage | Persist user preferences and trading patterns |

---

## Quick Start

### Prerequisites

- Node.js 18+
- An OpenAI-compatible LLM API endpoint (OpenAI, local Ollama, etc.)
- A wallet with ETH on Base (for gas)
- [Foundry](https://book.getfoundry.sh/) (for contract deployment only)

### 1. Clone & Install

```bash
git clone https://github.com/enderzcx/RIFI.git
cd RIFI/web
cp .env.example .env.local
npm install
```

### 2. Configure `.env.local`

```env
# Required
LLM_ENDPOINT=http://your-llm:8080/v1    # Any OpenAI-compatible API
LLM_API_KEY=your-key
PRIVATE_KEY=0x_your_wallet_key           # Backend executor wallet

# Optional — for full intelligence pipeline
VPS_API_URL=http://your-vps:3200         # If running VPS intelligence
```

Contract addresses are pre-filled — you can reuse the deployed contracts on Base.

### 3. Run

```bash
npm run dev
```

Open [localhost:3000](http://localhost:3000) → Connect wallet → Start chatting.

### 4. (Optional) Run Intelligence Pipeline

For full Sentinel Mode with 27+ data sources:

```bash
# Terminal 1: Start Crucix (see github.com/enderzcx/Crucix)
cd /path/to/Crucix && node server.mjs

# Terminal 2: Start VPS API
cd RIFI
cp vps-api/.env.example vps-api/.env
# Edit vps-api/.env with your API keys
node vps-api-index.mjs
```

### 5. (Optional) Deploy Your Own Contracts

```bash
curl -L https://foundry.paradigm.xyz | bash && foundryup
forge install

# Deploy on Base
forge script script/DeployBaseStopOrder.s.sol:DeployBase \
  --rpc-url $BASE_RPC_URL --private-key $PRIVATE_KEY --broadcast -vvvv

# Deploy on Reactive Network
forge script script/DeployBaseStopOrder.s.sol:DeployReactive \
  --rpc-url $REACTIVE_RPC --private-key $PRIVATE_KEY --broadcast -vvvv
```

---

## What Works Without the VPS

| Feature | Without VPS | With VPS |
|---------|-------------|----------|
| Chat with AI | ✅ | ✅ |
| Check price | ✅ | ✅ |
| View portfolio | ✅ | ✅ |
| Market swap | ✅ | ✅ |
| Stop-loss / Take-profit | ✅ | ✅ |
| Session Key auto-trading | ✅ | ✅ |
| Market intelligence signals | ⚠️ Fallback defaults | ✅ Real-time 27-source |
| Crypto news | ❌ | ✅ |
| Crucix macro data | ❌ | ✅ |
| Sentinel Mode auto-trade | ❌ | ✅ |

---

## Deployed Contracts

### Base Mainnet (8453)

| Contract | Address |
|----------|---------|
| StopOrderCallback | [`0x9702...f3`](https://basescan.org/address/0x9702220849b78318d7596B0F6503081DeE0a64f3) |
| OrderRegistry | [`0xcE97...98`](https://basescan.org/address/0xcE9720Ae1185e8E8c5739A5d3

[truncated…]

PUBLIC HISTORY

First discoveredMar 30, 2026

IDENTITY

inferred

Identity inferred from code signals. No PROVENANCE.yml found.

Is this yours? Claim it →

METADATA

platformgithub
first seenMar 27, 2026
last updatedMar 29, 2026
last crawledtoday
version

README BADGE

Add to your README:

![Provenance](https://getprovenance.dev/api/badge?id=provenance:github:enderzcx/RIFI)