false
true
0

Contract Address Details

0x458F5221b63429aF7d21eD3fC15775d067d8a1FC

Contract Name
StreamingRewardsV5
Creator
0x756639–797eec at 0xdc72a1–ac81d0
Balance
0 PLS ( )
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
26178229
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
StreamingRewardsV5




Optimization enabled
true
Compiler version
v0.8.34+commit.80d5c536




Optimization runs
200
EVM Version
osaka




Verified at
2026-04-01T23:06:56.503752Z

Constructor Arguments

00000000000000000000000017e7b189982d8df2539d059b46467a09a7bcb91d000000000000000000000000d7a138d66251ec49333e6a2c4b50781e7f49702d000000000000000000000000a96bcbed7f01de6ceed14fc86d90f21a36de2143000000000000000000000000956f90d84d9dd5ac0efa39679e6fa75d4ca8c934000000000000000000000000756639c761e228143780e022a175325d79797eec

Arg [0] (address) : 0x17e7b189982d8df2539d059b46467a09a7bcb91d
Arg [1] (address) : 0xd7a138d66251ec49333e6a2c4b50781e7f49702d
Arg [2] (address) : 0xa96bcbed7f01de6ceed14fc86d90f21a36de2143
Arg [3] (address) : 0x956f90d84d9dd5ac0efa39679e6fa75d4ca8c934
Arg [4] (address) : 0x756639c761e228143780e022a175325d79797eec

              

contracts/AER/StreamingRewardsV5.sol

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

import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";

// ─────────────────────────────────────────────────────────────────────────────
//  StreamingRewardsV5
//
//  ARCHITECTURE
//  ────────────
//  • Rate-based: every boosted second earns (baseRate × boostMultiplier) tokens
//  • Continuous accumulation: oracle pushes deltas every ~60s, user sees live balance
//  • Casino layer: on-chain RNG applies session multipliers (1x/2x/5x/10x)
//  • Proportional fallback: if pool is low, reward scales down gracefully — never stops
//  • Weekly jackpot: oracle settles weekly via distributeWeeklyJackpot()
//  • Fully frontend-friendly: getUserDashboard() returns everything in one call
//
//  ORACLE FLOW
//  ───────────
//  Every ~60s oracle calls updateStream(user, deltaSeconds, boostedDelta, token,
//                                       sessionId, nonce, signature)
//  Contract:
//    1. Verifies signature
//    2. Computes gross reward = boostedDelta × baseRate
//    3. Applies proportional fallback if pool low
//    4. Calls RNG for session multiplier (legendary/rare/uncommon/base)
//    5. Adds to pendingRewards[user][token]
//    6. Updates weeklyBoostedSeconds[user] (oracle uses for leaderboard)
//    7. Updates streak
//
//  USER CLAIM FLOW
//  ───────────────
//  User calls claim(token) or claimAll() at any time
//  Taxes applied on claim: noExpectationsTax → creatorAddress, incentiveBps → jackpotPool
// ─────────────────────────────────────────────────────────────────────────────

interface IKEYStaking {
    function getBoostBps(address user) external view returns (uint256 boostBps);
    function getTierId(address user) external view returns (uint8 tierId);
}

interface IRNG {
    function Generate() external returns (uint64);
}

interface IPulseXRouter {
    function getAmountsOut(uint256 amountIn, address[] calldata path)
        external view returns (uint256[] memory amounts);
}

