ETH Price: $1,863.58 (-5.49%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Emergency Withdr...233410832025-09-11 16:42:11164 days ago1757608931IN
0x53e29bcA...b3B6CEb35
0 ETH0.000102271.63068137
Emergency Withdr...233410772025-09-11 16:40:59164 days ago1757608859IN
0x53e29bcA...b3B6CEb35
0 ETH0.000056381.69217366
Add Token Liquid...233363142025-09-11 0:42:23165 days ago1757551343IN
0x53e29bcA...b3B6CEb35
0 ETH0.00026171.1491139
Add Token Liquid...233360142025-09-10 23:42:11165 days ago1757547731IN
0x53e29bcA...b3B6CEb35
0 ETH0.000234391.16186472
Set Min Token Li...233360112025-09-10 23:41:35165 days ago1757547695IN
0x53e29bcA...b3B6CEb35
0 ETH0.000035591.17286465

Latest 16 internal transactions

Advanced mode:
Parent Transaction Hash Method Block
From
To
Transfer233410772025-09-11 16:40:59164 days ago1757608859
0x53e29bcA...b3B6CEb35
0.00022543 ETH
Distribute Pool ...233403932025-09-11 14:23:23164 days ago1757600603
0x53e29bcA...b3B6CEb35
0.00000017 ETH
Transfer233403932025-09-11 14:23:23164 days ago1757600603
0x53e29bcA...b3B6CEb35
0.00004961 ETH
Distribute Pool ...233403392025-09-11 14:12:35164 days ago1757599955
0x53e29bcA...b3B6CEb35
0.00000017 ETH
Transfer233403392025-09-11 14:12:35164 days ago1757599955
0x53e29bcA...b3B6CEb35
0.00004961 ETH
Distribute Pool ...233397502025-09-11 12:14:23164 days ago1757592863
0x53e29bcA...b3B6CEb35
0.00000017 ETH
Transfer233397502025-09-11 12:14:23164 days ago1757592863
0x53e29bcA...b3B6CEb35
0.00005023 ETH
Execute Buy Orde...233365172025-09-11 1:23:35165 days ago1757553815
0x53e29bcA...b3B6CEb35
0 ETH
Distribute Pool ...233362622025-09-11 0:31:47165 days ago1757550707
0x53e29bcA...b3B6CEb35
0.00000018 ETH
Transfer233362622025-09-11 0:31:47165 days ago1757550707
0x53e29bcA...b3B6CEb35
0.00005225 ETH
Distribute Pool ...233361512025-09-11 0:09:35165 days ago1757549375
0x53e29bcA...b3B6CEb35
0.00000018 ETH
Transfer233361512025-09-11 0:09:35165 days ago1757549375
0x53e29bcA...b3B6CEb35
0.00005232 ETH
Distribute Pool ...233361142025-09-11 0:02:11165 days ago1757548931
0x53e29bcA...b3B6CEb35
0.00000183 ETH
Transfer233361142025-09-11 0:02:11165 days ago1757548931
0x53e29bcA...b3B6CEb35
0.00052324 ETH
Add ETH Liquidit...233359992025-09-10 23:39:11165 days ago1757547551
0x53e29bcA...b3B6CEb35
0.001 ETH
0x60c08060233359992025-09-10 23:39:11165 days ago1757547551  Contract Creation0 ETH
Loading...
Loading
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

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x8621F2c9...9f88A3868
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
GradientMarketMakerPoolV2

Compiler Version
v0.8.26+commit.8a97fa7a

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 19 : GradientMarketMakerPoolV2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import {IGradientRegistry} from "./interfaces/IGradientRegistry.sol";
import {IGradientMarketMakerFactory} from "./interfaces/IGradientMarketMakerFactory.sol";
import {IUniswapV2Pair} from "./interfaces/IUniswapV2Pair.sol";
import {IUniswapV2Router02} from "./interfaces/IUniswapV2Router.sol";
import {IUniswapV2Factory} from "./interfaces/IUniswapV2Factory.sol";
import {IEventAggregator} from "./interfaces/IEventAggregator.sol";

// Custom errors
error InvalidTokenAddress();
error TokenBlocked();
error OnlyRewardDistributor();
error OnlyOrderbook();
error OnlyFactory();
error AmountZero();
error InsufficientShares();
error InsufficientPoolBalance();
error InsufficientWithdrawal();
error ETHTransferFailed();
error ETHTransferToOrderbookFailed();
error VersionAlreadyProcessed();
error VersionNotAvailable();
error InvalidMerkleProof();
error NoMerkleRootForUpdates();
error InvalidSharesPercentage();
error NoLiquidity();
error NoLiquidityToWithdraw();
error NoSharesToBurn();
error InsufficientSharesToBurn();
error NoRewards();
error NoETHLiquidityOrRewards();
error NoTokenLiquidityOrRewards();
error NoTokenProviderRewards();
error InvalidRecipient();
error InsufficientETHBalance();
error InsufficientTokenBalance();
error ETHWithdrawalFailed();
error TokenWithdrawalFailed();
error RouterNotSet();
error PairDoesNotExist();
error OverflowInETHRewardCalculation();
error OverflowInTokenProviderRewardCalculation();
error OverflowInTokenRewardCalculation();
error ETHAmountMismatch();
error InsufficientTokenLiquidity();
error InsufficientETHLiquidity();
error ETHAmountBelowMinimum();
error TokenAmountBelowMinimum();
error NoETHSent();
error NoLiquidityOrRewards();
error InvalidMinLiquidity();
error InvalidMinTokenLiquidity();

/**
 * @title GradientMarketMakerPoolV2
 * @notice Individual pool contract for a single token - deployed by factory
 * @dev Each token gets its own pool contract, similar to Uniswap V2 pairs
 * @dev Simplified version without epochs - single pool per token
 * @dev Uses merkle tree for efficient bulk position updates after trades
 */
contract GradientMarketMakerPoolV2 is Ownable, ReentrancyGuard {
    using SafeERC20 for IERC20;

    // Immutable token address - this pool is dedicated to one token
    IERC20 public immutable token;
    IGradientMarketMakerFactory public immutable factory;

    // Single pool state (no epochs)
    uint256 public totalETH;
    uint256 public totalTokens;

    // Separate structs for ETH and token providers
    struct ETHProvider {
        uint256 ethPosition;
        uint256 rewardDebt;
        uint256 pendingRewards;
        uint256 lastUpdateVersion;
    }

    struct TokenProvider {
        uint256 tokenPosition;
        uint256 rewardDebt;
        uint256 pendingRewards;
        uint256 lastUpdateVersion;
    }

    // Separate mappings for each provider type
    mapping(address => ETHProvider) public ethProviders;
    mapping(address => TokenProvider) public tokenProviders;

    // Reward tracking - separate ETH pools for each provider type
    uint256 public accRewardPerShare; // For ETH providers (ETH rewards)
    uint256 public accTokenRewardPerShare; // For ETH providers (token rewards)
    uint256 public rewardBalance; // ETH rewards for ETH providers
    uint256 public tokenProviderRewardBalance; // ETH rewards for token providers

    uint256 public constant SCALE = 1e18;

    // Token decimals for proper reward calculations
    uint8 public tokenDecimals;

    // Configurable minimum liquidity requirements
    uint256 public minLiquidity = 1e15; // 0.001 ETH minimum (default)
    uint256 public minTokenLiquidity = 1e15; // 0.001 tokens minimum (default)

    // Track totals for this specific token pool
    uint256 public totalEthAdded; // Total ETH added to this pool
    uint256 public totalEthRemoved; // Total ETH removed from this pool
    uint256 public totalTokensAdded; // Total tokens added to this pool
    uint256 public totalTokensRemoved; // Total tokens removed from this pool

    // Uniswap pair address
    address public uniswapPair;

    // Merkle root for LP share updates
    bytes32 public merkleRoot;
    uint256 public currentVersion;
    mapping(uint256 => bytes32) public versionMerkleRoots;

    // Events
    event ETHLiquidityDeposited(
        address indexed user,
        address token,
        uint256 ethAmount
    );

    event TokenLiquidityDeposited(
        address indexed user,
        address token,
        uint256 tokenAmount
    );

    event ETHLiquidityWithdrawn(
        address indexed user,
        address token,
        uint256 ethAmount
    );

    event TokenLiquidityWithdrawn(
        address indexed user,
        address token,
        uint256 tokenAmount
    );

    event PoolFeeDistributed(
        address indexed from,
        uint256 amount,
        address token
    );

    event TokenFeeDistributed(
        address indexed from,
        uint256 amount,
        address token
    );

    event FeeClaimed(address indexed user, uint256 amount, address token);

    event PoolBalanceUpdated(
        address indexed token,
        uint256 newTotalEth,
        uint256 newTotalTokens
    );

    event MinLiquidityUpdated(uint256 newMinLiquidity);
    event MinTokenLiquidityUpdated(uint256 newMinTokenLiquidity);

    event MerkleRootUpdated(uint256 indexed version, bytes32 merkleRoot);
    event MerkleRootUpdateSkipped(uint256 indexed version, string reason);
    event UserPositionUpdated(
        address indexed user,
        uint256 indexed version,
        uint256 newETHPosition,
        uint256 newTokenPosition
    );

    modifier isNotBlocked() {
        if (getRegistry().blockedTokens(address(token))) revert TokenBlocked();
        _;
    }

    modifier onlyRewardDistributor() {
        if (!getRegistry().isRewardDistributor(msg.sender))
            revert OnlyRewardDistributor();
        _;
    }

    modifier onlyOrderbook() {
        if (msg.sender != getRegistry().orderbook()) revert OnlyOrderbook();
        _;
    }

    modifier onlyFactory() {
        if (msg.sender != address(factory)) revert OnlyFactory();
        _;
    }

    constructor(IERC20 _token, address _owner) Ownable(_owner) {
        if (address(_token) == address(0)) revert InvalidTokenAddress();
        if (_owner == address(0)) revert InvalidRecipient();

        token = _token;
        factory = IGradientMarketMakerFactory(msg.sender);

        // Initialize token decimals for proper reward calculations
        tokenDecimals = IERC20Metadata(address(_token)).decimals();
    }

    /**
     * @notice Receive ETH for reward distribution
     */
    receive() external payable {}

    // =============================== INTERNAL FUNCTIONS ===============================

    /**
     * @notice Get the registry address from the factory
     * @return registryAddress Address of the GradientRegistry
     */
    function getRegistry() public view returns (IGradientRegistry) {
        return IGradientRegistry(factory.getRegistry());
    }

    /**
     * @notice Get the event aggregator address from the factory
     * @return eventAggregatorAddress Address of the EventAggregator
     */
    function getEventAggregator() public view returns (IEventAggregator) {
        return IEventAggregator(factory.getEventAggregator());
    }

    /**
     * @notice Updates ETH pool rewards before modifying state
     * @param ethAmount Amount of ETH to distribute as rewards to ETH providers
     */
    function _updatePoolRewards(uint256 ethAmount) internal {
        if (ethAmount == 0) revert AmountZero();

        // Distribute ETH rewards to ETH providers only
        if (totalETH > 0) {
            uint256 newAccRewardPerShare = accRewardPerShare +
                ((ethAmount * SCALE) / totalETH);
            if (newAccRewardPerShare < accRewardPerShare)
                revert OverflowInETHRewardCalculation();
            accRewardPerShare = newAccRewardPerShare;
        }

        // Track ETH rewards
        rewardBalance += ethAmount;
    }

    /**
     * @notice Update token rewards for token providers
     * @param tokenAmount Amount of tokens to distribute as rewards (in token decimals)
     */
    function _updateTokenRewards(uint256 tokenAmount) internal {
        if (tokenAmount == 0) revert AmountZero();

        // Distribute token rewards to token providers only
        if (totalTokens > 0) {
            // Normalize token amount to 18 decimals for consistent calculations
            uint256 normalizedTokenAmount = _normalizeTo18Decimals(tokenAmount);
            uint256 normalizedTotalTokens = _normalizeTo18Decimals(totalTokens);

            uint256 newAccTokenRewardPerShare = accTokenRewardPerShare +
                ((normalizedTokenAmount * SCALE) / normalizedTotalTokens);
            if (newAccTokenRewardPerShare < accTokenRewardPerShare)
                revert OverflowInTokenRewardCalculation();
            accTokenRewardPerShare = newAccTokenRewardPerShare;
        }

        // Track token rewards
        totalTokensRemoved += tokenAmount;
    }

    /**
     * @notice Normalize token amount to 18 decimals for consistent calculations
     * @param amount Amount in token decimals
     * @return uint256 Amount normalized to 18 decimals
     */
    function _normalizeTo18Decimals(
        uint256 amount
    ) internal view returns (uint256) {
        if (tokenDecimals == 18) {
            return amount;
        } else if (tokenDecimals < 18) {
            return amount * (10 ** (18 - tokenDecimals));
        } else {
            return amount / (10 ** (tokenDecimals - 18));
        }
    }

    /**
     * @notice Denormalize from 18 decimals to token decimals
     * @param amount Amount in 18 decimals
     * @return uint256 Amount in token decimals
     */
    function _denormalizeFrom18Decimals(
        uint256 amount
    ) internal view returns (uint256) {
        if (tokenDecimals == 18) {
            return amount;
        } else if (tokenDecimals < 18) {
            return amount / (10 ** (18 - tokenDecimals));
        } else {
            return amount * (10 ** (tokenDecimals - 18));
        }
    }

    /**
     * @notice Update merkle root after trade execution
     * @param newMerkleRoot New merkle root to set
     */
    function _updateMerkleRootAfterTrade(bytes32 newMerkleRoot) internal {
        if (newMerkleRoot != bytes32(0)) {
            currentVersion++;
            merkleRoot = newMerkleRoot;
            versionMerkleRoots[currentVersion] = newMerkleRoot;

            // Emit to EventAggregator instead of local event
            getEventAggregator().emitMerkleRootUpdated(
                currentVersion,
                newMerkleRoot
            );

            emit MerkleRootUpdated(currentVersion, newMerkleRoot);
        }
    }

    /**
     * @notice Verify merkle proof for user position update
     * @param user User address
     * @param proof Merkle proof
     * @param newETHPosition New ETH position (actual ETH amount)
     * @param newTokenPosition New token position (actual token amount)
     * @param ethRewardsToAdd Off-chain calculated total ETH rewards
     * @param tokenRewardsToAdd Off-chain calculated total token provider rewards
     * @return isValid Whether the proof is valid
     */
    function _verifyMerkleProof(
        address user,
        bytes32[] calldata proof,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethRewardsToAdd,
        uint256 tokenRewardsToAdd
    ) internal view returns (bool isValid) {
        bytes32 leaf = keccak256(
            abi.encodePacked(
                user,
                newETHPosition,
                newTokenPosition,
                ethRewardsToAdd,
                tokenRewardsToAdd
            )
        );

        // Special handling for single provider case
        if (proof.length == 0) {
            // For single provider, verify that the leaf equals the merkle root
            return leaf == merkleRoot;
        }

        // For multiple providers, use standard merkle proof verification
        return MerkleProof.verify(proof, merkleRoot, leaf);
    }

    /**
     * @notice Update ETH provider position using merkle proof
     * @param user User address
     * @param newETHPosition New ETH position (actual ETH amount)
     */
    function _updateETHProviderPosition(
        address user,
        uint256 newETHPosition,
        uint256 totalRewards
    ) internal {
        ethProviders[user].pendingRewards = totalRewards;

        // Update user's last update version for ETH provider
        ethProviders[user].lastUpdateVersion = currentVersion;

        // Update ETH provider position
        ethProviders[user].ethPosition = newETHPosition;

        // Update reward debt for the new position to ensure accurate future reward calculations
        ethProviders[user].rewardDebt =
            (newETHPosition * accRewardPerShare) /
            SCALE;
    }

    /**
     * @notice Update token provider position using merkle proof
     * @param user User address
     * @param newTokenPosition New token position (actual token amount)
     */
    function _updateTokenProviderPosition(
        address user,
        uint256 newTokenPosition,
        uint256 totalRewards
    ) internal {
        tokenProviders[user].pendingRewards = totalRewards;

        // Update user's last update version for token provider
        tokenProviders[user].lastUpdateVersion = currentVersion;

        // Update token provider position
        tokenProviders[user].tokenPosition = newTokenPosition;

        // Update reward debt for the new position to ensure accurate future reward calculations
        uint256 normalizedTokenPosition = _normalizeTo18Decimals(
            newTokenPosition
        );
        tokenProviders[user].rewardDebt =
            (normalizedTokenPosition * accTokenRewardPerShare) /
            SCALE;
    }

    /**
     * @notice Update both ETH and token provider positions using merkle proof
     * @param user User address
     * @param newETHPosition New ETH position (actual ETH amount)
     * @param newTokenPosition New token position (actual token amount)
     */
    function _updateUserPosition(
        address user,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethTotalRewards,
        uint256 tokenTotalRewards
    ) internal {
        // Update both provider positions
        _updateETHProviderPosition(user, newETHPosition, ethTotalRewards);
        _updateTokenProviderPosition(user, newTokenPosition, tokenTotalRewards);

        // Emit event for position update
        emit UserPositionUpdated(
            user,
            currentVersion,
            newETHPosition,
            newTokenPosition
        );
    }

    // =============================== INTERNAL HELPER FUNCTIONS ===============================

    /**
     * @notice Check if user needs position update for either asset type
     * @param user User address to check
     * @return needsUpdate True if user needs position update
     */
    function _needsPositionUpdate(address user) internal view returns (bool) {
        return
            (ethProviders[user].ethPosition > 0 &&
                ethProviders[user].lastUpdateVersion < currentVersion) ||
            (tokenProviders[user].tokenPosition > 0 &&
                tokenProviders[user].lastUpdateVersion < currentVersion) ||
            // Also check if user has pending rewards that need position update
            (ethProviders[user].pendingRewards > 0 &&
                ethProviders[user].lastUpdateVersion < currentVersion) ||
            (tokenProviders[user].pendingRewards > 0 &&
                tokenProviders[user].lastUpdateVersion < currentVersion);
    }

    // =============================== PUBLIC FUNCTIONS ===============================

    /**
     * @notice Add ETH liquidity to the pool (internal function)
     * @param user User address to add liquidity for
     * @param ethAmount Amount of ETH to deposit
     */
    function _addETHLiquidity(address user, uint256 ethAmount) internal {
        // Initialize Uniswap pair if not set
        if (uniswapPair == address(0)) {
            uniswapPair = getPairAddress();
        }
        if (uniswapPair == address(0)) revert PairDoesNotExist();

        // Calculate pending rewards before update
        if (ethProviders[user].ethPosition > 0) {
            uint256 pendingReward = (ethProviders[user].ethPosition *
                accRewardPerShare) /
                SCALE -
                ethProviders[user].rewardDebt;
            ethProviders[user].pendingRewards += pendingReward;
        }

        ethProviders[user].ethPosition += ethAmount;

        // Initialize lastUpdateVersion for first-time liquidity providers
        if (ethProviders[user].lastUpdateVersion == 0) {
            ethProviders[user].lastUpdateVersion = currentVersion;
        }

        // Update reward debt
        ethProviders[user].rewardDebt =
            (ethProviders[user].ethPosition * accRewardPerShare) /
            SCALE;

        totalETH += ethAmount;
        totalEthAdded += ethAmount;

        // Emit to EventAggregator
        getEventAggregator().emitLiquidityEvent(
            user,
            address(token),
            0, // ETH_ADD
            ethAmount
        );

        // Emit local event
        emit ETHLiquidityDeposited(user, address(token), ethAmount);
    }

    /**
     * @notice Add token liquidity to the pool (internal function)
     * @param user User address to add liquidity for
     * @param tokenAmount Amount of tokens to deposit
     */
    function _addTokenLiquidity(address user, uint256 tokenAmount) internal {
        // Initialize Uniswap pair if not set
        if (uniswapPair == address(0)) {
            uniswapPair = getPairAddress();
        }
        if (uniswapPair == address(0)) revert PairDoesNotExist();

        // Transfer tokens from user
        token.safeTransferFrom(msg.sender, address(this), tokenAmount);

        // Calculate pending rewards before update
        if (tokenProviders[user].tokenPosition > 0) {
            uint256 pendingReward = (tokenProviders[user].tokenPosition *
                accTokenRewardPerShare) /
                SCALE -
                tokenProviders[user].rewardDebt;
            tokenProviders[user].pendingRewards += pendingReward;
        }

        tokenProviders[user].tokenPosition += tokenAmount;

        // Initialize lastUpdateVersion for first-time liquidity providers
        if (tokenProviders[user].lastUpdateVersion == 0) {
            tokenProviders[user].lastUpdateVersion = currentVersion;
        }

        // Update reward debt
        uint256 normalizedTokenPosition = _normalizeTo18Decimals(
            tokenProviders[user].tokenPosition
        );
        tokenProviders[user].rewardDebt =
            (normalizedTokenPosition * accTokenRewardPerShare) /
            SCALE;

        totalTokens += tokenAmount;
        totalTokensAdded += tokenAmount;

        // Emit to EventAggregator
        getEventAggregator().emitLiquidityEvent(
            user,
            address(token),
            2, // TOKEN_ADD
            tokenAmount
        );

        // Emit local event
        emit TokenLiquidityDeposited(user, address(token), tokenAmount);
    }

    /**
     * @notice Add ETH liquidity to the pool for a specific user
     * @param user User address to add liquidity for
     */
    function addETHLiquidityForUser(
        address user
    ) external payable isNotBlocked nonReentrant onlyFactory {
        if (msg.value < minLiquidity) revert ETHAmountBelowMinimum();
        if (user == address(0)) revert InvalidRecipient();
        _addETHLiquidity(user, msg.value);
    }

    /**
     * @notice Add token liquidity to the pool for a specific user
     * @param user User address to add liquidity for
     * @param tokenAmount Amount of tokens to deposit
     */
    function addTokenLiquidityForUser(
        address user,
        uint256 tokenAmount
    ) external isNotBlocked nonReentrant onlyFactory {
        if (tokenAmount < minTokenLiquidity) revert TokenAmountBelowMinimum();
        if (user == address(0)) revert InvalidRecipient();
        _addTokenLiquidity(user, tokenAmount);
    }

    /**
     * @notice Remove liquidity with optional position update
     * @param shares Percentage of pool to withdraw (in basis points, 10000 = 100%)
     * @param minEthAmount Minimum amount of ETH to receive
     * @param minTokenAmount Minimum amount of tokens to receive
     * @param proof Merkle proof for position update (required if user has pending updates)
     * @param newETHPosition New ETH position (required if proof provided)
     * @param newTokenPosition New token position (required if proof provided)
     */
    function removeLiquidityWithProof(
        uint256 shares,
        uint256 minEthAmount,
        uint256 minTokenAmount,
        bytes32[] calldata proof,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethRewardsToAdd,
        uint256 tokenRewardsToAdd
    ) external isNotBlocked nonReentrant {
        if (shares <= 0 || shares > 10000) revert InvalidSharesPercentage();

        // Check if user needs position update for either asset type - only if they have existing liquidity
        bool needsUpdate = _needsPositionUpdate(msg.sender);

        if (needsUpdate) {
            // Proof is required - validate parameters
            if (merkleRoot == bytes32(0)) revert NoMerkleRootForUpdates();

            // Verify merkle proof
            if (
                !_verifyMerkleProof(
                    msg.sender,
                    proof,
                    newETHPosition,
                    newTokenPosition,
                    ethRewardsToAdd,
                    tokenRewardsToAdd
                )
            ) revert InvalidMerkleProof();

            // Update user position first
            _updateUserPosition(
                msg.sender,
                newETHPosition,
                newTokenPosition,
                ethRewardsToAdd,
                tokenRewardsToAdd
            );
        }

        // Then remove liquidity
        _removeETHLiquidity(shares, minEthAmount);
        _removeTokenLiquidity(shares, minTokenAmount);
    }

    /**
     * @notice Remove ETH liquidity with optional position update
     * @param shares Percentage of pool to withdraw (in basis points, 10000 = 100%)
     * @param minEthAmount Minimum amount of ETH to receive
     * @param proof Merkle proof for position update (required if user has pending updates)
     * @param newETHPosition New ETH position (required if proof provided)
     * @param newTokenPosition New token position (required if proof provided)
     */
    function removeETHLiquidityWithProof(
        uint256 shares,
        uint256 minEthAmount,
        bytes32[] calldata proof,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethRewardsToAdd,
        uint256 tokenRewardsToAdd
    ) external isNotBlocked nonReentrant {
        if (shares <= 0 || shares > 10000) revert InvalidSharesPercentage();

        // Check if user needs position update for either asset type - only if they have existing liquidity
        bool needsUpdate = _needsPositionUpdate(msg.sender);

        if (needsUpdate) {
            // Proof is required - validate parameters
            if (merkleRoot == bytes32(0)) revert NoMerkleRootForUpdates();

            // Verify merkle proof
            if (
                !_verifyMerkleProof(
                    msg.sender,
                    proof,
                    newETHPosition,
                    newTokenPosition,
                    ethRewardsToAdd,
                    tokenRewardsToAdd
                )
            ) revert InvalidMerkleProof();

            // Update user position first
            _updateUserPosition(
                msg.sender,
                newETHPosition,
                newTokenPosition,
                ethRewardsToAdd,
                tokenRewardsToAdd
            );
        }

        // Then remove ETH liquidity
        _removeETHLiquidity(shares, minEthAmount);
    }

    /**
     * @notice Remove token liquidity with optional position update
     * @param shares Percentage of pool to withdraw (in basis points, 10000 = 100%)
     * @param minTokenAmount Minimum amount of tokens to receive
     * @param proof Merkle proof for position update (required if user has pending updates)
     * @param newETHPosition New ETH position (required if proof provided)
     * @param newTokenPosition New token position (required if proof provided)
     */
    function removeTokenLiquidityWithProof(
        uint256 shares,
        uint256 minTokenAmount,
        bytes32[] calldata proof,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethRewardsToAdd,
        uint256 tokenRewardsToAdd
    ) external isNotBlocked nonReentrant {
        if (shares <= 0 || shares > 10000) revert InvalidSharesPercentage();

        // Check if user needs position update for either asset type - only if they have existing liquidity
        bool needsUpdate = _needsPositionUpdate(msg.sender);

        if (needsUpdate) {
            // Proof is required - validate parameters
            if (merkleRoot == bytes32(0)) revert NoMerkleRootForUpdates();

            // Verify merkle proof
            if (
                !_verifyMerkleProof(
                    msg.sender,
                    proof,
                    newETHPosition,
                    newTokenPosition,
                    ethRewardsToAdd,
                    tokenRewardsToAdd
                )
            ) revert InvalidMerkleProof();

            // Update user position first
            _updateUserPosition(
                msg.sender,
                newETHPosition,
                newTokenPosition,
                ethRewardsToAdd,
                tokenRewardsToAdd
            );
        }

        // Then remove token liquidity
        _removeTokenLiquidity(shares, minTokenAmount);
    }

    // =============================== REMOVAL FUNCTIONS ===============================

    /**
     * @notice Remove ETH liquidity from the pool
     * @param shares Percentage of pool to withdraw (in basis points, 10000 = 100%)
     * @param minEthAmount Minimum amount of ETH to receive
     */
    function _removeETHLiquidity(
        uint256 shares,
        uint256 minEthAmount
    ) internal {
        if (totalETH == 0) revert NoLiquidity();
        if (ethProviders[msg.sender].ethPosition == 0)
            revert NoLiquidityToWithdraw();

        // Calculate pending rewards before withdrawing
        uint256 pendingReward = (ethProviders[msg.sender].ethPosition *
            accRewardPerShare) /
            SCALE -
            ethProviders[msg.sender].rewardDebt;
        ethProviders[msg.sender].pendingRewards += pendingReward;

        // Calculate amount to withdraw based on withdrawal percentage
        uint256 amountToWithdraw = (ethProviders[msg.sender].ethPosition *
            shares) / 10000;
        if (amountToWithdraw == 0) revert NoSharesToBurn();

        // Ensure we don't withdraw more than the user actually has (prevent underflow)
        if (amountToWithdraw > ethProviders[msg.sender].ethPosition) {
            amountToWithdraw = ethProviders[msg.sender].ethPosition;
        }
        if (amountToWithdraw > totalETH) revert InsufficientPoolBalance();

        // Update balances
        ethProviders[msg.sender].ethPosition -= amountToWithdraw;

        // Update reward debt
        ethProviders[msg.sender].rewardDebt =
            (ethProviders[msg.sender].ethPosition * accRewardPerShare) /
            SCALE;

        totalETH -= amountToWithdraw;
        totalEthRemoved += amountToWithdraw;

        // Transfer ETH back to user
        if (amountToWithdraw < minEthAmount) revert InsufficientWithdrawal();
        (bool success, ) = payable(msg.sender).call{value: amountToWithdraw}(
            ""
        );
        if (!success) revert ETHTransferFailed();

        // Emit to EventAggregator instead of local event
        getEventAggregator().emitLiquidityEvent(
            msg.sender,
            address(token),
            1, // ETH_REMOVE
            amountToWithdraw
        );

        emit ETHLiquidityWithdrawn(
            msg.sender,
            address(token),
            amountToWithdraw
        );
    }

    /**
     * @notice Remove token liquidity from the pool
     * @param shares Percentage of pool to withdraw (in basis points, 10000 = 100%)
     * @param minTokenAmount Minimum amount of tokens to receive
     */
    function _removeTokenLiquidity(
        uint256 shares,
        uint256 minTokenAmount
    ) internal {
        if (totalTokens == 0) revert NoLiquidity();
        if (tokenProviders[msg.sender].tokenPosition == 0)
            revert NoLiquidityToWithdraw();

        // Calculate pending rewards before withdrawing
        uint256 pendingReward = (tokenProviders[msg.sender].tokenPosition *
            accTokenRewardPerShare) /
            SCALE -
            tokenProviders[msg.sender].rewardDebt;
        tokenProviders[msg.sender].pendingRewards += pendingReward;

        // Calculate amount to withdraw based on withdrawal percentage
        uint256 amountToWithdraw = (tokenProviders[msg.sender].tokenPosition *
            shares) / 10000;
        if (amountToWithdraw == 0) revert NoSharesToBurn();

        // Ensure we don't withdraw more than the user actually has (prevent underflow)
        if (amountToWithdraw > tokenProviders[msg.sender].tokenPosition) {
            amountToWithdraw = tokenProviders[msg.sender].tokenPosition;
        }

        if (amountToWithdraw > totalTokens) revert InsufficientPoolBalance();

        // Update balances
        tokenProviders[msg.sender].tokenPosition -= amountToWithdraw;

        // Update reward debt
        tokenProviders[msg.sender].rewardDebt =
            (tokenProviders[msg.sender].tokenPosition *
                accTokenRewardPerShare) /
            SCALE;

        totalTokens -= amountToWithdraw;
        totalTokensRemoved += amountToWithdraw;

        // Transfer tokens back to user
        if (amountToWithdraw < minTokenAmount) revert InsufficientWithdrawal();
        if (amountToWithdraw > 0) {
            token.safeTransfer(msg.sender, amountToWithdraw);
        }

        // Emit to EventAggregator instead of local event
        getEventAggregator().emitLiquidityEvent(
            msg.sender,
            address(token),
            3, // TOKEN_REMOVE
            amountToWithdraw
        );

        emit TokenLiquidityWithdrawn(
            msg.sender,
            address(token),
            amountToWithdraw
        );
    }

    // =============================== ORDER EXECUTION FUNCTIONS ===============================

    /**
     * @notice Execute buy order - Orderbook sends ETH, receives tokens
     * @param ethAmount Amount of ETH sent by orderbook
     * @param tokenAmount Amount of tokens to send to orderbook
     * @param newMerkleRoot New merkle root to update after trade
     */
    function executeBuyOrder(
        uint256 ethAmount,
        uint256 tokenAmount,
        bytes32 newMerkleRoot
    ) external payable isNotBlocked onlyOrderbook {
        _executeBuyOrder(ethAmount, tokenAmount, newMerkleRoot);
    }

    /**
     * @notice Internal function to execute buy order
     * @param ethAmount Amount of ETH sent by orderbook
     * @param tokenAmount Amount of tokens to send to orderbook
     * @param newMerkleRoot New merkle root to update after trade
     */
    function _executeBuyOrder(
        uint256 ethAmount,
        uint256 tokenAmount,
        bytes32 newMerkleRoot
    ) internal {
        if (ethAmount == 0) revert AmountZero();
        if (tokenAmount == 0) revert AmountZero();
        if (msg.value != ethAmount) revert ETHAmountMismatch();

        if (totalTokens < tokenAmount) revert InsufficientTokenLiquidity();

        // Pool provides tokens to orderbook
        totalTokens -= tokenAmount;
        totalTokensRemoved += tokenAmount;
        totalETH += msg.value; // Update totalETH with incoming ETH from orderbook
        totalEthAdded += msg.value;

        // Transfer tokens to orderbook
        if (tokenAmount > 0) {
            token.safeTransfer(msg.sender, tokenAmount);
        }

        // Update merkle root if provided
        _updateMerkleRootAfterTrade(newMerkleRoot);

        // Emit trade event to EventAggregator
        getEventAggregator().emitTradeExecuted(
            msg.sender, // orderbook address
            0, // BUY trade
            ethAmount,
            tokenAmount
        );

        emit PoolBalanceUpdated(address(token), totalETH, totalTokens);
    }

    /**
     * @notice Execute sell order - Orderbook sends tokens, receives ETH
     * @param ethAmount Amount of ETH to send to orderbook
     * @param tokenAmount Amount of tokens sent by orderbook
     * @param newMerkleRoot New merkle root to update after trade
     */
    function executeSellOrder(
        uint256 ethAmount,
        uint256 tokenAmount,
        bytes32 newMerkleRoot
    ) external isNotBlocked onlyOrderbook {
        _executeSellOrder(ethAmount, tokenAmount, newMerkleRoot);
    }

    /**
     * @notice Internal function to execute sell order
     * @param ethAmount Amount of ETH to send to orderbook
     * @param tokenAmount Amount of tokens sent by orderbook
     * @param newMerkleRoot New merkle root to update after trade
     */
    function _executeSellOrder(
        uint256 ethAmount,
        uint256 tokenAmount,
        bytes32 newMerkleRoot
    ) internal {
        if (ethAmount == 0) revert AmountZero();
        if (tokenAmount == 0) revert AmountZero();

        if (totalETH < ethAmount) revert InsufficientETHLiquidity();

        // Transfer tokens from orderbook to market maker pool
        token.safeTransferFrom(msg.sender, address(this), tokenAmount);

        // Pool provides ETH to orderbook
        totalETH -= ethAmount;
        totalEthRemoved += ethAmount;
        totalTokens += tokenAmount;
        totalTokensAdded += tokenAmount;

        // Transfer ETH to orderbook
        (bool success, ) = payable(msg.sender).call{value: ethAmount}("");
        if (!success) revert ETHTransferToOrderbookFailed();

        // Update merkle root if provided
        _updateMerkleRootAfterTrade(newMerkleRoot);

        // Emit trade event to EventAggregator
        getEventAggregator().emitTradeExecuted(
            msg.sender, // orderbook address
            1, // SELL trade
            ethAmount,
            tokenAmount
        );

        emit PoolBalanceUpdated(address(token), totalETH, totalTokens);
    }

    /**
     * @notice Update user position using merkle proof
     * @param version Version of the merkle root
     * @param proof Merkle proof for the user's new position
     * @param newETHPosition New ETH position (actual ETH amount)
     * @param newTokenPosition New token position (actual token amount)
     */
    function updateUserPosition(
        uint256 version,
        bytes32[] calldata proof,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethRewardsToAdd,
        uint256 tokenRewardsToAdd
    ) external nonReentrant {
        // Check if version is newer than the last update for either provider type
        if (
            version <= ethProviders[msg.sender].lastUpdateVersion ||
            version <= tokenProviders[msg.sender].lastUpdateVersion
        ) revert VersionAlreadyProcessed();
        if (version > currentVersion) revert VersionNotAvailable();

        // Verify merkle proof
        if (
            !_verifyMerkleProof(
                msg.sender,
                proof,
                newETHPosition,
                newTokenPosition,
                ethRewardsToAdd,
                tokenRewardsToAdd
            )
        ) revert InvalidMerkleProof();

        // Update user position
        _updateUserPosition(
            msg.sender,
            newETHPosition,
            newTokenPosition,
            ethRewardsToAdd,
            tokenRewardsToAdd
        );
    }

    // =============================== REWARD DISTRIBUTION FUNCTIONS ===============================

    /**
     * @notice Distributes fee distribution from orderbook to be distributed to market makers
     */
    function distributePoolFee() external payable onlyRewardDistributor {
        if (msg.value == 0) revert NoETHSent();
        totalEthAdded += msg.value;
        _updatePoolRewards(msg.value);

        emit PoolFeeDistributed(msg.sender, msg.value, address(token));
    }

    /**
     * @notice Distributes token fees to token providers only
     * @param tokenAmount Amount of tokens to distribute as fees
     */
    function distributeTokenFee(
        uint256 tokenAmount
    ) external onlyRewardDistributor {
        if (tokenAmount == 0) revert AmountZero();

        // Transfer tokens from orderbook to this contract
        IERC20(token).safeTransferFrom(msg.sender, address(this), tokenAmount);

        // Update token rewards using the same pattern as distributePoolFee
        totalTokensAdded += tokenAmount;
        _updateTokenRewards(tokenAmount);

        emit TokenFeeDistributed(msg.sender, tokenAmount, address(token));
    }

    // =============================== USER FUNCTIONS ===============================

    /**
     * @notice Add ETH liquidity to the pool with optional position update
     * @param proof Merkle proof for position update (required if user has pending updates)
     * @param newETHPosition New ETH position (required if proof provided)
     * @param newTokenPosition New token position (required if proof provided)
     */
    function addETHLiquidityWithProof(
        bytes32[] calldata proof,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethRewardsToAdd,
        uint256 tokenRewardsToAdd
    ) external payable isNotBlocked nonReentrant {
        if (msg.value < minLiquidity) revert ETHAmountBelowMinimum();

        // Check if user needs position update - only if they have existing liquidity
        if (_needsPositionUpdate(msg.sender)) {
            // Proof is required - validate parameters
            if (merkleRoot == bytes32(0)) revert NoMerkleRootForUpdates();

            // Verify merkle proof
            if (
                !_verifyMerkleProof(
                    msg.sender,
                    proof,
                    newETHPosition,
                    newTokenPosition,
                    ethRewardsToAdd,
                    tokenRewardsToAdd
                )
            ) revert InvalidMerkleProof();

            // Update user position first
            _updateUserPosition(
                msg.sender,
                newETHPosition,
                newTokenPosition,
                ethRewardsToAdd,
                tokenRewardsToAdd
            );
        }

        // Then add ETH liquidity
        _addETHLiquidity(msg.sender, msg.value);
    }

    /**
     * @notice Add token liquidity to the pool with optional position update
     * @param tokenAmount Amount of tokens to deposit
     * @param proof Merkle proof for position update (required if user has pending updates)
     * @param newETHPosition New ETH position (required if proof provided)
     * @param newTokenPosition New token position (required if proof provided)
     */
    function addTokenLiquidityWithProof(
        uint256 tokenAmount,
        bytes32[] calldata proof,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethRewardsToAdd,
        uint256 tokenRewardsToAdd
    ) external isNotBlocked nonReentrant {
        if (tokenAmount < minTokenLiquidity) revert TokenAmountBelowMinimum();

        // Check if user needs position update - only if they have existing liquidity
        if (_needsPositionUpdate(msg.sender)) {
            // Proof is required - validate parameters
            if (merkleRoot == bytes32(0)) revert NoMerkleRootForUpdates();

            // Verify merkle proof
            if (
                !_verifyMerkleProof(
                    msg.sender,
                    proof,
                    newETHPosition,
                    newTokenPosition,
                    ethRewardsToAdd,
                    tokenRewardsToAdd
                )
            ) revert InvalidMerkleProof();

            // Update user position first
            _updateUserPosition(
                msg.sender,
                newETHPosition,
                newTokenPosition,
                ethRewardsToAdd,
                tokenRewardsToAdd
            );
        }

        // Then add token liquidity
        _addTokenLiquidity(msg.sender, tokenAmount);
    }

    /**
     * @notice Add liquidity to the pool with optional position update
     * @param tokenAmount Amount of tokens to deposit
     * @param proof Merkle proof for position update (required if user has pending updates)
     * @param newETHPosition New ETH position (required if proof provided)
     * @param newTokenPosition New token position (required if proof provided)
     */
    function addLiquidityWithProof(
        uint256 tokenAmount,
        bytes32[] calldata proof,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethRewardsToAdd,
        uint256 tokenRewardsToAdd
    ) external payable isNotBlocked nonReentrant {
        if (msg.value < minLiquidity) revert ETHAmountBelowMinimum();
        if (tokenAmount < minTokenLiquidity) revert TokenAmountBelowMinimum();

        // Check if user needs position update for either asset type - only if they have existing liquidity
        bool needsUpdate = _needsPositionUpdate(msg.sender);

        if (needsUpdate) {
            // Proof is required - validate parameters
            if (merkleRoot == bytes32(0)) revert NoMerkleRootForUpdates();

            // Verify merkle proof
            if (
                !_verifyMerkleProof(
                    msg.sender,
                    proof,
                    newETHPosition,
                    newTokenPosition,
                    ethRewardsToAdd,
                    tokenRewardsToAdd
                )
            ) revert InvalidMerkleProof();

            // Update user position first
            _updateUserPosition(
                msg.sender,
                newETHPosition,
                newTokenPosition,
                ethRewardsToAdd,
                tokenRewardsToAdd
            );
        }

        // Then add liquidity
        _addETHLiquidity(msg.sender, msg.value);
        _addTokenLiquidity(msg.sender, tokenAmount);
    }

    /**
     * @notice Claim rewards with optional position update
     * @param proof Merkle proof for position update (required if user has pending updates)
     * @param newETHPosition New ETH position (required if proof provided)
     * @param newTokenPosition New token position (required if proof provided)
     */
    function claimRewardsWithProof(
        bytes32[] calldata proof,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethRewardsToAdd,
        uint256 tokenRewardsToAdd
    ) external nonReentrant {
        uint256 totalUserPosition = ethProviders[msg.sender].ethPosition +
            tokenProviders[msg.sender].tokenPosition;
        if (
            totalUserPosition == 0 &&
            ethProviders[msg.sender].pendingRewards == 0 &&
            tokenProviders[msg.sender].pendingRewards == 0
        ) revert NoLiquidityOrRewards();

        // Check if user needs position update for either asset type - only if they have existing liquidity
        bool needsUpdate = _needsPositionUpdate(msg.sender);

        if (needsUpdate) {
            // Proof is required - validate parameters
            if (merkleRoot == bytes32(0)) revert NoMerkleRootForUpdates();

            // Verify merkle proof
            if (
                !_verifyMerkleProof(
                    msg.sender,
                    proof,
                    newETHPosition,
                    newTokenPosition,
                    ethRewardsToAdd,
                    tokenRewardsToAdd
                )
            ) revert InvalidMerkleProof();

            // Update user position first
            _updateUserPosition(
                msg.sender,
                newETHPosition,
                newTokenPosition,
                ethRewardsToAdd,
                tokenRewardsToAdd
            );
        }

        // Calculate ETH rewards after position update (if any)
        uint256 ethRewards = 0;
        if (ethProviders[msg.sender].ethPosition > 0) {
            uint256 ethAccumulated = (ethProviders[msg.sender].ethPosition *
                accRewardPerShare) / SCALE;
            ethRewards = ethAccumulated - ethProviders[msg.sender].rewardDebt;
        }
        // Always add pending rewards
        ethRewards += ethProviders[msg.sender].pendingRewards;

        // Calculate token rewards from token positions after position update (if any)
        uint256 tokenProviderRewards = 0;
        if (tokenProviders[msg.sender].tokenPosition > 0) {
            uint256 normalizedTokenPosition = _normalizeTo18Decimals(
                tokenProviders[msg.sender].tokenPosition
            );
            uint256 tokenAccumulated = (normalizedTokenPosition *
                accTokenRewardPerShare) / SCALE;
            tokenProviderRewards =
                tokenAccumulated -
                tokenProviders[msg.sender].rewardDebt;
        }
        // Always add pending rewards
        tokenProviderRewards += tokenProviders[msg.sender].pendingRewards;

        uint256 totalRewards = ethRewards + tokenProviderRewards;
        if (totalRewards == 0) revert NoRewards();

        // Update reward debt for both asset types
        if (ethProviders[msg.sender].ethPosition > 0) {
            ethProviders[msg.sender].rewardDebt =
                (ethProviders[msg.sender].ethPosition * accRewardPerShare) /
                SCALE;
        }
        if (tokenProviders[msg.sender].tokenPosition > 0) {
            uint256 normalizedTokenPosition = _normalizeTo18Decimals(
                tokenProviders[msg.sender].tokenPosition
            );
            tokenProviders[msg.sender].rewardDebt =
                (normalizedTokenPosition * accTokenRewardPerShare) /
                SCALE;
        }

        // Clear pending rewards
        ethProviders[msg.sender].pendingRewards = 0;
        tokenProviders[msg.sender].pendingRewards = 0;

        // Transfer ETH rewards
        if (ethRewards > 0) {
            totalEthRemoved += ethRewards;
            (bool success, ) = payable(msg.sender).call{value: ethRewards}("");
            if (!success) revert ETHWithdrawalFailed();
        }

        // Transfer token rewards
        if (tokenProviderRewards > 0) {
            // Denormalize rewards from 18 decimals back to token decimals
            uint256 denormalizedRewards = _denormalizeFrom18Decimals(
                tokenProviderRewards
            );
            token.safeTransfer(msg.sender, denormalizedRewards);
        }

        // Emit events to EventAggregator
        if (ethRewards > 0) {
            getEventAggregator().emitETHRewardsClaimed(
                msg.sender,
                address(token),
                ethRewards
            );
        }
        if (tokenProviderRewards > 0) {
            uint256 denormalizedRewards = _denormalizeFrom18Decimals(
                tokenProviderRewards
            );
            getEventAggregator().emitTokenRewardsClaimed(
                msg.sender,
                address(token),
                denormalizedRewards
            );
        }

        emit FeeClaimed(msg.sender, totalRewards, address(token));
    }

    /**
     * @notice Claim only ETH rewards for ETH liquidity providers with optional position update
     * @param proof Merkle proof for position update (required if user has pending updates)
     * @param newETHPosition New ETH position (required if proof provided)
     * @param newTokenPosition New token position (required if proof provided)
     */
    function claimETHRewardsWithProof(
        bytes32[] calldata proof,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethRewardsToAdd,
        uint256 tokenRewardsToAdd
    ) external nonReentrant {
        if (ethProviders[msg.sender].pendingRewards == 0)
            revert NoETHLiquidityOrRewards();

        // Check if user needs position update for either asset type - only if they have existing liquidity
        bool needsUpdate = _needsPositionUpdate(msg.sender);

        if (needsUpdate) {
            // Proof is required - validate parameters
            if (merkleRoot == bytes32(0)) revert NoMerkleRootForUpdates();

            // Verify merkle proof
            if (
                !_verifyMerkleProof(
                    msg.sender,
                    proof,
                    newETHPosition,
                    newTokenPosition,
                    ethRewardsToAdd,
                    tokenRewardsToAdd
                )
            ) revert InvalidMerkleProof();

            // Update user position first
            _updateUserPosition(
                msg.sender,
                newETHPosition,
                newTokenPosition,
                ethRewardsToAdd,
                tokenRewardsToAdd
            );
        }

        // Calculate ETH rewards from ETH positions only
        uint256 ethRewards = 0;
        if (ethProviders[msg.sender].ethPosition > 0) {
            uint256 ethAccumulated = (ethProviders[msg.sender].ethPosition *
                accRewardPerShare) / SCALE;
            ethRewards = ethAccumulated - ethProviders[msg.sender].rewardDebt;
        }
        // Always add pending rewards
        ethRewards += ethProviders[msg.sender].pendingRewards;

        if (ethRewards == 0) revert NoRewards();

        // Update reward debt
        if (ethProviders[msg.sender].ethPosition > 0) {
            ethProviders[msg.sender].rewardDebt =
                (ethProviders[msg.sender].ethPosition * accRewardPerShare) /
                SCALE;
        }

        // Clear pending rewards
        ethProviders[msg.sender].pendingRewards = 0;

        // Transfer ETH rewards
        totalEthRemoved += ethRewards;
        (bool success, ) = payable(msg.sender).call{value: ethRewards}("");
        if (!success) revert ETHWithdrawalFailed();

        // Emit to EventAggregator instead of local event
        getEventAggregator().emitETHRewardsClaimed(
            msg.sender,
            address(token),
            ethRewards
        );

        emit FeeClaimed(msg.sender, ethRewards, address(token));
    }

    /**
     * @notice Claim only ETH rewards for token liquidity providers with optional position update
     * @param proof Merkle proof for position update (required if user has pending updates)
     * @param newETHPosition New ETH position (required if proof provided)
     * @param newTokenPosition New token position (required if proof provided)
     */
    function claimTokenRewardsWithProof(
        bytes32[] calldata proof,
        uint256 newETHPosition,
        uint256 newTokenPosition,
        uint256 ethRewardsToAdd,
        uint256 tokenRewardsToAdd
    ) external nonReentrant {
        if (tokenProviders[msg.sender].pendingRewards == 0)
            revert NoTokenLiquidityOrRewards();

        // Check if user needs position update for either asset type - only if they have existing liquidity
        bool needsUpdate = _needsPositionUpdate(msg.sender);

        if (needsUpdate) {
            // Proof is required - validate parameters
            if (merkleRoot == bytes32(0)) revert NoMerkleRootForUpdates();

            // Verify merkle proof
            if (
                !_verifyMerkleProof(
                    msg.sender,
                    proof,
                    newETHPosition,
                    newTokenPosition,
                    ethRewardsToAdd,
                    tokenRewardsToAdd
                )
            ) revert InvalidMerkleProof();

            // Update user position first
            _updateUserPosition(
                msg.sender,
                newETHPosition,
                newTokenPosition,
                ethRewardsToAdd,
                tokenRewardsToAdd
            );
        }

        // Calculate token rewards from token positions only
        uint256 tokenProviderRewards = 0;
        if (tokenProviders[msg.sender].tokenPosition > 0) {
            // Normalize token position to 18 decimals for consistent calculation
            uint256 normalizedTokenPosition = _normalizeTo18Decimals(
                tokenProviders[msg.sender].tokenPosition
            );
            uint256 tokenAccumulated = (normalizedTokenPosition *
                accTokenRewardPerShare) / SCALE;
            tokenProviderRewards =
                tokenAccumulated -
                tokenProviders[msg.sender].rewardDebt;
        }
        // Always add pending rewards
        tokenProviderRewards += tokenProviders[msg.sender].pendingRewards;

        if (tokenProviderRewards == 0) revert NoTokenProviderRewards();

        // Update reward debt
        if (tokenProviders[msg.sender].tokenPosition > 0) {
            uint256 normalizedTokenPosition = _normalizeTo18Decimals(
                tokenProviders[msg.sender].tokenPosition
            );
            tokenProviders[msg.sender].rewardDebt =
                (normalizedTokenPosition * accTokenRewardPerShare) /
                SCALE;
        }

        // Clear pending rewards
        tokenProviders[msg.sender].pendingRewards = 0;

        // Transfer token rewards
        uint256 denormalizedRewards = _denormalizeFrom18Decimals(
            tokenProviderRewards
        );
        totalTokensRemoved += denormalizedRewards;
        token.safeTransfer(msg.sender, denormalizedRewards);

        // Emit to EventAggregator instead of local event
        getEventAggregator().emitTokenRewardsClaimed(
            msg.sender,
            address(token),
            denormalizedRewards
        );

        emit FeeClaimed(msg.sender, denormalizedRewards, address(token));
    }

    // =============================== VIEW FUNCTIONS ===============================

    /**
     * @notice Get the Uniswap V2 pair address for this token
     * @return pairAddress Address of the Uniswap V2 pair
     */
    function getPairAddress() public view returns (address pairAddress) {
        address routerAddress = getRegistry().router();
        if (routerAddress == address(0)) revert RouterNotSet();

        IUniswapV2Router02 router = IUniswapV2Router02(routerAddress);
        address factoryAddress = router.factory();
        address weth = router.WETH();

        IUniswapV2Factory factoryContract = IUniswapV2Factory(factoryAddress);
        return factoryContract.getPair(address(token), weth);
    }

    /**
     * @notice Get the reserves for this token pair
     * @return reserveETH ETH reserve amount
     * @return reserveToken Token reserve amount
     */
    function getReserves()
        public
        view
        returns (uint256 reserveETH, uint256 reserveToken)
    {
        address pairAddress = getPairAddress();
        if (pairAddress == address(0)) revert PairDoesNotExist();

        (uint112 reserve0, uint112 reserve1, ) = IUniswapV2Pair(pairAddress)
            .getReserves();
        address token0 = IUniswapV2Pair(pairAddress).token0();

        (reserveETH, reserveToken) = token0 == address(token)
            ? (reserve1, reserve0)
            : (reserve0, reserve1);
    }

    // =============================== OWNER FUNCTIONS ===============================

    /**
     * @notice Set minimum ETH liquidity requirement
     * @param _minLiquidity New minimum ETH liquidity amount
     */
    function setMinLiquidity(uint256 _minLiquidity) external onlyOwner {
        if (_minLiquidity == 0) revert InvalidMinLiquidity();
        minLiquidity = _minLiquidity;
        emit MinLiquidityUpdated(_minLiquidity);
    }

    /**
     * @notice Set minimum token liquidity requirement
     * @param _minTokenLiquidity New minimum token liquidity amount
     */
    function setMinTokenLiquidity(
        uint256 _minTokenLiquidity
    ) external onlyOwner {
        if (_minTokenLiquidity == 0) revert InvalidMinTokenLiquidity();
        minTokenLiquidity = _minTokenLiquidity;
        emit MinTokenLiquidityUpdated(_minTokenLiquidity);
    }

    // =============================== EMERGENCY FUNCTIONS ===============================

    /**
     * @notice Emergency function to withdraw ETH from the contract
     * @param recipient Address to receive the ETH
     * @param amount Amount of ETH to withdraw (0 = withdraw all)
     * @dev Only callable by contract owner in emergency situations
     */
    function emergencyWithdrawETH(
        address payable recipient,
        uint256 amount
    ) external onlyOwner {
        if (recipient == address(0)) revert InvalidRecipient();
        if (address(this).balance == 0) revert InsufficientETHBalance();

        uint256 withdrawAmount = amount == 0 ? address(this).balance : amount;
        if (withdrawAmount > address(this).balance)
            revert InsufficientETHBalance();

        (bool success, ) = recipient.call{value: withdrawAmount}("");
        if (!success) revert ETHWithdrawalFailed();

        emit EmergencyWithdrawETH(recipient, withdrawAmount);
    }

    /**
     * @notice Emergency function to withdraw any ERC20 token from the contract
     * @param tokenAddress Address of the token to withdraw
     * @param recipient Address to receive the tokens
     * @param amount Amount of tokens to withdraw (0 = withdraw all)
     * @dev Only callable by contract owner in emergency situations
     */
    function emergencyWithdrawToken(
        address tokenAddress,
        address recipient,
        uint256 amount
    ) external onlyOwner {
        if (tokenAddress == address(0)) revert InvalidTokenAddress();
        if (recipient == address(0)) revert InvalidRecipient();

        IERC20 tokenContract = IERC20(tokenAddress);
        uint256 balance = tokenContract.balanceOf(address(this));
        if (balance == 0) revert InsufficientTokenBalance();

        uint256 withdrawAmount = amount == 0 ? balance : amount;
        if (withdrawAmount > balance) revert InsufficientTokenBalance();

        tokenContract.safeTransfer(recipient, withdrawAmount);

        emit EmergencyWithdrawToken(tokenAddress, recipient, withdrawAmount);
    }

    // Events for emergency withdrawals
    event EmergencyWithdrawETH(address indexed recipient, uint256 amount);
    event EmergencyWithdrawToken(
        address indexed token,
        address indexed recipient,
        uint256 amount
    );
}

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

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

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

pragma solidity ^0.8.20;

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);
}

