Skip to main content

AI Trading Overview

The ONE SDK (@one_deploy/sdk v1.1.0) includes a full AI-powered trading agent system. AI agents execute algorithmic trading strategies on behalf of users, operating across multiple chains and trading pairs with configurable risk profiles and investment cycles.

Architecture

+------------------------------------------------------------------+
| Your Application |
+------------------------------------------------------------------+
| React Native | Web / Node (API only) |
| - OneChainSelector | - OneEngineClient |
| - OneTierSelector | AI trading methods |
| - OneCycleSelector | - useAIStrategies |
| - OnePairSelector | - useAIPortfolio |
+------------------------------------------------------------------+
| @one_deploy/sdk |
| +---------------------------+ +-----------------------------+ |
| | AI Trading Hooks | | AI Trading API | |
| | - useAIStrategies | | - getAIStrategies | |
| | - useAIStrategy | | - createAIOrder | |
| | - useAIOrders | | - pauseAIOrder | |
| | - useAIPortfolio | | - resumeAIOrder | |
| | - useAIMarketData | | - redeemAIOrder | |
| | - useAITrading | | - getAIPortfolio | |
| +---------------------------+ +-----------------------------+ |
| +----------------------------------------------------------+ |
| | botSimulationEngine (P&L projections) | |
| +----------------------------------------------------------+ |
+------------------------------------------------------------------+
| |
v v
ONE Engine API Blockchain Networks
engine.one23.io (Base, Ethereum, etc.)

Authentication: Standalone Token Management

Important

AI trading hooks and API methods use standalone token management, not OneProvider. You must set the access token explicitly using setAITradingAccessToken before calling any AI trading method, and clear it with clearAITradingAccessToken when the user signs out.

import {
setAITradingAccessToken,
clearAITradingAccessToken,
} from '@one_deploy/sdk';

// After your user authenticates, set the token
const token = await authenticateUser(); // your auth flow
setAITradingAccessToken(token);

// All AI trading hooks and API calls now use this token
// ...

// On sign-out, clear the token
clearAITradingAccessToken();

This design allows AI trading to function independently from the provider-based auth system, which is especially useful in React Native apps that do not use OneProvider.

Strategy Categories

Every AI strategy belongs to a StrategyCategory. Each category represents a different algorithmic approach and risk/reward profile.

type StrategyCategory =
| 'conservative'
| 'balanced'
| 'aggressive'
| 'hedge'
| 'arbitrage'
| 'trend'
| 'grid'
| 'dca';
CategoryDescriptionTypical Risk
conservativeCapital preservation focus, low drawdown toleranceLow
balancedModerate exposure with active rebalancingMedium
aggressiveHigh conviction positions with wider stop-lossesHigh
hedgeDelta-neutral or hedged positions to reduce market exposureLow-Medium
arbitrageExploits price discrepancies across venues or chainsLow
trendMomentum-following algorithms that ride sustained movesMedium-High
gridPlaces layered buy/sell orders across a price rangeMedium
dcaDollar-cost averaging -- splits entry across time intervalsLow-Medium

Risk Levels

The RiskLevel type represents the overall risk classification assigned to a strategy or order.

type RiskLevel = 'conservative' | 'moderate' | 'aggressive';
Risk LevelMax DrawdownPosition SizingDescription
conservative5-10%Small (1-3% per trade)Prioritises capital preservation
moderate10-20%Medium (3-7% per trade)Balanced risk/reward
aggressive20-40%Large (7-15% per trade)Maximises upside, accepts volatility

Trade Actions

The TradeAction type enumerates every action an AI agent can take on a position.

type TradeAction =
| 'buy'
| 'sell'
| 'long'
| 'short'
| 'close_long'
| 'close_short';
ActionDirectionDescription
buyLongOpen a spot buy position
sell--Close a spot position or take profit
longLongOpen a leveraged long (perpetuals)
shortShortOpen a leveraged short (perpetuals)
close_long--Close an open long position
close_short--Close an open short position

Order Lifecycle

An AI trading order moves through the following states:

  pending ──> active ──> completed
│ │
├──> paused │
│ │ │
│ └──> active (resumed)

└──> redeemed (early withdrawal)
type AIOrderStatus =
| 'pending'
| 'active'
| 'paused'
| 'completed'
| 'redeemed'
| 'failed';

Builder Flow

Creating an AI trading order follows a step-by-step builder flow. The SDK provides dedicated selector components for each step.

Select Strategy ──> Select Chain ──> Select Tier ──> Select Cycle ──> Select Pair ──> Set Amount ──> Create Order
│ │ │ │ │
v v v v v
useAIStrategies OneChainSelector OneTierSelector OneCycleSelector OnePairSelector

Key Exports

import {
// Authentication
setAITradingAccessToken,
clearAITradingAccessToken,

// Hooks
useAIStrategies,
useAIStrategy,
useAIOrders,
useAIPortfolio,
useAIMarketData,
useAITrading,

// Components (React Native)
OneChainSelector,
OneTierSelector,
OneCycleSelector,
OnePairSelector,

// API client
OneEngineClient,

// Simulation
botSimulationEngine,

// Constants
CHAIN_CONFIG,
PAIR_ICONS,
DEFAULT_SHARE_RATES,

// Types
type StrategyCategory,
type RiskLevel,
type TradeAction,
type AIOrderStatus,
type AIStrategy,
type AIOrder,
type AIPortfolioSummary,
type AINavSnapshot,
type AITradeExecution,
type AITradeAllocation,
type AIRedemptionResult,
type CreateAIOrderRequest,
} from '@one_deploy/sdk';

Next Steps