contract StreamingRewardsV5 is Ownable, ReentrancyGuard {
    using SafeERC20 for IERC20;
    using ECDSA for bytes32;
    using MessageHashUtils for bytes32;

    // ─── Constants ───────────────────────────────────────────────────────────

    // ── Truly immutable (math/security primitives) ───────────────────────────
    uint256 public constant BPS_DENOMINATOR    = 10000;
    uint256 public constant SECONDS_PER_WEEK   = 604800;
    uint256 public constant MAX_TAX_BPS        = 5000;   // hard ceiling 50%

    // ── Configurable by owner after deployment ────────────────────────────────
    uint256 public signatureWindow    = 600;      // 10 min — setSignatureWindow()
    uint256 public oracleChangeDelay  = 172800;   // 48h    — setOracleChangeDelay()
    uint256 public runwayWarningSecs  = 86400;    // 24h    — setRunwayWarning()

    // RNG thresholds (out of 10000) — setRNGThresholds()
    uint256 public legendaryThreshold = 10;    // 0.1%  → legendaryMultiplierBps
    uint256 public rareThreshold      = 60;    // 0.5%  → rareMultiplierBps
    uint256 public uncommonThreshold  = 260;   // 2.0%  → uncommonMultiplierBps

    // RNG multipliers in bps (10000 = 1x) — setRNGMultipliers()
    uint256 public legendaryMultiplierBps = 100000; // 10x
    uint256 public rareMultiplierBps      = 50000;  // 5x
    uint256 public uncommonMultiplierBps  = 20000;  // 2x

    // ─── Token Pool ──────────────────────────────────────────────────────────

    struct TokenPool {
        uint256 balance;            // current pool balance
        uint256 totalFunded;        // all-time funded
        uint256 totalDistributed;   // all-time paid out
        uint256 cachedTokensPerUSD; // how many token units = 1 USD (1e18 precision), updated by oracle
        uint256 lastPriceUpdate;    // timestamp of last price refresh
        uint8   decimals;
        bool    isActive;
    }

    address[]                      public supportedTokens;
    mapping(address => TokenPool)  public pools;
    mapping(address => bool)       public isSupported;

    // ─── USD Rate Config ─────────────────────────────────────────────────────

    // baseRateUSD: tokens earned per boosted second expressed in USD (1e18 = $1)
    // e.g. 1e15 = $0.001/sec → $0.06/min → ~$0.18 per 3-min session at base rate
    uint256 public baseRateUSD = 1e15; // $0.001 per boosted second — setBaseRateUSD()

    // Router for price discovery — PulseX
    address public constant PULSEX_ROUTER = 0x165C3410fC91EF562C50559f7d2289fEbed552d9;
    address public constant WPLS          = 0xA1077a294dDE1B09bB078844df40758a5D0f9a27;
    address public constant EDAI          = 0xefD766cCb38EaF1dfd701853BFCe31359239F305;

    // Price cache staleness threshold — oracle should refresh more frequently
    uint256 public priceStalenessThreshold = 3600; // 1 hour

    // ─── User State ──────────────────────────────────────────────────────────

    // pendingRewards[user][token] — claimable balance accumulating on-chain
    mapping(address => mapping(address => uint256)) public pendingRewards;

    // weeklyBoostedSeconds[user] — resets each week, oracle uses for leaderboard
    mapping(address => uint256) public weeklyBoostedSeconds;

    // lifetimeEarned[user][token]
    mapping(address => mapping(address => uint256)) public lifetimeEarned;

    // totalLifetimeBoostedSeconds[user]
    mapping(address => uint256) public totalLifetimeBoostedSeconds;

    // nonces[user] — replay protection
    mapping(address => uint256) public userNonces;

    // preferredToken[user]
    mapping(address => address) public preferredToken;

    // ─── Streak ──────────────────────────────────────────────────────────────

    struct StreakInfo {
        uint256 streakDays;
        uint256 lastStreamDay;     // unix day (timestamp / 86400)
        uint256 streakMultiplierBps; // additional bps on top of base 10000
        uint256 shields;
        uint256 totalDaysStreamed;
    }
    mapping(address => StreakInfo) public streaks;

    // Streak multiplier phases (bps per day)
    uint256 public streakPhase1BpsPerDay = 100;  // days 1-7:   +1%/day
    uint256 public streakPhase2BpsPerDay = 50;   // days 8-30:  +0.5%/day
    uint256 public streakPhase3BpsPerDay = 25;   // days 31-180: +0.25%/day
    uint256 public streakMaxBps          = 5400; // cap at ~54% (day 180)

    // ─── Weekly Jackpot ──────────────────────────────────────────────────────

    uint256 public weeklyJackpotPool;       // MEFI accumulated this week
    uint256 public weekNumber;              // increments on settlement
    uint256 public lastJackpotSettlement;   // timestamp of last settlement
    uint256 public minJackpotSize;          // rolls over if below this

    // jackpot funded by incentive carve on claims
    address public jackpotToken;            // MEFI

    // Legend staker pool — % of jackpot split equally among active Legend stakers
    uint256 public legendPoolBps = 500;     // 5% default — setLegendPoolBps()
    address[] public legendStakerList;      // maintained by oracle via syncLegendStakers()
    mapping(address => bool) public isLegendStaker;
    uint8   public legendTierId = 3;        // tier ID for Legend in KEYStaking

    // ─── Taxes ───────────────────────────────────────────────────────────────

    uint256 public noExpectationsTaxBps = 1000; // 10% → taxRecipient (helper wallet → swaps to MEFI for creator)
    uint256 public incentiveBps         = 500;  // 5%  → jackpot pool

    // taxRecipient: receives noExpectationsTax, swaps to eDAI, calls depositTax(creator)
    // This preserves the V4 oracle flow — helper wallet handles the swap, creator gets MEFI
    address public taxRecipient;         // set via setTaxRecipient() — oracle helper wallet address

    // incentiveTaxRecipient: receives incentiveBps tax, swaps to eDAI,
    // calls depositTax(thisContract) → MEFI minted into weeklyJackpotPool via notifyMefiReceived
    address public incentiveTaxRecipient; // set via setIncentiveTaxRecipient()

    // ─── External Contracts ──────────────────────────────────────────────────

    IKEYStaking public keyStaking;
    IRNG        public rngContract;

    // ─── Oracle Signer (with timelock) ───────────────────────────────────────

    address public oracleSigner;
    address public pendingOracleSigner;
    uint256 public oracleSignerChangeTime;

    // ─── Pause ───────────────────────────────────────────────────────────────

    bool public paused;

    // ─── Events ──────────────────────────────────────────────────────────────

    event RewardAccumulated(
        address indexed user,
        address indexed token,
        uint256 baseAmount,
        uint256 finalAmount,
        uint256 multiplier,   // 10000 = 1x, 20000 = 2x, etc
        bool    isLegendary
    );
    event RewardClaimed(
        address indexed user,
        address indexed token,
        uint256 amount,
        address creatorAddress
    );
    event StreamUpdated(
        address indexed user,
        uint256 boostedDelta,
        uint256 weeklyTotal,
        uint256 streakDays
    );
    event LegendarySession(
        address indexed user,
        address indexed token,
        uint256 amount,
        uint256 sessionId
    );
    event WeeklyJackpotDistributed(
        address[] winners,
        uint256[] amounts,
        uint256   weekNumber,
        uint256   totalPaid
    );
    event WeeklyJackpotRolledOver(uint256 amount, uint256 newTotal);
    event JackpotFunded(uint256 amount, uint256 newTotal);
    event TokenAdded(address indexed token, uint256 initialPrice, uint8 decimals);
    event TokenRateChanged(address indexed token, uint256 oldRate, uint256 newRate);
    event TokenActiveChanged(address indexed token, bool isActive);
    event PoolFunded(address indexed token, uint256 amount, uint256 newBalance, uint256 runwaySeconds);
    event StreakUpdated(address indexed user, uint256 streakDays, uint256 multiplierBps);
    event StreakMilestone(address indexed user, uint256 day, uint256 shieldsEarned);
    event DedicatedListener(address indexed user, address indexed topArtist, uint256 streakDays, uint256 timestamp);
    event OracleSignerProposed(address indexed proposed, uint256 executeAfter);
    event OracleSignerChanged(address indexed oldSigner, address indexed newSigner);

    // ─── Constructor ─────────────────────────────────────────────────────────

    constructor(
        address _oracleSigner,
        address _keyStaking,
        address _rngContract,
        address _jackpotToken,
        address initialOwner
    ) Ownable(initialOwner) {
        oracleSigner  = _oracleSigner;
        keyStaking    = IKEYStaking(_keyStaking);
        rngContract   = IRNG(_rngContract);
        jackpotToken  = _jackpotToken;
        lastJackpotSettlement = block.timestamp;
        weekNumber    = 1;
        minJackpotSize = 1e18; // 1 MEFI minimum to pay out
        taxRecipient          = 0xFf27fBF6fd7D68aF82473F68ebC665d2EacceAEC;
        incentiveTaxRecipient = 0x382ac15bc6F625B0738B8187154e7A8D932009Cc;

        // ── Pre-register all supported tokens ─────────────────────────────────
        // Base rates are conservative placeholders (tokens per boosted second).
        // Adjust per-token post-deploy with setTokenRate() once pool sizes
        // and token prices are known. Target: meaningful reward per 3-min session.
        //
        // 8-decimal tokens:  1e4  / sec = 0.0001 tokens/sec
        // 18-decimal tokens: 1e14 / sec = 0.0001 tokens/sec
        // Both scale to ~0.018 tokens per 3-min session at base rate (no boost).

        _registerToken(0x92337f43FB462163869342E72538744E030EAF55, 8);  // AER
        _registerToken(0x644F10dF242b43F3de45FCb3f6Ef8526fb5fdF71, 8);  // KEY
        _registerToken(0x9A28F76c18eE03E65EA6703AbAec77c1b99ddF31, 18); // SINEZ
        _registerToken(0xA1077a294dDE1B09bB078844df40758a5D0f9a27, 18); // WPLS
        _registerToken(0x2b591e99afE9f32eAA6214f7B7629768c40Eeb39, 8);  // PHEX
        _registerToken(0x95B303987A60C71504D99Aa1b13B4DA07b0790ab, 18); // PLSX
        _registerToken(0x2fa878Ab3F87CC1C9737Fc071108F904c0B0C95d, 18); // INC
        _registerToken(0x94534EeEe131840b1c0F61847c572228bdfDDE93, 18); // PTGC
        _registerToken(0x456548A9B56eFBbD89Ca0309edd17a9E20b04018, 18); // UFO
        _registerToken(0xcd1094C07F2dCF774cB0576E4E6C19c1319a3033, 18); // RMX
        _registerToken(0xF6f8Db0aBa00007681F8fAF16A0FDa1c9B030b11, 18); // PRVX
        _registerToken(0xec4252e62C6dE3D655cA9Ce3AfC12E553ebBA274, 18); // PUMP
        _registerToken(0x6B175474E89094C44Da98b954EedeAC495271d0F, 18); // PDAI
        _registerToken(0x57fde0a71132198BBeC939B98976993d8D89D225, 8);  // EHEX
        _registerToken(0xefD766cCb38EaF1dfd701853BFCe31359239F305, 18); // EDAI
        _registerToken(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599, 8);  // PWBTC
        _registerToken(0xCc78A0acDF847A2C1714D2A925bB4477df5d48a6, 18); // ATROPA
    }

    /// @dev Internal helper used only by constructor to register tokens without
    ///      the onlyOwner check (constructor runs as deployer = owner anyway).
    function _registerToken(address token, uint8 decimals) internal {
        supportedTokens.push(token);
        isSupported[token] = true;
        pools[token] = TokenPool({
            balance:           0,
            totalFunded:       0,
            totalDistributed:  0,
            cachedTokensPerUSD: 0,
            lastPriceUpdate:   0,
            decimals:          decimals,
            isActive:          true
        });
        emit TokenAdded(token, 0, decimals);
    }

    // ─────────────────────────────────────────────────────────────────────────
    //  ORACLE — updateStream
    // ─────────────────────────────────────────────────────────────────────────

    /**
     * @notice Oracle calls this every ~60s with accumulated streaming delta.
     * @param user           Streamer address
     * @param deltaSeconds   Raw seconds streamed since last update
     * @param boostedDelta   Seconds × boostMultiplier (oracle applies KEY boost)
     * @param token          User's preferred reward token
     * @param creatorAddress Creator of currently playing track (for tax routing)
     * @param sessionId      Unique session ID for RNG seed
     * @param nonce          Next expected nonce for this user
     * @param signature      Oracle signature over packed params
     */
    function updateStream(
        address user,
        uint256 deltaSeconds,
        uint256 boostedDelta,
        address token,
        address creatorAddress,
        uint256 sessionId,
        uint256 nonce,
        bytes   calldata signature
    ) external nonReentrant {
        require(!paused, "Paused");
        require(isSupported[token], "Bad token");
        require(pools[token].isActive, "Inactive");
        require(boostedDelta > 0, "Zero delta");
        require(nonce == userNonces[user] + 1, "Bad nonce");

        _verifySignature(user, deltaSeconds, boostedDelta, token, creatorAddress, sessionId, nonce, signature);
        userNonces[user] = nonce;

        _processReward(user, token, boostedDelta, sessionId);

        weeklyBoostedSeconds[user]        += boostedDelta;
        totalLifetimeBoostedSeconds[user] += boostedDelta;

        _updateStreak(user, deltaSeconds);

        if (preferredToken[user] != token) preferredToken[user] = token;

        emit StreamUpdated(user, boostedDelta, weeklyBoostedSeconds[user], streaks[user].streakDays);
    }

    function _verifySignature(
        address user,
        uint256 deltaSeconds,
        uint256 boostedDelta,
        address token,
        address creatorAddress,
        uint256 sessionId,
        uint256 nonce,
        bytes calldata signature
    ) internal view {
        uint256 window = block.timestamp / signatureWindow;
        bytes32 msgHash = keccak256(abi.encode(
            user, deltaSeconds, boostedDelta,
            token, creatorAddress, sessionId,
            nonce, window
        ));
        address signer = msgHash.toEthSignedMessageHash().recover(signature);
        require(signer == oracleSigner, "Bad sig");
    }

    function _processReward(
        address user,
        address token,
        uint256 boostedDelta,
        uint256 sessionId
    ) internal {
        TokenPool storage pool = pools[token];
        if (pool.cachedTokensPerUSD == 0) return; // price not yet set by oracle

        // grossReward = boostedDelta (seconds) × baseRateUSD ($/sec) × tokensPerUSD
        // baseRateUSD is 1e18-scaled, cachedTokensPerUSD is tokens per 1 USD (1e18-scaled)
        // result is in token's native decimals
        // baseRateUSD: USD per second, 1e18-scaled (e.g. 1e15 = $0.001/sec)
        // cachedTokensPerUSD: token wei per 1 USD (router output for 1e18 eDAI input)
        //   → already in native token decimals, so divide by 1e18 only
        uint256 grossReward = (boostedDelta * baseRateUSD * pool.cachedTokensPerUSD) / 1e18 / 1e18;
        if (grossReward == 0) return;

        // Proportional fallback
        uint256 netReward = grossReward > pool.balance ? pool.balance : grossReward;
        if (netReward == 0) return;

        // RNG multiplier
        uint256 multiplierBps = 10000;
        bool isLegendary = false;
        if (address(rngContract) != address(0)) {
            try rngContract.Generate() returns (uint64 rand) {
                uint256 roll = uint256(rand) % 10000;
                if (roll < legendaryThreshold) {
                    multiplierBps = legendaryMultiplierBps;
                    isLegendary   = true;
                } else if (roll < rareThreshold) {
                    multiplierBps = rareMultiplierBps;
                } else if (roll < uncommonThreshold) {
                    multiplierBps = uncommonMultiplierBps;
                }
            } catch {}
        }

        uint256 finalReward = (netReward * multiplierBps) / 10000;
        if (finalReward > pool.balance) finalReward = pool.balance;
        if (finalReward == 0) return;

        pool.balance          -= finalReward;
        pool.totalDistributed += finalReward;
        pendingRewards[user][token] += finalReward;
        lifetimeEarned[user][token] += finalReward;

        emit RewardAccumulated(user, token, grossReward, finalReward, multiplierBps, isLegendary);
        if (isLegendary) emit LegendarySession(user, token, finalReward, sessionId);
    }

    // ─────────────────────────────────────────────────────────────────────────
    //  STREAK
    // ─────────────────────────────────────────────────────────────────────────

    function _updateStreak(address user, uint256 deltaSeconds) internal {
        if (deltaSeconds == 0) return;

        StreakInfo storage s = streaks[user];
        uint256 today = block.timestamp / 86400;

        if (s.lastStreamDay == today) return; // already counted today

        uint256 yesterday = today - 1;

        if (s.lastStreamDay == 0) {
            // First ever stream
            s.streakDays = 1;
            s.streakMultiplierBps = streakPhase1BpsPerDay;
        } else if (s.lastStreamDay == yesterday) {
            // Consecutive day
            s.streakDays++;
            s.streakMultiplierBps = _computeStreakBps(s.streakDays);
        } else {
            // Missed at least one day
            if (s.shields > 0) {
                // One shield absorbs one missed day — only works if exactly one day missed
                uint256 daysMissed = today - s.lastStreamDay - 1;
                if (daysMissed == 1) {
                    s.shields--;
                    s.streakDays++;
                    s.streakMultiplierBps = _computeStreakBps(s.streakDays);
                } else {
                    // Missed multiple days — shields can't help, streak resets
                    s.streakDays = 1;
                    s.streakMultiplierBps = streakPhase1BpsPerDay;
                }
            } else {
                // No shield — streak resets immediately
                s.streakDays = 1;
                s.streakMultiplierBps = streakPhase1BpsPerDay;
            }
        }

        s.lastStreamDay = today;
        s.totalDaysStreamed++;

        // Check milestones
        _checkStreakMilestones(user, s.streakDays);

        emit StreakUpdated(user, s.streakDays, s.streakMultiplierBps);
    }

    function _computeStreakBps(uint256 streakDay) internal view returns (uint256) {
        uint256 bps = 0;
        if (streakDay <= 7) {
            bps = streakDay * streakPhase1BpsPerDay;
        } else if (streakDay <= 30) {
            bps = 7 * streakPhase1BpsPerDay + (streakDay - 7) * streakPhase2BpsPerDay;
        } else {
            bps = 7 * streakPhase1BpsPerDay
                + 23 * streakPhase2BpsPerDay
                + (streakDay - 30) * streakPhase3BpsPerDay;
        }
        return bps > streakMaxBps ? streakMaxBps : bps;
    }

    function _checkStreakMilestones(address user, uint256 day) internal {
        StreakInfo storage s = streaks[user];
        // Milestone days earn a streak shield
        if (day == 7 || day == 30 || day == 90 || day == 180) {
            s.shields++;
            if (s.shields > 3) s.shields = 3; // max 3 shields
            emit StreakMilestone(user, day, 1);
        }
        // Day 180 — oracle calls recordDedicatedListener() separately
        // with the user's actual top artist computed from lifetime streaming data
    }

    // ─────────────────────────────────────────────────────────────────────────
    //  CLAIM
    // ─────────────────────────────────────────────────────────────────────────

    /**
     * @notice Claim accumulated rewards for a specific token.
     *         Called automatically by the oracle at session end via claimFor().
     *         Users can also call this manually at any time.
     * @param token          Token to claim
     * @param creatorAddress Creator address for tax routing (pass address(0) if none)
     */
    function claim(address token, address creatorAddress) external nonReentrant {
        require(!paused, "Paused");
        uint256 amount = pendingRewards[msg.sender][token];
        require(amount > 0, "Empty");

        pendingRewards[msg.sender][token] = 0;

        // Apply taxes
        uint256 creatorTax = (amount * noExpectationsTaxBps) / BPS_DENOMINATOR;
        uint256 incentiveTax = (amount * incentiveBps) / BPS_DENOMINATOR;
        uint256 userAmount = amount - creatorTax - incentiveTax;

        IERC20 tokenContract = IERC20(token);

        if (userAmount > 0) {
            tokenContract.safeTransfer(msg.sender, userAmount);
        }
        if (creatorTax > 0) {
            address taxDest = (taxRecipient != address(0)) ? taxRecipient : creatorAddress;
            if (taxDest != address(0)) tokenContract.safeTransfer(taxDest, creatorTax);
        }
        // incentive tax → incentiveTaxRecipient if set, else stays in contract
        if (incentiveTax > 0 && incentiveTaxRecipient != address(0))
            tokenContract.safeTransfer(incentiveTaxRecipient, incentiveTax);

        emit RewardClaimed(msg.sender, token, userAmount, creatorAddress);
    }

    /**
     * @notice Claim all pending rewards across all supported tokens.
     */
    function claimAll(address creatorAddress) external nonReentrant {
        require(!paused, "Paused");
        for (uint256 i = 0; i < supportedTokens.length; i++) {
            address token = supportedTokens[i];
            uint256 amount = pendingRewards[msg.sender][token];
            if (amount == 0) continue;

            pendingRewards[msg.sender][token] = 0;

            uint256 creatorTax  = (amount * noExpectationsTaxBps) / BPS_DENOMINATOR;
            uint256 incentiveTax = (amount * incentiveBps) / BPS_DENOMINATOR;
            uint256 userAmount   = amount - creatorTax - incentiveTax;

            IERC20 tokenContract = IERC20(token);
            if (userAmount > 0) tokenContract.safeTransfer(msg.sender, userAmount);
            if (creatorTax > 0) {
                address taxDest = (taxRecipient != address(0)) ? taxRecipient : creatorAddress;
                if (taxDest != address(0)) tokenContract.safeTransfer(taxDest, creatorTax);
            }

            emit RewardClaimed(msg.sender, token, userAmount, creatorAddress);
        }
    }

    /**
     * @notice Oracle calls this at session end to automatically push rewards
     *         to the user's wallet. Users never need to claim manually —
     *         this is called on their behalf when STREAM_STOPPED fires.
     * @param user           Streamer to pay out
     * @param token          Token to claim
     * @param creatorAddress Creator of the last track played (for tax routing)
     */
    function claimFor(
        address user,
        address token,
        address creatorAddress
    ) external nonReentrant {
        require(msg.sender == oracleSigner || msg.sender == owner(), "Auth");
        require(!paused, "Paused");
        uint256 amount = pendingRewards[user][token];
        if (amount == 0) return;

        pendingRewards[user][token] = 0;

        uint256 creatorTax   = (amount * noExpectationsTaxBps) / BPS_DENOMINATOR;
        uint256 incentiveTax = (amount * incentiveBps) / BPS_DENOMINATOR;
        uint256 userAmount   = amount - creatorTax - incentiveTax;

        IERC20 t = IERC20(token);
        if (userAmount > 0)  t.safeTransfer(user, userAmount);
        if (creatorTax > 0) {
            address taxDest = (taxRecipient != address(0)) ? taxRecipient : creatorAddress;
            if (taxDest != address(0)) t.safeTransfer(taxDest, creatorTax);
        }
        if (incentiveTax > 0 && incentiveTaxRecipient != address(0))
            t.safeTransfer(incentiveTaxRecipient, incentiveTax);

        emit RewardClaimed(user, token, userAmount, creatorAddress);
    }

    /**
     * @notice Oracle calls this to auto-claim all tokens for a user at session end.
     */
    function claimAllFor(
        address user,
        address creatorAddress
    ) external nonReentrant {
        require(msg.sender == oracleSigner || msg.sender == owner(), "Auth");
        require(!paused, "Paused");
        for (uint256 i = 0; i < supportedTokens.length; i++) {
            address token = supportedTokens[i];
            uint256 amount = pendingRewards[user][token];
            if (amount == 0) continue;

            pendingRewards[user][token] = 0;

            uint256 creatorTax   = (amount * noExpectationsTaxBps) / BPS_DENOMINATOR;
            uint256 incentiveTax = (amount * incentiveBps) / BPS_DENOMINATOR;
            uint256 userAmount   = amount - creatorTax - incentiveTax;

            IERC20 t = IERC20(token);
            if (userAmount > 0) t.safeTransfer(user, userAmount);
            if (creatorTax > 0) {
                address taxDest = (taxRecipient != address(0)) ? taxRecipient : creatorAddress;
                if (taxDest != address(0)) t.safeTransfer(taxDest, creatorTax);
            }
            if (incentiveTax > 0 && incentiveTaxRecipient != address(0))
                t.safeTransfer(incentiveTaxRecipient, incentiveTax);

            emit RewardClaimed(user, token, userAmount, creatorAddress);
        }
    }

    // ─────────────────────────────────────────────────────────────────────────
    //  WEEKLY JACKPOT — oracle-settled
    // ─────────────────────────────────────────────────────────────────────────

    /**
     * @notice Oracle calls this each Sunday with the top streamers.
     *         Contract enforces the legend staker split on-chain —
     *         oracle only computes the competitive leaderboard portion.
     *
     *         Flow:
     *         1. legendPoolBps (5%) split equally among active Legend stakers
     *            — verified on-chain via KEYStaking.getTierId()
     *         2. Remaining 95% paid to top streamers per oracle-supplied amounts
     *
     * @param winners  Top streamer addresses in rank order (oracle-computed)
     * @param amounts  MEFI amounts for each winner (oracle-computed, from 95% pool)
     */
    function distributeWeeklyJackpot(
        address[] calldata winners,
        uint256[] calldata amounts
    ) external nonReentrant {
        require(msg.sender == oracleSigner || msg.sender == owner(), "Auth");
        require(winners.length == amounts.length, "Mismatch");
        require(winners.length > 0, "No winners");
        require(block.timestamp >= lastJackpotSettlement + 6 days, "Too soon");

        if (weeklyJackpotPool < minJackpotSize) {
            emit WeeklyJackpotRolledOver(weeklyJackpotPool, weeklyJackpotPool);
            lastJackpotSettlement = block.timestamp;
            weekNumber++;
            _resetWeeklySeconds(winners);
            return;
        }

        IERC20 mefi = IERC20(jackpotToken);

        // ── Legend staker split (on-chain enforced) ───────────────────────────
        uint256 legendPool = (weeklyJackpotPool * legendPoolBps) / BPS_DENOMINATOR;
        uint256 activeLegendCount = _countActiveLegendStakers();

        if (legendPool > 0 && activeLegendCount > 0) {
            uint256 perLegend = legendPool / activeLegendCount;
            if (perLegend > 0) {
                for (uint256 i = 0; i < legendStakerList.length; i++) {
                    address staker = legendStakerList[i];
                    if (!_isActiveLegend(staker)) continue;
                    weeklyJackpotPool -= perLegend;
                    mefi.safeTransfer(staker, perLegend);
                }
            }
        }

        // ── Competitive leaderboard payout ────────────────────────────────────
        uint256 totalPayout = 0;
        for (uint256 i = 0; i < amounts.length; i++) totalPayout += amounts[i];

        require(totalPayout <= weeklyJackpotPool, "Exceeds pool");

        for (uint256 i = 0; i < winners.length; i++) {
            if (amounts[i] > 0 && winners[i] != address(0)) {
                weeklyJackpotPool -= amounts[i];
                mefi.safeTransfer(winners[i], amounts[i]);
            }
        }

        emit WeeklyJackpotDistributed(winners, amounts, weekNumber, totalPayout);
        lastJackpotSettlement = block.timestamp;
        weekNumber++;
        _resetWeeklySeconds(winners);
    }

    function _countActiveLegendStakers() internal view returns (uint256 count) {
        for (uint256 i = 0; i < legendStakerList.length; i++) {
            if (_isActiveLegend(legendStakerList[i])) count++;
        }
    }

    function _isActiveLegend(address staker) internal view returns (bool) {
        if (address(keyStaking) == address(0)) return false;
        try keyStaking.getTierId(staker) returns (uint8 tierId) {
            return tierId == legendTierId;
        } catch {
            return false;
        }
    }

    function _resetWeeklySeconds(address[] calldata users) internal {
        for (uint256 i = 0; i < users.length; i++) {
            weeklyBoostedSeconds[users[i]] = 0;
        }
    }

    /**
     * @notice Oracle syncs the legend staker list on-chain.
     *         Called after scanning KEYStaking Staked/Restaked events.
     *         Contract re-verifies each address at payout time via getTierId.
     */
    function syncLegendStakers(address[] calldata stakers) external {
        require(msg.sender == oracleSigner || msg.sender == owner(), "Auth");
        // Clear and rebuild
        for (uint256 i = 0; i < legendStakerList.length; i++) {
            isLegendStaker[legendStakerList[i]] = false;
        }
        delete legendStakerList;
        for (uint256 i = 0; i < stakers.length; i++) {
            if (!isLegendStaker[stakers[i]]) {
                legendStakerList.push(stakers[i]);
                isLegendStaker[stakers[i]] = true;
            }
        }
    }

    /**
     * @notice Oracle calls this when a user reaches day 180 streak,
     *         passing their all-time most-streamed artist address.
     *         Oracle computes topArtist from its own lifetime creator tracking.
     *         Emits a permanent on-chain DedicatedListener record.
     */
    /**
     * @notice Oracle calls this to record (or update) a user's most-streamed artist.
     *         Can be called anytime — oracle tracks lifetime boosted seconds per
     *         creator per user and calls this when the top artist changes.
     *         Emits a permanent on-chain record of who this user listens to most.
     */
    function recordDedicatedListener(address user, address topArtist) external {
        require(msg.sender == oracleSigner || msg.sender == owner(), "Auth");
        require(topArtist != address(0), "Bad artist");
        emit DedicatedListener(user, topArtist, streaks[user].streakDays, block.timestamp);
    }

    /**
     * @notice Fund the weekly jackpot pool (oracle deposits MEFI here).
     *         All MEFI arriving via the creator tax flow goes here.
     *         This is the single MEFI pool — no separate incentive reserve.
     *         Streak milestones reward shields. RNG handles surprise bonuses.
     *         MEFI is reserved for weekly leaderboard winners only.
     */
    function fundJackpot(uint256 amount) external {
        IERC20(jackpotToken).safeTransferFrom(msg.sender, address(this), amount);
        weeklyJackpotPool += amount;
        emit JackpotFunded(amount, weeklyJackpotPool);
    }

    /**
     * @notice Drop-in replacement for V4's notifyMefiReceived().
     *         Oracle's existing watchMefiArrivals watcher can call this
     *         unchanged — no oracle code changes needed.
     *         Simply routes all incoming MEFI to the jackpot pool.
     */
    function notifyMefiReceived(uint256 amount) external {
        require(msg.sender == oracleSigner || msg.sender == owner(), "Auth");
        // MEFI already sitting in contract from transfer — just account for it
        weeklyJackpotPool += amount;
        emit JackpotFunded(amount, weeklyJackpotPool);
    }

    // ─────────────────────────────────────────────────────────────────────────
    //  TOKEN POOL MANAGEMENT
    // ─────────────────────────────────────────────────────────────────────────

    function addSupportedToken(
        address token,
        uint8   decimals
    ) external onlyOwner {
        require(!isSupported[token], "Exists");
        require(token != address(0), "Zero addr");

        supportedTokens.push(token);
        isSupported[token] = true;
        pools[token] = TokenPool({
            balance:            0,
            totalFunded:        0,
            totalDistributed:   0,
            cachedTokensPerUSD: 0,
            lastPriceUpdate:    0,
            decimals:           decimals,
            isActive:           true
        });

        emit TokenAdded(token, 0, decimals);
    }

    // ── USD Rate & Price Management ──────────────────────────────────────────

    function setBaseRateUSD(uint256 _rateUSD) external onlyOwner {
        require(_rateUSD > 0, "Bad rate");
        baseRateUSD = _rateUSD;
    }

    function setPriceStalenessThreshold(uint256 _seconds) external onlyOwner {
        priceStalenessThreshold = _seconds;
    }

    /**
     * @notice Oracle calls this to update the cached price for a single token.
     *         cachedTokensPerUSD = how many token units you get for $1 USD.
     *         Oracle computes this off-chain via PulseX router:
     *           path: eDAI → WPLS → token (or eDAI → token for direct pairs)
     *           amountOut for 1e18 eDAI = tokensPerUSD
     *         Storing oracle-computed price avoids on-chain router calls in updateStream.
     * @param token         Token address
     * @param tokensPerUSD  Token units received for 1 USD (1e18 eDAI input)
     */
    function refreshTokenPrice(address token, uint256 tokensPerUSD) external {
        require(msg.sender == oracleSigner || msg.sender == owner(), "Auth");
        require(isSupported[token], "Not supported");
        require(tokensPerUSD > 0, "Bad price");
        pools[token].cachedTokensPerUSD = tokensPerUSD;
        pools[token].lastPriceUpdate    = block.timestamp;
        emit TokenRateChanged(token, 0, tokensPerUSD);
    }

    /**
     * @notice Batch price update for all tokens — oracle calls this once per hour.
     * @param tokens       Array of token addresses
     * @param prices       Corresponding tokensPerUSD values
     */
    function refreshAllTokenPrices(
        address[] calldata tokens,
        uint256[] calldata prices
    ) external {
        require(msg.sender == oracleSigner || msg.sender == owner(), "Auth");
        require(tokens.length == prices.length, "Mismatch");
        for (uint256 i = 0; i < tokens.length; i++) {
            if (!isSupported[tokens[i]] || prices[i] == 0) continue;
            pools[tokens[i]].cachedTokensPerUSD = prices[i];
            pools[tokens[i]].lastPriceUpdate    = block.timestamp;
            emit TokenRateChanged(tokens[i], 0, prices[i]);
        }
    }

    function setTokenActive(address token, bool active) external onlyOwner {
        require(isSupported[token], "Not supported");
        pools[token].isActive = active;
        emit TokenActiveChanged(token, active);
    }

    function fundPool(address token, uint256 amount) external {
        require(isSupported[token], "Not supported");
        IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
        pools[token].balance      += amount;
        pools[token].totalFunded  += amount;

        uint256 rate = pools[token].cachedTokensPerUSD > 0
            ? (baseRateUSD * pools[token].cachedTokensPerUSD) / 1e18 / 1e18 : 0;
        uint256 runway = rate > 0 ? pools[token].balance / rate : type(uint256).max;

        emit PoolFunded(token, amount, pools[token].balance, runway);
    }

    /**
     * @notice Sync all pool balances to actual token balances held by contract.
     *         Use when tokens are sent directly to the contract (not via fundPool).
     *         Scans every supported token, credits any unaccounted balance into
     *         the pool. Safe to call anytime — never reduces a pool balance.
     *         Called by BatchBuyer after funding, or by owner after direct transfers.
     */
    function syncAllPoolBalances() external onlyOwner {
        for (uint256 i = 0; i < supportedTokens.length; i++) {
            address token = supportedTokens[i];
            uint256 actual  = IERC20(token).balanceOf(address(this));
            uint256 tracked = pools[token].balance;

            if (actual > tracked) {
                uint256 delta = actual - tracked;
                pools[token].balance     += delta;
                pools[token].totalFunded += delta;

                uint256 _rate = pools[token].cachedTokensPerUSD > 0
                    ? (baseRateUSD * pools[token].cachedTokensPerUSD) / 1e18 / 1e18 : 0;
                uint256 runway = _rate > 0 ? pools[token].balance / _rate : type(uint256).max;

                emit PoolFunded(token, delta, pools[token].balance, runway);
            }
        }
    }

    /**
     * @notice Sync a single token pool balance to actual contract holdings.
     *         More gas efficient when only one token was sent directly.
     */
    function syncPoolBalance(address token) external {
        require(isSupported[token], "Not supported");
        uint256 actual  = IERC20(token).balanceOf(address(this));
        uint256 tracked = pools[token].balance;

        if (actual > tracked) {
            uint256 delta = actual - tracked;
            pools[token].balance     += delta;
            pools[token].totalFunded += delta;

            uint256 _syncRate = pools[token].cachedTokensPerUSD > 0
                ? (baseRateUSD * pools[token].cachedTokensPerUSD) / 1e18 / 1e18 : 0;
            uint256 runway = _syncRate > 0 ? pools[token].balance / _syncRate : type(uint256).max;

            emit PoolFunded(token, delta, pools[token].balance, runway);
        }
    }

    // ─────────────────────────────────────────────────────────────────────────
    //  FRONTEND-FRIENDLY VIEW FUNCTIONS
    // ─────────────────────────────────────────────────────────────────────────

    // getUserDashboard() — see StreamingRewardsV5Lens.sol
    // Extracted to keep main contract under 24KB limit.

        struct PoolStatus {
        address token;
        uint256 balance;
        uint256 runwaySeconds;      // balance / baseRate
        uint256 totalFunded;
        uint256 totalDistributed;
        uint8   decimals;
        bool    isActive;
        bool    runwayWarning;      // true if runway < 24h
    }

    // getAllPoolsStatus() — see StreamingRewardsV5Lens.sol

    
    /**
     * @notice Returns pools whose runway is below the warning threshold.
     *         BatchBuyer and oracle dashboard should poll this.
     */
    function getRunwayWarnings()
        external
        view
        returns (address[] memory warningTokens, uint256[] memory runwaySeconds)
    {
        uint256 n = supportedTokens.length;
        address[] memory tmpTokens  = new address[](n);
        uint256[] memory tmpRunways = new uint256[](n);
        uint256 count = 0;

        for (uint256 i = 0; i < n; i++) {
            address t = supportedTokens[i];
            TokenPool storage p = pools[t];
            if (!p.isActive) continue;
            uint256 rate = p.cachedTokensPerUSD > 0
                ? (baseRateUSD * p.cachedTokensPerUSD) / 1e18 / 1e18 : 0;
            uint256 runway = rate > 0 ? p.balance / rate : type(uint256).max;
            if (runway < runwayWarningSecs) {
                tmpTokens[count]  = t;
                tmpRunways[count] = runway;
                count++;
            }
        }

        warningTokens  = new address[](count);
        runwaySeconds  = new uint256[](count);
        for (uint256 i = 0; i < count; i++) {
            warningTokens[i] = tmpTokens[i];
            runwaySeconds[i] = tmpRunways[i];
        }
    }

    /**
     * @notice What a user earns per second right now for a given token.
     *         baseRate × (1 + keyBoost)
     *         Frontend uses this to animate the live ticking balance.
     */
    function getEarningRate(address user, address token)
        external
        view
        returns (uint256 ratePerSecond)
    {
        if (!isSupported[token] || !pools[token].isActive) return 0;
        if (pools[token].cachedTokensPerUSD == 0) return 0;

        uint256 boostBps = 0;
        if (address(keyStaking) != address(0)) {
            try keyStaking.getBoostBps(user) returns (uint256 b) { boostBps = b; } catch {}
        }

        // ratePerSecond in token units = baseRateUSD × (1 + boost) × tokensPerUSD / 1e36
        uint256 effectiveRateUSD = (baseRateUSD * (BPS_DENOMINATOR + boostBps)) / BPS_DENOMINATOR;
        ratePerSecond = (effectiveRateUSD * pools[token].cachedTokensPerUSD) / 1e18 / 1e18;
    }

    // simulateSession() — see StreamingRewardsV5Lens.sol

    
    // getPoolInfo() V5-extended signature — see StreamingRewardsV5Lens.sol
    // V4-compatible getPoolInfo is in the BATCHBUYER COMPATIBILITY section below.

    /**
     * @notice Returns the streak info for a user.
     */
    function getStreakInfo(address user) external view returns (
        uint256 streakDays,
        uint256 streakMultiplierBps,
        uint256 lastStreamDay,
        uint256 shields,
        uint256 totalDaysStreamed
    ) {
        StreakInfo storage s = streaks[user];
        return (s.streakDays, s.streakMultiplierBps, s.lastStreamDay, s.shields, s.totalDaysStreamed);
    }

    // ─────────────────────────────────────────────────────────────────────────
    //  BATCHBUYER COMPATIBILITY — V4-compatible interface
    //  GeniusBatchBuyer reads these exact signatures. Do not rename.
    // ─────────────────────────────────────────────────────────────────────────

    /**
     * @notice V4-compatible getPoolInfo for BatchBuyer compatibility.
     *         Maps V5 fields to V4 return layout:
     *         balance         → pools[token].balance
     *         totalDeposited  → pools[token].totalFunded
     *         totalDistributed→ pools[token].totalDistributed
     *         distributionRate→ computed tokens/sec at current cached price
     *         isActive        → pools[token].isActive
     *         nextDistribution→ runway in seconds (balance / baseRate)
     *         decimals        → pools[token].decimals
     */
    function getPoolInfo(address token) external view returns (
        uint256 balance,
        uint256 totalDeposited,
        uint256 totalDistributed,
        uint256 distributionRate,
        bool    isActive,
        uint256 nextDistribution,
        uint8   decimals
    ) {
        TokenPool storage p = pools[token];
        // distributionRate = base tokens per second at current price (no boost)
        uint256 rate = p.cachedTokensPerUSD > 0
            ? (baseRateUSD * p.cachedTokensPerUSD) / 1e18 / 1e18
            : 0;
        uint256 runway = rate > 0 ? p.balance / rate : type(uint256).max;
        return (
            p.balance,
            p.totalFunded,
            p.totalDistributed,
            rate,
            p.isActive,
            runway,
            p.decimals
        );
    }

    /**
     * @notice V4-compatible isTokenSupported for BatchBuyer compatibility.
     */
    function isTokenSupported(address token) external view returns (bool) {
        return isSupported[token];
    }

    /**
     * @notice getAllSupportedTokens — already used by BatchBuyer.
     */
    function getAllSupportedTokens() external view returns (address[] memory) {
        return supportedTokens;
    }

    // ─────────────────────────────────────────────────────────────────────────
    //  ADMIN
    // ─────────────────────────────────────────────────────────────────────────

    // ── RNG & Threshold Config ────────────────────────────────────────────────

    function setRNGThresholds(
        uint256 _legendaryThreshold,
        uint256 _rareThreshold,
        uint256 _uncommonThreshold
    ) external onlyOwner {
        require(_legendaryThreshold < _rareThreshold, "Bad thresh");
        require(_rareThreshold < _uncommonThreshold, "Bad thresh");
        require(_uncommonThreshold < 10000, "Must be < 10000");
        legendaryThreshold = _legendaryThreshold;
        rareThreshold      = _rareThreshold;
        uncommonThreshold  = _uncommonThreshold;
    }

    function setRNGMultipliers(
        uint256 _legendaryBps,
        uint256 _rareBps,
        uint256 _uncommonBps
    ) external onlyOwner {
        require(_legendaryBps >= _rareBps && _rareBps >= _uncommonBps, "Bad order");
        require(_uncommonBps >= 10000, "Uncommon<1x");
        legendaryMultiplierBps = _legendaryBps;
        rareMultiplierBps      = _rareBps;
        uncommonMultiplierBps  = _uncommonBps;
    }

    // ── Timing Config ─────────────────────────────────────────────────────────

    function setSignatureWindow(uint256 _seconds) external onlyOwner {
        require(_seconds >= 60 && _seconds <= 3600, "Bad window");
        signatureWindow = _seconds;
    }

    function setOracleChangeDelay(uint256 _seconds) external onlyOwner {
        require(_seconds >= 3600, "Bad delay");
        oracleChangeDelay = _seconds;
    }

    function setRunwayWarning(uint256 _seconds) external onlyOwner {
        runwayWarningSecs = _seconds;
    }

    // ── Taxes ─────────────────────────────────────────────────────────────────

    function setTaxRecipient(address _taxRecipient) external onlyOwner {
        taxRecipient = _taxRecipient;
    }

    function setIncentiveTaxRecipient(address _recipient) external onlyOwner {
        incentiveTaxRecipient = _recipient;
    }

    function setTaxes(uint256 _noExpectationsBps, uint256 _incentiveBps) external onlyOwner {
        require(_noExpectationsBps + _incentiveBps <= MAX_TAX_BPS, "Exceeds max tax");
        noExpectationsTaxBps = _noExpectationsBps;
        incentiveBps         = _incentiveBps;
    }

    function setKeyStaking(address _keyStaking) external onlyOwner {
        keyStaking = IKEYStaking(_keyStaking);
    }

    function setRNGContract(address _rng) external onlyOwner {
        rngContract = IRNG(_rng);
    }

    function setJackpotToken(address _token) external onlyOwner {
        jackpotToken = _token;
    }

    function setMinJackpotSize(uint256 _min) external onlyOwner {
        minJackpotSize = _min;
    }

    function setLegendPoolBps(uint256 _bps) external onlyOwner {
        require(_bps <= 2000, "Max 20pct");
        legendPoolBps = _bps;
    }

    function setLegendTierId(uint8 _tierId) external onlyOwner {
        legendTierId = _tierId;
    }

    function setStreakParams(
        uint256 phase1Bps,
        uint256 phase2Bps,
        uint256 phase3Bps,
        uint256 maxBps
    ) external onlyOwner {
        streakPhase1BpsPerDay = phase1Bps;
        streakPhase2BpsPerDay = phase2Bps;
        streakPhase3BpsPerDay = phase3Bps;
        streakMaxBps          = maxBps;
    }

    function setPaused(bool _paused) external onlyOwner {
        paused = _paused;
    }

    // Oracle signer with 48h timelock
    function proposeOracleSignerChange(address newSigner) external onlyOwner {
        require(newSigner != address(0), "Zero addr");
        pendingOracleSigner   = newSigner;
        oracleSignerChangeTime = block.timestamp + oracleChangeDelay;
        emit OracleSignerProposed(newSigner, oracleSignerChangeTime);
    }

    function executeOracleSignerChange() external onlyOwner {
        require(pendingOracleSigner != address(0), "No change");
        require(block.timestamp >= oracleSignerChangeTime, "Locked");
        address old = oracleSigner;
        oracleSigner        = pendingOracleSigner;
        pendingOracleSigner = address(0);
        emit OracleSignerChanged(old, oracleSigner);
    }

    function cancelOracleSignerChange() external onlyOwner {
        pendingOracleSigner = address(0);
    }

    // Rescue stuck tokens (cannot rescue active pool tokens)
    function rescueToken(address token, uint256 amount) external onlyOwner {
        // Allow rescue of pool tokens only if pool is inactive
        if (isSupported[token]) {
            require(!pools[token].isActive, "Deactivate pool first");
        }
        IERC20(token).safeTransfer(owner(), amount);
    }

    // ─────────────────────────────────────────────────────────────────────────
    //  MIGRATION — import state from V4 or any prior version
    //
    //  All migration functions are owner-only and gated by migrationOpen flag.
    //  Call setMigrationOpen(false) once migration is complete to lock forever.
    //  Migration never touches pool balances — only user state.
    // ─────────────────────────────────────────────────────────────────────────

    bool public migrationOpen = true;

    event MigrationComplete(uint256 usersImported, uint256 timestamp);
    event MigrationLocked();

    modifier onlyDuringMigration() {
        require(migrationOpen, "Locked");
        require(msg.sender == owner(), "Auth");
        _;
    }

    /**
     * @notice Lock migration permanently. Cannot be reopened.
     */
    function lockMigration() external onlyOwner {
        migrationOpen = false;
        emit MigrationLocked();
    }

    /**
     * @notice Migrate pending rewards for a batch of users.
     *         Call with V4 pendingRewards state before users claim from V5.
     */
    function migrateRewards(
        address[] calldata users,
        address[] calldata tokens,
        uint256[] calldata amounts
    ) external onlyDuringMigration {
        require(users.length == tokens.length && tokens.length == amounts.length, "Mismatch");
        for (uint256 i = 0; i < users.length; i++) {
            require(isSupported[tokens[i]], "Bad token");
            pendingRewards[users[i]][tokens[i]] += amounts[i];
            lifetimeEarned[users[i]][tokens[i]] += amounts[i];
        }
    }

    /**
     * @notice Migrate user nonces from V4 to prevent replay attacks on existing sigs.
     */
    function migrateNonces(
        address[] calldata users,
        uint256[] calldata nonces
    ) external onlyDuringMigration {
        require(users.length == nonces.length, "Mismatch");
        for (uint256 i = 0; i < users.length; i++) {
            // Only allow increasing nonces — never decrease
            if (nonces[i] > userNonces[users[i]]) {
                userNonces[users[i]] = nonces[i];
            }
        }
    }

    /**
     * @notice Migrate preferred token settings from V4.
     */
    function migratePreferences(
        address[] calldata users,
        address[] calldata tokens
    ) external onlyDuringMigration {
        require(users.length == tokens.length, "Mismatch");
        for (uint256 i = 0; i < users.length; i++) {
            if (isSupported[tokens[i]]) {
                preferredToken[users[i]] = tokens[i];
            }
        }
    }

    /**
     * @notice Migrate lifetime streaming seconds from V4.
     *         Used to preserve leaderboard history and DedicatedListener tracking.
     */
    function migrateStreamingHistory(
        address[] calldata users,
        uint256[] calldata lifetimeSecs,
        uint256[] calldata weeklySecs
    ) external onlyDuringMigration {
        require(
            users.length == lifetimeSecs.length &&
            users.length == weeklySecs.length,
            "Mismatch"
        );
        for (uint256 i = 0; i < users.length; i++) {
            totalLifetimeBoostedSeconds[users[i]] += lifetimeSecs[i];
            weeklyBoostedSeconds[users[i]]        += weeklySecs[i];
        }
    }

    /**
     * @notice Migrate pool balances from V4.
     *         Caller must have approved this contract to spend the tokens.
     *         Typically called after transferring V4 pool balances to owner wallet.
     */
    function migratePoolBalance(address token, uint256 amount) external onlyDuringMigration {
        require(isSupported[token], "Bad token");
        IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
        pools[token].balance     += amount;
        pools[token].totalFunded += amount;
        uint256 _migRate2 = pools[token].cachedTokensPerUSD > 0
            ? (baseRateUSD * pools[token].cachedTokensPerUSD) / 1e18 / 1e18 : 0;
        emit PoolFunded(token, amount, pools[token].balance,
            _migRate2 > 0 ? pools[token].balance / _migRate2 : type(uint256).max
        );
    }

    /**
     * @notice Convenience: migrate everything for a batch of users in one tx.
     *         Combines rewards + nonces + preferences + history.
     */
    struct UserMigrationData {
        address user;
        address preferredTokenAddr;
        uint256 nonce;
        uint256 lifetimeStreamSecs;
        uint256 weeklyStreamSecs;
        address[] rewardTokens;
        uint256[] rewardAmounts;
    }

    function migrateBatch(UserMigrationData[] calldata data) external onlyDuringMigration {
        for (uint256 i = 0; i < data.length; i++) {
            UserMigrationData calldata d = data[i];

            // Nonce
            if (d.nonce > userNonces[d.user]) {
                userNonces[d.user] = d.nonce;
            }

            // Preferred token
            if (d.preferredTokenAddr != address(0) && isSupported[d.preferredTokenAddr]) {
                preferredToken[d.user] = d.preferredTokenAddr;
            }

            // Streaming history
            totalLifetimeBoostedSeconds[d.user] += d.lifetimeStreamSecs;
            weeklyBoostedSeconds[d.user]        += d.weeklyStreamSecs;

            // Pending rewards per token
            require(d.rewardTokens.length == d.rewardAmounts.length, "Mismatch");
            for (uint256 j = 0; j < d.rewardTokens.length; j++) {
                if (isSupported[d.rewardTokens[j]] && d.rewardAmounts[j] > 0) {
                    pendingRewards[d.user][d.rewardTokens[j]] += d.rewardAmounts[j];
                    lifetimeEarned[d.user][d.rewardTokens[j]] += d.rewardAmounts[j];
                }
            }
        }
    }

    // ─────────────────────────────────────────────────────────────────────────
    //  SYSTEM STATUS
    // ─────────────────────────────────────────────────────────────────────────

    function getSystemStatus() external view returns (
        uint256 totalPools,
        uint256 activePools,
        uint256 jackpotBalance,
        uint256 nextJackpotTime,
        uint256 currentWeek,
        bool    isPaused
    ) {
        uint256 active = 0;
        for (uint256 i = 0; i < supportedTokens.length; i++) {
            if (pools[supportedTokens[i]].isActive) active++;
        }
        return (
            supportedTokens.length,
            active,
            weeklyJackpotPool,
            lastJackpotSettlement + SECONDS_PER_WEEK,
            weekNumber,
            paused
        );
    }
}
        

/Bytes.sol

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

pragma solidity ^0.8.24;

import {Math} from "./math/Math.sol";

/**
 * @dev Bytes operations.
 */
