Skip to main content
TradeAgent is the on-chain identity for an AI trader. Holds name, Walrus strategy blob ref, agent address, human owner, BalanceManager id, TradeCap id, PredictManager id. Tracks reputation via signed PnL and a PLP score.

Custody surface

Move agent custody surface. Owner address holds AgentOwnerCap and uses it for pause / resume and record_outcome on the shared TradeAgent. The shared TradeAgent references the BalanceManager via balance_manager_id. The operator address holds TradeCap and uses it to place orders on the BalanceManager. withdraw_all is Move-gated and runs from the Owner address to the BalanceManager.

TradeAgent is the on-chain identity. Owner holds AgentOwnerCap; operator holds TradeCap. Neither alone can both trade and withdraw.

TradeAgent

Signed-PnL trick. Sui Move has no native i128. We split the signed quantity into realized_pnl_abs: u128 + realized_pnl_sign: bool. On record_outcome, the runtime computes new = old + delta in i128 mentally and writes back the abs+sign.

AgentOwnerCap

Gates the three owner-only actions:
All three abort with ENotOwner if cap.agent_id != object::id(agent).

Registration

Wraps AgentRegistered { agent_id, name, owner, agent_address } event. Wired via scripts/register-trade-agent.ts and the /agents Create wizard.

Pause/resume + indexer

pause and resume emit no events (verified at agent.move:215). The server paused column in the agents table is stuck at the registration default. Authoritative source for an agent’s active state is sui.getObject(TradeAgent).is_active. Frontend OwnerControls and the agent-service tick guard both read it live. Do not trust the API field.

Tests

No dedicated test file in tests/; covered indirectly by predict_facade_tests and the per-agent flows.