Skip to content

Paxeer Network

Architecture

Overview

v5-ASAMM is built on the Diamond Standard (EIP-2535), a proxy pattern that routes function calls to modular facets via selector-based dispatch. All state is stored in a single AppStorage struct at a deterministic storage slot, ensuring zero storage collisions across facets.

┌─────────────────────────────────────────────────────┐
│                   Diamond Proxy                      │
│  (fallback → delegatecall to facet by selector)      │
├─────────────────────────────────────────────────────┤
│  BUSINESS LOGIC FACETS                               │
│  ┌──────────┬───────────┬──────────┬──────────────┐ │
│  │SwapFacet │Liquidity  │PoolFacet │FeeFacet      │ │
│  │          │Facet      │          │              │ │
│  ├──────────┼───────────┼──────────┼──────────────┤ │
│  │Oracle    │OraclePeg  │Order     │RewardFacet   │ │
│  │Facet     │Facet      │Facet     │              │ │
│  ├──────────┼───────────┼──────────┼──────────────┤ │
│  │FlashLoan │           │          │              │ │
│  │Facet     │           │          │              │ │
│  └──────────┴───────────┴──────────┴──────────────┘ │
│  INFRASTRUCTURE FACETS                               │
│  ┌──────────┬───────────┬──────────┐                │
│  │DiamondCut│DiamondLoup│Ownership │                │
│  │Facet     │eFacet     │Facet     │                │
│  └──────────┴───────────┴──────────┘                │
│                                                      │
│  PERIPHERY (external, stateless)                     │
│  ┌──────┬────────┬────────────┬─────────────┐       │
│  │Router│Quoter  │Position    │OrderManager │       │
│  │      │        │Manager     │             │       │
│  └──────┴────────┴────────────┴─────────────┘       │
│                                                      │
│  EVENT HUB (external)                                │
│  ┌──────────────┐                                   │
│  │EventEmitter  │                                   │
│  └──────────────┘                                   │
└─────────────────────────────────────────────────────┘

Storage Pattern

All facets share a single storage struct via delegatecall. The struct is stored at a deterministic slot computed from keccak256("v5asamm.app.storage"):

solidity
struct AppStorage {
    // Pool state
    mapping(bytes32 => PoolConfig) poolConfigs;
    mapping(bytes32 => PoolState)  poolStates;
    bytes32[] poolIds;
    uint256   poolCount;

    // Positions
    mapping(uint256 => Position) positions;
    uint256 nextPositionId;

    // Tick state
    mapping(bytes32 => mapping(int24 => TickInfo)) ticks;
    mapping(bytes32 => mapping(int16 => uint256))  tickBitmaps;

    // Fee configuration
    mapping(bytes32 => FeeConfig) feeConfigs;

    // Order book
    mapping(uint256 => Order) orders;
    mapping(bytes32 => mapping(int24 => OrderBucket)) orderBuckets;
    uint256 nextOrderId;
    uint256 maxOrdersPerPool;
    uint256 defaultOrderTTL;
    uint256 minOrderSize;
    uint256 keeperBountyBps;

    // Oracle
    mapping(bytes32 => Observation[65535]) observations;
    mapping(bytes32 => ObservationState) observationStates;

    // Oracle peg
    mapping(bytes32 => PegConfig) pegConfigs;

    // Rewards
    mapping(bytes32 => mapping(address => LPRewardState)) lpRewards;
    mapping(address => TraderRewardState) traderRewards;
    uint256 currentEpoch;
    uint256 epochStartTime;
    EpochConfig epochConfig;

    // Protocol
    address treasury;
    bool    paused;
    mapping(address => bool) pauseGuardians;
    mapping(bytes32 => address) poolCreators;
    address eventEmitter;
    uint256 reentrancyStatus;
}

Facet Responsibilities

Business Logic Facets

FacetSelectorsResponsibility
PoolFacet14Pool creation (permissionless), initialization, state queries, pause/unpause
SwapFacet1Sigmoid curve swap execution with progressive fees
LiquidityFacet4Add/remove liquidity, fee collection, position queries
FeeFacet4Quadratic fee calculation, fee config, protocol fee collection
OracleFacet4Internal TWAP oracle with ring buffer observations
OraclePegFacet4External oracle integration for pegged pools
OrderFacet6Limit/stop orders, tick-aligned bucket execution
RewardFacet6LP loyalty multipliers, trader epoch rebates
FlashLoanFacet2Uncollateralized flash loans with fee