library Bytes {
    /**
     * @dev Forward search for `s` in `buffer`
     * * If `s` is present in the buffer, returns the index of the first instance
     * * If `s` is not present in the buffer, returns type(uint256).max
     *
     * NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf[Javascript's `Array.indexOf`]
     */
    function indexOf(bytes memory buffer, bytes1 s) internal pure returns (uint256) {
        return indexOf(buffer, s, 0);
    }

    /**
     * @dev Forward search for `s` in `buffer` starting at position `pos`
     * * If `s` is present in the buffer (at or after `pos`), returns the index of the next instance
     * * If `s` is not present in the buffer (at or after `pos`), returns type(uint256).max
     *
     * NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf[Javascript's `Array.indexOf`]
     */
    function indexOf(bytes memory buffer, bytes1 s, uint256 pos) internal pure returns (uint256) {
        uint256 length = buffer.length;
        for (uint256 i = pos; i < length; ++i) {
            if (bytes1(_unsafeReadBytesOffset(buffer, i)) == s) {
                return i;
            }
        }
        return type(uint256).max;
    }

    /**
     * @dev Backward search for `s` in `buffer`
     * * If `s` is present in the buffer, returns the index of the last instance
     * * If `s` is not present in the buffer, returns type(uint256).max
     *
     * NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf[Javascript's `Array.lastIndexOf`]
     */
    function lastIndexOf(bytes memory buffer, bytes1 s) internal pure returns (uint256) {
        return lastIndexOf(buffer, s, type(uint256).max);
    }

    /**
     * @dev Backward search for `s` in `buffer` starting at position `pos`
     * * If `s` is present in the buffer (at or before `pos`), returns the index of the previous instance
     * * If `s` is not present in the buffer (at or before `pos`), returns type(uint256).max
     *
     * NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf[Javascript's `Array.lastIndexOf`]
     */
    function lastIndexOf(bytes memory buffer, bytes1 s, uint256 pos) internal pure returns (uint256) {
        unchecked {
            uint256 length = buffer.length;
            for (uint256 i = Math.min(Math.saturatingAdd(pos, 1), length); i > 0; --i) {
                if (bytes1(_unsafeReadBytesOffset(buffer, i - 1)) == s) {
                    return i - 1;
                }
            }
            return type(uint256).max;
        }
    }

    /**
     * @dev Copies the content of `buffer`, from `start` (included) to the end of `buffer` into a new bytes object in
     * memory.
     *
     * NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice[Javascript's `Array.slice`]
     */
    function slice(bytes memory buffer, uint256 start) internal pure returns (bytes memory) {
        return slice(buffer, start, buffer.length);
    }

    /**
     * @dev Copies the content of `buffer`, from `start` (included) to `end` (excluded) into a new bytes object in
     * memory. The `end` argument is truncated to the length of the `buffer`.
     *
     * NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice[Javascript's `Array.slice`]
     */
    function slice(bytes memory buffer, uint256 start, uint256 end) internal pure returns (bytes memory) {
        // sanitize
        end = Math.min(end, buffer.length);
        start = Math.min(start, end);

        // allocate and copy
        bytes memory result = new bytes(end - start);
        assembly ("memory-safe") {
            mcopy(add(result, 0x20), add(add(buffer, 0x20), start), sub(end, start))
        }

        return result;
    }

    /**
     * @dev Moves the content of `buffer`, from `start` (included) to the end of `buffer` to the start of that buffer,
     * and shrinks the buffer length accordingly, effectively overriding the content of buffer with buffer[start:].
     *
     * NOTE: This function modifies the provided buffer in place. If you need to preserve the original buffer, use {slice} instead
     */
    function splice(bytes memory buffer, uint256 start) internal pure returns (bytes memory) {
        return splice(buffer, start, buffer.length);
    }

    /**
     * @dev Moves the content of `buffer`, from `start` (included) to `end` (excluded) to the start of that buffer,
     * and shrinks the buffer length accordingly, effectively overriding the content of buffer with buffer[start:end].
     * The `end` argument is truncated to the length of the `buffer`.
     *
     * NOTE: This function modifies the provided buffer in place. If you need to preserve the original buffer, use {slice} instead
     */
    function splice(bytes memory buffer, uint256 start, uint256 end) internal pure returns (bytes memory) {
        // sanitize
        end = Math.min(end, buffer.length);
        start = Math.min(start, end);

        // move and resize
        assembly ("memory-safe") {
            mcopy(add(buffer, 0x20), add(add(buffer, 0x20), start), sub(end, start))
            mstore(buffer, sub(end, start))
        }

        return buffer;
    }

    /**
     * @dev Replaces bytes in `buffer` starting at `pos` with all bytes from `replacement`.
     *
     * Parameters are clamped to valid ranges (i.e. `pos` is clamped to `[0, buffer.length]`).
     * If `pos >= buffer.length`, no replacement occurs and the buffer is returned unchanged.
     *
     * NOTE: This function modifies the provided buffer in place.
     */
    function replace(bytes memory buffer, uint256 pos, bytes memory replacement) internal pure returns (bytes memory) {
        return replace(buffer, pos, replacement, 0, replacement.length);
    }

    /**
     * @dev Replaces bytes in `buffer` starting at `pos` with bytes from `replacement` starting at `offset`.
     * Copies at most `length` bytes from `replacement` to `buffer`.
     *
     * Parameters are clamped to valid ranges (i.e. `pos` is clamped to `[0, buffer.length]`, `offset` is
     * clamped to `[0, replacement.length]`, and `length` is clamped to `min(length, replacement.length - offset,
     * buffer.length - pos))`. If `pos >= buffer.length` or `offset >= replacement.length`, no replacement occurs
     * and the buffer is returned unchanged.
     *
     * NOTE: This function modifies the provided buffer in place.
     */
    function replace(
        bytes memory buffer,
        uint256 pos,
        bytes memory replacement,
        uint256 offset,
        uint256 length
    ) internal pure returns (bytes memory) {
        // sanitize
        pos = Math.min(pos, buffer.length);
        offset = Math.min(offset, replacement.length);
        length = Math.min(length, Math.min(replacement.length - offset, buffer.length - pos));

        // replace
        assembly ("memory-safe") {
            mcopy(add(add(buffer, 0x20), pos), add(add(replacement, 0x20), offset), length)
        }

        return buffer;
    }

    /**
     * @dev Concatenate an array of bytes into a single bytes object.
     *
     * For fixed bytes types, we recommend using the solidity built-in `bytes.concat` or (equivalent)
     * `abi.encodePacked`.
     *
     * NOTE: this could be done in assembly with a single loop that expands starting at the FMP, but that would be
     * significantly less readable. It might be worth benchmarking the savings of the full-assembly approach.
     */
    function concat(bytes[] memory buffers) internal pure returns (bytes memory) {
        uint256 length = 0;
        for (uint256 i = 0; i < buffers.length; ++i) {
            length += buffers[i].length;
        }

        bytes memory result = new bytes(length);

        uint256 offset = 0x20;
        for (uint256 i = 0; i < buffers.length; ++i) {
            bytes memory input = buffers[i];
            assembly ("memory-safe") {
                mcopy(add(result, offset), add(input, 0x20), mload(input))
            }
            unchecked {
                offset += input.length;
            }
        }

        return result;
    }

    /**
     * @dev Split each byte in `input` into two nibbles (4 bits each)
     *
     * Example: hex"01234567" → hex"0001020304050607"
     */
    function toNibbles(bytes memory input) internal pure returns (bytes memory output) {
        assembly ("memory-safe") {
            let length := mload(input)
            output := mload(0x40)
            mstore(0x40, add(add(output, 0x20), mul(length, 2)))
            mstore(output, mul(length, 2))
            for {
                let i := 0
            } lt(i, length) {
                i := add(i, 0x10)
            } {
                let chunk := shr(128, mload(add(add(input, 0x20), i)))
                chunk := and(
                    0x0000000000000000ffffffffffffffff0000000000000000ffffffffffffffff,
                    or(shl(64, chunk), chunk)
                )
                chunk := and(
                    0x00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff,
                    or(shl(32, chunk), chunk)
                )
                chunk := and(
                    0x0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff,
                    or(shl(16, chunk), chunk)
                )
                chunk := and(
                    0x00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff,
                    or(shl(8, chunk), chunk)
                )
                chunk := and(
                    0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f,
                    or(shl(4, chunk), chunk)
                )
                mstore(add(add(output, 0x20), mul(i, 2)), chunk)
            }
        }
    }

    /**
     * @dev Returns true if the two byte buffers are equal.
     */
    function equal(bytes memory a, bytes memory b) internal pure returns (bool) {
        return a.length == b.length && keccak256(a) == keccak256(b);
    }

    /**
     * @dev Reverses the byte order of a bytes32 value, converting between little-endian and big-endian.
     * Inspired by https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel[Reverse Parallel]
     */
    function reverseBytes32(bytes32 value) internal pure returns (bytes32) {
        value = // swap bytes
            ((value >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |
            ((value & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);
        value = // swap 2-byte long pairs
            ((value >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |
            ((value & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);
        value = // swap 4-byte long pairs
            ((value >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |
            ((value & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);
        value = // swap 8-byte long pairs
            ((value >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |
            ((value & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);
        return (value >> 128) | (value << 128); // swap 16-byte long pairs
    }

    /// @dev Same as {reverseBytes32} but optimized for 128-bit values.
    function reverseBytes16(bytes16 value) internal pure returns (bytes16) {
        value = // swap bytes
            ((value & 0xFF00FF00FF00FF00FF00FF00FF00FF00) >> 8) |
            ((value & 0x00FF00FF00FF00FF00FF00FF00FF00FF) << 8);
        value = // swap 2-byte long pairs
            ((value & 0xFFFF0000FFFF0000FFFF0000FFFF0000) >> 16) |
            ((value & 0x0000FFFF0000FFFF0000FFFF0000FFFF) << 16);
        value = // swap 4-byte long pairs
            ((value & 0xFFFFFFFF00000000FFFFFFFF00000000) >> 32) |
            ((value & 0x00000000FFFFFFFF00000000FFFFFFFF) << 32);
        return (value >> 64) | (value << 64); // swap 8-byte long pairs
    }

    /// @dev Same as {reverseBytes32} but optimized for 64-bit values.
    function reverseBytes8(bytes8 value) internal pure returns (bytes8) {
        value = ((value & 0xFF00FF00FF00FF00) >> 8) | ((value & 0x00FF00FF00FF00FF) << 8); // swap bytes
        value = ((value & 0xFFFF0000FFFF0000) >> 16) | ((value & 0x0000FFFF0000FFFF) << 16); // swap 2-byte long pairs
        return (value >> 32) | (value << 32); // swap 4-byte long pairs
    }

    /// @dev Same as {reverseBytes32} but optimized for 32-bit values.
    function reverseBytes4(bytes4 value) internal pure returns (bytes4) {
        value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8); // swap bytes
        return (value >> 16) | (value << 16); // swap 2-byte long pairs
    }

    /// @dev Same as {reverseBytes32} but optimized for 16-bit values.
    function reverseBytes2(bytes2 value) internal pure returns (bytes2) {
        return (value >> 8) | (value << 8);
    }

    /**
     * @dev Counts the number of leading zero bits a bytes array. Returns `8 * buffer.length`
     * if the buffer is all zeros.
     */
    function clz(bytes memory buffer) internal pure returns (uint256) {
        for (uint256 i = 0; i < buffer.length; i += 0x20) {
            bytes32 chunk = _unsafeReadBytesOffset(buffer, i);
            if (chunk != bytes32(0)) {
                return Math.min(8 * i + Math.clz(uint256(chunk)), 8 * buffer.length);
            }
        }
        return 8 * buffer.length;
    }

    /**
     * @dev Reads a bytes32 from a bytes array without bounds checking.
     *
     * NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
     * assembly block as such would prevent some optimizations.
     */
    function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
        // This is not memory safe in the general case, but all calls to this private function are within bounds.
        assembly ("memory-safe") {
            value := mload(add(add(buffer, 0x20), offset))
        }
    }
}
          

/SignedMath.sol

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

pragma solidity ^0.8.20;

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

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
     *
     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
     * one branch when needed, making this function more expensive.
     */
    function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {
        unchecked {
            // branchless ternary works because:
            // b ^ (a ^ b) == a
            // b ^ 0 == b
            return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));
        }
    }

    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return ternary(a > b, a, b);
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return ternary(a < b, a, b);
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
            // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
            // taking advantage of the most significant (or "sign" bit) in two's complement representation.
            // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
            // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
            int256 mask = n >> 255;

            // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
            return uint256((n + mask) ^ mask);
        }
    }
}
          

/SafeCast.sol

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

pragma solidity ^0.8.20;

/**
 * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in a uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in a uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev A uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, value);
        }
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, value);
        }
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, value);
        }
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, value);
        }
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, value);
        }
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, value);
        }
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }

    /**
     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
     */
    function toUint(bool b) internal pure returns (uint256 u) {
        assembly ("memory-safe") {
            u := iszero(iszero(b))
        }
    }
}
          

/Panic.sol

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

pragma solidity ^0.8.20;

/**
 * @dev Helper library for emitting standardized panic codes.
 *
 * ```solidity
 * contract Example {
 *      using Panic for uint256;
 *
 *      // Use any of the declared internal constants
 *      function foo() { Panic.GENERIC.panic(); }
 *
 *      // Alternatively
 *      function foo() { Panic.panic(Panic.GENERIC); }
 * }
 * ```
 *
 * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
 *
 * _Available since v5.1._
 */
// slither-disable-next-line unused-state
library Panic {
    /// @dev generic / unspecified error
    uint256 internal constant GENERIC = 0x00;
    /// @dev used by the assert() builtin
    uint256 internal constant ASSERT = 0x01;
    /// @dev arithmetic underflow or overflow
    uint256 internal constant UNDER_OVERFLOW = 0x11;
    /// @dev division or modulo by zero
    uint256 internal constant DIVISION_BY_ZERO = 0x12;
    /// @dev enum conversion error
    uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
    /// @dev invalid encoding in storage
    uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
    /// @dev empty array pop
    uint256 internal constant EMPTY_ARRAY_POP = 0x31;
    /// @dev array out of bounds access
    uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
    /// @dev resource error (too large allocation or too large array)
    uint256 internal constant RESOURCE_ERROR = 0x41;
    /// @dev calling invalid internal function
    uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;

    /// @dev Reverts with a panic code. Recommended to use with
    /// the internal constants with predefined codes.
    function panic(uint256 code) internal pure {
        assembly ("memory-safe") {
            mstore(0x00, 0x4e487b71)
            mstore(0x20, code)
            revert(0x1c, 0x24)
        }
    }
}
          

/Math.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.6.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Return the 512-bit addition of two uint256.
     *
     * The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
     */
    function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
        assembly ("memory-safe") {
            low := add(a, b)
            high := lt(low, a)
        }
    }

    /**
     * @dev Return the 512-bit multiplication of two uint256.
     *
     * The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
     */
    function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
        // 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
        // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
        // variables such that product = high * 2²⁵⁶ + low.
        assembly ("memory-safe") {
            let mm := mulmod(a, b, not(0))
            low := mul(a, b)
            high := sub(sub(mm, low), lt(mm, low))
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a + b;
            success = c >= a;
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a - b;
            success = c <= a;
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a * b;
            assembly ("memory-safe") {
                // Only true when the multiplication doesn't overflow
                // (c / a == b) || (a == 0)
                success := or(eq(div(c, a), b), iszero(a))
            }
            // equivalent to: success ? c : 0
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            success = b > 0;
            assembly ("memory-safe") {
                // The `DIV` opcode returns zero when the denominator is 0.
                result := div(a, b)
            }
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            success = b > 0;
            assembly ("memory-safe") {
                // The `MOD` opcode returns zero when the denominator is 0.
                result := mod(a, b)
            }
        }
    }

    /**
     * @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
     */
    function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
        (bool success, uint256 result) = tryAdd(a, b);
        return ternary(success, result, type(uint256).max);
    }

    /**
     * @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
     */
    function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
        (, uint256 result) = trySub(a, b);
        return result;
    }

    /**
     * @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
     */
    function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
        (bool success, uint256 result) = tryMul(a, b);
        return ternary(success, result, type(uint256).max);
    }

    /**
     * @dev Branchless ternary evaluation for `condition ? a : b`. Gas costs are constant.
     *
     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
     * However, the compiler may optimize Solidity ternary operations (i.e. `condition ? a : b`) to only compute
     * one branch when needed, making this function more expensive.
     */
    function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
        unchecked {
            // branchless ternary works because:
            // b ^ (a ^ b) == a
            // b ^ 0 == b
            return b ^ ((a ^ b) * SafeCast.toUint(condition));
        }
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return ternary(a > b, a, b);
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return ternary(a < b, a, b);
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        unchecked {
            // (a + b) / 2 can overflow.
            return (a & b) + (a ^ b) / 2;
        }
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }

        // The following calculation ensures accurate ceiling division without overflow.
        // Since a is non-zero, (a - 1) / b will not overflow.
        // The largest possible result occurs when (a - 1) / b is type(uint256).max,
        // but the largest value we can obtain is type(uint256).max - 1, which happens
        // when a = type(uint256).max and b = 1.
        unchecked {
            return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
        }
    }

    /**
     * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     *
     * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            (uint256 high, uint256 low) = mul512(x, y);

            // Handle non-overflow cases, 256 by 256 division.
            if (high == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return low / denominator;
            }

            // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
            if (denominator <= high) {
                Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
            }

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [high low].
            uint256 remainder;
            assembly ("memory-safe") {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                high := sub(high, gt(remainder, low))
                low := sub(low, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.
            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.

            uint256 twos = denominator & (0 - denominator);
            assembly ("memory-safe") {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [high low] by twos.
                low := div(low, twos)

                // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from high into low.
            low |= high * twos;

            // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
            // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv ≡ 1 mod 2⁴.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
            inverse *= 2 - denominator * inverse; // inverse mod 2³²
            inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
            inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
            // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high
            // is no longer required.
            result = low * inverse;
            return result;
        }
    }

    /**
     * @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
    }

    /**
     * @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
     */
    function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
        unchecked {
            (uint256 high, uint256 low) = mul512(x, y);
            if (high >= 1 << n) {
                Panic.panic(Panic.UNDER_OVERFLOW);
            }
            return (high << (256 - n)) | (low >> n);
        }
    }

    /**
     * @dev Calculates x * y >> n with full precision, following the selected rounding direction.
     */
    function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
        return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
    }

    /**
     * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
     *
     * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
     * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
     *
     * If the input value is not inversible, 0 is returned.
     *
     * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
     * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
     */
    function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
        unchecked {
            if (n == 0) return 0;

            // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
            // Used to compute integers x and y such that: ax + ny = gcd(a, n).
            // When the gcd is 1, then the inverse of a modulo n exists and it's x.
            // ax + ny = 1
            // ax = 1 + (-y)n
            // ax ≡ 1 (mod n) # x is the inverse of a modulo n

            // If the remainder is 0 the gcd is n right away.
            uint256 remainder = a % n;
            uint256 gcd = n;

            // Therefore the initial coefficients are:
            // ax + ny = gcd(a, n) = n
            // 0a + 1n = n
            int256 x = 0;
            int256 y = 1;

            while (remainder != 0) {
                uint256 quotient = gcd / remainder;

                (gcd, remainder) = (
                    // The old remainder is the next gcd to try.
                    remainder,
                    // Compute the next remainder.
                    // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
                    // where gcd is at most n (capped to type(uint256).max)
                    gcd - remainder * quotient
                );

                (x, y) = (
                    // Increment the coefficient of a.
                    y,
                    // Decrement the coefficient of n.
                    // Can overflow, but the result is casted to uint256 so that the
                    // next value of y is "wrapped around" to a value between 0 and n - 1.
                    x - y * int256(quotient)
                );
            }

            if (gcd != 1) return 0; // No inverse exists.
            return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
        }
    }

    /**
     * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
     *
     * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
     * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
     * `a**(p-2)` is the modular multiplicative inverse of a in Fp.
     *
     * NOTE: this function does NOT check that `p` is a prime greater than `2`.
     */
    function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
        unchecked {
            return Math.modExp(a, p - 2, p);
        }
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
     *
     * Requirements:
     * - modulus can't be zero
     * - underlying staticcall to precompile must succeed
     *
     * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
     * sure the chain you're using it on supports the precompiled contract for modular exponentiation
     * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
     * the underlying function will succeed given the lack of a revert, but the result may be incorrectly
     * interpreted as 0.
     */
    function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
        (bool success, uint256 result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
     * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
     * to operate modulo 0 or if the underlying precompile reverted.
     *
     * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
     * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
     * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
     * of a revert, but the result may be incorrectly interpreted as 0.
     */
    function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
        if (m == 0) return (false, 0);
        assembly ("memory-safe") {
            let ptr := mload(0x40)
            // | Offset    | Content    | Content (Hex)                                                      |
            // |-----------|------------|--------------------------------------------------------------------|
            // | 0x00:0x1f | size of b  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x20:0x3f | size of e  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x40:0x5f | size of m  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x60:0x7f | value of b | 0x<.............................................................b> |
            // | 0x80:0x9f | value of e | 0x<.............................................................e> |
            // | 0xa0:0xbf | value of m | 0x<.............................................................m> |
            mstore(ptr, 0x20)
            mstore(add(ptr, 0x20), 0x20)
            mstore(add(ptr, 0x40), 0x20)
            mstore(add(ptr, 0x60), b)
            mstore(add(ptr, 0x80), e)
            mstore(add(ptr, 0xa0), m)

            // Given the result < m, it's guaranteed to fit in 32 bytes,
            // so we can use the memory scratch space located at offset 0.
            success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
            result := mload(0x00)
        }
    }

    /**
     * @dev Variant of {modExp} that supports inputs of arbitrary length.
     */
    function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
        (bool success, bytes memory result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Variant of {tryModExp} that supports inputs of arbitrary length.
     */
    function tryModExp(
        bytes memory b,
        bytes memory e,
        bytes memory m
    ) internal view returns (bool success, bytes memory result) {
        if (_zeroBytes(m)) return (false, new bytes(0));

        uint256 mLen = m.length;

        // Encode call args in result and move the free memory pointer
        result = abi.encodePacked(b.length, e.length, mLen, b, e, m);

        assembly ("memory-safe") {
            let dataPtr := add(result, 0x20)
            // Write result on top of args to avoid allocating extra memory.
            success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
            // Overwrite the length.
            // result.length > returndatasize() is guaranteed because returndatasize() == m.length
            mstore(result, mLen)
            // Set the memory pointer after the returned data.
            mstore(0x40, add(dataPtr, mLen))
        }
    }

    /**
     * @dev Returns whether the provided byte array is zero.
     */
    function _zeroBytes(bytes memory buffer) private pure returns (bool) {
        uint256 chunk;
        for (uint256 i = 0; i < buffer.length; i += 0x20) {
            // See _unsafeReadBytesOffset from utils/Bytes.sol
            assembly ("memory-safe") {
                chunk := mload(add(add(buffer, 0x20), i))
            }
            if (chunk >> (8 * saturatingSub(i + 0x20, buffer.length)) != 0) {
                return false;
            }
        }
        return true;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * This method is based on Newton's method for computing square roots; the algorithm is restricted to only
     * using integer operations.
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        unchecked {
            // Take care of easy edge cases when a == 0 or a == 1
            if (a <= 1) {
                return a;
            }

            // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
            // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
            // the current value as `ε_n = | x_n - sqrt(a) |`.
            //
            // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
            // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
            // bigger than any uint256.
            //
            // By noticing that
            // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
            // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
            // to the msb function.
            uint256 aa = a;
            uint256 xn = 1;

            if (aa >= (1 << 128)) {
                aa >>= 128;
                xn <<= 64;
            }
            if (aa >= (1 << 64)) {
                aa >>= 64;
                xn <<= 32;
            }
            if (aa >= (1 << 32)) {
                aa >>= 32;
                xn <<= 16;
            }
            if (aa >= (1 << 16)) {
                aa >>= 16;
                xn <<= 8;
            }
            if (aa >= (1 << 8)) {
                aa >>= 8;
                xn <<= 4;
            }
            if (aa >= (1 << 4)) {
                aa >>= 4;
                xn <<= 2;
            }
            if (aa >= (1 << 2)) {
                xn <<= 1;
            }

            // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
            //
            // We can refine our estimation by noticing that the middle of that interval minimizes the error.
            // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
            // This is going to be our x_0 (and ε_0)
            xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)

            // From here, Newton's method give us:
            // x_{n+1} = (x_n + a / x_n) / 2
            //
            // One should note that:
            // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
            //              = ((x_n² + a) / (2 * x_n))² - a
            //              = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
            //              = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
            //              = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
            //              = (x_n² - a)² / (2 * x_n)²
            //              = ((x_n² - a) / (2 * x_n))²
            //              ≥ 0
            // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
            //
            // This gives us the proof of quadratic convergence of the sequence:
            // ε_{n+1} = | x_{n+1} - sqrt(a) |
            //         = | (x_n + a / x_n) / 2 - sqrt(a) |
            //         = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
            //         = | (x_n - sqrt(a))² / (2 * x_n) |
            //         = | ε_n² / (2 * x_n) |
            //         = ε_n² / | (2 * x_n) |
            //
            // For the first iteration, we have a special case where x_0 is known:
            // ε_1 = ε_0² / | (2 * x_0) |
            //     ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
            //     ≤ 2**(2*e-4) / (3 * 2**(e-1))
            //     ≤ 2**(e-3) / 3
            //     ≤ 2**(e-3-log2(3))
            //     ≤ 2**(e-4.5)
            //
            // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
            // ε_{n+1} = ε_n² / | (2 * x_n) |
            //         ≤ (2**(e-k))² / (2 * 2**(e-1))
            //         ≤ 2**(2*e-2*k) / 2**e
            //         ≤ 2**(e-2*k)
            xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5)  -- special case, see above
            xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9)    -- general case with k = 4.5
            xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18)   -- general case with k = 9
            xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36)   -- general case with k = 18
            xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72)   -- general case with k = 36
            xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144)  -- general case with k = 72

            // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
            // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
            // sqrt(a) or sqrt(a) + 1.
            return xn - SafeCast.toUint(xn > a / xn);
        }
    }

    /**
     * @dev Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 x) internal pure returns (uint256 r) {
        // If value has upper 128 bits set, log2 result is at least 128
        r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
        // If upper 64 bits of 128-bit half set, add 64 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
        // If upper 32 bits of 64-bit half set, add 32 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
        // If upper 16 bits of 32-bit half set, add 16 to result
        r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
        // If upper 8 bits of 16-bit half set, add 8 to result
        r |= SafeCast.toUint((x >> r) > 0xff) << 3;
        // If upper 4 bits of 8-bit half set, add 4 to result
        r |= SafeCast.toUint((x >> r) > 0xf) << 2;

        // Shifts value right by the current result and use it as an index into this lookup table:
        //
        // | x (4 bits) |  index  | table[index] = MSB position |
        // |------------|---------|-----------------------------|
        // |    0000    |    0    |        table[0] = 0         |
        // |    0001    |    1    |        table[1] = 0         |
        // |    0010    |    2    |        table[2] = 1         |
        // |    0011    |    3    |        table[3] = 1         |
        // |    0100    |    4    |        table[4] = 2         |
        // |    0101    |    5    |        table[5] = 2         |
        // |    0110    |    6    |        table[6] = 2         |
        // |    0111    |    7    |        table[7] = 2         |
        // |    1000    |    8    |        table[8] = 3         |
        // |    1001    |    9    |        table[9] = 3         |
        // |    1010    |   10    |        table[10] = 3        |
        // |    1011    |   11    |        table[11] = 3        |
        // |    1100    |   12    |        table[12] = 3        |
        // |    1101    |   13    |        table[13] = 3        |
        // |    1110    |   14    |        table[14] = 3        |
        // |    1111    |   15    |        table[15] = 3        |
        //
        // The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the first 16 bytes (most significant half).
        assembly ("memory-safe") {
            r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
        }
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 x) internal pure returns (uint256 r) {
        // If value has upper 128 bits set, log2 result is at least 128
        r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
        // If upper 64 bits of 128-bit half set, add 64 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
        // If upper 32 bits of 64-bit half set, add 32 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
        // If upper 16 bits of 32-bit half set, add 16 to result
        r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
        // Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
        return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }

    /**
     * @dev Counts the number of leading zero bits in a uint256.
     */
    function clz(uint256 x) internal pure returns (uint256) {
        return ternary(x == 0, 256, 255 - log2(x));
    }
}
          

/Strings.sol

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

pragma solidity ^0.8.24;

import {Math} from "./math/Math.sol";
import {SafeCast} from "./math/SafeCast.sol";
import {SignedMath} from "./math/SignedMath.sol";
import {Bytes} from "./Bytes.sol";

/**
 * @dev String operations.
 */
