ETH Price: $2,903.08 (-1.19%)
 

Overview

ETH Balance

2 wei

Eth Value

Less Than $0.01 (@ $2,903.08/ETH)

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Withdraw Fees237402852025-11-06 12:37:1181 days ago1762432631IN
0xAe1D3Af8...51Ec15611
0 ETH0.000165543.00817583
Withdraw Fees237402812025-11-06 12:36:2381 days ago1762432583IN
0xAe1D3Af8...51Ec15611
0 ETH0.000137732.97481155
Approve Deal236298922025-10-22 1:46:5996 days ago1761097619IN
0xAe1D3Af8...51Ec15611
0 ETH0.000215271.60739336
Submit Work236298862025-10-22 1:45:4796 days ago1761097547IN
0xAe1D3Af8...51Ec15611
0 ETH0.000131941.6070101
Accept Deal236298812025-10-22 1:44:4796 days ago1761097487IN
0xAe1D3Af8...51Ec15611
0 ETH0.000117651.61207969
Create Deal ERC2...236298752025-10-22 1:43:3596 days ago1761097415IN
0xAe1D3Af8...51Ec15611
0 ETH0.000448521.60778226
Resolve Dispute236265822025-10-21 14:38:2396 days ago1761057503IN
0xAe1D3Af8...51Ec15611
0 ETH0.000523352.55901642
Raise Dispute236265742025-10-21 14:36:4796 days ago1761057407IN
0xAe1D3Af8...51Ec15611
0 ETH0.00016952.49357848
Submit Work236264232025-10-21 14:06:2396 days ago1761055583IN
0xAe1D3Af8...51Ec15611
0 ETH0.000152931.86266948
Accept Deal236264172025-10-21 14:05:1196 days ago1761055511IN
0xAe1D3Af8...51Ec15611
0 ETH0.000104591.87162083
Create Deal ETH236264102025-10-21 14:03:4796 days ago1761055427IN
0xAe1D3Af8...51Ec15611
0.0057 ETH0.000612811.90428264

Latest 4 internal transactions

Advanced mode:
Parent Transaction Hash Method Block
From
To
Transfer237402812025-11-06 12:36:2381 days ago1762432583
0xAe1D3Af8...51Ec15611
0.0025806 ETH
Transfer236265822025-10-21 14:38:2396 days ago1761057503
0xAe1D3Af8...51Ec15611
0.00214367 ETH
Transfer236265822025-10-21 14:38:2396 days ago1761057503
0xAe1D3Af8...51Ec15611
0.00091871 ETH
Transfer236265822025-10-21 14:38:2396 days ago1761057503
0xAe1D3Af8...51Ec15611
0.000057 ETH
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
YBZCore

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 16 : YBZCore.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/**
 * @title YBZ.io - Decentralized Escrow Platform
 * @notice "Trustless. Transparent. Guaranteed."
 * @dev Main entry point for YBZ.io escrow system.
 *      Code is Law. Immutable Code is Reliable Law.
 * 
 * @author YBZ.io Team
 * @custom:website https://ybz.io
 * @custom:security-contact [email protected]
 * @custom:version 1.0.3
 * @custom:date 2025-10-18
 */

import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
import "./interfaces/IYBZCore.sol";
import "./libraries/DealValidation.sol";