Infrastructure Facets

FacetResponsibility
DiamondCutFacetAdd, replace, remove facet selectors (owner only)
DiamondLoupeFacetIntrospection: query facets, selectors, interfaces
OwnershipFacetERC-173 ownership transfer

Periphery Contracts

Periphery contracts are stateless -- they interact with the Diamond via its external interface and hold no protocol state.

ContractPurpose
RouterMulti-hop swaps, slippage protection, deadline enforcement
QuoterOff-chain quote simulation via staticcall
PositionManagerERC-721 NFT LP positions, mint/burn lifecycle
OrderManagerUser-facing order placement, cancellation, status
PositionDescriptorOn-chain SVG metadata for position NFTs
MulticallBatch multiple calls in one transaction
SelfPermitGasless ERC-20 approvals via EIP-2612

EventEmitter

The EventEmitter is a standalone contract that:

  1. Emits rich events for every protocol operation (pools, swaps, liquidity, fees)
  2. Maintains an on-chain registry of pools, LPs, and volume statistics
  3. Provides query functions for dashboards and indexers

Only the Diamond can call emit functions. Anyone can call query functions.

Library Layer

All libraries are internal -- they execute in the Diamond's context via delegatecall.

LibraryPurpose
LibDiamondDiamond storage, selector→facet mapping, cut logic
LibPoolPool creation, state access, token sorting, pool ID computation
LibSwapSigmoid math: Padé tanh, swap step calculation
LibFeeQuadratic fee formula, fee distribution splits
LibOracleTWAP accumulator, observation ring buffer, geometric mean
LibOrderTick-bucket FIFO queue: insert, remove, drain
LibRewardTime+volume multiplier, epoch transitions
LibSecurityReentrancy guard, pausable, access control
LibPositionLP position accounting, fee growth tracking
LibTransferSafe ERC-20 transfers (handles non-standard returns)
LibTickBitmapBitmap for efficient next-initialized-tick queries
LibEventEmitterSafe external calls to EventEmitter from facets

Utility Contracts

Zero external dependencies -- every utility is hand-written:

ContractPurpose
FixedPointMathQ128.128 fixed-point: mul, div, tanh, sqrt, min/max
FullMath512-bit mulDiv for overflow-safe intermediate products
SqrtPriceMathToken amount deltas from sqrt price ranges
TickMathTick↔sqrtPriceX96 conversions
ERC20Minimal custom ERC-20
ERC721Minimal custom ERC-721
ERC721PermitERC-721 + EIP-4494 permit

Call Flow Examples

Swap Flow

User → Router.exactInputSingle()
  → Diamond.swap(params)
    → SwapFacet (via delegatecall)
      → LibSecurity.nonReentrantBefore()
      → LibSwap.computeSwapStep() [sigmoid math]
      → LibFee.calculateProgressiveFee() [quadratic]
      → LibPool.updateReserves()
      → LibOracle.write() [TWAP observation]
      → LibEventEmitter.emitSwap() → EventEmitter
      → LibSecurity.nonReentrantAfter()

Add Liquidity Flow

User → PositionManager.mint()
  → Diamond.addLiquidity(params)
    → LiquidityFacet (via delegatecall)
      → LibSecurity checks
      → LibPosition.createOrUpdate()
      → LibPool.updateLiquidity()
      → LibTransfer.safeTransferFrom() [pull tokens]
      → LibEventEmitter.emitLiquidityAdded()

Pool Creation Flow

Anyone → Diamond.createPool(config)
  → PoolFacet (via delegatecall)
    → LibSecurity.requireNotPaused()
    → Validate tickSpacing, baseFee, maxImpactFee
    → LibPool.createPool() [sort tokens, compute ID, store config]
    → Store feeConfig, track creator
    → LibEventEmitter.emitPoolCreated()

License

Licensed under the GNU General Public License v3.0--see LICENSE for terms.

Copyright (C) 2026 PaxLabs Inc.
SPDX-License-Identifier: GPL-3.0-only

Contact & Resources

ResourceLink
Protocol Documentationdocs.hyperpaxeer.com
Block Explorerpaxscan.paxeer.app
Sidiora Exchangeapp.hyperpaxeer.com
Websitepaxeer.app
Twitter/X@paxeer_app
General Inquiriesinfopaxeer@paxeer.app
Security Reportssecurity@paxeer.app

Released under the GPL-3.0 License.