File 4 of 19 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

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

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

pragma solidity ^0.8.20;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface for the optional metadata functions from the ERC-20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

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

pragma solidity ^0.8.20;

/**
 * @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) (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.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.3.0) (utils/cryptography/Hashes.sol)

pragma solidity ^0.8.20;

/**
 * @dev Library of standard hash functions.
 *
 * _Available since v5.1._
 */
library Hashes {
    /**
     * @dev Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs.
     *
     * NOTE: Equivalent to the `standardNodeHash` in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
     */
    function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32) {
        return a < b ? efficientKeccak256(a, b) : efficientKeccak256(b, a);
    }

    /**
     * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
     */
    function efficientKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32 value) {
        assembly ("memory-safe") {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MerkleProof.sol)
// This file was procedurally generated from scripts/generate/templates/MerkleProof.js.

pragma solidity ^0.8.20;

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

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The tree and the proofs can be generated using our
 * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
 * You will find a quickstart guide in the readme.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the Merkle tree could be reinterpreted as a leaf value.
 * OpenZeppelin's JavaScript library generates Merkle trees that are safe
 * against this attack out of the box.
 *
 * IMPORTANT: Consider memory side-effects when using custom hashing functions
 * that access memory in an unsafe way.
 *
 * NOTE: This library supports proof verification for merkle trees built using
 * custom _commutative_ hashing functions (i.e. `H(a, b) == H(b, a)`). Proving
 * leaf inclusion in trees built using non-commutative hashing functions requires
 * additional logic that is not supported by this library.
 */
library MerkleProof {
    /**
     *@dev The multiproof provided is not valid.
     */
    error MerkleProofInvalidMultiproof();

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     *
     * This version handles proofs in memory with the default hashing function.
     */
    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leaves & pre-images are assumed to be sorted.
     *
     * This version handles proofs in memory with the default hashing function.
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     *
     * This version handles proofs in memory with a custom hashing function.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bool) {
        return processProof(proof, leaf, hasher) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leaves & pre-images are assumed to be sorted.
     *
     * This version handles proofs in memory with a custom hashing function.
     */
    function processProof(
        bytes32[] memory proof,
        bytes32 leaf,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = hasher(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     *
     * This version handles proofs in calldata with the default hashing function.
     */
    function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leaves & pre-images are assumed to be sorted.
     *
     * This version handles proofs in calldata with the default hashing function.
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     *
     * This version handles proofs in calldata with a custom hashing function.
     */
    function verifyCalldata(
        bytes32[] calldata proof,
        bytes32 root,
        bytes32 leaf,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bool) {
        return processProofCalldata(proof, leaf, hasher) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leaves & pre-images are assumed to be sorted.
     *
     * This version handles proofs in calldata with a custom hashing function.
     */
    function processProofCalldata(
        bytes32[] calldata proof,
        bytes32 leaf,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = hasher(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in memory with the default hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProof}.
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * This version handles multiproofs in memory with the default hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
     * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
     * validating the leaves elsewhere.
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofFlagsLen = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proof.length != proofFlagsLen + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](proofFlagsLen);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < proofFlagsLen; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = Hashes.commutativeKeccak256(a, b);
        }

        if (proofFlagsLen > 0) {
            if (proofPos != proof.length) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[proofFlagsLen - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in memory with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProof}.
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bool) {
        return processMultiProof(proof, proofFlags, leaves, hasher) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * This version handles multiproofs in memory with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
     * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
     * validating the leaves elsewhere.
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofFlagsLen = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proof.length != proofFlagsLen + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](proofFlagsLen);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < proofFlagsLen; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = hasher(a, b);
        }

        if (proofFlagsLen > 0) {
            if (proofPos != proof.length) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[proofFlagsLen - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in calldata with the default hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProofCalldata}.
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * This version handles multiproofs in calldata with the default hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
     * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
     * validating the leaves elsewhere.
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofFlagsLen = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proof.length != proofFlagsLen + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](proofFlagsLen);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < proofFlagsLen; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = Hashes.commutativeKeccak256(a, b);
        }

        if (proofFlagsLen > 0) {
            if (proofPos != proof.length) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[proofFlagsLen - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in calldata with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProofCalldata}.
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves, hasher) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * This version handles multiproofs in calldata with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
     * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
     * validating the leaves elsewhere.
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofFlagsLen = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proof.length != proofFlagsLen + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](proofFlagsLen);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < proofFlagsLen; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = hasher(a, b);
        }

        if (proofFlagsLen > 0) {
            if (proofPos != proof.length) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[proofFlagsLen - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }
}

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

