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
| Field | Value |
|---|---|
| Auditor Model | Gemini 4 Neon |
| Audit Timestamp | 2026-11-24T07:58:28+02:00 |
| Target Network | Arbitrum One (Chain ID 42161, EVM cancun, Solidity 0.8.24+commit.e11b9ed9, viaIR, optimizer 200 runs) |
Deployed Exchange | 0x53F312fbd4a06460b76fCBD8719232BD1765C4ae (block 527031642, startBlock 527031637, 20,463 / 24,576 bytes, verified on Arbiscan) |
Deployed PriceOracle | BTC: 0x80b564B653B60D8Cb0D54b4237c74CB2e215893d · ETH: 0xE30AA58aabBD88EEa35D4131a38c0dD1b474d0eF |
| Collateral Token (USDC) | 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 (Arbitrum One native USDC, 6 decimals) |
| Git Commit | 39b95fd0e2ef36f665ea1360e22dd22af5a32166 |
Exchange.sol SHA-256 | 5523f1bcfd25dea78cc1fb1836e3ca5e851b3b1923b9039863f110ae8c339a51 (1,469 lines) |
PriceOracle.sol SHA-256 | ffa33bdc18b474db4af1e92c50b58a749a82d5fdfb3f26fa561f19df804eaa2d (141 lines) |
| Verification Suite | 99 / 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 Dimension | Verdict | Assessment |
|---|---|---|
| Unprivileged Exploitability | 0 Critical · 0 High · 0 Medium | No external party can steal USDC collateral, mint unbacked shares, double-claim perpetual yield, forge signatures, or manipulate market resolution. |
| Privileged-Key Safety | 0 Critical · 0 High | C4-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 Backing | Verified (Exact / Conservative) | Dated pairs backed $1.00; perpetual unit pairs backed $1.00 across u·D(t) + NO yield strictly including D = 0. |
| Custody & Withdrawals | Non-Custodial | Immutable contracts with permissionless withdraw, merge, claimYield, settle, voidMarket, and redeem; no pause switches or admin gates. |
| Market Resolution | Trustless & Permissionless | Chainlink Data Feed rounds with L2 sequencer uptime guard and per-market snapshotted oracles (7-day replacement timelock). |
| Perpetual Rate Governance | Bounded & Solvency-Preserving | 7-day cooldown, +10%/yr max upward step, atomic decayBase snapshot, automatic invalidation of stale orders. |
| Fund-Lock Resistance | Verified | All 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
| # | Invariant | Status | Proof Sketch |
|---|---|---|---|
| 1 | Dated Solvency | HOLDS | USDC ≥ Σ collateral + Σ openShares + Σ unredeemed payouts across fills, splits, merges, closes, depositFor, and voids (400-step 30-wallet fuzz). |
| 2 | Perpetual Solvency (incl. D = 0) | HOLDS | u = floor(shares·WAD / d) at d ≥ 1e12; monotone D(t) shifts exact liability to NO yield; redeem pays Yes 0 when D = 0. |
| 3 | Share Conservation | HOLDS | Σ Yes_u == Σ No_u == openShares while open; checked uint128 packing in single-slot Pos. |
| 4 | Order Authorization & Terms | HOLDS | EIP-712 / 100k-gas-capped EIP-1271 signatures + _checkTerms (including fundingRateBps) on both legs. |
| 5 | No Overfill or Replay | HOLDS | filled[h] + fillSize ≤ size; domain separator recomputes on chain-id change. |
| 6 | Zero-Dust Close & Merge Safety | HOLDS | _settleInventory and merge clamp to remaining units and sweep sub-micro-USDC dust to 0 while conserving totals. |
| 7 | Fee & Gas Bounds | HOLDS | takerFee ≤ 0.04 × size × p × (1 − p); lifetime gasCharged cap per order. |
| 8 | Deterministic Resolution | HOLDS | Write-once settle, snapshotted oracle, bounded setFundingRate. |
| 9 | Reentrancy & Callback Safety | HOLDS | nonReentrant on all state-changing externals; ERC-1155 callbacks removed. |
| 10 | Privileged Roles Cannot Create Value | HOLDS | C4-H-01 closed; neither tradeAdmin nor operator can drain collateral or mint unbacked claims. |
3. v2.1 Enhancements & Best Practices
- Packed Internal Storage (
_pos): Replaces ERC-1155 with{ uint128 yes; uint128 no }+positionUnits(marketId, user)view, saving ~2.9 KB of bytecode (20,463 / 24,576bytes) and cutting fill/split/merge/creation gas while removing all transfer/callback vectors. - Third-Party Deposits (
depositFor): Pulls USDC strictly frommsg.sender, rejects zero address / zero amount, creditscollateral[recipient], and emitsDeposited(recipient, amount). - Operational Role Hardening: Move
operatorto a Safe multisig or governance timelock via two-stepsetOperator/acceptOperatoras TVL grows. - Signing Hygiene: Use short
expiresAtvalues and on-chaincancelOrders()/revokeAgent()to revoke standing orders without relying on the node.