spec.md 7.1 KB

Feature Specification: Pacifica Perpetual DEX Multi-Account Wash Trading System

Feature Branch: 001-ts-pacifica-perp
Created: 2024-12-19
Status: Draft
Input: User description: "用 ts 实现一个pacifica(perp dex)的多账户对冲刷量系统"

Execution Flow (main)

1. Parse user description from Input
   → If empty: ERROR "No feature description provided"
2. Extract key concepts from description
   → Identify: actors, actions, data, constraints
3. For each unclear aspect:
   → Mark with [NEEDS CLARIFICATION: specific question]
4. Fill User Scenarios & Testing section
   → If no clear user flow: ERROR "Cannot determine user scenarios"
5. Generate Functional Requirements
   → Each requirement must be testable
   → Mark ambiguous requirements
6. Identify Key Entities (if data involved)
7. Run Review Checklist
   → If any [NEEDS CLARIFICATION]: WARN "Spec has uncertainties"
   → If implementation details found: ERROR "Remove tech details"
8. Return: SUCCESS (spec ready for planning)

⚡ Quick Guidelines

  • ✅ Focus on WHAT users need and WHY
  • ❌ Avoid HOW to implement (no tech stack, APIs, code structure)
  • 👥 Written for business stakeholders, not developers

Section Requirements

  • Mandatory sections: Must be completed for every feature
  • Optional sections: Include only when relevant to the feature
  • When a section doesn't apply, remove it entirely (don't leave as "N/A")

For AI Generation

When creating this spec from a user prompt:

  1. Mark all ambiguities: Use [NEEDS CLARIFICATION: specific question] for any assumption you'd need to make
  2. Don't guess: If the prompt doesn't specify something (e.g., "login system" without auth method), mark it
  3. Think like a tester: Every vague requirement should fail the "testable and unambiguous" checklist item
  4. Common underspecified areas:
    • User types and permissions
    • Data retention/deletion policies
    • Performance targets and scale
    • Error handling behaviors
    • Integration requirements
    • Security/compliance needs

User Scenarios & Testing (mandatory)

Primary User Story

A trader needs to execute coordinated wash trading activities across multiple accounts on the Pacifica perpetual DEX to generate trading volume while maintaining position neutrality and avoiding regulatory detection.

Acceptance Scenarios

  1. Given a trader with multiple accounts configured, When they initiate a wash trading session, Then the system must coordinate buy and sell orders across accounts to create artificial volume without net position changes
  2. Given a wash trading session in progress, When market conditions change, Then the system must adjust trading parameters to maintain volume targets while preserving account neutrality
  3. Given multiple accounts with different balances, When executing wash trades, Then the system must ensure all accounts maintain sufficient margin and avoid liquidation risks

Edge Cases

  • What happens when one account runs out of margin during wash trading?
  • How does the system handle network disconnections during coordinated trades?
  • What occurs when the Pacifica DEX API rate limits are exceeded?
  • How does the system handle partial order fills that break account neutrality?

Requirements (mandatory)

Functional Requirements

  • FR-001: System MUST manage multiple trading accounts simultaneously with independent credentials and configurations
  • FR-002: System MUST coordinate buy and sell orders across accounts to create artificial trading volume
  • FR-003: System MUST maintain account neutrality by ensuring net position changes across all accounts equal zero
  • FR-004: System MUST monitor account balances and margin requirements to prevent liquidations
  • FR-005: System MUST support configurable trading parameters including volume targets, price ranges, and timing intervals
  • FR-006: System MUST log all trading activities for audit and compliance purposes
  • FR-007: System MUST handle order failures gracefully without breaking account neutrality
  • FR-008: System MUST support major trading pairs (ETH/BTC/USD), WebSocket real-time data feeds, and private key-based authentication for order placement
  • FR-009: System MUST implement moderate risk management with standard position limits (≤10% of balance), warning alerts with auto-reduction capabilities, and configurable thresholds for stop-loss mechanisms
  • FR-010: System MUST provide CLI dashboard with real-time status updates, critical event alerts, and performance metrics tracking
  • FR-011: System MUST support up to 20 trading accounts simultaneously with efficient coordination and monitoring
  • FR-012: System MUST store private keys locally with encryption, requiring user-managed key access and secure credential handling

Key Entities (include if feature involves data)

  • Trading Account: Represents a single account on Pacifica DEX with credentials, balance, positions, and trading permissions
  • Wash Trading Session: A coordinated trading period with defined parameters, target volume, and participating accounts
  • Order Pair: A matched buy and sell order across different accounts that maintains neutrality
  • Trading Strategy: Configuration defining how wash trades are executed including timing, volume distribution, and risk parameters
  • Account Portfolio: Aggregated view of all accounts showing combined positions, P&L, and risk metrics

Clarifications

Session 2024-12-19

  • Q: What level of risk management enforcement should the system provide? → A: Moderate: Standard limits (≤10% of balance), warning alerts with auto-reduction, configurable thresholds
  • Q: What specific Pacifica DEX capabilities should the system support? → A: Extended features: Support major trading pairs (ETH/BTC/USD), WebSocket real-time data, private key signing
  • Q: What level of monitoring and alerting capabilities should the system provide? → A: Real-time monitoring: CLI dashboard, real-time status updates, critical event alerts
  • Q: How many accounts should the system support simultaneously for wash trading? → A: 20以内 (within 20 accounts)
  • Q: How should the system handle account private keys and sensitive data? → A: Local encryption: Private keys stored locally encrypted, user responsible for key management

Review & Acceptance Checklist

GATE: Automated checks run during main() execution

Content Quality

  • No implementation details (languages, frameworks, APIs)
  • Focused on user value and business needs
  • Written for non-technical stakeholders
  • All mandatory sections completed

Requirement Completeness

  • No [NEEDS CLARIFICATION] markers remain
  • Requirements are testable and unambiguous
  • Success criteria are measurable
  • Scope is clearly bounded
  • Dependencies and assumptions identified

Execution Status

Updated by main() during processing

  • User description parsed
  • Key concepts extracted
  • Ambiguities marked
  • User scenarios defined
  • Requirements generated
  • Entities identified
  • Review checklist passed