pragma solidity ^0.8.20;

/**
 * @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);
}

// 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
pragma solidity ^0.8.20;

interface IEventAggregator {
    // Event types
    function ETH_ADD() external view returns (uint8);

    function ETH_REMOVE() external view returns (uint8);

    function TOKEN_ADD() external view returns (uint8);

    function TOKEN_REMOVE() external view returns (uint8);

    function REWARDS_CLAIMED() external view returns (uint8);

    function TRADE_EXECUTED() external view returns (uint8);

    // Main functions
    function emitLiquidityEvent(
        address user,
        address token,
        uint8 eventType,
        uint256 amount
    ) external;

    function emitETHRewardsClaimed(
        address user,
        address token,
        uint256 amount
    ) external;

    function emitTokenRewardsClaimed(
        address user,
        address token,
        uint256 amount
    ) external;

    function emitTradeExecuted(
        address user,
        uint8 tradeType,
        uint256 ethAmount,
        uint256 tokenAmount
    ) external;

    function emitMerkleRootUpdated(
        uint256 version,
        bytes32 merkleRoot
    ) external;

    function emitPoolCreated(address token, address pool) external;

    // View functions
    function getEventTypeName(
        uint8 eventType
    ) external pure returns (string memory name);

    function getTradeTypeName(
        uint8 tradeType
    ) external pure returns (string memory name);
}

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

interface IGradientMarketMakerFactory {
    // Events
    event PoolCreated(
        address indexed token,
        address indexed pool,
        uint256 timestamp
    );

    // Pool management
    function createPool(address token) external returns (address pool);

    function createPoolWithLiquidity(
        address token,
        address initialLiquidityProvider,
        uint256 initialEthAmount,
        uint256 initialTokenAmount
    ) external payable returns (address pool);

    function getPool(address token) external view returns (address pool);

    function poolExists(address token) external view returns (bool);

    function getAllPools() external view returns (address[] memory);

    function getPoolCount() external view returns (uint256);

    // Pool info
    function pools(uint256 index) external view returns (address);

    function poolCount() external view returns (uint256);

    // Factory info
    function owner() external view returns (address);

    function getEventAggregator() external view returns (address);

    function setEventAggregator(address _eventAggregator) external;

    /**
     * @notice Get the registry address
     * @return registryAddress Address of the GradientRegistry
     */
    function getRegistry() external view returns (address);

    /**
     * @notice Check if a given address is a valid pool
     * @param poolAddress Address to check
     * @return isValid True if the address is a valid pool
     */
    function isValidPool(
        address poolAddress
    ) external view returns (bool isValid);
}

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

