10.1 · Trading account
One user-owned master wallet, one Privy-managed execution wallet
TradingAccount
Privy
type TradingAccount = {
id: string;
userId: string;
environment: "hyperliquid_testnet";
masterWallet: {
privyWalletId: string;
address: `0x${string}`;
ownership: "user";
};
executionWallet: {
privyWalletId: string;
address: `0x${string}`;
hyperliquidAgentName: string;
status:
| "creating"
| "awaiting_approval"
| "approved"
| "revoked"
| "error";
approvedAt?: number;
};
status:
| "onboarding"
| "ready"
| "agent_revoked"
| "account_unavailable"
| "error";
createdAt: number;
updatedAt: number;
};
The execution wallet signs actions. Hyperliquid account state is queried with the master-wallet address.
10.2 · Harness binding
One provider, bound for the life of a POC mission
TradingHarnessBinding
T3 server
type TradingHarnessBinding = {
provider: "codex" | "claude" | "opencode";
providerInstanceId: string;
providerSessionId?: string;
resumeCursor?: string;
threadId: string;
model?: string;
status: "available" | "unavailable";
};
The binding is immutable for an active POC mission.
10.3 · Trading mission
The durable mandate that outlives each harness turn
TradingMission
Harness
type TradingMission = {
id: string;
userId: string;
tradingAccountId: string;
instruction: string;
market: "ETH";
strategyFamily: "momentum";
harness: TradingHarnessBinding;
authority: TradingAuthority;
strategy?: MomentumStrategyState;
status:
| "initializing"
| "analysing"
| "waiting"
| "executing"
| "position_open"
| "paused"
| "agent_unavailable"
| "blocked"
| "revoked"
| "completed";
blockedReason?:
| "cumulative_loss_limit"
| "protection_failure"
| "account_unavailable"
| "reconciliation_failure";
control: {
entriesAllowed: boolean;
reentryAllowed: boolean;
pauseAfterPositionClose: boolean;
};
strategyVersion: number;
authorityVersion: number;
lastHarnessRunId?: string;
createdAt: number;
updatedAt: number;
};
10.4 · Trading authority & risk policy
User-authorized limits, deterministic risk accounting
TradingAuthority
Authority
type TradingAuthority = {
allocatedCapitalUsd: number;
allowedDirections: Array<"long" | "short">;
maximumLeverage: number;
maximumGrossNotionalUsd: number;
maximumCumulativeLossUsd: number;
maximumPlannedRiskPerPositionUsd: number;
marginModes: Array<"cross" | "isolated">;
allowScaleIn: boolean;
allowPartialReduction: boolean;
allowReentry: boolean;
allowDirectionReversal: boolean;
validUntil: "revoked" | number;
};
type TradingRiskPolicy = {
feeRateSource: "hyperliquid_user_fees";
fallbackTakerFeeBpsPerSide: number;
stopSlippageReserveBps: number;
positivePnlExpandsLossBudget: false;
};
POC defaults
Authority
const pocAuthorityDefaults = (
allocatedCapitalUsd: number
): TradingAuthority => ({
allocatedCapitalUsd,
allowedDirections: ["long", "short"],
maximumLeverage: 3,
maximumGrossNotionalUsd: allocatedCapitalUsd * 3,
maximumCumulativeLossUsd: allocatedCapitalUsd * 0.10,
maximumPlannedRiskPerPositionUsd: allocatedCapitalUsd * 0.02,
// POC decision: isolated margin only. Reject the mission if
// isolated is unavailable; do not fall back to cross.
marginModes: ["isolated"],
allowScaleIn: true,
allowPartialReduction: true,
allowReentry: true,
// POC decision: reversal off by default. Reversal is a harness
// power the user must grant explicitly via an authority patch.
allowDirectionReversal: false,
validUntil: "revoked",
});
const pocRiskPolicyDefaults: TradingRiskPolicy = {
feeRateSource: "hyperliquid_user_fees",
fallbackTakerFeeBpsPerSide: 5,
stopSlippageReserveBps: 25,
positivePnlExpandsLossBudget: false,
};
Worked example: $1,000 mandate
Maximum gross notional
$3,000
Maximum cumulative mission loss
$100
Maximum planned loss per position
$20
Scale-in & re-entry
Permitted
Direction reversal
Off by default
The harness may choose lower exposure. The TradingAuthority type admits cross margin and reversal so a user can grant them later; the POC defaults deliberately do not.
10.5 · Momentum strategy state
Published conclusions, not hidden reasoning
AgentConditionDescription
Harness
type AgentConditionDescription = {
description: string;
timeframe?: TradingTimeframe;
priceLevel?: number;
invalidatedBy?: string;
};
description carries the authoritative published conclusion. The optional fields are display hints only and never drive a runtime decision — watch predicates come from MarketWatch (§12.1), never from a condition description.
TradingTimeframe & MomentumStrategyState
Harness
type TradingTimeframe = "1m" | "3m" | "5m" | "15m" | "1h";
type MomentumStrategyState = {
version: number;
name: string;
market: "ETH";
mode:
| "breakout_continuation"
| "breakdown_continuation"
| "pullback_continuation"
| "volatility_expansion";
direction: "long" | "short" | "both" | "conditional";
timeframes: TradingTimeframe[];
belief: {
summary: string;
regime: string;
confidence?: number;
evidence: string[];
};
entryPlan: {
explanation: string;
initialNotionalUsd?: number;
maximumIntendedNotionalUsd?: number;
orderPreference: "marketable_ioc" | "resting_limit";
conditions: AgentConditionDescription[];
};
positionManagement: {
scaleInAllowed: boolean;
scaleInConditions: AgentConditionDescription[];
partialReductionAllowed: boolean;
trailingMethod?: string;
};
protection: {
stopMethod: string;
stopPrice?: number;
takeProfitMethod?: string;
takeProfitPrice?: number;
maximumPlannedLossUsd?: number;
};
exitConditions: AgentConditionDescription[];
abandonmentConditions: AgentConditionDescription[];
reentryConditions: AgentConditionDescription[];
currentAction:
| "analysing"
| "waiting"
| "entering"
| "holding"
| "scaling"
| "reducing"
| "exiting"
| "reassessing"
| "abandoning";
explanation: string;
updatedAt: number;
};
This stores published conclusions, not hidden reasoning.
10.6 · Contracts to be defined
Referenced types that are deliberately not yet pinned
Each type below is referenced by a published contract but has no published field list. Each is a decision owned by the phase that first implements it — that phase's prompt must not start until the shape is added to this site, so an implementing agent never has to invent a contract. Types not listed here are fully defined on their owning page.
Phase D · Read-only market data
Market-read contracts
AgentMarketSnapshot — referenced by TradingHarnessWakeup (§12.2). Known content: mark, mid, oracle, funding, open interest, day volume, and BBO with freshness metadata (§14.1), plus the computed features in §13.
AgentAccountSnapshot — referenced by TradingHarnessWakeup (§12.2). Known content: account value, margin used, withdrawable, and positions for the master-wallet address (§14.2).
ResolvedMarket, MarketSnapshot, MarketHistoryRequest, MarketHistory — referenced by HyperliquidGateway (§15.2).
Phase E · Watches and wake-up
Wake-up contracts
TradingDomainEventSummary — referenced by TradingHarnessWakeup.pendingEvents (§12.2). The coalesced per-run summary of a MissionInboxEvent (§18.1), not the inbox record itself.
HarnessRunRequest — input to TradingTurnCoordinator.requestRun (§12.3). Its content is implied by the seven pre-run checks.
Phase G · Execution
Execution contracts
NormalizedTradingAction, ExchangeSubmissionResult, CanonicalOrder, OrderStatus — referenced by HyperliquidGateway (§15.2).
- An execution-record type for §11.4's stored fields, currently unnamed.
- A canonical position type for the net ETH position (§14.2), currently unnamed.
Resolved
Defined as of this revision
AgentConditionDescription — §10.5 above.
PersistedWatch — §12.1 on the Runtime page.
HarnessRunOutcome — §12.3 on the Runtime page.
PublishMomentumStrategyBody and the §14.3 tool input/result — on the Tools page.