Σ pnl(t)Δ collateralmax(0, ret − minRet)σ(strategy)x·y=k∂P/∂t∫ roi dtE[r] ≥ r_fα + β·r_mVaR_{95}

Built-in Strategies

The trading agent template ships with four strategies ready to use. Each can be used as-is or extended with your own logic.

Arbitrage

arbitrage.ts

Cross-pool arbitrage on public Uniswap pools. Scans for price discrepancies between pairs like ETH/USDC vs WBTC/USDC via triangulation. Low risk, modest but consistent returns.

Detects: Price discrepancies between public Uniswap v4 pools for correlated token pairs.
Entry / Exit: Enters when spread exceeds minimum profit threshold (after gas + fees). Exits atomically in the same transaction — no open position held.
Ideal conditions: High volatility periods when prices diverge across pools. Works best with deep liquidity on both sides.
Risks: Gas cost exceeding spread on small opportunities. MEV competition from other arbitrageurs. Latency — opportunities are short-lived.
Expected metrics: Win rate >90%, avg return 0.05-0.2% per trade, Sharpe >3

Arbitrage Internal

arbitrage-internal.ts

The most native Lockstep strategy. Arbitrages between Lockstep internal pools (zero Uniswap fee, micro-fee only) and public external pools. During bootstrap, when internal pools are still building depth, prices diverge frequently and the agent captures those spreads.

Detects: Price differences between internal Lockstep pools and external Uniswap pools for the same pair. Uses get_arb_opportunities to find them.
Entry / Exit: Buys on the cheaper pool, sells on the more expensive one. Uses smart_route with execute: true for atomic execution via LockstepRouter.
Ideal conditions: Bootstrap phase when internal pool liquidity is growing — more price divergence. Also works when large trades on external pools create temporary dislocations.
Risks: Internal pool liquidity may be insufficient for large trades. Spread may close before execution. Micro-fee eats into thin margins.
Expected metrics: Win rate >85%, avg return 0.1-0.5% per trade, Sharpe >2.5

Flywheel contributor

The arbitrage-internal strategy is the most beneficial for the protocol. Every trade on internal pools generates micro-fees that are reinvested as liquidity — making the pools deeper and more attractive for future trades. Agents running this strategy are actively building the flywheel.

Momentum

momentum.ts

Trend-following strategy using moving average crossovers. Detects momentum on liquid pairs and enters in the direction of the trend. More volatile than arbitrage but with higher upside potential.

Detects: Moving average crossovers (short-term MA crossing above/below long-term MA) on major pairs like ETH/USDC, WBTC/USDC.
Entry / Exit: Enters when short MA crosses above long MA (bullish) or below (bearish). Exits on reverse crossover or stop-loss trigger. Position sizing based on risk limits.
Ideal conditions: Trending markets with sustained directional moves. Performs poorly in sideways/choppy markets.
Risks: False signals in range-bound markets. Slippage on large positions. Extended drawdowns during trend reversals.
Expected metrics: Win rate 45-55%, avg return 1-5% per winning trade, Sharpe 1-2

Market Making

market-making.ts

Provides bilateral liquidity on pools with wide spreads. Captures the bid-ask spread by placing orders on both sides. Works best on pairs with low volatility and steady volume.

Detects: Pools with wide bid-ask spreads and sufficient volume. Monitors spread width and volume to decide placement.
Entry / Exit: Places buy orders below mid-price and sell orders above. Profits when both sides fill. Rebalances position when inventory skews beyond threshold.
Ideal conditions: Stable pairs with wide spreads and consistent volume. Low volatility reduces inventory risk.
Risks: Inventory risk during sudden price moves (left holding one side). High volatility can cause losses. Requires careful position management.
Expected metrics: Win rate 60-70%, avg return 0.02-0.1% per round trip, Sharpe 2-3