/**
 * @title IGradientRegistry
 * @notice Interface for the GradientRegistry contract
 */
interface IGradientRegistry {
    /**
     * @notice Set all main contract addresses at once
     * @param _marketMakerFactory Address of the MarketMakerFactory contract
     * @param _gradientToken Address of the Gradient token contract
     * @param _orderbook Address of the Orderbook contract
     * @param _fallbackExecutor Address of the FallbackExecutor contract
     * @param _router Address of the Uniswap V2 Router contract
     */
    function setMainContracts(
        address _marketMakerFactory,
        address _gradientToken,
        address _orderbook,
        address _fallbackExecutor,
        address _router
    ) external;

    /**
     * @notice Set an individual main contract address
     * @param contractName Name of the contract to update
     * @param newAddress New address for the contract
     */
    function setContractAddress(
        string calldata contractName,
        address newAddress
    ) external;

    /**
     * @notice Set an additional contract address using a key
     * @param key The key to identify the contract
     * @param contractAddress The address of the contract
     */
    function setAdditionalContract(
        bytes32 key,
        address contractAddress
    ) external;

    /**
     * @notice Set the block status of a token
     * @param token The address of the token to set the block status of
     * @param blocked Whether the token should be blocked
     */
    function setTokenBlockStatus(address token, bool blocked) external;

    /**
     * @notice Set a reward distributor address
     * @param rewardDistributor The address of the reward distributor to authorize
     */
    function setRewardDistributor(address rewardDistributor) external;

    /**
     * @notice Authorize or deauthorize a fulfiller
     * @param fulfiller The address of the fulfiller to authorize
     * @param status The status of the fulfiller
     */
    function authorizeFulfiller(address fulfiller, bool status) external;

    /**
     * @notice Check if an address is an authorized fulfiller
     * @param fulfiller The address to check
     * @return bool Whether the address is an authorized fulfiller
     */
    function isAuthorizedFulfiller(
        address fulfiller
    ) external view returns (bool);

    /**
     * @notice Get all main contract addresses
     * @return _marketMakerFactory Address of the MarketMakerFactory contract
     * @return _gradientToken Address of the Gradient token contract
     * @return _orderbook Address of the Orderbook contract
     * @return _fallbackExecutor Address of the FallbackExecutor contract
     * @return _router Address of the Uniswap V2 Router contract
     */
    function getAllMainContracts()
        external
        view
        returns (
            address _marketMakerFactory,
            address _gradientToken,
            address _orderbook,
            address _fallbackExecutor,
            address _router
        );

    // View functions for individual contract addresses
    function marketMakerFactory() external view returns (address);

    // Legacy function for backward compatibility (returns factory address)
    function marketMakerPool() external view returns (address);

    // New function to get pool for specific token
    function getMarketMakerPool(address token) external view returns (address);

    // New function to check if pool exists for token
    function poolExists(address token) external view returns (bool);

    function gradientToken() external view returns (address);

    function orderbook() external view returns (address);

    function fallbackExecutor() external view returns (address);

    function router() external view returns (address);

    // View functions for mappings
    function blockedTokens(address token) external view returns (bool);

    function isRewardDistributor(
        address rewardDistributor
    ) external view returns (bool);

    function authorizedFulfillers(
        address fulfiller
    ) external view returns (bool);
}

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

interface IUniswapV2Factory {
    event PairCreated(
        address indexed token0,
        address indexed token1,
        address pair,
        uint
    );

    function feeTo() external view returns (address);

    function feeToSetter() external view returns (address);

    function getPair(
        address tokenA,
        address tokenB
    ) external view returns (address pair);

    function allPairs(uint) external view returns (address pair);

    function allPairsLength() external view returns (uint);

    function createPair(
        address tokenA,
        address tokenB
    ) external returns (address pair);

    function setFeeTo(address) external;

    function setFeeToSetter(address) external;
}

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

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);

    function symbol() external pure returns (string memory);

    function decimals() external pure returns (uint8);

    function totalSupply() external view returns (uint);

    function balanceOf(address owner) external view returns (uint);

    function allowance(
        address owner,
        address spender
    ) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);

    function transfer(address to, uint value) external returns (bool);

    function transferFrom(
        address from,
        address to,
        uint value
    ) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);

    function PERMIT_TYPEHASH() external pure returns (bytes32);

    function nonces(address owner) external view returns (uint);

    function permit(
        address owner,
        address spender,
        uint value,
        uint deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(
        address indexed sender,
        uint amount0,
        uint amount1,
        address indexed to
    );
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);

    function factory() external view returns (address);

    function token0() external view returns (address);

    function token1() external view returns (address);

    function getReserves()
        external
        view
        returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);

    function price0CumulativeLast() external view returns (uint);

    function price1CumulativeLast() external view returns (uint);

    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);

    function burn(address to) external returns (uint amount0, uint amount1);

    function swap(
        uint amount0Out,
        uint amount1Out,
        address to,
        bytes calldata data
    ) external;

    function skim(address to) external;

    function sync() external;

    function initialize(address, address) external;
}

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

