Pteaker

Entriprise grade Private ticker order book on ALeo

Repo

About

## Wave 1 submission

# Private Tick-Based Order Book on Aleo

## What it does

Our project is a **privacy-preserving decentralized exchange (DEX)** built on the Aleo blockchain that enables truly private trading through a tick-based order book mechanism. Unlike traditional DEXs where all order details are public, our system leverages Aleo's zero-knowledge proofs to keep sensitive trading information completely private while maintaining verifiable execution.

### Key Features:

**Privacy-First Trading:**

- Exact limit prices are encrypted using zero-knowledge proofs - only you know your true price - Order quantities remain private until settlement - Trader identities are protected throughout the process - Only tick ranges (price bands) are publicly visible, preserving price discovery while protecting traders

**Tick-Based Matching:**

- Orders are grouped into price "ticks" (e.g., $15.00-$15.01 range) - Public tick ranges enable efficient matching without revealing exact prices - Off-chain matcher nodes scan for profitable overlaps - Settlement executes at midpoint of crossing orders

**Token Pair Management:**

- Admin-controlled token pair registry - Support for multiple trading pairs (ALEO/USDC, ALEO/USDT, etc.) - Configurable tick sizes per pair - Emergency pair activation/deactivation

**Escrow & Settlement:**

- Optional token escrow for production trading - Testing mode available without real tokens - Atomic settlement with automatic token transfers - Partial fills supported for large orders

## The problem it solves

### 1. **Front-Running and MEV Extraction** Traditional DEXs suffer from Maximum Extractable Value (MEV) attacks where: - Bots scan the mempool for pending orders - Large orders get front-run by sandwich attacks - Traders lose money to MEV extractors

**Our Solution:** Zero-knowledge proofs hide exact prices and quantities, making front-running impossible. Attackers can't see what they're front-running.

### 2. **Privacy Concerns**

On public blockchains like Ethereum: - All trading activity is visible - Whales can't trade without everyone watching - Trading strategies become public information - Account balances are exposed

**Our Solution:** Aleo's privacy-by-default architecture encrypts sensitive data. Only participants in a trade see the full details.

### 3. **Capital Inefficiency**

Automated Market Makers (AMMs) like Uniswap require: - Passive liquidity providers - Significant capital locked in pools - Impermanent loss for LPs - Wide spreads for low-liquidity pairs

**Our Solution:** Order book model allows active price discovery with limit orders. Traders set their own prices and only lock tokens they're actively trading.

### 4. **Lack of Advanced Order Types**

Most DEXs only support simple swaps: - No limit orders - No partial fills - No order cancellation - No update capabilities

**Our Solution:** Full order book functionality with limit orders, updates, cancellations, and partial fills - all while maintaining privacy.

## Wave 2 submission

Update Notes — Smart Contract v4 & Frontend Order Book Integration (Summary) Overview

This update delivered a full upgrade of the Aleo order book contract (private_orderbook_v4.aleo) and a complete frontend data pipeline refactor to correctly display live on-chain order data. The prior issue—order book showing 0 buys and 0 sells despite active orders—was traced to flawed data sourcing and transition parsing. Both contract logic and frontend architecture were hardened.

Smart Contract v4 Highlights

Major Upgrade from v3

Partial Fills: Escrow entries are updated (not removed) for partial fills. Orders can now be matched across multiple settlements.

Contract-Derived Order Keys: order_key is generated internally using a hashed nonce, eliminating user-supplied key exploits.

Per-Pair Tick Size: Tick validation now uses pair.tick_size, allowing different price granularities per trading pair.

Permissionless Settlement + Keeper Fees: Any caller holding both TickOrder records can settle.

settler_fee_bps = 0.1%

protocol_fee_bps = 0.05%

Order Expiry: Optional expires_at (block height). 0 means no expiry.

Ceil Escrow Math: Buy-side escrow uses ceiling division to prevent underfunded quote deposits.

Two Settlement Variants:

Lightweight version (no explicit keys)

Full version (with escrow cleanup + depositor verification)

Batch Settlement: Two independent matches in one transaction.

Idempotent Pair Registration: Prevents overwriting existing pairs.

Required Constructor: Added @noupgrade async constructor() for Aleo V9 compatibility.

New Structs

SettleInfo (async arg packing)

TickRange (tick bounds packing)

Settlement (fill record for buyer/seller)

Testing & Demo

