Page cover

Based MiniApp

Introduction to Based.One MiniApps

Welcome to the Based.One MiniApp ecosystem! This guide will introduce you to the concepts, capabilities, and possibilities of building mini-applications for the Based.One trading terminal.

The API specification will evolve rapidly as we work with developers to figure out what APIs they need, and remove redundant ones to limit scope.

What Are MiniApps?

MiniApps are lightweight, focused applications that run directly within the Based.One trading terminal. They extend the platform's functionality by providing specialized tools, custom interfaces, and automated trading strategies - all while maintaining seamless integration with the core trading experience.

Think of MiniApps as plugins for traders - small, powerful applications that solve specific problems or provide unique functionality without leaving the trading environment.

The north-star for MiniApps is to enhance the experience within the Based.One trading terminal:

  • Enhance Based traders' edge

  • Increase Based terminal screen time and stickiness

  • Provide an out of the world experience, create something never seen before

Why Build MiniApps?

🎯 Focused Solutions

Instead of building a complete trading platform, create targeted tools that solve specific problems, some example ideas:

  • A position sizing calculator

  • A market scanner for specific strategies

  • A risk management dashboard

  • An automated DCA (Dollar Cost Averaging) bot

  • Price alerts

  • AI agent chatbot with trade recommendations

  • Liquidation heatmaps

  • Data-analysis tools for traders

  • Grid-trading bots

🔌 Native Integration

MiniApps have direct access to:

  • Trading functions - Place orders, manage positions, cancel trades

  • Real-time market data - Live prices, order books, trade feeds (feel free to plug your own data instead)

  • Account information - Balances, positions, trading history

Instant Deployment

  • No separate infrastructure needed

  • Built-in security and permissions

  • Automatic updates and distribution

  • Cross-platform compatibility

What Can You Build?

🤖 Trading Automation

  • Grid Trading Bots - Automated buy/sell grids for ranging markets

  • DCA Bots - Dollar cost averaging with custom schedules

  • Arbitrage Tools - Cross-exchange price difference monitoring

  • Stop Loss Managers - Advanced stop loss and take profit systems

📊 Analytics & Insights

  • Portfolio Analyzers - Advanced portfolio tracking and reporting

  • P&L Calculators - Real-time profit/loss analysis with projections

  • Risk Meters - Position sizing and portfolio risk assessment

  • Performance Trackers - Trading statistics and improvement metrics

🔍 Market Tools

  • Custom Scanners - Find trading opportunities based on technical patterns

  • Alert Systems - Price, volume, and technical indicator alerts

  • Correlation Analyzers - Asset correlation tracking and visualization

  • Market Sentiment - Social sentiment and on-chain data aggregation

📚 Educational & Utility

  • Trading Simulators - Paper trading with real market data

  • Strategy Backtesting - Test strategies against historical data

  • Learning Tools - Interactive tutorials and trading guides

  • Calculators - Position size, leverage, and risk calculators

🎮 Games & Entertainment

  • Video Streaming - Livestream FED meetings for trade execution, or simply videos for entertainment

  • Idle Games - Simple games while waiting for trade execution

How MiniApps Work

🏗️ Architecture Overview

┌─────────────────────────────────────────────┐
│              Based.One Terminal              │
├─────────────────────────────────────────────┤
│  ┌─────────────┐  ┌─────────────────────────┐ │
│  │   MiniApp   │  │    Trading Engine       │ │
│  │             │◄─┤                         │ │
│  │  Your Code  │  │  • Market Data          │ │
│  │             │─►│  • Order Management     │ │
│  │             │  │  • Account Info         │ │
│  └─────────────┘  └─────────────────────────┘ │
└─────────────────────────────────────────────┘

🔄 Communication Flow

  1. Your MiniApp sends requests to the terminal

  2. Terminal processes requests with proper permissions (if insufficient permissions, end-user will be prompted to grant permissions)

  3. Trading Engine executes operations (orders, data requests)

  4. Real-time updates flow back to your MiniApp

  5. Your UI updates to reflect current state

🛡️ Security Model

  • Permission-based access - Users explicitly grant capabilities

  • Sandboxed execution - MiniApps run in isolated environments

  • Secure communication - All data exchange is validated

  • User control - Users can revoke permissions at any time

Development Approaches