interface IUniswapV2Router01 {
    function factory() external pure returns (address);

    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);

    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    )
        external
        payable
        returns (uint amountToken, uint amountETH, uint liquidity);

    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);

    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);

    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint amountA, uint amountB);

    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint amountToken, uint amountETH);

    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);

    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);

    function swapExactETHForTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable returns (uint[] memory amounts);

    function swapTokensForExactETH(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);

    function swapExactTokensForETH(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);

    function swapETHForExactTokens(
        uint amountOut,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable returns (uint[] memory amounts);

    function quote(
        uint amountA,
        uint reserveA,
        uint reserveB
    ) external pure returns (uint amountB);

    function getAmountOut(
        uint amountIn,
        uint reserveIn,
        uint reserveOut
    ) external pure returns (uint amountOut);

    function getAmountIn(
        uint amountOut,
        uint reserveIn,
        uint reserveOut
    ) external pure returns (uint amountIn);

    function getAmountsOut(
        uint amountIn,
        address[] calldata path
    ) external view returns (uint[] memory amounts);

    function getAmountsIn(
        uint amountOut,
        address[] calldata path
    ) external view returns (uint[] memory amounts);
}

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);

    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;

    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;

    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AmountZero","type":"error"},{"inputs":[],"name":"ETHAmountBelowMinimum","type":"error"},{"inputs":[],"name":"ETHAmountMismatch","type":"error"},{"inputs":[],"name":"ETHTransferFailed","type":"error"},{"inputs":[],"name":"ETHTransferToOrderbookFailed","type":"error"},{"inputs":[],"name":"ETHWithdrawalFailed","type":"error"},{"inputs":[],"name":"InsufficientETHBalance","type":"error"},{"inputs":[],"name":"InsufficientETHLiquidity","type":"error"},{"inputs":[],"name":"InsufficientPoolBalance","type":"error"},{"inputs":[],"name":"InsufficientTokenBalance","type":"error"},{"inputs":[],"name":"InsufficientTokenLiquidity","type":"error"},{"inputs":[],"name":"InsufficientWithdrawal","type":"error"},{"inputs":[],"name":"InvalidMerkleProof","type":"error"},{"inputs":[],"name":"InvalidMinLiquidity","type":"error"},{"inputs":[],"name":"InvalidMinTokenLiquidity","type":"error"},{"inputs":[],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"InvalidSharesPercentage","type":"error"},{"inputs":[],"name":"InvalidTokenAddress","type":"error"},{"inputs":[],"name":"NoETHLiquidityOrRewards","type":"error"},{"inputs":[],"name":"NoETHSent","type":"error"},{"inputs":[],"name":"NoLiquidity","type":"error"},{"inputs":[],"name":"NoLiquidityOrRewards","type":"error"},{"inputs":[],"name":"NoLiquidityToWithdraw","type":"error"},{"inputs":[],"name":"NoMerkleRootForUpdates","type":"error"},{"inputs":[],"name":"NoRewards","type":"error"},{"inputs":[],"name":"NoSharesToBurn","type":"error"},{"inputs":[],"name":"NoTokenLiquidityOrRewards","type":"error"},{"inputs":[],"name":"NoTokenProviderRewards","type":"error"},{"inputs":[],"name":"OnlyFactory","type":"error"},{"inputs":[],"name":"OnlyOrderbook","type":"error"},{"inputs":[],"name":"OnlyRewardDistributor","type":"error"},{"inputs":[],"name":"OverflowInETHRewardCalculation","type":"error"},{"inputs":[],"name":"OverflowInTokenRewardCalculation","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"PairDoesNotExist","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"RouterNotSet","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"TokenAmountBelowMinimum","type":"error"},{"inputs":[],"name":"TokenBlocked","type":"error"},{"inputs":[],"name":"VersionAlreadyProcessed","type":"error"},{"inputs":[],"name":"VersionNotAvailable","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"ethAmount","type":"uint256"}],"name":"ETHLiquidityDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"ethAmount","type":"uint256"}],"name":"ETHLiquidityWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdrawETH","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":"EmergencyWithdrawToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"FeeClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"version","type":"uint256"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"MerkleRootUpdateSkipped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"version","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"name":"MerkleRootUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newMinLiquidity","type":"uint256"}],"name":"MinLiquidityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newMinTokenLiquidity","type":"uint256"}],"name":"MinTokenLiquidityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"newTotalEth","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalTokens","type":"uint256"}],"name":"PoolBalanceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"PoolFeeDistributed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"TokenFeeDistributed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"TokenLiquidityDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"TokenLiquidityWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"version","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newETHPosition","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTokenPosition","type":"uint256"}],"name":"UserPositionUpdated","type":"event"},{"inputs":[],"name":"SCALE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accRewardPerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accTokenRewardPerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"addETHLiquidityForUser","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"newETHPosition","type":"uint256"},{"internalType":"uint256","name":"newTokenPosition","type":"uint256"},{"internalType":"uint256","name":"ethRewardsToAdd","type":"uint256"},{"internalType":"uint256","name":"tokenRewardsToAdd","type":"uint256"}],"name":"addETHLiquidityWithProof","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"newETHPosition","type":"uint256"},{"internalType":"uint256","name":"newTokenPosition","type":"uint256"},{"internalType":"uint256","name":"ethRewardsToAdd","type":"uint256"},{"internalType":"uint256","name":"tokenRewardsToAdd","type":"uint256"}],"name":"addLiquidityWithProof","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"addTokenLiquidityForUser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"newETHPosition","type":"uint256"},{"internalType":"uint256","name":"newTokenPosition","type":"uint256"},{"internalType":"uint256","name":"ethRewardsToAdd","type":"uint256"},{"internalType":"uint256","name":"tokenRewardsToAdd","type":"uint256"}],"name":"addTokenLiquidityWithProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"newETHPosition","type":"uint256"},{"internalType":"uint256","name":"newTokenPosition","type":"uint256"},{"internalType":"uint256","name":"ethRewardsToAdd","type":"uint256"},{"internalType":"uint256","name":"tokenRewardsToAdd","type":"uint256"}],"name":"claimETHRewardsWithProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"newETHPosition","type":"uint256"},{"internalType":"uint256","name":"newTokenPosition","type":"uint256"},{"internalType":"uint256","name":"ethRewardsToAdd","type":"uint256"},{"internalType":"uint256","name":"tokenRewardsToAdd","type":"uint256"}],"name":"claimRewardsWithProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"newETHPosition","type":"uint256"},{"internalType":"uint256","name":"newTokenPosition","type":"uint256"},{"internalType":"uint256","name":"ethRewardsToAdd","type":"uint256"},{"internalType":"uint256","name":"tokenRewardsToAdd","type":"uint256"}],"name":"claimTokenRewardsWithProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributePoolFee","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"distributeTokenFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyWithdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyWithdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ethProviders","outputs":[{"internalType":"uint256","name":"ethPosition","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"},{"internalType":"uint256","name":"pendingRewards","type":"uint256"},{"internalType":"uint256","name":"lastUpdateVersion","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"bytes32","name":"newMerkleRoot","type":"bytes32"}],"name":"executeBuyOrder","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"bytes32","name":"newMerkleRoot","type":"bytes32"}],"name":"executeSellOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"contract IGradientMarketMakerFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getEventAggregator","outputs":[{"internalType":"contract IEventAggregator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPairAddress","outputs":[{"internalType":"address","name":"pairAddress","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRegistry","outputs":[{"internalType":"contract IGradientRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserves","outputs":[{"internalType":"uint256","name":"reserveETH","type":"uint256"},{"internalType":"uint256","name":"reserveToken","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minTokenLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"minEthAmount","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"newETHPosition","type":"uint256"},{"internalType":"uint256","name":"newTokenPosition","type":"uint256"},{"internalType":"uint256","name":"ethRewardsToAdd","type":"uint256"},{"internalType":"uint256","name":"tokenRewardsToAdd","type":"uint256"}],"name":"removeETHLiquidityWithProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"minEthAmount","type":"uint256"},{"internalType":"uint256","name":"minTokenAmount","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"newETHPosition","type":"uint256"},{"internalType":"uint256","name":"newTokenPosition","type":"uint256"},{"internalType":"uint256","name":"ethRewardsToAdd","type":"uint256"},{"internalType":"uint256","name":"tokenRewardsToAdd","type":"uint256"}],"name":"removeLiquidityWithProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"minTokenAmount","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"newETHPosition","type":"uint256"},{"internalType":"uint256","name":"newTokenPosition","type":"uint256"},{"internalType":"uint256","name":"ethRewardsToAdd","type":"uint256"},{"internalType":"uint256","name":"tokenRewardsToAdd","type":"uint256"}],"name":"removeTokenLiquidityWithProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minLiquidity","type":"uint256"}],"name":"setMinLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minTokenLiquidity","type":"uint256"}],"name":"setMinTokenLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenProviderRewardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenProviders","outputs":[{"internalType":"uint256","name":"tokenPosition","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"},{"internalType":"uint256","name":"pendingRewards","type":"uint256"},{"internalType":"uint256","name":"lastUpdateVersion","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalEthAdded","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalEthRemoved","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalTokensAdded","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalTokensRemoved","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapPair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"version","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"newETHPosition","type":"uint256"},{"internalType":"uint256","name":"newTokenPosition","type":"uint256"},{"internalType":"uint256","name":"ethRewardsToAdd","type":"uint256"},{"internalType":"uint256","name":"tokenRewardsToAdd","type":"uint256"}],"name":"updateUserPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"versionMerkleRoots","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

