import { RpcProvider, Account } from 'starknet'; import ObelyskPrivacy, { ecAdd as ecAdd$1, ecMul as ecMul$1, randomScalar as randomScalar$1, invMod, ECPoint } from '../privacy/index.js'; export { CURVE_ORDER, ElGamalCiphertext, ElGamalKeyPair, FIELD_PRIME, GENERATOR_G, GENERATOR_H } from '../privacy/index.js'; interface DepositParams { /** Token symbol (eth, strk, usdc, wbtc, sage) */ token: string; /** Human-readable amount (e.g. "1.5") */ amount: string; } interface DepositResult { /** Transaction hash */ txHash: string; /** Note data (SAVE THIS — needed for withdrawal) */ note: PrivacyNote; /** Commitment hash (on-chain identifier) */ commitmentHash: string; } interface WithdrawParams { /** The note from a previous deposit */ note: PrivacyNote; /** Recipient address (can be different from depositor for anonymity) */ recipient: string; /** Merkle proof (array of sibling hashes from leaf to root) */ merkleProof: string[]; /** Leaf index in the Merkle tree */ leafIndex: number; } interface WithdrawResult { txHash: string; amount: string; token: string; } /** Serializable privacy note — MUST be saved by the user */ interface PrivacyNote { /** Token symbol */ token: string; /** Amount in wei (bigint as string) */ amount: string; /** Pedersen blinding factor (bigint as string) */ blinding: string; /** Nullifier secret (bigint as string) */ nullifierSecret: string; /** Commitment point x (bigint as string) */ commitmentX: string; /** Commitment point y (bigint as string) */ commitmentY: string; /** Poseidon hash of commitment (felt252 hex) */ commitmentHash: string; /** Leaf index in Merkle tree (set after deposit confirms) */ leafIndex?: number; /** Deposit transaction hash */ depositTxHash?: string; /** Timestamp */ createdAt: number; } declare class PrivacyPoolClient { private readonly obelysk; constructor(obelysk: ObelyskClient); /** * Deposit tokens into a privacy pool. * * Creates a Pedersen commitment and range proof, then calls the * privacy pool contract's deposit function. * * @returns DepositResult with the note (SAVE THIS for withdrawal) */ deposit(params: DepositParams): Promise; /** * Withdraw tokens from a privacy pool. * * Requires the original note, a Merkle proof of inclusion, * and the leaf index. The recipient can be any address. */ withdraw(params: WithdrawParams): Promise; /** * Read the current global deposit Merkle root of a privacy pool. */ getMerkleRoot(token: string): Promise; /** * Get pool stats: (total_deposits, total_withdrawals, total_deposited_amount, total_withdrawn_amount) */ getPoolStats(token: string): Promise<{ totalDeposits: number; totalWithdrawals: number; totalDeposited: bigint; totalWithdrawn: bigint; }>; /** * Get the current leaf count (number of deposits) in a privacy pool. */ getLeafCount(token: string): Promise; /** * Check if a nullifier has been used (prevents double-withdrawal). */ isNullifierUsed(token: string, nullifier: string): Promise; /** * Check if a deposit commitment is valid. */ isDepositValid(token: string, commitment: string): Promise; /** * Get fee info for a privacy pool (bps, recipient, accumulated). */ getFeeInfo(token: string): Promise<{ feeBps: number; feeRecipient: string; accumulated: bigint; }>; /** * Fetch a Merkle proof for a given leaf index from on-chain data. * Reconstructs the tree from deposit events. */ fetchMerkleProof(token: string, leafIndex: number): Promise<{ proof: string[]; root: string; }>; } interface DarkPoolDepositParams { token: string; amount: string; } interface CommitOrderParams { /** Trading pair e.g. "SAGE/STRK" */ pair: string; /** Order side */ side: 'buy' | 'sell'; /** Price in 18-decimal fixed point (human-readable string) */ price: string; /** Amount in token decimals (human-readable string) */ amount: string; } interface RevealOrderParams { /** Order data from commitOrder result */ orderData: DarkPoolOrderData; } interface DarkPoolOrderData { orderId: string; pair: string; side: 'buy' | 'sell'; price: string; amount: string; salt: string; amountBlinding: string; commitHash: string; epoch: number; } interface EpochInfo { epoch: number; phase: 'Commit' | 'Reveal' | 'Settle' | 'Closed'; blocksRemaining: number; } interface ClaimFillParams { orderId: bigint; receiveCipher: { c1: { x: bigint; y: bigint; }; c2: { x: bigint; y: bigint; }; }; receiveHint: bigint; receiveProof: { commitment: bigint; challenge: bigint; response: bigint; }; spendCipher: { c1: { x: bigint; y: bigint; }; c2: { x: bigint; y: bigint; }; }; spendHint: bigint; spendProof: { commitment: bigint; challenge: bigint; response: bigint; }; } declare class DarkPoolClient { private readonly obelysk; constructor(obelysk: ObelyskClient); private get darkPoolAddress(); /** * Deposit tokens into the DarkPool for trading. * * Encrypts the amount using ElGamal and generates an AE hint * for O(1) balance decryption. */ deposit(params: DarkPoolDepositParams): Promise<{ txHash: string; }>; /** * Commit an order in the current commit phase. * * Returns order data that must be saved for the reveal phase. */ commitOrder(params: CommitOrderParams): Promise; /** * Reveal a previously committed order in the reveal phase. */ revealOrder(params: RevealOrderParams): Promise<{ txHash: string; }>; /** * Get current epoch info from the contract. */ getEpochInfo(): Promise; /** * Get the total number of orders ever placed. */ getOrderCount(): Promise; /** * Get order IDs for a given epoch. */ getEpochOrders(epochId: number): Promise; /** * Get supported trading pairs. */ getSupportedPairs(): Promise>; /** * Get fee info (bps, recipient). Returns null if fee module not yet active. */ getFeeInfo(): Promise<{ feeBps: number; feeRecipient: string; } | null>; /** * Withdraw tokens from the DarkPool. */ withdraw(params: { token: string; amount: string; }): Promise<{ txHash: string; }>; /** Cancel an order before reveal. */ cancelOrder(orderId: bigint): Promise; /** Claim fills after epoch settlement. */ claimFill(params: { orderId: bigint; receiveCipher: { c1: { x: bigint; y: bigint; }; c2: { x: bigint; y: bigint; }; }; receiveHint: bigint; receiveProof: { commitment: bigint; challenge: bigint; response: bigint; }; spendCipher: { c1: { x: bigint; y: bigint; }; c2: { x: bigint; y: bigint; }; }; spendHint: bigint; spendProof: { commitment: bigint; challenge: bigint; response: bigint; }; }): Promise; /** Register your ElGamal public key with the DarkPool. */ registerPubkey(pubkey: { x: bigint; y: bigint; }): Promise; /** Get the result of a settled epoch. */ getEpochResult(epochId: number): Promise<{ settled: boolean; clearingPrices: string[]; } | null>; /** Check if an order has been claimed. */ isOrderClaimed(orderId: bigint): Promise; /** Get a trader's registered public key. */ getTraderPubkey(address: string): Promise<{ x: bigint; y: bigint; } | null>; /** Get encrypted balance for a trader and asset. */ getEncryptedBalance(address: string, assetId: string): Promise<{ c1: { x: bigint; y: bigint; }; c2: { x: bigint; y: bigint; }; } | null>; } interface StealthSendParams { /** Recipient's Starknet address (must be registered in StealthRegistry) */ to: string; /** Token symbol */ token: string; /** Human-readable amount */ amount: string; } interface StealthMetaAddress { spendPublicKey: { x: bigint; y: bigint; }; viewPublicKey: { x: bigint; y: bigint; }; } interface StealthSpendingProof { commitment: bigint; challenge: bigint; response: bigint; stealthPubkey: { x: bigint; y: bigint; }; } interface StealthAnnouncement { ephemeralPubkey: { x: bigint; y: bigint; }; stealthAddress: string; viewTag: string; token: string; amount: bigint; } interface ClaimParams { announcementIndex: number; spendingProof: StealthSpendingProof; recipient: string; } declare class StealthClient { private readonly obelysk; constructor(obelysk: ObelyskClient); private get registryAddress(); /** * Look up a recipient's stealth meta-address from the registry. */ lookupRecipient(address: string): Promise; /** * Send tokens to a stealth address. * * Generates ephemeral key, derives stealth address via ECDH, * sends tokens + publishes ephemeral pubkey on-chain. */ send(params: StealthSendParams): Promise<{ txHash: string; stealthAddress: string; ephemeralPubKey: { x: string; y: string; }; }>; /** * Check if an address has a registered stealth meta-address. */ hasMetaAddress(address: string): Promise; /** * Get the total number of stealth payment announcements. */ getAnnouncementCount(): Promise; /** * Get the total number of registered workers/recipients. */ getRegisteredCount(): Promise; /** * Check if a stealth payment announcement has been claimed. */ isClaimed(announcementIndex: number): Promise; /** * Register your stealth meta-address in the registry. */ register(spendPubKey: { x: bigint; y: bigint; }, viewPubKey: { x: bigint; y: bigint; }): Promise<{ txHash: string; }>; /** Claim a stealth payment. */ claim(params: { announcementIndex: number; spendingProof: { commitment: bigint; challenge: bigint; response: bigint; stealthPubkey: { x: bigint; y: bigint; }; }; recipient: string; }): Promise; /** Batch claim multiple stealth payments. */ batchClaim(params: { announcementIndices: number[]; spendingProofs: Array<{ commitment: bigint; challenge: bigint; response: bigint; stealthPubkey: { x: bigint; y: bigint; }; }>; recipient: string; }): Promise; /** Update your stealth meta-address. */ updateMetaAddress(spendPubKey: { x: bigint; y: bigint; }, viewPubKey: { x: bigint; y: bigint; }): Promise; /** Get a specific announcement by index. */ getAnnouncement(index: number): Promise<{ ephemeralPubkey: { x: bigint; y: bigint; }; stealthAddress: string; viewTag: string; token: string; amount: bigint; } | null>; /** Get announcements in a range. */ getAnnouncementsRange(start: number, end: number): Promise>; } /** Modular reduction (always positive) */ declare function mod(a: bigint, m: bigint): bigint; /** Modular inverse via extended Euclidean algorithm */ declare const modInverse: typeof invMod; /** EC point addition on STARK curve */ declare const ecAdd: typeof ecAdd$1; /** EC scalar multiplication on STARK curve */ declare const ecMul: typeof ecMul$1; /** Cryptographically secure random scalar in [1, CURVE_ORDER) */ declare const randomScalar: typeof randomScalar$1; /** Pedersen commitment: C = value * G + blinding * H */ declare function pedersenCommit(value: bigint, blinding: bigint): ECPoint; /** ElGamal encrypt: (r*G, amount*H + r*PK) */ declare function elgamalEncrypt(amount: bigint, publicKey: ECPoint): { c1: ECPoint; c2: ECPoint; randomness: bigint; }; /** Schnorr proof of knowledge of r such that c1 = r*G */ declare function createEncryptionProof(r: bigint, c1: ECPoint): { commitment: ECPoint; challenge: bigint; response: bigint; }; /** Generate AE hint for O(1) decryption */ declare function createAEHint(amount: bigint, sharedSecret: bigint): { encryptedAmount: bigint; mac: bigint; }; /** Hash for commitment (Poseidon of point coordinates) */ declare function commitmentToHash(point: ECPoint): string; /** Derive nullifier from secret */ declare function deriveNullifier(nullifierSecret: bigint, commitmentHash: string): string; interface TransferParams { /** Recipient's Starknet address */ to: string; /** Recipient's ElGamal public key */ recipientPublicKey: ECPoint; /** Amount (human-readable) */ amount: string; /** Token symbol */ token: string; } interface FundParams { assetId: number; amount: bigint; encryptionRandomness: bigint; aeHint: bigint; } interface WithdrawCTParams { to: string; assetId: number; amount: bigint; proof: { commitment: bigint; challenge: bigint; response: bigint; }; } declare class ConfidentialTransferClient { private readonly obelysk; constructor(obelysk: ObelyskClient); private get contractAddress(); /** * Send a confidential transfer with ElGamal encrypted amount. * * Generates encryption proof (Schnorr) to prove the ciphertext is well-formed. */ transfer(params: TransferParams): Promise<{ txHash: string; }>; /** * Read your encrypted balance from the contract. */ getEncryptedBalance(address: string, token: string): Promise<{ c1: ECPoint; c2: ECPoint; } | null>; /** Register an ElGamal public key for confidential transfers. */ register(publicKey: { x: bigint; y: bigint; }): Promise; /** Fund: deposit public tokens into encrypted balance. */ fund(params: { assetId: number; amount: bigint; encryptionRandomness: bigint; aeHint: bigint; }): Promise; /** Fund another account's encrypted balance. */ fundFor(params: { account: string; assetId: number; amount: bigint; encryptionRandomness: bigint; aeHint: bigint; }): Promise; /** Rollover: claim pending incoming transfers into your balance. */ rollover(assetId: number): Promise; /** Withdraw: convert encrypted balance back to public tokens. */ withdraw(params: { to: string; assetId: number; amount: bigint; proof: { commitment: bigint; challenge: bigint; response: bigint; }; }): Promise; /** Get a registered public key. */ getPublicKey(address: string): Promise<{ x: bigint; y: bigint; } | null>; } type GpuTier = 'Consumer' | 'Professional' | 'DataCenter' | 'H100'; interface WorkerStake { amount: bigint; gpuTier: GpuTier; stakedAt: number; isActive: boolean; successCount: number; failCount: number; } interface StakingConfig { minStakeConsumer: bigint; minStakeProfessional: bigint; minStakeDataCenter: bigint; minStakeH100: bigint; cooldownPeriod: number; slashPercent: number; rewardRateBps: number; } declare class ProverStakingClient { private readonly obelysk; constructor(obelysk: ObelyskClient); private get contractAddress(); /** * Get a worker's current stake info. */ getStake(workerAddress: string): Promise; /** * Check if a worker is eligible (staked enough, not in cooldown). */ isEligible(workerAddress: string): Promise; /** * Get minimum stake required for a GPU tier. */ getMinStake(tier: GpuTier): Promise; /** * Get total SAGE staked across all workers. */ getTotalStaked(): Promise; /** * Get total SAGE slashed. */ getTotalSlashed(): Promise; /** * Get staking configuration. */ getConfig(): Promise; /** * Stake SAGE tokens to become a prover. */ stake(amount: string, tier: GpuTier): Promise<{ txHash: string; }>; /** * Request unstaking (starts cooldown period). */ requestUnstake(amount: string): Promise<{ txHash: string; }>; /** * Complete unstaking after cooldown period. */ completeUnstake(): Promise<{ txHash: string; }>; /** * Claim accumulated staking rewards. */ claimRewards(): Promise<{ txHash: string; }>; } /** * Privacy Router Client * * Read-only views into the Obelysk Privacy Router — the core private * balance, transfer, and audit infrastructure. */ interface PrivateAccount { publicKey: ECPoint; encryptedBalance: { c1: ECPoint; c2: ECPoint; }; registered: boolean; } declare class PrivacyRouterClient { private readonly obelysk; constructor(obelysk: ObelyskClient); private get contractAddress(); /** * Get a registered private account's info. */ getAccount(address: string): Promise; /** Check if a nullifier has been spent. */ isNullifierUsed(nullifier: string): Promise; /** Get the current nullifier tree root. */ getNullifierTreeRoot(): Promise; /** Get the current epoch of the privacy router. */ getCurrentEpoch(): Promise; /** Get total nullifier count. */ getNullifierCount(): Promise; /** Check if an asset ID is supported. */ isAssetSupported(assetId: number): Promise; /** Get the token address for an asset ID. */ getAssetToken(assetId: number): Promise; /** Get the number of auditors. */ getAuditorCount(): Promise; /** Check if an address is a registered auditor. */ isAuditor(address: string): Promise; /** Get the audit approval threshold. */ getAuditThreshold(): Promise; /** Get the large transfer threshold. */ getLargeTransferThreshold(): Promise; /** Check if the Lean IMT is active. */ isLeanIMTActive(): Promise; /** Get pending audit/disclosure request count. */ getPendingRequestCount(): Promise; /** Register an account with the privacy router. */ registerAccount(publicKey: { x: bigint; y: bigint; }): Promise; /** Deposit tokens into encrypted balance. */ deposit(params: { amount: bigint; encryptedAmount: { c1: { x: bigint; y: bigint; }; c2: { x: bigint; y: bigint; }; }; proof: { commitment: bigint; challenge: bigint; response: bigint; }; }): Promise; /** Withdraw from encrypted balance to public. */ withdraw(params: { amount: bigint; encryptedDelta: { c1: { x: bigint; y: bigint; }; c2: { x: bigint; y: bigint; }; }; proof: { commitment: bigint; challenge: bigint; response: bigint; }; rangeProofData?: string[]; }): Promise; /** Private transfer between accounts. */ privateTransfer(params: { to: string; senderCipher: { c1: { x: bigint; y: bigint; }; c2: { x: bigint; y: bigint; }; }; receiverCipher: { c1: { x: bigint; y: bigint; }; c2: { x: bigint; y: bigint; }; }; proof: { commitment: bigint; challenge: bigint; response: bigint; }; senderAeHint: bigint; receiverAeHint: bigint; }): Promise; /** Request disclosure of a nullifier (audit). */ requestDisclosure(nullifier: string, reason: string): Promise; /** Ragequit: emergency withdrawal with proof. */ ragequit(proof: string[]): Promise; /** Get the nullifier tree state. */ getNullifierTreeState(): Promise<{ root: string; size: number; }>; /** Get account balance hints (for O(1) decryption). */ getAccountHints(address: string): Promise<{ balanceHint: bigint; pendingInHint: bigint; pendingOutHint: bigint; } | null>; } /** * Shielded Swap Router Client * * Read swap router state (pools, fees, swap count). * Actual swaps require withdrawal proofs and are executed via the full * privacy pool → swap → re-deposit flow. */ interface ShieldedSwapParams { tokenIn: string; tokenOut: string; amountIn: bigint; minAmountOut: bigint; nullifier: string; merkleRoot: string; merkleProof: string[]; newCommitment: string; encryptedAmount: bigint; proof: string; } declare class ShieldedSwapClient { private readonly obelysk; constructor(obelysk: ObelyskClient); private get contractAddress(); /** Get total number of shielded swaps executed. */ getSwapCount(): Promise; /** Get the privacy pool address registered for a token. */ getPool(tokenAddress: string): Promise; /** Get the Ekubo core address (AMM integration). */ getEkuboCore(): Promise; /** Get swap fee info (bps, recipient). Returns null if not active. */ getSwapFeeInfo(): Promise<{ feeBps: number; feeRecipient: string; } | null>; /** Get contract owner. */ getOwner(): Promise; /** * Execute a shielded swap (privacy pool -> AMM -> re-deposit). * This is the full privacy-preserving swap flow. */ shieldedSwap(params: ShieldedSwapParams): Promise; } /** * VM31 UTXO Privacy Vault Client * * Wraps both on-chain VM31Pool contract reads and the VM31 relayer HTTP API * for transaction submission. The VM31 system uses Poseidon2-M31 hashing * with a UTXO model for confidential token transfers. * * On-chain reads go through `callContract()` to the VM31Pool. * Transaction submissions (deposit/withdraw/transfer) go through the * VM31 relayer HTTP API, which batches and proves transactions. */ interface PackedDigest { lo: string; hi: string; } type VM31AssetId = number; type BatchStatus = 'queued' | 'proving' | 'confirmed' | 'finalized' | 'error'; interface VaultNote { owner_pubkey: [number, number, number, number]; asset_id: number; amount_lo: number; amount_hi: number; blinding: [number, number, number, number]; } interface VaultMerklePath { siblings: number[][]; index: number; } interface VaultDepositParams { amount: bigint; assetId: number; recipientPubkey: [number, number, number, number]; recipientViewingKey: [number, number, number, number]; } interface VaultWithdrawParams { amount: bigint; assetId: number; note: VaultNote; spendingKey: [number, number, number, number]; merklePath: VaultMerklePath; merkleRoot: number[]; withdrawalBinding: number[]; bindingSalt?: number[]; } interface VaultTransferParams { amount: bigint; assetId: number; recipientPubkey: [number, number, number, number]; recipientViewingKey: [number, number, number, number]; senderViewingKey: [number, number, number, number]; inputNotes: Array<{ note: VaultNote; spendingKey: [number, number, number, number]; merklePath: VaultMerklePath; }>; merkleRoot: number[]; } interface VaultSubmitResult { status: 'queued' | 'batch_triggered' | 'duplicate'; batchId?: string; queuePosition?: number; idempotencyKey?: string; } interface VaultBatchInfo { id: string; status: BatchStatus; txCount: number; proofHash?: string; batchIdOnchain?: string; txHash?: string; createdAt?: string; error?: string; } interface RelayerInfo { pendingTransactions: number; batchMaxSize: number; batchTimeoutSecs: number; } declare class VM31VaultClient { private readonly obelysk; constructor(obelysk: ObelyskClient); private get contractAddress(); private get relayerUrl(); private get relayerApiKey(); /** Cached relayer X25519 public key (fetched on first encrypted submit) */ private _relayerPubkey; private relayerFetch; /** * Submit a payload to the relayer, encrypted with ECIES. * Falls back to plaintext if `encrypt: false` is passed. */ private relayerSubmit; /** Get the current Merkle root of the VM31 commitment tree */ getMerkleRoot(): Promise; /** Get the number of leaves in the commitment tree */ getTreeSize(): Promise; /** Check if a nullifier has been spent */ isNullifierSpent(nullifier: PackedDigest): Promise; /** Check if a Merkle root is known (valid historical root) */ isKnownRoot(root: PackedDigest): Promise; /** Get the total balance of an asset held in the pool */ getAssetBalance(assetId: number): Promise; /** Get on-chain batch status (0=NONE, 1=SUBMITTED, 2=FINALIZED, 3=CANCELLED) */ getBatchStatus(batchId: string): Promise; /** Get the currently active batch ID */ getActiveBatchId(): Promise; /** Get total transaction count in a batch */ getBatchTotalTxs(batchId: string): Promise; /** Get number of processed transactions in a batch */ getBatchProcessedCount(batchId: string): Promise; /** Get the ERC-20 token address for a VM31 asset ID */ getAssetToken(assetId: number): Promise; /** Get the VM31 asset ID for a given ERC-20 token address */ getTokenAsset(tokenAddress: string): Promise; /** Check if the VM31Pool contract is paused */ isPaused(): Promise; /** Get the contract owner address */ getOwner(): Promise; /** Get the authorized relayer address */ getRelayer(): Promise; /** Get batch timeout in blocks */ getBatchTimeoutBlocks(): Promise; /** Check relayer health (no auth required) */ getRelayerHealth(): Promise<{ status: string; version: string; service: string; }>; /** Get relayer queue status */ getRelayerStatus(): Promise; /** Get the relayer's public encryption key */ getRelayerPublicKey(): Promise<{ publicKey: string; version: number; algorithm: string; }>; /** * Submit a deposit transaction to the relayer. * Validates denomination (privacy gap #7) and encrypts with ECIES by default. * @param encrypt - Set to false for legacy plaintext mode (default: true) */ submitDeposit(params: VaultDepositParams, encrypt?: boolean): Promise; /** * Submit a withdrawal transaction to the relayer. * Withdrawals are not denomination-restricted. * @param encrypt - Set to false for legacy plaintext mode (default: true) */ submitWithdraw(params: VaultWithdrawParams, encrypt?: boolean): Promise; /** * Submit a private transfer transaction to the relayer. * Transfers are not denomination-restricted. * @param encrypt - Set to false for legacy plaintext mode (default: true) */ submitTransfer(params: VaultTransferParams, encrypt?: boolean): Promise; /** Query batch info from the relayer */ queryBatch(batchId: string): Promise; /** Fetch Merkle path for a commitment from the relayer */ fetchMerklePath(commitment: string): Promise<{ commitment: string; merklePath: VaultMerklePath | null; merkleRoot: number[] | null; batchId: string | null; createdAt?: string; status?: string; }>; /** Force the relayer to prove the current batch immediately */ forceProve(): Promise<{ status: string; batchId?: string; }>; /** Encode a bigint amount into M31 lo/hi pair (31-bit limbs) */ static encodeAmountM31(amount: bigint): { lo: number; hi: number; }; /** Decode an M31 lo/hi pair back into a bigint amount */ static decodeAmountM31(lo: number, hi: number): bigint; } /** * VM31 Confidential Bridge Client * * Read-only views into the VM31Bridge contract, which facilitates * bridging between the VM31 UTXO pool and the ElGamal-based * ConfidentialTransfer system. */ interface AssetPair { vm31AssetId: string; confidentialAssetId: string; } interface BridgeConfig { relayer: string; vm31Pool: string; confidentialTransfer: string; } declare class VM31BridgeClient { private readonly obelysk; constructor(obelysk: ObelyskClient); private get contractAddress(); /** Get the authorized relayer address */ getRelayer(): Promise; /** Get the VM31Pool contract address */ getVM31Pool(): Promise; /** Get the ConfidentialTransfer contract address */ getConfidentialTransfer(): Promise; /** Get the asset pair mapping for a given token address */ getAssetPair(tokenAddress: string): Promise; /** Check if a bridge key has already been processed */ isBridgeKeyProcessed(bridgeKey: string): Promise; /** Compute a bridge key from withdrawal parameters */ computeBridgeKey(params: { batchId: string; withdrawalIdx: number; payoutRecipient: string; creditRecipient: string; token: string; amount: bigint; }): Promise; /** Get full bridge configuration (relayer, vm31Pool, confidentialTransfer) */ getConfig(): Promise; /** Get pending upgrade info, if any */ getPendingUpgrade(): Promise<{ classHash: string; scheduledAt: number; } | null>; /** Check if the bridge contract is paused */ isPaused(): Promise; } /** * OTC Orderbook Client * * On-chain limit/market order book for peer-to-peer token trading. * Supports limit orders, market orders, batch operations, and * real-time orderbook depth queries. */ declare enum OrderSide { Buy = 0, Sell = 1 } declare enum OrderType { Limit = 0, Market = 1 } declare enum OrderStatus { Open = 0, PartialFill = 1, Filled = 2, Cancelled = 3, Expired = 4 } interface TradingPair { baseToken: string; quoteToken: string; minOrderSize: bigint; tickSize: bigint; isActive: boolean; } interface OTCOrder { orderId: bigint; maker: string; pairId: number; side: OrderSide; orderType: OrderType; price: bigint; remaining: bigint; amount: bigint; status: OrderStatus; createdAt: number; expiresAt: number; } interface OTCTrade { tradeId: bigint; makerOrderId: bigint; takerOrderId: bigint; maker: string; taker: string; price: bigint; amount: bigint; quoteAmount: bigint; executedAt: number; } interface OrderbookConfig { makerFeeBps: number; takerFeeBps: number; defaultExpirySecs: number; maxOrdersPerUser: number; paused: boolean; } interface PlaceLimitOrderParams { pairId: number; side: OrderSide; price: bigint; amount: bigint; /** Seconds until expiry. 0 or undefined uses the contract default. */ expiresIn?: number; } interface PlaceMarketOrderParams { pairId: number; side: OrderSide; amount: bigint; } interface OrderbookDepthLevel { price: bigint; totalAmount: bigint; orderCount: number; } interface OrderbookDepth { bids: OrderbookDepthLevel[]; asks: OrderbookDepthLevel[]; } interface Stats24h { volume: bigint; high: bigint; low: bigint; tradeCount: bigint; } declare class OTCOrderbookClient { private readonly obelysk; constructor(obelysk: ObelyskClient); private get contractAddress(); /** * Place a limit order on the orderbook. * * The contract handles internal matching against resting orders. * Returns the transaction hash. */ placeLimitOrder(params: PlaceLimitOrderParams): Promise; /** * Place a market order that fills immediately against resting liquidity. * Returns the transaction hash. */ placeMarketOrder(params: PlaceMarketOrderParams): Promise; /** * Cancel a single order by ID. * Only the maker can cancel their own order. */ cancelOrder(orderId: bigint): Promise; /** * Cancel all open orders for the caller. */ cancelAllOrders(): Promise; /** * Place multiple limit orders in a single transaction. * * Cairo expects an array of (u8, OrderSide, u256, u256, u64) tuples. * Calldata: [length, ...flattened orders]. */ batchPlaceOrders(orders: PlaceLimitOrderParams[]): Promise; /** * Cancel multiple orders in a single transaction. * * Calldata: [length, ...flattened u256 order IDs]. */ batchCancelOrders(orderIds: bigint[]): Promise; /** * Get a single order by ID. */ getOrder(orderId: bigint): Promise; /** * Get all order IDs belonging to a user. */ getUserOrders(user: string): Promise; /** * Get the best (highest) bid price for a trading pair. */ getBestBid(pairId: number): Promise; /** * Get the best (lowest) ask price for a trading pair. */ getBestAsk(pairId: number): Promise; /** * Get the bid-ask spread for a trading pair. */ getSpread(pairId: number): Promise; /** * Get trading pair configuration. */ getPair(pairId: number): Promise; /** * Get the orderbook configuration (fees, limits, pause state). */ getConfig(): Promise; /** * Get aggregate orderbook statistics. */ getStats(): Promise<{ orderCount: bigint; tradeCount: bigint; totalVolume: bigint; totalFees: bigint; }>; /** * Get total number of orders ever placed. */ getOrderCount(): Promise; /** * Get total number of trades executed. */ getTradeCount(): Promise; /** * Get the time-weighted average price for a trading pair. */ getTwap(pairId: number): Promise; /** * Get 24-hour rolling statistics for a trading pair. */ get24hStats(pairId: number): Promise; /** * Get the most recent trade for a trading pair. */ getLastTrade(pairId: number): Promise<{ price: bigint; amount: bigint; timestamp: number; }>; /** * Get the orderbook depth (price levels) for a trading pair. * * Returns up to `maxLevels` aggregated price levels for both * bids and asks. Each level contains price, total amount, and * number of orders at that price. */ getOrderbookDepth(pairId: number, maxLevels: number): Promise; /** * Get active orders for a trading pair with pagination. */ getActiveOrders(pairId: number, offset: number, limit: number): Promise; /** * Get trade history for a trading pair with pagination. */ getTradeHistory(pairId: number, offset: number, limit: number): Promise; /** * Get the contract owner address. */ getOwner(): Promise; } /** * Obelysk Protocol Contract Addresses & Token Registry * * All addresses inlined for npm consumers — no external JSON dependency. */ type ObelyskNetwork = 'sepolia' | 'mainnet'; declare function getRpcUrl(network: ObelyskNetwork): string; declare function getContracts(network: ObelyskNetwork): Record; declare const MAINNET_TOKENS: Record; declare const MAINNET_PRIVACY_POOLS: Record; /** Token decimals */ declare const TOKEN_DECIMALS: Record; /** DarkPool asset IDs (felt252) */ declare const DARKPOOL_ASSET_IDS: Record; /** VM31 asset IDs */ declare const VM31_ASSET_IDS: Record; /** Parse token amount to bigint */ declare function parseAmount(amount: string | number, token: string): bigint; /** Format bigint to human-readable string */ declare function formatAmount(amount: bigint, token: string): string; /** * Main Obelysk Protocol Client * * Orchestrates all protocol operations: privacy pools, dark pool, * stealth payments, confidential transfers, staking, router, and swaps. */ interface ObelyskConfig { /** Network to connect to */ network: ObelyskNetwork; /** starknet.js Account (for signing transactions) */ account?: Account; /** Optional custom RPC URL (strongly recommended — default public RPCs have limits) */ rpcUrl?: string; /** Optional privacy key pair (hex private key). If omitted, generated fresh. */ privacyPrivateKey?: string; /** VM31 relayer URL (default: https://relay.bitsage.network:3080) */ relayerUrl?: string; /** VM31 relayer API key */ relayerApiKey?: string; } declare class ObelyskClient { readonly network: ObelyskNetwork; readonly provider: RpcProvider; readonly account?: Account; readonly privacy: ObelyskPrivacy; readonly contracts: Record; readonly tokens: Record; readonly privacyPools: Record; readonly relayerUrl?: string; readonly relayerApiKey?: string; /** Privacy Pool operations (deposit/withdraw shielded tokens) */ readonly privacyPool: PrivacyPoolClient; /** DarkPool batch auction trading */ readonly darkPool: DarkPoolClient; /** Stealth address payments */ readonly stealth: StealthClient; /** Confidential peer-to-peer transfers */ readonly confidentialTransfer: ConfidentialTransferClient; /** SAGE prover staking (stake/unstake/rewards) */ readonly staking: ProverStakingClient; /** Privacy Router (private balances, nullifiers, auditing) */ readonly router: PrivacyRouterClient; /** Shielded swap router (privacy-preserving AMM swaps) */ readonly swap: ShieldedSwapClient; /** VM31 UTXO privacy vault (deposits/withdrawals/transfers via relayer) */ readonly vm31: VM31VaultClient; /** VM31 confidential bridge (bridge VM31 withdrawals to encrypted balances) */ readonly bridge: VM31BridgeClient; /** OTC orderbook (limit/market orders, trade history) */ readonly otc: OTCOrderbookClient; constructor(config: ObelyskConfig); /** Get token address by symbol */ getTokenAddress(symbol: string): string; /** Get privacy pool address for a token */ getPrivacyPoolAddress(symbol: string): string; /** Require an account is set */ requireAccount(): Account; } /** * ECIES Encryption for VM31 Relayer * * X25519 ECDH + HKDF-SHA256 + AES-256-GCM * Compatible with the Obelysk VM31 relayer (Rust: x25519-dalek + aes-gcm + hkdf) * * Uses Web Crypto API (works in Node 20+ and all modern browsers). */ interface ECIESEnvelope { ephemeral_pubkey: string; ciphertext: string; nonce: string; version: number; } /** * Encrypt a JSON payload for the VM31 relayer using ECIES. * * @param payload - The SubmitRequest object to encrypt * @param relayerPubkeyHex - The relayer's X25519 public key (hex, 64 chars) * @returns ECIES envelope ready to POST to /submit */ declare function eciesEncrypt(payload: unknown, relayerPubkeyHex: string): Promise; /** * VM31 Deposit Denomination Whitelists * * Privacy gap #7 mitigation: deposits must use standard denominations * to prevent exact-amount correlation attacks. * * Only deposits are restricted — withdrawals and transfers are unrestricted. */ /** wBTC denominations (8 decimals) */ declare const WBTC_DENOMINATIONS: readonly bigint[]; /** SAGE denominations (18 decimals) */ declare const SAGE_DENOMINATIONS: readonly bigint[]; /** ETH denominations (18 decimals) */ declare const ETH_DENOMINATIONS: readonly bigint[]; /** STRK denominations (18 decimals) */ declare const STRK_DENOMINATIONS: readonly bigint[]; /** USDC denominations (6 decimals) */ declare const USDC_DENOMINATIONS: readonly bigint[]; /** All denomination lists by VM31 asset ID */ declare const VM31_DENOMINATIONS: Record; /** Denomination lists by token symbol */ declare const DENOMINATION_BY_SYMBOL: Record; /** * Validate that a deposit amount is a standard denomination. * Throws if the amount is not in the whitelist. * Unknown assets pass through (forward-compatible). * * @param amount - Amount in base units (e.g., wei, satoshis) * @param assetIdOrSymbol - VM31 asset ID (0-4) or token symbol */ declare function validateDenomination(amount: bigint, assetIdOrSymbol: number | string): void; /** * Split an amount into the fewest standard denominations (greedy, largest first). * Useful for automatically batching a deposit into multiple denomination-safe transactions. * * @returns denominations array and any remainder that can't be represented */ declare function splitIntoDenominations(amount: bigint, assetIdOrSymbol: number | string): { denominations: bigint[]; remainder: bigint; }; /** * Get valid denominations for an asset. * Returns undefined for unknown assets. */ declare function getDenominations(assetIdOrSymbol: number | string): readonly bigint[] | undefined; export { type AssetPair, type BatchStatus, type BridgeConfig, type ClaimFillParams, type ClaimParams, type CommitOrderParams, ConfidentialTransferClient, DARKPOOL_ASSET_IDS, DENOMINATION_BY_SYMBOL, DarkPoolClient, type DarkPoolDepositParams, type DarkPoolOrderData, type DepositParams, type DepositResult, type ECIESEnvelope, ECPoint, ETH_DENOMINATIONS, type EpochInfo, type FundParams, type GpuTier, MAINNET_PRIVACY_POOLS, MAINNET_TOKENS, type OTCOrder, OTCOrderbookClient, type OTCTrade, ObelyskClient, type ObelyskConfig, type ObelyskNetwork, ObelyskPrivacy, OrderSide, OrderStatus, OrderType, type OrderbookConfig, type OrderbookDepth, type OrderbookDepthLevel, type PackedDigest, type PlaceLimitOrderParams, type PlaceMarketOrderParams, type PrivacyNote, PrivacyPoolClient, PrivacyRouterClient, type PrivateAccount, ProverStakingClient, type RelayerInfo, type RevealOrderParams, SAGE_DENOMINATIONS, STRK_DENOMINATIONS, ShieldedSwapClient, type ShieldedSwapParams, type StakingConfig, type Stats24h, type StealthAnnouncement, StealthClient, type StealthMetaAddress, type StealthSendParams, type StealthSpendingProof, TOKEN_DECIMALS, type TradingPair, type TransferParams, USDC_DENOMINATIONS, type VM31AssetId, VM31BridgeClient, VM31VaultClient, VM31_ASSET_IDS, VM31_DENOMINATIONS, type VaultBatchInfo, type VaultDepositParams, type VaultMerklePath, type VaultNote, type VaultSubmitResult, type VaultTransferParams, type VaultWithdrawParams, WBTC_DENOMINATIONS, type WithdrawCTParams, type WithdrawParams, type WithdrawResult, type WorkerStake, commitmentToHash, createAEHint, createEncryptionProof, deriveNullifier, ecAdd, ecMul, eciesEncrypt, elgamalEncrypt, formatAmount, getContracts, getDenominations, getRpcUrl, mod, modInverse, parseAmount, pedersenCommit, randomScalar, splitIntoDenominations, validateDenomination };