Skip to main content

Architecture

ZibaXeer is a full-stack on-chain protocol. This page covers how every layer connects — from the smart contracts on HyperPaxeer through the off-chain indexer and backend, to the React dashboard.

System Overview


Monorepo Structure

ZibaXeer/
├── apps/
│   ├── backend/          # Express.js API + BullMQ workers
│   ├── frontend/         # Next.js 15 dashboard
│   └── indexer/          # ethers.js on-chain event listener
├── contracts/            # Foundry smart contract project
├── packages/
│   ├── db/               # Shared Prisma client + schema
│   ├── sdk/              # Protocol SDK (WIP)
│   ├── types/            # Shared TypeScript types (job payloads)
│   └── utils/            # Shared utility helpers
└── docs/                 # This documentation

Trade Execution Flow

The complete sequence from a leader executing a trade to it appearing in the dashboard:

Vault Deployment Flow


Follower Subscription Flow


Revenue Distribution Flow

The split percentages are configurable per vault and stored in leaderShareBps and protocolFeeBps on the RevenueSplitter contract.

Queue Architecture

The indexer produces to four named BullMQ queues. The backend workers consume them.
QueueProducerConsumerPurpose
TradeProcessingQueuetrade.processor.tstrade.worker.tsPersist trade to DB
SnapshotCalculationQueuepnl.processor.tssnapshot.worker.tsRecalculate ROI/drawdown
VaultDeployedQueuevaultFactory.listener.tsvault.worker.tsRegister new vault in DB
FollowerEventQueuevault.listener.tsfollower.worker.tsSync follower subscriptions

Sidiora Perpetuals Trust Model

Sidiora integration introduces an intentional split of responsibility between on-chain controls and off-chain execution.
LayerResponsibilityTrust Boundary
On-chain adapter (SidioraVaultAdapter)Margin movement and delegate managementEnforced by Solidity access control
Indexer + mirror workersSignal handling, risk checks, and order forwardingTrusted service boundary
Sidiora sequencerOrder matching and batch settlementExternal dependency boundary
Non-negotiable constraints:
  • Mirror delegation must never include withdrawal permission.
  • Delegate compromise must be recoverable by on-chain revoke/rotate flows.
  • Risk checks must execute before any follower order is signed.
See the detailed spec in backend/sidiora-mirroring.

Sidiora Failure Domains

DomainExample FailureMitigation
Sequencer dependencySequencer API outageQueue buffering, backoff, temporary freeze
Mirror bot operationsSigning key compromiseOn-chain delegate revoke + key rotation
Risk policy enforcementIncorrect sizing across followersHard policy gate + freeze endpoint
Event pipelineQueue lag and delayed mirrorsBackpressure + autoscaling workers
Failure handling runbooks and message schemas are defined in backend/sidiora-mirroring.

Vault Lifecycle


Contract Dependency Map