We provide three different approaches to building MiniApps, each suited for different skill levels and requirements:

Perfect for getting started quickly:

import { createSimpleMiniApp } from '@basedone/miniapp-sdk/simple';

const miniApp = createSimpleMiniApp({ appId: 'my-scanner' });

// Subscribe to market data
await miniApp.subscribeToMarketData(['ETH', 'BTC']);

// Place a quick buy order
await miniApp.quickBuy('ETH', 0.1);

// Listen for price updates
miniApp.on('marketData', (data) => {
  console.log(`${data.symbol}: $${data.price}`);
});

Pros:

  • Minimal setup and configuration

  • Strongly-typed TypeScript APIs

  • Automatic permission handling

  • Built-in error handling and retries

Best for: Simple trading bots, basic market tools, learning projects

Great for building interactive interfaces:

import { useSimpleMiniApp, SimpleOrderForm } from '@basedone/miniapp-sdk/react';

function TradingDashboard() {
  const { marketData, connected } = useSimpleMiniApp({ appId: 'dashboard' });
  
  if (!connected) return <div>Connecting...</div>;
  
  return (
    <div>
      <h1>Trading Dashboard</h1>
      <MarketTicker data={marketData} />
      <SimpleOrderForm symbols={['ETH', 'BTC', 'SOL']} />
    </div>
  );
}

Pros:

  • Ready-to-use React components

  • Automatic state management

  • Real-time data binding

  • Professional UI components

Best for: Dashboards, portfolio analyzers, complex trading interfaces

🔴 Full SDK (Advanced Use Cases)

Maximum control and customization:

import { MiniAppSDK } from '@basedone/miniapp-sdk';

const sdk = new MiniAppSDK({ 
  appId: 'advanced-bot',
  permissions: ['trading', 'market_data', 'account_read']
});

// Custom trading logic with full control
sdk.commands.trading.placeOrder({
  symbol: 'ETH',
  side: 'buy',
  type: 'limit',
  quantity: 0.5,
  price: 2500,
  timeInForce: 'GTC',
  customParameters: { /* advanced options */ }
});

Pros:

  • Complete control over all functionality

  • Access to advanced features

  • Custom event handling

  • Maximum performance

Best for: Professional trading systems, complex algorithms

Real-World Example: Market Scanner

Here's a simple market scanner that alerts when prices move beyond certain thresholds:

import { createSimpleMiniApp } from '@basedone/miniapp-sdk/simple';

class PriceAlertBot {
  constructor() {
    this.miniApp = createSimpleMiniApp({ appId: 'price-alerts' });
    this.alerts = new Map(); // Store price thresholds
  }

  async start() {
    // Subscribe to market data for monitored symbols
    await this.miniApp.subscribeToMarketData(['ETH', 'BTC', 'SOL']);
    
    // Listen for price updates
    this.miniApp.on('marketData', (data) => {
      this.checkAlerts(data);
    });
  }

  addAlert(symbol, threshold, direction) {
    this.alerts.set(`${symbol}-${direction}`, { threshold, direction });
  }

  checkAlerts(marketData) {
    const { symbol, price } = marketData;
    
    // Check if price crossed any thresholds
    for (const [alertId, alert] of this.alerts) {
      if (alertId.startsWith(symbol)) {
        const crossed = alert.direction === 'above' 
          ? price > alert.threshold 
          : price < alert.threshold;
          
        if (crossed) {
          this.sendNotification(`${symbol} price alert: $${price}`);
          this.alerts.delete(alertId); // Remove triggered alert
        }
      }
    }
  }

  sendNotification(message) {
    // Show notification in the terminal
    console.log(`🚨 ALERT: ${message}`);
  }
}

// Usage
const bot = new PriceAlertBot();
bot.addAlert('ETH', 3000, 'above');
bot.addAlert('BTC', 40000, 'below');
bot.start();

This example shows how just a few lines of code can create a useful trading tool!

What's Next?

Now that you understand what MiniApps are and what's possible, let's get you set up:

  1. Quick Start Guide - Build your first MiniApp in 5 minutes

  2. Installation & Setup - Detailed development environment setup

  3. Simple API Guide - Learn the easiest way to build MiniApps

Ready to build your first MiniApp? Let's continue with the Quick Start Guide! 🚀


Next: Quick Start Guide →

Last updated