0x60c0806040523461025f57604081613dfa803803809161001f8285610264565b83398101031261025f578051906001600160a01b0382169081830361025f57602001516001600160a01b038116919082900361025f57811561024957600080546001600160a01b031981168417825560405193916001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a36001805566038d7ea4c68000600b5566038d7ea4c68000600c55801561023857816004816020936000966080523360a05263313ce56760e01b82525afa90811561022d5782916101e9575b60ff821660ff19600a541617600a55604051613b5c908161029e8239608051818181610257015281816104b60152818161076401528181610a0801528181610d2901528181610f5c015281816110ce015281816113120152818161147c01528181611681015281816117b00152818161193e01528181611b7a01528181611c0001528181611c8f01528181611d0501528181611fd9015281816121f1015281816125130152818161266701528181612acd01528181612f3d015281816133e4015281816134b60152818161361901526138fb015260a05181818161066d01528181611366015281816116d5015281816129ad0152612bbb0152f35b90506020813d602011610225575b8161020460209383610264565b81010312610221575160ff811681036102215760ff9150386100ee565b5080fd5b3d91506101f7565b6040513d84823e3d90fd5b630f58058360e11b60005260046000fd5b631e4fbdf760e01b600052600060045260246000fd5b600080fd5b601f909101601f19168101906001600160401b0382119082101761028757604052565b634e487b7160e01b600052604160045260246000fdfe6080604052600436101561001b575b361561001957600080fd5b005b6000803560e01c80630902f1ac146125de57806310628146146124da5780631e489b12146124bc578063252cf2d21461249e578063271ebed314612474578063277327a5146123255780632b62a95a146123075780632eb4a7ab146122e957806330f391c31461216c57806335bc514714611f0757806336bdee7414611ee9578063370cb37d14611a395780633b97e85614611a185780634315d2a7146119035780635ab1bd53146118e85780635c4c4749146118845780635d4a07301461177c57806368061fcf14611640578063694457b3146115d95780636d8fca511461141d57806370036e94146112da578063715018a61461128057806374d0c73f146112625780637e1c0c0914611244578063832c7735146112265780638d5f81e21461120b5780638da5cb5b146111e4578063939d6237146111c65780639d888e86146111a85780639f68c5f614611093578063a91a9d6914611075578063aa5c3ab414611057578063af3fb49e14610ef2578063afd843c714610c74578063b09273be14610c10578063b23d349b146109e4578063bf0df0f9146109c6578063c056f87414610745578063c308d3f81461069c578063c45a015514610657578063c816841b1461062e578063d0251d9814610601578063d6eb902f14610482578063d79e8567146103bb578063eced552614610398578063f2fde38b14610312578063f30b2cbe146102a7578063fa3e67d4146102895763fc0c546a14610242575061000e565b346102865780600319360112610286576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b80fd5b50346102865780600319360112610286576020601054604051908152f35b5034610286576020366003190112610286576040906001600160a01b036102cc6127bc565b168152600560205220805461030e6001830154926003600282015491015490604051948594859094939260609260808301968352602083015260408201520152565b0390f35b50346102865760203660031901126102865761032c6127bc565b61033461317a565b6001600160a01b031680156103845781546001600160a01b03198116821783556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b631e4fbdf760e01b82526004829052602482fd5b50346102865780600319360112610286576020604051670de0b6b3a76400008152f35b5034610286576040366003190112610286576004356001600160a01b0381169081900361047e576024356103ed61317a565b811561046f57471561045b578061046a5750475b47811161045b578280808084865af1610418612958565b501561044c5760207f20f907b58305c7b76035bc03b26f32b1c4f6560f96be6f3bb54c5c848a2d4ddd91604051908152a280f35b634088176760e11b8352600483fd5b635dd9055760e11b8352600483fd5b610401565b634e46966960e11b8352600483fd5b5080fd5b5061048c36612778565b94909391929190602460206001600160a01b036104a7612998565b604051630736b32b60e31b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600482015293849290918391165afa9081156105f65789916105c7575b506105b857610508612c00565b600b5434106105a957600c54871061059a5761052333612c22565b610544575b8761053d88610537343361353e565b33612f11565b6001805580f35b6012541561058b5784848461055b94899433612d2c565b1561057c579161053d9493916105719333612e25565b903880808080610528565b63582f497d60e11b8652600486fd5b6396fceb9560e01b8852600488fd5b63e9e2150160e01b8852600488fd5b6313eed88360e01b8852600488fd5b63363cc9c560e11b8852600488fd5b6105e9915060203d6020116105ef575b6105e18183612872565b8101906128dd565b386104fb565b503d6105d7565b6040513d8b823e3d90fd5b5034610286578060031936011261028657602061061c612ba6565b6040516001600160a01b039091168152f35b50346102865780600319360112610286576011546040516001600160a01b039091168152602090f35b50346102865780600319360112610286576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5034610286576106ab36612778565b949093919296956106ba612c00565b33875260046020526003604088200154811180159061072c575b61071d576013541061070e578383886106ef94889433612d2c565b156106ff5761053d939433612e25565b63582f497d60e11b8452600484fd5b636b5a319160e11b8652600486fd5b63836e885160e01b8752600487fd5b50338752600560205260036040882001548111156106d4565b5061074f36612858565b916001600160a01b03610760612998565b16927f00000000000000000000000000000000000000000000000000000000000000006024602060018060a01b0383169660405192838092630736b32b60e31b82528a60048301525afa90811561098d5787916109a7575b5061099857600460206001600160a01b036107d1612998565b16604051928380926360c58eaf60e11b82525afa90811561098d57879161095e575b506001600160a01b0316330361094f5782156109405783156109405782340361093157600354848110610922579161086d8561087293610836828b99989761294b565b600355610845826010546128f5565b601055610854346002546128f5565b60025561086334600d546128f5565b600d5533906131a3565b613a33565b6001600160a01b03610882612ba6565b1691823b1561091e576084849283604051958694859363a2b570a160e01b8552336004860152836024860152604485015260648401525af18015610913576108fe575b50507f9429d90350814b8ecd99839a70fae357d681f41ba9d8519ee2272250cae0ff8a604060025460035482519182526020820152a280f35b8161090891612872565b61047e5781386108c5565b6040513d84823e3d90fd5b8380fd5b639dd27ee760e01b8752600487fd5b636c4e725160e11b8652600486fd5b6365e52d5160e11b8652600486fd5b63a9fec59b60e01b8652600486fd5b610980915060203d602011610986575b6109788183612872565b8101906128be565b386107f3565b503d61096e565b6040513d89823e3d90fd5b63363cc9c560e11b8652600486fd5b6109c0915060203d6020116105ef576105e18183612872565b386107b8565b50346102865780600319360112610286576020600e54604051908152f35b5034610286576109f336612858565b916001600160a01b03610a04612998565b16927f00000000000000000000000000000000000000000000000000000000000000006024602060018060a01b0383169660405192838092630736b32b60e31b82528a60048301525afa90811561098d578791610bf1575b5061099857600460206001600160a01b03610a75612998565b16604051928380926360c58eaf60e11b82525afa90811561098d578791610bd2575b506001600160a01b0316330361094f578215610940578315610940578260025410610bc35783610aca913090339061376c565b610ad68260025461294b565b600255610ae582600e546128f5565b600e55610af4836003546128f5565b600355610b0383600f546128f5565b600f558480808085335af1610b16612958565b5015610bb45790610b28859392613a33565b6001600160a01b03610b38612ba6565b1691823b1561091e576084849283604051958694859363a2b570a160e01b855233600486015260016024860152604485015260648401525af18015610913576108fe5750507f9429d90350814b8ecd99839a70fae357d681f41ba9d8519ee2272250cae0ff8a604060025460035482519182526020820152a280f35b635cb84edb60e11b8552600485fd5b635473c39360e01b8652600486fd5b610beb915060203d602011610986576109788183612872565b38610a97565b610c0a915060203d6020116105ef576105e18183612872565b38610a5c565b503461028657602036600319011261028657600435610c2d61317a565b8015610c65576020817f554ff81f8d029070b26b416ba425c7e95c46f196538825a375116221b489351192600c55604051908152a180f35b63219a277b60e01b8252600482fd5b503461028657610c83366127d2565b9390929594610c90612c00565b3386526005602052600260408720015415610ee357610cae33612c22565b610ea2575b505050505080915033825260056020526040822054610e5c575b33825260056020526040822060020154610ce6916128f5565b8015610e4d57610d189033835260056020526040832054610e0d575b338352600560205282600260408220015561326d565b610d24816010546128f5565b6010557f0000000000000000000000000000000000000000000000000000000000000000610d538233836131a3565b826001600160a01b03610d64612ba6565b6001600160a01b039093169216803b1561047e5760405163a85b4a2560e01b81523360048201526001600160a01b0384166024820152604481018590529082908290606490829084905af1801561091357610df4575b5050604080519283526001600160a01b0390911660208301523391600080516020613b0783398151915291819081015b0390a26001805580f35b81610dfe91612872565b610e09578238610dba565b8280fd5b3383526005602052670de0b6b3a7640000610e37610e2e6040862054613222565b60075490612918565b0433845260056020526001604085200155610d02565b6339addcf960e01b8252600482fd5b503381526005602052610ce6610e9b670de0b6b3a7640000610e84610e2e6040862054613222565b04338452600560205260016040852001549061294b565b9050610ccd565b60125415610ed457838388610eb994889433612d2c565b156106ff57610ec9939433612e25565b803880808080610cb3565b6396fceb9560e01b8652600486fd5b63b07a180360e01b8652600486fd5b5034610286576101003660031901126102865760043560643567ffffffffffffffff8111610e0957610f28903690600401612742565b60e4359160c4359160a435916084359190602460206001600160a01b03610f4d612998565b604051630736b32b60e31b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600482015293849290918391165afa9081156105f6578991611038575b506105b857610fae612c00565b8615801561102d575b61101b57610fc433612c22565b610fe3575b8761053d88610fda602435826137ae565b604435906132a7565b6012541561058b57848484610ffa94899433612d2c565b1561057c579161053d9493916110109333612e25565b903880808080610fc9565b600162784ebb60e11b03198852600488fd5b506127108711610fb7565b611051915060203d6020116105ef576105e18183612872565b38610fa1565b50346102865780600319360112610286576020600854604051908152f35b50346102865780600319360112610286576020600954604051908152f35b5034610286576110a236612811565b979694909391929190602460206001600160a01b036110bf612998565b604051630736b32b60e31b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600482015293849290918391165afa9081156105f6578991611189575b506105b857611120612c00565b8515801561117e575b61101b5761113633612c22565b611146575b8761053d88886137ae565b6012541561058b5784848461115d948c9433612d2c565b1561057c579161053d9596916111739333612e25565b83923880808061113b565b506127108611611129565b6111a2915060203d6020116105ef576105e18183612872565b38611113565b50346102865780600319360112610286576020601354604051908152f35b50346102865780600319360112610286576020600654604051908152f35b5034610286578060031936011261028657546040516001600160a01b039091168152602090f35b5034610286578060031936011261028657602061061c612a1e565b50346102865780600319360112610286576020600754604051908152f35b50346102865780600319360112610286576020600354604051908152f35b50346102865780600319360112610286576020600f54604051908152f35b503461028657806003193601126102865761129961317a565b80546001600160a01b03198116825581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b506020366003190112610286576112ef6127bc565b602460206001600160a01b03611303612998565b604051630736b32b60e31b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600482015293849290918391165afa9081156114125783916113f3575b506113e457611364612c00565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031633036113d557600b5434106113c6576001600160a01b038116156113b75761053d90349061353e565b634e46966960e11b8252600482fd5b6313eed88360e01b8252600482fd5b630636a15760e11b8252600482fd5b63363cc9c560e11b8252600482fd5b61140c915060203d6020116105ef576105e18183612872565b38611357565b6040513d85823e3d90fd5b503461028657602036600319011261028657600435602460206001600160a01b03611446612998565b16604051928380926316ed852560e01b82523360048301525afa9081156114125783916115ba575b50156115ab57801561159c577f0000000000000000000000000000000000000000000000000000000000000000906114a88130338561376c565b6114b481600f546128f5565b600f556003548061151d575b50611517816114f27f8d2db909f3e847842d54629432430824220c8530b099c6ab61a569c5f6859af7936010546128f5565b601055604080519182526001600160a01b039094166020820152339390918291820190565b0390a280f35b61152f61152983613222565b91613222565b60075491670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561158857611567916115619161292b565b826128f5565b908110611579576007556115176114c0565b63a3080b5d60e01b8452600484fd5b634e487b7160e01b86526011600452602486fd5b6365e52d5160e11b8252600482fd5b6301e803c360e01b8252600482fd5b6115d3915060203d6020116105ef576105e18183612872565b3861146e565b5034610286576020366003190112610286576040906001600160a01b036115fe6127bc565b168152600460205220805461030e6001830154926003600282015491015490604051948594859094939260609260808301968352602083015260408201520152565b50346102865760403660031901126102865761165a6127bc565b60248035919060206001600160a01b03611672612998565b604051630736b32b60e31b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600482015293849290918391165afa908115611771578491611752575b50611743576116d3612c00565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361173457600c548210611725576001600160a01b0381161561046f579061053d91612f11565b63e9e2150160e01b8352600483fd5b630636a15760e11b8352600483fd5b63363cc9c560e11b8352600483fd5b61176b915060203d6020116105ef576105e18183612872565b386116c6565b6040513d86823e3d90fd5b50611786366127d2565b92959492939092602460206001600160a01b036117a1612998565b604051630736b32b60e31b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600482015293849290918391165afa90811561098d578791611865575b5061099857611802612c00565b600b5434106118565761181433612c22565b611824575b8561053d343361353e565b60125415610ed45783838861183b94889433612d2c565b156106ff5761184b939433612e25565b803880808080611819565b6313eed88360e01b8652600486fd5b61187e915060203d6020116105ef576105e18183612872565b386117f5565b5034610286576020366003190112610286576004356118a161317a565b80156118d9576020817fb2ee55c75b3383382e754fd3eff2d543c0e990be639421a4e2d8f2a42c5b8fdb92600b55604051908152a180f35b631198d8ad60e21b8252600482fd5b5034610286578060031936011261028657602061061c612998565b50346102865761191236612811565b979694909391929190602460206001600160a01b0361192f612998565b604051630736b32b60e31b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600482015293849290918391165afa9081156105f65789916119f9575b506105b857611990612c00565b851580156119ee575b61101b576119a633612c22565b6119b6575b8761053d88886132a7565b6012541561058b578484846119cd948c9433612d2c565b1561057c579161053d9596916119e39333612e25565b8392388080806119ab565b506127108611611999565b611a12915060203d6020116105ef576105e18183612872565b38611983565b5034610286578060031936011261028657602060ff600a5416604051908152f35b503461028657611a48366127d2565b9390929594611a55612c00565b3386526004602052611a78604087205433885260056020526040882054906128f5565b1580611ed2575b80611ebb575b611eac57611a9233612c22565b611e7a575b505050505080915033825260046020526040822054611e33575b33825260046020526040822060020154611aca916128f5565b8133835260056020526040832054611ded575b33835260056020526040832060020154611af6916128f5565b611b0081836128f5565b918215611dde5790839133835260046020526040832054611da6575b33835260056020526040832054611d6f575b338352600460205282600260408220015533835260056020528260026040822001558015159081611d2e575b8215159182611cf6575b611c5a575b50611bc2575b5050604080519182527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031660208301523391600080516020613b078339815191529181908101610dea565b611bcb9061326d565b6001600160a01b03611bdb612ba6565b16803b15610e095760405163a85b4a2560e01b81523360048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166024820152604481019290925282908290606490829084905af180156109135715611b6f5781611c4f91612872565b61047e578138611b6f565b6001600160a01b03611c6a612ba6565b16803b15611cf257604051634811781160e11b81523360048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166024820152604481019290925284908290606490829084905af1908115611771578491611cdd575b50611b69565b81611ce791612872565b610e09578238611cd7565b8480fd5b611d29611d028561326d565b337f00000000000000000000000000000000000000000000000000000000000000006131a3565b611b64565b90919250611d3e81600e546128f5565b600e558480808084335af1611d51612958565b5015611d605790849291611b5a565b634088176760e11b8552600485fd5b3383526005602052670de0b6b3a7640000611d90610e2e6040862054613222565b0433845260056020526001604085200155611b2e565b3383526004602052670de0b6b3a7640000611dc8604085205460065490612918565b0433845260046020526001604085200155611b1c565b630fec21fd60e21b8452600484fd5b503382526005602052611af6611e2c670de0b6b3a7640000611e15610e2e6040872054613222565b04338552600560205260016040862001549061294b565b9050611add565b503381526004602052611aca611e73670de0b6b3a7640000611e5c604085205460065490612918565b04338452600460205260016040852001549061294b565b9050611ab1565b60125415610ed457838388611e9194889433612d2c565b156106ff57611ea1939433612e25565b803880808080611a97565b633624525160e01b8652600486fd5b503386526005602052600260408720015415611a85565b503386526004602052600260408720015415611a7f565b50346102865780600319360112610286576020600254604051908152f35b503461028657611f16366127d2565b9390929594611f23612c00565b338652600460205260026040872001541561215d57611f4133612c22565b61212b575b5050505050809150338252600460205260408220546120fb575b33825260046020526040822060020154611f79916128f5565b80156120ec57338252600460205260408220546120b4575b3382526004602052816002604082200155611fae81600e546128f5565b600e558180808084335af1611fc1612958565b50156120a5576001600160a01b03611fd7612ba6565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169116803b1561091e57604051634811781160e11b81523360048201526001600160a01b0383166024820152604481018490529084908290606490829084905af180156117715761207f575b50604080519283526001600160a01b0390911660208301523391600080516020613b078339815191529181908101610dea565b8361209d600080516020613b078339815191529395610dea93612872565b93915061204c565b634088176760e11b8252600482fd5b3382526004602052670de0b6b3a76400006120d6604084205460065490612918565b0433835260046020526001604084200155611f91565b630fec21fd60e21b8252600482fd5b503381526004602052611f79612124670de0b6b3a7640000611e5c604085205460065490612918565b9050611f60565b60125415610ed45783838861214294889433612d2c565b156106ff57612152939433612e25565b803880808080611f46565b63122c3e7b60e01b8652600486fd5b508060031936011261028657602460206001600160a01b0361218c612998565b16604051928380926316ed852560e01b82523360048301525afa9081156109135782916122ca575b50156122bb5734156122ac576121cc34600d546128f5565b600d556002548061224c575b506121e5346008546128f5565b600855604080513481527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316602082015233917fb72a3c2dec58e0026c0ec33851aa7028c754e26f575d1346a2542a36c85c7c37919081908101611517565b60065490670de0b6b3a76400003402348104670de0b6b3a76400000361229857612279916115619161292b565b90811061228957600655386121d8565b632f72cb2760e21b8252600482fd5b634e487b7160e01b84526011600452602484fd5b630b7cc7c360e11b8152600490fd5b6301e803c360e01b8152600490fd5b6122e3915060203d6020116105ef576105e18183612872565b386121b4565b50346102865780600319360112610286576020601254604051908152f35b50346102865780600319360112610286576020600c54604051908152f35b50346102865760603660031901126102865761233f6127bc565b6024356001600160a01b0381169182820361091e576044359061236061317a565b6001600160a01b0316918215612465578315612456576040516370a0823160e01b815230600482015291602083602481875afa92831561244b578693612413575b50821561240457806123fe5750815b82116123ef57816123e57fda0612d7ca9ff90ca7143a6021ba8938994f8d045b2834ae585fd07b27ea697c93602093866131a3565b604051908152a380f35b637222ae5760e11b8552600485fd5b916123b0565b637222ae5760e11b8652600486fd5b9092506020813d602011612443575b8161242f60209383612872565b8101031261243f575191386123a1565b8580fd5b3d9150612422565b6040513d88823e3d90fd5b634e46966960e11b8552600485fd5b630f58058360e11b8552600485fd5b50346102865760203660031901126102865760406020916004358152601483522054604051908152f35b50346102865780600319360112610286576020600b54604051908152f35b50346102865780600319360112610286576020600d54604051908152f35b5034610286576124e936612778565b94909391929190602460206001600160a01b03612504612998565b604051630736b32b60e31b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600482015293849290918391165afa9081156105f65789916125bf575b506105b857612565612c00565b600c54871061059a5761257733612c22565b612587575b8761053d8833612f11565b6012541561058b5784848461259e94899433612d2c565b1561057c579161053d9493916125b49333612e25565b90388080808061257c565b6125d8915060203d6020116105ef576105e18183612872565b38612558565b50346102865780600319360112610286576001600160a01b036125ff612a1e565b16801561273357604051630240bc6b60e21b815290606082600481845afa90811561141257839284926126d7575b50602060049160405192838092630dfe168160e01b82525afa908115611771579360409481926126b6575b50506001600160a01b039081167f0000000000000000000000000000000000000000000000000000000000000000909116036126a8576001600160701b0390915b81845193168352166020820152f35b6001600160701b0390612699565b6126d091925060203d602011610986576109788183612872565b9038612658565b925090506060823d60601161272b575b816126f460609383612872565b81010312610e0957612705826128aa565b6040612713602085016128aa565b93015163ffffffff81160361091e579190602061262d565b3d91506126e7565b63317f12fd60e21b8252600482fd5b9181601f840112156127735782359167ffffffffffffffff8311612773576020808501948460051b01011161277357565b600080fd5b9060c060031983011261277357600435916024359067ffffffffffffffff8211612773576127a891600401612742565b909160443590606435906084359060a43590565b600435906001600160a01b038216820361277357565b60a0600319820112612773576004359067ffffffffffffffff8211612773576127fd91600401612742565b909160243590604435906064359060843590565b60e06003198201126127735760043591602435916044359067ffffffffffffffff82116127735761284491600401612742565b9091606435906084359060a4359060c43590565b606090600319011261277357600435906024359060443590565b90601f8019910116810190811067ffffffffffffffff82111761289457604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160701b038216820361277357565b9081602091031261277357516001600160a01b03811681036127735790565b90816020910312612773575180151581036127735790565b9190820180921161290257565b634e487b7160e01b600052601160045260246000fd5b8181029291811591840414171561290257565b8115612935570490565b634e487b7160e01b600052601260045260246000fd5b9190820391821161290257565b3d15612993573d9067ffffffffffffffff82116128945760405191612987601f8201601f191660200184612872565b82523d6000602084013e565b606090565b604051635ab1bd5360e01b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115612a12576000916129f3575b506001600160a01b031690565b612a0c915060203d602011610986576109788183612872565b386129e6565b6040513d6000823e3d90fd5b600460206001600160a01b03612a32612998565b16604051928380926303e21fa960e61b82525afa908115612a1257600091612b87575b506001600160a01b03168015612b765760405163c45a015560e01b815290602082600481845afa918215612a1257600092612b51575b506020600491604051928380926315ab88c960e31b82525afa8015612a1257602091600091612b34575b5060405163e6a4390560e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600483015291821660248201529283916044918391165afa908115612a1257600091612b18575090565b612b31915060203d602011610986576109788183612872565b90565b612b4b9150823d8411610986576109788183612872565b38612ab5565b6004919250612b6e602091823d8411610986576109788183612872565b929150612a8b565b63179ce99f60e01b60005260046000fd5b612ba0915060203d602011610986576109788183612872565b38612a55565b604051631a04a3b360e31b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115612a12576000916129f357506001600160a01b031690565b600260015414612c11576002600155565b633ee5aeb560e01b60005260046000fd5b6001600160a01b031660008181526004602052604090205415159081612d0e575b8115612cd3575b8115612c95575b8115612c5b575090565b809150600052600560205260026040600020015415159081612c7b575090565b905060005260056020526003604060002001546013541190565b8091506000526004602052600260406000200154151580612cb7575b90612c51565b5080600052600460205260036040600020015460135411612cb1565b8091506000526005602052604060002054151580612cf2575b90612c4a565b5080600052600560205260036040600020015460135411612cec565b80915060005260046020526003604060002001546013541190612c43565b939694909591966040519360208501956001600160601b03199060601b168652603485015260548401526074830152609482015260948152612d6f60b482612872565b5190208315612e1b576012549267ffffffffffffffff8511612894578460051b60405195612da06020830188612872565b8652602086019082019136831161277357905b828210612e0b57505050906000915b8451831015612e0357604060019160009060208660051b8901015190818110600014612df7578252602052205b920191612dc2565b90825260205220612def565b915092501490565b8135815260209182019101612db3565b6012541492509050565b6001600160a01b0316600081815260046020526040908190206002810195909555601354600386015593829055600654929490937f93ae833dd09f76d0cc6a0b7e741d4c1321a8dcdc17d992347a42390dacab1b7e9390929190670de0b6b3a764000090612e939084612918565b04856000526004602052600184600020015584600052600560205260028360002001556013548460005260056020526003836000200155836000526005602052848260002055670de0b6b3a7640000612eee610e2e87613222565b0484600052600560205260018360002001556013549482519182526020820152a3565b60115460009392906001600160a01b03811615613152575b506011546001600160a01b031615613143577f000000000000000000000000000000000000000000000000000000000000000091612f698230338661376c565b6001600160a01b0316808552600560205260408520549092906130e6575b828552600560205260408520612f9e8382546128f5565b905582855260056020526003604086200154156130ce575b8285526005602052670de0b6b3a7640000612fd7610e2e6040882054613222565b0483865260056020526001604087200155612ff4826003546128f5565b60035561300382600f546128f5565b600f55846001600160a01b03613017612ba6565b6001600160a01b039093169216803b1561047e5781906084604051809981936337b033bd60e01b8352896004840152876024840152600260448401528860648401525af19586156130c1577f676a21a4f9b16f222794969ac5e4186afd0825a66363806c0e826e20515355519495966130b1575b5050604080516001600160a01b039092168252602082019290925290819081015b0390a2565b816130bb91612872565b3861308b565b50604051903d90823e3d90fd5b60135483865260056020526003604087200155612fb6565b8285526005602052613122670de0b6b3a764000061310b604088205460075490612918565b04848752600560205260016040882001549061294b565b838652600560205261313c600260408820019182546128f5565b9055612f87565b63317f12fd60e21b8452600484fd5b6001600160a01b03613162612a1e565b16906001600160601b0360a01b161760115538612f29565b6000546001600160a01b0316330361318e57565b63118cdaa760e01b6000523360045260246000fd5b60405163a9059cbb60e01b60208201526001600160a01b03909216602483015260448201929092526131eb916131e682606481015b03601f198101845283612872565b6139d8565b565b60ff6011199116019060ff821161290257565b60ff166012039060ff821161290257565b60ff16604d811161290257600a0a90565b600a5460ff1660128103613234575090565b9060128210156132585761325261324d612b3193613200565b613211565b90612918565b61326761324d612b31936131ed565b9061292b565b600a5460ff166012810361327f575090565b9060128210156132985761326761324d612b3193613200565b61325261324d612b31936131ed565b90600354916000921561352f57338352600560205260408320541561352057613337612710913385526005602052613309670de0b6b3a76400006132f2604088205460075490612918565b04338752600560205260016040882001549061294b565b3386526005602052613323600260408820019182546128f5565b905533855260056020526040852054612918565b04908115613511573383526005602052604083205482116134fd575b60035482116134ee5733835260056020526040832061337383825461294b565b90553383526005602052670de0b6b3a7640000613397604085205460075490612918565b04338452600560205260016040852001556133b48260035461294b565b6003556133c3826010546128f5565b60105581106134df57806134af575b6001600160a01b036133e2612ba6565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316939116803b1561047e578180916084604051809481936337b033bd60e01b8352336004840152896024840152600360448401528860648401525af1801561091357917f872453a59772ebfa5955982584cc9984effe9618fe3f7aedbf5e7d830a17093f93916130ac9361349f575b5050604080516001600160a01b03909516855260208501919091523393918291820190565b816134a991612872565b3861347a565b6134da81337f00000000000000000000000000000000000000000000000000000000000000006131a3565b6133d2565b636c6c627d60e11b8252600482fd5b63bc6072f160e01b8352600483fd5b338352600560205260408320549150613353565b6397b879e360e01b8352600483fd5b6318c0f41760e11b8352600483fd5b636180f03f60e11b8352600483fd5b6011546000939291906001600160a01b03811615613744575b506011546001600160a01b031615613143576001600160a01b0316808452600460205260408420549091906136e7575b81845260046020526040842061359e8282546128f5565b905581845260046020526003604085200154156136cf575b8184526004602052670de0b6b3a76400006135d8604086205460065490612918565b04828552600460205260016040862001556135f5816002546128f5565b60025561360481600d546128f5565b600d556001600160a01b03613617612ba6565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031691869116803b1561047e5781906084604051809981936337b033bd60e01b83528960048401528760248401528160448401528860648401525af19586156130c1577f614370605682ad8ee86ae1639ff454988bff8f380e3afe2538785311eeb6cf149495966130b1575050604080516001600160a01b039092168252602082019290925290819081016130ac565b601354828552600460205260036040862001556135b6565b8184526004602052613723670de0b6b3a764000061370c604087205460065490612918565b04838652600460205260016040872001549061294b565b828552600460205261373d600260408720019182546128f5565b9055613587565b6001600160a01b03613754612a1e565b16906001600160601b0360a01b161760115538613557565b6040516323b872dd60e01b60208201526001600160a01b03928316602482015292909116604483015260648201929092526131eb916131e682608481016131d8565b90600254916000921561352f5733835260046020526040832054156135205761383e612710913385526004602052613810670de0b6b3a76400006137f9604088205460065490612918565b04338752600460205260016040882001549061294b565b338652600460205261382a600260408820019182546128f5565b905533855260046020526040852054612918565b04908115613511573383526004602052604083205482116139c4575b60025482116134ee5733835260046020526040832061387a83825461294b565b90553383526004602052670de0b6b3a764000061389e604085205460065490612918565b04338452600460205260016040852001556138bb8260025461294b565b6002556138ca82600e546128f5565b600e5581106134df578180808084335af16138e3612958565b50156139b5576001600160a01b036138f9612ba6565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316939116803b1561047e578180916084604051809481936337b033bd60e01b8352336004840152896024840152600160448401528860648401525af1801561091357917f0ee27c3eed2141ba713bf02854f5b24c90aa85985c767cdc8571a823ed07bde893916130ac9361349f575050604080516001600160a01b03909516855260208501919091523393918291820190565b63b12d13eb60e01b8252600482fd5b33835260046020526040832054915061385a565b906000602091828151910182855af115612a12576000513d613a2a57506001600160a01b0381163b155b613a095750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b60011415613a02565b600081613a3e575050565b6013546000198114613af2576001016013819055601283905581526014602052604081208290556001600160a01b03613a75612ba6565b16601354813b15610e09578291604483926040519485938492630fad898560e41b845260048401528860248401525af1801561091357613ae2575b50507f9ff79792a92b66fee090acb66e07837a2edb31ee6b9780fa551fd04b79dffcd2602060135492604051908152a2565b81613aec91612872565b38613ab0565b634e487b7160e01b82526011600452602482fdfe59025468c1ca9e7ccfc63ddd68950d1c78cdeca982ae691697d089b592b87ad3a264697066735822122080e4f39d56193ef9b912c806a67e5ad855fd5b20416b53b3b6a98f12ac6caa3464736f6c634300081a0033000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e000000000000000000000000edb6e78008bace6ddc169fccbddcfc371c6f3c8c

