Angstrom Documentation

website·Indexed 32 days ago

https://docs.angstrom.xyz

Documentation for Angstrom, a decentralized exchange featuring app-specific sequencing, batch auctions, and MEV capture. Includes guides for L1 and L2 architectures, Uniswap v4 hook integration, the angstrom-sdk for Rust developers, and API references for trading and consensus.

Tokens
31.1K
Snippets
95
Records
207
Agent score
58%

What's inside Angstrom

  1. Overview of Angstrom L2 Contract Architecture

    The Angstrom L2 deployment implements an MEV-taxing model based on the 'Priority is All You Need' framework. It consists of two primary smart contracts:

    1. AngstromL2: A Uniswap v4 hook that taxes swaps and Just-In-Time (JIT) liquidity based on the sequencer priority fee. The collected proceeds are redistributed to pool creators, the protocol treasury, and Liquidity Providers (LPs).
    2. AngstromL2Factory: A governance contract responsible for deploying verified hooks, configuring protocol fees, and providing emergency controls.

    There is no off-chain coordination layer; routers interact directly with the standard Uniswap v4 pool manager, and the hook's callbacks manage the taxing and redistribution logic.

  2. Overview of angstrom-v4 library capabilities

    The angstrom-v4 library is designed for Rust developers to interact with UniswapV4 pool states with Angstrom-specific features. Key capabilities include:

    • Pool Management: Tracking and updating pool states via Angstrom's Slot0 WebSocket stream.
    • Swap Simulation: Calculating swap outputs using Uniswap V3/4 math primitives.
    • Async Operations: Built on the Tokio runtime for concurrent pool operations.
    • Ethereum Integration: Direct RPC and contract interactions via the Alloy framework.
  3. Overview of Angstrom Technical Libraries

    Angstrom provides two primary technical libraries for developers:

    1. angstrom-sdk: Used for direct interaction with the Angstrom protocol.
    2. angstrom-v4: Used for interacting with and managing UniswapV4 pool state specifically utilizing Angstrom features.
  4. Overview of AngstromL2 Uniswap v4 Hook

    AngstromL2.sol is a Uniswap v4 hook designed for rollups to enforce MEV taxes, fee splits, and LP compensation. It implements the IBeforeSwap, IAfterSwap, IAfterAddLiquidity, and IAfterRemoveLiquidity hooks, and uses IBeforeInitialize as a guard to ensure pools are created via the approved initialization process.
  5. Overview of the Angstrom Rust SDK

    The angstrom-sdk-rs is the official SDK for Rust developers to interact with the Angstrom protocol. It provides tools for sending orders, querying on-chain and off-chain data, managing liquidity, and subscribing to real-time events via WebSockets. Key capabilities include:

    • Order Management: Support for TopOfBlock, Flash, and Standing order types using a builder pattern.
    • Automated Preparation: Built-in "Fillers" for order signing, nonce management, and balance checks.
    • Data Access: Querying for pools, tokens, historical orders, and user positions.
    • Real-time Events: WebSocket subscriptions for order events and empty block attestations.
    • Integration: Full coverage of Angstrom's Node RPC, Data, and User-specific functionalities.
  6. Overview of Angstrom Order Types

    In the Angstrom JSON-RPC API, orders are submitted as a payload conforming to the Order enum. Each order type is a specific variant containing only the necessary data for that type to minimize ambiguity and simplify validation.

    Orders are categorized into three main groups:

    1. Flash Orders: Executed within a single block. Includes Partial (Immediate-or-Cancel style) and Exact (Fill-or-Kill style).
    2. Standing Orders: Persist across blocks until filled, canceled, or expired. They include a nonce and deadline for replay protection.
    3. TOB (Top-of-Block) Orders: Used for Angstrom's arbitrage auction, allowing arbitrageurs to bid for the first trade against a liquidity pool.
    pub enum Order {
        PartialFlash(PartialFlashOrder),
        ExactFlash(ExactFlashOrder),
        PartialStanding(PartialStandingOrder),
        ExactStanding(ExactStandingOrder),
        TOB(TopOfBlockOrder),
    }
  7. Overview of Angstrom Consensus Algorithm

    Angstrom is a consensus algorithm designed to integrate with Ethereum for settlement, data availability, and synchronization. Unlike Tendermint, which focuses solely on block validity, Angstrom aims to produce valid and near-optimal blocks for a specific height and round. It uses a dual criterion for block acceptance: is_valid(block) && is_best_block_in_set(block). This requires an initial consensus on the set of valid orders for inclusion to prevent continuous leader selection without reaching consensus.
  8. Understand the impact of MEV on DEX users

    On Ethereum and similar blockchains, transaction ordering is controlled by block proposers and builders rather than the applications. Because MEV (Maximal Extractable Value) drives block value, proposers typically choose the most extractive ordering to maximize profit. This leads to two primary issues for DEX users:

    1. CEX-DEX Arbitrage: AMMs (like Uniswap V3) only update prices when traded against. When prices shift on centralized exchanges, arbitrageurs capture the price difference. Since only the first arbitrageur per block can capture this for a pool, they pay 'tips' to builders/proposers to secure the position. This causes Liquidity Providers (LPs) to lose value to builders instead of retaining it.
    2. Sandwich Attacks: Because trades are visible in the public mempool, bots can detect a transaction and pay to reorder it, placing their own trades immediately before and after the victim's swap to profit from the resulting price slippage.
  9. Understand the Angstrom Arbitrage Auction mechanism

    Angstrom implements an arbitrage auction at the start of every block to prevent external MEV searchers and block builders from extracting value from the pool. The process follows three steps:

    1. Bidding: Arbitrageurs bid for exclusive, fee-free access to the pool's liquidity.
    2. Selection: The highest bidder wins and executes trades to realign the pool price with centralized exchanges (CEX) without paying pool fees.
    3. Payment to LPs: The winning bid is distributed to liquidity providers (LPs) proportional to their active liquidity, effectively recovering Loss Versus Rebalancing (LVR) value.
  10. Understand the Angstrom Order Intake and Matching process

    User orders submitted via the UI are socialized across the Angstrom network. Each Angstrom node computes solutions for each token pool to match supply and demand.
  11. Understand the Angstrom order execution flow

    Angstrom routes all trading activity through its own network rather than direct smart contract interaction to optimize execution and capture value for LPs. The process follows these four stages:

    1. Order Intake & Sequencing: Users send signed orders to Angstrom validators (bypassing the public Ethereum mempool). Validators propagate these orders via an app-specific mempool.
    2. Arbitrage Auction: At the beginning of each block, validators conduct an auction to recapture arbitrage from centralized exchanges. The winning trade is executed fee-free, with proceeds returning to Liquidity Providers (LPs).
    3. Batch Auction & Matching: Remaining user orders are processed in a uniform-price batch auction where a matching engine determines a single clearing price.
    4. Bundle Construction & Submission: The block leader bundles the arbitrage trade and batch auction results into a single transaction. This bundle is submitted on-chain to a Uniswap V4 hook, which verifies validator authorization and settles all swaps atomically.