library Strings {
    using SafeCast for *;

    bytes16 private constant HEX_DIGITS = "0123456789abcdef";
    uint8 private constant ADDRESS_LENGTH = 20;
    uint256 private constant SPECIAL_CHARS_LOOKUP =
        0xffffffff | // first 32 bits corresponding to the control characters (U+0000 to U+001F)
            (1 << 0x22) | // double quote
            (1 << 0x5c); // backslash

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @dev The string being parsed contains characters that are not in scope of the given base.
     */
    error StringsInvalidChar();

    /**
     * @dev The string being parsed is not a properly formatted address.
     */
    error StringsInvalidAddressFormat();

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            assembly ("memory-safe") {
                ptr := add(add(buffer, 0x20), length)
            }
            while (true) {
                ptr--;
                assembly ("memory-safe") {
                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        uint256 localValue = value;
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = HEX_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
     * representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal
     * representation, according to EIP-55.
     */
    function toChecksumHexString(address addr) internal pure returns (string memory) {
        bytes memory buffer = bytes(toHexString(addr));

        // hash the hex part of buffer (skip length + 2 bytes, length 40)
        uint256 hashValue;
        assembly ("memory-safe") {
            hashValue := shr(96, keccak256(add(buffer, 0x22), 40))
        }

        for (uint256 i = 41; i > 1; --i) {
            // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)
            if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {
                // case shift by xoring with 0x20
                buffer[i] ^= 0x20;
            }
            hashValue >>= 4;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `bytes` buffer to its ASCII `string` hexadecimal representation.
     */
    function toHexString(bytes memory input) internal pure returns (string memory) {
        unchecked {
            bytes memory buffer = new bytes(2 * input.length + 2);
            buffer[0] = "0";
            buffer[1] = "x";
            for (uint256 i = 0; i < input.length; ++i) {
                uint8 v = uint8(input[i]);
                buffer[2 * i + 2] = HEX_DIGITS[v >> 4];
                buffer[2 * i + 3] = HEX_DIGITS[v & 0xf];
            }
            return string(buffer);
        }
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return Bytes.equal(bytes(a), bytes(b));
    }

    /**
     * @dev Parse a decimal string and returns the value as a `uint256`.
     *
     * Requirements:
     * - The string must be formatted as `[0-9]*`
     * - The result must fit into an `uint256` type
     */
    function parseUint(string memory input) internal pure returns (uint256) {
        return parseUint(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseUint-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `[0-9]*`
     * - The result must fit into an `uint256` type
     */
    function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
        (bool success, uint256 value) = tryParseUint(input, begin, end);
        if (!success) revert StringsInvalidChar();
        return value;
    }

    /**
     * @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {
        return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid
     * character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseUint(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, uint256 value) {
        if (end > bytes(input).length || begin > end) return (false, 0);
        return _tryParseUintUncheckedBounds(input, begin, end);
    }

    /**
     * @dev Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
     */
    function _tryParseUintUncheckedBounds(
        string memory input,
        uint256 begin,
        uint256 end
    ) private pure returns (bool success, uint256 value) {
        bytes memory buffer = bytes(input);

        uint256 result = 0;
        for (uint256 i = begin; i < end; ++i) {
            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
            if (chr > 9) return (false, 0);
            result *= 10;
            result += chr;
        }
        return (true, result);
    }

    /**
     * @dev Parse a decimal string and returns the value as a `int256`.
     *
     * Requirements:
     * - The string must be formatted as `[-+]?[0-9]*`
     * - The result must fit in an `int256` type.
     */
    function parseInt(string memory input) internal pure returns (int256) {
        return parseInt(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `[-+]?[0-9]*`
     * - The result must fit in an `int256` type.
     */
    function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {
        (bool success, int256 value) = tryParseInt(input, begin, end);
        if (!success) revert StringsInvalidChar();
        return value;
    }

    /**
     * @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if
     * the result does not fit in a `int256`.
     *
     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
     */
    function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {
        return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);
    }

    uint256 private constant ABS_MIN_INT256 = 2 ** 255;

    /**
     * @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid
     * character or if the result does not fit in a `int256`.
     *
     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
     */
    function tryParseInt(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, int256 value) {
        if (end > bytes(input).length || begin > end) return (false, 0);
        return _tryParseIntUncheckedBounds(input, begin, end);
    }

    /**
     * @dev Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that
     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
     */
    function _tryParseIntUncheckedBounds(
        string memory input,
        uint256 begin,
        uint256 end
    ) private pure returns (bool success, int256 value) {
        bytes memory buffer = bytes(input);

        // Check presence of a negative sign.
        bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
        bool positiveSign = sign == bytes1("+");
        bool negativeSign = sign == bytes1("-");
        uint256 offset = (positiveSign || negativeSign).toUint();

        (bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);

        if (absSuccess && absValue < ABS_MIN_INT256) {
            return (true, negativeSign ? -int256(absValue) : int256(absValue));
        } else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {
            return (true, type(int256).min);
        } else return (false, 0);
    }

    /**
     * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`.
     *
     * Requirements:
     * - The string must be formatted as `(0x)?[0-9a-fA-F]*`
     * - The result must fit in an `uint256` type.
     */
    function parseHexUint(string memory input) internal pure returns (uint256) {
        return parseHexUint(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseHexUint-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `(0x)?[0-9a-fA-F]*`
     * - The result must fit in an `uint256` type.
     */
    function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
        (bool success, uint256 value) = tryParseHexUint(input, begin, end);
        if (!success) revert StringsInvalidChar();
        return value;
    }

    /**
     * @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {
        return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an
     * invalid character.
     *
     * NOTE: This function will revert if the result does not fit in a `uint256`.
     */
    function tryParseHexUint(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, uint256 value) {
        if (end > bytes(input).length || begin > end) return (false, 0);
        return _tryParseHexUintUncheckedBounds(input, begin, end);
    }

    /**
     * @dev Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.
     */
    function _tryParseHexUintUncheckedBounds(
        string memory input,
        uint256 begin,
        uint256 end
    ) private pure returns (bool success, uint256 value) {
        bytes memory buffer = bytes(input);

        // skip 0x prefix if present
        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
        uint256 offset = hasPrefix.toUint() * 2;

        uint256 result = 0;
        for (uint256 i = begin + offset; i < end; ++i) {
            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
            if (chr > 15) return (false, 0);
            result *= 16;
            unchecked {
                // Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).
                // This guarantees that adding a value < 16 will not cause an overflow, hence the unchecked.
                result += chr;
            }
        }
        return (true, result);
    }

    /**
     * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`.
     *
     * Requirements:
     * - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`
     */
    function parseAddress(string memory input) internal pure returns (address) {
        return parseAddress(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseAddress-string} that parses a substring of `input` located between position `begin` (included) and
     * `end` (excluded).
     *
     * Requirements:
     * - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`
     */
    function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {
        (bool success, address value) = tryParseAddress(input, begin, end);
        if (!success) revert StringsInvalidAddressFormat();
        return value;
    }

    /**
     * @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly
     * formatted address. See {parseAddress-string} requirements.
     */
    function tryParseAddress(string memory input) internal pure returns (bool success, address value) {
        return tryParseAddress(input, 0, bytes(input).length);
    }

    /**
     * @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly
     * formatted address. See {parseAddress-string-uint256-uint256} requirements.
     */
    function tryParseAddress(
        string memory input,
        uint256 begin,
        uint256 end
    ) internal pure returns (bool success, address value) {
        if (end > bytes(input).length || begin > end) return (false, address(0));

        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
        uint256 expectedLength = 40 + hasPrefix.toUint() * 2;

        // check that input is the correct length
        if (end - begin == expectedLength) {
            // length guarantees that this does not overflow, and value is at most type(uint160).max
            (bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);
            return (s, address(uint160(v)));
        } else {
            return (false, address(0));
        }
    }

    function _tryParseChr(bytes1 chr) private pure returns (uint8) {
        uint8 value = uint8(chr);

        // Try to parse `chr`:
        // - Case 1: [0-9]
        // - Case 2: [a-f]
        // - Case 3: [A-F]
        // - otherwise not supported
        unchecked {
            if (value > 47 && value < 58) value -= 48;
            else if (value > 96 && value < 103) value -= 87;
            else if (value > 64 && value < 71) value -= 55;
            else return type(uint8).max;
        }

        return value;
    }

    /**
     * @dev Escape special characters in JSON strings. This can be useful to prevent JSON injection in NFT metadata.
     *
     * WARNING: This function should only be used in double quoted JSON strings. Single quotes are not escaped.
     *
     * NOTE: This function escapes backslashes (including those in \uXXXX sequences) and the characters in ranges
     * defined in section 2.5 of RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). All control characters in U+0000
     * to U+001F are escaped (\b, \t, \n, \f, \r use short form; others use \u00XX). ECMAScript's `JSON.parse` does
     * recover escaped unicode characters that are not in this range, but other tooling may provide different results.
     */
    function escapeJSON(string memory input) internal pure returns (string memory) {
        bytes memory buffer = bytes(input);

        // Put output at the FMP. Memory will be reserved later when we figure out the actual length of the escaped
        // string. All write are done using _unsafeWriteBytesOffset, which avoid the (expensive) length checks for
        // each character written.
        bytes memory output;
        assembly ("memory-safe") {
            output := mload(0x40)
        }
        uint256 outputLength = 0;

        for (uint256 i = 0; i < buffer.length; ++i) {
            uint8 char = uint8(bytes1(_unsafeReadBytesOffset(buffer, i)));
            if (((SPECIAL_CHARS_LOOKUP & (1 << char)) != 0)) {
                _unsafeWriteBytesOffset(output, outputLength++, "\\");
                if (char == 0x08) _unsafeWriteBytesOffset(output, outputLength++, "b");
                else if (char == 0x09) _unsafeWriteBytesOffset(output, outputLength++, "t");
                else if (char == 0x0a) _unsafeWriteBytesOffset(output, outputLength++, "n");
                else if (char == 0x0c) _unsafeWriteBytesOffset(output, outputLength++, "f");
                else if (char == 0x0d) _unsafeWriteBytesOffset(output, outputLength++, "r");
                else if (char == 0x5c) _unsafeWriteBytesOffset(output, outputLength++, "\\");
                else if (char == 0x22) {
                    // solhint-disable-next-line quotes
                    _unsafeWriteBytesOffset(output, outputLength++, '"');
                } else {
                    // U+0000 to U+001F without short form: output \u00XX
                    _unsafeWriteBytesOffset(output, outputLength++, "u");
                    _unsafeWriteBytesOffset(output, outputLength++, "0");
                    _unsafeWriteBytesOffset(output, outputLength++, "0");
                    _unsafeWriteBytesOffset(output, outputLength++, HEX_DIGITS[char >> 4]);
                    _unsafeWriteBytesOffset(output, outputLength++, HEX_DIGITS[char & 0x0f]);
                }
            } else {
                _unsafeWriteBytesOffset(output, outputLength++, bytes1(char));
            }
        }
        // write the actual length and reserve memory
        assembly ("memory-safe") {
            mstore(output, outputLength)
            mstore(0x40, add(output, add(outputLength, 0x20)))
        }

        return string(output);
    }

    /**
     * @dev Reads a bytes32 from a bytes array without bounds checking.
     *
     * NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
     * assembly block as such would prevent some optimizations.
     */
    function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
        // This is not memory safe in the general case, but all calls to this private function are within bounds.
        assembly ("memory-safe") {
            value := mload(add(add(buffer, 0x20), offset))
        }
    }

    /**
     * @dev Write a bytes1 to a bytes array without bounds checking.
     *
     * NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
     * assembly block as such would prevent some optimizations.
     */
    function _unsafeWriteBytesOffset(bytes memory buffer, uint256 offset, bytes1 value) private pure {
        // This is not memory safe in the general case, but all calls to this private function are within bounds.
        assembly ("memory-safe") {
            mstore8(add(add(buffer, 0x20), offset), shr(248, value))
        }
    }
}
          

/MessageHashUtils.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.6.0) (utils/cryptography/MessageHashUtils.sol)

pragma solidity ^0.8.24;

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

/**
 * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
 *
 * The library provides methods for generating a hash of a message that conforms to the
 * https://eips.ethereum.org/EIPS/eip-191[ERC-191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
 * specifications.
 */
library MessageHashUtils {
    error ERC5267ExtensionsNotSupported();

    /**
     * @dev Returns the keccak256 digest of an ERC-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing a bytes32 `messageHash` with
     * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
     * hash signed when using the https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
     * keccak256, although any bytes32 value can be safely used because the final digest will
     * be re-hashed.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
        assembly ("memory-safe") {
            mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
        }
    }

    /**
     * @dev Returns the keccak256 digest of an ERC-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing an arbitrary `message` with
     * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
     * hash signed when using the https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
        return
            keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
    }

    /**
     * @dev Returns the keccak256 digest of an ERC-191 signed data with version
     * `0x00` (data with intended validator).
     *
     * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
     * `validator` address. Then hashing the result.
     *
     * See {ECDSA-recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(hex"19_00", validator, data));
    }

    /**
     * @dev Variant of {toDataWithIntendedValidatorHash-address-bytes} optimized for cases where `data` is a bytes32.
     */
    function toDataWithIntendedValidatorHash(
        address validator,
        bytes32 messageHash
    ) internal pure returns (bytes32 digest) {
        assembly ("memory-safe") {
            mstore(0x00, hex"19_00")
            mstore(0x02, shl(96, validator))
            mstore(0x16, messageHash)
            digest := keccak256(0x00, 0x36)
        }
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`).
     *
     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
     * `\x19\x01` and hashing the result. It corresponds to the hash signed by the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
     *
     * See {ECDSA-recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
        assembly ("memory-safe") {
            let ptr := mload(0x40)
            mstore(ptr, hex"19_01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            digest := keccak256(ptr, 0x42)
        }
    }

    /**
     * @dev Returns the EIP-712 domain separator constructed from an `eip712Domain`. See {IERC5267-eip712Domain}
     *
     * This function dynamically constructs the domain separator based on which fields are present in the
     * `fields` parameter. It contains flags that indicate which domain fields are present:
     *
     * * Bit 0 (0x01): name
     * * Bit 1 (0x02): version
     * * Bit 2 (0x04): chainId
     * * Bit 3 (0x08): verifyingContract
     * * Bit 4 (0x10): salt
     *
     * Arguments that correspond to fields which are not present in `fields` are ignored. For example, if `fields` is
     * `0x0f` (`0b01111`), then the `salt` parameter is ignored.
     */
    function toDomainSeparator(
        bytes1 fields,
        string memory name,
        string memory version,
        uint256 chainId,
        address verifyingContract,
        bytes32 salt
    ) internal pure returns (bytes32 hash) {
        return
            toDomainSeparator(
                fields,
                keccak256(bytes(name)),
                keccak256(bytes(version)),
                chainId,
                verifyingContract,
                salt
            );
    }

    /// @dev Variant of {toDomainSeparator-bytes1-string-string-uint256-address-bytes32} that uses hashed name and version.
    function toDomainSeparator(
        bytes1 fields,
        bytes32 nameHash,
        bytes32 versionHash,
        uint256 chainId,
        address verifyingContract,
        bytes32 salt
    ) internal pure returns (bytes32 hash) {
        bytes32 domainTypeHash = toDomainTypeHash(fields);

        assembly ("memory-safe") {
            // align fields to the right for easy processing
            fields := shr(248, fields)

            // FMP used as scratch space
            let fmp := mload(0x40)
            mstore(fmp, domainTypeHash)

            let ptr := add(fmp, 0x20)
            if and(fields, 0x01) {
                mstore(ptr, nameHash)
                ptr := add(ptr, 0x20)
            }
            if and(fields, 0x02) {
                mstore(ptr, versionHash)
                ptr := add(ptr, 0x20)
            }
            if and(fields, 0x04) {
                mstore(ptr, chainId)
                ptr := add(ptr, 0x20)
            }
            if and(fields, 0x08) {
                mstore(ptr, verifyingContract)
                ptr := add(ptr, 0x20)
            }
            if and(fields, 0x10) {
                mstore(ptr, salt)
                ptr := add(ptr, 0x20)
            }

            hash := keccak256(fmp, sub(ptr, fmp))
        }
    }

    /// @dev Builds an EIP-712 domain type hash depending on the `fields` provided, following https://eips.ethereum.org/EIPS/eip-5267[ERC-5267]
    function toDomainTypeHash(bytes1 fields) internal pure returns (bytes32 hash) {
        if (fields & 0x20 == 0x20) revert ERC5267ExtensionsNotSupported();

        assembly ("memory-safe") {
            // align fields to the right for easy processing
            fields := shr(248, fields)

            // FMP used as scratch space
            let fmp := mload(0x40)
            mstore(fmp, "EIP712Domain(")

            let ptr := add(fmp, 0x0d)
            // name field
            if and(fields, 0x01) {
                mstore(ptr, "string name,")
                ptr := add(ptr, 0x0c)
            }
            // version field
            if and(fields, 0x02) {
                mstore(ptr, "string version,")
                ptr := add(ptr, 0x0f)
            }
            // chainId field
            if and(fields, 0x04) {
                mstore(ptr, "uint256 chainId,")
                ptr := add(ptr, 0x10)
            }
            // verifyingContract field
            if and(fields, 0x08) {
                mstore(ptr, "address verifyingContract,")
                ptr := add(ptr, 0x1a)
            }
            // salt field
            if and(fields, 0x10) {
                mstore(ptr, "bytes32 salt,")
                ptr := add(ptr, 0x0d)
            }
            // if any field is enabled, remove the trailing comma
            ptr := sub(ptr, iszero(iszero(and(fields, 0x1f))))
            // add the closing brace
            mstore8(ptr, 0x29) // add closing brace
            ptr := add(ptr, 1)

            hash := keccak256(fmp, sub(ptr, fmp))
        }
    }
}
          

/ECDSA.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.6.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.20;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS
    }

    /**
     * @dev The signature is invalid.
     */
    error ECDSAInvalidSignature();

    /**
     * @dev The signature has an invalid length.
     */
    error ECDSAInvalidSignatureLength(uint256 length);

    /**
     * @dev The signature has an S value that is in the upper half order.
     */
    error ECDSAInvalidSignatureS(bytes32 s);

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
     * return address(0) without also returning an error description. Errors are documented using an enum (error type)
     * and a bytes32 providing additional information about the error.
     *
     * If no error is returned, then the address can be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * NOTE: This function only supports 65-byte signatures. ERC-2098 short signatures are rejected. This restriction
     * is DEPRECATED and will be removed in v6.0. Developers SHOULD NOT use signatures as unique identifiers; use hash
     * invalidation or nonces for replay protection.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     *
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     */
    function tryRecover(
        bytes32 hash,
        bytes memory signature
    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly ("memory-safe") {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
        }
    }

    /**
     * @dev Variant of {tryRecover} that takes a signature in calldata
     */
    function tryRecoverCalldata(
        bytes32 hash,
        bytes calldata signature
    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, calldata slices would work here, but are
            // significantly more expensive (length check) than using calldataload in assembly.
            assembly ("memory-safe") {
                r := calldataload(signature.offset)
                s := calldataload(add(signature.offset, 0x20))
                v := byte(0, calldataload(add(signature.offset, 0x40)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * NOTE: This function only supports 65-byte signatures. ERC-2098 short signatures are rejected. This restriction
     * is DEPRECATED and will be removed in v6.0. Developers SHOULD NOT use signatures as unique identifiers; use hash
     * invalidation or nonces for replay protection.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Variant of {recover} that takes a signature in calldata
     */
    function recoverCalldata(bytes32 hash, bytes calldata signature) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecoverCalldata(hash, signature);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
        unchecked {
            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
            // We do not check for an overflow here since the shift operation results in 0 or 1.
            uint8 v = uint8((uint256(vs) >> 255) + 27);
            return tryRecover(hash, v, r, s);
        }
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r` and `vs` short-signature fields separately.
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS, s);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature, bytes32(0));
        }

        return (signer, RecoverError.NoError, bytes32(0));
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Parse a signature into its `v`, `r` and `s` components. Supports 65-byte and 64-byte (ERC-2098)
     * formats. Returns (0,0,0) for invalid signatures.
     *
     * For 64-byte signatures, `v` is automatically normalized to 27 or 28.
     * For 65-byte signatures, `v` is returned as-is and MUST already be 27 or 28 for use with ecrecover.
     *
     * Consider validating the result before use, or use {tryRecover}/{recover} which perform full validation.
     */
    function parse(bytes memory signature) internal pure returns (uint8 v, bytes32 r, bytes32 s) {
        assembly ("memory-safe") {
            // Check the signature length
            switch mload(signature)
            // - case 65: r,s,v signature (standard)
            case 65 {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098)
            case 64 {
                let vs := mload(add(signature, 0x40))
                r := mload(add(signature, 0x20))
                s := and(vs, shr(1, not(0)))
                v := add(shr(255, vs), 27)
            }
            default {
                r := 0
                s := 0
                v := 0
            }
        }
    }

    /**
     * @dev Variant of {parse} that takes a signature in calldata
     */
    function parseCalldata(bytes calldata signature) internal pure returns (uint8 v, bytes32 r, bytes32 s) {
        assembly ("memory-safe") {
            // Check the signature length
            switch signature.length
            // - case 65: r,s,v signature (standard)
            case 65 {
                r := calldataload(signature.offset)
                s := calldataload(add(signature.offset, 0x20))
                v := byte(0, calldataload(add(signature.offset, 0x40)))
            }
            // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098)
            case 64 {
                let vs := calldataload(add(signature.offset, 0x20))
                r := calldataload(signature.offset)
                s := and(vs, shr(1, not(0)))
                v := add(shr(255, vs), 27)
            }
            default {
                r := 0
                s := 0
                v := 0
            }
        }
    }

    /**
     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
     */
    function _throwError(RecoverError error, bytes32 errorArg) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert ECDSAInvalidSignature();
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert ECDSAInvalidSignatureLength(uint256(errorArg));
        } else if (error == RecoverError.InvalidSignatureS) {
            revert ECDSAInvalidSignatureS(errorArg);
        }
    }
}
          

/IERC165.sol

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

pragma solidity >=0.4.16;

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

/IERC165.sol

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

pragma solidity >=0.4.16;

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

/IERC20.sol

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

pragma solidity >=0.4.16;

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

/IERC1363.sol

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

pragma solidity >=0.6.2;

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

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

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

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

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

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

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

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

/utils/SafeERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.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 {
        if (!_safeTransfer(token, to, value, true)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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 {
        if (!_safeTransferFrom(token, from, to, value, true)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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 _safeTransfer(token, to, value, false);
    }

    /**
     * @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 _safeTransferFrom(token, from, to, value, false);
    }

    /**
     * @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 {
        if (!_safeApprove(token, spender, value, false)) {
            if (!_safeApprove(token, spender, 0, true)) revert SafeERC20FailedOperation(address(token));
            if (!_safeApprove(token, spender, value, true)) revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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 relies 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 relies 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}.
     * Oppositely, 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 `token.transfer(to, value)` call, 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 to The recipient of the tokens
     * @param value The amount of token to transfer
     * @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
     */
    function _safeTransfer(IERC20 token, address to, uint256 value, bool bubble) private returns (bool success) {
        bytes4 selector = IERC20.transfer.selector;

        assembly ("memory-safe") {
            let fmp := mload(0x40)
            mstore(0x00, selector)
            mstore(0x04, and(to, shr(96, not(0))))
            mstore(0x24, value)
            success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
            // if call success and return is true, all is good.
            // otherwise (not success or return is not true), we need to perform further checks
            if iszero(and(success, eq(mload(0x00), 1))) {
                // if the call was a failure and bubble is enabled, bubble the error
                if and(iszero(success), bubble) {
                    returndatacopy(fmp, 0x00, returndatasize())
                    revert(fmp, returndatasize())
                }
                // if the return value is not true, then the call is only successful if:
                // - the token address has code
                // - the returndata is empty
                success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
            }
            mstore(0x40, fmp)
        }
    }

    /**
     * @dev Imitates a Solidity `token.transferFrom(from, to, value)` call, 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 from The sender of the tokens
     * @param to The recipient of the tokens
     * @param value The amount of token to transfer
     * @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
     */
    function _safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value,
        bool bubble
    ) private returns (bool success) {
        bytes4 selector = IERC20.transferFrom.selector;

        assembly ("memory-safe") {
            let fmp := mload(0x40)
            mstore(0x00, selector)
            mstore(0x04, and(from, shr(96, not(0))))
            mstore(0x24, and(to, shr(96, not(0))))
            mstore(0x44, value)
            success := call(gas(), token, 0, 0x00, 0x64, 0x00, 0x20)
            // if call success and return is true, all is good.
            // otherwise (not success or return is not true), we need to perform further checks
            if iszero(and(success, eq(mload(0x00), 1))) {
                // if the call was a failure and bubble is enabled, bubble the error
                if and(iszero(success), bubble) {
                    returndatacopy(fmp, 0x00, returndatasize())
                    revert(fmp, returndatasize())
                }
                // if the return value is not true, then the call is only successful if:
                // - the token address has code
                // - the returndata is empty
                success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
            }
            mstore(0x40, fmp)
            mstore(0x60, 0)
        }
    }

    /**
     * @dev Imitates a Solidity `token.approve(spender, value)` call, 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 spender The spender of the tokens
     * @param value The amount of token to transfer
     * @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
     */
    function _safeApprove(IERC20 token, address spender, uint256 value, bool bubble) private returns (bool success) {
        bytes4 selector = IERC20.approve.selector;

        assembly ("memory-safe") {
            let fmp := mload(0x40)
            mstore(0x00, selector)
            mstore(0x04, and(spender, shr(96, not(0))))
            mstore(0x24, value)
            success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
            // if call success and return is true, all is good.
            // otherwise (not success or return is not true), we need to perform further checks
            if iszero(and(success, eq(mload(0x00), 1))) {
                // if the call was a failure and bubble is enabled, bubble the error
                if and(iszero(success), bubble) {
                    returndatacopy(fmp, 0x00, returndatasize())
                    revert(fmp, returndatasize())
                }
                // if the return value is not true, then the call is only successful if:
                // - the token address has code
                // - the returndata is empty
                success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
            }
            mstore(0x40, fmp)
        }
    }
}
          

/IERC20.sol

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

pragma solidity >=0.4.16;

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

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

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

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

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

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

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

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

/Context.sol

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

/Ownable.sol

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

/StorageSlot.sol

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

pragma solidity ^0.8.20;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC-1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * TIP: Consider using this library along with {SlotDerivation}.
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct Int256Slot {
        int256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Int256Slot` with member `value` located at `slot`.
     */
    function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns a `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }
}
          

/ReentrancyGuard.sol

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

pragma solidity ^0.8.20;

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

/**
 * @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].
 *
 * IMPORTANT: Deprecated. This storage-based reentrancy guard will be removed and replaced
 * by the {ReentrancyGuardTransient} variant in v6.0.
 *
 * @custom:stateless
 */
abstract contract ReentrancyGuard {
    using StorageSlot for bytes32;

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant REENTRANCY_GUARD_STORAGE =
        0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;

    // 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;

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

    constructor() {
        _reentrancyGuardStorageSlot().getUint256Slot().value = 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();
    }

    /**
     * @dev A `view` only version of {nonReentrant}. Use to block view functions
     * from being called, preventing reading from inconsistent contract state.
     *
     * CAUTION: This is a "view" modifier and does not change the reentrancy
     * status. Use it only on view functions. For payable or non-payable functions,
     * use the standard {nonReentrant} modifier instead.
     */
    modifier nonReentrantView() {
        _nonReentrantBeforeView();
        _;
    }

    function _nonReentrantBeforeView() private view {
        if (_reentrancyGuardEntered()) {
            revert ReentrancyGuardReentrantCall();
        }
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        _nonReentrantBeforeView();

        // Any calls to nonReentrant after this point will fail
        _reentrancyGuardStorageSlot().getUint256Slot().value = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _reentrancyGuardStorageSlot().getUint256Slot().value = 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 _reentrancyGuardStorageSlot().getUint256Slot().value == ENTERED;
    }

    function _reentrancyGuardStorageSlot() internal pure virtual returns (bytes32) {
        return REENTRANCY_GUARD_STORAGE;
    }
}
          

Compiler Settings

{"remappings":[],"optimizer":{"runs":200,"enabled":true},"metadata":{"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"osaka","compilationTarget":{"contracts/AER/StreamingRewardsV5.sol":"StreamingRewardsV5"}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_oracleSigner","internalType":"address"},{"type":"address","name":"_keyStaking","internalType":"address"},{"type":"address","name":"_rngContract","internalType":"address"},{"type":"address","name":"_jackpotToken","internalType":"address"},{"type":"address","name":"initialOwner","internalType":"address"}]},{"type":"error","name":"ECDSAInvalidSignature","inputs":[]},{"type":"error","name":"ECDSAInvalidSignatureLength","inputs":[{"type":"uint256","name":"length","internalType":"uint256"}]},{"type":"error","name":"ECDSAInvalidSignatureS","inputs":[{"type":"bytes32","name":"s","internalType":"bytes32"}]},{"type":"error","name":"OwnableInvalidOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"OwnableUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"error","name":"ReentrancyGuardReentrantCall","inputs":[]},{"type":"error","name":"SafeERC20FailedOperation","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"event","name":"DedicatedListener","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"address","name":"topArtist","internalType":"address","indexed":true},{"type":"uint256","name":"streakDays","internalType":"uint256","indexed":false},{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"JackpotFunded","inputs":[{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"newTotal","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LegendarySession","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"sessionId","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MigrationComplete","inputs":[{"type":"uint256","name":"usersImported","internalType":"uint256","indexed":false},{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MigrationLocked","inputs":[],"anonymous":false},{"type":"event","name":"OracleSignerChanged","inputs":[{"type":"address","name":"oldSigner","internalType":"address","indexed":true},{"type":"address","name":"newSigner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OracleSignerProposed","inputs":[{"type":"address","name":"proposed","internalType":"address","indexed":true},{"type":"uint256","name":"executeAfter","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"PoolFunded","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"newBalance","internalType":"uint256","indexed":false},{"type":"uint256","name":"runwaySeconds","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardAccumulated","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"baseAmount","internalType":"uint256","indexed":false},{"type":"uint256","name":"finalAmount","internalType":"uint256","indexed":false},{"type":"uint256","name":"multiplier","internalType":"uint256","indexed":false},{"type":"bool","name":"isLegendary","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"RewardClaimed","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"address","name":"creatorAddress","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"StreakMilestone","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"day","internalType":"uint256","indexed":false},{"type":"uint256","name":"shieldsEarned","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"StreakUpdated","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"streakDays","internalType":"uint256","indexed":false},{"type":"uint256","name":"multiplierBps","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"StreamUpdated","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"boostedDelta","internalType":"uint256","indexed":false},{"type":"uint256","name":"weeklyTotal","internalType":"uint256","indexed":false},{"type":"uint256","name":"streakDays","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TokenActiveChanged","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"bool","name":"isActive","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"TokenAdded","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"initialPrice","internalType":"uint256","indexed":false},{"type":"uint8","name":"decimals","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"TokenRateChanged","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"oldRate","internalType":"uint256","indexed":false},{"type":"uint256","name":"newRate","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"WeeklyJackpotDistributed","inputs":[{"type":"address[]","name":"winners","internalType":"address[]","indexed":false},{"type":"uint256[]","name":"amounts","internalType":"uint256[]","indexed":false},{"type":"uint256","name":"weekNumber","internalType":"uint256","indexed":false},{"type":"uint256","name":"totalPaid","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"WeeklyJackpotRolledOver","inputs":[{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"newTotal","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"BPS_DENOMINATOR","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"EDAI","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_TAX_BPS","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"PULSEX_ROUTER","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"SECONDS_PER_WEEK","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"WPLS","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addSupportedToken","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint8","name":"decimals","internalType":"uint8"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"baseRateUSD","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelOracleSignerChange","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claim","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"address","name":"creatorAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimAll","inputs":[{"type":"address","name":"creatorAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimAllFor","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"address","name":"creatorAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimFor","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"address","name":"token","internalType":"address"},{"type":"address","name":"creatorAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"distributeWeeklyJackpot","inputs":[{"type":"address[]","name":"winners","internalType":"address[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"executeOracleSignerChange","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"fundJackpot","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"fundPool","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getAllSupportedTokens","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"ratePerSecond","internalType":"uint256"}],"name":"getEarningRate","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"address","name":"token","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"balance","internalType":"uint256"},{"type":"uint256","name":"totalDeposited","internalType":"uint256"},{"type":"uint256","name":"totalDistributed","internalType":"uint256"},{"type":"uint256","name":"distributionRate","internalType":"uint256"},{"type":"bool","name":"isActive","internalType":"bool"},{"type":"uint256","name":"nextDistribution","internalType":"uint256"},{"type":"uint8","name":"decimals","internalType":"uint8"}],"name":"getPoolInfo","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"warningTokens","internalType":"address[]"},{"type":"uint256[]","name":"runwaySeconds","internalType":"uint256[]"}],"name":"getRunwayWarnings","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"streakDays","internalType":"uint256"},{"type":"uint256","name":"streakMultiplierBps","internalType":"uint256"},{"type":"uint256","name":"lastStreamDay","internalType":"uint256"},{"type":"uint256","name":"shields","internalType":"uint256"},{"type":"uint256","name":"totalDaysStreamed","internalType":"uint256"}],"name":"getStreakInfo","inputs":[{"type":"address","name":"user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"totalPools","internalType":"uint256"},{"type":"uint256","name":"activePools","internalType":"uint256"},{"type":"uint256","name":"jackpotBalance","internalType":"uint256"},{"type":"uint256","name":"nextJackpotTime","internalType":"uint256"},{"type":"uint256","name":"currentWeek","internalType":"uint256"},{"type":"bool","name":"isPaused","internalType":"bool"}],"name":"getSystemStatus","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"incentiveBps","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"incentiveTaxRecipient","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isLegendStaker","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isSupported","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isTokenSupported","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"jackpotToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IKEYStaking"}],"name":"keyStaking","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastJackpotSettlement","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"legendPoolBps","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"legendStakerList","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"legendTierId","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"legendaryMultiplierBps","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"legendaryThreshold","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lifetimeEarned","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"lockMigration","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"migrateBatch","inputs":[{"type":"tuple[]","name":"data","internalType":"struct StreamingRewardsV5.UserMigrationData[]","components":[{"type":"address","name":"user","internalType":"address"},{"type":"address","name":"preferredTokenAddr","internalType":"address"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint256","name":"lifetimeStreamSecs","internalType":"uint256"},{"type":"uint256","name":"weeklyStreamSecs","internalType":"uint256"},{"type":"address[]","name":"rewardTokens","internalType":"address[]"},{"type":"uint256[]","name":"rewardAmounts","internalType":"uint256[]"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"migrateNonces","inputs":[{"type":"address[]","name":"users","internalType":"address[]"},{"type":"uint256[]","name":"nonces","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"migratePoolBalance","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"migratePreferences","inputs":[{"type":"address[]","name":"users","internalType":"address[]"},{"type":"address[]","name":"tokens","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"migrateRewards","inputs":[{"type":"address[]","name":"users","internalType":"address[]"},{"type":"address[]","name":"tokens","internalType":"address[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"migrateStreamingHistory","inputs":[{"type":"address[]","name":"users","internalType":"address[]"},{"type":"uint256[]","name":"lifetimeSecs","internalType":"uint256[]"},{"type":"uint256[]","name":"weeklySecs","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"migrationOpen","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minJackpotSize","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"noExpectationsTaxBps","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"notifyMefiReceived","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"oracleChangeDelay","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"oracleSigner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"oracleSignerChangeTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pendingOracleSigner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"pendingRewards","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"balance","internalType":"uint256"},{"type":"uint256","name":"totalFunded","internalType":"uint256"},{"type":"uint256","name":"totalDistributed","internalType":"uint256"},{"type":"uint256","name":"cachedTokensPerUSD","internalType":"uint256"},{"type":"uint256","name":"lastPriceUpdate","internalType":"uint256"},{"type":"uint8","name":"decimals","internalType":"uint8"},{"type":"bool","name":"isActive","internalType":"bool"}],"name":"pools","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"preferredToken","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"priceStalenessThreshold","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"proposeOracleSignerChange","inputs":[{"type":"address","name":"newSigner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rareMultiplierBps","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rareThreshold","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"recordDedicatedListener","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"address","name":"topArtist","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"refreshAllTokenPrices","inputs":[{"type":"address[]","name":"tokens","internalType":"address[]"},{"type":"uint256[]","name":"prices","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"refreshTokenPrice","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"tokensPerUSD","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"rescueToken","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IRNG"}],"name":"rngContract","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"runwayWarningSecs","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBaseRateUSD","inputs":[{"type":"uint256","name":"_rateUSD","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setIncentiveTaxRecipient","inputs":[{"type":"address","name":"_recipient","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setJackpotToken","inputs":[{"type":"address","name":"_token","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setKeyStaking","inputs":[{"type":"address","name":"_keyStaking","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setLegendPoolBps","inputs":[{"type":"uint256","name":"_bps","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setLegendTierId","inputs":[{"type":"uint8","name":"_tierId","internalType":"uint8"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinJackpotSize","inputs":[{"type":"uint256","name":"_min","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setOracleChangeDelay","inputs":[{"type":"uint256","name":"_seconds","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPaused","inputs":[{"type":"bool","name":"_paused","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPriceStalenessThreshold","inputs":[{"type":"uint256","name":"_seconds","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRNGContract","inputs":[{"type":"address","name":"_rng","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRNGMultipliers","inputs":[{"type":"uint256","name":"_legendaryBps","internalType":"uint256"},{"type":"uint256","name":"_rareBps","internalType":"uint256"},{"type":"uint256","name":"_uncommonBps","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRNGThresholds","inputs":[{"type":"uint256","name":"_legendaryThreshold","internalType":"uint256"},{"type":"uint256","name":"_rareThreshold","internalType":"uint256"},{"type":"uint256","name":"_uncommonThreshold","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRunwayWarning","inputs":[{"type":"uint256","name":"_seconds","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSignatureWindow","inputs":[{"type":"uint256","name":"_seconds","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setStreakParams","inputs":[{"type":"uint256","name":"phase1Bps","internalType":"uint256"},{"type":"uint256","name":"phase2Bps","internalType":"uint256"},{"type":"uint256","name":"phase3Bps","internalType":"uint256"},{"type":"uint256","name":"maxBps","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTaxRecipient","inputs":[{"type":"address","name":"_taxRecipient","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTaxes","inputs":[{"type":"uint256","name":"_noExpectationsBps","internalType":"uint256"},{"type":"uint256","name":"_incentiveBps","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTokenActive","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"bool","name":"active","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"signatureWindow","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"streakMaxBps","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"streakPhase1BpsPerDay","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"streakPhase2BpsPerDay","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"streakPhase3BpsPerDay","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"streakDays","internalType":"uint256"},{"type":"uint256","name":"lastStreamDay","internalType":"uint256"},{"type":"uint256","name":"streakMultiplierBps","internalType":"uint256"},{"type":"uint256","name":"shields","internalType":"uint256"},{"type":"uint256","name":"totalDaysStreamed","internalType":"uint256"}],"name":"streaks","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"supportedTokens","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"syncAllPoolBalances","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"syncLegendStakers","inputs":[{"type":"address[]","name":"stakers","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"syncPoolBalance","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"taxRecipient","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalLifetimeBoostedSeconds","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"uncommonMultiplierBps","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"uncommonThreshold","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateStream","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"uint256","name":"deltaSeconds","internalType":"uint256"},{"type":"uint256","name":"boostedDelta","internalType":"uint256"},{"type":"address","name":"token","internalType":"address"},{"type":"address","name":"creatorAddress","internalType":"address"},{"type":"uint256","name":"sessionId","internalType":"uint256"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"bytes","name":"signature","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"userNonces","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"weekNumber","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"weeklyBoostedSeconds","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"weeklyJackpotPool","inputs":[]}]
              

Contract Creation Code

0x60806040526102586001556202a300600255620151806003908155600a600455603c600555610104600655620186a060075561c350600855614e2060095566038d7ea4c68000600d55610e10600e55606460165560326017556019601881905561151890556101f4601f8190556022805460ff19169092179091556103e8602355602455602c805461ff00191661010017905534801561009d575f5ffd5b506040516162ed3803806162ed8339810160408190526100bc9161056c565b806001600160a01b0381166100ea57604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b6100f3816103cd565b5060017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055602980546001600160a01b038088166001600160a01b0319928316179092556027805487841690831617905560288054868416908316179055601e80549285169282169290921790915542601c556001601b55670de0b6b3a7640000601d5560258054821673ff27fbf6fd7d68af82473f68ebc665d2eacceaec1790556026805490911673382ac15bc6f625b0738b8187154e7a8d932009cc1790556101d37392337f43fb462163869342e72538744e030eaf55600861041c565b6101f273644f10df242b43f3de45fcb3f6ef8526fb5fdf71600861041c565b610211739a28f76c18ee03e65ea6703abaec77c1b99ddf31601261041c565b61023073a1077a294dde1b09bb078844df40758a5d0f9a27601261041c565b61024f732b591e99afe9f32eaa6214f7b7629768c40eeb39600861041c565b61026e7395b303987a60c71504d99aa1b13b4da07b0790ab601261041c565b61028d732fa878ab3f87cc1c9737fc071108f904c0b0c95d601261041c565b6102ac7394534eeee131840b1c0f61847c572228bdfdde93601261041c565b6102cb73456548a9b56efbbd89ca0309edd17a9e20b04018601261041c565b6102ea73cd1094c07f2dcf774cb0576e4e6c19c1319a3033601261041c565b61030973f6f8db0aba00007681f8faf16a0fda1c9b030b11601261041c565b61032873ec4252e62c6de3d655ca9ce3afc12e553ebba274601261041c565b610347736b175474e89094c44da98b954eedeac495271d0f601261041c565b6103667357fde0a71132198bbec939b98976993d8d89d225600861041c565b61038573efd766ccb38eaf1dfd701853bfce31359239f305601261041c565b6103a4732260fac5e5542a773aa44fbcfedf7c193bc2c599600861041c565b6103c373cc78a0acdf847a2c1714d2a925bb4477df5d48a6601261041c565b50505050506105cd565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600a805460018181019092557fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180546001600160a01b0385166001600160a01b031990911681179091555f818152600c60209081526040808320805460ff191686179055805160e081018252838152808301848152818301858152606083018681526080840187815260ff8b811660a0870190815260c087018c81528b8b52600b909952878a209651875594519a86019a909a55915160028501555160038401555160048301555160059091018054935115156101000261ffff19909416919096161791909117909355915190917f636b8a2520822c5b7b7d8e7ab81293e4efae637cf0bd895c34c4c1ecacc66525916105459190859091825260ff16602082015260400190565b60405180910390a25050565b80516001600160a01b0381168114610567575f5ffd5b919050565b5f5f5f5f5f60a08688031215610580575f5ffd5b61058986610551565b945061059760208701610551565b93506105a560408701610551565b92506105b360608701610551565b91506105c160808701610551565b90509295509295909350565b615d13806105da5f395ff3fe608060405234801561000f575f5ffd5b506004361061063d575f3560e01c8063843a5a4711610341578063c74d50b1116101ba578063e2f1b79211610109578063f2fde38b116100a9578063f6ba229511610084578063f6ba229514610efd578063f762ab8514610f10578063f9f5d09d14610f2f578063fbc7b53014610f42575f5ffd5b8063f2fde38b14610ece578063f3b6328c14610ee1578063f4aecd5114610ef4575f5ffd5b8063ecef233f116100e4578063ecef233f14610e6e578063ef8ef56f14610e8d578063ef9c7bce14610ea8578063f0d86d5514610ebb575f5ffd5b8063e2f1b79214610e3f578063e38bf1c314610e52578063e7df057614610e65575f5ffd5b8063d1b4f4e511610174578063d66ddbec1161014f578063d66ddbec14610ddf578063d918ca6014610de8578063dc95573b14610df1578063e1a4521814610e36575f5ffd5b8063d1b4f4e514610dab578063d27794c614610db4578063d2d2d90114610dd6575f5ffd5b8063c74d50b114610d4d578063cabcc5d814610d56578063cd4823fd14610d5f578063cda2c34714610d72578063cfe32bd514610d85578063d0902a0f14610d98575f5ffd5b8063a34cbbfb11610290578063bd11187011610230578063c37f4b7b1161020b578063c37f4b7b14610cf9578063c625562614610d0c578063c647b20e14610d1f578063c687782214610d32575f5ffd5b8063bd11187014610cd4578063bf62b08514610cdd578063c2465c8414610cf0575f5ffd5b8063a97f999d1161026b578063a97f999d14610c9d578063ae5e8b3014610ca6578063b92db50314610cb9578063bc485fab14610ccc575f5ffd5b8063a34cbbfb14610bf9578063a4063dbc14610c02578063a790022014610c8a575f5ffd5b80638ec9925e116102fb57806398c8bece116102d657806398c8bece14610b975780639ab3ec2f14610ba95780639caa855c14610bbc5780639fa43af414610be6575f5ffd5b80638ec9925e14610b695780638f4aaa8714610b7c578063985498dc14610b8f575f5ffd5b8063843a5a4714610b0357806384ae2a7414610b165780638571c44114610b205780638be5742814610b335780638ce8852014610b465780638da5cb5b14610b59575f5ffd5b80633b7ef933116104d35780635e6030e01161042257806375151b63116103c257806379fd93651161039d57806379fd936514610a475780637a58043414610aab5780637aabea9514610abe57806380ac822814610ad9575f5ffd5b806375151b63146109f657806377329f3514610a2157806378e3079e14610a34575f5ffd5b80636bf9b731116103fd5780636bf9b731146109b55780637059e9f8146109c8578063715018a6146109db578063737ea06e146109e3575f5ffd5b80635e6030e01461099a5780635ef5cc4a146109a3578063604bc053146109ac575f5ffd5b806349adc84e1161048d57806350c1d19d1161046857806350c1d19d14610930578063558ce2531461096757806359d0677d1461097a5780635c975abb1461098d575f5ffd5b806349adc84e146108e25780634f129c53146108f55780634fc57c8714610927575f5ffd5b80633b7ef9331461088e5780633d74076914610897578063438d33d7146108aa5780634535ea9c146108b3578063468d4ca2146108c65780634915a858146108cf575f5ffd5b806321c0b3421161058f5780632c597de91161054957806333f3d6281161052457806333f3d6281461084a5780633564fe381461085d57806337b7e152146108655780633922e30914610878575f5ffd5b80632c597de91461080f5780632d42783d146108185780632f7801f41461082b575f5ffd5b806321c0b342146107a75780632247e21c146107ba57806326351e52146107cd57806328f5250e146107e05780632bfd5146146107f35780632c1d7ebd14610806575f5ffd5b80630fc0482a116105fa57806316c38b3c116105d557806316c38b3c146107655780631709a61b146107785780631b68fb5d1461078b5780631f87f6db14610794575f5ffd5b80630fc0482a146107145780631136fcf21461071c57806311cc69cb14610725575f5ffd5b80630107e472146106415780630312ba2f1461065f57806306bfa93814610674578063086640aa146106c15780630bad91d3146106d45780630e13585314610701575b5f5ffd5b610649610f4b565b60405161065691906154bb565b60405180910390f35b61067261066d3660046154cd565b610fab565b005b6106876106823660046154fa565b610fb8565b6040805197885260208801969096529486019390935260608501919091521515608084015260a083015260ff1660c082015260e001610656565b6106726106cf36600461555a565b611071565b6106f36106e23660046154fa565b60106020525f908152604090205481565b604051908152602001610656565b61067261070f3660046154cd565b6114b1565b6106726114f8565b6106f3601a5481565b61074d6107333660046154fa565b60146020525f90815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610656565b6106726107733660046155d3565b611535565b60295461074d906001600160a01b031681565b6106f360055481565b6106726107a23660046155fa565b611550565b6106726107b536600461562f565b611720565b6106726107c836600461562f565b611913565b6106726107db366004615660565b6119f7565b6106726107ee366004615722565b611cbb565b610672610801366004615722565b611dc8565b6106f3602b5481565b6106f361138881565b61067261082636600461574a565b611f5f565b6106f36108393660046154fa565b60136020525f908152604090205481565b610672610858366004615722565b611ffd565b6106726120b2565b60275461074d906001600160a01b031681565b6108806122d8565b604051610656929190615773565b6106f360165481565b6106726108a53660046154fa565b6125c8565b6106f360245481565b6106726108c13660046154fa565b6125f2565b6106f360025481565b6106726108dd3660046154cd565b612812565b6106726108f036600461555a565b61281f565b6109176109033660046154fa565b600c6020525f908152604090205460ff1681565b6040519015158152602001610656565b6106f360195481565b610938612974565b6040805196875260208701959095529385019290925260608401526080830152151560a082015260c001610656565b61067261097536600461574a565b612a21565b6106726109883660046157cb565b612af2565b602c546109179060ff1681565b6106f360085481565b6106f3601b5481565b6106f360235481565b6106726109c3366004615867565b612d62565b6106f36109d636600461562f565b612f74565b6106726130e8565b60255461074d906001600160a01b031681565b610917610a043660046154fa565b6001600160a01b03165f908152600c602052604090205460ff1690565b610672610a2f3660046154fa565b6130fb565b610672610a423660046154fa565b6132c6565b610a83610a553660046154fa565b60156020525f9081526040902080546001820154600283015460038401546004909401549293919290919085565b604080519586526020860194909452928401919091526060830152608082015260a001610656565b610672610ab936600461562f565b6132f0565b61074d73efd766ccb38eaf1dfd701853bfce31359239f30581565b6106f3610ae736600461562f565b600f60209081525f928352604080842090915290825290205481565b610672610b113660046154fa565b613538565b6106f362093a8081565b610672610b2e3660046154cd565b613562565b610672610b4136600461555a565b6135d0565b610672610b543660046158a7565b6137e7565b5f546001600160a01b031661074d565b601e5461074d906001600160a01b031681565b610672610b8a3660046154cd565b613c65565b610672613cb0565b602c5461091790610100900460ff1681565b610672610bb73660046157cb565b613d7a565b6106f3610bca36600461562f565b601160209081525f928352604080842090915290825290205481565b60265461074d906001600160a01b031681565b6106f360185481565b610c50610c103660046154fa565b600b6020525f9081526040902080546001820154600283015460038401546004850154600590950154939492939192909160ff8082169161010090041687565b604080519788526020880196909652948601939093526060850191909152608084015260ff1660a0830152151560c082015260e001610656565b610672610c983660046154fa565b613ef1565b6106f3600d5481565b610672610cb43660046158e5565b613f1b565b610672610cc73660046154fa565b613f39565b610672613ff1565b6106f3600e5481565b61074d610ceb3660046154cd565b61400b565b6106f360065481565b610672610d0736600461555a565b614033565b61074d610d1a3660046154cd565b61417a565b610672610d2d366004615900565b614189565b61074d73165c3410fc91ef562c50559f7d2289febed552d981565b6106f360035481565b6106f360095481565b610672610d6d366004615722565b6141e9565b610672610d803660046154cd565b6143cd565b610672610d933660046154cd565b614418565b610672610da63660046158a7565b614471565b6106f360075481565b610917610dc23660046154fa565b60216020525f908152604090205460ff1681565b6106f3601f5481565b6106f3601c5481565b6106f360045481565b610a83610dff3660046154fa565b6001600160a01b03165f90815260156020526040902080546002820154600183015460038401546004909401549294919390929091565b6106f361271081565b610672610e4d366004615920565b614624565b610672610e603660046154fa565b6146c3565b6106f3601d5481565b602254610e7b9060ff1681565b60405160ff9091168152602001610656565b61074d73a1077a294dde1b09bb078844df40758a5d0f9a2781565b602a5461074d906001600160a01b031681565b60285461074d906001600160a01b031681565b610672610edc3660046154fa565b6146ed565b610672610eef3660046154cd565b614727565b6106f360175481565b610672610f0b3660046154cd565b614734565b6106f3610f1e3660046154fa565b60126020525f908152604090205481565b610672610f3d366004615948565b614772565b6106f360015481565b6060600a805480602002602001604051908101604052809291908181526020018280548015610fa157602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311610f83575b5050505050905090565b610fb361478e565b600355565b6001600160a01b0381165f908152600b6020526040812060038101548291829182918291829182918290610fec575f61101c565b670de0b6b3a7640000808360030154600d54611008919061598b565b61101291906159b6565b61101c91906159b6565b90505f5f821161102d575f1961103a565b825461103a9083906159b6565b835460018501546002860154600590960154919e909d50949b5092995060ff61010084048116995090975090911694509092505050565b6110796147ba565b6029546001600160a01b031633148061109b57505f546001600160a01b031633145b6110c05760405162461bcd60e51b81526004016110b7906159c9565b60405180910390fd5b8281146110df5760405162461bcd60e51b81526004016110b7906159e7565b826111195760405162461bcd60e51b815260206004820152600a6024820152694e6f2077696e6e65727360b01b60448201526064016110b7565b601c54611129906207e900615a09565b4210156111635760405162461bcd60e51b81526020600482015260086024820152672a37b79039b7b7b760c11b60448201526064016110b7565b601d54601a5410156111d357601a546040805182815260208101929092527f8db0ebe5f64ac513aa57bc8f320f1b18dd3b7c6dc2cc68f383ee0521eb964bbc910160405180910390a142601c55601b8054905f6111bf83615a1c565b91905055506111ce84846147d5565b611495565b601e54601f54601a546001600160a01b03909216915f91612710916111f8919061598b565b61120291906159b6565b90505f61120d61482b565b90505f8211801561121d57505f81115b156112b7575f61122d82846159b6565b905080156112b5575f5b6020548110156112b3575f6020828154811061125557611255615a34565b5f918252602090912001546001600160a01b0316905061127481614886565b61127e57506112ab565b82601a5f82825461128f9190615a48565b909155506112a990506001600160a01b0387168285614926565b505b600101611237565b505b505b5f805b858110156112f0578686828181106112d4576112d4615a34565b90506020020135826112e69190615a09565b91506001016112ba565b50601a548111156113325760405162461bcd60e51b815260206004820152600c60248201526b115e18d959591cc81c1bdbdb60a21b60448201526064016110b7565b5f5b8781101561142a575f87878381811061134f5761134f615a34565b9050602002013511801561139257505f89898381811061137157611371615a34565b905060200201602081019061138691906154fa565b6001600160a01b031614155b15611422578686828181106113a9576113a9615a34565b90506020020135601a5f8282546113c09190615a48565b9091555061142290508989838181106113db576113db615a34565b90506020020160208101906113f091906154fa565b88888481811061140257611402615a34565b90506020020135876001600160a01b03166149269092919063ffffffff16565b600101611334565b507fa96d0397e2fe4d6ef9f2667b45bd71a2f3ececf47b0147ff3c6652763cc1467088888888601b548660405161146696959493929190615a5b565b60405180910390a142601c55601b8054905f61148183615a1c565b919050555061149088886147d5565b505050505b6114ab60015f516020615cbe5f395f51905f5255565b50505050565b6114b961478e565b5f81116114f35760405162461bcd60e51b8152602060048201526008602482015267426164207261746560c01b60448201526064016110b7565b600d55565b61150061478e565b602c805461ff00191690556040517f9bb3a4a301e0fd406aaa546b2a772ebc9fca96f40128b2d160d9df351bcbf1bf905f90a1565b61153d61478e565b602c805460ff1916911515919091179055565b61155861478e565b6001600160a01b0382165f908152600c602052604090205460ff16156115a95760405162461bcd60e51b815260206004820152600660248201526545786973747360d01b60448201526064016110b7565b6001600160a01b0382166115eb5760405162461bcd60e51b81526020600482015260096024820152682d32b9379030b2323960b91b60448201526064016110b7565b600a805460018181019092557fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180546001600160a01b0385166001600160a01b031990911681179091555f818152600c60209081526040808320805460ff191686179055805160e081018252838152808301848152818301858152606083018681526080840187815260ff8b811660a0870190815260c087018c81528b8b52600b909952878a209651875594519a86019a909a55915160028501555160038401555160048301555160059091018054935115156101000261ffff19909416919096161791909117909355915190917f636b8a2520822c5b7b7d8e7ab81293e4efae637cf0bd895c34c4c1ecacc66525916117149190859091825260ff16602082015260400190565b60405180910390a25050565b6117286147ba565b602c5460ff161561174b5760405162461bcd60e51b81526004016110b790615ae8565b335f908152600f602090815260408083206001600160a01b0386168452909152902054806117a35760405162461bcd60e51b8152602060048201526005602482015264456d70747960d81b60448201526064016110b7565b335f908152600f602090815260408083206001600160a01b03871684529091528120819055602354612710906117d9908461598b565b6117e391906159b6565b90505f612710602454846117f7919061598b565b61180191906159b6565b90505f8161180f8486615a48565b6118199190615a48565b9050858115611836576118366001600160a01b0382163384614926565b8315611888576025545f906001600160a01b03166118545786611861565b6025546001600160a01b03165b90506001600160a01b03811615611886576118866001600160a01b0383168287614926565b505b5f831180156118a157506026546001600160a01b031615155b156118c0576026546118c0906001600160a01b03838116911685614926565b604080518381526001600160a01b03888116602083015289169133915f516020615c9e5f395f51905f52910160405180910390a3505050505061190f60015f516020615cbe5f395f51905f5255565b5050565b6029546001600160a01b031633148061193557505f546001600160a01b031633145b6119515760405162461bcd60e51b81526004016110b7906159c9565b6001600160a01b0381166119945760405162461bcd60e51b815260206004820152600a60248201526910985908185c9d1a5cdd60b21b60448201526064016110b7565b6001600160a01b038281165f8181526015602052604090819020549051928416927f628b7356de2062bea33757b892caf43731bcc3555f6fe746af75a640c1375d51916119eb914290918252602082015260400190565b60405180910390a35050565b6119ff6147ba565b602c5460ff1615611a225760405162461bcd60e51b81526004016110b790615ae8565b6001600160a01b0386165f908152600c602052604090205460ff16611a595760405162461bcd60e51b81526004016110b790615b08565b6001600160a01b0386165f908152600b6020526040902060050154610100900460ff16611ab35760405162461bcd60e51b8152602060048201526008602482015267496e61637469766560c01b60448201526064016110b7565b5f8711611aef5760405162461bcd60e51b815260206004820152600a6024820152695a65726f2064656c746160b01b60448201526064016110b7565b6001600160a01b0389165f90815260136020526040902054611b12906001615a09565b8314611b4c5760405162461bcd60e51b8152602060048201526009602482015268426164206e6f6e636560b81b60448201526064016110b7565b611b5d89898989898989898961495b565b6001600160a01b0389165f908152601360205260409020839055611b8389878987614a75565b6001600160a01b0389165f9081526010602052604081208054899290611baa908490615a09565b90915550506001600160a01b0389165f9081526012602052604081208054899290611bd6908490615a09565b90915550611be690508989614d93565b6001600160a01b038981165f90815260146020526040902054811690871614611c37576001600160a01b038981165f90815260146020526040902080546001600160a01b0319169188169190911790555b6001600160a01b0389165f8181526010602090815260408083205460158352928190205481518c8152928301939093528101919091527f635fe28e1e101300ac11cb078440df04c1998af47d23bf2bbad91fa92944589c9060600160405180910390a2611cb060015f516020615cbe5f395f51905f5255565b505050505050505050565b6029546001600160a01b0316331480611cdd57505f546001600160a01b031633145b611cf95760405162461bcd60e51b81526004016110b7906159c9565b6001600160a01b0382165f908152600c602052604090205460ff16611d305760405162461bcd60e51b81526004016110b790615b2b565b5f8111611d6b5760405162461bcd60e51b815260206004820152600960248201526842616420707269636560b81b60448201526064016110b7565b6001600160a01b0382165f818152600b60205260408082206003810185905542600490910155517fe36d126b25a23b3eb8b1322ea5a6df9be5d680c05fa2c496adfef77193de7d3591611714918590918252602082015260400190565b6001600160a01b0382165f908152600c602052604090205460ff16611dff5760405162461bcd60e51b81526004016110b790615b2b565b611e146001600160a01b038316333084614f42565b6001600160a01b0382165f908152600b602052604081208054839290611e3b908490615a09565b90915550506001600160a01b0382165f908152600b602052604081206001018054839290611e6a908490615a09565b90915550506001600160a01b0382165f908152600b6020526040812060030154611e94575f611edc565b6001600160a01b0383165f908152600b6020526040902060030154600d54670de0b6b3a7640000918291611ec8919061598b565b611ed291906159b6565b611edc91906159b6565b90505f5f8211611eed575f19611f10565b6001600160a01b0384165f908152600b6020526040902054611f109083906159b6565b6001600160a01b0385165f818152600b602090815260409182902054825188815291820152908101839052919250905f516020615c7e5f395f51905f529060600160405180910390a250505050565b611f6761478e565b818310158015611f775750808210155b611faf5760405162461bcd60e51b81526020600482015260096024820152682130b21037b93232b960b91b60448201526064016110b7565b612710811015611fef5760405162461bcd60e51b815260206004820152600b60248201526a0aadcc6dedadadedc7862f60ab1b60448201526064016110b7565b600792909255600855600955565b61200561478e565b6001600160a01b0382165f908152600c602052604090205460ff161561208d576001600160a01b0382165f908152600b6020526040902060050154610100900460ff161561208d5760405162461bcd60e51b815260206004820152601560248201527411195858dd1a5d985d19481c1bdbdb08199a5c9cdd605a1b60448201526064016110b7565b61190f6120a15f546001600160a01b031690565b6001600160a01b0384169083614926565b6120ba61478e565b5f5b600a548110156122d5575f600a82815481106120da576120da615a34565b5f9182526020822001546040516370a0823160e01b81523060048201526001600160a01b03909116925082906370a0823190602401602060405180830381865afa15801561212a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061214e9190615b52565b6001600160a01b0383165f908152600b6020526040902054909150808211156122ca575f61217c8284615a48565b6001600160a01b0385165f908152600b60205260408120805492935083929091906121a8908490615a09565b90915550506001600160a01b0384165f908152600b6020526040812060010180548392906121d7908490615a09565b90915550506001600160a01b0384165f908152600b6020526040812060030154612201575f612249565b6001600160a01b0385165f908152600b6020526040902060030154600d54670de0b6b3a7640000918291612235919061598b565b61223f91906159b6565b61224991906159b6565b90505f5f821161225a575f1961227d565b6001600160a01b0386165f908152600b602052604090205461227d9083906159b6565b6001600160a01b0387165f818152600b602090815260409182902054825188815291820152908101839052919250905f516020615c7e5f395f51905f529060600160405180910390a25050505b5050506001016120bc565b50565b600a5460609081905f816001600160401b038111156122f9576122f9615b69565b604051908082528060200260200182016040528015612322578160200160208202803683370190505b5090505f826001600160401b0381111561233e5761233e615b69565b604051908082528060200260200182016040528015612367578160200160208202803683370190505b5090505f805b848110156124a1575f600a828154811061238957612389615a34565b5f9182526020808320909101546001600160a01b0316808352600b909152604090912060058101549192509060ff610100909104166123c9575050612499565b5f5f8260030154116123db575f61240b565b670de0b6b3a7640000808360030154600d546123f7919061598b565b61240191906159b6565b61240b91906159b6565b90505f5f821161241c575f19612429565b82546124299083906159b6565b9050600354811015612494578388878151811061244857612448615a34565b60200260200101906001600160a01b031690816001600160a01b0316815250508087878151811061247b5761247b615a34565b60209081029190910101528561249081615a1c565b9650505b505050505b60010161236d565b50806001600160401b038111156124ba576124ba615b69565b6040519080825280602002602001820160405280156124e3578160200160208202803683370190505b509550806001600160401b038111156124fe576124fe615b69565b604051908082528060200260200182016040528015612527578160200160208202803683370190505b5094505f5b818110156125bf5783818151811061254657612546615a34565b602002602001015187828151811061256057612560615a34565b60200260200101906001600160a01b031690816001600160a01b03168152505082818151811061259257612592615a34565b60200260200101518682815181106125ac576125ac615a34565b602090810291909101015260010161252c565b50505050509091565b6125d061478e565b601e80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381165f908152600c602052604090205460ff166126295760405162461bcd60e51b81526004016110b790615b2b565b6040516370a0823160e01b81523060048201525f906001600160a01b038316906370a0823190602401602060405180830381865afa15801561266d573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126919190615b52565b6001600160a01b0383165f908152600b60205260409020549091508082111561280d575f6126bf8284615a48565b6001600160a01b0385165f908152600b60205260408120805492935083929091906126eb908490615a09565b90915550506001600160a01b0384165f908152600b60205260408120600101805483929061271a908490615a09565b90915550506001600160a01b0384165f908152600b6020526040812060030154612744575f61278c565b6001600160a01b0385165f908152600b6020526040902060030154600d54670de0b6b3a7640000918291612778919061598b565b61278291906159b6565b61278c91906159b6565b90505f5f821161279d575f196127c0565b6001600160a01b0386165f908152600b60205260409020546127c09083906159b6565b6001600160a01b0387165f818152600b602090815260409182902054825188815291820152908101839052919250905f516020615c7e5f395f51905f529060600160405180910390a25050505b505050565b61281a61478e565b600e55565b602c54610100900460ff166128465760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b0316331461286f5760405162461bcd60e51b81526004016110b7906159c9565b82811461288e5760405162461bcd60e51b81526004016110b7906159e7565b5f5b8381101561296d57600c5f8484848181106128ad576128ad615a34565b90506020020160208101906128c291906154fa565b6001600160a01b0316815260208101919091526040015f205460ff1615612965578282828181106128f5576128f5615a34565b905060200201602081019061290a91906154fa565b60145f87878581811061291f5761291f615a34565b905060200201602081019061293491906154fa565b6001600160a01b03908116825260208201929092526040015f2080546001600160a01b031916929091169190911790555b600101612890565b5050505050565b5f808080808080805b600a548110156129e857600b5f600a838154811061299d5761299d615a34565b5f9182526020808320909101546001600160a01b0316835282019290925260400190206005015460ff61010090910416156129e057816129dc81615a1c565b9250505b60010161297d565b50600a54601a54601c54839190612a039062093a8090615a09565b601b54602c54949c939b509199509750955060ff9091169350915050565b612a2961478e565b818310612a655760405162461bcd60e51b815260206004820152600a602482015269084c2c840e8d0e4cae6d60b31b60448201526064016110b7565b808210612aa15760405162461bcd60e51b815260206004820152600a602482015269084c2c840e8d0e4cae6d60b31b60448201526064016110b7565b6127108110612ae45760405162461bcd60e51b815260206004820152600f60248201526e04d757374206265203c20313030303608c1b60448201526064016110b7565b600492909255600555600655565b602c54610100900460ff16612b195760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b03163314612b425760405162461bcd60e51b81526004016110b7906159c9565b8483148015612b5057508281145b612b6c5760405162461bcd60e51b81526004016110b7906159e7565b5f5b85811015612d5957600c5f868684818110612b8b57612b8b615a34565b9050602002016020810190612ba091906154fa565b6001600160a01b0316815260208101919091526040015f205460ff16612bd85760405162461bcd60e51b81526004016110b790615b08565b828282818110612bea57612bea615a34565b90506020020135600f5f898985818110612c0657612c06615a34565b9050602002016020810190612c1b91906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f878785818110612c4d57612c4d615a34565b9050602002016020810190612c6291906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254612c8f9190615a09565b909155508390508282818110612ca757612ca7615a34565b9050602002013560115f898985818110612cc357612cc3615a34565b9050602002016020810190612cd891906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f878785818110612d0a57612d0a615a34565b9050602002016020810190612d1f91906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254612d4c9190615a09565b9091555050600101612b6e565b50505050505050565b612d6a6147ba565b6029546001600160a01b0316331480612d8c57505f546001600160a01b031633145b612da85760405162461bcd60e51b81526004016110b7906159c9565b602c5460ff1615612dcb5760405162461bcd60e51b81526004016110b790615ae8565b6001600160a01b038084165f908152600f6020908152604080832093861683529290529081205490819003612e005750612f5e565b6001600160a01b038085165f908152600f60209081526040808320938716835292905290812081905560235461271090612e3a908461598b565b612e4491906159b6565b90505f61271060245484612e58919061598b565b612e6291906159b6565b90505f81612e708486615a48565b612e7a9190615a48565b9050858115612e9757612e976001600160a01b0382168984614926565b8315612ee9576025545f906001600160a01b0316612eb55786612ec2565b6025546001600160a01b03165b90506001600160a01b03811615612ee757612ee76001600160a01b0383168287614926565b505b5f83118015612f0257506026546001600160a01b031615155b15612f2157602654612f21906001600160a01b03838116911685614926565b604080518381526001600160a01b038881166020830152808a1692908b16915f516020615c9e5f395f51905f52910160405180910390a350505050505b61280d60015f516020615cbe5f395f51905f5255565b6001600160a01b0381165f908152600c602052604081205460ff161580612fbb57506001600160a01b0382165f908152600b6020526040902060050154610100900460ff16155b15612fc757505f6130e2565b6001600160a01b0382165f908152600b60205260408120600301549003612fef57505f6130e2565b6027545f906001600160a01b031615613070576027546040516306ed11f760e31b81526001600160a01b038681166004830152909116906337688fb890602401602060405180830381865afa925050508015613068575060408051601f3d908101601f1916820190925261306591810190615b52565b60015b156130705790505b5f61271061307e8382615a09565b600d5461308b919061598b565b61309591906159b6565b6001600160a01b0385165f908152600b6020526040902060030154909150670de0b6b3a76400009081906130c9908461598b565b6130d391906159b6565b6130dd91906159b6565b925050505b92915050565b6130f061478e565b6130f95f614f78565b565b6131036147ba565b602c5460ff16156131265760405162461bcd60e51b81526004016110b790615ae8565b5f5b600a548110156132af575f600a828154811061314657613146615a34565b5f918252602080832090910154338352600f825260408084206001600160a01b039092168085529190925290822054909250908190036131875750506132a7565b335f908152600f602090815260408083206001600160a01b03861684529091528120819055602354612710906131bd908461598b565b6131c791906159b6565b90505f612710602454846131db919061598b565b6131e591906159b6565b90505f816131f38486615a48565b6131fd9190615a48565b905084811561321a5761321a6001600160a01b0382163384614926565b831561326c576025545f906001600160a01b03166132385788613245565b6025546001600160a01b03165b90506001600160a01b0381161561326a5761326a6001600160a01b0383168287614926565b505b604080518381526001600160a01b038a8116602083015288169133915f516020615c9e5f395f51905f52910160405180910390a35050505050505b600101613128565b506122d560015f516020615cbe5f395f51905f5255565b6132ce61478e565b602580546001600160a01b0319166001600160a01b0392909216919091179055565b6132f86147ba565b6029546001600160a01b031633148061331a57505f546001600160a01b031633145b6133365760405162461bcd60e51b81526004016110b7906159c9565b602c5460ff16156133595760405162461bcd60e51b81526004016110b790615ae8565b5f5b600a54811015613521575f600a828154811061337957613379615a34565b5f9182526020808320909101546001600160a01b038781168452600f83526040808520919092168085529252822054909250908190036133ba575050613519565b6001600160a01b038086165f908152600f602090815260408083209386168352929052908120819055602354612710906133f4908461598b565b6133fe91906159b6565b90505f61271060245484613412919061598b565b61341c91906159b6565b90505f8161342a8486615a48565b6134349190615a48565b9050848115613451576134516001600160a01b0382168a84614926565b83156134a3576025545f906001600160a01b031661346f578861347c565b6025546001600160a01b03165b90506001600160a01b038116156134a1576134a16001600160a01b0383168287614926565b505b5f831180156134bc57506026546001600160a01b031615155b156134db576026546134db906001600160a01b03838116911685614926565b604080518381526001600160a01b038a8116602083015280891692908c16915f516020615c9e5f395f51905f52910160405180910390a35050505050505b60010161335b565b5061190f60015f516020615cbe5f395f51905f5255565b61354061478e565b602680546001600160a01b0319166001600160a01b0392909216919091179055565b601e5461357a906001600160a01b0316333084614f42565b80601a5f82825461358b9190615a09565b9091555050601a546040805183815260208101929092527fdebc7807341368163ff883cc9f2791669b791ffa7a3c555196bfb70a1453d775910160405180910390a150565b6029546001600160a01b03163314806135f257505f546001600160a01b031633145b61360e5760405162461bcd60e51b81526004016110b7906159c9565b82811461362d5760405162461bcd60e51b81526004016110b7906159e7565b5f5b8381101561296d57600c5f86868481811061364c5761364c615a34565b905060200201602081019061366191906154fa565b6001600160a01b0316815260208101919091526040015f205460ff1615806136a0575082828281811061369657613696615a34565b905060200201355f145b6137df578282828181106136b6576136b6615a34565b90506020020135600b5f8787858181106136d2576136d2615a34565b90506020020160208101906136e791906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f206003018190555042600b5f87878581811061372357613723615a34565b905060200201602081019061373891906154fa565b6001600160a01b0316815260208101919091526040015f206004015584848281811061376657613766615a34565b905060200201602081019061377b91906154fa565b6001600160a01b03167fe36d126b25a23b3eb8b1322ea5a6df9be5d680c05fa2c496adfef77193de7d355f8585858181106137b8576137b8615a34565b905060200201356040516137d6929190918252602082015260400190565b60405180910390a25b60010161362f565b602c54610100900460ff1661380e5760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b031633146138375760405162461bcd60e51b81526004016110b7906159c9565b5f5b8181101561280d573683838381811061385457613854615a34565b90506020028101906138669190615b9d565b905060135f61387860208401846154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f2054816040013511156138d257604081013560135f6138b860208501856154fa565b6001600160a01b0316815260208101919091526040015f20555b5f6138e360408301602084016154fa565b6001600160a01b0316141580156139255750600c5f61390860408401602085016154fa565b6001600160a01b0316815260208101919091526040015f205460ff165b1561397b5761393a60408201602083016154fa565b60145f61394a60208501856154fa565b6001600160a01b03908116825260208201929092526040015f2080546001600160a01b031916929091169190911790555b606081013560125f61399060208501856154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f8282546139bd9190615a09565b9091555050608081013560105f6139d760208501856154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254613a049190615a09565b90915550613a17905060c0820182615bbb565b9050613a2660a0830183615bbb565b905014613a455760405162461bcd60e51b81526004016110b7906159e7565b5f5b613a5460a0830183615bbb565b9050811015613c5b57600c5f613a6d60a0850185615bbb565b84818110613a7d57613a7d615a34565b9050602002016020810190613a9291906154fa565b6001600160a01b0316815260208101919091526040015f205460ff168015613adc57505f613ac360c0840184615bbb565b83818110613ad357613ad3615a34565b90506020020135115b15613c5357613aee60c0830183615bbb565b82818110613afe57613afe615a34565b90506020020135600f5f845f016020810190613b1a91906154fa565b6001600160a01b0316815260208101919091526040015f90812090613b4260a0860186615bbb565b85818110613b5257613b52615a34565b9050602002016020810190613b6791906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254613b949190615a09565b90915550613ba7905060c0830183615bbb565b82818110613bb757613bb7615a34565b9050602002013560115f845f016020810190613bd391906154fa565b6001600160a01b0316815260208101919091526040015f90812090613bfb60a0860186615bbb565b85818110613c0b57613c0b615a34565b9050602002016020810190613c2091906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254613c4d9190615a09565b90915550505b600101613a47565b5050600101613839565b613c6d61478e565b610e10811015613cab5760405162461bcd60e51b81526020600482015260096024820152684261642064656c617960b81b60448201526064016110b7565b600255565b613cb861478e565b602a546001600160a01b0316613cfc5760405162461bcd60e51b81526020600482015260096024820152684e6f206368616e676560b81b60448201526064016110b7565b602b54421015613d1e5760405162461bcd60e51b81526004016110b790615b7d565b60298054602a80546001600160a01b03198084166001600160a01b038381169182179096559116909155604051929091169182907f9275b597b6188dcd901ecae14175fd5b02a5c9dee8bcce5af021f420af6cd1a3905f90a350565b602c54610100900460ff16613da15760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b03163314613dca5760405162461bcd60e51b81526004016110b7906159c9565b8483148015613dd857508481145b613df45760405162461bcd60e51b81526004016110b7906159e7565b5f5b85811015612d5957848482818110613e1057613e10615a34565b9050602002013560125f898985818110613e2c57613e2c615a34565b9050602002016020810190613e4191906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254613e6e9190615a09565b909155508390508282818110613e8657613e86615a34565b9050602002013560105f898985818110613ea257613ea2615a34565b9050602002016020810190613eb791906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254613ee49190615a09565b9091555050600101613df6565b613ef961478e565b602780546001600160a01b0319166001600160a01b0392909216919091179055565b613f2361478e565b6022805460ff191660ff92909216919091179055565b613f4161478e565b6001600160a01b038116613f835760405162461bcd60e51b81526020600482015260096024820152682d32b9379030b2323960b91b60448201526064016110b7565b602a80546001600160a01b0319166001600160a01b038316179055600254613fab9042615a09565b602b8190556040519081526001600160a01b038216907f2a1459dc71e0f6a29305688e3de1620261942b79596c24acce059a6200a268309060200160405180910390a250565b613ff961478e565b602a80546001600160a01b0319169055565b6020818154811061401a575f80fd5b5f918252602090912001546001600160a01b0316905081565b602c54610100900460ff1661405a5760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b031633146140835760405162461bcd60e51b81526004016110b7906159c9565b8281146140a25760405162461bcd60e51b81526004016110b7906159e7565b5f5b8381101561296d5760135f8686848181106140c1576140c1615a34565b90506020020160208101906140d691906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205483838381811061410857614108615a34565b9050602002013511156141725782828281811061412757614127615a34565b9050602002013560135f87878581811061414357614143615a34565b905060200201602081019061415891906154fa565b6001600160a01b0316815260208101919091526040015f20555b6001016140a4565b600a818154811061401a575f80fd5b61419161478e565b61138861419e8284615a09565b11156141de5760405162461bcd60e51b815260206004820152600f60248201526e08af0c6cacac8e640dac2f040e8c2f608b1b60448201526064016110b7565b602391909155602455565b602c54610100900460ff166142105760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b031633146142395760405162461bcd60e51b81526004016110b7906159c9565b6001600160a01b0382165f908152600c602052604090205460ff166142705760405162461bcd60e51b81526004016110b790615b08565b6142856001600160a01b038316333084614f42565b6001600160a01b0382165f908152600b6020526040812080548392906142ac908490615a09565b90915550506001600160a01b0382165f908152600b6020526040812060010180548392906142db908490615a09565b90915550506001600160a01b0382165f908152600b6020526040812060030154614305575f61434d565b6001600160a01b0383165f908152600b6020526040902060030154600d54670de0b6b3a7640000918291614339919061598b565b61434391906159b6565b61434d91906159b6565b6001600160a01b0384165f818152600b6020526040902054919250905f516020615c7e5f395f51905f5290849084614386575f196143a9565b6001600160a01b0387165f908152600b60205260409020546143a99086906159b6565b604080519384526020840192909252908201526060015b60405180910390a2505050565b6143d561478e565b6107d08111156144135760405162461bcd60e51b815260206004820152600960248201526813585e080c8c1c18dd60ba1b60448201526064016110b7565b601f55565b61442061478e565b603c81101580156144335750610e108111155b61446c5760405162461bcd60e51b815260206004820152600a6024820152694261642077696e646f7760b01b60448201526064016110b7565b600155565b6029546001600160a01b031633148061449357505f546001600160a01b031633145b6144af5760405162461bcd60e51b81526004016110b7906159c9565b5f5b60205481101561450d575f60215f602084815481106144d2576144d2615a34565b5f918252602080832091909101546001600160a01b031683528201929092526040019020805460ff19169115159190911790556001016144b1565b5061451960205f61544e565b5f5b8181101561280d5760215f84848481811061453857614538615a34565b905060200201602081019061454d91906154fa565b6001600160a01b0316815260208101919091526040015f205460ff1661461c57602083838381811061458157614581615a34565b905060200201602081019061459691906154fa565b8154600180820184555f9384526020842090910180546001600160a01b0319166001600160a01b039390931692909217909155906021908585858181106145df576145df615a34565b90506020020160208101906145f491906154fa565b6001600160a01b0316815260208101919091526040015f20805460ff19169115159190911790555b60010161451b565b61462c61478e565b6001600160a01b0382165f908152600c602052604090205460ff166146635760405162461bcd60e51b81526004016110b790615b2b565b6001600160a01b0382165f818152600b60205260409081902060050180548415156101000261ff0019909116179055517e8ffc907c147b686f342f9d04a1986e3a56bf453b5f4a99b59a85c1f1f4b6ec9061171490841515815260200190565b6146cb61478e565b602880546001600160a01b0319166001600160a01b0392909216919091179055565b6146f561478e565b6001600160a01b03811661471e57604051631e4fbdf760e01b81525f60048201526024016110b7565b6122d581614f78565b61472f61478e565b601d55565b6029546001600160a01b031633148061475657505f546001600160a01b031633145b61357a5760405162461bcd60e51b81526004016110b7906159c9565b61477a61478e565b601693909355601791909155601855601955565b5f546001600160a01b031633146130f95760405163118cdaa760e01b81523360048201526024016110b7565b6147c2614fc7565b60025f516020615cbe5f395f51905f5255565b5f5b8181101561280d575f60105f8585858181106147f5576147f5615a34565b905060200201602081019061480a91906154fa565b6001600160a01b0316815260208101919091526040015f20556001016147d7565b5f805b602054811015614882576148676020828154811061484e5761484e615a34565b5f918252602090912001546001600160a01b0316614886565b1561487a578161487681615a1c565b9250505b60010161482e565b5090565b6027545f906001600160a01b031661489f57505f919050565b602754604051630edf617560e41b81526001600160a01b0384811660048301529091169063edf6175090602401602060405180830381865afa925050508015614905575060408051601f3d908101601f1916820190925261490291810190615c00565b60015b61491057505f919050565b60225460ff91821691161492915050565b919050565b6149338383836001614ff6565b61280d57604051635274afe760e01b81526001600160a01b03841660048201526024016110b7565b5f6001544261496a91906159b6565b604080516001600160a01b03808e1660208301529181018c9052606081018b9052818a16608082015290881660a082015260c0810187905260e0810186905261010081018290529091505f90610120016040516020818303038152906040528051906020012090505f614a1d85858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250614a1792508691506150589050565b9061508a565b6029549091506001600160a01b03808316911614614a675760405162461bcd60e51b81526020600482015260076024820152664261642073696760c81b60448201526064016110b7565b505050505050505050505050565b6001600160a01b0383165f908152600b602052604081206003810154909103614a9e57506114ab565b5f670de0b6b3a7640000808360030154600d5487614abc919061598b565b614ac6919061598b565b614ad091906159b6565b614ada91906159b6565b9050805f03614aea5750506114ab565b81545f908211614afa5781614afd565b82545b9050805f03614b0e575050506114ab565b602854612710905f906001600160a01b031615614bf05760285f9054906101000a90046001600160a01b03166001600160a01b031663d805b6506040518163ffffffff1660e01b81526004016020604051808303815f875af1925050508015614b94575060408051601f3d908101601f19168201909252614b9191810190615c1b565b60015b15614bf0575f614baf6127106001600160401b038416615c41565b9050600454811015614bc957600754935060019250614bed565b600554811015614bdd576008549350614bed565b600654811015614bed5760095493505b50505b5f612710614bfe848661598b565b614c0891906159b6565b8654909150811115614c18575084545b805f03614c2a575050505050506114ab565b80865f015f828254614c3c9190615a48565b9250508190555080866002015f828254614c569190615a09565b90915550506001600160a01b03808b165f908152600f60209081526040808320938d1683529290529081208054839290614c91908490615a09565b90915550506001600160a01b03808b165f908152601160209081526040808320938d1683529290529081208054839290614ccc908490615a09565b9091555050604080518681526020810183905290810184905282151560608201526001600160a01b03808b1691908c16907fd3042a53eaaad09313490338daad8d1cdcbe701c5c1a19bcb0ff8a1a837fc8199060800160405180910390a38115614d8757886001600160a01b03168a6001600160a01b03167ff389a375bbcf0ba97f38cc0e5c5468a6d7905c752eb92b5f08ca60debd5c0dbe838a604051614d7e929190918252602082015260400190565b60405180910390a35b50505050505050505050565b805f03614d9e575050565b6001600160a01b0382165f90815260156020526040812090614dc362015180426159b6565b905080826001015403614dd65750505050565b5f614de2600183615a48565b905082600101545f03614e0057600183556016546002840155614ec0565b80836001015403614e32578254835f614e1883615a1c565b90915550508254614e28906150b2565b6002840155614ec0565b600383015415614eb3575f6001846001015484614e4f9190615a48565b614e599190615a48565b905080600103614ea057600384018054905f614e7483615c54565b90915550508354845f614e8683615a1c565b90915550508354614e96906150b2565b6002850155614ead565b6001845560165460028501555b50614ec0565b6001835560165460028401555b60018301829055600483018054905f614ed883615a1c565b9190505550614eea85845f015461516c565b825460028401546040516001600160a01b038816927fd9ad1f2b351c160231808ff9bc723542c8d3b0cdad54db25801bfe561bd4c6e392614f3392918252602082015260400190565b60405180910390a25050505050565b614f50848484846001615218565b6114ab57604051635274afe760e01b81526001600160a01b03851660048201526024016110b7565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f516020615cbe5f395f51905f52546002036130f957604051633ee5aeb560e01b815260040160405180910390fd5b60405163a9059cbb60e01b5f8181526001600160a01b038616600452602485905291602083604481808b5af1925060015f5114831661504c578383151615615040573d5f823e3d81fd5b5f873b113d1516831692505b60405250949350505050565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000005f908152601c91909152603c902090565b5f5f5f5f6150988686615285565b9250925092506150a882826152ce565b5090949350505050565b5f80600783116150d0576016546150c9908461598b565b9050615152565b601e8311615108576017546150e6600785615a48565b6150f0919061598b565b6016546150fe90600761598b565b6150c99190615a09565b601854615116601e85615a48565b615120919061598b565b6017805461512d9161598b565b60165461513b90600761598b565b6151459190615a09565b61514f9190615a09565b90505b60195481116151615780615165565b6019545b9392505050565b6001600160a01b0382165f9081526015602052604090206007821480615192575081601e145b8061519d575081605a145b806151a857508160b4145b1561280d57600381018054905f6151be83615a1c565b91905055506003816003015411156151d7576003818101555b60408051838152600160208201526001600160a01b038516917f3e36978d09ecbfcd5deec4f3c53e931d9a55776a08d36e727728c8f6b285f26091016143c0565b6040516323b872dd60e01b5f8181526001600160a01b038781166004528616602452604485905291602083606481808c5af1925060015f51148316615274578383151615615268573d5f823e3d81fd5b5f883b113d1516831692505b604052505f60605295945050505050565b5f5f5f83516041036152bc576020840151604085015160608601515f1a6152ae88828585615386565b9550955095505050506152c7565b505081515f91506002905b9250925092565b5f8260038111156152e1576152e1615c69565b036152ea575050565b60018260038111156152fe576152fe615c69565b0361531c5760405163f645eedf60e01b815260040160405180910390fd5b600282600381111561533057615330615c69565b036153515760405163fce698f760e01b8152600481018290526024016110b7565b600382600381111561536557615365615c69565b0361190f576040516335e2f38360e21b8152600481018290526024016110b7565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411156153bf57505f91506003905082615444565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015615410573d5f5f3e3d5ffd5b5050604051601f1901519150506001600160a01b03811661543b57505f925060019150829050615444565b92505f91508190505b9450945094915050565b5080545f8255905f5260205f20906130f991905f5b8082111561280d575f81840155600101615463565b5f8151808452602084019350602083015f5b828110156154b15781516001600160a01b031686526020958601959091019060010161548a565b5093949350505050565b602081525f6151656020830184615478565b5f602082840312156154dd575f5ffd5b5035919050565b80356001600160a01b0381168114614921575f5ffd5b5f6020828403121561550a575f5ffd5b615165826154e4565b5f5f83601f840112615523575f5ffd5b5081356001600160401b03811115615539575f5ffd5b6020830191508360208260051b8501011115615553575f5ffd5b9250929050565b5f5f5f5f6040858703121561556d575f5ffd5b84356001600160401b03811115615582575f5ffd5b61558e87828801615513565b90955093505060208501356001600160401b038111156155ac575f5ffd5b6155b887828801615513565b95989497509550505050565b80358015158114614921575f5ffd5b5f602082840312156155e3575f5ffd5b615165826155c4565b60ff811681146122d5575f5ffd5b5f5f6040838503121561560b575f5ffd5b615614836154e4565b91506020830135615624816155ec565b809150509250929050565b5f5f60408385031215615640575f5ffd5b615649836154e4565b9150615657602084016154e4565b90509250929050565b5f5f5f5f5f5f5f5f5f6101008a8c031215615679575f5ffd5b6156828a6154e4565b985060208a0135975060408a0135965061569e60608b016154e4565b95506156ac60808b016154e4565b945060a08a0135935060c08a0135925060e08a01356001600160401b038111156156d4575f5ffd5b8a01601f81018c136156e4575f5ffd5b80356001600160401b038111156156f9575f5ffd5b8c602082840101111561570a575f5ffd5b60208201935080925050509295985092959850929598565b5f5f60408385031215615733575f5ffd5b61573c836154e4565b946020939093013593505050565b5f5f5f6060848603121561575c575f5ffd5b505081359360208301359350604090920135919050565b604081525f6157856040830185615478565b82810360208401528084518083526020830191506020860192505f5b818110156157bf5783518352602093840193909201916001016157a1565b50909695505050505050565b5f5f5f5f5f5f606087890312156157e0575f5ffd5b86356001600160401b038111156157f5575f5ffd5b61580189828a01615513565b90975095505060208701356001600160401b0381111561581f575f5ffd5b61582b89828a01615513565b90955093505060408701356001600160401b03811115615849575f5ffd5b61585589828a01615513565b979a9699509497509295939492505050565b5f5f5f60608486031215615879575f5ffd5b615882846154e4565b9250615890602085016154e4565b915061589e604085016154e4565b90509250925092565b5f5f602083850312156158b8575f5ffd5b82356001600160401b038111156158cd575f5ffd5b6158d985828601615513565b90969095509350505050565b5f602082840312156158f5575f5ffd5b8135615165816155ec565b5f5f60408385031215615911575f5ffd5b50508035926020909101359150565b5f5f60408385031215615931575f5ffd5b61593a836154e4565b9150615657602084016155c4565b5f5f5f5f6080858703121561595b575f5ffd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176130e2576130e2615977565b634e487b7160e01b5f52601260045260245ffd5b5f826159c4576159c46159a2565b500490565b602080825260049082015263082eae8d60e31b604082015260600190565b60208082526008908201526709ad2e6dac2e8c6d60c31b604082015260600190565b808201808211156130e2576130e2615977565b5f60018201615a2d57615a2d615977565b5060010190565b634e487b7160e01b5f52603260045260245ffd5b818103818111156130e2576130e2615977565b608080825281018690525f8760a08301825b89811015615a9b576001600160a01b03615a86846154e4565b16825260209283019290910190600101615a6d565b5083810360208501528681526001600160fb1b03871115615aba575f5ffd5b8660051b91508188602083013760208282010192505050836040830152826060830152979650505050505050565b60208082526006908201526514185d5cd95960d21b604082015260600190565b6020808252600990820152682130b2103a37b5b2b760b91b604082015260600190565b6020808252600d908201526c139bdd081cdd5c1c1bdc9d1959609a1b604082015260600190565b5f60208284031215615b62575f5ffd5b5051919050565b634e487b7160e01b5f52604160045260245ffd5b602080825260069082015265131bd8dad95960d21b604082015260600190565b5f823560de19833603018112615bb1575f5ffd5b9190910192915050565b5f5f8335601e19843603018112615bd0575f5ffd5b8301803591506001600160401b03821115615be9575f5ffd5b6020019150600581901b3603821315615553575f5ffd5b5f60208284031215615c10575f5ffd5b8151615165816155ec565b5f60208284031215615c2b575f5ffd5b81516001600160401b0381168114615165575f5ffd5b5f82615c4f57615c4f6159a2565b500690565b5f81615c6257615c62615977565b505f190190565b634e487b7160e01b5f52602160045260245ffdfe97e12f1c44b21051b923802d8094fe3237ddd78bcb36f91756180975f639a362b980dfc709fc65b9489197f87620cf86cb0d70f3ed844483e41acd41f7d0b2009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a264697066735822122008b8a0d00bb472d2a2bd1239e24e424ee4c9df17324b2274dbf075ae2cb0b84a64736f6c6343000822003300000000000000000000000017e7b189982d8df2539d059b46467a09a7bcb91d000000000000000000000000d7a138d66251ec49333e6a2c4b50781e7f49702d000000000000000000000000a96bcbed7f01de6ceed14fc86d90f21a36de2143000000000000000000000000956f90d84d9dd5ac0efa39679e6fa75d4ca8c934000000000000000000000000756639c761e228143780e022a175325d79797eec

Deployed ByteCode

0x608060405234801561000f575f5ffd5b506004361061063d575f3560e01c8063843a5a4711610341578063c74d50b1116101ba578063e2f1b79211610109578063f2fde38b116100a9578063f6ba229511610084578063f6ba229514610efd578063f762ab8514610f10578063f9f5d09d14610f2f578063fbc7b53014610f42575f5ffd5b8063f2fde38b14610ece578063f3b6328c14610ee1578063f4aecd5114610ef4575f5ffd5b8063ecef233f116100e4578063ecef233f14610e6e578063ef8ef56f14610e8d578063ef9c7bce14610ea8578063f0d86d5514610ebb575f5ffd5b8063e2f1b79214610e3f578063e38bf1c314610e52578063e7df057614610e65575f5ffd5b8063d1b4f4e511610174578063d66ddbec1161014f578063d66ddbec14610ddf578063d918ca6014610de8578063dc95573b14610df1578063e1a4521814610e36575f5ffd5b8063d1b4f4e514610dab578063d27794c614610db4578063d2d2d90114610dd6575f5ffd5b8063c74d50b114610d4d578063cabcc5d814610d56578063cd4823fd14610d5f578063cda2c34714610d72578063cfe32bd514610d85578063d0902a0f14610d98575f5ffd5b8063a34cbbfb11610290578063bd11187011610230578063c37f4b7b1161020b578063c37f4b7b14610cf9578063c625562614610d0c578063c647b20e14610d1f578063c687782214610d32575f5ffd5b8063bd11187014610cd4578063bf62b08514610cdd578063c2465c8414610cf0575f5ffd5b8063a97f999d1161026b578063a97f999d14610c9d578063ae5e8b3014610ca6578063b92db50314610cb9578063bc485fab14610ccc575f5ffd5b8063a34cbbfb14610bf9578063a4063dbc14610c02578063a790022014610c8a575f5ffd5b80638ec9925e116102fb57806398c8bece116102d657806398c8bece14610b975780639ab3ec2f14610ba95780639caa855c14610bbc5780639fa43af414610be6575f5ffd5b80638ec9925e14610b695780638f4aaa8714610b7c578063985498dc14610b8f575f5ffd5b8063843a5a4714610b0357806384ae2a7414610b165780638571c44114610b205780638be5742814610b335780638ce8852014610b465780638da5cb5b14610b59575f5ffd5b80633b7ef933116104d35780635e6030e01161042257806375151b63116103c257806379fd93651161039d57806379fd936514610a475780637a58043414610aab5780637aabea9514610abe57806380ac822814610ad9575f5ffd5b806375151b63146109f657806377329f3514610a2157806378e3079e14610a34575f5ffd5b80636bf9b731116103fd5780636bf9b731146109b55780637059e9f8146109c8578063715018a6146109db578063737ea06e146109e3575f5ffd5b80635e6030e01461099a5780635ef5cc4a146109a3578063604bc053146109ac575f5ffd5b806349adc84e1161048d57806350c1d19d1161046857806350c1d19d14610930578063558ce2531461096757806359d0677d1461097a5780635c975abb1461098d575f5ffd5b806349adc84e146108e25780634f129c53146108f55780634fc57c8714610927575f5ffd5b80633b7ef9331461088e5780633d74076914610897578063438d33d7146108aa5780634535ea9c146108b3578063468d4ca2146108c65780634915a858146108cf575f5ffd5b806321c0b3421161058f5780632c597de91161054957806333f3d6281161052457806333f3d6281461084a5780633564fe381461085d57806337b7e152146108655780633922e30914610878575f5ffd5b80632c597de91461080f5780632d42783d146108185780632f7801f41461082b575f5ffd5b806321c0b342146107a75780632247e21c146107ba57806326351e52146107cd57806328f5250e146107e05780632bfd5146146107f35780632c1d7ebd14610806575f5ffd5b80630fc0482a116105fa57806316c38b3c116105d557806316c38b3c146107655780631709a61b146107785780631b68fb5d1461078b5780631f87f6db14610794575f5ffd5b80630fc0482a146107145780631136fcf21461071c57806311cc69cb14610725575f5ffd5b80630107e472146106415780630312ba2f1461065f57806306bfa93814610674578063086640aa146106c15780630bad91d3146106d45780630e13585314610701575b5f5ffd5b610649610f4b565b60405161065691906154bb565b60405180910390f35b61067261066d3660046154cd565b610fab565b005b6106876106823660046154fa565b610fb8565b6040805197885260208801969096529486019390935260608501919091521515608084015260a083015260ff1660c082015260e001610656565b6106726106cf36600461555a565b611071565b6106f36106e23660046154fa565b60106020525f908152604090205481565b604051908152602001610656565b61067261070f3660046154cd565b6114b1565b6106726114f8565b6106f3601a5481565b61074d6107333660046154fa565b60146020525f90815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610656565b6106726107733660046155d3565b611535565b60295461074d906001600160a01b031681565b6106f360055481565b6106726107a23660046155fa565b611550565b6106726107b536600461562f565b611720565b6106726107c836600461562f565b611913565b6106726107db366004615660565b6119f7565b6106726107ee366004615722565b611cbb565b610672610801366004615722565b611dc8565b6106f3602b5481565b6106f361138881565b61067261082636600461574a565b611f5f565b6106f36108393660046154fa565b60136020525f908152604090205481565b610672610858366004615722565b611ffd565b6106726120b2565b60275461074d906001600160a01b031681565b6108806122d8565b604051610656929190615773565b6106f360165481565b6106726108a53660046154fa565b6125c8565b6106f360245481565b6106726108c13660046154fa565b6125f2565b6106f360025481565b6106726108dd3660046154cd565b612812565b6106726108f036600461555a565b61281f565b6109176109033660046154fa565b600c6020525f908152604090205460ff1681565b6040519015158152602001610656565b6106f360195481565b610938612974565b6040805196875260208701959095529385019290925260608401526080830152151560a082015260c001610656565b61067261097536600461574a565b612a21565b6106726109883660046157cb565b612af2565b602c546109179060ff1681565b6106f360085481565b6106f3601b5481565b6106f360235481565b6106726109c3366004615867565b612d62565b6106f36109d636600461562f565b612f74565b6106726130e8565b60255461074d906001600160a01b031681565b610917610a043660046154fa565b6001600160a01b03165f908152600c602052604090205460ff1690565b610672610a2f3660046154fa565b6130fb565b610672610a423660046154fa565b6132c6565b610a83610a553660046154fa565b60156020525f9081526040902080546001820154600283015460038401546004909401549293919290919085565b604080519586526020860194909452928401919091526060830152608082015260a001610656565b610672610ab936600461562f565b6132f0565b61074d73efd766ccb38eaf1dfd701853bfce31359239f30581565b6106f3610ae736600461562f565b600f60209081525f928352604080842090915290825290205481565b610672610b113660046154fa565b613538565b6106f362093a8081565b610672610b2e3660046154cd565b613562565b610672610b4136600461555a565b6135d0565b610672610b543660046158a7565b6137e7565b5f546001600160a01b031661074d565b601e5461074d906001600160a01b031681565b610672610b8a3660046154cd565b613c65565b610672613cb0565b602c5461091790610100900460ff1681565b610672610bb73660046157cb565b613d7a565b6106f3610bca36600461562f565b601160209081525f928352604080842090915290825290205481565b60265461074d906001600160a01b031681565b6106f360185481565b610c50610c103660046154fa565b600b6020525f9081526040902080546001820154600283015460038401546004850154600590950154939492939192909160ff8082169161010090041687565b604080519788526020880196909652948601939093526060850191909152608084015260ff1660a0830152151560c082015260e001610656565b610672610c983660046154fa565b613ef1565b6106f3600d5481565b610672610cb43660046158e5565b613f1b565b610672610cc73660046154fa565b613f39565b610672613ff1565b6106f3600e5481565b61074d610ceb3660046154cd565b61400b565b6106f360065481565b610672610d0736600461555a565b614033565b61074d610d1a3660046154cd565b61417a565b610672610d2d366004615900565b614189565b61074d73165c3410fc91ef562c50559f7d2289febed552d981565b6106f360035481565b6106f360095481565b610672610d6d366004615722565b6141e9565b610672610d803660046154cd565b6143cd565b610672610d933660046154cd565b614418565b610672610da63660046158a7565b614471565b6106f360075481565b610917610dc23660046154fa565b60216020525f908152604090205460ff1681565b6106f3601f5481565b6106f3601c5481565b6106f360045481565b610a83610dff3660046154fa565b6001600160a01b03165f90815260156020526040902080546002820154600183015460038401546004909401549294919390929091565b6106f361271081565b610672610e4d366004615920565b614624565b610672610e603660046154fa565b6146c3565b6106f3601d5481565b602254610e7b9060ff1681565b60405160ff9091168152602001610656565b61074d73a1077a294dde1b09bb078844df40758a5d0f9a2781565b602a5461074d906001600160a01b031681565b60285461074d906001600160a01b031681565b610672610edc3660046154fa565b6146ed565b610672610eef3660046154cd565b614727565b6106f360175481565b610672610f0b3660046154cd565b614734565b6106f3610f1e3660046154fa565b60126020525f908152604090205481565b610672610f3d366004615948565b614772565b6106f360015481565b6060600a805480602002602001604051908101604052809291908181526020018280548015610fa157602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311610f83575b5050505050905090565b610fb361478e565b600355565b6001600160a01b0381165f908152600b6020526040812060038101548291829182918291829182918290610fec575f61101c565b670de0b6b3a7640000808360030154600d54611008919061598b565b61101291906159b6565b61101c91906159b6565b90505f5f821161102d575f1961103a565b825461103a9083906159b6565b835460018501546002860154600590960154919e909d50949b5092995060ff61010084048116995090975090911694509092505050565b6110796147ba565b6029546001600160a01b031633148061109b57505f546001600160a01b031633145b6110c05760405162461bcd60e51b81526004016110b7906159c9565b60405180910390fd5b8281146110df5760405162461bcd60e51b81526004016110b7906159e7565b826111195760405162461bcd60e51b815260206004820152600a6024820152694e6f2077696e6e65727360b01b60448201526064016110b7565b601c54611129906207e900615a09565b4210156111635760405162461bcd60e51b81526020600482015260086024820152672a37b79039b7b7b760c11b60448201526064016110b7565b601d54601a5410156111d357601a546040805182815260208101929092527f8db0ebe5f64ac513aa57bc8f320f1b18dd3b7c6dc2cc68f383ee0521eb964bbc910160405180910390a142601c55601b8054905f6111bf83615a1c565b91905055506111ce84846147d5565b611495565b601e54601f54601a546001600160a01b03909216915f91612710916111f8919061598b565b61120291906159b6565b90505f61120d61482b565b90505f8211801561121d57505f81115b156112b7575f61122d82846159b6565b905080156112b5575f5b6020548110156112b3575f6020828154811061125557611255615a34565b5f918252602090912001546001600160a01b0316905061127481614886565b61127e57506112ab565b82601a5f82825461128f9190615a48565b909155506112a990506001600160a01b0387168285614926565b505b600101611237565b505b505b5f805b858110156112f0578686828181106112d4576112d4615a34565b90506020020135826112e69190615a09565b91506001016112ba565b50601a548111156113325760405162461bcd60e51b815260206004820152600c60248201526b115e18d959591cc81c1bdbdb60a21b60448201526064016110b7565b5f5b8781101561142a575f87878381811061134f5761134f615a34565b9050602002013511801561139257505f89898381811061137157611371615a34565b905060200201602081019061138691906154fa565b6001600160a01b031614155b15611422578686828181106113a9576113a9615a34565b90506020020135601a5f8282546113c09190615a48565b9091555061142290508989838181106113db576113db615a34565b90506020020160208101906113f091906154fa565b88888481811061140257611402615a34565b90506020020135876001600160a01b03166149269092919063ffffffff16565b600101611334565b507fa96d0397e2fe4d6ef9f2667b45bd71a2f3ececf47b0147ff3c6652763cc1467088888888601b548660405161146696959493929190615a5b565b60405180910390a142601c55601b8054905f61148183615a1c565b919050555061149088886147d5565b505050505b6114ab60015f516020615cbe5f395f51905f5255565b50505050565b6114b961478e565b5f81116114f35760405162461bcd60e51b8152602060048201526008602482015267426164207261746560c01b60448201526064016110b7565b600d55565b61150061478e565b602c805461ff00191690556040517f9bb3a4a301e0fd406aaa546b2a772ebc9fca96f40128b2d160d9df351bcbf1bf905f90a1565b61153d61478e565b602c805460ff1916911515919091179055565b61155861478e565b6001600160a01b0382165f908152600c602052604090205460ff16156115a95760405162461bcd60e51b815260206004820152600660248201526545786973747360d01b60448201526064016110b7565b6001600160a01b0382166115eb5760405162461bcd60e51b81526020600482015260096024820152682d32b9379030b2323960b91b60448201526064016110b7565b600a805460018181019092557fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180546001600160a01b0385166001600160a01b031990911681179091555f818152600c60209081526040808320805460ff191686179055805160e081018252838152808301848152818301858152606083018681526080840187815260ff8b811660a0870190815260c087018c81528b8b52600b909952878a209651875594519a86019a909a55915160028501555160038401555160048301555160059091018054935115156101000261ffff19909416919096161791909117909355915190917f636b8a2520822c5b7b7d8e7ab81293e4efae637cf0bd895c34c4c1ecacc66525916117149190859091825260ff16602082015260400190565b60405180910390a25050565b6117286147ba565b602c5460ff161561174b5760405162461bcd60e51b81526004016110b790615ae8565b335f908152600f602090815260408083206001600160a01b0386168452909152902054806117a35760405162461bcd60e51b8152602060048201526005602482015264456d70747960d81b60448201526064016110b7565b335f908152600f602090815260408083206001600160a01b03871684529091528120819055602354612710906117d9908461598b565b6117e391906159b6565b90505f612710602454846117f7919061598b565b61180191906159b6565b90505f8161180f8486615a48565b6118199190615a48565b9050858115611836576118366001600160a01b0382163384614926565b8315611888576025545f906001600160a01b03166118545786611861565b6025546001600160a01b03165b90506001600160a01b03811615611886576118866001600160a01b0383168287614926565b505b5f831180156118a157506026546001600160a01b031615155b156118c0576026546118c0906001600160a01b03838116911685614926565b604080518381526001600160a01b03888116602083015289169133915f516020615c9e5f395f51905f52910160405180910390a3505050505061190f60015f516020615cbe5f395f51905f5255565b5050565b6029546001600160a01b031633148061193557505f546001600160a01b031633145b6119515760405162461bcd60e51b81526004016110b7906159c9565b6001600160a01b0381166119945760405162461bcd60e51b815260206004820152600a60248201526910985908185c9d1a5cdd60b21b60448201526064016110b7565b6001600160a01b038281165f8181526015602052604090819020549051928416927f628b7356de2062bea33757b892caf43731bcc3555f6fe746af75a640c1375d51916119eb914290918252602082015260400190565b60405180910390a35050565b6119ff6147ba565b602c5460ff1615611a225760405162461bcd60e51b81526004016110b790615ae8565b6001600160a01b0386165f908152600c602052604090205460ff16611a595760405162461bcd60e51b81526004016110b790615b08565b6001600160a01b0386165f908152600b6020526040902060050154610100900460ff16611ab35760405162461bcd60e51b8152602060048201526008602482015267496e61637469766560c01b60448201526064016110b7565b5f8711611aef5760405162461bcd60e51b815260206004820152600a6024820152695a65726f2064656c746160b01b60448201526064016110b7565b6001600160a01b0389165f90815260136020526040902054611b12906001615a09565b8314611b4c5760405162461bcd60e51b8152602060048201526009602482015268426164206e6f6e636560b81b60448201526064016110b7565b611b5d89898989898989898961495b565b6001600160a01b0389165f908152601360205260409020839055611b8389878987614a75565b6001600160a01b0389165f9081526010602052604081208054899290611baa908490615a09565b90915550506001600160a01b0389165f9081526012602052604081208054899290611bd6908490615a09565b90915550611be690508989614d93565b6001600160a01b038981165f90815260146020526040902054811690871614611c37576001600160a01b038981165f90815260146020526040902080546001600160a01b0319169188169190911790555b6001600160a01b0389165f8181526010602090815260408083205460158352928190205481518c8152928301939093528101919091527f635fe28e1e101300ac11cb078440df04c1998af47d23bf2bbad91fa92944589c9060600160405180910390a2611cb060015f516020615cbe5f395f51905f5255565b505050505050505050565b6029546001600160a01b0316331480611cdd57505f546001600160a01b031633145b611cf95760405162461bcd60e51b81526004016110b7906159c9565b6001600160a01b0382165f908152600c602052604090205460ff16611d305760405162461bcd60e51b81526004016110b790615b2b565b5f8111611d6b5760405162461bcd60e51b815260206004820152600960248201526842616420707269636560b81b60448201526064016110b7565b6001600160a01b0382165f818152600b60205260408082206003810185905542600490910155517fe36d126b25a23b3eb8b1322ea5a6df9be5d680c05fa2c496adfef77193de7d3591611714918590918252602082015260400190565b6001600160a01b0382165f908152600c602052604090205460ff16611dff5760405162461bcd60e51b81526004016110b790615b2b565b611e146001600160a01b038316333084614f42565b6001600160a01b0382165f908152600b602052604081208054839290611e3b908490615a09565b90915550506001600160a01b0382165f908152600b602052604081206001018054839290611e6a908490615a09565b90915550506001600160a01b0382165f908152600b6020526040812060030154611e94575f611edc565b6001600160a01b0383165f908152600b6020526040902060030154600d54670de0b6b3a7640000918291611ec8919061598b565b611ed291906159b6565b611edc91906159b6565b90505f5f8211611eed575f19611f10565b6001600160a01b0384165f908152600b6020526040902054611f109083906159b6565b6001600160a01b0385165f818152600b602090815260409182902054825188815291820152908101839052919250905f516020615c7e5f395f51905f529060600160405180910390a250505050565b611f6761478e565b818310158015611f775750808210155b611faf5760405162461bcd60e51b81526020600482015260096024820152682130b21037b93232b960b91b60448201526064016110b7565b612710811015611fef5760405162461bcd60e51b815260206004820152600b60248201526a0aadcc6dedadadedc7862f60ab1b60448201526064016110b7565b600792909255600855600955565b61200561478e565b6001600160a01b0382165f908152600c602052604090205460ff161561208d576001600160a01b0382165f908152600b6020526040902060050154610100900460ff161561208d5760405162461bcd60e51b815260206004820152601560248201527411195858dd1a5d985d19481c1bdbdb08199a5c9cdd605a1b60448201526064016110b7565b61190f6120a15f546001600160a01b031690565b6001600160a01b0384169083614926565b6120ba61478e565b5f5b600a548110156122d5575f600a82815481106120da576120da615a34565b5f9182526020822001546040516370a0823160e01b81523060048201526001600160a01b03909116925082906370a0823190602401602060405180830381865afa15801561212a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061214e9190615b52565b6001600160a01b0383165f908152600b6020526040902054909150808211156122ca575f61217c8284615a48565b6001600160a01b0385165f908152600b60205260408120805492935083929091906121a8908490615a09565b90915550506001600160a01b0384165f908152600b6020526040812060010180548392906121d7908490615a09565b90915550506001600160a01b0384165f908152600b6020526040812060030154612201575f612249565b6001600160a01b0385165f908152600b6020526040902060030154600d54670de0b6b3a7640000918291612235919061598b565b61223f91906159b6565b61224991906159b6565b90505f5f821161225a575f1961227d565b6001600160a01b0386165f908152600b602052604090205461227d9083906159b6565b6001600160a01b0387165f818152600b602090815260409182902054825188815291820152908101839052919250905f516020615c7e5f395f51905f529060600160405180910390a25050505b5050506001016120bc565b50565b600a5460609081905f816001600160401b038111156122f9576122f9615b69565b604051908082528060200260200182016040528015612322578160200160208202803683370190505b5090505f826001600160401b0381111561233e5761233e615b69565b604051908082528060200260200182016040528015612367578160200160208202803683370190505b5090505f805b848110156124a1575f600a828154811061238957612389615a34565b5f9182526020808320909101546001600160a01b0316808352600b909152604090912060058101549192509060ff610100909104166123c9575050612499565b5f5f8260030154116123db575f61240b565b670de0b6b3a7640000808360030154600d546123f7919061598b565b61240191906159b6565b61240b91906159b6565b90505f5f821161241c575f19612429565b82546124299083906159b6565b9050600354811015612494578388878151811061244857612448615a34565b60200260200101906001600160a01b031690816001600160a01b0316815250508087878151811061247b5761247b615a34565b60209081029190910101528561249081615a1c565b9650505b505050505b60010161236d565b50806001600160401b038111156124ba576124ba615b69565b6040519080825280602002602001820160405280156124e3578160200160208202803683370190505b509550806001600160401b038111156124fe576124fe615b69565b604051908082528060200260200182016040528015612527578160200160208202803683370190505b5094505f5b818110156125bf5783818151811061254657612546615a34565b602002602001015187828151811061256057612560615a34565b60200260200101906001600160a01b031690816001600160a01b03168152505082818151811061259257612592615a34565b60200260200101518682815181106125ac576125ac615a34565b602090810291909101015260010161252c565b50505050509091565b6125d061478e565b601e80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381165f908152600c602052604090205460ff166126295760405162461bcd60e51b81526004016110b790615b2b565b6040516370a0823160e01b81523060048201525f906001600160a01b038316906370a0823190602401602060405180830381865afa15801561266d573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126919190615b52565b6001600160a01b0383165f908152600b60205260409020549091508082111561280d575f6126bf8284615a48565b6001600160a01b0385165f908152600b60205260408120805492935083929091906126eb908490615a09565b90915550506001600160a01b0384165f908152600b60205260408120600101805483929061271a908490615a09565b90915550506001600160a01b0384165f908152600b6020526040812060030154612744575f61278c565b6001600160a01b0385165f908152600b6020526040902060030154600d54670de0b6b3a7640000918291612778919061598b565b61278291906159b6565b61278c91906159b6565b90505f5f821161279d575f196127c0565b6001600160a01b0386165f908152600b60205260409020546127c09083906159b6565b6001600160a01b0387165f818152600b602090815260409182902054825188815291820152908101839052919250905f516020615c7e5f395f51905f529060600160405180910390a25050505b505050565b61281a61478e565b600e55565b602c54610100900460ff166128465760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b0316331461286f5760405162461bcd60e51b81526004016110b7906159c9565b82811461288e5760405162461bcd60e51b81526004016110b7906159e7565b5f5b8381101561296d57600c5f8484848181106128ad576128ad615a34565b90506020020160208101906128c291906154fa565b6001600160a01b0316815260208101919091526040015f205460ff1615612965578282828181106128f5576128f5615a34565b905060200201602081019061290a91906154fa565b60145f87878581811061291f5761291f615a34565b905060200201602081019061293491906154fa565b6001600160a01b03908116825260208201929092526040015f2080546001600160a01b031916929091169190911790555b600101612890565b5050505050565b5f808080808080805b600a548110156129e857600b5f600a838154811061299d5761299d615a34565b5f9182526020808320909101546001600160a01b0316835282019290925260400190206005015460ff61010090910416156129e057816129dc81615a1c565b9250505b60010161297d565b50600a54601a54601c54839190612a039062093a8090615a09565b601b54602c54949c939b509199509750955060ff9091169350915050565b612a2961478e565b818310612a655760405162461bcd60e51b815260206004820152600a602482015269084c2c840e8d0e4cae6d60b31b60448201526064016110b7565b808210612aa15760405162461bcd60e51b815260206004820152600a602482015269084c2c840e8d0e4cae6d60b31b60448201526064016110b7565b6127108110612ae45760405162461bcd60e51b815260206004820152600f60248201526e04d757374206265203c20313030303608c1b60448201526064016110b7565b600492909255600555600655565b602c54610100900460ff16612b195760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b03163314612b425760405162461bcd60e51b81526004016110b7906159c9565b8483148015612b5057508281145b612b6c5760405162461bcd60e51b81526004016110b7906159e7565b5f5b85811015612d5957600c5f868684818110612b8b57612b8b615a34565b9050602002016020810190612ba091906154fa565b6001600160a01b0316815260208101919091526040015f205460ff16612bd85760405162461bcd60e51b81526004016110b790615b08565b828282818110612bea57612bea615a34565b90506020020135600f5f898985818110612c0657612c06615a34565b9050602002016020810190612c1b91906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f878785818110612c4d57612c4d615a34565b9050602002016020810190612c6291906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254612c8f9190615a09565b909155508390508282818110612ca757612ca7615a34565b9050602002013560115f898985818110612cc357612cc3615a34565b9050602002016020810190612cd891906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f878785818110612d0a57612d0a615a34565b9050602002016020810190612d1f91906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254612d4c9190615a09565b9091555050600101612b6e565b50505050505050565b612d6a6147ba565b6029546001600160a01b0316331480612d8c57505f546001600160a01b031633145b612da85760405162461bcd60e51b81526004016110b7906159c9565b602c5460ff1615612dcb5760405162461bcd60e51b81526004016110b790615ae8565b6001600160a01b038084165f908152600f6020908152604080832093861683529290529081205490819003612e005750612f5e565b6001600160a01b038085165f908152600f60209081526040808320938716835292905290812081905560235461271090612e3a908461598b565b612e4491906159b6565b90505f61271060245484612e58919061598b565b612e6291906159b6565b90505f81612e708486615a48565b612e7a9190615a48565b9050858115612e9757612e976001600160a01b0382168984614926565b8315612ee9576025545f906001600160a01b0316612eb55786612ec2565b6025546001600160a01b03165b90506001600160a01b03811615612ee757612ee76001600160a01b0383168287614926565b505b5f83118015612f0257506026546001600160a01b031615155b15612f2157602654612f21906001600160a01b03838116911685614926565b604080518381526001600160a01b038881166020830152808a1692908b16915f516020615c9e5f395f51905f52910160405180910390a350505050505b61280d60015f516020615cbe5f395f51905f5255565b6001600160a01b0381165f908152600c602052604081205460ff161580612fbb57506001600160a01b0382165f908152600b6020526040902060050154610100900460ff16155b15612fc757505f6130e2565b6001600160a01b0382165f908152600b60205260408120600301549003612fef57505f6130e2565b6027545f906001600160a01b031615613070576027546040516306ed11f760e31b81526001600160a01b038681166004830152909116906337688fb890602401602060405180830381865afa925050508015613068575060408051601f3d908101601f1916820190925261306591810190615b52565b60015b156130705790505b5f61271061307e8382615a09565b600d5461308b919061598b565b61309591906159b6565b6001600160a01b0385165f908152600b6020526040902060030154909150670de0b6b3a76400009081906130c9908461598b565b6130d391906159b6565b6130dd91906159b6565b925050505b92915050565b6130f061478e565b6130f95f614f78565b565b6131036147ba565b602c5460ff16156131265760405162461bcd60e51b81526004016110b790615ae8565b5f5b600a548110156132af575f600a828154811061314657613146615a34565b5f918252602080832090910154338352600f825260408084206001600160a01b039092168085529190925290822054909250908190036131875750506132a7565b335f908152600f602090815260408083206001600160a01b03861684529091528120819055602354612710906131bd908461598b565b6131c791906159b6565b90505f612710602454846131db919061598b565b6131e591906159b6565b90505f816131f38486615a48565b6131fd9190615a48565b905084811561321a5761321a6001600160a01b0382163384614926565b831561326c576025545f906001600160a01b03166132385788613245565b6025546001600160a01b03165b90506001600160a01b0381161561326a5761326a6001600160a01b0383168287614926565b505b604080518381526001600160a01b038a8116602083015288169133915f516020615c9e5f395f51905f52910160405180910390a35050505050505b600101613128565b506122d560015f516020615cbe5f395f51905f5255565b6132ce61478e565b602580546001600160a01b0319166001600160a01b0392909216919091179055565b6132f86147ba565b6029546001600160a01b031633148061331a57505f546001600160a01b031633145b6133365760405162461bcd60e51b81526004016110b7906159c9565b602c5460ff16156133595760405162461bcd60e51b81526004016110b790615ae8565b5f5b600a54811015613521575f600a828154811061337957613379615a34565b5f9182526020808320909101546001600160a01b038781168452600f83526040808520919092168085529252822054909250908190036133ba575050613519565b6001600160a01b038086165f908152600f602090815260408083209386168352929052908120819055602354612710906133f4908461598b565b6133fe91906159b6565b90505f61271060245484613412919061598b565b61341c91906159b6565b90505f8161342a8486615a48565b6134349190615a48565b9050848115613451576134516001600160a01b0382168a84614926565b83156134a3576025545f906001600160a01b031661346f578861347c565b6025546001600160a01b03165b90506001600160a01b038116156134a1576134a16001600160a01b0383168287614926565b505b5f831180156134bc57506026546001600160a01b031615155b156134db576026546134db906001600160a01b03838116911685614926565b604080518381526001600160a01b038a8116602083015280891692908c16915f516020615c9e5f395f51905f52910160405180910390a35050505050505b60010161335b565b5061190f60015f516020615cbe5f395f51905f5255565b61354061478e565b602680546001600160a01b0319166001600160a01b0392909216919091179055565b601e5461357a906001600160a01b0316333084614f42565b80601a5f82825461358b9190615a09565b9091555050601a546040805183815260208101929092527fdebc7807341368163ff883cc9f2791669b791ffa7a3c555196bfb70a1453d775910160405180910390a150565b6029546001600160a01b03163314806135f257505f546001600160a01b031633145b61360e5760405162461bcd60e51b81526004016110b7906159c9565b82811461362d5760405162461bcd60e51b81526004016110b7906159e7565b5f5b8381101561296d57600c5f86868481811061364c5761364c615a34565b905060200201602081019061366191906154fa565b6001600160a01b0316815260208101919091526040015f205460ff1615806136a0575082828281811061369657613696615a34565b905060200201355f145b6137df578282828181106136b6576136b6615a34565b90506020020135600b5f8787858181106136d2576136d2615a34565b90506020020160208101906136e791906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f206003018190555042600b5f87878581811061372357613723615a34565b905060200201602081019061373891906154fa565b6001600160a01b0316815260208101919091526040015f206004015584848281811061376657613766615a34565b905060200201602081019061377b91906154fa565b6001600160a01b03167fe36d126b25a23b3eb8b1322ea5a6df9be5d680c05fa2c496adfef77193de7d355f8585858181106137b8576137b8615a34565b905060200201356040516137d6929190918252602082015260400190565b60405180910390a25b60010161362f565b602c54610100900460ff1661380e5760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b031633146138375760405162461bcd60e51b81526004016110b7906159c9565b5f5b8181101561280d573683838381811061385457613854615a34565b90506020028101906138669190615b9d565b905060135f61387860208401846154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f2054816040013511156138d257604081013560135f6138b860208501856154fa565b6001600160a01b0316815260208101919091526040015f20555b5f6138e360408301602084016154fa565b6001600160a01b0316141580156139255750600c5f61390860408401602085016154fa565b6001600160a01b0316815260208101919091526040015f205460ff165b1561397b5761393a60408201602083016154fa565b60145f61394a60208501856154fa565b6001600160a01b03908116825260208201929092526040015f2080546001600160a01b031916929091169190911790555b606081013560125f61399060208501856154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f8282546139bd9190615a09565b9091555050608081013560105f6139d760208501856154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254613a049190615a09565b90915550613a17905060c0820182615bbb565b9050613a2660a0830183615bbb565b905014613a455760405162461bcd60e51b81526004016110b7906159e7565b5f5b613a5460a0830183615bbb565b9050811015613c5b57600c5f613a6d60a0850185615bbb565b84818110613a7d57613a7d615a34565b9050602002016020810190613a9291906154fa565b6001600160a01b0316815260208101919091526040015f205460ff168015613adc57505f613ac360c0840184615bbb565b83818110613ad357613ad3615a34565b90506020020135115b15613c5357613aee60c0830183615bbb565b82818110613afe57613afe615a34565b90506020020135600f5f845f016020810190613b1a91906154fa565b6001600160a01b0316815260208101919091526040015f90812090613b4260a0860186615bbb565b85818110613b5257613b52615a34565b9050602002016020810190613b6791906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254613b949190615a09565b90915550613ba7905060c0830183615bbb565b82818110613bb757613bb7615a34565b9050602002013560115f845f016020810190613bd391906154fa565b6001600160a01b0316815260208101919091526040015f90812090613bfb60a0860186615bbb565b85818110613c0b57613c0b615a34565b9050602002016020810190613c2091906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254613c4d9190615a09565b90915550505b600101613a47565b5050600101613839565b613c6d61478e565b610e10811015613cab5760405162461bcd60e51b81526020600482015260096024820152684261642064656c617960b81b60448201526064016110b7565b600255565b613cb861478e565b602a546001600160a01b0316613cfc5760405162461bcd60e51b81526020600482015260096024820152684e6f206368616e676560b81b60448201526064016110b7565b602b54421015613d1e5760405162461bcd60e51b81526004016110b790615b7d565b60298054602a80546001600160a01b03198084166001600160a01b038381169182179096559116909155604051929091169182907f9275b597b6188dcd901ecae14175fd5b02a5c9dee8bcce5af021f420af6cd1a3905f90a350565b602c54610100900460ff16613da15760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b03163314613dca5760405162461bcd60e51b81526004016110b7906159c9565b8483148015613dd857508481145b613df45760405162461bcd60e51b81526004016110b7906159e7565b5f5b85811015612d5957848482818110613e1057613e10615a34565b9050602002013560125f898985818110613e2c57613e2c615a34565b9050602002016020810190613e4191906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254613e6e9190615a09565b909155508390508282818110613e8657613e86615a34565b9050602002013560105f898985818110613ea257613ea2615a34565b9050602002016020810190613eb791906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205f828254613ee49190615a09565b9091555050600101613df6565b613ef961478e565b602780546001600160a01b0319166001600160a01b0392909216919091179055565b613f2361478e565b6022805460ff191660ff92909216919091179055565b613f4161478e565b6001600160a01b038116613f835760405162461bcd60e51b81526020600482015260096024820152682d32b9379030b2323960b91b60448201526064016110b7565b602a80546001600160a01b0319166001600160a01b038316179055600254613fab9042615a09565b602b8190556040519081526001600160a01b038216907f2a1459dc71e0f6a29305688e3de1620261942b79596c24acce059a6200a268309060200160405180910390a250565b613ff961478e565b602a80546001600160a01b0319169055565b6020818154811061401a575f80fd5b5f918252602090912001546001600160a01b0316905081565b602c54610100900460ff1661405a5760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b031633146140835760405162461bcd60e51b81526004016110b7906159c9565b8281146140a25760405162461bcd60e51b81526004016110b7906159e7565b5f5b8381101561296d5760135f8686848181106140c1576140c1615a34565b90506020020160208101906140d691906154fa565b6001600160a01b03166001600160a01b031681526020019081526020015f205483838381811061410857614108615a34565b9050602002013511156141725782828281811061412757614127615a34565b9050602002013560135f87878581811061414357614143615a34565b905060200201602081019061415891906154fa565b6001600160a01b0316815260208101919091526040015f20555b6001016140a4565b600a818154811061401a575f80fd5b61419161478e565b61138861419e8284615a09565b11156141de5760405162461bcd60e51b815260206004820152600f60248201526e08af0c6cacac8e640dac2f040e8c2f608b1b60448201526064016110b7565b602391909155602455565b602c54610100900460ff166142105760405162461bcd60e51b81526004016110b790615b7d565b5f546001600160a01b031633146142395760405162461bcd60e51b81526004016110b7906159c9565b6001600160a01b0382165f908152600c602052604090205460ff166142705760405162461bcd60e51b81526004016110b790615b08565b6142856001600160a01b038316333084614f42565b6001600160a01b0382165f908152600b6020526040812080548392906142ac908490615a09565b90915550506001600160a01b0382165f908152600b6020526040812060010180548392906142db908490615a09565b90915550506001600160a01b0382165f908152600b6020526040812060030154614305575f61434d565b6001600160a01b0383165f908152600b6020526040902060030154600d54670de0b6b3a7640000918291614339919061598b565b61434391906159b6565b61434d91906159b6565b6001600160a01b0384165f818152600b6020526040902054919250905f516020615c7e5f395f51905f5290849084614386575f196143a9565b6001600160a01b0387165f908152600b60205260409020546143a99086906159b6565b604080519384526020840192909252908201526060015b60405180910390a2505050565b6143d561478e565b6107d08111156144135760405162461bcd60e51b815260206004820152600960248201526813585e080c8c1c18dd60ba1b60448201526064016110b7565b601f55565b61442061478e565b603c81101580156144335750610e108111155b61446c5760405162461bcd60e51b815260206004820152600a6024820152694261642077696e646f7760b01b60448201526064016110b7565b600155565b6029546001600160a01b031633148061449357505f546001600160a01b031633145b6144af5760405162461bcd60e51b81526004016110b7906159c9565b5f5b60205481101561450d575f60215f602084815481106144d2576144d2615a34565b5f918252602080832091909101546001600160a01b031683528201929092526040019020805460ff19169115159190911790556001016144b1565b5061451960205f61544e565b5f5b8181101561280d5760215f84848481811061453857614538615a34565b905060200201602081019061454d91906154fa565b6001600160a01b0316815260208101919091526040015f205460ff1661461c57602083838381811061458157614581615a34565b905060200201602081019061459691906154fa565b8154600180820184555f9384526020842090910180546001600160a01b0319166001600160a01b039390931692909217909155906021908585858181106145df576145df615a34565b90506020020160208101906145f491906154fa565b6001600160a01b0316815260208101919091526040015f20805460ff19169115159190911790555b60010161451b565b61462c61478e565b6001600160a01b0382165f908152600c602052604090205460ff166146635760405162461bcd60e51b81526004016110b790615b2b565b6001600160a01b0382165f818152600b60205260409081902060050180548415156101000261ff0019909116179055517e8ffc907c147b686f342f9d04a1986e3a56bf453b5f4a99b59a85c1f1f4b6ec9061171490841515815260200190565b6146cb61478e565b602880546001600160a01b0319166001600160a01b0392909216919091179055565b6146f561478e565b6001600160a01b03811661471e57604051631e4fbdf760e01b81525f60048201526024016110b7565b6122d581614f78565b61472f61478e565b601d55565b6029546001600160a01b031633148061475657505f546001600160a01b031633145b61357a5760405162461bcd60e51b81526004016110b7906159c9565b61477a61478e565b601693909355601791909155601855601955565b5f546001600160a01b031633146130f95760405163118cdaa760e01b81523360048201526024016110b7565b6147c2614fc7565b60025f516020615cbe5f395f51905f5255565b5f5b8181101561280d575f60105f8585858181106147f5576147f5615a34565b905060200201602081019061480a91906154fa565b6001600160a01b0316815260208101919091526040015f20556001016147d7565b5f805b602054811015614882576148676020828154811061484e5761484e615a34565b5f918252602090912001546001600160a01b0316614886565b1561487a578161487681615a1c565b9250505b60010161482e565b5090565b6027545f906001600160a01b031661489f57505f919050565b602754604051630edf617560e41b81526001600160a01b0384811660048301529091169063edf6175090602401602060405180830381865afa925050508015614905575060408051601f3d908101601f1916820190925261490291810190615c00565b60015b61491057505f919050565b60225460ff91821691161492915050565b919050565b6149338383836001614ff6565b61280d57604051635274afe760e01b81526001600160a01b03841660048201526024016110b7565b5f6001544261496a91906159b6565b604080516001600160a01b03808e1660208301529181018c9052606081018b9052818a16608082015290881660a082015260c0810187905260e0810186905261010081018290529091505f90610120016040516020818303038152906040528051906020012090505f614a1d85858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250614a1792508691506150589050565b9061508a565b6029549091506001600160a01b03808316911614614a675760405162461bcd60e51b81526020600482015260076024820152664261642073696760c81b60448201526064016110b7565b505050505050505050505050565b6001600160a01b0383165f908152600b602052604081206003810154909103614a9e57506114ab565b5f670de0b6b3a7640000808360030154600d5487614abc919061598b565b614ac6919061598b565b614ad091906159b6565b614ada91906159b6565b9050805f03614aea5750506114ab565b81545f908211614afa5781614afd565b82545b9050805f03614b0e575050506114ab565b602854612710905f906001600160a01b031615614bf05760285f9054906101000a90046001600160a01b03166001600160a01b031663d805b6506040518163ffffffff1660e01b81526004016020604051808303815f875af1925050508015614b94575060408051601f3d908101601f19168201909252614b9191810190615c1b565b60015b15614bf0575f614baf6127106001600160401b038416615c41565b9050600454811015614bc957600754935060019250614bed565b600554811015614bdd576008549350614bed565b600654811015614bed5760095493505b50505b5f612710614bfe848661598b565b614c0891906159b6565b8654909150811115614c18575084545b805f03614c2a575050505050506114ab565b80865f015f828254614c3c9190615a48565b9250508190555080866002015f828254614c569190615a09565b90915550506001600160a01b03808b165f908152600f60209081526040808320938d1683529290529081208054839290614c91908490615a09565b90915550506001600160a01b03808b165f908152601160209081526040808320938d1683529290529081208054839290614ccc908490615a09565b9091555050604080518681526020810183905290810184905282151560608201526001600160a01b03808b1691908c16907fd3042a53eaaad09313490338daad8d1cdcbe701c5c1a19bcb0ff8a1a837fc8199060800160405180910390a38115614d8757886001600160a01b03168a6001600160a01b03167ff389a375bbcf0ba97f38cc0e5c5468a6d7905c752eb92b5f08ca60debd5c0dbe838a604051614d7e929190918252602082015260400190565b60405180910390a35b50505050505050505050565b805f03614d9e575050565b6001600160a01b0382165f90815260156020526040812090614dc362015180426159b6565b905080826001015403614dd65750505050565b5f614de2600183615a48565b905082600101545f03614e0057600183556016546002840155614ec0565b80836001015403614e32578254835f614e1883615a1c565b90915550508254614e28906150b2565b6002840155614ec0565b600383015415614eb3575f6001846001015484614e4f9190615a48565b614e599190615a48565b905080600103614ea057600384018054905f614e7483615c54565b90915550508354845f614e8683615a1c565b90915550508354614e96906150b2565b6002850155614ead565b6001845560165460028501555b50614ec0565b6001835560165460028401555b60018301829055600483018054905f614ed883615a1c565b9190505550614eea85845f015461516c565b825460028401546040516001600160a01b038816927fd9ad1f2b351c160231808ff9bc723542c8d3b0cdad54db25801bfe561bd4c6e392614f3392918252602082015260400190565b60405180910390a25050505050565b614f50848484846001615218565b6114ab57604051635274afe760e01b81526001600160a01b03851660048201526024016110b7565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f516020615cbe5f395f51905f52546002036130f957604051633ee5aeb560e01b815260040160405180910390fd5b60405163a9059cbb60e01b5f8181526001600160a01b038616600452602485905291602083604481808b5af1925060015f5114831661504c578383151615615040573d5f823e3d81fd5b5f873b113d1516831692505b60405250949350505050565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000005f908152601c91909152603c902090565b5f5f5f5f6150988686615285565b9250925092506150a882826152ce565b5090949350505050565b5f80600783116150d0576016546150c9908461598b565b9050615152565b601e8311615108576017546150e6600785615a48565b6150f0919061598b565b6016546150fe90600761598b565b6150c99190615a09565b601854615116601e85615a48565b615120919061598b565b6017805461512d9161598b565b60165461513b90600761598b565b6151459190615a09565b61514f9190615a09565b90505b60195481116151615780615165565b6019545b9392505050565b6001600160a01b0382165f9081526015602052604090206007821480615192575081601e145b8061519d575081605a145b806151a857508160b4145b1561280d57600381018054905f6151be83615a1c565b91905055506003816003015411156151d7576003818101555b60408051838152600160208201526001600160a01b038516917f3e36978d09ecbfcd5deec4f3c53e931d9a55776a08d36e727728c8f6b285f26091016143c0565b6040516323b872dd60e01b5f8181526001600160a01b038781166004528616602452604485905291602083606481808c5af1925060015f51148316615274578383151615615268573d5f823e3d81fd5b5f883b113d1516831692505b604052505f60605295945050505050565b5f5f5f83516041036152bc576020840151604085015160608601515f1a6152ae88828585615386565b9550955095505050506152c7565b505081515f91506002905b9250925092565b5f8260038111156152e1576152e1615c69565b036152ea575050565b60018260038111156152fe576152fe615c69565b0361531c5760405163f645eedf60e01b815260040160405180910390fd5b600282600381111561533057615330615c69565b036153515760405163fce698f760e01b8152600481018290526024016110b7565b600382600381111561536557615365615c69565b0361190f576040516335e2f38360e21b8152600481018290526024016110b7565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411156153bf57505f91506003905082615444565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015615410573d5f5f3e3d5ffd5b5050604051601f1901519150506001600160a01b03811661543b57505f925060019150829050615444565b92505f91508190505b9450945094915050565b5080545f8255905f5260205f20906130f991905f5b8082111561280d575f81840155600101615463565b5f8151808452602084019350602083015f5b828110156154b15781516001600160a01b031686526020958601959091019060010161548a565b5093949350505050565b602081525f6151656020830184615478565b5f602082840312156154dd575f5ffd5b5035919050565b80356001600160a01b0381168114614921575f5ffd5b5f6020828403121561550a575f5ffd5b615165826154e4565b5f5f83601f840112615523575f5ffd5b5081356001600160401b03811115615539575f5ffd5b6020830191508360208260051b8501011115615553575f5ffd5b9250929050565b5f5f5f5f6040858703121561556d575f5ffd5b84356001600160401b03811115615582575f5ffd5b61558e87828801615513565b90955093505060208501356001600160401b038111156155ac575f5ffd5b6155b887828801615513565b95989497509550505050565b80358015158114614921575f5ffd5b5f602082840312156155e3575f5ffd5b615165826155c4565b60ff811681146122d5575f5ffd5b5f5f6040838503121561560b575f5ffd5b615614836154e4565b91506020830135615624816155ec565b809150509250929050565b5f5f60408385031215615640575f5ffd5b615649836154e4565b9150615657602084016154e4565b90509250929050565b5f5f5f5f5f5f5f5f5f6101008a8c031215615679575f5ffd5b6156828a6154e4565b985060208a0135975060408a0135965061569e60608b016154e4565b95506156ac60808b016154e4565b945060a08a0135935060c08a0135925060e08a01356001600160401b038111156156d4575f5ffd5b8a01601f81018c136156e4575f5ffd5b80356001600160401b038111156156f9575f5ffd5b8c602082840101111561570a575f5ffd5b60208201935080925050509295985092959850929598565b5f5f60408385031215615733575f5ffd5b61573c836154e4565b946020939093013593505050565b5f5f5f6060848603121561575c575f5ffd5b505081359360208301359350604090920135919050565b604081525f6157856040830185615478565b82810360208401528084518083526020830191506020860192505f5b818110156157bf5783518352602093840193909201916001016157a1565b50909695505050505050565b5f5f5f5f5f5f606087890312156157e0575f5ffd5b86356001600160401b038111156157f5575f5ffd5b61580189828a01615513565b90975095505060208701356001600160401b0381111561581f575f5ffd5b61582b89828a01615513565b90955093505060408701356001600160401b03811115615849575f5ffd5b61585589828a01615513565b979a9699509497509295939492505050565b5f5f5f60608486031215615879575f5ffd5b615882846154e4565b9250615890602085016154e4565b915061589e604085016154e4565b90509250925092565b5f5f602083850312156158b8575f5ffd5b82356001600160401b038111156158cd575f5ffd5b6158d985828601615513565b90969095509350505050565b5f602082840312156158f5575f5ffd5b8135615165816155ec565b5f5f60408385031215615911575f5ffd5b50508035926020909101359150565b5f5f60408385031215615931575f5ffd5b61593a836154e4565b9150615657602084016155c4565b5f5f5f5f6080858703121561595b575f5ffd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176130e2576130e2615977565b634e487b7160e01b5f52601260045260245ffd5b5f826159c4576159c46159a2565b500490565b602080825260049082015263082eae8d60e31b604082015260600190565b60208082526008908201526709ad2e6dac2e8c6d60c31b604082015260600190565b808201808211156130e2576130e2615977565b5f60018201615a2d57615a2d615977565b5060010190565b634e487b7160e01b5f52603260045260245ffd5b818103818111156130e2576130e2615977565b608080825281018690525f8760a08301825b89811015615a9b576001600160a01b03615a86846154e4565b16825260209283019290910190600101615a6d565b5083810360208501528681526001600160fb1b03871115615aba575f5ffd5b8660051b91508188602083013760208282010192505050836040830152826060830152979650505050505050565b60208082526006908201526514185d5cd95960d21b604082015260600190565b6020808252600990820152682130b2103a37b5b2b760b91b604082015260600190565b6020808252600d908201526c139bdd081cdd5c1c1bdc9d1959609a1b604082015260600190565b5f60208284031215615b62575f5ffd5b5051919050565b634e487b7160e01b5f52604160045260245ffd5b602080825260069082015265131bd8dad95960d21b604082015260600190565b5f823560de19833603018112615bb1575f5ffd5b9190910192915050565b5f5f8335601e19843603018112615bd0575f5ffd5b8301803591506001600160401b03821115615be9575f5ffd5b6020019150600581901b3603821315615553575f5ffd5b5f60208284031215615c10575f5ffd5b8151615165816155ec565b5f60208284031215615c2b575f5ffd5b81516001600160401b0381168114615165575f5ffd5b5f82615c4f57615c4f6159a2565b500690565b5f81615c6257615c62615977565b505f190190565b634e487b7160e01b5f52602160045260245ffdfe97e12f1c44b21051b923802d8094fe3237ddd78bcb36f91756180975f639a362b980dfc709fc65b9489197f87620cf86cb0d70f3ed844483e41acd41f7d0b2009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a264697066735822122008b8a0d00bb472d2a2bd1239e24e424ee4c9df17324b2274dbf075ae2cb0b84a64736f6c63430008220033