/** * Intent DAG Mempool (Narwhal-Style) * * Flashbots tarzı blok-sıralama yerine: * Intent DAG → Narwhal/Tusk benzeri mempool * * Pipeline: * Intent * → QUIC * → DAG Mempool Node * → Consensus Sequencer * → Validator * * Özellikler: * - Forks yok (DAG yapısı) * - 50–150 ms finalize * - Intent latency < MEV latency */ import { EventEmitter } from 'events'; export interface Intent { id: string; type: 'swap' | 'transfer' | 'bridge' | 'stake' | 'custom'; sender: string; timestamp: number; deadline: number; payload: IntentPayload; signature: Uint8Array; nonce: number; } export interface IntentPayload { assetIn?: string; assetOut?: string; amountIn?: bigint; minAmountOut?: bigint; recipient?: string; chainId?: number; data?: Uint8Array; } export interface DAGVertex { round: number; author: string; timestamp: number; intents: Intent[]; parents: string[]; hash: string; signature: Uint8Array; } export interface DAGCertificate { vertex: DAGVertex; signatures: Map; quorum: number; certified: boolean; } export interface ConsensusState { currentRound: number; committedRound: number; pendingVertices: Map; certificates: Map; leaders: Map; } /** * DAG Vertex Builder * Creates and validates DAG vertices */ export declare class DAGVertexBuilder { /** * Create new vertex */ static create(round: number, author: string, intents: Intent[], parents: string[], privateKey: Uint8Array): DAGVertex; /** * Compute vertex hash */ static computeHash(data: Omit): string; /** * Verify vertex */ static verify(vertex: DAGVertex): boolean; private static sign; private static verifySignature; } /** * Intent Validator * Validates intent structure and signatures */ export declare class IntentValidator { /** * Validate intent */ static validate(intent: Intent): { valid: boolean; error?: string; }; private static verifySignature; } /** * Narwhal-Style DAG Mempool * Implements DAG-based consensus for intent ordering */ export declare class DAGMempool extends EventEmitter { private config; private state; private validators; private myId; private privateKey; private pendingIntents; private roundTimer; constructor(config: { roundDurationMs?: number; maxIntentsPerVertex?: number; quorumThreshold?: number; validators: string[]; }); /** * Start DAG mempool */ start(): void; /** * Stop DAG mempool */ stop(): void; /** * Submit intent to mempool */ submit(intent: Intent): Promise<{ accepted: boolean; intentId: string; }>; /** * Advance to next round */ private advanceRound; /** * Get parent certificates from previous round */ private getParents; /** * Try to certify a vertex */ private tryCertify; /** * Try to commit rounds */ private tryCommit; /** * Commit a round and its causal history */ private commitRound; /** * Elect leader for a round */ private electLeader; private simulateSignature; /** * Get current state */ getState(): { currentRound: number; committedRound: number; pendingIntents: number; certificates: number; }; /** * Get finality time */ getFinalityTimeMs(): number; } /** * Intent Builder * Helper for creating intents */ export declare class IntentBuilder { private intent; constructor(type: Intent['type']); sender(address: string): this; assetIn(asset: string): this; assetOut(asset: string): this; amountIn(amount: bigint): this; minAmountOut(amount: bigint): this; recipient(address: string): this; chainId(id: number): this; deadline(ms: number): this; sign(privateKey: Uint8Array): Intent; } /** * High-level SDK API for Intent DAG */ export declare class IntentDAGSDK { private mempool; /** * Initialize DAG mempool */ init(config: { validators: string[]; roundDurationMs?: number; }): void; /** * Start mempool */ start(): void; /** * Stop mempool */ stop(): void; /** * Submit intent */ submit(intent: { type: Intent['type']; assetIn?: string; assetOut?: string; amountIn?: bigint; minAmountOut?: bigint; recipient?: string; chainId?: number; }): Promise; /** * Subscribe to committed intents */ onCommit(handler: (data: { round: number; intents: Intent[]; }) => void): void; /** * Get mempool state */ getState(): { currentRound: number; committedRound: number; pendingIntents: number; certificates: number; } | undefined; /** * Get expected finality time */ getFinalityTimeMs(): number; } export declare const intentDAG: IntentDAGSDK; //# sourceMappingURL=intent-dag.d.ts.map