Deployed Bytecode

0x6080604052600436101561001b575b361561001957600080fd5b005b6000803560e01c80630902f1ac146125de57806310628146146124da5780631e489b12146124bc578063252cf2d21461249e578063271ebed314612474578063277327a5146123255780632b62a95a146123075780632eb4a7ab146122e957806330f391c31461216c57806335bc514714611f0757806336bdee7414611ee9578063370cb37d14611a395780633b97e85614611a185780634315d2a7146119035780635ab1bd53146118e85780635c4c4749146118845780635d4a07301461177c57806368061fcf14611640578063694457b3146115d95780636d8fca511461141d57806370036e94146112da578063715018a61461128057806374d0c73f146112625780637e1c0c0914611244578063832c7735146112265780638d5f81e21461120b5780638da5cb5b146111e4578063939d6237146111c65780639d888e86146111a85780639f68c5f614611093578063a91a9d6914611075578063aa5c3ab414611057578063af3fb49e14610ef2578063afd843c714610c74578063b09273be14610c10578063b23d349b146109e4578063bf0df0f9146109c6578063c056f87414610745578063c308d3f81461069c578063c45a015514610657578063c816841b1461062e578063d0251d9814610601578063d6eb902f14610482578063d79e8567146103bb578063eced552614610398578063f2fde38b14610312578063f30b2cbe146102a7578063fa3e67d4146102895763fc0c546a14610242575061000e565b346102865780600319360112610286576040517f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b03168152602090f35b80fd5b50346102865780600319360112610286576020601054604051908152f35b5034610286576020366003190112610286576040906001600160a01b036102cc6127bc565b168152600560205220805461030e6001830154926003600282015491015490604051948594859094939260609260808301968352602083015260408201520152565b0390f35b50346102865760203660031901126102865761032c6127bc565b61033461317a565b6001600160a01b031680156103845781546001600160a01b03198116821783556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b631e4fbdf760e01b82526004829052602482fd5b50346102865780600319360112610286576020604051670de0b6b3a76400008152f35b5034610286576040366003190112610286576004356001600160a01b0381169081900361047e576024356103ed61317a565b811561046f57471561045b578061046a5750475b47811161045b578280808084865af1610418612958565b501561044c5760207f20f907b58305c7b76035bc03b26f32b1c4f6560f96be6f3bb54c5c848a2d4ddd91604051908152a280f35b634088176760e11b8352600483fd5b635dd9055760e11b8352600483fd5b610401565b634e46966960e11b8352600483fd5b5080fd5b5061048c36612778565b94909391929190602460206001600160a01b036104a7612998565b604051630736b32b60e31b81527f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b0316600482015293849290918391165afa9081156105f65789916105c7575b506105b857610508612c00565b600b5434106105a957600c54871061059a5761052333612c22565b610544575b8761053d88610537343361353e565b33612f11565b6001805580f35b6012541561058b5784848461055b94899433612d2c565b1561057c579161053d9493916105719333612e25565b903880808080610528565b63582f497d60e11b8652600486fd5b6396fceb9560e01b8852600488fd5b63e9e2150160e01b8852600488fd5b6313eed88360e01b8852600488fd5b63363cc9c560e11b8852600488fd5b6105e9915060203d6020116105ef575b6105e18183612872565b8101906128dd565b386104fb565b503d6105d7565b6040513d8b823e3d90fd5b5034610286578060031936011261028657602061061c612ba6565b6040516001600160a01b039091168152f35b50346102865780600319360112610286576011546040516001600160a01b039091168152602090f35b50346102865780600319360112610286576040517f000000000000000000000000ad6d930552c779cf5640ab46d6b50da989cce5216001600160a01b03168152602090f35b5034610286576106ab36612778565b949093919296956106ba612c00565b33875260046020526003604088200154811180159061072c575b61071d576013541061070e578383886106ef94889433612d2c565b156106ff5761053d939433612e25565b63582f497d60e11b8452600484fd5b636b5a319160e11b8652600486fd5b63836e885160e01b8752600487fd5b50338752600560205260036040882001548111156106d4565b5061074f36612858565b916001600160a01b03610760612998565b16927f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6024602060018060a01b0383169660405192838092630736b32b60e31b82528a60048301525afa90811561098d5787916109a7575b5061099857600460206001600160a01b036107d1612998565b16604051928380926360c58eaf60e11b82525afa90811561098d57879161095e575b506001600160a01b0316330361094f5782156109405783156109405782340361093157600354848110610922579161086d8561087293610836828b99989761294b565b600355610845826010546128f5565b601055610854346002546128f5565b60025561086334600d546128f5565b600d5533906131a3565b613a33565b6001600160a01b03610882612ba6565b1691823b1561091e576084849283604051958694859363a2b570a160e01b8552336004860152836024860152604485015260648401525af18015610913576108fe575b50507f9429d90350814b8ecd99839a70fae357d681f41ba9d8519ee2272250cae0ff8a604060025460035482519182526020820152a280f35b8161090891612872565b61047e5781386108c5565b6040513d84823e3d90fd5b8380fd5b639dd27ee760e01b8752600487fd5b636c4e725160e11b8652600486fd5b6365e52d5160e11b8652600486fd5b63a9fec59b60e01b8652600486fd5b610980915060203d602011610986575b6109788183612872565b8101906128be565b386107f3565b503d61096e565b6040513d89823e3d90fd5b63363cc9c560e11b8652600486fd5b6109c0915060203d6020116105ef576105e18183612872565b386107b8565b50346102865780600319360112610286576020600e54604051908152f35b5034610286576109f336612858565b916001600160a01b03610a04612998565b16927f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6024602060018060a01b0383169660405192838092630736b32b60e31b82528a60048301525afa90811561098d578791610bf1575b5061099857600460206001600160a01b03610a75612998565b16604051928380926360c58eaf60e11b82525afa90811561098d578791610bd2575b506001600160a01b0316330361094f578215610940578315610940578260025410610bc35783610aca913090339061376c565b610ad68260025461294b565b600255610ae582600e546128f5565b600e55610af4836003546128f5565b600355610b0383600f546128f5565b600f558480808085335af1610b16612958565b5015610bb45790610b28859392613a33565b6001600160a01b03610b38612ba6565b1691823b1561091e576084849283604051958694859363a2b570a160e01b855233600486015260016024860152604485015260648401525af18015610913576108fe5750507f9429d90350814b8ecd99839a70fae357d681f41ba9d8519ee2272250cae0ff8a604060025460035482519182526020820152a280f35b635cb84edb60e11b8552600485fd5b635473c39360e01b8652600486fd5b610beb915060203d602011610986576109788183612872565b38610a97565b610c0a915060203d6020116105ef576105e18183612872565b38610a5c565b503461028657602036600319011261028657600435610c2d61317a565b8015610c65576020817f554ff81f8d029070b26b416ba425c7e95c46f196538825a375116221b489351192600c55604051908152a180f35b63219a277b60e01b8252600482fd5b503461028657610c83366127d2565b9390929594610c90612c00565b3386526005602052600260408720015415610ee357610cae33612c22565b610ea2575b505050505080915033825260056020526040822054610e5c575b33825260056020526040822060020154610ce6916128f5565b8015610e4d57610d189033835260056020526040832054610e0d575b338352600560205282600260408220015561326d565b610d24816010546128f5565b6010557f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e610d538233836131a3565b826001600160a01b03610d64612ba6565b6001600160a01b039093169216803b1561047e5760405163a85b4a2560e01b81523360048201526001600160a01b0384166024820152604481018590529082908290606490829084905af1801561091357610df4575b5050604080519283526001600160a01b0390911660208301523391600080516020613b0783398151915291819081015b0390a26001805580f35b81610dfe91612872565b610e09578238610dba565b8280fd5b3383526005602052670de0b6b3a7640000610e37610e2e6040862054613222565b60075490612918565b0433845260056020526001604085200155610d02565b6339addcf960e01b8252600482fd5b503381526005602052610ce6610e9b670de0b6b3a7640000610e84610e2e6040862054613222565b04338452600560205260016040852001549061294b565b9050610ccd565b60125415610ed457838388610eb994889433612d2c565b156106ff57610ec9939433612e25565b803880808080610cb3565b6396fceb9560e01b8652600486fd5b63b07a180360e01b8652600486fd5b5034610286576101003660031901126102865760043560643567ffffffffffffffff8111610e0957610f28903690600401612742565b60e4359160c4359160a435916084359190602460206001600160a01b03610f4d612998565b604051630736b32b60e31b81527f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b0316600482015293849290918391165afa9081156105f6578991611038575b506105b857610fae612c00565b8615801561102d575b61101b57610fc433612c22565b610fe3575b8761053d88610fda602435826137ae565b604435906132a7565b6012541561058b57848484610ffa94899433612d2c565b1561057c579161053d9493916110109333612e25565b903880808080610fc9565b600162784ebb60e11b03198852600488fd5b506127108711610fb7565b611051915060203d6020116105ef576105e18183612872565b38610fa1565b50346102865780600319360112610286576020600854604051908152f35b50346102865780600319360112610286576020600954604051908152f35b5034610286576110a236612811565b979694909391929190602460206001600160a01b036110bf612998565b604051630736b32b60e31b81527f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b0316600482015293849290918391165afa9081156105f6578991611189575b506105b857611120612c00565b8515801561117e575b61101b5761113633612c22565b611146575b8761053d88886137ae565b6012541561058b5784848461115d948c9433612d2c565b1561057c579161053d9596916111739333612e25565b83923880808061113b565b506127108611611129565b6111a2915060203d6020116105ef576105e18183612872565b38611113565b50346102865780600319360112610286576020601354604051908152f35b50346102865780600319360112610286576020600654604051908152f35b5034610286578060031936011261028657546040516001600160a01b039091168152602090f35b5034610286578060031936011261028657602061061c612a1e565b50346102865780600319360112610286576020600754604051908152f35b50346102865780600319360112610286576020600354604051908152f35b50346102865780600319360112610286576020600f54604051908152f35b503461028657806003193601126102865761129961317a565b80546001600160a01b03198116825581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b506020366003190112610286576112ef6127bc565b602460206001600160a01b03611303612998565b604051630736b32b60e31b81527f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b0316600482015293849290918391165afa9081156114125783916113f3575b506113e457611364612c00565b7f000000000000000000000000ad6d930552c779cf5640ab46d6b50da989cce5216001600160a01b031633036113d557600b5434106113c6576001600160a01b038116156113b75761053d90349061353e565b634e46966960e11b8252600482fd5b6313eed88360e01b8252600482fd5b630636a15760e11b8252600482fd5b63363cc9c560e11b8252600482fd5b61140c915060203d6020116105ef576105e18183612872565b38611357565b6040513d85823e3d90fd5b503461028657602036600319011261028657600435602460206001600160a01b03611446612998565b16604051928380926316ed852560e01b82523360048301525afa9081156114125783916115ba575b50156115ab57801561159c577f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e906114a88130338561376c565b6114b481600f546128f5565b600f556003548061151d575b50611517816114f27f8d2db909f3e847842d54629432430824220c8530b099c6ab61a569c5f6859af7936010546128f5565b601055604080519182526001600160a01b039094166020820152339390918291820190565b0390a280f35b61152f61152983613222565b91613222565b60075491670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561158857611567916115619161292b565b826128f5565b908110611579576007556115176114c0565b63a3080b5d60e01b8452600484fd5b634e487b7160e01b86526011600452602486fd5b6365e52d5160e11b8252600482fd5b6301e803c360e01b8252600482fd5b6115d3915060203d6020116105ef576105e18183612872565b3861146e565b5034610286576020366003190112610286576040906001600160a01b036115fe6127bc565b168152600460205220805461030e6001830154926003600282015491015490604051948594859094939260609260808301968352602083015260408201520152565b50346102865760403660031901126102865761165a6127bc565b60248035919060206001600160a01b03611672612998565b604051630736b32b60e31b81527f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b0316600482015293849290918391165afa908115611771578491611752575b50611743576116d3612c00565b7f000000000000000000000000ad6d930552c779cf5640ab46d6b50da989cce5216001600160a01b0316330361173457600c548210611725576001600160a01b0381161561046f579061053d91612f11565b63e9e2150160e01b8352600483fd5b630636a15760e11b8352600483fd5b63363cc9c560e11b8352600483fd5b61176b915060203d6020116105ef576105e18183612872565b386116c6565b6040513d86823e3d90fd5b50611786366127d2565b92959492939092602460206001600160a01b036117a1612998565b604051630736b32b60e31b81527f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b0316600482015293849290918391165afa90811561098d578791611865575b5061099857611802612c00565b600b5434106118565761181433612c22565b611824575b8561053d343361353e565b60125415610ed45783838861183b94889433612d2c565b156106ff5761184b939433612e25565b803880808080611819565b6313eed88360e01b8652600486fd5b61187e915060203d6020116105ef576105e18183612872565b386117f5565b5034610286576020366003190112610286576004356118a161317a565b80156118d9576020817fb2ee55c75b3383382e754fd3eff2d543c0e990be639421a4e2d8f2a42c5b8fdb92600b55604051908152a180f35b631198d8ad60e21b8252600482fd5b5034610286578060031936011261028657602061061c612998565b50346102865761191236612811565b979694909391929190602460206001600160a01b0361192f612998565b604051630736b32b60e31b81527f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b0316600482015293849290918391165afa9081156105f65789916119f9575b506105b857611990612c00565b851580156119ee575b61101b576119a633612c22565b6119b6575b8761053d88886132a7565b6012541561058b578484846119cd948c9433612d2c565b1561057c579161053d9596916119e39333612e25565b8392388080806119ab565b506127108611611999565b611a12915060203d6020116105ef576105e18183612872565b38611983565b5034610286578060031936011261028657602060ff600a5416604051908152f35b503461028657611a48366127d2565b9390929594611a55612c00565b3386526004602052611a78604087205433885260056020526040882054906128f5565b1580611ed2575b80611ebb575b611eac57611a9233612c22565b611e7a575b505050505080915033825260046020526040822054611e33575b33825260046020526040822060020154611aca916128f5565b8133835260056020526040832054611ded575b33835260056020526040832060020154611af6916128f5565b611b0081836128f5565b918215611dde5790839133835260046020526040832054611da6575b33835260056020526040832054611d6f575b338352600460205282600260408220015533835260056020528260026040822001558015159081611d2e575b8215159182611cf6575b611c5a575b50611bc2575b5050604080519182527f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b031660208301523391600080516020613b078339815191529181908101610dea565b611bcb9061326d565b6001600160a01b03611bdb612ba6565b16803b15610e095760405163a85b4a2560e01b81523360048201526001600160a01b037f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e166024820152604481019290925282908290606490829084905af180156109135715611b6f5781611c4f91612872565b61047e578138611b6f565b6001600160a01b03611c6a612ba6565b16803b15611cf257604051634811781160e11b81523360048201526001600160a01b037f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e166024820152604481019290925284908290606490829084905af1908115611771578491611cdd575b50611b69565b81611ce791612872565b610e09578238611cd7565b8480fd5b611d29611d028561326d565b337f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6131a3565b611b64565b90919250611d3e81600e546128f5565b600e558480808084335af1611d51612958565b5015611d605790849291611b5a565b634088176760e11b8552600485fd5b3383526005602052670de0b6b3a7640000611d90610e2e6040862054613222565b0433845260056020526001604085200155611b2e565b3383526004602052670de0b6b3a7640000611dc8604085205460065490612918565b0433845260046020526001604085200155611b1c565b630fec21fd60e21b8452600484fd5b503382526005602052611af6611e2c670de0b6b3a7640000611e15610e2e6040872054613222565b04338552600560205260016040862001549061294b565b9050611add565b503381526004602052611aca611e73670de0b6b3a7640000611e5c604085205460065490612918565b04338452600460205260016040852001549061294b565b9050611ab1565b60125415610ed457838388611e9194889433612d2c565b156106ff57611ea1939433612e25565b803880808080611a97565b633624525160e01b8652600486fd5b503386526005602052600260408720015415611a85565b503386526004602052600260408720015415611a7f565b50346102865780600319360112610286576020600254604051908152f35b503461028657611f16366127d2565b9390929594611f23612c00565b338652600460205260026040872001541561215d57611f4133612c22565b61212b575b5050505050809150338252600460205260408220546120fb575b33825260046020526040822060020154611f79916128f5565b80156120ec57338252600460205260408220546120b4575b3382526004602052816002604082200155611fae81600e546128f5565b600e558180808084335af1611fc1612958565b50156120a5576001600160a01b03611fd7612ba6565b7f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b03169116803b1561091e57604051634811781160e11b81523360048201526001600160a01b0383166024820152604481018490529084908290606490829084905af180156117715761207f575b50604080519283526001600160a01b0390911660208301523391600080516020613b078339815191529181908101610dea565b8361209d600080516020613b078339815191529395610dea93612872565b93915061204c565b634088176760e11b8252600482fd5b3382526004602052670de0b6b3a76400006120d6604084205460065490612918565b0433835260046020526001604084200155611f91565b630fec21fd60e21b8252600482fd5b503381526004602052611f79612124670de0b6b3a7640000611e5c604085205460065490612918565b9050611f60565b60125415610ed45783838861214294889433612d2c565b156106ff57612152939433612e25565b803880808080611f46565b63122c3e7b60e01b8652600486fd5b508060031936011261028657602460206001600160a01b0361218c612998565b16604051928380926316ed852560e01b82523360048301525afa9081156109135782916122ca575b50156122bb5734156122ac576121cc34600d546128f5565b600d556002548061224c575b506121e5346008546128f5565b600855604080513481527f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b0316602082015233917fb72a3c2dec58e0026c0ec33851aa7028c754e26f575d1346a2542a36c85c7c37919081908101611517565b60065490670de0b6b3a76400003402348104670de0b6b3a76400000361229857612279916115619161292b565b90811061228957600655386121d8565b632f72cb2760e21b8252600482fd5b634e487b7160e01b84526011600452602484fd5b630b7cc7c360e11b8152600490fd5b6301e803c360e01b8152600490fd5b6122e3915060203d6020116105ef576105e18183612872565b386121b4565b50346102865780600319360112610286576020601254604051908152f35b50346102865780600319360112610286576020600c54604051908152f35b50346102865760603660031901126102865761233f6127bc565b6024356001600160a01b0381169182820361091e576044359061236061317a565b6001600160a01b0316918215612465578315612456576040516370a0823160e01b815230600482015291602083602481875afa92831561244b578693612413575b50821561240457806123fe5750815b82116123ef57816123e57fda0612d7ca9ff90ca7143a6021ba8938994f8d045b2834ae585fd07b27ea697c93602093866131a3565b604051908152a380f35b637222ae5760e11b8552600485fd5b916123b0565b637222ae5760e11b8652600486fd5b9092506020813d602011612443575b8161242f60209383612872565b8101031261243f575191386123a1565b8580fd5b3d9150612422565b6040513d88823e3d90fd5b634e46966960e11b8552600485fd5b630f58058360e11b8552600485fd5b50346102865760203660031901126102865760406020916004358152601483522054604051908152f35b50346102865780600319360112610286576020600b54604051908152f35b50346102865780600319360112610286576020600d54604051908152f35b5034610286576124e936612778565b94909391929190602460206001600160a01b03612504612998565b604051630736b32b60e31b81527f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b0316600482015293849290918391165afa9081156105f65789916125bf575b506105b857612565612c00565b600c54871061059a5761257733612c22565b612587575b8761053d8833612f11565b6012541561058b5784848461259e94899433612d2c565b1561057c579161053d9493916125b49333612e25565b90388080808061257c565b6125d8915060203d6020116105ef576105e18183612872565b38612558565b50346102865780600319360112610286576001600160a01b036125ff612a1e565b16801561273357604051630240bc6b60e21b815290606082600481845afa90811561141257839284926126d7575b50602060049160405192838092630dfe168160e01b82525afa908115611771579360409481926126b6575b50506001600160a01b039081167f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e909116036126a8576001600160701b0390915b81845193168352166020820152f35b6001600160701b0390612699565b6126d091925060203d602011610986576109788183612872565b9038612658565b925090506060823d60601161272b575b816126f460609383612872565b81010312610e0957612705826128aa565b6040612713602085016128aa565b93015163ffffffff81160361091e579190602061262d565b3d91506126e7565b63317f12fd60e21b8252600482fd5b9181601f840112156127735782359167ffffffffffffffff8311612773576020808501948460051b01011161277357565b600080fd5b9060c060031983011261277357600435916024359067ffffffffffffffff8211612773576127a891600401612742565b909160443590606435906084359060a43590565b600435906001600160a01b038216820361277357565b60a0600319820112612773576004359067ffffffffffffffff8211612773576127fd91600401612742565b909160243590604435906064359060843590565b60e06003198201126127735760043591602435916044359067ffffffffffffffff82116127735761284491600401612742565b9091606435906084359060a4359060c43590565b606090600319011261277357600435906024359060443590565b90601f8019910116810190811067ffffffffffffffff82111761289457604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160701b038216820361277357565b9081602091031261277357516001600160a01b03811681036127735790565b90816020910312612773575180151581036127735790565b9190820180921161290257565b634e487b7160e01b600052601160045260246000fd5b8181029291811591840414171561290257565b8115612935570490565b634e487b7160e01b600052601260045260246000fd5b9190820391821161290257565b3d15612993573d9067ffffffffffffffff82116128945760405191612987601f8201601f191660200184612872565b82523d6000602084013e565b606090565b604051635ab1bd5360e01b81526020816004817f000000000000000000000000ad6d930552c779cf5640ab46d6b50da989cce5216001600160a01b03165afa908115612a12576000916129f3575b506001600160a01b031690565b612a0c915060203d602011610986576109788183612872565b386129e6565b6040513d6000823e3d90fd5b600460206001600160a01b03612a32612998565b16604051928380926303e21fa960e61b82525afa908115612a1257600091612b87575b506001600160a01b03168015612b765760405163c45a015560e01b815290602082600481845afa918215612a1257600092612b51575b506020600491604051928380926315ab88c960e31b82525afa8015612a1257602091600091612b34575b5060405163e6a4390560e01b81526001600160a01b037f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e8116600483015291821660248201529283916044918391165afa908115612a1257600091612b18575090565b612b31915060203d602011610986576109788183612872565b90565b612b4b9150823d8411610986576109788183612872565b38612ab5565b6004919250612b6e602091823d8411610986576109788183612872565b929150612a8b565b63179ce99f60e01b60005260046000fd5b612ba0915060203d602011610986576109788183612872565b38612a55565b604051631a04a3b360e31b81526020816004817f000000000000000000000000ad6d930552c779cf5640ab46d6b50da989cce5216001600160a01b03165afa908115612a12576000916129f357506001600160a01b031690565b600260015414612c11576002600155565b633ee5aeb560e01b60005260046000fd5b6001600160a01b031660008181526004602052604090205415159081612d0e575b8115612cd3575b8115612c95575b8115612c5b575090565b809150600052600560205260026040600020015415159081612c7b575090565b905060005260056020526003604060002001546013541190565b8091506000526004602052600260406000200154151580612cb7575b90612c51565b5080600052600460205260036040600020015460135411612cb1565b8091506000526005602052604060002054151580612cf2575b90612c4a565b5080600052600560205260036040600020015460135411612cec565b80915060005260046020526003604060002001546013541190612c43565b939694909591966040519360208501956001600160601b03199060601b168652603485015260548401526074830152609482015260948152612d6f60b482612872565b5190208315612e1b576012549267ffffffffffffffff8511612894578460051b60405195612da06020830188612872565b8652602086019082019136831161277357905b828210612e0b57505050906000915b8451831015612e0357604060019160009060208660051b8901015190818110600014612df7578252602052205b920191612dc2565b90825260205220612def565b915092501490565b8135815260209182019101612db3565b6012541492509050565b6001600160a01b0316600081815260046020526040908190206002810195909555601354600386015593829055600654929490937f93ae833dd09f76d0cc6a0b7e741d4c1321a8dcdc17d992347a42390dacab1b7e9390929190670de0b6b3a764000090612e939084612918565b04856000526004602052600184600020015584600052600560205260028360002001556013548460005260056020526003836000200155836000526005602052848260002055670de0b6b3a7640000612eee610e2e87613222565b0484600052600560205260018360002001556013549482519182526020820152a3565b60115460009392906001600160a01b03811615613152575b506011546001600160a01b031615613143577f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e91612f698230338661376c565b6001600160a01b0316808552600560205260408520549092906130e6575b828552600560205260408520612f9e8382546128f5565b905582855260056020526003604086200154156130ce575b8285526005602052670de0b6b3a7640000612fd7610e2e6040882054613222565b0483865260056020526001604087200155612ff4826003546128f5565b60035561300382600f546128f5565b600f55846001600160a01b03613017612ba6565b6001600160a01b039093169216803b1561047e5781906084604051809981936337b033bd60e01b8352896004840152876024840152600260448401528860648401525af19586156130c1577f676a21a4f9b16f222794969ac5e4186afd0825a66363806c0e826e20515355519495966130b1575b5050604080516001600160a01b039092168252602082019290925290819081015b0390a2565b816130bb91612872565b3861308b565b50604051903d90823e3d90fd5b60135483865260056020526003604087200155612fb6565b8285526005602052613122670de0b6b3a764000061310b604088205460075490612918565b04848752600560205260016040882001549061294b565b838652600560205261313c600260408820019182546128f5565b9055612f87565b63317f12fd60e21b8452600484fd5b6001600160a01b03613162612a1e565b16906001600160601b0360a01b161760115538612f29565b6000546001600160a01b0316330361318e57565b63118cdaa760e01b6000523360045260246000fd5b60405163a9059cbb60e01b60208201526001600160a01b03909216602483015260448201929092526131eb916131e682606481015b03601f198101845283612872565b6139d8565b565b60ff6011199116019060ff821161290257565b60ff166012039060ff821161290257565b60ff16604d811161290257600a0a90565b600a5460ff1660128103613234575090565b9060128210156132585761325261324d612b3193613200565b613211565b90612918565b61326761324d612b31936131ed565b9061292b565b600a5460ff166012810361327f575090565b9060128210156132985761326761324d612b3193613200565b61325261324d612b31936131ed565b90600354916000921561352f57338352600560205260408320541561352057613337612710913385526005602052613309670de0b6b3a76400006132f2604088205460075490612918565b04338752600560205260016040882001549061294b565b3386526005602052613323600260408820019182546128f5565b905533855260056020526040852054612918565b04908115613511573383526005602052604083205482116134fd575b60035482116134ee5733835260056020526040832061337383825461294b565b90553383526005602052670de0b6b3a7640000613397604085205460075490612918565b04338452600560205260016040852001556133b48260035461294b565b6003556133c3826010546128f5565b60105581106134df57806134af575b6001600160a01b036133e2612ba6565b7f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b0316939116803b1561047e578180916084604051809481936337b033bd60e01b8352336004840152896024840152600360448401528860648401525af1801561091357917f872453a59772ebfa5955982584cc9984effe9618fe3f7aedbf5e7d830a17093f93916130ac9361349f575b5050604080516001600160a01b03909516855260208501919091523393918291820190565b816134a991612872565b3861347a565b6134da81337f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6131a3565b6133d2565b636c6c627d60e11b8252600482fd5b63bc6072f160e01b8352600483fd5b338352600560205260408320549150613353565b6397b879e360e01b8352600483fd5b6318c0f41760e11b8352600483fd5b636180f03f60e11b8352600483fd5b6011546000939291906001600160a01b03811615613744575b506011546001600160a01b031615613143576001600160a01b0316808452600460205260408420549091906136e7575b81845260046020526040842061359e8282546128f5565b905581845260046020526003604085200154156136cf575b8184526004602052670de0b6b3a76400006135d8604086205460065490612918565b04828552600460205260016040862001556135f5816002546128f5565b60025561360481600d546128f5565b600d556001600160a01b03613617612ba6565b7f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b031691869116803b1561047e5781906084604051809981936337b033bd60e01b83528960048401528760248401528160448401528860648401525af19586156130c1577f614370605682ad8ee86ae1639ff454988bff8f380e3afe2538785311eeb6cf149495966130b1575050604080516001600160a01b039092168252602082019290925290819081016130ac565b601354828552600460205260036040862001556135b6565b8184526004602052613723670de0b6b3a764000061370c604087205460065490612918565b04838652600460205260016040872001549061294b565b828552600460205261373d600260408720019182546128f5565b9055613587565b6001600160a01b03613754612a1e565b16906001600160601b0360a01b161760115538613557565b6040516323b872dd60e01b60208201526001600160a01b03928316602482015292909116604483015260648201929092526131eb916131e682608481016131d8565b90600254916000921561352f5733835260046020526040832054156135205761383e612710913385526004602052613810670de0b6b3a76400006137f9604088205460065490612918565b04338752600460205260016040882001549061294b565b338652600460205261382a600260408820019182546128f5565b905533855260046020526040852054612918565b04908115613511573383526004602052604083205482116139c4575b60025482116134ee5733835260046020526040832061387a83825461294b565b90553383526004602052670de0b6b3a764000061389e604085205460065490612918565b04338452600460205260016040852001556138bb8260025461294b565b6002556138ca82600e546128f5565b600e5581106134df578180808084335af16138e3612958565b50156139b5576001600160a01b036138f9612ba6565b7f000000000000000000000000cca28c3aba68ae6dc88f63ceb43efa11a9ca144e6001600160a01b0316939116803b1561047e578180916084604051809481936337b033bd60e01b8352336004840152896024840152600160448401528860648401525af1801561091357917f0ee27c3eed2141ba713bf02854f5b24c90aa85985c767cdc8571a823ed07bde893916130ac9361349f575050604080516001600160a01b03909516855260208501919091523393918291820190565b63b12d13eb60e01b8252600482fd5b33835260046020526040832054915061385a565b906000602091828151910182855af115612a12576000513d613a2a57506001600160a01b0381163b155b613a095750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b60011415613a02565b600081613a3e575050565b6013546000198114613af2576001016013819055601283905581526014602052604081208290556001600160a01b03613a75612ba6565b16601354813b15610e09578291604483926040519485938492630fad898560e41b845260048401528860248401525af1801561091357613ae2575b50507f9ff79792a92b66fee090acb66e07837a2edb31ee6b9780fa551fd04b79dffcd2602060135492604051908152a2565b81613aec91612872565b38613ab0565b634e487b7160e01b82526011600452602482fdfe59025468c1ca9e7ccfc63ddd68950d1c78cdeca982ae691697d089b592b87ad3a264697066735822122080e4f39d56193ef9b912c806a67e5ad855fd5b20416b53b3b6a98f12ac6caa3464736f6c634300081a0033

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.