Security

xendune implements multiple layers of security across its 32 smart contracts. All admin operations are controlled by a Gnosis Safe multisig wallet.

Access Control

Role Hierarchy

Role Assignment Permissions
Owner Gnosis Safe multisig Global configuration, role management
Admin Set by Owner Arbitration, keyword approval, forced operations
CS Set by Owner Arbitration assistance
Factory Automatic (inter-contract calls) Product/trade registration
Authorized Product Set by Factory Deposit deductions

Core Principle

Owner/admin have no functions to directly withdraw or transfer user funds. All fund flows are triggered through business logic (arbitration resolution, trade settlement, zombie reclamation), with every transfer emitting events for transparency.

Reentrancy Protection

All contracts use uint256-based reentrancy locks (not bool)—best practice for EIP-1167 clones. Clone contracts have storage initialized to zero; bool defaults to false which cannot distinguish "uninitialized" from "unlocked". The uint256 pattern (0→1 in initialize(), then 1→2→1 for lock/unlock) ensures correct behavior in cloned contracts.

Anti-Bot Protection

The noContract modifier blocks smart contract calls (except whitelisted contracts):

modifier noContract() {
    if (msg.sender != tx.origin && !settings.isContractWhitelisted(msg.sender))
        revert NoContractCalls();
    _;
}

This defends against flash loan attacks and automated exploits.

Safe Transfer Pattern

All USDT transfers use ProductLib._safeTransferToUser() with pull payment safety net:

  1. Attempt direct transfer to recipient
  2. If transfer fails (e.g., recipient is a contract rejecting transfers), store amount in pendingWithdrawals[recipient]
  3. Recipient can later call claimPending() to retrieve funds

This prevents a single failed transfer from blocking entire settlement flow.

Deposit-Based Trust

Merchant deposits create real economic skin in the game:

Audit Findings

The protocol has been audited with findings addressed in the following categories:

Input Validation

Business Logic

Gas Optimization

Design Decisions

Emergency Response