documentation

Audit Report — Gemini 4 Neon (v2.1)

Formal smart contract security audit of Arizal Exchange v2.1 on Arbitrum One, covering Round 4 remediations, packed internal position accounting, zero-dust closes/merges, and depositFor.

Audit Metadata

FieldValue
Auditor ModelGemini 4 Neon
Audit Timestamp2026-11-24T07:58:28+02:00
Target NetworkArbitrum One (Chain ID 42161, EVM cancun, Solidity 0.8.24+commit.e11b9ed9, viaIR, optimizer 200 runs)
Deployed Exchange0x53F312fbd4a06460b76fCBD8719232BD1765C4ae (block 527031642, startBlock 527031637, 20,463 / 24,576 bytes, verified on Arbiscan)
Deployed PriceOracleBTC: 0x80b564B653B60D8Cb0D54b4237c74CB2e215893d · ETH: 0xE30AA58aabBD88EEa35D4131a38c0dD1b474d0eF
Collateral Token (USDC)0xaf88d065e77c8cC2239327C5EDb3A432268e5831 (Arbitrum One native USDC, 6 decimals)
Git Commit39b95fd0e2ef36f665ea1360e22dd22af5a32166
Exchange.sol SHA-2565523f1bcfd25dea78cc1fb1836e3ca5e851b3b1923b9039863f110ae8c339a51 (1,469 lines)
PriceOracle.sol SHA-256ffa33bdc18b474db4af1e92c50b58a749a82d5fdfb3f26fa561f19df804eaa2d (141 lines)
Verification Suite99 / 99 passing Hardhat tests (unit, batch isolation, 9-test PerpetualHit.js suite, AuditPoC.js / AuditPoC2.js / AuditPoC3.js / AuditPoC4.js, and 400-step 30-wallet randomized solvency fuzz)

1. Executive Summary & Security Verdict

This audit evaluated the live v2.1 Arbitrum One deployment at 0x53F312fbd4a06460b76fCBD8719232BD1765C4ae, which remediates every Round 4 finding (C4-H-01, C4-L-01, C4-I-01, C4-I-04), removes ERC-1155 in favor of a single-slot packed internal mapping (Pos { uint128 yes; uint128 no }), hardens zero-dust closes and merges, and adds depositFor(recipient, amount).

Security DimensionVerdictAssessment
Unprivileged Exploitability0 Critical · 0 High · 0 MediumNo external party can steal USDC collateral, mint unbacked shares, double-claim perpetual yield, forge signatures, or manipulate market resolution.
Privileged-Key Safety0 Critical · 0 HighC4-H-01 is eliminated: redeem uses _decayFactor(m) strictly, perpetual startTs is bounded, and new mints/splits revert below MIN_MINT_DECAY (1e12). Neither operator nor tradeAdmin can drain user collateral.
100% Collateral BackingVerified (Exact / Conservative)Dated pairs backed $1.00; perpetual unit pairs backed $1.00 across u·D(t) + NO yield strictly including D = 0.
Custody & WithdrawalsNon-CustodialImmutable contracts with permissionless withdraw, merge, claimYield, settle, voidMarket, and redeem; no pause switches or admin gates.
Market ResolutionTrustless & PermissionlessChainlink Data Feed rounds with L2 sequencer uptime guard and per-market snapshotted oracles (7-day replacement timelock).
Perpetual Rate GovernanceBounded & Solvency-Preserving7-day cooldown, +10%/yr max upward step, atomic decayBase snapshot, automatic invalidation of stale orders.
Fund-Lock ResistanceVerifiedAll dated markets reach settle or voidMarket (7d Above/Between, 30d dated Hit); perpetuals keep merge, claimYield, touch settle, and redeem.

2. Formal Invariant Verification Matrix

#InvariantStatusProof Sketch
1Dated SolvencyHOLDSUSDC ≥ Σ collateral + Σ openShares + Σ unredeemed payouts across fills, splits, merges, closes, depositFor, and voids (400-step 30-wallet fuzz).
2Perpetual Solvency (incl. D = 0)HOLDSu = floor(shares·WAD / d) at d ≥ 1e12; monotone D(t) shifts exact liability to NO yield; redeem pays Yes 0 when D = 0.
3Share ConservationHOLDSΣ Yes_u == Σ No_u == openShares while open; checked uint128 packing in single-slot Pos.
4Order Authorization & TermsHOLDSEIP-712 / 100k-gas-capped EIP-1271 signatures + _checkTerms (including fundingRateBps) on both legs.
5No Overfill or ReplayHOLDSfilled[h] + fillSize ≤ size; domain separator recomputes on chain-id change.
6Zero-Dust Close & Merge SafetyHOLDS_settleInventory and merge clamp to remaining units and sweep sub-micro-USDC dust to 0 while conserving totals.
7Fee & Gas BoundsHOLDStakerFee ≤ 0.04 × size × p × (1 − p); lifetime gasCharged cap per order.
8Deterministic ResolutionHOLDSWrite-once settle, snapshotted oracle, bounded setFundingRate.
9Reentrancy & Callback SafetyHOLDSnonReentrant on all state-changing externals; ERC-1155 callbacks removed.
10Privileged Roles Cannot Create ValueHOLDSC4-H-01 closed; neither tradeAdmin nor operator can drain collateral or mint unbacked claims.

3. v2.1 Enhancements & Best Practices