Updated demo script for testnet execution via snarkos developer execute.

Migrated to token IDs 7001field / 7002field.

Safe re-runs with setup checks.

Fixed record extraction parsing.

28 Leo tests pass (escrow math, midpoint pricing, overlap validation, settlement arithmetic).

Frontend Order Book Fixes

1. Default Pair Correction

DEFAULT_TOKEN_PAIR changed from 1 to 2 (pair 1 belongs to another admin).

  • Token Registry Fix

Corrected token IDs to 7001field / 7002field

Renamed pair to ALEO/USDC

Disabled inactive pair 1

  • Data Hook Rewrite

Removed Puzzle SDK event path (wallet-scoped only). Now exclusively uses Provable v2 API transition scanning for global on-chain visibility.

  • Transition Parsing Fix

Removed faulty tx.function filter. Added robust Leo input parsing (strips u64 suffix before integer parsing).

  • Single-Fetch Architecture

useOrderBookData now runs once at dashboard level and passes data via props to:

OrderBookDisplay

OrderBookStats

RecentTrades

Prevents race conditions and redundant RPC calls.

  • New Stats Component

## Wave 3 submission

Redesigned smart contract Added keeper but for handling trade matching Deployed private_orderbook_v17.aleo Updates coming

## Wave 4 submission

Private Order Book v1 - Multi-Token Support with USDCx private_matching_orderbook_v1.aleo Leonardo - Private Order Book v1 Wave Summary Private Order Book v1 - Multi-Token Support with USDCx Bridge Architecture:

Order records owned by ORCHESTRATOR (keeper) - private, encrypted

Users receive Receipt records as proof

Dynamic pair registration (anyone can register)

USDCx (7000field) serves as bridge token for cross-pair swaps

Token Design:

Base token: Native ALEO (0field) or any ARC20 token

Quote token: Any ARC20 token via token_registry or USDCx

Supports any TOKEN/TOKEN pair

Key Features:

1. Multi-Token Order Submission

Generic buy/sell orders via token_registry

USDCx buy/sell orders via test_usdcx_stablecoin.aleo

All orders include expiry validation

  • Three Settlement Variants

settle_match: Any token pair via token_registry

settle_match_usdcx: Quote token is USDCx

settle_match_usdcx_base: Base token is USDCx

  • Cross-Pair Atomic Swaps (settle_cross_pair)

USDCx bridges between two pairs

Example: User sells ALEO → receives TKNB (via ALEO/USDCx + TKNB/USDCx)

Atomic execution: 5 transfers in single finalize call

Participants: User (seller leg1), CP1 (buyer leg1), CP2 (seller leg2)

  • Fee Distribution

Settler Fee: 10 bps (0.10%) → keeper

Protocol Fee: 5 bps (0.05%) → treasury

Deducted from quote_amount before seller payment

Cross-pair: Fees on leg1, bridge amount = leg1 - fees

  • Dynamic Pair Management

Open registration: Anyone can register pairs

Pair enumeration via pair_count/pair_ids mappings

Admin can activate/deactivate pairs

TokenPair includes: base_token_id, quote_token_id, tick_size, is_active

  • Order Expiry & Safety

All orders validated: block.height <= expires_at

Escrow safety: Buy orders escrow ≥ (qty × price)/10000, sell orders escrow = qty

Cross-pair: Bridge amount must equal leg2 requirement

## Wave 5 submission

upgraded to leo 4.0.0 # ============================================================ # Private Order Book with USDCx — Record-Based Demo # ============================================================ # Architecture: Keeper model (orders owned by keeper) # This script demonstrates the complete order book flow with USDCx support # # Key Features: # - Token Registry for all ARC20 tokens (including native ALEO via 0field) # - USDCx support via test_usdcx_stablecoin.aleo # - Cross-pair trading via USDCx bridge # - Consolidated finalize functions (efficient) #

From the public Akindo product page. Votes, swipes and the judge score are hackfeed's own.

AI judge

Not judged yet. A free model reads this page, compares it with similar projects and this event's winners, then scores it and says what would make it win.

Still being built?

Not checked yet.

Swipe stats

0upvotes
0skips
0saves

Discussion 0

No comments yet. Ask the team something, or say what you'd use it for.

Posting as a guest. Plain text, 1,000 characters max.

Already built nearby

Closest projects by meaning and shared words. Similar isn't the same as copied: read them.