/** * MERIDIAN: Universal Settlement Network -- multilateral netting + atomic settlement * * Provides a settlement layer for batching and netting payment intents across * multiple wallets and chains. Instead of executing every individual transfer * on-chain, the settlement engine accumulates intents during a cycle, computes * net positions via multilateral netting, and settles only the net amounts * atomically using NEXUS cross-chain signing. * * Settlement cycles: * 1. OPEN -- intents are accepted and queued * 2. NETTING -- cycle closes, net positions are computed (off-chain) * 3. SETTLING -- atomic signing + broadcast of net transfers (via NEXUS) * 4. COMPLETE -- all net transfers confirmed on-chain * 5. FAILED -- one or more net transfers could not settle * * @example * ```typescript * import { Sequence0 } from '@sequence0/sdk'; * * const s0 = new Sequence0({ network: 'mainnet', ownerPrivateKey: '0x...' }); * const settlement = s0.getSettlementClient(); * * // Submit a payment intent * const { intentHash, cycleId } = await settlement.submitIntent( * { * senderWalletId: 'alice-eth-wallet', * recipientWalletId: 'bob-eth-wallet', * chain: 'ethereum', * amount: '1000000000000000000', // 1 ETH * }, * ownerSignature, * timestamp, * ); * * // Check current cycle status * const cycle = await settlement.getCurrentCycle(); * console.log(cycle.status); // 'open' | 'netting' | 'settling' | 'complete' * ``` */ import { Chain } from '../core/types'; import { HttpClient } from '../utils/http'; export interface SettlementIntent { /** Wallet ID of the sender */ senderWalletId: string; /** Wallet ID of the recipient */ recipientWalletId: string; /** Target blockchain for settlement */ chain: Chain; /** Amount in the chain's smallest denomination (e.g. wei, lamports) */ amount: string; /** Token contract address. Omit for native token transfers. */ token?: string; } export interface SettlementCycle { /** Unique cycle identifier */ cycleId: number; /** Current cycle status */ status: 'open' | 'netting' | 'settling' | 'complete' | 'failed'; /** Number of intents in this cycle */ intentCount: number; /** Unix timestamp when the cycle opened */ openedAt: number; /** Unix timestamp when the cycle closed (undefined if still open) */ closedAt?: number; } export interface NetPosition { /** Sender wallet ID (after netting) */ senderWallet: string; /** Recipient wallet ID (after netting) */ recipientWallet: string; /** Chain for this net transfer */ chain: string; /** Net amount to transfer (smallest denomination) */ netAmount: string; } export interface SettlementResult { /** Cycle that was settled */ cycleId: number; /** NEXUS atomic manifest ID used for settlement */ manifestId: string; /** Final status */ status: 'complete' | 'failed'; /** Computed net positions that were settled */ netPositions: NetPosition[]; /** Error message if settlement failed */ error?: string; } /** * Settlement client for MERIDIAN Universal Settlement Network. * * Communicates with settlement endpoints on the agent node to submit * payment intents, query cycle status, and retrieve settlement history. */ export declare class SettlementClient { private httpClient; /** * Create a new SettlementClient * * @param baseUrl - Agent node HTTP endpoint URL * @param httpClient - Shared HttpClient instance for making requests */ constructor(baseUrl: string, httpClient: HttpClient); /** * Submit a payment intent to the current open settlement cycle. * * The intent is queued for netting when the cycle closes. The caller must * provide an ownership proof (signature + timestamp) to authorize the * sender wallet. * * @param intent - Payment intent details * @param ownerSignature - EIP-712 ownership proof signature (hex string) * @param timestamp - Unix timestamp used in the ownership proof * @returns The intent hash and the cycle it was assigned to * * @throws {Sequence0Error} If the intent is invalid or the cycle is not open * @throws {NetworkError} If the agent is unreachable */ submitIntent(intent: SettlementIntent, ownerSignature: string, timestamp: number): Promise<{ intentHash: string; cycleId: number; }>; /** * Get the current open settlement cycle. * * @returns Current cycle status * @throws {NetworkError} If the agent is unreachable */ getCurrentCycle(): Promise; /** * Get a specific settlement cycle by ID. * * @param cycleId - The cycle ID to look up * @returns Cycle status and details * @throws {Sequence0Error} If the cycle is not found * @throws {NetworkError} If the agent is unreachable */ getCycle(cycleId: number): Promise; /** * Get settlement cycle history. * * @param limit - Max number of cycles to return (default: 20) * @returns Array of settlement cycles, most recent first * @throws {NetworkError} If the agent is unreachable */ getCycleHistory(limit?: number): Promise; /** * Map a raw cycle response from the agent to the SettlementCycle interface. */ private mapCycleResponse; } //# sourceMappingURL=settlement.d.ts.map