contract YBZCore is 
    AccessControl,
    ReentrancyGuard,
    Pausable,
    IYBZCore
{
    using SafeERC20 for IERC20;
    using DealValidation for *;
    
    // ============ Roles ============
    
    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
    bytes32 public constant ARBITER_ROLE = keccak256("ARBITER_ROLE");
    
    // ============ Hardcoded Addresses (Ethereum Mainnet Only) ============
    
    /// @notice Chainlink ETH/USD price feed (Mainnet)
    address public constant CHAINLINK_ETH_USD = 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419;
    
    /// @notice USDT address (Mainnet)
    address public constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
    
    /// @notice USDC address (Mainnet)
    address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
    
    /// @notice Initial arbiters (hardcoded)
    address public constant ARBITER_1 = 0xB1BB66C47DEE78b91E8AEEb6E74e66e02CA34567;
    address public constant ARBITER_2 = 0xBf3a2c7c9bC27e3143dF965fFa80E421f5445678;

    // ============ State Variables ============
    
    /// @notice Deal counter
    uint256 private _dealIdCounter;
    
    /// @notice Stablecoin configuration
    struct StablecoinInfo {
        bool isActive;      // Whether this stablecoin is supported
        uint8 decimals;     // Token decimals (6 for USDT/USDC, 18 for DAI)
    }
    
    /// @notice All deals
    mapping(uint256 => Deal) private _deals;
    
    /// @notice Dispute resolutions
    mapping(uint256 => DisputeResolution) private _resolutions;
    
    /// @notice Supported stablecoins registry (replaces tokenWhitelist for ERC20)
    /// @dev address(0) is reserved for ETH (not a stablecoin)
    mapping(address => StablecoinInfo) public stablecoins;
    
    /// @notice List of all registered stablecoin addresses
    address[] public stablecoinList;
    
    /// @notice Accumulated platform fees by token (treasury balance)
    /// @dev token => accumulated fee amount
    mapping(address => uint256) public accumulatedFees;
    
    // ============ Fee Management (Integrated) ============
    
    /// @notice Default platform fee in basis points (200 = 2%)
    uint16 public defaultPlatformFeeBps;
    
    /// @notice Default arbiter fee in basis points (100 = 1%)
    uint16 public defaultArbiterFeeBps;
    
    /// @notice Maximum fee in basis points (1000 = 10%)
    uint16 public constant MAX_FEE_BPS = 1000;
    
    /// @notice Tiered fee structure: amount threshold => fee in bps
    mapping(uint256 => uint16) public tieredPlatformFees;
    
    /// @notice Array of tier thresholds for iteration
    uint256[] public tierThresholds;
    
    // ============ Treasury (Integrated) ============
    
    /// @notice Withdrawal destination address
    address public withdrawalAddress;
    
    
    // ============ Arbitration (Integrated) ============
    
    /// @notice Arbiter information
    struct ArbiterInfo {
        bool isActive;
        uint256 totalCases;
        uint256 resolvedCases;
        uint256 reputation; // 0-100 score (not used currently)
        uint16 arbiterFeeBps; // Individual arbiter fee in basis points (can be adjusted by admin)
        uint64 registeredAt;
    }
    
    /// @notice Registered arbiters
    mapping(address => ArbiterInfo) public arbiters;
    
    /// @notice List of all arbiter addresses
    address[] public arbiterList;
    
    // ============ Price Oracle (Integrated - Chainlink) ============
    
    /// @notice Chainlink ETH/USD price feed interface
    AggregatorV3Interface public ethUsdPriceFeed;
    
    /// @notice Cached ETH price (8 decimals)
    uint256 public cachedEthPrice;
    
    /// @notice Price cache timestamp
    uint256 public priceCacheTime;
    
    /// @notice Price cache duration (10 minutes)
    uint256 public constant PRICE_CACHE_DURATION = 10 minutes;
    
    /// @notice Minimum deal amount in USD (8 decimals: 2000_0000_0000 = $20.00)
    uint256 public constant MIN_DEAL_AMOUNT_USD = 20_0000_0000; // $20.00
    
    /// @notice Minimum platform fee in USD (8 decimals: 1000_0000_0000 = $10.00)
    uint256 public constant MIN_FEE_USD = 10_0000_0000; // $10.00
    
    /// @notice Maximum dispute cooldown period (24 hours)
    /// @dev Actual cooldown is dynamic: min(24 hours, confirmWindow / 2)
    /// @dev This prevents buyers from being locked out of disputes in short-term deals
    uint64 public constant MAX_DISPUTE_COOLDOWN = 24 hours;
    
    /// @notice Platform brand message for event marketing
    /// @dev Displayed in blockchain explorers for brand exposure
    string public constant PLATFORM_MESSAGE = "ybz.io - Escrow Layer";
    
    // ============ Events ============
    
    // Core Events (from IYBZCore interface)
    
    // Fee Management Events
    event FeeWithdrawn(address indexed token, address indexed recipient, uint256 amount);
    
    // Arbitration Events (important business operations)
    event ArbiterRegistered(address indexed arbiter, uint64 timestamp);
    event ArbiterRemoved(address indexed arbiter);
    
    // ============ Errors ============
    
    error DisputeCooldownActive(uint64 remainingTime);
    error InvalidFee();
    error InvalidThreshold();
    error TierAlreadyExists();
    error TierNotFound();
    error ArbiterNotFound();
    error ArbiterAlreadyExists();
    error ArbiterInactive();
    error InsufficientBalance();
    error InvalidPrice();
    
    // ============ Constructor ============
    
    /**
     * @notice Constructs the unified escrow contract
     * @param admin Admin address
     * @param withdrawalAddr Initial withdrawal address for fees
     * @dev Everything else is auto-configured (Chainlink, stablecoins, arbiters)
     */
    constructor(
        address admin,
        address withdrawalAddr
    ) {
        require(admin != address(0), "Invalid admin");
        require(withdrawalAddr != address(0), "Invalid withdrawal address");
        
        // Grant roles
        _grantRole(DEFAULT_ADMIN_ROLE, admin);
        _grantRole(OPERATOR_ROLE, admin);
        
        // Initialize fee structure
        defaultPlatformFeeBps = 200;  // 2%
        defaultArbiterFeeBps = 100;   // 1%
        
        // Initialize treasury
        withdrawalAddress = withdrawalAddr;
        
        // Auto-configure Chainlink price feed and stablecoins for mainnet
        if (block.chainid == 1) {
            // Ethereum Mainnet - Auto-configure everything
            ethUsdPriceFeed = AggregatorV3Interface(CHAINLINK_ETH_USD);
            
            // Register hardcoded arbiters (mainnet only)
            _registerArbiterInternal(ARBITER_1);
            _registerArbiterInternal(ARBITER_2);
            
            // Auto-register USDT
            stablecoins[USDT] = StablecoinInfo({
                isActive: true,
                decimals: 6
            });
            stablecoinList.push(USDT);
            
            // Auto-register USDC
            stablecoins[USDC] = StablecoinInfo({
                isActive: true,
                decimals: 6
            });
            stablecoinList.push(USDC);
        }
        // For other networks (testnet/localhost), use setManualPrice() for testing
        
        _dealIdCounter = 1; // Start from 1
    }
    
    // ============ Deal Creation ============
    
    /**
     * @notice Creates a new ETH escrow deal
     * @param seller Seller address
     * @param termsHash IPFS hash of deal terms
     * @param acceptWindow Time window for seller to accept (seconds)
     * @param submitWindow Time window for seller to submit work (seconds)
     * @param confirmWindow Time window for buyer to confirm (seconds)
     * @param preferredArbiter Optional: pre-select arbiter (must be active, or address(0) for random)
     * @return dealId New deal identifier
     */
    function createDealETH(
        address seller,
        bytes32 termsHash,
        uint64 acceptWindow,
        uint64 submitWindow,
        uint64 confirmWindow,
        address preferredArbiter
    ) external payable override nonReentrant whenNotPaused returns (uint256 dealId) {
        // Validate inputs
        DealValidation.validateCreateDeal(
            seller,
            msg.value,
            termsHash,
            acceptWindow,
            submitWindow,
            confirmWindow
        );
        
        if (msg.sender == seller) revert DealValidation.InvalidAddress();
        
        // Create deal
        dealId = _createDeal(
            msg.sender,
            seller,
            address(0), // ETH
            msg.value,
            termsHash,
            acceptWindow,
            submitWindow,
            confirmWindow,
            preferredArbiter
        );
        
        // Get created deal data for event
        Deal storage newDeal = _deals[dealId];
        
        emit DealCreated(
            dealId, 
            msg.sender, 
            seller, 
            address(0), 
            msg.value,
            newDeal.creationPriceUSD,
            newDeal.platformFeeBps,
            newDeal.arbiterFeeBps,
            termsHash, 
            acceptWindow, 
            submitWindow, 
            confirmWindow, 
            preferredArbiter, 
            PLATFORM_MESSAGE
        );
    }
    
    /**
     * @notice Creates a new ERC20 escrow deal (USDT/USDC only)
     * @param seller Seller address
     * @param token Token address (must be USDT or USDC)
     * @param amount Token amount
     * @param termsHash IPFS hash of deal terms
     * @param acceptWindow Time window for seller to accept (seconds)
     * @param submitWindow Time window for seller to submit work (seconds)
     * @param confirmWindow Time window for buyer to confirm (seconds)
     * @param preferredArbiter Optional: pre-select arbiter (must be active, or address(0) for random)
     * @return dealId New deal identifier
     * @dev Only stablecoins (USDT/USDC) are supported for ERC20 deals
     */
    function createDealERC20(
        address seller,
        address token,
        uint256 amount,
        bytes32 termsHash,
        uint64 acceptWindow,
        uint64 submitWindow,
        uint64 confirmWindow,
        address preferredArbiter
    ) external override nonReentrant whenNotPaused returns (uint256 dealId) {
        // Validate token is a supported stablecoin
        if (token == address(0)) revert DealValidation.InvalidAddress();
        
        StablecoinInfo memory stablecoin = stablecoins[token];
        require(stablecoin.isActive, "Token is not a supported stablecoin");
        
        // ===== Early USD Amount Check for Stablecoins (Gas Optimization) =====
        // Stablecoins are 1:1 USD, convert to 8 decimals for comparison
        // Formula: amount * 10^(8 - tokenDecimals)
        // Example: 100 USDT (6 decimals) = 100000000 → 10000000000 (8 decimals) = $100
        
        uint256 dealAmountUSD;
        if (stablecoin.decimals <= 8) {
            dealAmountUSD = amount * (10 ** (8 - stablecoin.decimals));
        } else {
            dealAmountUSD = amount / (10 ** (stablecoin.decimals - 8));
        }
        
        // Check minimum deal amount ($20 USD)
        require(dealAmountUSD >= MIN_DEAL_AMOUNT_USD, "Deal amount below $20 minimum");
        
        // Minimum fee ($10) will be enforced in _releaseFunds:
        // - If amount * 2% < $10 → charge $10
        // - If amount * 2% >= $10 → charge 2%
        // This way $20-$500 orders are accepted but pay $10 minimum
        
        // ===== End Early Check =====
        if (seller == address(0)) revert DealValidation.InvalidAddress();
        if (termsHash == bytes32(0)) revert DealValidation.InvalidTermsHash();
        if (acceptWindow < DealValidation.MIN_ACCEPT_WINDOW || acceptWindow > DealValidation.MAX_ACCEPT_WINDOW) {
            revert DealValidation.InvalidTimeWindow();
        }
        if (submitWindow < DealValidation.MIN_SUBMIT_WINDOW || submitWindow > DealValidation.MAX_SUBMIT_WINDOW) {
            revert DealValidation.InvalidTimeWindow();
        }
        if (confirmWindow < DealValidation.MIN_CONFIRM_WINDOW || confirmWindow > DealValidation.MAX_CONFIRM_WINDOW) {
            revert DealValidation.InvalidTimeWindow();
        }
        
        if (msg.sender == seller) revert DealValidation.InvalidAddress();
        
        // Transfer tokens to contract
        IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
        
        // Create deal
        dealId = _createDeal(
            msg.sender,
            seller,
            token,
            amount,
            termsHash,
            acceptWindow,
            submitWindow,
            confirmWindow,
            preferredArbiter
        );
        
        // Get created deal data for event
        Deal storage newDeal = _deals[dealId];
        
        emit DealCreated(
            dealId, 
            msg.sender, 
            seller, 
            token, 
            amount,
            newDeal.creationPriceUSD,
            newDeal.platformFeeBps,
            newDeal.arbiterFeeBps,
            termsHash, 
            acceptWindow, 
            submitWindow, 
            confirmWindow, 
            preferredArbiter, 
            PLATFORM_MESSAGE
        );
    }
    
    /**
     * @notice Internal deal creation logic
     */
    function _createDeal(
        address buyer,
        address seller,
        address token,
        uint256 amount,
        bytes32 termsHash,
        uint64 acceptWindow,
        uint64 submitWindow,
        uint64 confirmWindow,
        address preferredArbiter
    ) internal returns (uint256 dealId) {
        dealId = _dealIdCounter++;
        
        // ============ Arbiter Validation ============
        
        address assignedArbiter = address(0);
        
        // If user pre-selects an arbiter, validate it
        if (preferredArbiter != address(0)) {
            require(
                _isActiveArbiter(preferredArbiter),
                "Preferred arbiter is not active"
            );
            assignedArbiter = preferredArbiter;
        }
        // If address(0), arbiter will be randomly assigned during dispute
        
        // ============ USD Amount Validation ============
        
        uint256 creationPriceUSD = 0;
        
        // Check if token is a stablecoin (registered in our system)
        StablecoinInfo memory stablecoin = stablecoins[token];
        
        if (stablecoin.isActive) {
            // ===== Stablecoin (USDT/USDC/DAI): Simple validation =====
            // Already validated in createDealERC20 (early check)
            // Just confirm minimum deal amount using dynamic decimals
            
            uint256 dealAmountUSD;
            if (stablecoin.decimals <= 8) {
                dealAmountUSD = amount * (10 ** (8 - stablecoin.decimals));
            } else {
                dealAmountUSD = amount / (10 ** (stablecoin.decimals - 8));
            }
            require(dealAmountUSD >= MIN_DEAL_AMOUNT_USD, "Deal amount below $20 minimum");
            
            // Fee will be enforced in _releaseFunds: max(amount * 2%, $10)
            // No rejection here - always accept if >= $20
            
            // creationPriceUSD = 0 for stablecoins
            
        } else {
            // ===== ETH: Query price ONCE and save (with 10-min cache) =====
            // Get ETH price and update cache if needed
            // If cache valid (<10 min): returns cached price (cheap)
            // If cache expired: queries Chainlink and updates cache (expensive, but helps next user)
            creationPriceUSD = _getEthPriceUSD();
            require(creationPriceUSD > 0, "Invalid price");
            
            // Calculate USD values using this single price query
            uint256 dealAmountUSD = (amount * creationPriceUSD) / 1e18;
            
            // Check minimum deal amount ($20 USD)
            require(dealAmountUSD >= MIN_DEAL_AMOUNT_USD, "Deal amount below $20 minimum");
            
        }
        
        // ============ End USD Validation ============
        
        // Get fee rates
        uint16 platformFeeBps = _getPlatformFeeBps(amount);
        
        // Get arbiter fee rate: use assigned arbiter's rate if pre-selected, otherwise default
        uint16 arbiterFeeBps;
        if (assignedArbiter != address(0)) {
            arbiterFeeBps = arbiters[assignedArbiter].arbiterFeeBps;
        } else {
            arbiterFeeBps = defaultArbiterFeeBps;
        }
        
        // Calculate deadlines
        uint64 now64 = uint64(block.timestamp);
        uint64 acceptDeadline = now64 + acceptWindow;
        uint64 submitDeadline = acceptDeadline + submitWindow;
        uint64 confirmDeadline = submitDeadline + confirmWindow;
        
        _deals[dealId] = Deal({
            buyer: buyer,
            seller: seller,
            token: token,
            amount: amount,
            creationPriceUSD: creationPriceUSD,
            platformFeeBps: platformFeeBps,
            arbiterFeeBps: arbiterFeeBps,
            termsHash: termsHash,
            deliveryHash: bytes32(0),
            acceptDeadline: acceptDeadline,
            submitDeadline: submitDeadline,
            confirmDeadline: confirmDeadline,
            acceptWindow: acceptWindow,
            submitWindow: submitWindow,
            confirmWindow: confirmWindow,
            createdAt: now64,
            submittedAt: 0,
            arbiter: assignedArbiter,
            status: DealStatus.Created,
            refundRequested: false
        });
    }
    
    // ============ Deal Workflow ============
    
    /**
     * @notice Seller accepts the deal
     * @param dealId Deal identifier
     */
    function acceptDeal(uint256 dealId) external override nonReentrant whenNotPaused {
        Deal storage deal = _deals[dealId];
        
        // Validations
        DealValidation.requireStatus(deal.status, DealStatus.Created);
        DealValidation.requireAuthorized(deal, msg.sender, false);
        DealValidation.requireDeadlineNotPassed(deal.acceptDeadline);
        
        // Update status
        deal.status = DealStatus.Accepted;
        
        emit DealAccepted(dealId, msg.sender, deal.submitDeadline);
    }
    
    /**
     * @notice Seller submits work
     * @param dealId Deal identifier
     * @param deliveryHash IPFS hash of delivery proof
     */
    function submitWork(uint256 dealId, bytes32 deliveryHash) 
        external 
        override 
        nonReentrant 
        whenNotPaused 
    {
        Deal storage deal = _deals[dealId];
        
        // Validations
        DealValidation.requireStatus(deal.status, DealStatus.Accepted);
        DealValidation.requireAuthorized(deal, msg.sender, false);
        DealValidation.requireDeadlineNotPassed(deal.submitDeadline);
        
        if (deliveryHash == bytes32(0)) revert DealValidation.InvalidTermsHash();
        
        // Update deal
        deal.deliveryHash = deliveryHash;
        deal.submittedAt = uint64(block.timestamp);
        deal.status = DealStatus.Submitted;
        
        // Recalculate confirmDeadline based on actual submission time
        // This gives buyer full confirmWindow starting from NOW
        deal.confirmDeadline = uint64(block.timestamp) + deal.confirmWindow;
        
        emit WorkSubmitted(dealId, deliveryHash, deal.confirmDeadline);
    }
    
    /**
     * @notice Buyer approves and releases payment
     * @param dealId Deal identifier
     */
    function approveDeal(uint256 dealId) external override nonReentrant whenNotPaused {
        Deal storage deal = _deals[dealId];
        
        // Validations
        DealValidation.requireStatus(deal.status, DealStatus.Submitted);
        DealValidation.requireAuthorized(deal, msg.sender, true);
        DealValidation.requireDeadlineNotPassed(deal.confirmDeadline);
        
        // Mark as approved
        deal.status = DealStatus.Approved;
        
        // Release funds
        _releaseFunds(dealId, deal.seller, 100, 0);
        
        emit DealApproved(dealId, deal.seller, deal.amount);
        
        // Clean up storage
        _closeDeal(dealId);
    }
    
    /**
     * @notice Raises a dispute
     * @param dealId Deal identifier
     * @param evidenceHash IPFS hash of evidence
     * @dev Requires 24-hour cooldown after work submission to prevent malicious disputes
     */
    function raiseDispute(uint256 dealId, bytes32 evidenceHash) 
        external 
        override 
        nonReentrant 
        whenNotPaused 
    {
        Deal storage deal = _deals[dealId];
        
        // Can dispute in Accepted or Submitted states
        if (deal.status != DealStatus.Accepted && deal.status != DealStatus.Submitted) {
            revert DealValidation.InvalidStatus(deal.status, DealStatus.Submitted);
        }
        
        // Only buyer or seller can raise dispute
        if (msg.sender != deal.buyer && msg.sender != deal.seller) {
            revert DealValidation.Unauthorized();
        }
        
        // Enforce dynamic cooldown period after work submission
        if (deal.status == DealStatus.Submitted && deal.submittedAt > 0) {
            // Calculate cooldown based on total confirm time (fixed at submission)
            // cooldown = min(24h, confirmWindow / 2)
            uint64 totalConfirmTime = deal.confirmDeadline - deal.submittedAt;
            uint64 cooldownPeriod = totalConfirmTime < (MAX_DISPUTE_COOLDOWN * 2) 
                ? totalConfirmTime / 2 
                : MAX_DISPUTE_COOLDOWN;
            
            uint64 timeSinceSubmission = uint64(block.timestamp) - deal.submittedAt;
            if (timeSinceSubmission < cooldownPeriod) {
                uint64 remainingTime = cooldownPeriod - timeSinceSubmission;
                revert DisputeCooldownActive(remainingTime);
            }
        }
        
        // Select arbiter: use preferred arbiter if set, otherwise random
        address arbiter;
        if (deal.arbiter != address(0)) {
            // User pre-selected arbiter during deal creation
            arbiter = deal.arbiter;
            // Verify arbiter is still active
            require(_isActiveArbiter(arbiter), "Pre-selected arbiter is no longer active");
        } else {
            // No preferred arbiter, select randomly
            arbiter = _selectRandomArbiter();
            deal.arbiter = arbiter;
            // Update arbiter fee to match selected arbiter's rate
            deal.arbiterFeeBps = arbiters[arbiter].arbiterFeeBps;
        }
        
        deal.status = DealStatus.Disputed;
        
        // Register dispute (update arbiter stats)
        _registerDispute(dealId, msg.sender, arbiter);
        
        emit DisputeRaised(dealId, msg.sender, evidenceHash);
    }
    
    /**
     * @notice Resolves a dispute (arbiter only)
     * @param dealId Deal identifier
     * @param buyerRatio Buyer's share (0-100)
     * @param sellerRatio Seller's share (0-100)
     * @param evidenceHash Resolution evidence hash
     */
    function resolveDispute(
        uint256 dealId,
        uint8 buyerRatio,
        uint8 sellerRatio,
        bytes32 evidenceHash
    ) external override nonReentrant whenNotPaused {
        Deal storage deal = _deals[dealId];
        
        // Validations
        DealValidation.requireStatus(deal.status, DealStatus.Disputed);
        DealValidation.validateResolutionRatio(buyerRatio, sellerRatio);
        
        // Check if sender is authorized to resolve dispute
        bool isAssignedArbiter = (msg.sender == deal.arbiter);
        bool isOperator = hasRole(OPERATOR_ROLE, msg.sender);
        
        if (!isAssignedArbiter && !isOperator) {
            revert DealValidation.Unauthorized();
        }
        
        // If arbiter is resolving, verify they are still active
        // This prevents deactivated arbiters from resolving disputes
        // Operators can always resolve (emergency override)
        if (isAssignedArbiter && !isOperator) {
            require(
                _isActiveArbiter(msg.sender),
                "Arbiter has been deactivated"
            );
        }
        
        // Mark as resolved
        deal.status = DealStatus.Resolved;
        
        // Record resolution
        _resolutions[dealId] = DisputeResolution({
            arbiter: msg.sender,
            buyerRatio: buyerRatio,
            sellerRatio: sellerRatio,
            evidenceHash: evidenceHash,
            resolvedAt: uint64(block.timestamp),
            arbiterFee: (deal.amount * deal.arbiterFeeBps) / 10000
        });
        
        // Release funds according to ratio
        _releaseFunds(dealId, address(0), buyerRatio, sellerRatio);
        
        // Update arbiter statistics
        _resolveDisputeRecord(msg.sender);
        
        emit DisputeResolved(dealId, msg.sender, buyerRatio, sellerRatio, evidenceHash);
        
        // Clean up
        _closeDeal(dealId);
    }
    
    /**
     * @notice Auto-cancel if seller doesn't accept in time
     * @param dealId Deal identifier
     * @dev Anyone can trigger after acceptDeadline
     */
    function autoCancel(uint256 dealId) external override nonReentrant whenNotPaused {
        Deal storage deal = _deals[dealId];
        
        // Must be in Created status
        DealValidation.requireStatus(deal.status, DealStatus.Created);
        
        // Accept deadline must have passed
        DealValidation.requireDeadlinePassed(deal.acceptDeadline);
        
        // Update status
        deal.status = DealStatus.Cancelled;
        
        // Refund buyer (full amount, no fees)
        _transferFunds(deal.token, deal.buyer, deal.amount);
        
        emit DealFinalized(
            dealId, 
            deal.buyer, 
            msg.sender, 
            deal.amount, 
            DealStatus.Cancelled,
            PLATFORM_MESSAGE,
            "Accept timeout - seller did not respond"
        );
        
        // Clean up storage
        _closeDeal(dealId);
    }
    
    /**
     * @notice Cancel deal if seller accepted but didn't submit work
     * @param dealId Deal identifier
     * @dev Only buyer can trigger after submitDeadline
     */
    function cancelDeal(uint256 dealId) external override nonReentrant whenNotPaused {
        Deal storage deal = _deals[dealId];
        
        // Must be in Accepted status
        DealValidation.requireStatus(deal.status, DealStatus.Accepted);
        
        // Only buyer can cancel
        DealValidation.requireAuthorized(deal, msg.sender, true);
        
        // Submit deadline must have passed
        DealValidation.requireDeadlinePassed(deal.submitDeadline);
        
        deal.status = DealStatus.Cancelled;
        
        // Refund buyer
        _transferFunds(deal.token, deal.buyer, deal.amount);
        
        emit DealFinalized(
            dealId, 
            deal.buyer, 
            msg.sender, 
            deal.amount, 
            DealStatus.Cancelled,
            PLATFORM_MESSAGE,
            "Submit timeout - seller did not deliver"
        );
        
        _closeDeal(dealId);
    }
    
    /**
     * @notice Auto-refund (buyer can trigger after submit deadline)
     * @param dealId Deal identifier
     * @dev Removed whenNotPaused to allow fund release during pause
     */
    function autoRefund(uint256 dealId) external override nonReentrant {
        Deal storage deal = _deals[dealId];
        
        DealValidation.requireStatus(deal.status, DealStatus.Accepted);
        DealValidation.requireAuthorized(deal, msg.sender, true);
        DealValidation.requireDeadlinePassed(deal.submitDeadline);
        
        deal.status = DealStatus.Cancelled;
        
        // Refund buyer
        _transferFunds(deal.token, deal.buyer, deal.amount);
        
        emit DealFinalized(
            dealId, 
            deal.buyer, 
            msg.sender, 
            deal.amount, 
            DealStatus.Cancelled,
            PLATFORM_MESSAGE,
            "Auto-refund - submit timeout"
        );
        
        _closeDeal(dealId);
    }
    
    /**
     * @notice Buyer requests mutual refund (e.g., seller can't fulfill)
     * @param dealId Deal identifier
     * @dev Seller can approve with approveRefund()
     */
    function requestRefund(uint256 dealId) external override nonReentrant whenNotPaused {
        Deal storage deal = _deals[dealId];
        
        // Can request refund in Accepted or Submitted states
        if (deal.status != DealStatus.Accepted && deal.status != DealStatus.Submitted) {
            revert DealValidation.InvalidStatus(deal.status, DealStatus.Accepted);
        }
        
        // Only buyer can request refund
        DealValidation.requireAuthorized(deal, msg.sender, true);
        
        // Mark as refund requested
        deal.refundRequested = true;
        
        emit RefundRequested(dealId, msg.sender);
    }
    
    /**
     * @notice Seller approves buyer's refund request
     * @param dealId Deal identifier
     * @dev Triggers full refund to buyer (no fees)
     */
    function approveRefund(uint256 dealId) external override nonReentrant whenNotPaused {
        Deal storage deal = _deals[dealId];
        
        // Must have refund request pending
        require(deal.refundRequested, "No refund request");
        
        // Can approve refund in Accepted or Submitted states
        if (deal.status != DealStatus.Accepted && deal.status != DealStatus.Submitted) {
            revert DealValidation.InvalidStatus(deal.status, DealStatus.Accepted);
        }
        
        // Only seller can approve
        DealValidation.requireAuthorized(deal, msg.sender, false);
        
        // Update status
        deal.status = DealStatus.Cancelled;
        
        // Full refund to buyer (no fees - mutual agreement)
        _transferFunds(deal.token, deal.buyer, deal.amount);
        
        emit DealFinalized(
            dealId, 
            deal.buyer, 
            msg.sender, 
            deal.amount, 
            DealStatus.Cancelled,
            PLATFORM_MESSAGE,
            "Mutual agreement - seller approved refund"
        );
        
        _closeDeal(dealId);
    }
    
    /**
     * @notice Emergency fund release during contract pause
     * @param dealId Deal identifier
     * @dev Only admin can trigger, refunds to buyer as safest option
     */
    function emergencyRelease(uint256 dealId) 
        external 
        override
        nonReentrant 
        whenPaused 
        onlyRole(DEFAULT_ADMIN_ROLE) 
    {
        Deal storage deal = _deals[dealId];
        
        // Can only release if not already finalized
        require(
            deal.status != DealStatus.Closed && 
            deal.status != DealStatus.Approved,
            "Already finalized"
        );
        
        deal.status = DealStatus.Cancelled;
        
        // Emergency refund to buyer (safest option during emergency)
        _transferFunds(deal.token, deal.buyer, deal.amount);
        
        emit DealFinalized(
            dealId, 
            deal.buyer, 
            msg.sender, 
            deal.amount, 
            DealStatus.Cancelled,
            PLATFORM_MESSAGE,
            "Emergency release during pause"
        );
        
        _closeDeal(dealId);
    }
    
    /**
     * @notice Auto-release (anyone can trigger after confirm deadline)
     * @param dealId Deal identifier
     * @dev Removed whenNotPaused to allow fund release during pause
     */
    function autoRelease(uint256 dealId) external override nonReentrant {
        Deal storage deal = _deals[dealId];
        
        if (!DealValidation.canAutoRelease(deal)) {
            revert DealValidation.DeadlineNotReached();
        }
        
        deal.status = DealStatus.Approved;
        
        // Release to seller
        _releaseFunds(dealId, deal.seller, 100, 0);
        
        emit DealFinalized(
            dealId,
            deal.seller,
            msg.sender,
            deal.amount,
            DealStatus.Closed,
            PLATFORM_MESSAGE,
            "Auto-release - buyer did not respond in time"
        );
        
        _closeDeal(dealId);
    }
    
    // ============ Internal Functions ============
    
    /**
     * @notice Releases funds with fee distribution
     * @param dealId Deal identifier
     * @param primaryRecipient Primary recipient (if ratio is 100/0)
     * @param buyerRatio Buyer's share (0-100)
     * @param sellerRatio Seller's share (0-100)
     */
    function _releaseFunds(
        uint256 dealId,
        address primaryRecipient,
        uint8 buyerRatio,
        uint8 sellerRatio
    ) internal {
        Deal storage deal = _deals[dealId];
        
        // Calculate platform fee (percentage)
        uint256 platformFee = _calculatePlatformFee(deal.amount);
        
        // Enforce minimum fee ($10 USD)
        if (deal.creationPriceUSD > 0) {
            // ===== ETH: Use creation time price =====
            // Calculate fee USD value using CREATION time price
            uint256 feeUSD = (platformFee * deal.creationPriceUSD) / 1e18;
            
            // If fee < $10, adjust to minimum
            if (feeUSD < MIN_FEE_USD) {
                // Calculate minimum fee in ETH: ($10 * 1e18) / price
                platformFee = (MIN_FEE_USD * 1e18) / deal.creationPriceUSD;
            }
            
        } else {
            // ===== Stablecoin: 1:1 USD =====
            // Get stablecoin decimals for dynamic conversion
            StablecoinInfo memory stablecoin = stablecoins[deal.token];
            
            // Convert fee to USD (token decimals → 8 decimals)
            uint256 feeUSD;
            if (stablecoin.decimals <= 8) {
                feeUSD = platformFee * (10 ** (8 - stablecoin.decimals));
            } else {
                feeUSD = platformFee / (10 ** (stablecoin.decimals - 8));
            }
            
            // If fee < $10, adjust to minimum
            if (feeUSD < MIN_FEE_USD) {
                // Convert $10 (8 decimals) to token decimals
                if (stablecoin.decimals <= 8) {
                    platformFee = MIN_FEE_USD / (10 ** (8 - stablecoin.decimals));
                } else {
                    platformFee = MIN_FEE_USD * (10 ** (stablecoin.decimals - 8));
                }
            }
        }
        
        uint256 arbiterFee = 0;
        
        // Charge arbiter fee only if disputed
        if (deal.status == DealStatus.Resolved) {
            // Use the arbiter's individual fee rate stored in the deal
            arbiterFee = (deal.amount * deal.arbiterFeeBps) / 10000;
        }
        
        uint256 netAmount = deal.amount - platformFee - arbiterFee;
        
        // Accumulate platform fee in contract (gas optimization)
        accumulatedFees[deal.token] += platformFee;
        
        // Send arbiter fee if applicable
        if (arbiterFee > 0 && deal.arbiter != address(0)) {
            _transferFunds(deal.token, deal.arbiter, arbiterFee);
        }
        
        // Distribute net amount
        if (buyerRatio == 100) {
            // Full refund to buyer or single recipient
            address recipient = primaryRecipient != address(0) ? primaryRecipient : deal.buyer;
            _transferFunds(deal.token, recipient, netAmount);
        } else if (sellerRatio == 100) {
            // Full payment to seller
            _transferFunds(deal.token, deal.seller, netAmount);
        } else {
            // Split according to ratio
            uint256 buyerAmount = (netAmount * buyerRatio) / 100;
            uint256 sellerAmount = netAmount - buyerAmount;
            
            if (buyerAmount > 0) {
                _transferFunds(deal.token, deal.buyer, buyerAmount);
            }
            
            if (sellerAmount > 0) {
                _transferFunds(deal.token, deal.seller, sellerAmount);
            }
        }
    }
    
    /**
     * @notice Transfers funds (ETH or ERC20)
     * @param token Token address (address(0) for ETH)
     * @param to Recipient address
     * @param amount Amount to transfer
     */
    function _transferFunds(address token, address to, uint256 amount) internal {
        if (amount == 0) return;
        
        if (token == address(0)) {
            // Transfer ETH
            (bool success, ) = to.call{value: amount}("");
            require(success, "ETH transfer failed");
        } else {
            // Transfer ERC20
            IERC20(token).safeTransfer(to, amount);
        }
    }
    
    /**
     * @notice Closes a deal and releases storage
     * @param dealId Deal identifier
     * @dev Deletes storage to get gas refund and prevent state bloat
     * @dev All events are preserved on-chain for audit trail
     */
    function _closeDeal(uint256 dealId) internal {        
        // Release storage to get gas refund (~15,000 gas)
        delete _deals[dealId];
        delete _resolutions[dealId];
        
        // Note: Events are preserved on-chain for historical audit
        // Storage cleanup doesn't affect event-based data retrieval
    }
    
    // ============ Admin Functions ============
    
    /**
     * @notice Adds a stablecoin to the supported list
     * @param token Stablecoin address (USDT, USDC, DAI, etc.)
     * @param decimals Token decimals (6 for USDT/USDC, 18 for DAI)
     * @dev Only admin can add stablecoins. Each stablecoin is assumed to be 1:1 USD pegged
     */
    function addStablecoin(address token, uint8 decimals) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(token != address(0), "Invalid token address");
        require(decimals > 0 && decimals <= 18, "Invalid decimals");
        require(!stablecoins[token].isActive, "Stablecoin already exists");
        
        stablecoins[token] = StablecoinInfo({
            isActive: true,
            decimals: decimals
        });
        
        stablecoinList.push(token);
    }
    
    /**
     * @notice Removes a stablecoin from the supported list
     * @param token Stablecoin address to remove
     * @dev Only admin can remove. This will prevent new deals but won't affect existing ones
     */
    function removeStablecoin(address token) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(stablecoins[token].isActive, "Stablecoin not found");
        
        stablecoins[token].isActive = false;
        
        // Remove from array
        for (uint256 i = 0; i < stablecoinList.length; i++) {
            if (stablecoinList[i] == token) {
                stablecoinList[i] = stablecoinList[stablecoinList.length - 1];
                stablecoinList.pop();
                break;
            }
        }
    }
    
    /**
     * @notice Updates a stablecoin's decimals (in case of error correction)
     * @param token Stablecoin address
     * @param decimals New decimals value
     */
    function updateStablecoinDecimals(address token, uint8 decimals) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(stablecoins[token].isActive, "Stablecoin not found");
        require(decimals > 0 && decimals <= 18, "Invalid decimals");
        
        stablecoins[token].decimals = decimals;
    }
    
    // ============ Fee Management (Admin) ============
    
    /**
     * @notice Update default platform fee rate
     */
    function updatePlatformFee(uint16 newFeeBps) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (newFeeBps > MAX_FEE_BPS) revert InvalidFee();
        defaultPlatformFeeBps = newFeeBps;
    }
    
    /**
     * @notice Update default arbiter fee rate
     * @dev This is the default rate for new arbiters and non-pre-selected arbiters
     */
    function updateDefaultArbiterFee(uint16 newFeeBps) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (newFeeBps > MAX_FEE_BPS) revert InvalidFee();
        defaultArbiterFeeBps = newFeeBps;
    }
    
    // ============ Arbitration Management (Admin) ============
    
    /**
     * @notice Register a new arbiter
     */
    function registerArbiter(address arbiter) external onlyRole(DEFAULT_ADMIN_ROLE) {
        _registerArbiterInternal(arbiter);
    }
    
    /**
     * @notice Deactivate an arbiter
     */
    function deactivateArbiter(address arbiter) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (arbiters[arbiter].registeredAt == 0) revert ArbiterNotFound();
        arbiters[arbiter].isActive = false;
        _revokeRole(ARBITER_ROLE, arbiter);
    }
    
    /**
     * @notice Activate an arbiter
     */
    function activateArbiter(address arbiter) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (arbiters[arbiter].registeredAt == 0) revert ArbiterNotFound();
        arbiters[arbiter].isActive = true;
        _grantRole(ARBITER_ROLE, arbiter);
    }
    
    /**
     * @notice Remove arbiter from registry
     */
    function removeArbiter(address arbiter) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (arbiters[arbiter].registeredAt == 0) revert ArbiterNotFound();
        require(
            arbiters[arbiter].totalCases == arbiters[arbiter].resolvedCases,
            "Arbiter has pending cases"
        );
        
        // Remove from array
        for (uint256 i = 0; i < arbiterList.length; i++) {
            if (arbiterList[i] == arbiter) {
                arbiterList[i] = arbiterList[arbiterList.length - 1];
                arbiterList.pop();
                break;
            }
        }
        
        _revokeRole(ARBITER_ROLE, arbiter);
        delete arbiters[arbiter];
        emit ArbiterRemoved(arbiter);
    }
    
    /**
     * @notice Update individual arbiter's fee rate
     * @param arbiter Arbiter address
     * @param feeBps New fee rate in basis points (e.g., 100 = 1%, 150 = 1.5%)
     * @dev Allows admin to incentivize good arbiters or penalize poor ones
     */
    function updateArbiterFee(address arbiter, uint16 feeBps) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (arbiters[arbiter].registeredAt == 0) revert ArbiterNotFound();
        if (feeBps > MAX_FEE_BPS) revert InvalidFee();
        
        arbiters[arbiter].arbiterFeeBps = feeBps;
    }
    
    /**
     * @notice Get all arbiters
     */
    function getAllArbiters() external view returns (address[] memory) {
        return arbiterList;
    }
    
    /**
     * @notice Check if arbiter is active
     */
    function isActiveArbiter(address arbiter) external view returns (bool) {
        return _isActiveArbiter(arbiter);
    }
    
    /**
     * @notice Get arbiter information
     */
    function getArbiterInfo(address arbiter) external view returns (ArbiterInfo memory) {
        return arbiters[arbiter];
    }
    
    // ============ Treasury Management (Admin) ============
    
    /**
     * @notice Update withdrawal address
     */
    function updateWithdrawalAddress(address newAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(newAddress != address(0), "Invalid address");
        withdrawalAddress = newAddress;
    }
    
    // ============ Price Oracle Management (Admin) ============
    
    /**
     * @notice Update Chainlink price feed
     */
    function updatePriceFeed(address newFeed) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(newFeed != address(0), "Invalid address");
        ethUsdPriceFeed = AggregatorV3Interface(newFeed);
    }
    
    /**
     * @notice Manually set cached price (for testnet/emergencies)
     */
    function setManualPrice(uint256 price) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (price == 0) revert InvalidPrice();
        cachedEthPrice = price;
        priceCacheTime = block.timestamp;
    }
    
    /**
     * @notice Get current cached price
     */
    function getCachedPrice() external view returns (uint256 price, uint256 timestamp) {
        return (cachedEthPrice, priceCacheTime);
    }
    
    // ============ Emergency Controls ============
    
    /**
     * @notice Pauses the contract
     */
    function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
        _pause();
    }
    
    /**
     * @notice Unpauses the contract
     */
    function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
        _unpause();
    }
    
    // ============ View Functions ============
    
    /**
     * @notice Gets deal information
     * @param dealId Deal identifier
     * @return Deal struct
     */
    function getDeal(uint256 dealId) external view override returns (Deal memory) {
        return _deals[dealId];
    }
    
    /**
     * @notice Gets dispute resolution information
     * @param dealId Deal identifier
     * @return DisputeResolution struct
     */
    function getDisputeResolution(uint256 dealId) 
        external 
        view 
        override 
        returns (DisputeResolution memory) 
    {
        return _resolutions[dealId];
    }
    
    /**
     * @notice Gets the highest deal ID ever created
     * @return Last deal ID (continuously incrementing, never decreases)
     * @dev This is the max dealId, not active deal count
     * @dev Deal IDs increment forever: 1, 2, 3, ... even if some deals are closed
     * @dev For backend: Use this as unique identifier sequence
     */
    function dealCount() external view override returns (uint256) {
        return _dealIdCounter - 1;
    }
    
    /**
     * @notice Checks if token is supported
     * @param token Token address (address(0) for ETH)
     * @return True if supported
     * @dev ETH is always supported. ERC20 tokens must be registered stablecoins
     */
    function isTokenWhitelisted(address token) external view override returns (bool) {
        if (token == address(0)) {
            return true; // ETH is always supported
        }
        return stablecoins[token].isActive;
    }
    
    /**
     * @notice Gets all supported stablecoins
     * @return Array of stablecoin addresses
     */
    function getSupportedStablecoins() external view returns (address[] memory) {
        return stablecoinList;
    }
    
    /**
     * @notice Gets stablecoin info
     * @param token Stablecoin address
     * @return info Stablecoin configuration
     */
    function getStablecoinInfo(address token) external view returns (StablecoinInfo memory info) {
        return stablecoins[token];
    }
    
    /**
     * @notice Gets contract version
     * @return Version string
     */
    function version() external pure returns (string memory) {
        return "1.0.3";
    }
    
    // ============ Fee Management ============
    
    /**
     * @notice Withdraws accumulated platform fees
     * @dev Only admin can withdraw fees
     * @dev Fees are withdrawn to the treasury contract
     * @param token Token address (address(0) for ETH)
     * @param amount Amount to withdraw (0 to withdraw all)
     */
    function withdrawFees(address token, uint256 amount) 
        external 
        onlyRole(DEFAULT_ADMIN_ROLE) 
        nonReentrant 
    {
        uint256 available = accumulatedFees[token];
        require(available > 0, "No fees to withdraw");
        
        // If amount is 0, withdraw all
        uint256 withdrawAmount = amount == 0 ? available : amount;
        require(withdrawAmount <= available, "Insufficient fees");
        
        // Update state
        accumulatedFees[token] -= withdrawAmount;
        
        // Transfer to withdrawal address
        _transferFunds(token, withdrawalAddress, withdrawAmount);
        
        emit FeeWithdrawn(token, withdrawalAddress, withdrawAmount);
    }
    
    
    /**
     * @notice Gets accumulated platform fees for a token
     * @param token Token address (address(0) for ETH)
     * @return Accumulated fee amount
     */
    function getAccumulatedFees(address token) external view returns (uint256) {
        return accumulatedFees[token];
    }
    
    // ============================================================
    // INTEGRATED INTERNAL FUNCTIONS
    // ============================================================
    
    // -------- Fee Management Functions --------
    
    /**
     * @notice Calculate platform fee for given amount
     */
    function _calculatePlatformFee(uint256 amount) internal view returns (uint256) {
        uint16 feeBps = _getPlatformFeeBps(amount);
        return (amount * feeBps) / 10000;
    }
    
    /**
     * @notice Get platform fee rate in basis points
     */
    function _getPlatformFeeBps(uint256 /* amount */) internal view returns (uint16) {
        // Simplified: no tiers, just default rate
        return defaultPlatformFeeBps;
    }
    
    // -------- Arbitration Functions --------
    
    /**
     * @notice Check if address is active arbiter
     */
    function _isActiveArbiter(address arbiter) internal view returns (bool) {
        return arbiters[arbiter].isActive && arbiters[arbiter].registeredAt != 0;
    }
    
    /**
     * @notice Internal arbiter registration
     */
    function _registerArbiterInternal(address arbiter) internal {
        if (arbiter == address(0)) revert ArbiterNotFound();
        if (arbiters[arbiter].registeredAt != 0) revert ArbiterAlreadyExists();
        
        arbiters[arbiter] = ArbiterInfo({
            isActive: true,
            totalCases: 0,
            resolvedCases: 0,
            reputation: 80, // Default reputation
            arbiterFeeBps: defaultArbiterFeeBps, // Use default fee rate initially
            registeredAt: uint64(block.timestamp)
        });
        
        arbiterList.push(arbiter);
        _grantRole(ARBITER_ROLE, arbiter);
        
        emit ArbiterRegistered(arbiter, uint64(block.timestamp));
    }
    
    /**
     * @notice Select random arbiter from active list
     */
    function _selectRandomArbiter() internal view returns (address) {
        uint256 activeCount = 0;
        for (uint256 i = 0; i < arbiterList.length; i++) {
            if (arbiters[arbiterList[i]].isActive) {
                activeCount++;
            }
        }
        
        require(activeCount > 0, "No active arbiters");
        
        // Simple pseudo-random selection
        uint256 randomIndex = uint256(keccak256(abi.encodePacked(
            block.timestamp,
            block.prevrandao,
            msg.sender
        ))) % activeCount;
        
        uint256 currentIndex = 0;
        for (uint256 i = 0; i < arbiterList.length; i++) {
            if (arbiters[arbiterList[i]].isActive) {
                if (currentIndex == randomIndex) {
                    return arbiterList[i];
                }
                currentIndex++;
            }
        }
        
        revert("Arbiter selection failed");
    }
    
    /**
     * @notice Register dispute (update arbiter stats)
     */
    function _registerDispute(uint256 /* dealId */, address /* initiator */, address arbiter) internal {
        arbiters[arbiter].totalCases++;
    }
    
    /**
     * @notice Mark dispute as resolved (update arbiter stats)
     */
    function _resolveDisputeRecord(address arbiter) internal {
        arbiters[arbiter].resolvedCases++;
    }
    
    // -------- Price Oracle Functions --------
    
    /**
     * @notice Get ETH price in USD (8 decimals) with caching
     */
    function _getEthPriceUSD() internal returns (uint256) {
        // Check cache validity (10 minutes)
        if (priceCacheTime > 0 && block.timestamp - priceCacheTime < PRICE_CACHE_DURATION) {
            return cachedEthPrice;
        }
        
        // Fetch fresh price from Chainlink
        uint256 freshPrice = _fetchEthPriceFromChainlink();
        
        // Update cache
        cachedEthPrice = freshPrice;
        priceCacheTime = block.timestamp;
        
        return freshPrice;
    }
    
    /**
     * @notice Fetch ETH price from Chainlink
     */
    function _fetchEthPriceFromChainlink() internal view returns (uint256) {
        if (address(ethUsdPriceFeed) == address(0)) {
            // Fallback to manual price if no feed set
            return cachedEthPrice > 0 ? cachedEthPrice : 2500_0000_0000; // $2500 default
        }
        
        try ethUsdPriceFeed.latestRoundData() returns (
            uint80 /* roundId */,
            int256 price,
            uint256 /* startedAt */,
            uint256 updatedAt,
            uint80 /* answeredInRound */
        ) {
            require(price > 0, "Invalid price from feed");
            require(updatedAt > 0, "Price data is stale");
            require(block.timestamp - updatedAt < 1 hours, "Price too old");
            
            // Chainlink returns 8 decimals for ETH/USD
            return uint256(price);
        } catch {
            revert InvalidPrice();
        }
    }
    
    /**
     * @notice Convert amount to USD (8 decimals)
     */
    function _convertToUSD(uint256 amount, uint8 decimals) internal pure returns (uint256) {
        if (decimals <= 8) {
            return amount * (10 ** (8 - decimals));
        } else {
            return amount / (10 ** (decimals - 8));
        }
    }
    
    // ============ Receive ETH ============
    
    /**
     * @notice Rejects direct ETH transfers
     * @dev Users must use createDealETH() to create deals
     * @dev Prevents accidental fund loss from direct transfers
     */
    receive() external payable {
        revert("Use createDealETH() to create deals");
    }
    
    /**
     * @notice Rejects calls to undefined functions
     * @dev Prevents accidental fund loss
     */
    fallback() external payable {
        revert("Function not found. Use createDealETH() for deals");
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "../interfaces/IYBZCore.sol";

/**
 * @title DealValidation
 * @notice Library for deal validation and state transition checks
 * @dev Gas-optimized validation logic extracted to library
 */
library DealValidation {
    
    /// @notice Minimum time windows (in seconds)
    /// @dev Flexible limits to accommodate various industries
    uint64 public constant MIN_ACCEPT_WINDOW = 1 hours;     // Min: 1 hour (quick response)
    uint64 public constant MIN_SUBMIT_WINDOW = 1 hours;     // Min: 1 hour (small tasks like translation)
    uint64 public constant MIN_CONFIRM_WINDOW = 1 hours;    // Min: 1 hour (quick verification)
    
    /// @notice Maximum time windows (in seconds)
    /// @dev Max limits prevent indefinite locks
    uint64 public constant MAX_ACCEPT_WINDOW = 30 days;     // Max: 30 days
    uint64 public constant MAX_SUBMIT_WINDOW = 180 days;    // Max: 6 months (supply chain, custom manufacturing)
    uint64 public constant MAX_CONFIRM_WINDOW = 30 days;    // Max: 30 days
    
    /// @notice Minimum deal amount (to prevent spam)
    uint256 public constant MIN_DEAL_AMOUNT = 0.001 ether;
    
    /// @notice Maximum fee in basis points (10%)
    uint16 public constant MAX_FEE_BPS = 1000;
    
    // ============ Errors ============
    
    error InvalidAmount();
    error InvalidAddress();
    error InvalidTimeWindow();
    error InvalidTermsHash();
    error InvalidStatus(IYBZCore.DealStatus current, IYBZCore.DealStatus required);
    error Unauthorized();
    error DeadlinePassed();
    error DeadlineNotReached();
    error InvalidRatio();
    
    // ============ Validation Functions ============
    
    /**
     * @notice Validates deal creation parameters
     * @param seller Seller address
     * @param amount Deal amount
     * @param termsHash Terms hash
     * @param acceptWindow Accept time window
     * @param submitWindow Submit time window
     * @param confirmWindow Confirm time window
     */
    function validateCreateDeal(
        address seller,
        uint256 amount,
        bytes32 termsHash,
        uint64 acceptWindow,
        uint64 submitWindow,
        uint64 confirmWindow
    ) internal pure {
        if (seller == address(0)) revert InvalidAddress();
        if (amount < MIN_DEAL_AMOUNT) revert InvalidAmount();
        if (termsHash == bytes32(0)) revert InvalidTermsHash();
        
        if (acceptWindow < MIN_ACCEPT_WINDOW || acceptWindow > MAX_ACCEPT_WINDOW) {
            revert InvalidTimeWindow();
        }
        if (submitWindow < MIN_SUBMIT_WINDOW || submitWindow > MAX_SUBMIT_WINDOW) {
            revert InvalidTimeWindow();
        }
        if (confirmWindow < MIN_CONFIRM_WINDOW || confirmWindow > MAX_CONFIRM_WINDOW) {
            revert InvalidTimeWindow();
        }
    }
    
    /**
     * @notice Validates state transition
     * @param currentStatus Current deal status
     * @param requiredStatus Required status for operation
     */
    function requireStatus(
        IYBZCore.DealStatus currentStatus,
        IYBZCore.DealStatus requiredStatus
    ) internal pure {
        if (currentStatus != requiredStatus) {
            revert InvalidStatus(currentStatus, requiredStatus);
        }
    }
    
    /**
     * @notice Checks if caller is authorized for the deal
     * @param deal Deal struct
     * @param caller Caller address
     * @param isBuyerRequired True if buyer authorization required
     */
    function requireAuthorized(
        IYBZCore.Deal memory deal,
        address caller,
        bool isBuyerRequired
    ) internal pure {
        address authorized = isBuyerRequired ? deal.buyer : deal.seller;
        if (caller != authorized) revert Unauthorized();
    }
    
    /**
     * @notice Checks if deadline has passed
     * @param deadline Deadline timestamp
     */
    function requireDeadlinePassed(uint64 deadline) internal view {
        if (block.timestamp <= deadline) revert DeadlineNotReached();
    }
    
    /**
     * @notice Checks if deadline has not passed
     * @param deadline Deadline timestamp
     */
    function requireDeadlineNotPassed(uint64 deadline) internal view {
        if (block.timestamp > deadline) revert DeadlinePassed();
    }
    
    /**
     * @notice Validates dispute resolution ratios
     * @param buyerRatio Buyer ratio (0-100)
     * @param sellerRatio Seller ratio (0-100)
     */
    function validateResolutionRatio(
        uint8 buyerRatio,
        uint8 sellerRatio
    ) internal pure {
        if (buyerRatio + sellerRatio != 100) revert InvalidRatio();
    }
    
    /**
     * @notice Checks if deal can be auto-cancelled (Created status only)
     * @param deal Deal struct
     * @dev Now only for Created status, Accepted uses cancelDeal()
     */
    function canAutoCancel(IYBZCore.Deal memory deal) internal view returns (bool) {
        // Can auto-cancel if Created and accept deadline passed
        return deal.status == IYBZCore.DealStatus.Created && 
               block.timestamp > deal.acceptDeadline;
    }
    
    /**
     * @notice Checks if deal can be auto-released
     * @param deal Deal struct
     */
    function canAutoRelease(IYBZCore.Deal memory deal) internal view returns (bool) {
        return deal.status == IYBZCore.DealStatus.Submitted && 
               block.timestamp > deal.confirmDeadline;
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/**
 * @title IYBZCore
 * @notice Interface for YBZ Escrow Core Contract
 * @dev Defines the core escrow functionality and data structures
 */
interface IYBZCore {
    
    /// @notice Deal lifecycle status
    enum DealStatus {
        Created,      // Deal created, waiting for seller acceptance
        Accepted,     // Seller accepted, waiting for work submission
        Submitted,    // Work submitted, waiting for buyer confirmation
        Disputed,     // Dispute raised, waiting for arbitration
        Approved,     // Deal approved, funds released
        Cancelled,    // Deal cancelled (timeout or manual cancellation)
        Resolved,     // Dispute resolved by arbitrator
        Closed        // Deal completed and storage cleaned
    }
    
    /// @notice Main deal structure
    struct Deal {
        address buyer;                  // Buyer address
        address seller;                 // Seller address
        address token;                  // Token address (address(0) for ETH)
        uint256 amount;                 // Total amount locked
        uint256 creationPriceUSD;       // Token price in USD at creation (8 decimals, for ETH only)
        uint16 platformFeeBps;          // Platform fee in basis points
        uint16 arbiterFeeBps;           // Arbiter fee in basis points (only charged if disputed)
        bytes32 termsHash;              // IPFS hash of deal terms
        bytes32 deliveryHash;           // IPFS hash of delivery proof
        uint64 acceptDeadline;          // Deadline for seller to accept
        uint64 submitDeadline;          // Deadline for seller to submit work
        uint64 confirmDeadline;         // Deadline for buyer to confirm (recalculated on submission)
        uint64 acceptWindow;            // Time window for accept (stored for reference)
        uint64 submitWindow;            // Time window for submit (stored for reference)
        uint64 confirmWindow;           // Time window for confirm (used to recalculate deadline)
        uint64 createdAt;               // Creation timestamp
        uint64 submittedAt;             // Work submission timestamp (0 if not submitted)
        address arbiter;                // Assigned arbiter address
        DealStatus status;              // Current deal status
        bool refundRequested;           // Buyer requested mutual refund
    }
    
    /// @notice Dispute resolution data
    struct DisputeResolution {
        address arbiter;                // Arbiter who resolved the dispute
        uint8 buyerRatio;               // Percentage to buyer (0-100)
        uint8 sellerRatio;              // Percentage to seller (0-100)
        bytes32 evidenceHash;           // IPFS hash of arbitration evidence
        uint64 resolvedAt;              // Resolution timestamp
        uint256 arbiterFee;             // Fee paid to arbiter
    }
    
    // ============ Events ============
    
    event DealCreated(
        uint256 indexed dealId,
        address indexed buyer,
        address indexed seller,
        address token,
        uint256 amount,
        uint256 creationPriceUSD,
        uint16 platformFeeBps,
        uint16 arbiterFeeBps,
        bytes32 termsHash,
        uint64 acceptWindow,
        uint64 submitWindow,
        uint64 confirmWindow,
        address preferredArbiter,
        string platform
    );
    
    event DealAccepted(
        uint256 indexed dealId,
        address indexed seller,
        uint64 submitDeadline
    );
    
    event WorkSubmitted(
        uint256 indexed dealId,
        bytes32 deliveryHash,
        uint64 confirmDeadline
    );
    
    event DealApproved(
        uint256 indexed dealId,
        address indexed seller,
        uint256 amount
    );
    
    event DisputeRaised(
        uint256 indexed dealId,
        address indexed initiator,
        bytes32 evidenceHash
    );
    
    event DisputeResolved(
        uint256 indexed dealId,
        address indexed arbiter,
        uint8 buyerRatio,
        uint8 sellerRatio,
        bytes32 evidenceHash
    );
    
    event DealCancelled(
        uint256 indexed dealId,
        address indexed initiator,
        string reason
    );
    
    event DealFinalized(
        uint256 indexed dealId,
        address indexed recipient,
        address indexed initiator,
        uint256 amount,
        DealStatus finalStatus,
        string platform,
        string reason
    );
    
    event RefundRequested(
        uint256 indexed dealId,
        address indexed buyer
    );
    
    // ============ Core Functions ============
    
    function createDealETH(
        address seller,
        bytes32 termsHash,
        uint64 acceptWindow,
        uint64 submitWindow,
        uint64 confirmWindow,
        address preferredArbiter
    ) external payable returns (uint256 dealId);
    
    function createDealERC20(
        address seller,
        address token,
        uint256 amount,
        bytes32 termsHash,
        uint64 acceptWindow,
        uint64 submitWindow,
        uint64 confirmWindow,
        address preferredArbiter
    ) external returns (uint256 dealId);
    
    function acceptDeal(uint256 dealId) external;
    
    function submitWork(uint256 dealId, bytes32 deliveryHash) external;
    
    function approveDeal(uint256 dealId) external;
    
    function raiseDispute(uint256 dealId, bytes32 evidenceHash) external;
    
    function resolveDispute(
        uint256 dealId,
        uint8 buyerRatio,
        uint8 sellerRatio,
        bytes32 evidenceHash
    ) external;
    
    function autoCancel(uint256 dealId) external;
    
    function cancelDeal(uint256 dealId) external;
    
    function autoRefund(uint256 dealId) external;
    
    function requestRefund(uint256 dealId) external;
    
    function approveRefund(uint256 dealId) external;
    
    function autoRelease(uint256 dealId) external;
    
    function emergencyRelease(uint256 dealId) external;
    
    // ============ View Functions ============
    
    function getDeal(uint256 dealId) external view returns (Deal memory);
    
    function getDisputeResolution(uint256 dealId) external view returns (DisputeResolution memory);
    
    function dealCount() external view returns (uint256);
    
    function isTokenWhitelisted(address token) external view returns (bool);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// solhint-disable-next-line interface-starts-with-i
interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  function getRoundData(
    uint80 _roundId
  ) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);

  function latestRoundData()
    external
    view
    returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    /**
     * @dev An operation with an ERC-20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {IERC165, ERC165} from "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /// @inheritdoc IERC165
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual returns (bool) {
        return _roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)

pragma solidity >=0.6.2;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /// @inheritdoc IERC165
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)

pragma solidity >=0.8.4;

/**
 * @dev External interface of AccessControl declared to support ERC-165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted to signal this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
     * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 15 of 16 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)

pragma solidity >=0.4.16;

import {IERC165} from "../utils/introspection/IERC165.sol";

File 16 of 16 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)

pragma solidity >=0.4.16;

import {IERC20} from "../token/ERC20/IERC20.sol";

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "viaIR": true,
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "remappings": []
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"withdrawalAddr","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ArbiterAlreadyExists","type":"error"},{"inputs":[],"name":"ArbiterInactive","type":"error"},{"inputs":[],"name":"ArbiterNotFound","type":"error"},{"inputs":[],"name":"DeadlineNotReached","type":"error"},{"inputs":[],"name":"DeadlinePassed","type":"error"},{"inputs":[{"internalType":"uint64","name":"remainingTime","type":"uint64"}],"name":"DisputeCooldownActive","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidFee","type":"error"},{"inputs":[],"name":"InvalidPrice","type":"error"},{"inputs":[],"name":"InvalidRatio","type":"error"},{"inputs":[{"internalType":"enum IYBZCore.DealStatus","name":"current","type":"uint8"},{"internalType":"enum IYBZCore.DealStatus","name":"required","type":"uint8"}],"name":"InvalidStatus","type":"error"},{"inputs":[],"name":"InvalidTermsHash","type":"error"},{"inputs":[],"name":"InvalidThreshold","type":"error"},{"inputs":[],"name":"InvalidTimeWindow","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"TierAlreadyExists","type":"error"},{"inputs":[],"name":"TierNotFound","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"arbiter","type":"address"},{"indexed":false,"internalType":"uint64","name":"timestamp","type":"uint64"}],"name":"ArbiterRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"arbiter","type":"address"}],"name":"ArbiterRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"dealId","type":"uint256"},{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"uint64","name":"submitDeadline","type":"uint64"}],"name":"DealAccepted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"dealId","type":"uint256"},{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DealApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"dealId","type":"uint256"},{"indexed":true,"internalType":"address","name":"initiator","type":"address"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"DealCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"dealId","type":"uint256"},{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"creationPriceUSD","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"platformFeeBps","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"arbiterFeeBps","type":"uint16"},{"indexed":false,"internalType":"bytes32","name":"termsHash","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"acceptWindow","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"submitWindow","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"confirmWindow","type":"uint64"},{"indexed":false,"internalType":"address","name":"preferredArbiter","type":"address"},{"indexed":false,"internalType":"string","name":"platform","type":"string"}],"name":"DealCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"dealId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"address","name":"initiator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"enum IYBZCore.DealStatus","name":"finalStatus","type":"uint8"},{"indexed":false,"internalType":"string","name":"platform","type":"string"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"DealFinalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"dealId","type":"uint256"},{"indexed":true,"internalType":"address","name":"initiator","type":"address"},{"indexed":false,"internalType":"bytes32","name":"evidenceHash","type":"bytes32"}],"name":"DisputeRaised","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"dealId","type":"uint256"},{"indexed":true,"internalType":"address","name":"arbiter","type":"address"},{"indexed":false,"internalType":"uint8","name":"buyerRatio","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"sellerRatio","type":"uint8"},{"indexed":false,"internalType":"bytes32","name":"evidenceHash","type":"bytes32"}],"name":"DisputeResolved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeeWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"dealId","type":"uint256"},{"indexed":true,"internalType":"address","name":"buyer","type":"address"}],"name":"RefundRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"dealId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"deliveryHash","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"confirmDeadline","type":"uint64"}],"name":"WorkSubmitted","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"ARBITER_1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ARBITER_2","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ARBITER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CHAINLINK_ETH_USD","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_DISPUTE_COOLDOWN","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FEE_BPS","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_DEAL_AMOUNT_USD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_FEE_USD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PLATFORM_MESSAGE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRICE_CACHE_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDC","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"name":"acceptDeal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accumulatedFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"arbiter","type":"address"}],"name":"activateArbiter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"name":"addStablecoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"name":"approveDeal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"name":"approveRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"arbiterList","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"arbiters","outputs":[{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"uint256","name":"totalCases","type":"uint256"},{"internalType":"uint256","name":"resolvedCases","type":"uint256"},{"internalType":"uint256","name":"reputation","type":"uint256"},{"internalType":"uint16","name":"arbiterFeeBps","type":"uint16"},{"internalType":"uint64","name":"registeredAt","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"name":"autoCancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"name":"autoRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"name":"autoRelease","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cachedEthPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"name":"cancelDeal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"termsHash","type":"bytes32"},{"internalType":"uint64","name":"acceptWindow","type":"uint64"},{"internalType":"uint64","name":"submitWindow","type":"uint64"},{"internalType":"uint64","name":"confirmWindow","type":"uint64"},{"internalType":"address","name":"preferredArbiter","type":"address"}],"name":"createDealERC20","outputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"bytes32","name":"termsHash","type":"bytes32"},{"internalType":"uint64","name":"acceptWindow","type":"uint64"},{"internalType":"uint64","name":"submitWindow","type":"uint64"},{"internalType":"uint64","name":"confirmWindow","type":"uint64"},{"internalType":"address","name":"preferredArbiter","type":"address"}],"name":"createDealETH","outputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"arbiter","type":"address"}],"name":"deactivateArbiter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dealCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultArbiterFeeBps","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultPlatformFeeBps","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"name":"emergencyRelease","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"ethUsdPriceFeed","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getAccumulatedFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllArbiters","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"arbiter","type":"address"}],"name":"getArbiterInfo","outputs":[{"components":[{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"uint256","name":"totalCases","type":"uint256"},{"internalType":"uint256","name":"resolvedCases","type":"uint256"},{"internalType":"uint256","name":"reputation","type":"uint256"},{"internalType":"uint16","name":"arbiterFeeBps","type":"uint16"},{"internalType":"uint64","name":"registeredAt","type":"uint64"}],"internalType":"struct YBZCore.ArbiterInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCachedPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"name":"getDeal","outputs":[{"components":[{"internalType":"address","name":"buyer","type":"address"},{"internalType":"address","name":"seller","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"creationPriceUSD","type":"uint256"},{"internalType":"uint16","name":"platformFeeBps","type":"uint16"},{"internalType":"uint16","name":"arbiterFeeBps","type":"uint16"},{"internalType":"bytes32","name":"termsHash","type":"bytes32"},{"internalType":"bytes32","name":"deliveryHash","type":"bytes32"},{"internalType":"uint64","name":"acceptDeadline","type":"uint64"},{"internalType":"uint64","name":"submitDeadline","type":"uint64"},{"internalType":"uint64","name":"confirmDeadline","type":"uint64"},{"internalType":"uint64","name":"acceptWindow","type":"uint64"},{"internalType":"uint64","name":"submitWindow","type":"uint64"},{"internalType":"uint64","name":"confirmWindow","type":"uint64"},{"internalType":"uint64","name":"createdAt","type":"uint64"},{"internalType":"uint64","name":"submittedAt","type":"uint64"},{"internalType":"address","name":"arbiter","type":"address"},{"internalType":"enum IYBZCore.DealStatus","name":"status","type":"uint8"},{"internalType":"bool","name":"refundRequested","type":"bool"}],"internalType":"struct IYBZCore.Deal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"name":"getDisputeResolution","outputs":[{"components":[{"internalType":"address","name":"arbiter","type":"address"},{"internalType":"uint8","name":"buyerRatio","type":"uint8"},{"internalType":"uint8","name":"sellerRatio","type":"uint8"},{"internalType":"bytes32","name":"evidenceHash","type":"bytes32"},{"internalType":"uint64","name":"resolvedAt","type":"uint64"},{"internalType":"uint256","name":"arbiterFee","type":"uint256"}],"internalType":"struct IYBZCore.DisputeResolution","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getStablecoinInfo","outputs":[{"components":[{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"internalType":"struct YBZCore.StablecoinInfo","name":"info","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSupportedStablecoins","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"arbiter","type":"address"}],"name":"isActiveArbiter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isTokenWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceCacheTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"},{"internalType":"bytes32","name":"evidenceHash","type":"bytes32"}],"name":"raiseDispute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"arbiter","type":"address"}],"name":"registerArbiter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"arbiter","type":"address"}],"name":"removeArbiter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"removeStablecoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"}],"name":"requestRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"},{"internalType":"uint8","name":"buyerRatio","type":"uint8"},{"internalType":"uint8","name":"sellerRatio","type":"uint8"},{"internalType":"bytes32","name":"evidenceHash","type":"bytes32"}],"name":"resolveDispute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setManualPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stablecoinList","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stablecoins","outputs":[{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dealId","type":"uint256"},{"internalType":"bytes32","name":"deliveryHash","type":"bytes32"}],"name":"submitWork","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tierThresholds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tieredPlatformFees","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"arbiter","type":"address"},{"internalType":"uint16","name":"feeBps","type":"uint16"}],"name":"updateArbiterFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newFeeBps","type":"uint16"}],"name":"updateDefaultArbiterFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newFeeBps","type":"uint16"}],"name":"updatePlatformFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newFeed","type":"address"}],"name":"updatePriceFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"name":"updateStablecoinDecimals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"updateWithdrawalAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawalAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

6080346200059b57620057d8906001600160401b0390601f38849003908101601f1916820190838211838310176200059f57808391604096879485528339810103126200059b576200005181620005f3565b90620000616020809201620005f3565b600180805593906001600160a01b039084821615620005675716928315620005235780620000936200009a9262000608565b5062000678565b506009805463ffffffff1916626400c81790819055600c80546001600160a01b0319908116909517905591468514620000e1575b858560035551614f019081620008578239f35b735f4ec3df9cbd43714fe2740f5e3616155c5b841984600f541617600f5573b1bb66c47dee78b91e8aeeb6e74e66e02ca3456791825f52600d825260049384885f2001549082601092831c1662000513579080888a8795948961ffff928392884216998a968c62000151620005d3565b94828652818601915f8352818701945f86528960608901976050895260808a019e1c168d5260a088019b8c525f52600d90525f2094511515620001a090869060ff801983541691151516179055565b51908401555160028301555160038201550193511692805493600160501b620100009003809451871b1690600160501b600190031980961617179055600e9485549868010000000000000000998a81101562000500578d8101808955811015620004ed5791818f99979593899795938f918d9b5f528b5f2001918254161790556200022a62000718565b5089518881527f3e9e037f5ae1b02104d124fd8f1783111cdf05db0bf2f9b784b2c8d3d866ebf4998a91a28b73bf3a2c7c9bc27e3143df965ffa80e421f5445678998a5f52600d8c525f200154851c16620004dd57918c9391838f8d908b8d8b98600954891c16996200029c620005d3565b93818552828501905f8252808601935f8552606087019560508752608088019e8f5260a088019d8e525f52600d90525f2094511515620002e890869060ff801983541691151516179055565b5190840155516002830155516003820155019551169285549451901b1692161717905580549086821015620004ca57898201808255821015620004b757908592915f52825f2001848982541617905562000341620007b7565b508951908152a262000352620005b3565b92858452818401906006825273dac17f958d2ee523a2206206994597c13d831ec791825f526006845262000398895f2096511515879060ff801983541691151516179055565b5185549561ff0096879261ff001998899160081b169116179055600792835486811015620004a4578981018086558110156200049157845f52855f20019088825416179055620003e7620005b3565b90888252848201966006885273a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4897885f52600687526200042d8c5f2094511515859060ff801983541691151516179055565b519183549260081b1691161790558154938410156200047e578684018083558410156200046b57505f525f2001918254161790555f808080620000ce565b603290634e487b7160e01b5f525260245ffd5b604190634e487b7160e01b5f525260245ffd5b603284634e487b7160e01b5f525260245ffd5b604184634e487b7160e01b5f525260245ffd5b603288634e487b7160e01b5f525260245ffd5b604188634e487b7160e01b5f525260245ffd5b8d516301934db960e01b81528b90fd5b60328c634e487b7160e01b5f525260245ffd5b60418c634e487b7160e01b5f525260245ffd5b88516301934db960e01b81528690fd5b855162461bcd60e51b815260048101849052601a60248201527f496e76616c6964207769746864726177616c20616464726573730000000000006044820152606490fd5b865162461bcd60e51b815260048101859052600d60248201526c24b73b30b634b21030b236b4b760991b6044820152606490fd5b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b60408051919082016001600160401b038111838210176200059f57604052565b6040519060c082016001600160401b038111838210176200059f57604052565b51906001600160a01b03821682036200059b57565b6001600160a01b03165f8181525f80516020620057b8833981519152602052604090205460ff1662000673575f8181525f80516020620057b883398151915260205260408120805460ff191660011790553391905f80516020620057588339815191528180a4600190565b505f90565b6001600160a01b03165f8181527fee57cd81e84075558e8fcc182a1f4393f91fc97f963a136e66b7f949a62f319f60205260409020547f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929919060ff166200071257815f525f60205260405f20815f5260205260405f20600160ff1982541617905533915f80516020620057588339815191525f80a4600190565b50505f90565b73b1bb66c47dee78b91e8aeeb6e74e66e02ca345675f8190525f80516020620057788339815191526020527f02167d379dd2811fe849f33f7683c98c9277acc693ff4af85f0277e476d8c6e5545f8051602062005798833981519152919060ff166200071257815f525f60205260405f20815f5260205260405f20600160ff1982541617905533915f80516020620057588339815191525f80a4600190565b73bf3a2c7c9bc27e3143df965ffa80e421f54456785f8190525f80516020620057788339815191526020527ffb962e770b88de270999993f211897365f9f49431afaa29e745dc60cac4a02a9545f8051602062005798833981519152919060ff166200071257815f525f60205260405f20815f5260205260405f20600160ff1982541617905533915f80516020620057588339815191525f80a460019056fe60a08060405260043610156100c6575b5036156100755760405162461bcd60e51b815260206004820152603160248201527f46756e6374696f6e206e6f7420666f756e642e20557365206372656174654465604482015270616c455448282920666f72206465616c7360781b6064820152608490fd5b60405162461bcd60e51b815260206004820152602360248201527f557365206372656174654465616c455448282920746f20637265617465206465604482015262616c7360e81b6064820152608490fd5b5f3560e01c90816301ffc9a714613d095750806306ba047314613c035780630993cdbe14613b055780630a9eeded146139dc5780630c3054cd146139165780630db2ad8b146138aa5780631322ec8c1461388d578063172d4d1b146137f957806317d80419146137db5780631c1e42bf14613671578063204769741461311e578063248a9ca3146130f25780632f2ff15d146130b657806331ea1a3914612fa05780633487e08c14612dfe578063348a71a614612c7c57806336568abe14612c3557806339c28c6214612ad25780633b947d2b146129d65780633eff50e0146124005780633f4ba83a146123aa57806342f6fb29146123825780634450b47214612359578063459b860e146122125780634d104adf146121d8578063539f51db146121bc57806354fd4d5014612177578063564201f91461043e5780635be5eeea146121535780635c975abb146121315780635e72fc5d146120e55780635ebf1d75146120b75780635f9d8efb14611fb15780636035ceba14611f8357806360e74f5614611f11578063636bf26d14611c7057806367946dd814611bef5780637414126614611bad5780637678734c146112ab5780637bf2bb101461122c5780637c6f73eb1461119f5780637d41702e146110e557806382fd5bac14610f155780638456cb5914610ebc57806385407c9a14610e9957806389a3027114610e6b57806390c4c34a14610de957806391d1485414610da1578063929b657814610d8357806393144f5014610d6657806395877f7814610d1a5780639791d49214610cec578063a100d69d14610c9c578063a217fddf14610c82578063a4b2409e14610b96578063a52dba3c146109f8578063ad3b1b47146108c3578063afb0695214610885578063b5af090f14610858578063b64fefd9146107d7578063bd0bb4d3146107a4578063c54e44eb14610776578063d547741f14610738578063d55be8c61461071c578063d65f203a146106ee578063d7a71868146106b2578063d98906b114610695578063e0d1732b14610638578063e61d47c51461057c578063eadb3c9c1461053f578063ed3b7e9f1461051e578063f2bcd022146104f6578063f5b541a6146104bc578063fa84783614610476578063fcf666641461043e5763fd03088b14610416575f61000f565b3461043a575f36600319011261043a57604060105460115482519182526020820152f35b5f80fd5b3461043a57602036600319011261043a576001600160a01b0361045f613d72565b165f526008602052602060405f2054604051908152f35b3461043a57602036600319011261043a576001600160a01b03610497613d72565b165f5260066020526040805f205460ff8251918181161515835260081c166020820152f35b3461043a575f36600319011261043a5760206040517f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9298152f35b3461043a575f36600319011261043a57600c546040516001600160a01b039091168152602090f35b3461043a575f36600319011261043a57602061ffff60095416604051908152f35b3461043a575f36600319011261043a576003545f19810190811161056857602090604051908152f35b634e487b7160e01b5f52601160045260245ffd5b3461043a57602036600319011261043a576105956140f4565b506004355f52600560205260c060405f206040516105b281613ee2565b815460018060a01b03811692838352602083019160ff8160a01c16835260ff604085019160a81c16815260ff60018301549160608601928352816001600160401b039560a06003886002890154169760808b01988952015498019788526040519889525116602088015251166040860152516060850152511660808301525160a0820152f35b3461043a57602036600319011261043a57610651613ed1565b610659614515565b6103e861ffff8216116106835763ffff00006009549160101b169063ffff00001916176009555f80f35b6040516358d620b360e01b8152600490fd5b3461043a575f36600319011261043a576020604051620151808152f35b3461043a57602036600319011261043a576004356106ce614515565b80156106dd5760105542601155005b60405162bfc92160e01b8152600490fd5b3461043a575f36600319011261043a57602060405173b1bb66c47dee78b91e8aeeb6e74e66e02ca345678152f35b3461043a575f36600319011261043a5760206040516103e88152f35b3461043a57604036600319011261043a57610774600435610757613d88565b90805f525f60205261076f600160405f20015461456b565b614659565b005b3461043a575f36600319011261043a57602060405173dac17f958d2ee523a2206206994597c13d831ec78152f35b3461043a575f36600319011261043a576107d36107bf613f70565b604051918291602083526020830190613e42565b0390f35b3461043a57602036600319011261043a576107f0613d72565b6107f8614515565b6001600160a01b0381165f818152600d602052604090206004015490919060101c6001600160401b03161561084657610774915f52600d60205260405f20600160ff19825416179055614995565b604051630cb5cfe160e31b8152600490fd5b3461043a57602036600319011261043a57602061087b610876613d72565b6142bf565b6040519015158152f35b3461043a57602036600319011261043a5761ffff6108a1613ed1565b6108a9614515565b166103e881116106835761ffff1960095416176009555f80f35b3461043a57604036600319011261043a576108dc613d72565b602435906108e8614515565b6108f06142e6565b6001600160a01b038181165f818152600860205260409020549390929084156109bd57806109b75750835b841161097e577eed5939179dc194223f0edd1517ecee2210b22da7f82c8e4b1795e93b9f06aa9161096c85602093865f526008855260405f2061095f8382546141da565b905583600c541690614384565b600c541693604051908152a360018055005b60405162461bcd60e51b8152602060048201526011602482015270496e73756666696369656e74206665657360781b6044820152606490fd5b9361091b565b60405162461bcd60e51b81526020600482015260136024820152724e6f206665657320746f20776974686472617760681b6044820152606490fd5b3461043a57604036600319011261043a57610a11613d72565b610a19613d9e565b610a21614515565b6001600160a01b038216908115610b595760ff169081151580610b4e575b610a4890614167565b805f52600660205260ff60405f205416610b095760ff610ab49260405192610a6f84613efd565b60018452602084019182525f526006602052610a9e60405f2093511515849060ff801983541691151516179055565b51825461ff001916911660081b61ff0016179055565b60075490600160401b821015610af557610ad78260016107749401600755613e0d565b90919060018060a01b038084549260031b9316831b921b1916179055565b634e487b7160e01b5f52604160045260245ffd5b60405162461bcd60e51b815260206004820152601960248201527f537461626c65636f696e20616c726561647920657869737473000000000000006044820152606490fd5b506012821115610a3f565b60405162461bcd60e51b8152602060048201526015602482015274496e76616c696420746f6b656e206164647265737360581b6044820152606490fd5b3461043a57602036600319011261043a57600435610bb26142e6565b610bba614309565b805f52600460205260405f20600a81019081549060ff8260a01c166008811015610c6e57600181141580610c63575b610c3c5750610c0190610bfc3391613fc5565b6144c5565b60ff60a81b1916600160a81b17905533907fd8420f97dab0b820e066ebfad617848c1eab2d260922358cc1d5cdcdc568d5725f80a360018055005b60405163f924664d60e01b8152604491610c5a906004830190613ec4565b60016024820152fd5b506002811415610be9565b634e487b7160e01b5f52602160045260245ffd5b3461043a575f36600319011261043a5760206040515f8152f35b3461043a57602036600319011261043a57600435600b5481101561043a57602090600b5f527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90154604051908152f35b3461043a57602036600319011261043a576004355f52600a602052602061ffff60405f205416604051908152f35b3461043a57602036600319011261043a57610d33613d72565b610d3b614515565b6001600160a01b0316610d4f8115156141e7565b6001600160601b0360a01b600f541617600f555f80f35b3461043a575f36600319011261043a576020601154604051908152f35b3461043a575f36600319011261043a576020604051633b9aca008152f35b3461043a57604036600319011261043a57610dba613d88565b6004355f525f60205260405f209060018060a01b03165f52602052602060ff60405f2054166040519015158152f35b3461043a57604036600319011261043a57610e02613d72565b6024359061ffff821680920361043a57610e1a614515565b6001600160a01b03165f818152600d602052604090206004015460101c6001600160401b031615610846576103e88211610683575f52600d602052600460405f20019061ffff198254161790555f80f35b3461043a575f36600319011261043a57602060405173a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488152f35b3461043a57602036600319011261043a57602061087b610eb7613d72565b6146cb565b3461043a575f36600319011261043a57610ed4614515565b610edc614309565b600160ff1960025416176002557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b3461043a57602036600319011261043a57604051610f3281613f18565b5f8152602081015f9052604081015f9052606081015f9052608081015f905260a081015f905260c081015f905260e081015f9052610100908181015f9052610120908181015f9052610140918282015f9052610160928383015f9052610180918284015f90526101a0908185015f90526101c08086015f90526101e0908187015f9052610200938488015f9052610220968789015f9052610240988981015f9052610260015f90526004355f52600460205260405f20610ff190613fc5565b998a976040518d819e600160a01b600190039b8c81511684528c60208201511660208501528c6040820151166040850152606081015160608501526080810151608085015260a081015161ffff80911660a086015260c08201511660c085015260e081015160e085015201519101528c878d0151976001600160401b0380991691015286818d015116908d015285818c015116908c015284818b015116908b015283818a015116908a01528281890151169089015281818801511690880152818601511690860152818401511690840152808201519083016110d291613ec4565b6102600151151561026082015261028090f35b3461043a57602036600319011261043a576004356111016142e6565b611109614309565b805f52600460205260405f2090600a820191600883549161112f60ff8460a01c16614327565b6111413361113c83613fc5565b6144da565b0154926001600160401b03916111588386166144f2565b60ff60a01b1916600160a01b1790556040805193901c16825233917f314ba42b89005e45f141b530b3f8fb557b2070e3853b8d95facfb8549cec4a7690602090a360018055005b3461043a575f36600319011261043a57604051806007549182815260208091019260075f527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688915f905b82821061120c576107d38561120081890382613f4f565b60405191829182613e80565b83546001600160a01b0316865294850194600193840193909101906111e9565b3461043a57602036600319011261043a576001600160a01b0361124d613d72565b165f52600d60205260c060405f206001600160401b0360ff8254169160018101549060028101546004600383015492015492604051951515865260208601526040850152606084015261ffff8116608084015260101c1660a0820152f35b3461043a5761010036600319011261043a576112c5613d72565b6112cd613d88565b6112d5613dae565b906001600160401b0360a4351660a4350361043a576001600160401b0360c4351660c4350361043a5760e4356001600160a01b038116900361043a576113196142e6565b611321614309565b6001600160a01b03811615611ae35760018060a01b0381165f52600660205260405f206040519061135182613efd565b5460ff80821615918215845260081c166020830152611b5c5760208101516113af9163773594009160ff16600881116119e657506113a061139b60ff60206113a894015116614251565b614262565b6044356141a6565b1015614273565b6001600160a01b03831615611ae35760643515611b4a57610e10806001600160401b038416108015611b35575b611af557806001600160401b0360a43516108015611b1e575b611af5576001600160401b0360c43516108015611b07575b611af557336001600160a01b03841614611ae3576040516323b872dd60e01b60208201523360248201523060448201526044356064820152606481528060a08101106001600160401b0360a083011117610af55760a0810160405261147b906001600160a01b038316614c9f565b6003549161148883614987565b600355815f60e4356001600160a01b0316611a83575b6001600160a01b0382165f9081526006602052604080822090518892916114c482613efd565b5460ff80821615159182845260081c1660208301525f14611a04576001600160401b03929161151d6377359400859360ff60208201511660088111155f146119e657506113a061139b60ff60206113a894015116614251565b60095482906001600160a01b038716156119d8576001600160a01b0387165f908152600d602052604090206004015461ffff9081165b816115608c8642166140d9565b9361156d60a435866140d9565b9661157a60c435896140d9565b99604080519e8f9261158b84613f18565b33845260018060a01b0316602084015260018060a01b03169101528c606060443591015260808d01521660a08b01521660c089015260643560e08901525f6101008901521661012087015216610140850152166101608301526001600160401b0383166101808301526001600160401b0360a435166101a08301526001600160401b0360c435166101c08301526001600160401b0342166101e08301525f61020083015260018060a01b03166102208201525f6102408201525f610260820152835f52600460205260405f209060018060a01b038151166001600160601b0360a01b8354161782556001820160018060a01b036020830151166001600160601b0360a01b8254161790556002820160018060a01b036040830151166001600160601b0360a01b82541617905560608101516003830155608081015160048301556117076005830161ffff60a08401511661ffff1982541617815561ffff60c08401511663ffff000082549160101b169063ffff00001916179055565b60e08101516006830155610100810151600783015561187c600883016117d46001600160401b0361012085015116916001600160401b031992838254161781556117826001600160401b0361014087015116829067ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b610160850151815467ffffffffffffffff60801b191660809190911b67ffffffffffffffff60801b1617815561018085015181546001600160c01b031660c09190911b6001600160c01b031916179055565b60098401906001600160401b036101a0850151169082541617815561182a6001600160401b036101c085015116829067ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b6101e0830151815467ffffffffffffffff60801b191660809190911b67ffffffffffffffff60801b1617815561020083015181546001600160c01b031660c09190911b6001600160c01b031916179055565b610220810151600a830180546001600160a01b0319166001600160a01b0392909216919091179055610240810151956008871015610c6e5761190f83600a6102607f26eba422e79370cb5e1b2e3334dcb8de7ce02260b605de540c0f0bae7ef704a0956118ee60209c848d9a01613fa1565b01519101805460ff60a81b191691151560a81b60ff60a81b16919091179055565b825f52600487526001600160401b0360405f209461ffff60056004880154970154611938613f70565b976040519960018060a01b03168a526044358c8b015260408a015281811660608a015260101c16608088015260643560a08801521660c08601526001600160401b0360a4351660e08601526001600160401b0360c4351661010086015260018060a01b0360e4351661012086015261016061014086015260018060a01b031693806119c93395610160830190613e42565b0390a460018055604051908152f35b61ffff808260101c16611553565b6119ff915061139b6119f79161423e565b6044356141d0565b6113a8565b5050509050611a11614c5e565b908115611a4e576001600160401b03868184611a496377359400670de0b6b3a7640000611a418b996044356141a6565b041015614273565b61151d565b60405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420707269636560981b6044820152606490fd5b5050611a9060e4356146cb565b15611a9e578160e43561149e565b60405162461bcd60e51b815260206004820152601f60248201527f5072656665727265642061726269746572206973206e6f7420616374697665006044820152606490fd5b60405163e6c4247b60e01b8152600490fd5b60405163b11cd48160e01b8152600490fd5b5062278d006001600160401b0360c435161161140d565b5062ed4e006001600160401b0360a43516116113f5565b5062278d006001600160401b038416116113dc565b6040516392a3c43160e01b8152600490fd5b60405162461bcd60e51b815260206004820152602360248201527f546f6b656e206973206e6f74206120737570706f7274656420737461626c656360448201526237b4b760e91b6064820152608490fd5b3461043a57602036600319011261043a57600435600e5481101561043a57611bd6602091613dc4565b905460405160039290921b1c6001600160a01b03168152f35b3461043a575f36600319011261043a5760405180600e5491828152602080910192600e5f527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd915f905b828210611c50576107d38561120081890382613f4f565b83546001600160a01b031686529485019460019384019390910190611c39565b3461043a57611c7e36613d5c565b611c866142e6565b611c8e614309565b815f52600460205260405f2091600a830192835460ff8160a01c169460088610159283610c6e576001968781141580611f03575b611edc5781546001600160a01b039590861633141580611ecd575b611ebc57610c6e5760021480611eac575b611e1c575b82841615611dc55750805483169150611d0b826146cb565b15611d6f575b805460ff60a01b1916600360a01b179055165f908152600d6020526040902083018054611d3d90614987565b90556040519182527f7ab71b430e1c8a5ceb166189a725f797de4594dbf7b4493262e82e99f183eb6d60203393a38055005b60405162461bcd60e51b815260206004820152602860248201527f5072652d73656c65637465642061726269746572206973206e6f206c6f6e6765604482015267722061637469766560c01b6064820152608490fd5b611e1790611dd1614ad5565b9385851680916001600160601b0360a01b161784555f52600d602052600561ffff600460405f2001541691019063ffff000082549160101b169063ffff00001916179055565b611d11565b6001600160401b0380600883015460801c16611e40600984015460c01c8092614225565b6202a3008184161015611e9e57677fffffffffffffff611e67918b1c16915b834216614225565b9082811683831610611e7b57505050611cf3565b60249291611e8891614225565b604051631806d23b60e11b815291166004820152fd5b50611e676201518091611e5f565b50600981015460c01c1515611cee565b6040516282b42960e81b8152600490fd5b50858984015416331415611cdd565b60405163f924664d60e01b8152604491611efa906004830190613ec4565b60026024820152fd5b505f94506002811415611cc2565b3461043a57602036600319011261043a57611f2a613d72565b5f6020604051611f3981613efd565b828152015260018060a01b03165f5260066020526040805f2060ff825191611f6083613efd565b54816020818316151594858152019160081c168152835192835251166020820152f35b3461043a575f36600319011261043a57602060405173bf3a2c7c9bc27e3143df965ffa80e421f54456788152f35b3461043a57602036600319011261043a57600435611fcd6142e6565b611fd5614309565b805f52600460205260405f2090600a82019182549260ff8460a01c16936008851015610c6e576002850361209a57612094945061201533610bfc85613fc5565b61202e6001600160401b03600885015460801c166144f2565b60ff60a01b1916600160a21b17905560018101805483917fccc2f4f9903c15c16b3fe18956f58becad7fc1e3267c7652b847c3d71e61a1e0916020916003916001600160a01b03919061208390831687614707565b5416940154604051908152a361445d565b60018055005b60405163f924664d60e01b8152604490611efa6004820188613ec4565b3461043a575f36600319011261043a576020604051735f4ec3df9cbd43714fe2740f5e3616155c5b84198152f35b3461043a57602036600319011261043a576120fe613d72565b612106614515565b6001600160a01b031661211a8115156141e7565b6001600160601b0360a01b600c541617600c555f80f35b3461043a575f36600319011261043a57602060ff600254166040519015158152f35b3461043a575f36600319011261043a57602061ffff60095460101c16604051908152f35b3461043a575f36600319011261043a576107d360405161219681613efd565b6005815264312e302e3360d81b6020820152604051918291602083526020830190613e42565b3461043a575f36600319011261043a5760206040516102588152f35b3461043a575f36600319011261043a5760206040517fbb08418a67729a078f87bbc8d02a770929bb68f5bfdf134ae2ead6ed38e2f4ae8152f35b3461043a57602036600319011261043a5760043561222e6142e6565b805f52600460205260405f209061224482613fc5565b6102408101516008811015610c6e576002149081612341575b501561232f57600a8201805460ff60a01b1916600160a21b17905560018201805461209493916003916001600160a01b03919061229c90831686614707565b541691015490825f80516020614eac8339815191526122da6122bc613f70565b60405195865260076020870152608060408701526080860190613e42565b936b706f6e6420696e2074696d6560a01b604082870396876060850152602c81527f4175746f2d72656c65617365202d20627579657220646964206e6f742072657360208201520152606033950190a461445d565b604051633376277360e11b8152600490fd5b6001600160401b03915061016001511642118361225d565b3461043a57602036600319011261043a5760043560075481101561043a57611bd6602091613e0d565b3461043a575f36600319011261043a57600f546040516001600160a01b039091168152602090f35b3461043a575f36600319011261043a576123c2614515565b6123ca614ab6565b60ff19600254166002557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60c036600319011261043a57612414613d72565b6001600160401b03604435166044350361043a576001600160401b03606435166064350361043a57612444613dae565b60a4356001600160a01b038116810361043a5761245f6142e6565b612467614309565b6001600160a01b03831615611ae35766038d7ea4c6800034106129c45760243515611b4a57610e10806001600160401b03604435161080156129ad575b611af557806001600160401b0360643516108015612996575b611af5576001600160401b038316108015612981575b611af557336001600160a01b03841614611ae357600354916124f483614987565b600355835f6001600160a01b03841661296a575b5f80805260066020526040517f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f861253e82613efd565b549060ff6020818416151592838152019260081c1682525f1461292d579061259763773594006001600160401b039360ff81511660088111155f14612916575061259161139b60ff6113a8935116614251565b346141a6565b60095482906001600160a01b03851615612908576001600160a01b0385165f908152600d6020526040902060040154829061ffff165b61ffff6125de6044358442166140d9565b91816125ec606435856140d9565b956125f78d886140d9565b985f604080519e8f9061260982613f18565b33825260018060a01b0316602082015201528c60603491015260808d01521660a08b01521660c089015260243560e08901525f6101008901521661012087015216610140850152166101608301526001600160401b03604435166101808301526001600160401b03606435166101a08301526001600160401b0383166101c08301526001600160401b0342166101e08301525f61020083015260018060a01b03166102208201525f6102408201525f610260820152835f52600460205260405f209060018060a01b038151166001600160601b0360a01b8354161782556001820160018060a01b036020830151166001600160601b0360a01b8254161790556002820160018060a01b036040830151166001600160601b0360a01b825416179055606081015160038301556080810151600483015561277a6005830161ffff60a08401511661ffff1982541617815561ffff60c08401511663ffff000082549160101b169063ffff00001916179055565b60e0810151600683015561010081015160078301556127f5600883016117d46001600160401b0361012085015116916001600160401b031992838254161781556117826001600160401b0361014087015116829067ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b610220810151600a830180546001600160a01b0319166001600160a01b0392909216919091179055610240810151956008871015610c6e5761286783600a6102607f26eba422e79370cb5e1b2e3334dcb8de7ce02260b605de540c0f0bae7ef704a0956118ee60209c848d9a01613fa1565b825f526004875260405f20946001600160401b03600560048801549701549561ffff612891613f70565b97604051995f8b52348d8c015260408b015281811660608b015260101c16608089015260243560a0890152816044351660c0890152816064351660e08901521661010087015260018060a01b031661012086015261016061014086015260018060a01b031693806119c93395610160830190613e42565b8161ffff8260101c166125cd565b6119ff915061139b6129279161423e565b346141d0565b50509050612939614c5e565b908115611a4e576001600160401b03826129656377359400670de0b6b3a7640000611a418b97346141a6565b612597565b5050612975826146cb565b15611a9e578382612508565b5062278d006001600160401b038316116124d3565b5062ed4e006001600160401b0360643516116124bd565b5062278d006001600160401b0360443516116124a4565b60405163162908e360e11b8152600490fd5b3461043a57602036600319011261043a576129ef613d72565b6129f7614515565b60018060a01b0380911690815f526006602052612a1a60ff60405f205416614124565b5f828152600660205260408120805460ff191690555b600780548083101561077457839085612a4885613e0d565b939054600394851b1c1614612a6257505050600101612a30565b90929194505f199384820191821161056857612a9093612a84610ad793613e0d565b9054911b1c1691613e0d565b81548015612abe570190612abb612aa683613e0d565b81549060018060a01b039060031b1b19169055565b55005b634e487b7160e01b5f52603160045260245ffd5b3461043a57602036600319011261043a57600435612aee6142e6565b612af6614ab6565b612afe614515565b805f52600460205260405f2090600a82019182549260ff8460a01c166008811015610c6e5760078114159081612c29575b5015612bf05760ff60a01b19909316600560a01b17909255600282015482546003840180546120949591936001600160a01b0393612b739291908516908516614384565b5416905490825f80516020614eac833981519152612bb0612b92613f70565b60405195865260056020870152608060408701526080860190613e42565b937f456d657267656e63792072656c6561736520647572696e672070617573650000602082870396876060850152601e81520152604033950190a461445d565b60405162461bcd60e51b8152602060048201526011602482015270105b1c9958591e48199a5b985b1a5e9959607a1b6044820152606490fd5b60049150141585612b2f565b3461043a57604036600319011261043a57612c4e613d88565b336001600160a01b03821603612c6a5761077490600435614659565b60405163334bd91960e11b8152600490fd5b3461043a57602036600319011261043a57600435612c986142e6565b612ca0614309565b805f52600460205260405f2090600a82019182549260ff8460a81c1615612dc55760ff8460a01c16936008851015610c6e57600185141580612dba575b612d9d576120949450612cf33361113c85613fc5565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b03939092612d2c9291908516908516614384565b5416905490825f80516020614eac833981519152612d4b612b92613f70565b93681959081c99599d5b9960ba1b604082870396876060850152602981527f4d757475616c2061677265656d656e74202d2073656c6c657220617070726f7660208201520152606033950190a461445d565b60405163f924664d60e01b8152604490610c5a6004820188613ec4565b506002851415612cdd565b60405162461bcd60e51b8152602060048201526011602482015270139bc81c99599d5b99081c995c5d595cdd607a1b6044820152606490fd5b3461043a57602036600319011261043a57612e17613d72565b612e1f614515565b6001600160a01b038181165f818152600d60205260409020600401549192909160101c6001600160401b03161561084657815f52600d60205260405f20926001936002600182015491015403612f5b575f845b612ece575b83612e81846145aa565b50805f52600d6020525f60046040822082815582600182015582600282015582600382015501557fb7a0f68489d6e103758c5896f7f700d18e1e9213039ef12daf1c81a88b1ce6715f80a2005b600e805480831015612f5457839086612ee685613dc4565b939054600394851b1c1614612f0057505050840184612e72565b909291939596505f199586820191821161056857612f3093612f24610ad793613dc4565b9054911b1c1691613dc4565b8054928315612abe57612e81930190612f4b612aa683613dc4565b55829184612e77565b5050612e77565b60405162461bcd60e51b815260206004820152601960248201527f41726269746572206861732070656e64696e67206361736573000000000000006044820152606490fd5b3461043a57602036600319011261043a57612094600435612fbf6142e6565b612fc7614309565b805f52600460205260405f20600a81018054612fe860ff8260a01c1661435e565b612ff533610bfc85613fc5565b61300e6001600160401b03600885015460401c16614372565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b039390926130479291908516908516614384565b5416905490825f80516020614eac833981519152613066612b92613f70565b93663232b634bb32b960c91b604082870396876060850152602781527f5375626d69742074696d656f7574202d2073656c6c657220646964206e6f742060208201520152606033950190a461445d565b3461043a57604036600319011261043a576107746004356130d5613d88565b90805f525f6020526130ed600160405f20015461456b565b614a40565b3461043a57602036600319011261043a576004355f525f6020526020600160405f200154604051908152f35b3461043a57608036600319011261043a5760043560805261313d613d9e565b60443560ff9081811680910361043a5760649283359261315b6142e6565b613163614309565b6080515f526020916004835260405f2091600a830196875491808360a01c169360089485811015610c6e576003810361364a5750811698878a018281116105685782849116036136385760018060a01b039384811633147f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9295f525f895260405f20335f5289528360405f205416811580613630575b611ebc5781613627575b506135d6575b9060059594939291600360a11b9060ff60a01b19161790558760038b896001600160401b038d848c01549b61324e6127109d8e9261ffff9e8f91015460101c16906141a6565b04936040519661325d88613ee2565b338852848801918252604088019081526060880192835260056080890195854216875260a08a019788526080515f52528a60405f2098511688549260ff60a01b905160a01b169160ff60a81b905160a81b169269ffffffffffffffffffff60b01b161717178655516001860155600285019151166001600160401b0319825416179055519101556004875260405f2095600387015495816133028260095416896141a6565b049660048901548015155f146134eb57633b9aca00670de0b6b3a764000061332a838c6141a6565b04106134d9575b505b5f92600a8a0194855460a01c169288841015610c6e5760068a94146134b4575b50506133636133689284926141da565b6141da565b956002880195858754165f52895260405f2080549182018092116105685755801515806134a8575b61348f575b505088810361340b5750806133ae945416915416614384565b335f52600d8152600260405f20016133c68154614987565b9055604051938452830152604082015233907f943c9c113661af578bbf2cbbfb531582e552aa48ab9002da7f837049687ecee8606060805192a361209460805161445d565b91939186810361342e57506001816134299554169201541690614384565b6133ae565b6134449061343c8a866141a6565b0480946141da565b9280613477575b508261345b575b505050506133ae565b60018161346e9554169201541690614384565b84808080613452565b61348990828654168385541690614384565b8861344b565b6134a191848087541691541690614384565b8980613395565b50838254161515613390565b613368939450906134d16133639260058d015460101c16846141a6565b049392613353565b6134e49198506141b9565b968d613331565b508560028a0154165f5260068a5260405f208a856040519261350c84613efd565b54818116151584528a1c169101818152908881116135bb575061353d61353761139b87845116614251565b8a6141a6565b905b633b9aca00809210613553575b5050613333565b858092939a50815116898111155f1461359b57506135769161139b915116614251565b9081156135875704965b8d8061354c565b634e487b7160e01b5f52601260045260245ffd5b6135aa925061139b915061423e565b808202918204036105685796613580565b6135ca61139b6135d09261423e565b8a6141d0565b9061353f565b6135df336146cb565b6132085760405162461bcd60e51b815260048101899052601c60248201527f4172626974657220686173206265656e2064656163746976617465640000000060448201528490fd5b9050158c613202565b5080156131f8565b60405163648564d360e01b8152600490fd5b60405163f924664d60e01b8152604491613668906004830190613ec4565b60036024820152fd5b3461043a57602036600319011261043a5761368a613d72565b613692614515565b6001600160a01b03811690811561084657815f52600d6020526001600160401b039081600460405f20015460101c166137c95761ffff918260095460101c1690421692604051906136e282613ee2565b60018252600460208301925f8452604081015f81526060820190605082526080830196875260a08301958987528a5f52600d60205261373460405f2094511515859060ff801983541691151516179055565b5160018401555160028301555160038201550192511669ffffffffffffffff00008354925160101b169169ffffffffffffffffffff191617179055600e5491600160401b831015610af5576137bf826137ba602094610ad78760017f3e9e037f5ae1b02104d124fd8f1783111cdf05db0bf2f9b784b2c8d3d866ebf49901600e55613dc4565b614995565b50604051908152a2005b6040516301934db960e01b8152600490fd5b3461043a575f36600319011261043a57602060405163773594008152f35b3461043a57604036600319011261043a57610774613815613d72565b61381d613d9e565b90613826614515565b6001600160a01b03165f818152600660205260409020546138499060ff16614124565b61386060ff83168015159081613881575b50614167565b5f52600660205260405f209061ff0082549160081b169061ff001916179055565b6012915011158561385a565b3461043a575f36600319011261043a576020601054604051908152f35b3461043a57602036600319011261043a576138c3613d72565b6138cb614515565b6001600160a01b0381165f818152600d602052604090206004015490919060101c6001600160401b03161561084657610774915f52600d60205260405f2060ff1981541690556145aa565b3461043a57602036600319011261043a5761392f613d72565b6139376140f4565b5060018060a01b03165f52600d60205260c060405f2060a06040519161395c83613ee2565b60ff815416151592838152600182015490602081019182526002830154926040820193845260046003820154916060840192835201549361ffff93608084019385871685526001600160401b03978891019660101c16865260405197885251602088015251604087015251606086015251166080840152511660a0820152f35b3461043a576139ea36613d5c565b6139f26142e6565b6139fa614309565b815f52600460205260405f2090600a820190613a1c60ff835460a01c1661435e565b613a293361113c85613fc5565b600883016001600160401b0390613a4582825460401c166144f2565b8215611b4a57613aef613ac786846040978760077f9e9c1d76a37a54669f8a78e425540f992456de1e11f2e7304bd440057eff2ddf9b01556009824216930190613aac8483908154906001600160401b0360c01b9060c01b169060018060c01b0316179055565b805460ff60a01b1916600160a11b17905554881c16906140d9565b825467ffffffffffffffff60801b191660809190911b67ffffffffffffffff60801b16178255565b5460801c1682519182526020820152a260018055005b3461043a57602036600319011261043a57612094600435613b246142e6565b805f52600460205260405f20600a81018054613b4560ff8260a01c1661435e565b613b5233610bfc85613fc5565b613b6b6001600160401b03600885015460401c16614372565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b03939092613ba49291908516908516614384565b5416905490825f80516020614eac833981519152613bc3612b92613f70565b937f4175746f2d726566756e64202d207375626d69742074696d656f757400000000602082870396876060850152601c81520152604033950190a461445d565b3461043a57602036600319011261043a57612094600435613c226142e6565b613c2a614309565b805f52600460205260405f20600a81018054613c4b60ff8260a01c16614327565b613c616001600160401b03600885015416614372565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b03939092613c9a9291908516908516614384565b5416905490825f80516020614eac833981519152613cb9612b92613f70565b93661c995cdc1bdb9960ca1b604082870396876060850152602781527f4163636570742074696d656f7574202d2073656c6c657220646964206e6f742060208201520152606033950190a461445d565b3461043a57602036600319011261043a576004359063ffffffff60e01b821680920361043a57602091637965db0b60e01b8114908115613d4b575b5015158152f35b6301ffc9a760e01b14905083613d44565b604090600319011261043a576004359060243590565b600435906001600160a01b038216820361043a57565b602435906001600160a01b038216820361043a57565b6024359060ff8216820361043a57565b608435906001600160401b038216820361043a57565b600e54811015613df957600e5f527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd01905f90565b634e487b7160e01b5f52603260045260245ffd5b600754811015613df95760075f527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68801905f90565b91908251928382525f5b848110613e6c575050825f602080949584010152601f8019910116010190565b602081830181015184830182015201613e4c565b60209060206040818301928281528551809452019301915f5b828110613ea7575050505090565b83516001600160a01b031685529381019392810192600101613e99565b906008821015610c6e5752565b6004359061ffff8216820361043a57565b60c081019081106001600160401b03821117610af557604052565b604081019081106001600160401b03821117610af557604052565b61028081019081106001600160401b03821117610af557604052565b608081019081106001600160401b03821117610af557604052565b90601f801991011681019081106001600160401b03821117610af557604052565b60405190613f7d82613efd565b60158252743cb13d1734b790169022b9b1b937bb902630bcb2b960591b6020830152565b906008811015610c6e57815460ff60a01b191660a09190911b60ff60a01b16179055565b90604051613fd281613f18565b8092600a60018060a01b03918281541684528260018201541660208501528260028201541660408501526003810154606085015260048101546080850152600581015461ffff9081811660a087015260101c1660c0850152600681015460e0850152600781015461010085015260088101546001600160401b0390818116610120870152818160401c16610140870152818160801c1661016087015260c01c6101808601526009820154908082166101a0870152808260401c166101c08701528160801c166101e086015260c01c610200850152015490811661022083015260ff8160a01c166008811015610c6e576102609160ff9161024085015260a81c161515910152565b9190916001600160401b038080941691160191821161056857565b6040519061410182613ee2565b5f60a0838281528260208201528260408201528260608201528260808201520152565b1561412b57565b60405162461bcd60e51b815260206004820152601460248201527314dd18589b1958dbda5b881b9bdd08199bdd5b9960621b6044820152606490fd5b1561416e57565b60405162461bcd60e51b815260206004820152601060248201526f496e76616c696420646563696d616c7360801b6044820152606490fd5b8181029291811591840414171561056857565b8015613587576b033b2e3c9fd0803ce80000000490565b8115613587570490565b9190820391821161056857565b156141ee57565b60405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606490fd5b6001600160401b03918216908216039190821161056857565b60ff6007199116019060ff821161056857565b60ff166008039060ff821161056857565b60ff16604d811161056857600a0a90565b1561427a57565b60405162461bcd60e51b815260206004820152601d60248201527f4465616c20616d6f756e742062656c6f7720243230206d696e696d756d0000006044820152606490fd5b6001600160a01b031680156142e0575f52600660205260ff60405f20541690565b50600190565b6002600154146142f7576002600155565b604051633ee5aeb560e01b8152600490fd5b60ff6002541661431557565b60405163d93c066560e01b8152600490fd5b6008811015610c6e57806143385750565b60405163f924664d60e01b8152604491614356906004830190613ec4565b5f6024820152fd5b6008811015610c6e5760018103610c3c5750565b6001600160401b031642111561232f57565b8215614458576001600160a01b0390811690816144235750505f80809381935af13d1561441e573d6001600160401b038111610af557604051906143d2601f8201601f191660200183613f4f565b81525f60203d92013e5b156143e357565b60405162461bcd60e51b8152602060048201526013602482015272115512081d1c985b9cd9995c8819985a5b1959606a1b6044820152606490fd5b6143dc565b92614456936040519363a9059cbb60e01b602086015216602484015260448301526044825261445182613f34565b614c9f565b565b505050565b5f5260046020525f600a60408220828155826001820155826002820155826003820155826004820155826005820155826006820155826007820155826008820155826009820155015560056020525f6003604082208281558260018201558260028201550155565b516001600160a01b03908116911603611ebc57565b602001516001600160a01b03908116911603611ebc57565b6001600160401b0316421161450357565b60405163387b2e5560e11b8152600490fd5b335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff161561454d57565b60405163e2517d3f60e01b81523360048201525f6024820152604490fd5b805f525f60205260405f20335f5260205260ff60405f2054161561458c5750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b6001600160a01b03165f8181527f89777fffb7045c97177d1161cd08d871365cb73d0b18f242761255a7718434cf60205260409020547fbb08418a67729a078f87bbc8d02a770929bb68f5bfdf134ae2ead6ed38e2f4ae919060ff161561465357815f525f60205260405f20815f5260205260405f2060ff19815416905533917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b50505f90565b90815f525f60205260405f209060018060a01b031690815f5260205260ff60405f2054165f1461465357815f525f60205260405f20815f5260205260405f2060ff19815416905533917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b6001600160a01b03165f908152600d60205260409020805460ff1690816146f0575090565b6001600160401b0391506004015460101c16151590565b9190915f526004918260205260405f20926003840154906127109261ffff846147348260095416866141a6565b0493838801548015155f1461487c57633b9aca00670de0b6b3a764000061475b83896141a6565b041061486a575b505b5f95600a89019260ff845460a01c1660088110156148575760061461482e575b50508561336386614794936141da565b94600288019460018060a01b0394858754165f52600860205260405f2090815492830180931161481b5750559596614456968492908015158061480f575b6147f6575b5050828216156147ec575050915b5416614384565b54169290506147e5565b61480891848089541691541690614384565b5f806147d7565b508382541615156147d2565b601190634e487b7160e01b5f525260245ffd5b869750614794929161484c6133639260058d015460101c16846141a6565b049750819250614784565b602187634e487b7160e01b5f525260245ffd5b6148759195506141b9565b935f614762565b5060018060a01b036002890154165f52600660205260405f20602060ff604051926148a684613efd565b548181161515845260081c1691019080825260088111155f1461496c57506148dd6148d761139b60ff845116614251565b876141a6565b905b633b9aca008092106148f3575b5050614764565b8051929650909160ff166008811161493a575061139b60ff614916925116614251565b9081156149275704935b5f806148ec565b601285634e487b7160e01b5f525260245ffd5b614948915061139b9061423e565b808202918204036149595793614920565b601184634e487b7160e01b5f525260245ffd5b61497b61139b6149819261423e565b876141d0565b906148df565b5f1981146105685760010190565b6001600160a01b03165f8181527f89777fffb7045c97177d1161cd08d871365cb73d0b18f242761255a7718434cf60205260409020547fbb08418a67729a078f87bbc8d02a770929bb68f5bfdf134ae2ead6ed38e2f4ae919060ff1661465357815f525f60205260405f20815f5260205260405f20600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b90815f525f60205260405f209060018060a01b031690815f5260205260ff60405f205416155f1461465357815f525f60205260405f20815f5260205260405f20600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b60ff6002541615614ac357565b604051638dfc202b60e01b8152600490fd5b600e545f91825b828110614c1657508215614bdc576040926040519060209160208101904282524460408201523360601b606082015260548152614b1881613f34565b51902006935f945f5b858110614b6d5760405162461bcd60e51b815260206004820152601860248201527f417262697465722073656c656374696f6e206661696c656400000000000000006044820152606490fd5b614b7681613dc4565b60018060a01b03809254600392831b1c165f52600d865260ff855f205416614ba3575b5050600101614b21565b8389939914614bc1575050614bb9600191614987565b96905f614b99565b9597935095505050614bd39150613dc4565b9054911b1c1690565b60405162461bcd60e51b81526020600482015260126024820152714e6f2061637469766520617262697465727360701b6044820152606490fd5b614c1f81613dc4565b60018060a01b0391549060031b1c165f52600d60205260ff60405f205416614c4a575b600101614adc565b92614c56600191614987565b939050614c42565b6011548015159081614c89575b50614c8357614c78614d1b565b806010554260115590565b60105490565b6102589150614c9890426141da565b105f614c6b565b905f602091828151910182855af115614cf9575f513d614cf057506001600160a01b0381163b155b614cce5750565b604051635274afe760e01b81526001600160a01b039091166004820152602490fd5b60011415614cc7565b6040513d5f823e3d90fd5b519069ffffffffffffffffffff8216820361043a57565b600f546001600160a01b03168015614e945760a060049160405192838092633fabe5a360e21b82525afa805f925f92614e3e575b50614d655760405162bfc92160e01b8152600490fd5b5f821315614df9578015614dbe57614d80610e1091426141da565b1015614d895790565b60405162461bcd60e51b815260206004820152600d60248201526c141c9a58d9481d1bdbc81bdb19609a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601360248201527250726963652064617461206973207374616c6560681b6044820152606490fd5b60405162461bcd60e51b815260206004820152601760248201527f496e76616c69642070726963652066726f6d20666565640000000000000000006044820152606490fd5b9250905060a0823d60a011614e8c575b81614e5b60a09383613f4f565b8101031261043a57614e6c82614d04565b506020820151614e83608060608501519401614d04565b5091905f614d4f565b3d9150614e4e565b506010548015614ea15790565b50643a352944009056fef2939da9344d885aca2f5f28e06d6a2f38fc3646202731fdc9730008761a3ed8a2646970667358221220454c7c2873ac8af6466d2717765fc219da4ffc7b215ca93ebd77e0bb37820f2a64736f6c634300081800332f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d89777fffb7045c97177d1161cd08d871365cb73d0b18f242761255a7718434cfbb08418a67729a078f87bbc8d02a770929bb68f5bfdf134ae2ead6ed38e2f4aead3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5000000000000000000000000b5ec77fe37481ab79430f8bd9284741c50a5432100000000000000000000000031bc0e77a629be095b58fc428c84541aee811111

Deployed Bytecode

0x60a08060405260043610156100c6575b5036156100755760405162461bcd60e51b815260206004820152603160248201527f46756e6374696f6e206e6f7420666f756e642e20557365206372656174654465604482015270616c455448282920666f72206465616c7360781b6064820152608490fd5b60405162461bcd60e51b815260206004820152602360248201527f557365206372656174654465616c455448282920746f20637265617465206465604482015262616c7360e81b6064820152608490fd5b5f3560e01c90816301ffc9a714613d095750806306ba047314613c035780630993cdbe14613b055780630a9eeded146139dc5780630c3054cd146139165780630db2ad8b146138aa5780631322ec8c1461388d578063172d4d1b146137f957806317d80419146137db5780631c1e42bf14613671578063204769741461311e578063248a9ca3146130f25780632f2ff15d146130b657806331ea1a3914612fa05780633487e08c14612dfe578063348a71a614612c7c57806336568abe14612c3557806339c28c6214612ad25780633b947d2b146129d65780633eff50e0146124005780633f4ba83a146123aa57806342f6fb29146123825780634450b47214612359578063459b860e146122125780634d104adf146121d8578063539f51db146121bc57806354fd4d5014612177578063564201f91461043e5780635be5eeea146121535780635c975abb146121315780635e72fc5d146120e55780635ebf1d75146120b75780635f9d8efb14611fb15780636035ceba14611f8357806360e74f5614611f11578063636bf26d14611c7057806367946dd814611bef5780637414126614611bad5780637678734c146112ab5780637bf2bb101461122c5780637c6f73eb1461119f5780637d41702e146110e557806382fd5bac14610f155780638456cb5914610ebc57806385407c9a14610e9957806389a3027114610e6b57806390c4c34a14610de957806391d1485414610da1578063929b657814610d8357806393144f5014610d6657806395877f7814610d1a5780639791d49214610cec578063a100d69d14610c9c578063a217fddf14610c82578063a4b2409e14610b96578063a52dba3c146109f8578063ad3b1b47146108c3578063afb0695214610885578063b5af090f14610858578063b64fefd9146107d7578063bd0bb4d3146107a4578063c54e44eb14610776578063d547741f14610738578063d55be8c61461071c578063d65f203a146106ee578063d7a71868146106b2578063d98906b114610695578063e0d1732b14610638578063e61d47c51461057c578063eadb3c9c1461053f578063ed3b7e9f1461051e578063f2bcd022146104f6578063f5b541a6146104bc578063fa84783614610476578063fcf666641461043e5763fd03088b14610416575f61000f565b3461043a575f36600319011261043a57604060105460115482519182526020820152f35b5f80fd5b3461043a57602036600319011261043a576001600160a01b0361045f613d72565b165f526008602052602060405f2054604051908152f35b3461043a57602036600319011261043a576001600160a01b03610497613d72565b165f5260066020526040805f205460ff8251918181161515835260081c166020820152f35b3461043a575f36600319011261043a5760206040517f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9298152f35b3461043a575f36600319011261043a57600c546040516001600160a01b039091168152602090f35b3461043a575f36600319011261043a57602061ffff60095416604051908152f35b3461043a575f36600319011261043a576003545f19810190811161056857602090604051908152f35b634e487b7160e01b5f52601160045260245ffd5b3461043a57602036600319011261043a576105956140f4565b506004355f52600560205260c060405f206040516105b281613ee2565b815460018060a01b03811692838352602083019160ff8160a01c16835260ff604085019160a81c16815260ff60018301549160608601928352816001600160401b039560a06003886002890154169760808b01988952015498019788526040519889525116602088015251166040860152516060850152511660808301525160a0820152f35b3461043a57602036600319011261043a57610651613ed1565b610659614515565b6103e861ffff8216116106835763ffff00006009549160101b169063ffff00001916176009555f80f35b6040516358d620b360e01b8152600490fd5b3461043a575f36600319011261043a576020604051620151808152f35b3461043a57602036600319011261043a576004356106ce614515565b80156106dd5760105542601155005b60405162bfc92160e01b8152600490fd5b3461043a575f36600319011261043a57602060405173b1bb66c47dee78b91e8aeeb6e74e66e02ca345678152f35b3461043a575f36600319011261043a5760206040516103e88152f35b3461043a57604036600319011261043a57610774600435610757613d88565b90805f525f60205261076f600160405f20015461456b565b614659565b005b3461043a575f36600319011261043a57602060405173dac17f958d2ee523a2206206994597c13d831ec78152f35b3461043a575f36600319011261043a576107d36107bf613f70565b604051918291602083526020830190613e42565b0390f35b3461043a57602036600319011261043a576107f0613d72565b6107f8614515565b6001600160a01b0381165f818152600d602052604090206004015490919060101c6001600160401b03161561084657610774915f52600d60205260405f20600160ff19825416179055614995565b604051630cb5cfe160e31b8152600490fd5b3461043a57602036600319011261043a57602061087b610876613d72565b6142bf565b6040519015158152f35b3461043a57602036600319011261043a5761ffff6108a1613ed1565b6108a9614515565b166103e881116106835761ffff1960095416176009555f80f35b3461043a57604036600319011261043a576108dc613d72565b602435906108e8614515565b6108f06142e6565b6001600160a01b038181165f818152600860205260409020549390929084156109bd57806109b75750835b841161097e577eed5939179dc194223f0edd1517ecee2210b22da7f82c8e4b1795e93b9f06aa9161096c85602093865f526008855260405f2061095f8382546141da565b905583600c541690614384565b600c541693604051908152a360018055005b60405162461bcd60e51b8152602060048201526011602482015270496e73756666696369656e74206665657360781b6044820152606490fd5b9361091b565b60405162461bcd60e51b81526020600482015260136024820152724e6f206665657320746f20776974686472617760681b6044820152606490fd5b3461043a57604036600319011261043a57610a11613d72565b610a19613d9e565b610a21614515565b6001600160a01b038216908115610b595760ff169081151580610b4e575b610a4890614167565b805f52600660205260ff60405f205416610b095760ff610ab49260405192610a6f84613efd565b60018452602084019182525f526006602052610a9e60405f2093511515849060ff801983541691151516179055565b51825461ff001916911660081b61ff0016179055565b60075490600160401b821015610af557610ad78260016107749401600755613e0d565b90919060018060a01b038084549260031b9316831b921b1916179055565b634e487b7160e01b5f52604160045260245ffd5b60405162461bcd60e51b815260206004820152601960248201527f537461626c65636f696e20616c726561647920657869737473000000000000006044820152606490fd5b506012821115610a3f565b60405162461bcd60e51b8152602060048201526015602482015274496e76616c696420746f6b656e206164647265737360581b6044820152606490fd5b3461043a57602036600319011261043a57600435610bb26142e6565b610bba614309565b805f52600460205260405f20600a81019081549060ff8260a01c166008811015610c6e57600181141580610c63575b610c3c5750610c0190610bfc3391613fc5565b6144c5565b60ff60a81b1916600160a81b17905533907fd8420f97dab0b820e066ebfad617848c1eab2d260922358cc1d5cdcdc568d5725f80a360018055005b60405163f924664d60e01b8152604491610c5a906004830190613ec4565b60016024820152fd5b506002811415610be9565b634e487b7160e01b5f52602160045260245ffd5b3461043a575f36600319011261043a5760206040515f8152f35b3461043a57602036600319011261043a57600435600b5481101561043a57602090600b5f527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90154604051908152f35b3461043a57602036600319011261043a576004355f52600a602052602061ffff60405f205416604051908152f35b3461043a57602036600319011261043a57610d33613d72565b610d3b614515565b6001600160a01b0316610d4f8115156141e7565b6001600160601b0360a01b600f541617600f555f80f35b3461043a575f36600319011261043a576020601154604051908152f35b3461043a575f36600319011261043a576020604051633b9aca008152f35b3461043a57604036600319011261043a57610dba613d88565b6004355f525f60205260405f209060018060a01b03165f52602052602060ff60405f2054166040519015158152f35b3461043a57604036600319011261043a57610e02613d72565b6024359061ffff821680920361043a57610e1a614515565b6001600160a01b03165f818152600d602052604090206004015460101c6001600160401b031615610846576103e88211610683575f52600d602052600460405f20019061ffff198254161790555f80f35b3461043a575f36600319011261043a57602060405173a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488152f35b3461043a57602036600319011261043a57602061087b610eb7613d72565b6146cb565b3461043a575f36600319011261043a57610ed4614515565b610edc614309565b600160ff1960025416176002557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b3461043a57602036600319011261043a57604051610f3281613f18565b5f8152602081015f9052604081015f9052606081015f9052608081015f905260a081015f905260c081015f905260e081015f9052610100908181015f9052610120908181015f9052610140918282015f9052610160928383015f9052610180918284015f90526101a0908185015f90526101c08086015f90526101e0908187015f9052610200938488015f9052610220968789015f9052610240988981015f9052610260015f90526004355f52600460205260405f20610ff190613fc5565b998a976040518d819e600160a01b600190039b8c81511684528c60208201511660208501528c6040820151166040850152606081015160608501526080810151608085015260a081015161ffff80911660a086015260c08201511660c085015260e081015160e085015201519101528c878d0151976001600160401b0380991691015286818d015116908d015285818c015116908c015284818b015116908b015283818a015116908a01528281890151169089015281818801511690880152818601511690860152818401511690840152808201519083016110d291613ec4565b6102600151151561026082015261028090f35b3461043a57602036600319011261043a576004356111016142e6565b611109614309565b805f52600460205260405f2090600a820191600883549161112f60ff8460a01c16614327565b6111413361113c83613fc5565b6144da565b0154926001600160401b03916111588386166144f2565b60ff60a01b1916600160a01b1790556040805193901c16825233917f314ba42b89005e45f141b530b3f8fb557b2070e3853b8d95facfb8549cec4a7690602090a360018055005b3461043a575f36600319011261043a57604051806007549182815260208091019260075f527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688915f905b82821061120c576107d38561120081890382613f4f565b60405191829182613e80565b83546001600160a01b0316865294850194600193840193909101906111e9565b3461043a57602036600319011261043a576001600160a01b0361124d613d72565b165f52600d60205260c060405f206001600160401b0360ff8254169160018101549060028101546004600383015492015492604051951515865260208601526040850152606084015261ffff8116608084015260101c1660a0820152f35b3461043a5761010036600319011261043a576112c5613d72565b6112cd613d88565b6112d5613dae565b906001600160401b0360a4351660a4350361043a576001600160401b0360c4351660c4350361043a5760e4356001600160a01b038116900361043a576113196142e6565b611321614309565b6001600160a01b03811615611ae35760018060a01b0381165f52600660205260405f206040519061135182613efd565b5460ff80821615918215845260081c166020830152611b5c5760208101516113af9163773594009160ff16600881116119e657506113a061139b60ff60206113a894015116614251565b614262565b6044356141a6565b1015614273565b6001600160a01b03831615611ae35760643515611b4a57610e10806001600160401b038416108015611b35575b611af557806001600160401b0360a43516108015611b1e575b611af5576001600160401b0360c43516108015611b07575b611af557336001600160a01b03841614611ae3576040516323b872dd60e01b60208201523360248201523060448201526044356064820152606481528060a08101106001600160401b0360a083011117610af55760a0810160405261147b906001600160a01b038316614c9f565b6003549161148883614987565b600355815f60e4356001600160a01b0316611a83575b6001600160a01b0382165f9081526006602052604080822090518892916114c482613efd565b5460ff80821615159182845260081c1660208301525f14611a04576001600160401b03929161151d6377359400859360ff60208201511660088111155f146119e657506113a061139b60ff60206113a894015116614251565b60095482906001600160a01b038716156119d8576001600160a01b0387165f908152600d602052604090206004015461ffff9081165b816115608c8642166140d9565b9361156d60a435866140d9565b9661157a60c435896140d9565b99604080519e8f9261158b84613f18565b33845260018060a01b0316602084015260018060a01b03169101528c606060443591015260808d01521660a08b01521660c089015260643560e08901525f6101008901521661012087015216610140850152166101608301526001600160401b0383166101808301526001600160401b0360a435166101a08301526001600160401b0360c435166101c08301526001600160401b0342166101e08301525f61020083015260018060a01b03166102208201525f6102408201525f610260820152835f52600460205260405f209060018060a01b038151166001600160601b0360a01b8354161782556001820160018060a01b036020830151166001600160601b0360a01b8254161790556002820160018060a01b036040830151166001600160601b0360a01b82541617905560608101516003830155608081015160048301556117076005830161ffff60a08401511661ffff1982541617815561ffff60c08401511663ffff000082549160101b169063ffff00001916179055565b60e08101516006830155610100810151600783015561187c600883016117d46001600160401b0361012085015116916001600160401b031992838254161781556117826001600160401b0361014087015116829067ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b610160850151815467ffffffffffffffff60801b191660809190911b67ffffffffffffffff60801b1617815561018085015181546001600160c01b031660c09190911b6001600160c01b031916179055565b60098401906001600160401b036101a0850151169082541617815561182a6001600160401b036101c085015116829067ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b6101e0830151815467ffffffffffffffff60801b191660809190911b67ffffffffffffffff60801b1617815561020083015181546001600160c01b031660c09190911b6001600160c01b031916179055565b610220810151600a830180546001600160a01b0319166001600160a01b0392909216919091179055610240810151956008871015610c6e5761190f83600a6102607f26eba422e79370cb5e1b2e3334dcb8de7ce02260b605de540c0f0bae7ef704a0956118ee60209c848d9a01613fa1565b01519101805460ff60a81b191691151560a81b60ff60a81b16919091179055565b825f52600487526001600160401b0360405f209461ffff60056004880154970154611938613f70565b976040519960018060a01b03168a526044358c8b015260408a015281811660608a015260101c16608088015260643560a08801521660c08601526001600160401b0360a4351660e08601526001600160401b0360c4351661010086015260018060a01b0360e4351661012086015261016061014086015260018060a01b031693806119c93395610160830190613e42565b0390a460018055604051908152f35b61ffff808260101c16611553565b6119ff915061139b6119f79161423e565b6044356141d0565b6113a8565b5050509050611a11614c5e565b908115611a4e576001600160401b03868184611a496377359400670de0b6b3a7640000611a418b996044356141a6565b041015614273565b61151d565b60405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420707269636560981b6044820152606490fd5b5050611a9060e4356146cb565b15611a9e578160e43561149e565b60405162461bcd60e51b815260206004820152601f60248201527f5072656665727265642061726269746572206973206e6f7420616374697665006044820152606490fd5b60405163e6c4247b60e01b8152600490fd5b60405163b11cd48160e01b8152600490fd5b5062278d006001600160401b0360c435161161140d565b5062ed4e006001600160401b0360a43516116113f5565b5062278d006001600160401b038416116113dc565b6040516392a3c43160e01b8152600490fd5b60405162461bcd60e51b815260206004820152602360248201527f546f6b656e206973206e6f74206120737570706f7274656420737461626c656360448201526237b4b760e91b6064820152608490fd5b3461043a57602036600319011261043a57600435600e5481101561043a57611bd6602091613dc4565b905460405160039290921b1c6001600160a01b03168152f35b3461043a575f36600319011261043a5760405180600e5491828152602080910192600e5f527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd915f905b828210611c50576107d38561120081890382613f4f565b83546001600160a01b031686529485019460019384019390910190611c39565b3461043a57611c7e36613d5c565b611c866142e6565b611c8e614309565b815f52600460205260405f2091600a830192835460ff8160a01c169460088610159283610c6e576001968781141580611f03575b611edc5781546001600160a01b039590861633141580611ecd575b611ebc57610c6e5760021480611eac575b611e1c575b82841615611dc55750805483169150611d0b826146cb565b15611d6f575b805460ff60a01b1916600360a01b179055165f908152600d6020526040902083018054611d3d90614987565b90556040519182527f7ab71b430e1c8a5ceb166189a725f797de4594dbf7b4493262e82e99f183eb6d60203393a38055005b60405162461bcd60e51b815260206004820152602860248201527f5072652d73656c65637465642061726269746572206973206e6f206c6f6e6765604482015267722061637469766560c01b6064820152608490fd5b611e1790611dd1614ad5565b9385851680916001600160601b0360a01b161784555f52600d602052600561ffff600460405f2001541691019063ffff000082549160101b169063ffff00001916179055565b611d11565b6001600160401b0380600883015460801c16611e40600984015460c01c8092614225565b6202a3008184161015611e9e57677fffffffffffffff611e67918b1c16915b834216614225565b9082811683831610611e7b57505050611cf3565b60249291611e8891614225565b604051631806d23b60e11b815291166004820152fd5b50611e676201518091611e5f565b50600981015460c01c1515611cee565b6040516282b42960e81b8152600490fd5b50858984015416331415611cdd565b60405163f924664d60e01b8152604491611efa906004830190613ec4565b60026024820152fd5b505f94506002811415611cc2565b3461043a57602036600319011261043a57611f2a613d72565b5f6020604051611f3981613efd565b828152015260018060a01b03165f5260066020526040805f2060ff825191611f6083613efd565b54816020818316151594858152019160081c168152835192835251166020820152f35b3461043a575f36600319011261043a57602060405173bf3a2c7c9bc27e3143df965ffa80e421f54456788152f35b3461043a57602036600319011261043a57600435611fcd6142e6565b611fd5614309565b805f52600460205260405f2090600a82019182549260ff8460a01c16936008851015610c6e576002850361209a57612094945061201533610bfc85613fc5565b61202e6001600160401b03600885015460801c166144f2565b60ff60a01b1916600160a21b17905560018101805483917fccc2f4f9903c15c16b3fe18956f58becad7fc1e3267c7652b847c3d71e61a1e0916020916003916001600160a01b03919061208390831687614707565b5416940154604051908152a361445d565b60018055005b60405163f924664d60e01b8152604490611efa6004820188613ec4565b3461043a575f36600319011261043a576020604051735f4ec3df9cbd43714fe2740f5e3616155c5b84198152f35b3461043a57602036600319011261043a576120fe613d72565b612106614515565b6001600160a01b031661211a8115156141e7565b6001600160601b0360a01b600c541617600c555f80f35b3461043a575f36600319011261043a57602060ff600254166040519015158152f35b3461043a575f36600319011261043a57602061ffff60095460101c16604051908152f35b3461043a575f36600319011261043a576107d360405161219681613efd565b6005815264312e302e3360d81b6020820152604051918291602083526020830190613e42565b3461043a575f36600319011261043a5760206040516102588152f35b3461043a575f36600319011261043a5760206040517fbb08418a67729a078f87bbc8d02a770929bb68f5bfdf134ae2ead6ed38e2f4ae8152f35b3461043a57602036600319011261043a5760043561222e6142e6565b805f52600460205260405f209061224482613fc5565b6102408101516008811015610c6e576002149081612341575b501561232f57600a8201805460ff60a01b1916600160a21b17905560018201805461209493916003916001600160a01b03919061229c90831686614707565b541691015490825f80516020614eac8339815191526122da6122bc613f70565b60405195865260076020870152608060408701526080860190613e42565b936b706f6e6420696e2074696d6560a01b604082870396876060850152602c81527f4175746f2d72656c65617365202d20627579657220646964206e6f742072657360208201520152606033950190a461445d565b604051633376277360e11b8152600490fd5b6001600160401b03915061016001511642118361225d565b3461043a57602036600319011261043a5760043560075481101561043a57611bd6602091613e0d565b3461043a575f36600319011261043a57600f546040516001600160a01b039091168152602090f35b3461043a575f36600319011261043a576123c2614515565b6123ca614ab6565b60ff19600254166002557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60c036600319011261043a57612414613d72565b6001600160401b03604435166044350361043a576001600160401b03606435166064350361043a57612444613dae565b60a4356001600160a01b038116810361043a5761245f6142e6565b612467614309565b6001600160a01b03831615611ae35766038d7ea4c6800034106129c45760243515611b4a57610e10806001600160401b03604435161080156129ad575b611af557806001600160401b0360643516108015612996575b611af5576001600160401b038316108015612981575b611af557336001600160a01b03841614611ae357600354916124f483614987565b600355835f6001600160a01b03841661296a575b5f80805260066020526040517f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f861253e82613efd565b549060ff6020818416151592838152019260081c1682525f1461292d579061259763773594006001600160401b039360ff81511660088111155f14612916575061259161139b60ff6113a8935116614251565b346141a6565b60095482906001600160a01b03851615612908576001600160a01b0385165f908152600d6020526040902060040154829061ffff165b61ffff6125de6044358442166140d9565b91816125ec606435856140d9565b956125f78d886140d9565b985f604080519e8f9061260982613f18565b33825260018060a01b0316602082015201528c60603491015260808d01521660a08b01521660c089015260243560e08901525f6101008901521661012087015216610140850152166101608301526001600160401b03604435166101808301526001600160401b03606435166101a08301526001600160401b0383166101c08301526001600160401b0342166101e08301525f61020083015260018060a01b03166102208201525f6102408201525f610260820152835f52600460205260405f209060018060a01b038151166001600160601b0360a01b8354161782556001820160018060a01b036020830151166001600160601b0360a01b8254161790556002820160018060a01b036040830151166001600160601b0360a01b825416179055606081015160038301556080810151600483015561277a6005830161ffff60a08401511661ffff1982541617815561ffff60c08401511663ffff000082549160101b169063ffff00001916179055565b60e0810151600683015561010081015160078301556127f5600883016117d46001600160401b0361012085015116916001600160401b031992838254161781556117826001600160401b0361014087015116829067ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b610220810151600a830180546001600160a01b0319166001600160a01b0392909216919091179055610240810151956008871015610c6e5761286783600a6102607f26eba422e79370cb5e1b2e3334dcb8de7ce02260b605de540c0f0bae7ef704a0956118ee60209c848d9a01613fa1565b825f526004875260405f20946001600160401b03600560048801549701549561ffff612891613f70565b97604051995f8b52348d8c015260408b015281811660608b015260101c16608089015260243560a0890152816044351660c0890152816064351660e08901521661010087015260018060a01b031661012086015261016061014086015260018060a01b031693806119c93395610160830190613e42565b8161ffff8260101c166125cd565b6119ff915061139b6129279161423e565b346141d0565b50509050612939614c5e565b908115611a4e576001600160401b03826129656377359400670de0b6b3a7640000611a418b97346141a6565b612597565b5050612975826146cb565b15611a9e578382612508565b5062278d006001600160401b038316116124d3565b5062ed4e006001600160401b0360643516116124bd565b5062278d006001600160401b0360443516116124a4565b60405163162908e360e11b8152600490fd5b3461043a57602036600319011261043a576129ef613d72565b6129f7614515565b60018060a01b0380911690815f526006602052612a1a60ff60405f205416614124565b5f828152600660205260408120805460ff191690555b600780548083101561077457839085612a4885613e0d565b939054600394851b1c1614612a6257505050600101612a30565b90929194505f199384820191821161056857612a9093612a84610ad793613e0d565b9054911b1c1691613e0d565b81548015612abe570190612abb612aa683613e0d565b81549060018060a01b039060031b1b19169055565b55005b634e487b7160e01b5f52603160045260245ffd5b3461043a57602036600319011261043a57600435612aee6142e6565b612af6614ab6565b612afe614515565b805f52600460205260405f2090600a82019182549260ff8460a01c166008811015610c6e5760078114159081612c29575b5015612bf05760ff60a01b19909316600560a01b17909255600282015482546003840180546120949591936001600160a01b0393612b739291908516908516614384565b5416905490825f80516020614eac833981519152612bb0612b92613f70565b60405195865260056020870152608060408701526080860190613e42565b937f456d657267656e63792072656c6561736520647572696e672070617573650000602082870396876060850152601e81520152604033950190a461445d565b60405162461bcd60e51b8152602060048201526011602482015270105b1c9958591e48199a5b985b1a5e9959607a1b6044820152606490fd5b60049150141585612b2f565b3461043a57604036600319011261043a57612c4e613d88565b336001600160a01b03821603612c6a5761077490600435614659565b60405163334bd91960e11b8152600490fd5b3461043a57602036600319011261043a57600435612c986142e6565b612ca0614309565b805f52600460205260405f2090600a82019182549260ff8460a81c1615612dc55760ff8460a01c16936008851015610c6e57600185141580612dba575b612d9d576120949450612cf33361113c85613fc5565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b03939092612d2c9291908516908516614384565b5416905490825f80516020614eac833981519152612d4b612b92613f70565b93681959081c99599d5b9960ba1b604082870396876060850152602981527f4d757475616c2061677265656d656e74202d2073656c6c657220617070726f7660208201520152606033950190a461445d565b60405163f924664d60e01b8152604490610c5a6004820188613ec4565b506002851415612cdd565b60405162461bcd60e51b8152602060048201526011602482015270139bc81c99599d5b99081c995c5d595cdd607a1b6044820152606490fd5b3461043a57602036600319011261043a57612e17613d72565b612e1f614515565b6001600160a01b038181165f818152600d60205260409020600401549192909160101c6001600160401b03161561084657815f52600d60205260405f20926001936002600182015491015403612f5b575f845b612ece575b83612e81846145aa565b50805f52600d6020525f60046040822082815582600182015582600282015582600382015501557fb7a0f68489d6e103758c5896f7f700d18e1e9213039ef12daf1c81a88b1ce6715f80a2005b600e805480831015612f5457839086612ee685613dc4565b939054600394851b1c1614612f0057505050840184612e72565b909291939596505f199586820191821161056857612f3093612f24610ad793613dc4565b9054911b1c1691613dc4565b8054928315612abe57612e81930190612f4b612aa683613dc4565b55829184612e77565b5050612e77565b60405162461bcd60e51b815260206004820152601960248201527f41726269746572206861732070656e64696e67206361736573000000000000006044820152606490fd5b3461043a57602036600319011261043a57612094600435612fbf6142e6565b612fc7614309565b805f52600460205260405f20600a81018054612fe860ff8260a01c1661435e565b612ff533610bfc85613fc5565b61300e6001600160401b03600885015460401c16614372565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b039390926130479291908516908516614384565b5416905490825f80516020614eac833981519152613066612b92613f70565b93663232b634bb32b960c91b604082870396876060850152602781527f5375626d69742074696d656f7574202d2073656c6c657220646964206e6f742060208201520152606033950190a461445d565b3461043a57604036600319011261043a576107746004356130d5613d88565b90805f525f6020526130ed600160405f20015461456b565b614a40565b3461043a57602036600319011261043a576004355f525f6020526020600160405f200154604051908152f35b3461043a57608036600319011261043a5760043560805261313d613d9e565b60443560ff9081811680910361043a5760649283359261315b6142e6565b613163614309565b6080515f526020916004835260405f2091600a830196875491808360a01c169360089485811015610c6e576003810361364a5750811698878a018281116105685782849116036136385760018060a01b039384811633147f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9295f525f895260405f20335f5289528360405f205416811580613630575b611ebc5781613627575b506135d6575b9060059594939291600360a11b9060ff60a01b19161790558760038b896001600160401b038d848c01549b61324e6127109d8e9261ffff9e8f91015460101c16906141a6565b04936040519661325d88613ee2565b338852848801918252604088019081526060880192835260056080890195854216875260a08a019788526080515f52528a60405f2098511688549260ff60a01b905160a01b169160ff60a81b905160a81b169269ffffffffffffffffffff60b01b161717178655516001860155600285019151166001600160401b0319825416179055519101556004875260405f2095600387015495816133028260095416896141a6565b049660048901548015155f146134eb57633b9aca00670de0b6b3a764000061332a838c6141a6565b04106134d9575b505b5f92600a8a0194855460a01c169288841015610c6e5760068a94146134b4575b50506133636133689284926141da565b6141da565b956002880195858754165f52895260405f2080549182018092116105685755801515806134a8575b61348f575b505088810361340b5750806133ae945416915416614384565b335f52600d8152600260405f20016133c68154614987565b9055604051938452830152604082015233907f943c9c113661af578bbf2cbbfb531582e552aa48ab9002da7f837049687ecee8606060805192a361209460805161445d565b91939186810361342e57506001816134299554169201541690614384565b6133ae565b6134449061343c8a866141a6565b0480946141da565b9280613477575b508261345b575b505050506133ae565b60018161346e9554169201541690614384565b84808080613452565b61348990828654168385541690614384565b8861344b565b6134a191848087541691541690614384565b8980613395565b50838254161515613390565b613368939450906134d16133639260058d015460101c16846141a6565b049392613353565b6134e49198506141b9565b968d613331565b508560028a0154165f5260068a5260405f208a856040519261350c84613efd565b54818116151584528a1c169101818152908881116135bb575061353d61353761139b87845116614251565b8a6141a6565b905b633b9aca00809210613553575b5050613333565b858092939a50815116898111155f1461359b57506135769161139b915116614251565b9081156135875704965b8d8061354c565b634e487b7160e01b5f52601260045260245ffd5b6135aa925061139b915061423e565b808202918204036105685796613580565b6135ca61139b6135d09261423e565b8a6141d0565b9061353f565b6135df336146cb565b6132085760405162461bcd60e51b815260048101899052601c60248201527f4172626974657220686173206265656e2064656163746976617465640000000060448201528490fd5b9050158c613202565b5080156131f8565b60405163648564d360e01b8152600490fd5b60405163f924664d60e01b8152604491613668906004830190613ec4565b60036024820152fd5b3461043a57602036600319011261043a5761368a613d72565b613692614515565b6001600160a01b03811690811561084657815f52600d6020526001600160401b039081600460405f20015460101c166137c95761ffff918260095460101c1690421692604051906136e282613ee2565b60018252600460208301925f8452604081015f81526060820190605082526080830196875260a08301958987528a5f52600d60205261373460405f2094511515859060ff801983541691151516179055565b5160018401555160028301555160038201550192511669ffffffffffffffff00008354925160101b169169ffffffffffffffffffff191617179055600e5491600160401b831015610af5576137bf826137ba602094610ad78760017f3e9e037f5ae1b02104d124fd8f1783111cdf05db0bf2f9b784b2c8d3d866ebf49901600e55613dc4565b614995565b50604051908152a2005b6040516301934db960e01b8152600490fd5b3461043a575f36600319011261043a57602060405163773594008152f35b3461043a57604036600319011261043a57610774613815613d72565b61381d613d9e565b90613826614515565b6001600160a01b03165f818152600660205260409020546138499060ff16614124565b61386060ff83168015159081613881575b50614167565b5f52600660205260405f209061ff0082549160081b169061ff001916179055565b6012915011158561385a565b3461043a575f36600319011261043a576020601054604051908152f35b3461043a57602036600319011261043a576138c3613d72565b6138cb614515565b6001600160a01b0381165f818152600d602052604090206004015490919060101c6001600160401b03161561084657610774915f52600d60205260405f2060ff1981541690556145aa565b3461043a57602036600319011261043a5761392f613d72565b6139376140f4565b5060018060a01b03165f52600d60205260c060405f2060a06040519161395c83613ee2565b60ff815416151592838152600182015490602081019182526002830154926040820193845260046003820154916060840192835201549361ffff93608084019385871685526001600160401b03978891019660101c16865260405197885251602088015251604087015251606086015251166080840152511660a0820152f35b3461043a576139ea36613d5c565b6139f26142e6565b6139fa614309565b815f52600460205260405f2090600a820190613a1c60ff835460a01c1661435e565b613a293361113c85613fc5565b600883016001600160401b0390613a4582825460401c166144f2565b8215611b4a57613aef613ac786846040978760077f9e9c1d76a37a54669f8a78e425540f992456de1e11f2e7304bd440057eff2ddf9b01556009824216930190613aac8483908154906001600160401b0360c01b9060c01b169060018060c01b0316179055565b805460ff60a01b1916600160a11b17905554881c16906140d9565b825467ffffffffffffffff60801b191660809190911b67ffffffffffffffff60801b16178255565b5460801c1682519182526020820152a260018055005b3461043a57602036600319011261043a57612094600435613b246142e6565b805f52600460205260405f20600a81018054613b4560ff8260a01c1661435e565b613b5233610bfc85613fc5565b613b6b6001600160401b03600885015460401c16614372565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b03939092613ba49291908516908516614384565b5416905490825f80516020614eac833981519152613bc3612b92613f70565b937f4175746f2d726566756e64202d207375626d69742074696d656f757400000000602082870396876060850152601c81520152604033950190a461445d565b3461043a57602036600319011261043a57612094600435613c226142e6565b613c2a614309565b805f52600460205260405f20600a81018054613c4b60ff8260a01c16614327565b613c616001600160401b03600885015416614372565b60ff60a01b1916600560a01b1790556002810154815460038301805490936001600160a01b03939092613c9a9291908516908516614384565b5416905490825f80516020614eac833981519152613cb9612b92613f70565b93661c995cdc1bdb9960ca1b604082870396876060850152602781527f4163636570742074696d656f7574202d2073656c6c657220646964206e6f742060208201520152606033950190a461445d565b3461043a57602036600319011261043a576004359063ffffffff60e01b821680920361043a57602091637965db0b60e01b8114908115613d4b575b5015158152f35b6301ffc9a760e01b14905083613d44565b604090600319011261043a576004359060243590565b600435906001600160a01b038216820361043a57565b602435906001600160a01b038216820361043a57565b6024359060ff8216820361043a57565b608435906001600160401b038216820361043a57565b600e54811015613df957600e5f527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd01905f90565b634e487b7160e01b5f52603260045260245ffd5b600754811015613df95760075f527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68801905f90565b91908251928382525f5b848110613e6c575050825f602080949584010152601f8019910116010190565b602081830181015184830182015201613e4c565b60209060206040818301928281528551809452019301915f5b828110613ea7575050505090565b83516001600160a01b031685529381019392810192600101613e99565b906008821015610c6e5752565b6004359061ffff8216820361043a57565b60c081019081106001600160401b03821117610af557604052565b604081019081106001600160401b03821117610af557604052565b61028081019081106001600160401b03821117610af557604052565b608081019081106001600160401b03821117610af557604052565b90601f801991011681019081106001600160401b03821117610af557604052565b60405190613f7d82613efd565b60158252743cb13d1734b790169022b9b1b937bb902630bcb2b960591b6020830152565b906008811015610c6e57815460ff60a01b191660a09190911b60ff60a01b16179055565b90604051613fd281613f18565b8092600a60018060a01b03918281541684528260018201541660208501528260028201541660408501526003810154606085015260048101546080850152600581015461ffff9081811660a087015260101c1660c0850152600681015460e0850152600781015461010085015260088101546001600160401b0390818116610120870152818160401c16610140870152818160801c1661016087015260c01c6101808601526009820154908082166101a0870152808260401c166101c08701528160801c166101e086015260c01c610200850152015490811661022083015260ff8160a01c166008811015610c6e576102609160ff9161024085015260a81c161515910152565b9190916001600160401b038080941691160191821161056857565b6040519061410182613ee2565b5f60a0838281528260208201528260408201528260608201528260808201520152565b1561412b57565b60405162461bcd60e51b815260206004820152601460248201527314dd18589b1958dbda5b881b9bdd08199bdd5b9960621b6044820152606490fd5b1561416e57565b60405162461bcd60e51b815260206004820152601060248201526f496e76616c696420646563696d616c7360801b6044820152606490fd5b8181029291811591840414171561056857565b8015613587576b033b2e3c9fd0803ce80000000490565b8115613587570490565b9190820391821161056857565b156141ee57565b60405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606490fd5b6001600160401b03918216908216039190821161056857565b60ff6007199116019060ff821161056857565b60ff166008039060ff821161056857565b60ff16604d811161056857600a0a90565b1561427a57565b60405162461bcd60e51b815260206004820152601d60248201527f4465616c20616d6f756e742062656c6f7720243230206d696e696d756d0000006044820152606490fd5b6001600160a01b031680156142e0575f52600660205260ff60405f20541690565b50600190565b6002600154146142f7576002600155565b604051633ee5aeb560e01b8152600490fd5b60ff6002541661431557565b60405163d93c066560e01b8152600490fd5b6008811015610c6e57806143385750565b60405163f924664d60e01b8152604491614356906004830190613ec4565b5f6024820152fd5b6008811015610c6e5760018103610c3c5750565b6001600160401b031642111561232f57565b8215614458576001600160a01b0390811690816144235750505f80809381935af13d1561441e573d6001600160401b038111610af557604051906143d2601f8201601f191660200183613f4f565b81525f60203d92013e5b156143e357565b60405162461bcd60e51b8152602060048201526013602482015272115512081d1c985b9cd9995c8819985a5b1959606a1b6044820152606490fd5b6143dc565b92614456936040519363a9059cbb60e01b602086015216602484015260448301526044825261445182613f34565b614c9f565b565b505050565b5f5260046020525f600a60408220828155826001820155826002820155826003820155826004820155826005820155826006820155826007820155826008820155826009820155015560056020525f6003604082208281558260018201558260028201550155565b516001600160a01b03908116911603611ebc57565b602001516001600160a01b03908116911603611ebc57565b6001600160401b0316421161450357565b60405163387b2e5560e11b8152600490fd5b335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff161561454d57565b60405163e2517d3f60e01b81523360048201525f6024820152604490fd5b805f525f60205260405f20335f5260205260ff60405f2054161561458c5750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b6001600160a01b03165f8181527f89777fffb7045c97177d1161cd08d871365cb73d0b18f242761255a7718434cf60205260409020547fbb08418a67729a078f87bbc8d02a770929bb68f5bfdf134ae2ead6ed38e2f4ae919060ff161561465357815f525f60205260405f20815f5260205260405f2060ff19815416905533917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b50505f90565b90815f525f60205260405f209060018060a01b031690815f5260205260ff60405f2054165f1461465357815f525f60205260405f20815f5260205260405f2060ff19815416905533917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b6001600160a01b03165f908152600d60205260409020805460ff1690816146f0575090565b6001600160401b0391506004015460101c16151590565b9190915f526004918260205260405f20926003840154906127109261ffff846147348260095416866141a6565b0493838801548015155f1461487c57633b9aca00670de0b6b3a764000061475b83896141a6565b041061486a575b505b5f95600a89019260ff845460a01c1660088110156148575760061461482e575b50508561336386614794936141da565b94600288019460018060a01b0394858754165f52600860205260405f2090815492830180931161481b5750559596614456968492908015158061480f575b6147f6575b5050828216156147ec575050915b5416614384565b54169290506147e5565b61480891848089541691541690614384565b5f806147d7565b508382541615156147d2565b601190634e487b7160e01b5f525260245ffd5b869750614794929161484c6133639260058d015460101c16846141a6565b049750819250614784565b602187634e487b7160e01b5f525260245ffd5b6148759195506141b9565b935f614762565b5060018060a01b036002890154165f52600660205260405f20602060ff604051926148a684613efd565b548181161515845260081c1691019080825260088111155f1461496c57506148dd6148d761139b60ff845116614251565b876141a6565b905b633b9aca008092106148f3575b5050614764565b8051929650909160ff166008811161493a575061139b60ff614916925116614251565b9081156149275704935b5f806148ec565b601285634e487b7160e01b5f525260245ffd5b614948915061139b9061423e565b808202918204036149595793614920565b601184634e487b7160e01b5f525260245ffd5b61497b61139b6149819261423e565b876141d0565b906148df565b5f1981146105685760010190565b6001600160a01b03165f8181527f89777fffb7045c97177d1161cd08d871365cb73d0b18f242761255a7718434cf60205260409020547fbb08418a67729a078f87bbc8d02a770929bb68f5bfdf134ae2ead6ed38e2f4ae919060ff1661465357815f525f60205260405f20815f5260205260405f20600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b90815f525f60205260405f209060018060a01b031690815f5260205260ff60405f205416155f1461465357815f525f60205260405f20815f5260205260405f20600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b60ff6002541615614ac357565b604051638dfc202b60e01b8152600490fd5b600e545f91825b828110614c1657508215614bdc576040926040519060209160208101904282524460408201523360601b606082015260548152614b1881613f34565b51902006935f945f5b858110614b6d5760405162461bcd60e51b815260206004820152601860248201527f417262697465722073656c656374696f6e206661696c656400000000000000006044820152606490fd5b614b7681613dc4565b60018060a01b03809254600392831b1c165f52600d865260ff855f205416614ba3575b5050600101614b21565b8389939914614bc1575050614bb9600191614987565b96905f614b99565b9597935095505050614bd39150613dc4565b9054911b1c1690565b60405162461bcd60e51b81526020600482015260126024820152714e6f2061637469766520617262697465727360701b6044820152606490fd5b614c1f81613dc4565b60018060a01b0391549060031b1c165f52600d60205260ff60405f205416614c4a575b600101614adc565b92614c56600191614987565b939050614c42565b6011548015159081614c89575b50614c8357614c78614d1b565b806010554260115590565b60105490565b6102589150614c9890426141da565b105f614c6b565b905f602091828151910182855af115614cf9575f513d614cf057506001600160a01b0381163b155b614cce5750565b604051635274afe760e01b81526001600160a01b039091166004820152602490fd5b60011415614cc7565b6040513d5f823e3d90fd5b519069ffffffffffffffffffff8216820361043a57565b600f546001600160a01b03168015614e945760a060049160405192838092633fabe5a360e21b82525afa805f925f92614e3e575b50614d655760405162bfc92160e01b8152600490fd5b5f821315614df9578015614dbe57614d80610e1091426141da565b1015614d895790565b60405162461bcd60e51b815260206004820152600d60248201526c141c9a58d9481d1bdbc81bdb19609a1b6044820152606490fd5b60405162461bcd60e51b815260206004820152601360248201527250726963652064617461206973207374616c6560681b6044820152606490fd5b60405162461bcd60e51b815260206004820152601760248201527f496e76616c69642070726963652066726f6d20666565640000000000000000006044820152606490fd5b9250905060a0823d60a011614e8c575b81614e5b60a09383613f4f565b8101031261043a57614e6c82614d04565b506020820151614e83608060608501519401614d04565b5091905f614d4f565b3d9150614e4e565b506010548015614ea15790565b50643a352944009056fef2939da9344d885aca2f5f28e06d6a2f38fc3646202731fdc9730008761a3ed8a2646970667358221220454c7c2873ac8af6466d2717765fc219da4ffc7b215ca93ebd77e0bb37820f2a64736f6c63430008180033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000b5ec77fe37481ab79430f8bd9284741c50a5432100000000000000000000000031bc0e77a629be095b58fc428c84541aee811111

-----Decoded View---------------
Arg [0] : admin (address): 0xB5eC77Fe37481AB79430f8bd9284741c50A54321
Arg [1] : withdrawalAddr (address): 0x31BC0E77a629bE095B58Fc428c84541Aee811111

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000b5ec77fe37481ab79430f8bd9284741c50a54321
Arg [1] : 00000000000000000000000031bc0e77a629be095b58fc428c84541aee811111


Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.