ETH Price: $1,835.58 (-3.38%)

Contract

0x65c55F33F9493E8702FEea89B4fA357283eD3841
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Mine BFX221499932025-03-29 3:50:477 hrs ago1743220247IN
0x65c55F33...283eD3841
0 ETH0.000149140.41019065
Claim BFX Batch221497692025-03-29 3:05:358 hrs ago1743217535IN
0x65c55F33...283eD3841
0 ETH0.000114080.4514307
Claim BFX Batch221495882025-03-29 2:29:119 hrs ago1743215351IN
0x65c55F33...283eD3841
0 ETH0.000264611.05956234
Approve221481272025-03-28 21:35:2314 hrs ago1743197723IN
0x65c55F33...283eD3841
0 ETH0.000023140.78849663
Approve221481172025-03-28 21:33:2314 hrs ago1743197603IN
0x65c55F33...283eD3841
0 ETH0.000025120.856101
Approve221481092025-03-28 21:31:4714 hrs ago1743197507IN
0x65c55F33...283eD3841
0 ETH0.000040760.87759838
Approve221480722025-03-28 21:24:1114 hrs ago1743197051IN
0x65c55F33...283eD3841
0 ETH0.000063921.37553623
Approve221480502025-03-28 21:19:4714 hrs ago1743196787IN
0x65c55F33...283eD3841
0 ETH0.000051391.1
Mine BFX221472802025-03-28 18:44:3517 hrs ago1743187475IN
0x65c55F33...283eD3841
0 ETH0.000226480.90369771
Mine BFX221471442025-03-28 18:17:2317 hrs ago1743185843IN
0x65c55F33...283eD3841
0 ETH0.00017630.58385503
Claim BFX Batch221471222025-03-28 18:12:5917 hrs ago1743185579IN
0x65c55F33...283eD3841
0 ETH0.000109810.6
Claim BFX221471172025-03-28 18:11:5917 hrs ago1743185519IN
0x65c55F33...283eD3841
0 ETH0.000182970.6
Mine BFX221456532025-03-28 13:16:5922 hrs ago1743167819IN
0x65c55F33...283eD3841
0 ETH0.000373691.34507022
Mine BFX221456362025-03-28 13:13:3522 hrs ago1743167615IN
0x65c55F33...283eD3841
0 ETH0.000341321.22863581
Mine BFX221456222025-03-28 13:10:4722 hrs ago1743167447IN
0x65c55F33...283eD3841
0 ETH0.00049481.13389544
Claim BFX Batch221456062025-03-28 13:07:3522 hrs ago1743167255IN
0x65c55F33...283eD3841
0 ETH0.000588231.17766779
Claim BFX Batch221456022025-03-28 13:06:4722 hrs ago1743167207IN
0x65c55F33...283eD3841
0 ETH0.000541821.25195618
Claim BFX Batch221455972025-03-28 13:05:4722 hrs ago1743167147IN
0x65c55F33...283eD3841
0 ETH0.000573711.14860458
Mine BFX221455942025-03-28 13:05:1122 hrs ago1743167111IN
0x65c55F33...283eD3841
0 ETH0.000324541.16816324
Approve221447562025-03-28 10:16:2325 hrs ago1743156983IN
0x65c55F33...283eD3841
0 ETH0.000042810.92137125
Claim BFX Batch221447042025-03-28 10:05:5925 hrs ago1743156359IN
0x65c55F33...283eD3841
0 ETH0.000137110.88564242
Claim BFX Batch221446892025-03-28 10:02:5925 hrs ago1743156179IN
0x65c55F33...283eD3841
0 ETH0.000138610.8953463
Mine BFX221412332025-03-27 22:28:1137 hrs ago1743114491IN
0x65c55F33...283eD3841
0 ETH0.000127080.4
Transfer221412232025-03-27 22:26:1137 hrs ago1743114371IN
0x65c55F33...283eD3841
0 ETH0.000011930.4
Claim BFX Batch221412032025-03-27 22:22:1137 hrs ago1743114131IN
0x65c55F33...283eD3841
0 ETH0.000073210.4
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Method Block
From
To
Deposit221188952025-03-24 19:36:474 days ago1742845007
0x65c55F33...283eD3841
0.0024 ETH
Deposit220823462025-03-19 17:16:479 days ago1742404607
0x65c55F33...283eD3841
0.005 ETH
Deposit220782332025-03-19 3:27:5910 days ago1742354879
0x65c55F33...283eD3841
0.00349722 ETH
Deposit220671512025-03-17 14:17:1111 days ago1742221031
0x65c55F33...283eD3841
0.01 ETH
Deposit220668242025-03-17 13:11:1111 days ago1742217071
0x65c55F33...283eD3841
0.058 ETH
Deposit220598342025-03-16 13:46:4712 days ago1742132807
0x65c55F33...283eD3841
0.01 ETH
Deposit220562472025-03-16 1:45:2313 days ago1742089523
0x65c55F33...283eD3841
0.00319398 ETH
Deposit220458132025-03-14 14:48:5914 days ago1741963739
0x65c55F33...283eD3841
0.01 ETH
Deposit220425262025-03-14 3:47:1115 days ago1741924031
0x65c55F33...283eD3841
0.00752763 ETH
Deposit220386892025-03-13 14:57:3515 days ago1741877855
0x65c55F33...283eD3841
0.01 ETH
Deposit220322382025-03-12 17:20:1116 days ago1741800011
0x65c55F33...283eD3841
0.0016294 ETH
Deposit220314802025-03-12 14:47:3516 days ago1741790855
0x65c55F33...283eD3841
0.01 ETH
Deposit220314732025-03-12 14:46:1116 days ago1741790771
0x65c55F33...283eD3841
0.01 ETH
Deposit219923762025-03-07 3:39:5922 days ago1741318799
0x65c55F33...283eD3841
0.01563931 ETH
Deposit219914822025-03-07 0:39:1122 days ago1741307951
0x65c55F33...283eD3841
0.00351422 ETH
Deposit219613052025-03-02 19:32:4726 days ago1740943967
0x65c55F33...283eD3841
0.01100391 ETH
Deposit219537912025-03-01 18:24:3527 days ago1740853475
0x65c55F33...283eD3841
0.0084 ETH
Deposit219266772025-02-25 23:38:4731 days ago1740526727
0x65c55F33...283eD3841
0.07 ETH
Deposit219204342025-02-25 2:43:1132 days ago1740451391
0x65c55F33...283eD3841
0.00024016 ETH
Deposit219139922025-02-24 5:06:2333 days ago1740373583
0x65c55F33...283eD3841
0.01696865 ETH
Deposit219085792025-02-23 10:58:3534 days ago1740308315
0x65c55F33...283eD3841
0.009 ETH
Deposit219056392025-02-23 1:06:1134 days ago1740272771
0x65c55F33...283eD3841
0.00097772 ETH
Deposit219035132025-02-22 17:58:5934 days ago1740247139
0x65c55F33...283eD3841
0.00246421 ETH
Deposit218515092025-02-15 11:24:1142 days ago1739618651
0x65c55F33...283eD3841
0.003 ETH
Deposit218249302025-02-11 18:00:2345 days ago1739296823
0x65c55F33...283eD3841
0.00591654 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BonFire

Compiler Version
v0.8.26+commit.8a97fa7a

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 49 : BFX.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

/* === UNIV3 === */
import {ISwapRouter} from "./lib/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import {TransferHelper} from "./lib/v3-periphery/contracts/libraries/TransferHelper.sol";
import {FullMath} from "./lib/v3-core/contracts/libraries/FullMath.sol";
import {Math} from "./lib/openzeppelin-contracts/contracts/utils/math/Math.sol";
import {IUniswapV3Pool} from "./lib/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {INonfungiblePositionManager} from "./lib/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol";

/* === OZ === */
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

/* === CONST === */
import "./BuyAndBurnConst.sol";

/* === SYSTEM === */
import {BonFireBuyAndBurn} from "./BonFireBuyAndBurn.sol";
import {BonFireLpAdder} from "./BonFireLpAdder.sol";

interface IX28 {
    function mintX28withTitanX(uint256 amount) external;
}

interface IWETH {
    function deposit() payable external;
}

// Custom errors
error BFX_InsufficientBalance();
error BFX_NotAllowed();
error BFX_AmountMismatch();
error BFX_ETHNotAllowed();
error BFX_LPTokensHasMinted();
error BFX_InvalidAddress();
error BFX_InvalidSBPPurchase();
error BFX_SwapFailed();
error BFX_UnsupportedToken();
error BFX_NoSBPToClaim();
error BFX_DayNotEnded();
error BFX_CycleNotStarted();
error OnlyBuyAndBurn();


/**
 * @title BonFire (BFX)
 * @author BuildTheTech.com
 * @notice This contract handles the minting of BFX Tokens and distribution of X28.
 */
contract BonFire is ERC20Burnable, ReentrancyGuard, Ownable {
    using FullMath for uint256;
    // Storage Variables
    uint256 public totalX28Deposited;
    address public genesisAddress = 0xDa7d64289Ff01E4eE816Cc914C75C471a4E39Ad0;
    address public devAddress = 0xFBd4cC5a61d38b95eb6fb9530657c57C5cB27BcE;
    BonFireBuyAndBurn public buyAndBurn;
    BonFireLpAdder public lpAdder;
    address public x28BfxPool;
    bool private lpAdded;

    uint256 public currentCycle;
    uint256 public cycleStartTime;    

    // LP Distribution
    uint32 public LP_BPS = 800;

    // Burn Config
    uint256 public X28_BURN = 1000;
    uint256 public MORPH_BURN = 1000;
    uint256 public E280_BURN = 1000;
    uint256 public BFX_BURN = 7000;

    // BFX Settings
    bool private isDistributedForCycle0 = false; // Triggers premint of the first cycle when false. Once flagged true, it is never used again.
    uint256 public bfxDailyDistribution = 50_000_000e18; // Starting at 50M BFX
    uint32 public REDUCTION_PERCENTAGE = 0; // The percent the bfxDailyDistribution is reduced by, each day.
    uint32 public DAILY_DECAY = 1250; // 12.5% daily for 8 total days of minting per SBP.
    uint32 public MINER_LENGTH = 8; // 8 Days miner length by default.
    uint256 public totalBFXAvailable; // Total amount of BFX that is available to be claimed (whether from minting or recycling).

    // BFX Recycle Pool
    uint256 public recyclePoolAmount; // The total amount of BFX held in the Recycle Pool.
    uint32 public distributionPercent = 400; // The percent of recycle pool that is used for miner rewards each day, default of 1%.
    uint32 public recyclePercent = 2000; // The percent of BuyAndBurn that will be used to recycle.
    bool public recycleMode; // Flags to true once minimum bfx daily threshold is reached.

    // BFX Vesting Pool
    uint256 public vestingClaimPercent = 5000; // The percent of the vesting rewards users are able to claim. The remaining is passed down.
    uint256 public vestingPoolAmount; // The total amount of BFX held in the Vesting Pool.
    uint256 public totalVestingAvailable; // The total amount of BFX that the Vesting Pool has distributed.

    // Mappings
    mapping(address => TokenSwapInfo) private allowedTokens;
    mapping(uint256 => uint256) public cycleTotalSBP;
    mapping(uint256 => uint256) public cycleSpentSBP;
    mapping(address => mapping(uint256 => uint256)) public userCycleSBP;
    mapping(uint256 => uint256) public cycleUsers;
    mapping(uint256 => uint256) public cyclesBFX;
    mapping(uint256 => uint256) public cyclesClaimedBFX;
    mapping(uint256 => uint256) public cyclesForfeitBFX;
    mapping(uint256 => uint256) public todaysX28;
    mapping(uint256 => uint256) public vestingCycleDistribution;
    mapping(address => mapping(uint256 => uint256)) public userCycleClaimedBFX;
    mapping(address => mapping(uint256 => uint256)) public userCycleClaimedVesting;


    // Structs
    struct TokenSwapInfo {
        address[] swapPath;
        uint24[] feeTiers;
    }

    struct BatchClaimTotals {
    uint256 totalUserShare;
    uint256 totalVestingTransfer;
    uint256 totalPenaltyAmount;
    uint256 totalSpentSBP;
    uint256 totalVestingLeftover;
    uint256 contractMintAmount;
    uint256 vestingPoolIncrement;
}

    // Events
    event MinerStarted(address indexed user, uint256 x28Amount, uint256 sbpAmount, uint256 cycleId);
    event BFXClaimed(address indexed user, uint256 bfxAmount);
    event ParameterUpdated();

    event RewardClaimed(address indexed user, uint256 indexed reward);

    constructor(uint32 _startTimestamp, address _owner) payable ERC20("BonFire", "BFX") Ownable(msg.sender) {
        buyAndBurn = new BonFireBuyAndBurn(
            _startTimestamp,
            _owner
        );
        lpAdder = new BonFireLpAdder(_owner);
        IERC20(X28_ADDRESS).approve(address(buyAndBurn), type(uint256).max);
        cycleStartTime = _startTimestamp;
    }

    modifier onlyBuyAndBurn() {
        _onlyBuyAndBurn();
        _;
    }

    function _onlyBuyAndBurn() internal view {
        if (msg.sender != address(buyAndBurn)) revert OnlyBuyAndBurn();
    }

    // Function for users to mine BFX tokens.
    function mineBFX(
        address inputToken,
        uint256 amountIn,
        uint256 amountOutMin
    ) external payable nonReentrant {
        if (amountIn == 0) revert BFX_InvalidSBPPurchase();
        if (block.timestamp < cycleStartTime) revert BFX_CycleNotStarted();
        if (inputToken == address(0)) revert BFX_InvalidAddress();

        bool isWETH = inputToken == address(WETH_ADDRESS);
        if (isWETH) {
            if (amountIn != msg.value) revert BFX_AmountMismatch();
        } else {
            if (msg.value != 0) revert BFX_ETHNotAllowed();
        }

        if (isWETH) {
            IWETH(WETH_ADDRESS).deposit{value: msg.value}();
        }

        _checkAndStartNewCycle();

        IERC20 _x28 = IERC20(X28_ADDRESS);
        uint256 titanXAmount;
        uint256 x28Amount;

        if (inputToken == X28_ADDRESS) {
            TransferHelper.safeTransferFrom(X28_ADDRESS, msg.sender, address(this), amountIn);
            x28Amount = amountIn;
        } else if (inputToken == TITAN_X_ADDRESS) {
            TransferHelper.safeTransferFrom(TITAN_X_ADDRESS, msg.sender, address(this), amountIn);
            TransferHelper.safeApprove(TITAN_X_ADDRESS, X28_ADDRESS, amountIn);
            IX28(X28_ADDRESS).mintX28withTitanX(amountIn);
            x28Amount = amountIn;
        } else {
            TokenSwapInfo memory swapInfo = allowedTokens[inputToken];
            if (swapInfo.swapPath.length == 0) revert BFX_UnsupportedToken();

            if (!isWETH) {
                TransferHelper.safeTransferFrom(inputToken, msg.sender, address(this), amountIn);
            }

            TransferHelper.safeApprove(inputToken, UNISWAP_V3_ROUTER, amountIn);

            if (swapInfo.swapPath.length == 2) {
                ISwapRouter.ExactInputSingleParams memory singleParams = ISwapRouter.ExactInputSingleParams({
                    tokenIn: swapInfo.swapPath[0],
                    tokenOut: swapInfo.swapPath[1],
                    fee: swapInfo.feeTiers[0],
                    recipient: address(this),
                    deadline: block.timestamp,
                    amountIn: amountIn,
                    amountOutMinimum: amountOutMin,
                    sqrtPriceLimitX96: 0
                });

                titanXAmount = ISwapRouter(UNISWAP_V3_ROUTER).exactInputSingle(singleParams);
            } else {
                bytes memory encodedPath = abi.encodePacked(swapInfo.swapPath[0]);
                for (uint256 i = 1; i < swapInfo.swapPath.length; ) {
                    encodedPath = abi.encodePacked(encodedPath, swapInfo.feeTiers[i - 1], swapInfo.swapPath[i]);
                    unchecked { ++i; }
                }

                ISwapRouter.ExactInputParams memory multiParams = ISwapRouter.ExactInputParams({
                    path: encodedPath,
                    recipient: address(this),
                    deadline: block.timestamp,
                    amountIn: amountIn,
                    amountOutMinimum: amountOutMin
                });

                titanXAmount = ISwapRouter(UNISWAP_V3_ROUTER).exactInput(multiParams);
            }

            if (titanXAmount == 0) revert BFX_SwapFailed();

            TransferHelper.safeApprove(TITAN_X_ADDRESS, X28_ADDRESS, titanXAmount);
            IX28(X28_ADDRESS).mintX28withTitanX(titanXAmount);
            x28Amount = titanXAmount;
        }

        totalX28Deposited += x28Amount;
        todaysX28[currentCycle] += x28Amount;

        uint256 sbpAmount = x28Amount * 369 / 10_000_000;
        if (sbpAmount == 0) revert BFX_InvalidSBPPurchase(); 
        _assignSBP(msg.sender, sbpAmount, currentCycle);

        uint256 lpAmount = x28Amount * LP_BPS / BPS_DENOM;
        uint256 devAmount = x28Amount * DEV_BPS / BPS_DENOM;
        uint256 genesisAmount = x28Amount * GENESIS_BPS / BPS_DENOM;

        TransferHelper.safeTransfer(X28_ADDRESS, address(lpAdder), lpAmount);
        TransferHelper.safeTransfer(X28_ADDRESS, genesisAddress, genesisAmount);
        TransferHelper.safeTransfer(X28_ADDRESS, devAddress, devAmount);

        buyAndBurn.distributeX28ForBurning(_x28.balanceOf(address(this)));

        if (!buyAndBurn.liquidityAdded() && _x28.balanceOf(address(buyAndBurn)) >= INITIAL_X28_FOR_LIQ) {
            buyAndBurn.addLiquidityToBonFireX28Pool(uint32(block.timestamp + 60));
        }

        emit MinerStarted(msg.sender, x28Amount, sbpAmount, currentCycle);
    }

    // Function to claim BFX
    function claimBFX(uint256 cycleId) external nonReentrant {
        _checkAndStartNewCycle();

        if (cycleId == currentCycle) revert BFX_DayNotEnded();

        uint256 userSBP = userCycleSBP[msg.sender][cycleId];
        if (userSBP == 0) revert BFX_NoSBPToClaim();

        uint256 userShare = _calculateUserShare(msg.sender, cycleId);
        if (userShare == 0) revert BFX_NoSBPToClaim();

        (uint256 vestingReward, uint256 excessVestingReward) = _calculateUserVestingReward(msg.sender, cycleId);

        uint256 penaltyAmount;
        uint256 vestingClaim;

        uint256 cycleDifference = currentCycle - cycleId;

        uint256 vestingRewardForTheNext8Days = 0;

        if (cycleDifference < 9) {
            uint256 penaltyPercentage = 9 - cycleDifference;

            unchecked {
                penaltyAmount = userShare * penaltyPercentage / 100;
                userShare = userShare * (100 - penaltyPercentage) / 100;
            }

            if (cycleTotalSBP[cycleId] == cycleSpentSBP[cycleId] + userSBP && vestingReward > 0) {
                vestingCycleDistribution[cycleId] -= vestingReward * PRECISION_FACTOR;
                if (cycleId < 368 && currentCycle > 359) {
                    recyclePoolAmount += vestingReward;
                    totalVestingAvailable -= vestingReward;
                } else {
                    vestingRewardForTheNext8Days = vestingReward * PRECISION_FACTOR / 8;
                }
            } else {
                vestingCycleDistribution[cycleId] -= vestingReward * PRECISION_FACTOR / 2;
                if (cycleId < 368 && currentCycle > 359) {
                    recyclePoolAmount += vestingReward / 2;
                    totalVestingAvailable -= vestingReward / 2;
                } else {
                    vestingRewardForTheNext8Days = vestingReward * PRECISION_FACTOR / 2 / 8;
                }
            }

            cyclesForfeitBFX[cycleId] += penaltyAmount;
            vestingPoolAmount += penaltyAmount;
            totalVestingAvailable += penaltyAmount;
        } else {
            vestingClaim = vestingReward * vestingClaimPercent / BPS_DENOM;

            if (cycleTotalSBP[cycleId] == cycleSpentSBP[cycleId] + userSBP && vestingReward > 0) {
                vestingCycleDistribution[cycleId] -= vestingReward * PRECISION_FACTOR;
                if (cycleId < 368 && currentCycle > 359) {
                    recyclePoolAmount += (vestingReward - vestingClaim);
                    totalVestingAvailable -= (vestingReward - vestingClaim);
                } else {
                    vestingRewardForTheNext8Days = (vestingReward - vestingClaim) * PRECISION_FACTOR / 8;
                }
            } else {
                vestingCycleDistribution[cycleId] -= vestingClaim * PRECISION_FACTOR;
            }
        }

        if (excessVestingReward > 0) {
            vestingCycleDistribution[cycleId] -= excessVestingReward * PRECISION_FACTOR;
            if (cycleId < 368 && currentCycle > 359) {
                recyclePoolAmount += excessVestingReward;
                totalVestingAvailable -= excessVestingReward;
            } else {
                vestingRewardForTheNext8Days += excessVestingReward * PRECISION_FACTOR / 8;
            }
        }

        for (uint256 i = 1; i <= 8; i++) {
            vestingCycleDistribution[currentCycle + i] += vestingRewardForTheNext8Days;
        }

        cycleSpentSBP[cycleId] += userSBP;
        cycleUsers[cycleId] -= 1;
        userCycleSBP[msg.sender][cycleId] = 0;
        cyclesClaimedBFX[cycleId] += userShare;
        userCycleClaimedBFX[msg.sender][cycleId] = userShare;
        userCycleClaimedVesting[msg.sender][cycleId] = vestingClaim;
        totalBFXAvailable -= userShare + penaltyAmount;

        TransferHelper.safeTransfer(address(this), msg.sender, userShare + vestingClaim);
        emit BFXClaimed(msg.sender, userShare + vestingClaim);
    }
    
    // Function to allow users to batch claim their BFX and Vesting Rewards.
    function claimBFXBatch(uint256[] memory cycleIds) external nonReentrant {
        uint256 totalUserShare = 0;
        uint256 totalVestingClaim = 0;

        _checkAndStartNewCycle();

        for (uint256 i = 0; i < cycleIds.length; i++) {
            uint256 cycleId = cycleIds[i];

            if (cycleId == currentCycle) revert BFX_DayNotEnded();

            uint256 userSBP = userCycleSBP[msg.sender][cycleId];
            if (userSBP == 0) revert BFX_NoSBPToClaim();

            uint256 userShare = _calculateUserShare(msg.sender, cycleId);
            if (userShare == 0) revert BFX_NoSBPToClaim();

            (uint256 vestingReward, uint256 excessVestingReward) = _calculateUserVestingReward(msg.sender, cycleId);

            uint256 penaltyAmount;
            uint256 vestingClaim;

            uint256 cycleDifference = currentCycle - cycleId;

            uint256 vestingRewardForTheNext8Days = 0;

            if (cycleDifference < 9) {
                uint256 penaltyPercentage = 9 - cycleDifference;

                unchecked {
                    penaltyAmount = userShare * penaltyPercentage / 100;
                    userShare = userShare * (100 - penaltyPercentage) / 100;
                }

                if (cycleTotalSBP[cycleId] == cycleSpentSBP[cycleId] + userSBP && vestingReward > 0) {
                    vestingCycleDistribution[cycleId] -= vestingReward * PRECISION_FACTOR;
                    if (cycleId < 368 && currentCycle > 359) {
                        recyclePoolAmount += vestingReward;
                        totalVestingAvailable -= vestingReward;
                    } else {
                        vestingRewardForTheNext8Days = vestingReward * PRECISION_FACTOR / 8;
                    }
                } else {
                    vestingCycleDistribution[cycleId] -= vestingReward * PRECISION_FACTOR / 2;
                    if (cycleId < 368 && currentCycle > 359) {
                        recyclePoolAmount += vestingReward / 2;
                        totalVestingAvailable -= vestingReward / 2;
                    } else {
                        vestingRewardForTheNext8Days = vestingReward * PRECISION_FACTOR / 2 / 8;
                    }

                }

                cyclesForfeitBFX[cycleId] += penaltyAmount;
                vestingPoolAmount += penaltyAmount;
                totalVestingAvailable += penaltyAmount;
            } else {
                vestingClaim = vestingReward * vestingClaimPercent / BPS_DENOM;
                totalVestingAvailable -= vestingClaim;

                if (cycleTotalSBP[cycleId] == cycleSpentSBP[cycleId] + userSBP && vestingReward > 0) {
                    vestingCycleDistribution[cycleId] -= vestingReward * PRECISION_FACTOR;
                    if (cycleId < 368 && currentCycle > 359) {
                        recyclePoolAmount += (vestingReward - vestingClaim);
                        totalVestingAvailable -= (vestingReward - vestingClaim);
                    } else {
                        vestingRewardForTheNext8Days = (vestingReward - vestingClaim) * PRECISION_FACTOR / 8;
                    }
                } else {
                    vestingCycleDistribution[cycleId] -= vestingClaim * PRECISION_FACTOR;
                }
            }

            if (excessVestingReward > 0) {
                vestingCycleDistribution[cycleId] -= excessVestingReward * PRECISION_FACTOR;
                if (cycleId < 368 && currentCycle > 359) {
                    recyclePoolAmount += excessVestingReward;
                    totalVestingAvailable -= excessVestingReward;
                } else {
                    vestingRewardForTheNext8Days += excessVestingReward * PRECISION_FACTOR / 8;
                }
            }
            
            for (uint256 j = 1; j <= 8; j++) {
                vestingCycleDistribution[currentCycle + j] += vestingRewardForTheNext8Days;
            }

            cycleSpentSBP[cycleId] += userSBP;
            cycleUsers[cycleId] -= 1;
            userCycleSBP[msg.sender][cycleId] = 0;
            cyclesClaimedBFX[cycleId] += userShare;
            userCycleClaimedBFX[msg.sender][cycleId] = userShare;
            userCycleClaimedVesting[msg.sender][cycleId] = vestingClaim;
            totalBFXAvailable -= userShare + penaltyAmount;

            totalUserShare += userShare;
            totalVestingClaim += vestingClaim;
        }
        
        TransferHelper.safeTransfer(address(this), msg.sender, totalUserShare + totalVestingClaim);
        emit BFXClaimed(msg.sender, totalUserShare + totalVestingClaim);
    }

    // Function to check and start a new cycle
    function _checkAndStartNewCycle() private {
        if (isDistributedForCycle0 == false) {
            _mint(address(this), bfxDailyDistribution);
            isDistributedForCycle0 = true;
        }
        if (block.timestamp >= cycleStartTime + CYCLE_DURATION) {
            cyclesBFX[currentCycle] = bfxDailyDistribution;
            totalBFXAvailable += bfxDailyDistribution;
    
            if (vestingPoolAmount > 0 && cycleTotalSBP[currentCycle - 1] != cycleSpentSBP[currentCycle - 1]) {
                vestingCycleDistribution[currentCycle - 1] += vestingPoolAmount * PRECISION_FACTOR;
                vestingPoolAmount = 0;
            }
            
            cycleStartTime = cycleStartTime + CYCLE_DURATION;

            if (currentCycle == 7) {
                REDUCTION_PERCENTAGE = 1;
            }

            if (currentCycle == 367) {
                LP_BPS = 100;
                X28_BURN = 1600;
                MORPH_BURN = 1600;
                E280_BURN = 1600;
                BFX_BURN = 5200;
                recycleMode = true;
                recyclePercent = 5000;
            }

            if (
                !recycleMode
            ) {
                bfxDailyDistribution = bfxDailyDistribution * (100 - REDUCTION_PERCENTAGE) / 100;
                _mint(address(this), bfxDailyDistribution);
            } else {
                bfxDailyDistribution = recyclePoolAmount * distributionPercent / BPS_DENOM;
                recyclePoolAmount -= bfxDailyDistribution;
            }

            currentCycle++;
        }
    }

    // Returns user's claimable BFX amount from a cycleId.
    function getClaimableBFX(address user, uint256 cycleId) external view returns (uint256) {
        return _calculateUserShare(user, cycleId);
    }

    // Returns user's claimable Vesting Pool BFX amount from a cycleId.
    function getVestingClaimable(address user, uint256 cycleId) external view returns (uint256, uint256) {
        return _calculateUserVestingReward(user, cycleId);
    }

    // Returns info for a token that is allowed to purchaseSBP.
    function getAllowedToken(address token) external view returns (address[] memory, uint24[] memory) {
        TokenSwapInfo memory swapInfo = allowedTokens[token];
        return (swapInfo.swapPath, swapInfo.feeTiers);
    }

    // Function to auto-claim the final user for a cycleId.
    function _assignSBP(address user, uint256 sbpAmount, uint256 cycleId) internal {
        for (uint256 i = 0; i < MINER_LENGTH; i++) {
            uint256 decayFactor = sbpAmount * (10000 - (DAILY_DECAY * i)) / BPS_DENOM;
            uint256 usersCurrentSBP = userCycleSBP[user][cycleId + i];
            userCycleSBP[user][cycleId + i] += decayFactor;
            cycleTotalSBP[cycleId + i] += decayFactor;
            if (usersCurrentSBP == 0) {
                cycleUsers[cycleId + i] += 1;
            }
        }
    }

    // Function to calculate user share.
    function _calculateUserShare(address user, uint256 cycleId) private view returns (uint256) {
        uint256 userSBP = userCycleSBP[user][cycleId];
        uint256 totalSBP = cycleTotalSBP[cycleId];
        uint256 cycleBFX = 0;
        if(cycleId == currentCycle) {
            cycleBFX = bfxDailyDistribution;
        } else {
            cycleBFX = cyclesBFX[cycleId];
        }
        if (totalSBP == 0 || cycleBFX == 0 || userSBP == 0) return 0;
        return cycleBFX * userSBP / totalSBP;
    }

    // Function to calculate the user's share of the vesting reward pool
    function _calculateUserVestingReward(address user, uint256 cycleId) private view returns (uint256 vestingReward, uint256 excessReward) {
        uint256 userSBP = userCycleSBP[user][cycleId];
        uint256 totalSBP = cycleTotalSBP[cycleId] - cycleSpentSBP[cycleId];
        uint256 totalVesting = vestingCycleDistribution[cycleId];

        if (totalSBP == 0 || totalVesting == 0 || userSBP == 0) return (0, 0);

        uint256 userShare = _calculateUserShare(user, cycleId);

        uint256 vestingCap = userShare * 6;

        uint256 rawVestingReward = totalVesting * userSBP / totalSBP / PRECISION_FACTOR;
        vestingReward = rawVestingReward > vestingCap ? vestingCap : rawVestingReward;
        excessReward = rawVestingReward > vestingCap ? (rawVestingReward - vestingCap) : 0;

        return (vestingReward, excessReward);
    }

    // Function to allow BNB to deposit to recyclePool
    function depositRecycle(uint256 amount) external {
        if (_msgSender() != address(buyAndBurn)) revert OnlyBuyAndBurn();
        recyclePoolAmount += amount;
    }

    // Function to allow BNB to Check and Start New Cycle.
    function checkAndStartNewCycle() external {
        if (_msgSender() != address(buyAndBurn)) revert OnlyBuyAndBurn();
        _checkAndStartNewCycle();
    }

    // Function to set new Distribution Percent for Recycle Pool.
    function setDistributionPercent(uint32 newPercent) external {
        if (msg.sender != address(genesisAddress) && msg.sender != address(devAddress)) revert BFX_NotAllowed();
        distributionPercent = newPercent;
        require(distributionPercent >= 100 && distributionPercent <= 1000, "1 to 10 percent only.");
        emit ParameterUpdated();
    }

    // Function to update the buy and burn contract address.
    function setBuyAndBurnContractAddress(address contractAddress) external {
        if (contractAddress == address(0)) revert BFX_InvalidAddress();
        if (contractAddress.code.length == 0) revert BFX_InvalidAddress();
        if (msg.sender != address(genesisAddress) && msg.sender != address(devAddress)) revert BFX_NotAllowed();
        buyAndBurn = BonFireBuyAndBurn(contractAddress);
        IERC20(X28_ADDRESS).approve(address(buyAndBurn), type(uint256).max);
        emit ParameterUpdated();
    }

    // Function to update the distribution percents.
    function setLpPercent(uint32 _newLpPercent) external {
        if (msg.sender != address(genesisAddress) && msg.sender != address(devAddress)) revert BFX_NotAllowed();
        LP_BPS = _newLpPercent;
        if (currentCycle <= 367) {
            require(LP_BPS <= 800, "Maximum 8 percent to LP allowed.");
        } else {
            require(LP_BPS <= 100, "Maximum 1 percent to LP allowed.");
        }
        emit ParameterUpdated();
    }

    // Function to allow genesis address to be updated.
    function setNewGenesisAddress(address newGenesisAddress) external {
        if (_msgSender() != genesisAddress) revert BFX_NotAllowed();
        if (newGenesisAddress == address(0)) revert BFX_InvalidAddress();
        genesisAddress = newGenesisAddress;
        emit ParameterUpdated();
    }

    // Function to allow dev address to be updated.
    function setNewDevAddress(address newDevAddress) external {
        if (_msgSender() != devAddress) revert BFX_NotAllowed();
        if (newDevAddress == address(0)) revert BFX_InvalidAddress();
        devAddress = newDevAddress;
        emit ParameterUpdated();
    }

    // Function to set allowed tokens.
    function setAllowedToken(
        address token,
        address[] memory swapPath,
        uint24[] memory feeTiers
    ) external {
        if (msg.sender != address(genesisAddress) && msg.sender != address(devAddress) && msg.sender != address(owner())) revert BFX_NotAllowed();
        if (token.code.length == 0) revert BFX_InvalidAddress();
        require(swapPath.length == feeTiers.length + 1, "Invalid swap path or fee tiers length");
        allowedTokens[token] = TokenSwapInfo(swapPath, feeTiers);
        emit ParameterUpdated();
    }

    // Function to mint LP tokens, only called once and only by the BuyAndBurn contract.
    function mintLPTokens() external {
        if (_msgSender() != address(buyAndBurn)) revert OnlyBuyAndBurn();
        if (lpAdded) revert BFX_NotAllowed();
        _mint(address(buyAndBurn), INITIAL_LP_MINT);
        lpAdded = true;
    }

    ///@notice - Creates the BFX/X28 Pool on uniswapV3
    ///@notice - Only called once when liquidity is added from BuyAndBurn
    function createX28BonfirePool(
        address _x28,
        uint256 _x28Received
    ) external onlyBuyAndBurn returns (address _x28BfxPool) {
        address _bfx = address(this);

        (address token0, address token1) = _x28 < _bfx
            ? (_x28, _bfx)
            : (_bfx, _x28);

        uint256 x28Amount = _x28Received;
        uint256 bfxAmount = INITIAL_LP_MINT;

        (uint256 amount0, uint256 amount1) = token0 == _x28
            ? (x28Amount, bfxAmount)
            : (bfxAmount, x28Amount);

        uint160 sqrtPriceX96 = uint160(
            (Math.sqrt((amount1 * 1e18) / amount0) * 2 ** 96) / 1e9
        );

        INonfungiblePositionManager manager = INonfungiblePositionManager(
            UNISWAP_V3_POSITION_MANAGER
        );

        x28BfxPool = manager.createAndInitializePoolIfNecessary(
            token0,
            token1,
            POOL_FEE,
            sqrtPriceX96
        );

        _x28BfxPool = x28BfxPool;

        IUniswapV3Pool(x28BfxPool).increaseObservationCardinalityNext(uint16(100));
    }
}

File 2 of 49 : 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);
    }
}

File 3 of 49 : draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC-20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC-721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC-1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

File 4 of 49 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC-20
 * applications.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

    mapping(address account => mapping(address spender => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Skips emitting an {Approval} event indicating an allowance update. This is not
     * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     *
     * ```solidity
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `value`.
     *
     * Does not update the allowance value in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Does not emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value, false);
            }
        }
    }
}

File 5 of 49 : ERC20Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Burnable.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys a `value` amount of tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 value) public virtual {
        _burn(_msgSender(), value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, deducting from
     * the caller's allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `value`.
     */
    function burnFrom(address account, uint256 value) public virtual {
        _spendAllowance(account, _msgSender(), value);
        _burn(account, value);
    }
}

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

pragma solidity ^0.8.20;

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

File 8 of 49 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.20;

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

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 9 of 49 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.20;

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

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 10 of 49 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Required interface of an ERC-721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC-721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
     *   {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 11 of 49 : 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;
    }
}

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

pragma solidity ^0.8.20;

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

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

pragma solidity ^0.8.20;

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

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

    uint256 private _status;

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

    constructor() {
        _status = NOT_ENTERED;
    }

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

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

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

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

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

File 14 of 49 : IUniswapV3SwapCallback.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
    /// @dev In the implementation you must pay the pool tokens owed for the swap.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
    function uniswapV3SwapCallback(
        int256 amount0Delta,
        int256 amount1Delta,
        bytes calldata data
    ) external;
}

File 15 of 49 : BonFireBuyAndBurn.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.26;

/* === UNIV3 === */
import {IUniswapV2Pair} from "./lib/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import {IUniswapV2Router01, IUniswapV2Router02} from "./lib/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import {IUniswapV3Pool} from "./lib/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {TransferHelper} from "./lib/v3-periphery/contracts/libraries/TransferHelper.sol";
import {INonfungiblePositionManager} from "./lib/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol";
import {TickMath} from "./lib/v3-core/contracts/libraries/TickMath.sol";
import {OracleLibrary} from "./OracleLibrary.sol";
import {ISwapRouter} from "./lib/v3-periphery/contracts/interfaces/ISwapRouter.sol";

/* === OZ === */
import {ReentrancyGuard} from "./lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol";
import {Math} from "./lib/openzeppelin-contracts/contracts/utils/math/Math.sol";
import {Ownable2Step, Ownable} from "./lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol";
import {IERC20} from "./lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {ERC20Burnable} from "./lib/openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Burnable.sol";

/* === CONST === */
import "./BuyAndBurnConst.sol";

/* === SYSTEM === */
import {BonFire} from "./BFX.sol";
import {BonFireLpAdder} from "./BonFireLpAdder.sol";

/**
 * @title BonFireBuyAndBurn
 * @author BuildTheTech.com
 * @notice This contract handles the buying and burning of BonFire tokens using Uniswap V3 pools.
 */
contract BonFireBuyAndBurn is ReentrancyGuard, Ownable2Step {
    using TransferHelper for IERC20;
    using Math for uint256;

    /* == STRUCTS == */

    /// @notice Struct to represent intervals for burning
    struct Interval {
        uint128 amountAllocated;
        uint128 amountBurned;
    }

    struct LP {
        uint248 tokenId;
        bool isX28Token0;
    }

    /* == CONTSTANTS == */

    /// @notice Uniswap V3 position manager
    INonfungiblePositionManager public constant POSITION_MANAGER =
        INonfungiblePositionManager(UNISWAP_V3_POSITION_MANAGER);

    /* == IMMUTABLE == */
    /// @notice BonFire token contract
    BonFire public immutable bfxToken;

    /// @notice BonFireLpAdder contract
    uint256 public lpAddThreshold = 100_000_000e18;

    ///@notice The startTimestamp
    uint32 public immutable startTimeStamp;

    /* == STATE == */

    ///@notice The liquidity position after creating the BonFire/X28 Pool
    LP private lp;

    /// @notice Indicates if liquidity has been added to the pool
    bool public liquidityAdded;

    /// @notice Timestamp of the last burn call
    uint32 public lastBurnedIntervalStartTimestamp;

    /// @notice Last stored BFX/X28 price
    uint256 public lastBonFireX28Price;

    /// @notice Buy and burn settings
    uint32 public currentMultiplier = 100;
    uint32 public nextMultiplier = 100;

    /// @notice Total amount of tokens burnt
    uint256 public totalBonFireBurnt;
    uint256 public totalMorphBurnt;
    uint256 public totalX28Burnt;
    uint256 public totalE280Burnt;

    /// @notice Mapping from interval number to Interval struct
    mapping(uint32 interval => Interval) public intervals;

    /// @notice Last interval number
    uint32 public lastIntervalNumber;

    /// @notice Interval Multipliers and Percent Triggers
    uint32 public FIRST_MULTIPLIER = 150;
    uint32 public SECOND_MULTIPLIER = 200;
    uint32 public THIRD_MULTIPLIER = 300;
    uint32 public FOURTH_MULTIPLIER = 500;
    uint32 public FIFTH_MULTIPLIER = 800;
    uint32 public FIRST_PERCENT = 150;
    uint32 public SECOND_PERCENT = 500;
    uint32 public THIRD_PERCENT = 1500;
    uint32 public FOURTH_PERCENT = 2500;
    uint32 public FIFTH_PERCENT = 5000;

    /// @notice Total X28 tokens distributed
    uint256 public totalX28ForBurn;

    ///@notice The slippage for the second swap in the buy and burn in %
    uint8 public titanXToX28Slippage = 10;
    uint8 public x28ToBonFireSlippage = 50;
    uint8 public titanXToE280Slippage = 10;
    uint8 public titanXToDragonXSlippage = 10;
    uint8 public dragonXToMorphSlippage = 10;

    ///@notice The daily percentage of x28 used in buy and burn
    uint256 public DAILY_ALLOCATION = 800;

    /* == EVENTS == */

    /// @notice Event emitted when tokens are bought and burnt
    event BuyAndBurn(
        uint256 indexed x28Amount,
        uint256 indexed bfxBurnt,
        address indexed caller
    );
    event ParameterUpdated();

    /* == ERRORS == */

    /// @notice Error when the contract has not started yet
    error NotStartedYet();

    /// @notice Error when minter is not msg.msg.sender
    error OnlyBFX();

    /// @notice Error when action is not allowed by caller
    error NotAllowed();

    /// @notice Error when some user input is considered invalid
    error InvalidInput();

    /// @notice Error when we try to create liquidity pool with less than the intial amount
    error NotEnoughX28ForLiquidity();

    /// @notice Error when liquidity has already been added
    error LiquidityAlreadyAdded();

    /// @notice Error when interval has already been burned
    error IntervalAlreadyBurned();

    /* == CONSTRUCTOR == */

    /// @notice Constructor initializes the contract
    /// @notice Constructor is payable to save gas
    constructor(
        uint32 startTimestamp,
        address _owner
    ) payable Ownable(_owner) {
        startTimeStamp = startTimestamp;
        bfxToken = BonFire(msg.sender);
        lastBurnedIntervalStartTimestamp = startTimestamp;
    }

    /* === MODIFIERS === */

    /// @notice Updates the contract state for intervals
    modifier intervalUpdate() {
        _intervalUpdate();
        _;
    }

    /* == PUBLIC/EXTERNAL == */

    /**
     * @notice Swaps X28 for BonFire and burns the BonFire tokens
     * @param _deadline The deadline for which the passes should pass
     */
    function swapX28ForBonFireAndBurn(uint32 _deadline) external nonReentrant intervalUpdate {
        if (!liquidityAdded) revert NotStartedYet();
        Interval storage currInterval = intervals[lastIntervalNumber];
        if (currInterval.amountBurned != 0) revert IntervalAlreadyBurned();

        uint256 amountAllocated = (currInterval.amountAllocated * currentMultiplier) / 100;
        uint256 incentive = (amountAllocated * INCENTIVE_FEE) / BPS_DENOM;
        uint256 leftover = amountAllocated - incentive;

        leftover = _handleRecycle(leftover, _deadline);

        (
            uint256 x28BurnAmount,
            uint256 bfxAmount,
            uint256 e280Amount,
            uint256 morphAmount,
            uint256 amountForBurns
        ) = _handleBurns(leftover, _deadline);

        TransferHelper.safeTransfer(X28_ADDRESS, msg.sender, incentive);

        burnBonFire();

        if (IERC20(X28_ADDRESS).balanceOf(address(bfxToken.lpAdder())) >= lpAddThreshold) {
            BonFireLpAdder(getLpAdder()).addLP(_deadline);
        }

        totalE280Burnt += e280Amount;
        totalX28Burnt += x28BurnAmount;
        totalMorphBurnt += morphAmount;

        totalX28ForBurn = IERC20(X28_ADDRESS).balanceOf(address(this));

        emit BuyAndBurn(amountForBurns, bfxAmount, msg.sender);

        _updatePriceAndMultiplier();
        bfxToken.checkAndStartNewCycle();
    }

    /**
     * @notice Creates a Uniswap V3 pool and adds liquidity
     * @param _deadline The deadline for the liquidity addition
     */
    function addLiquidityToBonFireX28Pool(
        uint32 _deadline
    ) external {
        if (liquidityAdded) revert LiquidityAlreadyAdded();
        if (IERC20(X28_ADDRESS).balanceOf(address(this)) < INITIAL_X28_FOR_LIQ)
            revert NotEnoughX28ForLiquidity();
        if (msg.sender != address(bfxToken))
            revert OnlyBFX();

        liquidityAdded = true;

        bfxToken.createX28BonfirePool(X28_ADDRESS, INITIAL_X28_FOR_LIQ);

        bfxToken.mintLPTokens();
        (
            uint256 amount0,
            uint256 amount1,
            uint256 amount0Min,
            uint256 amount1Min,
            address token0,
            address token1
        ) = _sortAmounts(INITIAL_X28_FOR_LIQ, INITIAL_LP_MINT);

        TransferHelper.safeApprove(token0, address(POSITION_MANAGER), amount0);
        TransferHelper.safeApprove(token1, address(POSITION_MANAGER), amount1);

        INonfungiblePositionManager.MintParams
            memory params = INonfungiblePositionManager.MintParams({
                token0: token0,
                token1: token1,
                fee: POOL_FEE,
                tickLower: (TickMath.MIN_TICK / TICK_SPACING) * TICK_SPACING,
                tickUpper: (TickMath.MAX_TICK / TICK_SPACING) * TICK_SPACING,
                amount0Desired: amount0,
                amount1Desired: amount1,
                amount0Min: amount0Min,
                amount1Min: amount1Min,
                recipient: address(this),
                deadline: _deadline
            });

        (uint256 tokenId, , , ) = POSITION_MANAGER.mint(params);

        lp = LP({
            tokenId: uint248(tokenId),
            isX28Token0: token0 == X28_ADDRESS
        });

        totalX28ForBurn = IERC20(X28_ADDRESS).balanceOf(address(this));
    }

    /**
     * @notice Allows dev or genesis to update the LP add Threshold setting
     * @param newThreshold New threshold balance of X28 in the LpAdder contract
     */
    function setLpAddThreshold(uint8 newThreshold) external {
        if (msg.sender != address(bfxToken.genesisAddress()) && msg.sender != address(bfxToken.devAddress())) revert NotAllowed();
        lpAddThreshold = newThreshold;
        require(lpAddThreshold >= 2, "Invalid threshold");
    }

    /**
     * @notice Allows owner to update the interval multipliers and percentage triggers
     * @param _newDailyAllocation The desired pre-multiplied percent of buy and burned to be burned daily.
     * @param _firstMultiplier The first multiplier
     * @param _secondMultiplier The second multiplier
     * @param _thirdMultiplier The third multiplier
     * @param _fourthMultiplier The fourth multiplier
     * @param _fifthMultiplier The fifth multiplier
     * @param _firstPercent The percent loss required to trigger first multiplier
     * @param _secondPercent The percent loss required to trigger second multiplier
     * @param _thirdPercent The percent loss required to trigger third multiplier
     * @param _fourthPercent The percent loss required to trigger fourth multiplier
     * @param _fifthPercent The percent loss required to trigger fifth multiplier
     */
    function setBurnSettings(
        uint256 _newDailyAllocation,
        uint32 _firstMultiplier,
        uint32 _secondMultiplier,
        uint32 _thirdMultiplier,
        uint32 _fourthMultiplier,
        uint32 _fifthMultiplier,
        uint32 _firstPercent,
        uint32 _secondPercent,
        uint32 _thirdPercent,
        uint32 _fourthPercent,
        uint32 _fifthPercent
    ) external {
        if (msg.sender != address(bfxToken.genesisAddress()) && msg.sender != address(bfxToken.devAddress())) revert NotAllowed();

        DAILY_ALLOCATION = _newDailyAllocation;
        FIRST_MULTIPLIER = _firstMultiplier;
        SECOND_MULTIPLIER = _secondMultiplier;
        THIRD_MULTIPLIER = _thirdMultiplier;
        FOURTH_MULTIPLIER = _fourthMultiplier;
        FIFTH_MULTIPLIER = _fifthMultiplier;
        FIRST_PERCENT = _firstPercent;
        SECOND_PERCENT = _secondPercent;
        THIRD_PERCENT = _thirdPercent;
        FOURTH_PERCENT = _fourthPercent;
        FIFTH_PERCENT = _fifthPercent;

        uint256 maxMultiplier = (18e5 / DAILY_ALLOCATION);

        require(
            DAILY_ALLOCATION >= 100 && DAILY_ALLOCATION <= 1000,
            "DAILY_ALLOCATION must be between 100 (1%) and 1000 (10%)"
        );
        require(
            FIRST_MULTIPLIER >= 100 && FIRST_MULTIPLIER <= maxMultiplier &&
            SECOND_MULTIPLIER >= 100 && SECOND_MULTIPLIER <= maxMultiplier &&
            THIRD_MULTIPLIER >= 100 && THIRD_MULTIPLIER <= maxMultiplier &&
            FOURTH_MULTIPLIER >= 100 && FOURTH_MULTIPLIER <= maxMultiplier &&
            FIFTH_MULTIPLIER >= 100 && FIFTH_MULTIPLIER <= maxMultiplier,
            "Multiplier exceeds allowed maximum"
        );

        _intervalUpdate();

        emit ParameterUpdated();
    }

    /// @notice Burns BonFire tokens held by the contract
    function burnBonFire() public {
        uint256 bfxToBurn = bfxToken.balanceOf(address(this));

        totalBonFireBurnt = totalBonFireBurnt + bfxToBurn;
        bfxToken.burn(bfxToBurn);
    }

    /**
     * @notice Allows owner to update the slippage setting for all internal swaps
     * @param _titanXToX28Slippage TitanX -> X28 Slippage
     * @param _x28ToBonFireSlippage X28 -> BFX Slippage
     * @param _titanXToE280Slippage TitanX -> E280 Slippage
     * @param _titanXToDragonXSlippage TitanX -> DragonX Slippage
     * @param _dragonXToMorphSlippage DragonX -> Morpheus Slippage
     */
    function setSlippages(uint8 _titanXToX28Slippage, uint8 _x28ToBonFireSlippage, uint8 _titanXToE280Slippage, uint8 _titanXToDragonXSlippage, uint8 _dragonXToMorphSlippage) external {
        if (msg.sender != address(bfxToken.genesisAddress()) && msg.sender != address(bfxToken.devAddress())) revert NotAllowed();
        if (_titanXToX28Slippage > 100 || _titanXToX28Slippage < 2) revert InvalidInput();
        if (_x28ToBonFireSlippage > 100 || _x28ToBonFireSlippage < 2) revert InvalidInput();
        if (_titanXToE280Slippage > 100 || _titanXToE280Slippage < 2) revert InvalidInput();
        if (_titanXToDragonXSlippage > 100 || _titanXToDragonXSlippage < 2) revert InvalidInput();
        if (_dragonXToMorphSlippage > 100 || _dragonXToMorphSlippage < 2) revert InvalidInput();

        titanXToX28Slippage = _titanXToX28Slippage;
        x28ToBonFireSlippage = _x28ToBonFireSlippage;
        titanXToE280Slippage = _titanXToE280Slippage;
        titanXToDragonXSlippage = _titanXToDragonXSlippage;
        dragonXToMorphSlippage = _dragonXToMorphSlippage;

        emit ParameterUpdated();
    }

    /**
     * @notice Distributes X28 tokens for burning
     * @param _amount The amount of X28 tokens
     */
    function distributeX28ForBurning(uint256 _amount) external {
        if (_amount == 0) revert InvalidInput();

        TransferHelper.safeTransferFrom(
            X28_ADDRESS,
            msg.sender,
            address(this),
            _amount
        );

        totalX28ForBurn = IERC20(X28_ADDRESS).balanceOf(address(this));
    }

    /**
    * @notice Increases the liquidity of the existing Uniswap V3 position
    * @param x28Amount The amount of x28 to use to add as liquidity
    * @param _deadline The deadline by which the transaction must be completed
    */
    function increaseLiquidity(
        uint256 x28Amount,
        uint256 _deadline
    ) external {
        if (!liquidityAdded) revert NotStartedYet();
        if (msg.sender != getLpAdder()) revert NotAllowed();

        uint256 x28Before = IERC20(X28_ADDRESS).balanceOf(address(this));

        // Transfer X28 from sender
        TransferHelper.safeTransferFrom(
            X28_ADDRESS,
            msg.sender,
            address(this),
            x28Amount
        );

        // Swap X28 for BFX
        uint256 bfxReceived = _swapX28ForBonFire(
            x28Amount / 2,
            _deadline
        );

        // Approve tokens for POSITION_MANAGER
        TransferHelper.safeApprove(address(bfxToken), address(POSITION_MANAGER), bfxReceived);
        TransferHelper.safeApprove(X28_ADDRESS, address(POSITION_MANAGER), x28Amount / 2);

        // Add liquidity with balanced amounts
        INonfungiblePositionManager.IncreaseLiquidityParams memory params = INonfungiblePositionManager
            .IncreaseLiquidityParams({
                tokenId: lp.tokenId,
                amount0Desired: lp.isX28Token0 ? x28Amount / 2 : bfxReceived,
                amount1Desired: lp.isX28Token0 ? bfxReceived : x28Amount / 2,
                amount0Min: lp.isX28Token0 ? ((100 - x28ToBonFireSlippage) * (x28Amount / 2)) / 100 : ((100 - x28ToBonFireSlippage) * bfxReceived) / 100,
                amount1Min: lp.isX28Token0 ? ((100 - x28ToBonFireSlippage) * bfxReceived) / 100 : ((100 - x28ToBonFireSlippage) * (x28Amount / 2)) / 100,
                deadline: _deadline
            });

        POSITION_MANAGER.increaseLiquidity(params);

        uint256 x28After = IERC20(X28_ADDRESS).balanceOf(address(this)) - x28Before;

        if (x28After > 0) {
            TransferHelper.safeTransfer(X28_ADDRESS, getLpAdder(), x28After);
        }
    }

    /**
     * @notice Burns the fees collected from the Uniswap V3 position
     *
     * @return amount0 The amount of token0 collected
     * @return amount1 The amount of token1 collected
     */
    function burnFees() external returns (uint256 amount0, uint256 amount1) {
        LP memory _lp = lp;

        INonfungiblePositionManager.CollectParams
            memory params = INonfungiblePositionManager.CollectParams({
                tokenId: _lp.tokenId,
                recipient: address(this),
                amount0Max: type(uint128).max,
                amount1Max: type(uint128).max
            });

        (amount0, amount1) = POSITION_MANAGER.collect(params);

        (uint256 x28Amount, ) = _lp.isX28Token0
            ? (amount0, amount1)
            : (amount1, amount0);

        TransferHelper.safeTransfer(X28_ADDRESS, getLpAdder(), x28Amount);
        burnBonFire();
    }

    /* == PUBLIC-GETTERS == */

    /**
     * @notice Gets the daily X28 allocation
     * @return dailyBPSAllocation The daily allocation in basis points
     */
    function getDailyX28Allocation() public view returns (uint32 dailyBPSAllocation) {
        dailyBPSAllocation = uint32(DAILY_ALLOCATION);
    }

    /**
     * @notice Gets a quote for DragonX tokens in exchange for TitanX tokens
     * @param baseAmount The amount of TitanX tokens
     * @return quote The amount of DragonX tokens received
     */
    function getDragonxQuoteForTitanX(
        uint256 baseAmount
    ) public view returns (uint256 quote) {
        address poolAddress = UNISWAP_V3_DRAGON_X_TITAN_X_POOL;
        uint32 secondsAgo = 15 * 60;
        uint32 oldestObservation = OracleLibrary.getOldestObservationSecondsAgo(
            poolAddress
        );

        if (oldestObservation < secondsAgo) secondsAgo = oldestObservation;

        (int24 arithmeticMeanTick, ) = OracleLibrary.consult(
            poolAddress,
            secondsAgo
        );

        uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(arithmeticMeanTick);

        quote = OracleLibrary.getQuoteForSqrtRatioX96(
            sqrtPriceX96,
            baseAmount,
            TITAN_X_ADDRESS,
            DRAGON_X_ADDRESS
        );
    }

    /**
     * @notice Gets a quote for MORPH tokens in exchange for DragonX tokens
     * @param baseAmount The amount of DragonX tokens
     * @return quote The amount of X28 tokens received
     */
    function getMorphQuoteForDragonX(
        uint256 baseAmount
    ) public view returns (uint256 quote) {
        address poolAddress = UNISWAP_V3_MORPH_DRAGON_X_POOL;
        uint32 secondsAgo = 15 * 60;
        uint32 oldestObservation = OracleLibrary.getOldestObservationSecondsAgo(
            poolAddress
        );

        if (oldestObservation < secondsAgo) secondsAgo = oldestObservation;

        (int24 arithmeticMeanTick, ) = OracleLibrary.consult(
            poolAddress,
            secondsAgo
        );

        uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(arithmeticMeanTick);

        quote = OracleLibrary.getQuoteForSqrtRatioX96(
            sqrtPriceX96,
            baseAmount,
            DRAGON_X_ADDRESS,
            MORPH_ADDRESS
        );
    }

    /**
     * @notice Gets a quote for TitanX tokens in exchange for X28 tokens
     * @param baseAmount The amount of Titanx tokens
     * @return quote The amount of X28 tokens received
     */
    function getTitanXQuoteForX28(
        uint256 baseAmount
    ) public view returns (uint256 quote) {
        address poolAddress = UNISWAP_V3_X28_TITAN_X_POOL;
        uint32 secondsAgo = 15 * 60;
        uint32 oldestObservation = OracleLibrary.getOldestObservationSecondsAgo(
            poolAddress
        );

        if (oldestObservation < secondsAgo) secondsAgo = oldestObservation;

        (int24 arithmeticMeanTick, ) = OracleLibrary.consult(
            poolAddress,
            secondsAgo
        );

        uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(arithmeticMeanTick);

        quote = OracleLibrary.getQuoteForSqrtRatioX96(
            sqrtPriceX96,
            baseAmount,
            X28_ADDRESS,
            TITAN_X_ADDRESS
        );
    }

    /**
     * @notice Gets a quote for BonFire tokens in exchange for X28 tokens
     * @param baseAmount The amount of X28 tokens
     * @return quote The amount of BonFire tokens received
     */
    function getBonFireQuoteForX28(
        uint256 baseAmount
    ) public view returns (uint256 quote) {
        address poolAddress = bfxToken.x28BfxPool();
        uint32 secondsAgo = 15 * 60;
        uint32 oldestObservation = OracleLibrary.getOldestObservationSecondsAgo(
            poolAddress
        );

        if (oldestObservation < secondsAgo) secondsAgo = oldestObservation;

        (int24 arithmeticMeanTick, ) = OracleLibrary.consult(
            poolAddress,
            secondsAgo
        );

        uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(arithmeticMeanTick);

        quote = OracleLibrary.getQuoteForSqrtRatioX96(
            sqrtPriceX96,
            baseAmount,
            X28_ADDRESS,
            address(bfxToken)
        );
    }

    /// @notice Function to get the lpAdder address
    function getLpAdder() public view returns (address) {
        return address(bfxToken.lpAdder());
    }

    /* == INTERNAL/PRIVATE == */

    /**
     * @notice Swaps X28 tokens for TitanX tokens
     * @param amountX28 The amount of X28 tokens
     * @param _deadline The deadline for when the swap must be executed
     * @return _titanXAmount The amount of TitanX tokens received
     */
    function _swapX28ForTitanX(
        uint256 amountX28,
        uint256 _deadline
    ) private returns (uint256 _titanXAmount) {
        // wake-disable-next-line
        IERC20(X28_ADDRESS).approve(UNISWAP_V3_ROUTER, amountX28);
        // Setup the swap-path, swap
        bytes memory path = abi.encodePacked(
            X28_ADDRESS,
            POOL_FEE,
            TITAN_X_ADDRESS
        );

        uint256 expectedTitanXAmount = getTitanXQuoteForX28(
            amountX28
        );

        // Adjust for slippage (applied uniformly across both hops)
        uint256 adjustedTitanXAmount = expectedTitanXAmount * (100 - titanXToX28Slippage) / 100;

        // Swap parameters
        ISwapRouter.ExactInputParams memory params = ISwapRouter
            .ExactInputParams({
                path: path,
                recipient: address(this),
                deadline: _deadline,
                amountIn: amountX28,
                amountOutMinimum: adjustedTitanXAmount
            });

        // Execute the swap
        return ISwapRouter(UNISWAP_V3_ROUTER).exactInput(params);
    }

    /**
     * @notice Swaps TitanX tokens for E280 tokens using Uniswap V2
     * @param amountTitanX The amount of TitanX tokens
     * @param _deadline The deadline for when the swap must be executed
     * @return _e280Amount The amount of E280 tokens received
     */
    function _swapTitanXForE280(
        uint256 amountTitanX,
        uint256 _deadline
    ) private returns (uint256 _e280Amount) {
        IERC20(TITAN_X_ADDRESS).approve(UNISWAP_V2_ROUTER, amountTitanX);

        address[] memory path = new address[](2);
        path[0] = address(TITAN_X_ADDRESS);
        path[1] = address(E280_ADDRESS);

        uint256[] memory amountsOut = IUniswapV2Router01(UNISWAP_V2_ROUTER).getAmountsOut(amountTitanX, path);
        uint256 adjustedE280Amount = (amountsOut[1] * (100 - titanXToE280Slippage)) / 100;
        
        uint256 e280Before = IERC20(E280_ADDRESS).balanceOf(address(this));

        IUniswapV2Router02(UNISWAP_V2_ROUTER).swapExactTokensForTokensSupportingFeeOnTransferTokens(
            amountTitanX,
            adjustedE280Amount,
            path,
            address(this),
            _deadline
        );

        uint256 e280Gained = IERC20(E280_ADDRESS).balanceOf(address(this)) - e280Before;
        return e280Gained;
    }

    /**
     * @notice Swaps TitanX tokens for DragonX tokens
     * @param amountTitanX The amount of TitanX tokens
     * @param _deadline The deadline for when the swap must be executed
     * @return _dragonXAmount The amount of dragonX tokens received
     */
    function _swapTitanXForDragonX(
        uint256 amountTitanX,
        uint256 _deadline
    ) private returns (uint256 _dragonXAmount) {
        // wake-disable-next-line
        IERC20(TITAN_X_ADDRESS).approve(UNISWAP_V3_ROUTER, amountTitanX);
        // Setup the swap-path, swap
        bytes memory path = abi.encodePacked(
            TITAN_X_ADDRESS,
            POOL_FEE,
            DRAGON_X_ADDRESS
        );

        uint256 expectedDragonXAmount = getDragonxQuoteForTitanX(
            amountTitanX
        );

        // Adjust for slippage (applied uniformly across both hops)
        uint256 adjustedDragonXAmount = expectedDragonXAmount * (100 - titanXToDragonXSlippage) / 100;

        // Swap parameters
        ISwapRouter.ExactInputParams memory params = ISwapRouter
            .ExactInputParams({
                path: path,
                recipient: address(this),
                deadline: _deadline,
                amountIn: amountTitanX,
                amountOutMinimum: adjustedDragonXAmount
            });

        // Execute the swap
        return ISwapRouter(UNISWAP_V3_ROUTER).exactInput(params);
    }

    function _swapDragonXForMorph(
        uint256 amountDragonX,
        uint256 _deadline
    ) private returns (uint256 _morphAmount) {
        // wake-disable-next-line
        IERC20(DRAGON_X_ADDRESS).approve(UNISWAP_V3_ROUTER, amountDragonX);
        // Setup the swap-path, swap
        bytes memory path = abi.encodePacked(
            DRAGON_X_ADDRESS,
            POOL_FEE,
            MORPH_ADDRESS
        );

        uint256 expectedMorphAmount = getMorphQuoteForDragonX(
            amountDragonX
        );

        // Adjust for slippage (applied uniformly across both hops)
        uint256 adjustedMorphAmount = expectedMorphAmount * (100 - dragonXToMorphSlippage) / 100;

        // Swap parameters
        ISwapRouter.ExactInputParams memory params = ISwapRouter
            .ExactInputParams({
                path: path,
                recipient: address(this),
                deadline: _deadline,
                amountIn: amountDragonX,
                amountOutMinimum: adjustedMorphAmount
            });

        // Execute the swap
        return ISwapRouter(UNISWAP_V3_ROUTER).exactInput(params);
    }

    function _swapX28ForBonFire(
        uint256 amountX28,
        uint256 _deadline
    ) private returns (uint256 _bfxAmount) {
        // wake-disable-next-line
        IERC20(X28_ADDRESS).approve(UNISWAP_V3_ROUTER, amountX28);
        // Setup the swap-path, swap
        bytes memory path = abi.encodePacked(
            X28_ADDRESS,
            POOL_FEE,
            address(bfxToken)
        );

        uint256 expectedBonFireAmount = getBonFireQuoteForX28(
            amountX28
        );

        // Adjust for slippage (applied uniformly across both hops)
        uint256 adjustedBonFireAmount = expectedBonFireAmount * (100 - x28ToBonFireSlippage) / 100;

        // Swap parameters
        ISwapRouter.ExactInputParams memory params = ISwapRouter
            .ExactInputParams({
                path: path,
                recipient: address(this),
                deadline: _deadline,
                amountIn: amountX28,
                amountOutMinimum: adjustedBonFireAmount
            });

        // Execute the swap
        return ISwapRouter(UNISWAP_V3_ROUTER).exactInput(params);
    }

    function _calculateIntervals(
        uint256 timeElapsedSince
    )
        internal
        view
        returns (
            uint32 _lastIntervalNumber,
            uint128 _totalAmountForInterval,
            uint16 missedIntervals
        )
    {
        missedIntervals = _calculateMissedIntervals(timeElapsedSince);

        _lastIntervalNumber = lastIntervalNumber + missedIntervals + 1;

        uint256 dailyAllcation = totalX28ForBurn * DAILY_ALLOCATION / BPS_DENOM;
        uint128 _amountPerInterval = uint128(dailyAllcation / INTERVALS_PER_DAY);
        uint128 additionalAmount = _amountPerInterval * missedIntervals;

        _totalAmountForInterval = _amountPerInterval + additionalAmount;

        if (_totalAmountForInterval > totalX28ForBurn) {
            _totalAmountForInterval = uint128(totalX28ForBurn);
        }
    }

    function _calculateMissedIntervals(
        uint256 timeElapsedSince
    ) internal view returns (uint16 _missedIntervals) {
        if (lastBurnedIntervalStartTimestamp == 0) {
            /// @dev - If there is no burned interval, we do no deduct 1 since no intervals is yet claimed
            _missedIntervals = timeElapsedSince <= INTERVAL_TIME
                ? 0
                : uint16(timeElapsedSince / INTERVAL_TIME);
        } else {
            /// @dev - If we already have, a burned interval we remove 1, since the previus interval is already burned
            _missedIntervals = timeElapsedSince <= INTERVAL_TIME
                ? 0
                : uint16(timeElapsedSince / INTERVAL_TIME) - 1;
        }
    }

    /// @notice Updates the contract state for intervals
    function _intervalUpdate() private {
        if (block.timestamp < startTimeStamp) revert NotStartedYet();

        uint32 timeElapseSinceLastBurn = uint32(
            lastBurnedIntervalStartTimestamp == 0
                ? block.timestamp - startTimeStamp
                : block.timestamp - lastBurnedIntervalStartTimestamp
        );

        uint32 _lastInterval;
        uint128 _amountAllocated;
        uint16 _missedIntervals;
        uint32 _lastIntervalStartTimestamp;

        bool updated;

        ///@dev -> If this is the first time burning, Calculate if any intervals were missed and update update the allocated amount
        if (lastBurnedIntervalStartTimestamp == 0) {
            (
                _lastInterval,
                _amountAllocated,
                _missedIntervals
            ) = _calculateIntervals(timeElapseSinceLastBurn);

            _lastIntervalStartTimestamp = startTimeStamp;

            updated = true;

            ///@dev -> If the lastBurnTimeExceeds, calculate how much intervals were skipped (if any) and calculate the amount accordingly
        } else if (timeElapseSinceLastBurn > INTERVAL_TIME) {
            (
                _lastInterval,
                _amountAllocated,
                _missedIntervals
            ) = _calculateIntervals(timeElapseSinceLastBurn);

            _lastIntervalStartTimestamp = lastBurnedIntervalStartTimestamp;

            updated = true;

            _missedIntervals++;
        }

        if (updated) {
            lastBurnedIntervalStartTimestamp =
                _lastIntervalStartTimestamp +
                (_missedIntervals * INTERVAL_TIME);
            intervals[_lastInterval] = Interval({
                amountAllocated: _amountAllocated,
                amountBurned: 0
            });
            lastIntervalNumber = _lastInterval;
        }
    }

    // Handles recycle for the buy and burn.
    function _handleRecycle(uint256 leftover, uint32 _deadline) internal returns (uint256) {
        if (bfxToken.recyclePercent() > 0) {
            uint256 amountForRecycle = leftover * bfxToken.recyclePercent() / BPS_DENOM;
            leftover -= amountForRecycle;

            uint256 recycleAmount = _swapX28ForBonFire(amountForRecycle, _deadline);
            TransferHelper.safeTransfer(address(bfxToken), address(bfxToken), recycleAmount);
            bfxToken.depositRecycle(recycleAmount);
        }
        return leftover;
    }

    // Handles the burns for the buy and burn.
    function _handleBurns(
        uint256 leftover,
        uint32 _deadline
    )
        internal
        returns (
            uint256 x28BurnAmount,
            uint256 bfxAmount,
            uint256 e280Amount,
            uint256 morphAmount,
            uint256 amountForBurns
        )
    {
        uint256 denomMinusX28Burn = BPS_DENOM - (bfxToken.X28_BURN() + bfxToken.BFX_BURN());

        // X28 Burn
        if (bfxToken.X28_BURN() > 0) {
            x28BurnAmount = leftover * bfxToken.X28_BURN() / BPS_DENOM;
            leftover -= x28BurnAmount;
            TransferHelper.safeTransfer(X28_ADDRESS, X28_BURN_ADDRESS, x28BurnAmount);
        }

        // BFX Burn
        if (bfxToken.BFX_BURN() > 0) {
            uint256 bfxBurnAmount = leftover * bfxToken.BFX_BURN() / BPS_DENOM;
            leftover -= bfxBurnAmount;
            bfxAmount = _swapX28ForBonFire(bfxBurnAmount, _deadline);
        }

        // Swap leftover X28 for TitanX
        amountForBurns = _swapX28ForTitanX(leftover, _deadline);

        // E280 Burn
        if (bfxToken.E280_BURN() > 0) {
            uint256 e280Input = amountForBurns * bfxToken.E280_BURN() / denomMinusX28Burn;
            e280Amount = _swapTitanXForE280(e280Input, _deadline);
            IERC20(E280_ADDRESS).approve(E280_ADDRESS, e280Amount);
            IERC20(E280_ADDRESS).burn(e280Amount);
        }

        // MORPH Burn
        if (bfxToken.MORPH_BURN() > 0) {
            uint256 dragonXInput = amountForBurns * bfxToken.MORPH_BURN() / denomMinusX28Burn;
            uint256 dragonXAmount = _swapTitanXForDragonX(dragonXInput, _deadline);
            morphAmount = _swapDragonXForMorph(dragonXAmount, _deadline);
            TransferHelper.safeTransfer(MORPH_ADDRESS, MORPH_BURN_ADDRESS, morphAmount);
        }
    }

    // Updates price and multiplier for buy and burn.
    function _updatePriceAndMultiplier() internal {
        uint256 currentPrice = getBonFireQuoteForX28(1e18);

        if (lastBonFireX28Price == 0) {
            lastBonFireX28Price = currentPrice;
        }

        uint256 priceChange = currentPrice > lastBonFireX28Price
            ? (currentPrice - lastBonFireX28Price) * 10000 / lastBonFireX28Price
            : 0;

        uint32 newMultiplier = 100;
        if (priceChange >= FIFTH_PERCENT) {
            newMultiplier = FIFTH_MULTIPLIER;
        } else if (priceChange >= FOURTH_PERCENT) {
            newMultiplier = FOURTH_MULTIPLIER;
        } else if (priceChange >= THIRD_PERCENT) {
            newMultiplier = THIRD_MULTIPLIER;
        } else if (priceChange >= SECOND_PERCENT) {
            newMultiplier = SECOND_MULTIPLIER;
        } else if (priceChange >= FIRST_PERCENT) {
            newMultiplier = FIRST_MULTIPLIER;
        }

        currentMultiplier = newMultiplier;
        lastBonFireX28Price = currentPrice;
    }

    /**
     * @notice Creates a Uniswap V3 pool and returns the parameters
     * @return amount0 The amount of token0
     * @return amount1 The amount of token1
     * @return amount0Min Minimum amount of token0
     * @return amount1Min Minimum amount of token1
     * @return token0 Address of token0
     * @return token1 Address of token1
     */
    function _sortAmounts(
        uint256 x28Amount,
        uint256 bfxAmount
    )
        internal
        view
        returns (
            uint256 amount0,
            uint256 amount1,
            uint256 amount0Min,
            uint256 amount1Min,
            address token0,
            address token1
        )
    {
        address _x28 = X28_ADDRESS;
        address _bfx = address(bfxToken);

        (token0, token1) = _x28 < _bfx
            ? (_x28, _bfx)
            : (_bfx, _x28);
        (amount0, amount1) = token0 == _x28
            ? (x28Amount, bfxAmount)
            : (bfxAmount, x28Amount);
        (amount0Min, amount1Min) = (
            _minus10Perc(amount0),
            _minus10Perc(amount1)
        );
    }

    ///@notice Helper to remove 10% of an amount
    function _minus10Perc(
        uint256 _amount
    ) internal pure returns (uint256 amount) {
        amount = _amount * 9000 / BPS_DENOM;
    }
}

File 16 of 49 : BonFireLpAdder.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.26;

/* === UNIV3  === */
import {TransferHelper} from "./lib/v3-periphery/contracts/libraries/TransferHelper.sol";

/* === OZ === */
import {ReentrancyGuard} from "./lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol";
import {Ownable2Step, Ownable} from "./lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol";
import {IERC20} from "./lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";

/* === CONST === */
import "./BuyAndBurnConst.sol";

/* === SYSTEM === */
import {BonFire} from "./BFX.sol";
import {BonFireBuyAndBurn} from "./BonFireBuyAndBurn.sol";

/**
 * @title BonFireLpAdder
 * @author BuildTheTech.com
 * @notice This contract stores the TitanX tokens to be used to add to liquidity to BonFire/X28 on Uniswap V3.
 */
contract BonFireLpAdder is Ownable2Step, ReentrancyGuard {

    /* == IMMUTABLE == */

    /// @notice BonFire token contract
    BonFire public immutable bfxToken;

    /* == ERRORS == */
    error Insufficient_Balance();
    error Not_Allowed();

    /* == EVENTS == */

    /// @notice Event emitted when LP is added
    event LPAdded(
        uint256 indexed titanXAmount,
        address indexed caller
    );


    /* == CONSTRUCTOR == */
    constructor(address _owner) payable Ownable(_owner) {
        bfxToken = BonFire(msg.sender);
    }

    /* == PUBLIC/EXTERNAL == */
    function addLP(uint256 _deadline) external {
        if (msg.sender != address(bfxToken.buyAndBurn())) revert Not_Allowed();
        if (IERC20(X28_ADDRESS).balanceOf(address(this)) == 0) revert Insufficient_Balance();
        
        uint256 allowance = IERC20(X28_ADDRESS).allowance(address(this), address(bfxToken.buyAndBurn()));
        if (allowance < IERC20(X28_ADDRESS).balanceOf(address(this))) {
            IERC20(X28_ADDRESS).approve(address(bfxToken.buyAndBurn()), type(uint256).max);
        }

        BonFireBuyAndBurn(bfxToken.buyAndBurn()).increaseLiquidity(IERC20(X28_ADDRESS).balanceOf(address(this)), _deadline);

        emit LPAdded(IERC20(X28_ADDRESS).balanceOf(address(this)), msg.sender);
    }    
}

File 17 of 49 : BuyAndBurnConst.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

uint256 constant PRECISION_FACTOR = 1e18;
uint256 constant INCENTIVE_FEE = 150;

address constant TITAN_X_ADDRESS = 0xF19308F923582A6f7c465e5CE7a9Dc1BEC6665B1;
address constant DRAGON_X_ADDRESS = 0x96a5399D07896f757Bd4c6eF56461F58DB951862;

address constant E280_ADDRESS = 0xe9A53C43a0B58706e67341C4055de861e29Ee943;

address constant MORPH_ADDRESS = 0x4687f007da484EFE20D7A17E5B1D105CDBFCA0Eb;
address constant MORPH_BURN_ADDRESS = 0x14f485D6480D76fe31e9332Ed4B87e704601b552;

address constant X28_ADDRESS = 0x5c47902c8C80779CB99235E42C354E53F38C3B0d;
address constant X28_BURN_ADDRESS = 0xa3144E7FCceD79Ce6ff6E14AE9d8DF229417A7a2;

address constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

/* === MINT CONFIG === */
uint32 constant GENESIS_BPS = 400;
uint32 constant DEV_BPS = 400;
uint256 constant CYCLE_DURATION = 24 hours;

/* === BURN CONFIG === */
uint256 constant BPS_DENOM = 10_000;

/// @dev 8 * 180 = 24 hours
uint256 constant INTERVALS_PER_DAY = 180;
uint32 constant INTERVAL_TIME = 8 minutes;

///@dev  The initial TitanX amount needed to create liquidity pool
uint256 constant INITIAL_X28_FOR_LIQ = 50_000_000_000e18;

///@dev The intial BFX that pairs with the TitanX
uint256 constant INITIAL_LP_MINT = 500_000_000e18;

/* === UNI === */
address constant UNISWAP_V2_FACTORY = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
address constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address constant UNISWAP_V3_ROUTER = 0xE592427A0AEce92De3Edee1F18E0157C05861564;
address constant UNISWAP_V3_POSITION_MANAGER = 0xC36442b4a4522E871399CD717aBDD847Ab11FE88;
address constant UNISWAP_V3_TITAN_X_WETH_POOL = 0xc45A81BC23A64eA556ab4CdF08A86B61cdcEEA8b;
address constant UNISWAP_V3_X28_TITAN_X_POOL = 0x99f60479da6A49D55eBA34893958cdAACc710eE9;
address constant UNISWAP_V3_MORPH_DRAGON_X_POOL = 0x763c4978b8536d5EB18fB846b91A2D3ae3E31B0C;
address constant UNISWAP_V3_DRAGON_X_TITAN_X_POOL = 0x25215d9ba4403b3DA77ce50606b54577a71b7895;

uint24 constant POOL_FEE = 10_000;

int24 constant TICK_SPACING = 200;

File 18 of 49 : 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);
    }
}

File 19 of 49 : Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

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

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

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

File 20 of 49 : draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

File 21 of 49 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

    mapping(address account => mapping(address spender => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     * ```
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `value`.
     *
     * Does not update the allowance value in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Does not emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value, false);
            }
        }
    }
}

File 22 of 49 : ERC20Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Burnable.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys a `value` amount of tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 value) public virtual {
        _burn(_msgSender(), value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, deducting from
     * the caller's allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `value`.
     */
    function burnFrom(address account, uint256 value) public virtual {
        _spendAllowance(account, _msgSender(), value);
        _burn(account, value);
    }
}

File 23 of 49 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

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

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

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

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

File 24 of 49 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
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);
    function burn(uint256 amount) external;
}

File 25 of 49 : 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;
    }
}

File 26 of 49 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

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

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return 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) {
        // (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.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     * @dev 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 {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 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 prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

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

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, 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 {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

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

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            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^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // 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^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice 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) {
        uint256 result = mulDiv(x, y, denominator);
        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

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

    /**
     * @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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @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 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @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 + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
        }
    }

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

File 27 of 49 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

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

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

    uint256 private _status;

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

    constructor() {
        _status = NOT_ENTERED;
    }

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

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

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

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

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

File 28 of 49 : IUniswapV2Pair.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;

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

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

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

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

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

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

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

File 29 of 49 : IUniswapV2Router01.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2;

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

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

File 30 of 49 : IUniswapV2Router02.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

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

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

File 31 of 49 : IUniswapV3Pool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import {IUniswapV3PoolImmutables} from './pool/IUniswapV3PoolImmutables.sol';
import {IUniswapV3PoolState} from './pool/IUniswapV3PoolState.sol';
import {IUniswapV3PoolDerivedState} from './pool/IUniswapV3PoolDerivedState.sol';
import {IUniswapV3PoolActions} from './pool/IUniswapV3PoolActions.sol';
import {IUniswapV3PoolOwnerActions} from './pool/IUniswapV3PoolOwnerActions.sol';
import {IUniswapV3PoolErrors} from './pool/IUniswapV3PoolErrors.sol';
import {IUniswapV3PoolEvents} from './pool/IUniswapV3PoolEvents.sol';

/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
    IUniswapV3PoolImmutables,
    IUniswapV3PoolState,
    IUniswapV3PoolDerivedState,
    IUniswapV3PoolActions,
    IUniswapV3PoolOwnerActions,
    IUniswapV3PoolErrors,
    IUniswapV3PoolEvents
{

}

File 32 of 49 : IUniswapV3PoolActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
    /// @notice Sets the initial price for the pool
    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
    function initialize(uint160 sqrtPriceX96) external;

    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
    /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
    /// on tickLower, tickUpper, the amount of liquidity, and the current price.
    /// @param recipient The address for which the liquidity will be created
    /// @param tickLower The lower tick of the position in which to add liquidity
    /// @param tickUpper The upper tick of the position in which to add liquidity
    /// @param amount The amount of liquidity to mint
    /// @param data Any data that should be passed through to the callback
    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
    function mint(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount,
        bytes calldata data
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Collects tokens owed to a position
    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
    /// @param recipient The address which should receive the fees collected
    /// @param tickLower The lower tick of the position for which to collect fees
    /// @param tickUpper The upper tick of the position for which to collect fees
    /// @param amount0Requested How much token0 should be withdrawn from the fees owed
    /// @param amount1Requested How much token1 should be withdrawn from the fees owed
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);

    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
    /// @dev Fees must be collected separately via a call to #collect
    /// @param tickLower The lower tick of the position for which to burn liquidity
    /// @param tickUpper The upper tick of the position for which to burn liquidity
    /// @param amount How much liquidity to burn
    /// @return amount0 The amount of token0 sent to the recipient
    /// @return amount1 The amount of token1 sent to the recipient
    function burn(
        int24 tickLower,
        int24 tickUpper,
        uint128 amount
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Swap token0 for token1, or token1 for token0
    /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
    /// @param recipient The address to receive the output of the swap
    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap
    /// @param data Any data to be passed through to the callback
    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
    function swap(
        address recipient,
        bool zeroForOne,
        int256 amountSpecified,
        uint160 sqrtPriceLimitX96,
        bytes calldata data
    ) external returns (int256 amount0, int256 amount1);

    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
    /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
    /// with 0 amount{0,1} and sending the donation amount(s) from the callback
    /// @param recipient The address which will receive the token0 and token1 amounts
    /// @param amount0 The amount of token0 to send
    /// @param amount1 The amount of token1 to send
    /// @param data Any data to be passed through to the callback
    function flash(
        address recipient,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external;

    /// @notice Increase the maximum number of price and liquidity observations that this pool will store
    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
    /// the input observationCardinalityNext.
    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store
    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}

File 33 of 49 : IUniswapV3PoolDerivedState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
    /// you must call it with secondsAgos = [3600, 0].
    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
    /// timestamp
    function observe(uint32[] calldata secondsAgos)
        external
        view
        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);

    /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
    /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
    /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
    /// snapshot is taken and the second snapshot is taken.
    /// @param tickLower The lower tick of the range
    /// @param tickUpper The upper tick of the range
    /// @return tickCumulativeInside The snapshot of the tick accumulator for the range
    /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
    /// @return secondsInside The snapshot of seconds per liquidity for the range
    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
        external
        view
        returns (
            int56 tickCumulativeInside,
            uint160 secondsPerLiquidityInsideX128,
            uint32 secondsInside
        );
}

File 34 of 49 : IUniswapV3PoolErrors.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Errors emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolErrors {
    error LOK();
    error TLU();
    error TLM();
    error TUM();
    error AI();
    error M0();
    error M1();
    error AS();
    error IIA();
    error L();
    error F0();
    error F1();
}

File 35 of 49 : IUniswapV3PoolEvents.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool
    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
    event Initialize(uint160 sqrtPriceX96, int24 tick);

    /// @notice Emitted when liquidity is minted for a given position
    /// @param sender The address that minted the liquidity
    /// @param owner The owner of the position and recipient of any minted liquidity
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity minted to the position range
    /// @param amount0 How much token0 was required for the minted liquidity
    /// @param amount1 How much token1 was required for the minted liquidity
    event Mint(
        address sender,
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted when fees are collected by the owner of a position
    /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
    /// @param owner The owner of the position for which fees are collected
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount0 The amount of token0 fees collected
    /// @param amount1 The amount of token1 fees collected
    event Collect(
        address indexed owner,
        address recipient,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount0,
        uint128 amount1
    );

    /// @notice Emitted when a position's liquidity is removed
    /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
    /// @param owner The owner of the position for which liquidity is removed
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity to remove
    /// @param amount0 The amount of token0 withdrawn
    /// @param amount1 The amount of token1 withdrawn
    event Burn(
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted by the pool for any swaps between token0 and token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the output of the swap
    /// @param amount0 The delta of the token0 balance of the pool
    /// @param amount1 The delta of the token1 balance of the pool
    /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
    /// @param liquidity The liquidity of the pool after the swap
    /// @param tick The log base 1.0001 of price of the pool after the swap
    event Swap(
        address indexed sender,
        address indexed recipient,
        int256 amount0,
        int256 amount1,
        uint160 sqrtPriceX96,
        uint128 liquidity,
        int24 tick
    );

    /// @notice Emitted by the pool for any flashes of token0/token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the tokens from flash
    /// @param amount0 The amount of token0 that was flashed
    /// @param amount1 The amount of token1 that was flashed
    /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
    /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
    event Flash(
        address indexed sender,
        address indexed recipient,
        uint256 amount0,
        uint256 amount1,
        uint256 paid0,
        uint256 paid1
    );

    /// @notice Emitted by the pool for increases to the number of observations that can be stored
    /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
    /// just before a mint/swap/burn.
    /// @param observationCardinalityNextOld The previous value of the next observation cardinality
    /// @param observationCardinalityNextNew The updated value of the next observation cardinality
    event IncreaseObservationCardinalityNext(
        uint16 observationCardinalityNextOld,
        uint16 observationCardinalityNextNew
    );

    /// @notice Emitted when the protocol fee is changed by the pool
    /// @param feeProtocol0Old The previous value of the token0 protocol fee
    /// @param feeProtocol1Old The previous value of the token1 protocol fee
    /// @param feeProtocol0New The updated value of the token0 protocol fee
    /// @param feeProtocol1New The updated value of the token1 protocol fee
    event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);

    /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
    /// @param sender The address that collects the protocol fees
    /// @param recipient The address that receives the collected protocol fees
    /// @param amount0 The amount of token0 protocol fees that is withdrawn
    /// @param amount0 The amount of token1 protocol fees that is withdrawn
    event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}

File 36 of 49 : IUniswapV3PoolImmutables.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
    /// @return The contract address
    function factory() external view returns (address);

    /// @notice The first of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token0() external view returns (address);

    /// @notice The second of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token1() external view returns (address);

    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
    /// @return The fee
    function fee() external view returns (uint24);

    /// @notice The pool tick spacing
    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
    /// This value is an int24 to avoid casting even though it is always positive.
    /// @return The tick spacing
    function tickSpacing() external view returns (int24);

    /// @notice The maximum amount of position liquidity that can use any tick in the range
    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
    /// @return The max amount of liquidity per tick
    function maxLiquidityPerTick() external view returns (uint128);
}

File 37 of 49 : IUniswapV3PoolOwnerActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
    /// @notice Set the denominator of the protocol's % share of the fees
    /// @param feeProtocol0 new protocol fee for token0 of the pool
    /// @param feeProtocol1 new protocol fee for token1 of the pool
    function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;

    /// @notice Collect the protocol fee accrued to the pool
    /// @param recipient The address to which collected protocol fees should be sent
    /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
    /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
    /// @return amount0 The protocol fee collected in token0
    /// @return amount1 The protocol fee collected in token1
    function collectProtocol(
        address recipient,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);
}

File 38 of 49 : IUniswapV3PoolState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
    /// when accessed externally.
    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
    /// @return tick The current tick of the pool, i.e. according to the last tick transition that was run.
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// @return observationIndex The index of the last oracle observation that was written,
    /// @return observationCardinality The current maximum number of observations stored in the pool,
    /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// @return feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal0X128() external view returns (uint256);

    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal1X128() external view returns (uint256);

    /// @notice The amounts of token0 and token1 that are owed to the protocol
    /// @dev Protocol fees will never exceed uint128 max in either token
    function protocolFees() external view returns (uint128 token0, uint128 token1);

    /// @notice The currently in range liquidity available to the pool
    /// @dev This value has no relationship to the total liquidity across all ticks
    /// @return The liquidity at the current price of the pool
    function liquidity() external view returns (uint128);

    /// @notice Look up information about a specific tick in the pool
    /// @param tick The tick to look up
    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
    /// tick upper
    /// @return liquidityNet how much liquidity changes when the pool price crosses the tick,
    /// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
    /// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
    /// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
    /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
    /// @return secondsOutside the seconds spent on the other side of the tick from the current tick,
    /// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for
    /// a specific position.
    function ticks(int24 tick)
        external
        view
        returns (
            uint128 liquidityGross,
            int128 liquidityNet,
            uint256 feeGrowthOutside0X128,
            uint256 feeGrowthOutside1X128,
            int56 tickCumulativeOutside,
            uint160 secondsPerLiquidityOutsideX128,
            uint32 secondsOutside,
            bool initialized
        );

    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
    function tickBitmap(int16 wordPosition) external view returns (uint256);

    /// @notice Returns the information about a position by the position's key
    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
    /// @return liquidity The amount of liquidity in the position,
    /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
    /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
    /// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
    /// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
    function positions(bytes32 key)
        external
        view
        returns (
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    /// @notice Returns data about a specific observation index
    /// @param index The element of the observations array to fetch
    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
    /// ago, rather than at a specific index in the array.
    /// @return blockTimestamp The timestamp of the observation,
    /// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
    /// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
    /// @return initialized whether the observation has been initialized and the values are safe to use
    function observations(uint256 index)
        external
        view
        returns (
            uint32 blockTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,
            bool initialized
        );
}

File 39 of 49 : FullMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = a * b
            // Compute the product mod 2**256 and mod 2**256 - 1
            // then use the Chinese Remainder Theorem to reconstruct
            // the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2**256 + prod0
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(a, b, not(0))
                prod0 := mul(a, b)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division
            if (prod1 == 0) {
                require(denominator > 0);
                assembly {
                    result := div(prod0, denominator)
                }
                return result;
            }

            // Make sure the result is less than 2**256.
            // Also prevents denominator == 0
            require(denominator > prod1);

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

            // Make division exact by subtracting the remainder from [prod1 prod0]
            // Compute remainder using mulmod
            uint256 remainder;
            assembly {
                remainder := mulmod(a, b, denominator)
            }
            // Subtract 256 bit number from 512 bit number
            assembly {
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator
            // Compute largest power of two divisor of denominator.
            // Always >= 1.
            uint256 twos = (0 - denominator) & denominator;
            // Divide denominator by power of two
            assembly {
                denominator := div(denominator, twos)
            }

            // Divide [prod1 prod0] by the factors of two
            assembly {
                prod0 := div(prod0, twos)
            }
            // Shift in bits from prod1 into prod0. For this we need
            // to flip `twos` such that it is 2**256 / twos.
            // If twos is zero, then it becomes one
            assembly {
                twos := add(div(sub(0, twos), twos), 1)
            }
            prod0 |= prod1 * twos;

            // Invert denominator mod 2**256
            // Now that denominator is an odd number, it has an inverse
            // modulo 2**256 such that denominator * inv = 1 mod 2**256.
            // Compute the inverse by starting with a seed that is correct
            // correct for four bits. That is, denominator * inv = 1 mod 2**4
            uint256 inv = (3 * denominator) ^ 2;
            // Now use 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.
            inv *= 2 - denominator * inv; // inverse mod 2**8
            inv *= 2 - denominator * inv; // inverse mod 2**16
            inv *= 2 - denominator * inv; // inverse mod 2**32
            inv *= 2 - denominator * inv; // inverse mod 2**64
            inv *= 2 - denominator * inv; // inverse mod 2**128
            inv *= 2 - denominator * inv; // inverse mod 2**256

            // 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**256. Since the precoditions guarantee
            // that the outcome is less than 2**256, this is the final result.
            // We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inv;
            return result;
        }
    }

    /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    function mulDivRoundingUp(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            result = mulDiv(a, b, denominator);
            if (mulmod(a, b, denominator) > 0) {
                require(result < type(uint256).max);
                result++;
            }
        }
    }
}

File 40 of 49 : TickMath.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
    error T();
    error R();

    /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
    int24 internal constant MIN_TICK = -887272;
    /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
    int24 internal constant MAX_TICK = -MIN_TICK;

    /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
    uint160 internal constant MIN_SQRT_RATIO = 4295128739;
    /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
    uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;

    /// @notice Calculates sqrt(1.0001^tick) * 2^96
    /// @dev Throws if |tick| > max tick
    /// @param tick The input tick for the above formula
    /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
    /// at the given tick
    function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
        unchecked {
            uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
            if (absTick > uint256(int256(MAX_TICK))) revert T();

            uint256 ratio = absTick & 0x1 != 0
                ? 0xfffcb933bd6fad37aa2d162d1a594001
                : 0x100000000000000000000000000000000;
            if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
            if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
            if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
            if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
            if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
            if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
            if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
            if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
            if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
            if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
            if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
            if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
            if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
            if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
            if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
            if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
            if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
            if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
            if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;

            if (tick > 0) ratio = type(uint256).max / ratio;

            // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
            // we then downcast because we know the result always fits within 160 bits due to our tick input constraint
            // we round up in the division so getTickAtSqrtRatio of the output price is always consistent
            sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
        }
    }

    /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
    /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
    /// ever return.
    /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
    /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
    function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
        unchecked {
            // second inequality must be < because the price can never reach the price at the max tick
            if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert R();
            uint256 ratio = uint256(sqrtPriceX96) << 32;

            uint256 r = ratio;
            uint256 msb = 0;

            assembly {
                let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(5, gt(r, 0xFFFFFFFF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(4, gt(r, 0xFFFF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(3, gt(r, 0xFF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(2, gt(r, 0xF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(1, gt(r, 0x3))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := gt(r, 0x1)
                msb := or(msb, f)
            }

            if (msb >= 128) r = ratio >> (msb - 127);
            else r = ratio << (127 - msb);

            int256 log_2 = (int256(msb) - 128) << 64;

            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(63, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(62, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(61, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(60, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(59, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(58, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(57, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(56, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(55, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(54, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(53, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(52, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(51, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(50, f))
            }

            int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number

            int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
            int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);

            tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;
        }
    }
}

File 41 of 49 : IERC721Permit.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

import '@openzeppelin/contracts/token/ERC721/IERC721.sol';

/// @title ERC721 with permit
/// @notice Extension to ERC721 that includes a permit function for signature based approvals
interface IERC721Permit is IERC721 {
    /// @notice The permit typehash used in the permit signature
    /// @return The typehash for the permit
    function PERMIT_TYPEHASH() external pure returns (bytes32);

    /// @notice The domain separator used in the permit signature
    /// @return The domain seperator used in encoding of permit signature
    function DOMAIN_SEPARATOR() external view returns (bytes32);

    /// @notice Approve of a specific token ID for spending by spender via signature
    /// @param spender The account that is being approved
    /// @param tokenId The ID of the token that is being approved for spending
    /// @param deadline The deadline timestamp by which the call must be mined for the approve to work
    /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`
    /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`
    /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`
    function permit(
        address spender,
        uint256 tokenId,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external payable;
}

File 42 of 49 : INonfungiblePositionManager.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';

import './IPoolInitializer.sol';
import './IERC721Permit.sol';
import './IPeripheryPayments.sol';
import './IPeripheryImmutableState.sol';
import '../libraries/PoolAddress.sol';

/// @title Non-fungible token for positions
/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred
/// and authorized.
interface INonfungiblePositionManager is
    IPoolInitializer,
    IPeripheryPayments,
    IPeripheryImmutableState,
    IERC721Metadata,
    IERC721Enumerable,
    IERC721Permit
{
    /// @notice Emitted when liquidity is increased for a position NFT
    /// @dev Also emitted when a token is minted
    /// @param tokenId The ID of the token for which liquidity was increased
    /// @param liquidity The amount by which liquidity for the NFT position was increased
    /// @param amount0 The amount of token0 that was paid for the increase in liquidity
    /// @param amount1 The amount of token1 that was paid for the increase in liquidity
    event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    /// @notice Emitted when liquidity is decreased for a position NFT
    /// @param tokenId The ID of the token for which liquidity was decreased
    /// @param liquidity The amount by which liquidity for the NFT position was decreased
    /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity
    /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity
    event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    /// @notice Emitted when tokens are collected for a position NFT
    /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior
    /// @param tokenId The ID of the token for which underlying tokens were collected
    /// @param recipient The address of the account that received the collected tokens
    /// @param amount0 The amount of token0 owed to the position that was collected
    /// @param amount1 The amount of token1 owed to the position that was collected
    event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);

    /// @notice Returns the position information associated with a given token ID.
    /// @dev Throws if the token ID is not valid.
    /// @param tokenId The ID of the token that represents the position
    /// @return nonce The nonce for permits
    /// @return operator The address that is approved for spending
    /// @return token0 The address of the token0 for a specific pool
    /// @return token1 The address of the token1 for a specific pool
    /// @return fee The fee associated with the pool
    /// @return tickLower The lower end of the tick range for the position
    /// @return tickUpper The higher end of the tick range for the position
    /// @return liquidity The liquidity of the position
    /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
    /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
    /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
    /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
    function positions(uint256 tokenId)
        external
        view
        returns (
            uint96 nonce,
            address operator,
            address token0,
            address token1,
            uint24 fee,
            int24 tickLower,
            int24 tickUpper,
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    struct MintParams {
        address token0;
        address token1;
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        address recipient;
        uint256 deadline;
    }

    /// @notice Creates a new position wrapped in a NFT
    /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized
    /// a method does not exist, i.e. the pool is assumed to be initialized.
    /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata
    /// @return tokenId The ID of the token that represents the minted position
    /// @return liquidity The amount of liquidity for this position
    /// @return amount0 The amount of token0
    /// @return amount1 The amount of token1
    function mint(MintParams calldata params)
        external
        payable
        returns (
            uint256 tokenId,
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );

    struct IncreaseLiquidityParams {
        uint256 tokenId;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`
    /// @param params tokenId The ID of the token for which liquidity is being increased,
    /// amount0Desired The desired amount of token0 to be spent,
    /// amount1Desired The desired amount of token1 to be spent,
    /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,
    /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,
    /// deadline The time by which the transaction must be included to effect the change
    /// @return liquidity The new liquidity amount as a result of the increase
    /// @return amount0 The amount of token0 to acheive resulting liquidity
    /// @return amount1 The amount of token1 to acheive resulting liquidity
    function increaseLiquidity(IncreaseLiquidityParams calldata params)
        external
        payable
        returns (
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );

    struct DecreaseLiquidityParams {
        uint256 tokenId;
        uint128 liquidity;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    /// @notice Decreases the amount of liquidity in a position and accounts it to the position
    /// @param params tokenId The ID of the token for which liquidity is being decreased,
    /// amount The amount by which liquidity will be decreased,
    /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,
    /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,
    /// deadline The time by which the transaction must be included to effect the change
    /// @return amount0 The amount of token0 accounted to the position's tokens owed
    /// @return amount1 The amount of token1 accounted to the position's tokens owed
    function decreaseLiquidity(DecreaseLiquidityParams calldata params)
        external
        payable
        returns (uint256 amount0, uint256 amount1);

    struct CollectParams {
        uint256 tokenId;
        address recipient;
        uint128 amount0Max;
        uint128 amount1Max;
    }

    /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
    /// @param params tokenId The ID of the NFT for which tokens are being collected,
    /// recipient The account that should receive the tokens,
    /// amount0Max The maximum amount of token0 to collect,
    /// amount1Max The maximum amount of token1 to collect
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);

    /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens
    /// must be collected first.
    /// @param tokenId The ID of the token that is being burned
    function burn(uint256 tokenId) external payable;
}

File 43 of 49 : IPeripheryImmutableState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Immutable state
/// @notice Functions that return immutable state of the router
interface IPeripheryImmutableState {
    /// @return Returns the address of the Uniswap V3 factory
    function factory() external view returns (address);

    /// @return Returns the address of WETH9
    function WETH9() external view returns (address);
}

File 44 of 49 : IPeripheryPayments.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

/// @title Periphery Payments
/// @notice Functions to ease deposits and withdrawals of ETH
interface IPeripheryPayments {
    /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.
    /// @param amountMinimum The minimum amount of WETH9 to unwrap
    /// @param recipient The address receiving ETH
    function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;

    /// @notice Refunds any ETH balance held by this contract to the `msg.sender`
    /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
    /// that use ether for the input amount
    function refundETH() external payable;

    /// @notice Transfers the full amount of a token held by this contract to recipient
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users
    /// @param token The contract address of the token which will be transferred to `recipient`
    /// @param amountMinimum The minimum amount of token required for a transfer
    /// @param recipient The destination address of the token
    function sweepToken(
        address token,
        uint256 amountMinimum,
        address recipient
    ) external payable;
}

File 45 of 49 : IPoolInitializer.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Creates and initializes V3 Pools
/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that
/// require the pool to exist.
interface IPoolInitializer {
    /// @notice Creates a new pool if it does not exist, then initializes if not initialized
    /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool
    /// @param token0 The contract address of token0 of the pool
    /// @param token1 The contract address of token1 of the pool
    /// @param fee The fee amount of the v3 pool for the specified token pair
    /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value
    /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary
    function createAndInitializePoolIfNecessary(
        address token0,
        address token1,
        uint24 fee,
        uint160 sqrtPriceX96
    ) external payable returns (address pool);
}

File 46 of 49 : ISwapRouter.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';

/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface ISwapRouter is IUniswapV3SwapCallback {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);

    struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);

    struct ExactOutputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);

    struct ExactOutputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
}

File 47 of 49 : PoolAddress.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee
library PoolAddress {
    bytes32 internal constant POOL_INIT_CODE_HASH = 0xa598dd2fba360510c5a8f02f44423a4468e902df5857dbce3ca162a43a3a31ff;

    /// @notice The identifying key of the pool
    struct PoolKey {
        address token0;
        address token1;
        uint24 fee;
    }

    /// @notice Returns PoolKey: the ordered tokens with the matched fee levels
    /// @param tokenA The first token of a pool, unsorted
    /// @param tokenB The second token of a pool, unsorted
    /// @param fee The fee level of the pool
    /// @return Poolkey The pool details with ordered token0 and token1 assignments
    function getPoolKey(
        address tokenA,
        address tokenB,
        uint24 fee
    ) internal pure returns (PoolKey memory) {
        if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);
        return PoolKey({token0: tokenA, token1: tokenB, fee: fee});
    }

    /// @notice Deterministically computes the pool address given the factory and PoolKey
    /// @param factory The Uniswap V3 factory contract address
    /// @param key The PoolKey
    /// @return pool The contract address of the V3 pool
    function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
        require(key.token0 < key.token1);
        pool = address(
            uint160(
                uint256(
                    keccak256(
                        abi.encodePacked(
                            hex'ff',
                            factory,
                            keccak256(abi.encode(key.token0, key.token1, key.fee)),
                            POOL_INIT_CODE_HASH
                        )
                    )
                )
            )
        );
    }
}

File 48 of 49 : TransferHelper.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';

library TransferHelper {
    /// @notice Transfers tokens from the targeted address to the given destination
    /// @notice Errors with 'STF' if transfer fails
    /// @param token The contract address of the token to be transferred
    /// @param from The originating address from which the tokens will be transferred
    /// @param to The destination address of the transfer
    /// @param value The amount to be transferred
    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)
        );
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
    }

    /// @notice Transfers tokens from msg.sender to a recipient
    /// @dev Errors with ST if transfer fails
    /// @param token The contract address of the token which will be transferred
    /// @param to The recipient of the transfer
    /// @param value The value of the transfer
    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev Errors with 'SA' if transfer fails
    /// @param token The contract address of the token to be approved
    /// @param to The target of the approval
    /// @param value The amount of the given token the target will be allowed to spend
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
    }

    /// @notice Transfers ETH to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}

File 49 of 49 : OracleLibrary.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.26;

// Uniswap
import {IUniswapV3Pool} from "./lib/v3-core/contracts/interfaces/IUniswapV3Pool.sol";

// OpenZeppelin
import {Math} from "./lib/openzeppelin-contracts/contracts/utils/math/Math.sol";

/**
 * @notice Adapted Uniswap V3 OracleLibrary computation to be compliant with Solidity 0.8.x and later.
 *
 * Documentation for Auditors:
 *
 * Solidity Version: Updated the Solidity version pragma to ^0.8.0. This change ensures compatibility
 * with Solidity version 0.8.x.
 *
 * Safe Arithmetic Operations: Solidity 0.8.x automatically checks for arithmetic overflows/underflows.
 * Therefore, the code no longer needs to use SafeMath library (or similar) for basic arithmetic operations.
 * This change simplifies the code and reduces the potential for errors related to manual overflow/underflow checking.
 *
 * Overflow/Underflow: With the introduction of automatic overflow/underflow checks in Solidity 0.8.x, the code is inherently
 * safer and less prone to certain types of arithmetic errors.
 *
 * Removal of SafeMath Library: Since Solidity 0.8.x handles arithmetic operations safely, the use of SafeMath library
 * is omitted in this update.
 *
 * Git-style diff for the `consult` function:
 *
 * ```diff
 * function consult(address pool, uint32 secondsAgo)
 *     internal
 *     view
 *     returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)
 * {
 *     require(secondsAgo != 0, 'BP');
 *
 *     uint32[] memory secondsAgos = new uint32[](2);
 *     secondsAgos[0] = secondsAgo;
 *     secondsAgos[1] = 0;
 *
 *     (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s) =
 *         IUniswapV3Pool(pool).observe(secondsAgos);
 *
 *     int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];
 *     uint160 secondsPerLiquidityCumulativesDelta =
 *         secondsPerLiquidityCumulativeX128s[1] - secondsPerLiquidityCumulativeX128s[0];
 *
 * -   arithmeticMeanTick = int24(tickCumulativesDelta / secondsAgo);
 * +   int56 secondsAgoInt56 = int56(uint56(secondsAgo));
 * +   arithmeticMeanTick = int24(tickCumulativesDelta / secondsAgoInt56);
 *     // Always round to negative infinity
 * -   if (tickCumulativesDelta < 0 && (tickCumulativesDelta % secondsAgo != 0)) arithmeticMeanTick--;
 * +   if (tickCumulativesDelta < 0 && (tickCumulativesDelta % secondsAgoInt56 != 0)) arithmeticMeanTick--;
 *
 * -   uint192 secondsAgoX160 = uint192(secondsAgo) * type(uint160).max;
 * +   uint192 secondsAgoUint192 = uint192(secondsAgo);
 * +   uint192 secondsAgoX160 = secondsAgoUint192 * type(uint160).max;
 *     harmonicMeanLiquidity = uint128(secondsAgoX160 / (uint192(secondsPerLiquidityCumulativesDelta) << 32));
 * }
 * ```
 */

/// @title Oracle library
/// @notice Provides functions to integrate with V3 pool oracle
library OracleLibrary {
    /// @notice Calculates time-weighted means of tick and liquidity for a given Uniswap V3 pool
    /// @param pool Address of the pool that we want to observe
    /// @param secondsAgo Number of seconds in the past from which to calculate the time-weighted means
    /// @return arithmeticMeanTick The arithmetic mean tick from (block.timestamp - secondsAgo) to block.timestamp
    /// @return harmonicMeanLiquidity The harmonic mean liquidity from (block.timestamp - secondsAgo) to block.timestamp
    function consult(
        address pool,
        uint32 secondsAgo
    )
        internal
        view
        returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)
    {
        require(secondsAgo != 0, "BP");

        uint32[] memory secondsAgos = new uint32[](2);
        secondsAgos[0] = secondsAgo;
        secondsAgos[1] = 0;

        (
            int56[] memory tickCumulatives,
            uint160[] memory secondsPerLiquidityCumulativeX128s
        ) = IUniswapV3Pool(pool).observe(secondsAgos);

        int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];
        uint160 secondsPerLiquidityCumulativesDelta = secondsPerLiquidityCumulativeX128s[
                1
            ] - secondsPerLiquidityCumulativeX128s[0];

        // Safe casting of secondsAgo to int56 for division
        int56 secondsAgoInt56 = int56(uint56(secondsAgo));
        arithmeticMeanTick = int24(tickCumulativesDelta / secondsAgoInt56);
        // Always round to negative infinity
        if (
            tickCumulativesDelta < 0 &&
            (tickCumulativesDelta % secondsAgoInt56 != 0)
        ) arithmeticMeanTick--;

        // Safe casting of secondsAgo to uint192 for multiplication
        uint192 secondsAgoUint192 = uint192(secondsAgo);
        harmonicMeanLiquidity = uint128(
            (secondsAgoUint192 * uint192(type(uint160).max)) /
                (uint192(secondsPerLiquidityCumulativesDelta) << 32)
        );
    }

    /// @notice Given a pool, it returns the number of seconds ago of the oldest stored observation
    /// @param pool Address of Uniswap V3 pool that we want to observe
    /// @return secondsAgo The number of seconds ago of the oldest observation stored for the pool
    function getOldestObservationSecondsAgo(
        address pool
    ) internal view returns (uint32 secondsAgo) {
        (
            ,
            ,
            uint16 observationIndex,
            uint16 observationCardinality,
            ,
            ,

        ) = IUniswapV3Pool(pool).slot0();
        require(observationCardinality > 0, "NI");

        (uint32 observationTimestamp, , , bool initialized) = IUniswapV3Pool(
            pool
        ).observations((observationIndex + 1) % observationCardinality);

        // The next index might not be initialized if the cardinality is in the process of increasing
        // In this case the oldest observation is always in index 0
        if (!initialized) {
            (observationTimestamp, , , ) = IUniswapV3Pool(pool).observations(0);
        }

        secondsAgo = uint32(block.timestamp) - observationTimestamp;
    }

    /// @notice Given a tick and a token amount, calculates the amount of token received in exchange
    /// a slightly modified version of the UniSwap library getQuoteAtTick to accept a sqrtRatioX96 as input parameter
    /// @param sqrtRatioX96 The sqrt ration
    /// @param baseAmount Amount of token to be converted
    /// @param baseToken Address of an ERC20 token contract used as the baseAmount denomination
    /// @param quoteToken Address of an ERC20 token contract used as the quoteAmount denomination
    /// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken
    function getQuoteForSqrtRatioX96(
        uint160 sqrtRatioX96,
        uint256 baseAmount,
        address baseToken,
        address quoteToken
    ) internal pure returns (uint256 quoteAmount) {
        // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself
        if (sqrtRatioX96 <= type(uint128).max) {
            uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;
            quoteAmount = baseToken < quoteToken
                ? Math.mulDiv(ratioX192, baseAmount, 1 << 192)
                : Math.mulDiv(1 << 192, baseAmount, ratioX192);
        } else {
            uint256 ratioX128 = Math.mulDiv(
                sqrtRatioX96,
                sqrtRatioX96,
                1 << 64
            );
            quoteAmount = baseToken < quoteToken
                ? Math.mulDiv(ratioX128, baseAmount, 1 << 128)
                : Math.mulDiv(1 << 128, baseAmount, ratioX128);
        }
    }
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"uint32","name":"_startTimestamp","type":"uint32"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"payable","type":"constructor"},{"inputs":[],"name":"BFX_AmountMismatch","type":"error"},{"inputs":[],"name":"BFX_CycleNotStarted","type":"error"},{"inputs":[],"name":"BFX_DayNotEnded","type":"error"},{"inputs":[],"name":"BFX_ETHNotAllowed","type":"error"},{"inputs":[],"name":"BFX_InvalidAddress","type":"error"},{"inputs":[],"name":"BFX_InvalidSBPPurchase","type":"error"},{"inputs":[],"name":"BFX_NoSBPToClaim","type":"error"},{"inputs":[],"name":"BFX_NotAllowed","type":"error"},{"inputs":[],"name":"BFX_SwapFailed","type":"error"},{"inputs":[],"name":"BFX_UnsupportedToken","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[],"name":"OnlyBuyAndBurn","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"bfxAmount","type":"uint256"}],"name":"BFXClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"x28Amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sbpAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cycleId","type":"uint256"}],"name":"MinerStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[],"name":"ParameterUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"BFX_BURN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DAILY_DECAY","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"E280_BURN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LP_BPS","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINER_LENGTH","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MORPH_BURN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REDUCTION_PERCENTAGE","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"X28_BURN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bfxDailyDistribution","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"buyAndBurn","outputs":[{"internalType":"contract BonFireBuyAndBurn","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"checkAndStartNewCycle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"cycleId","type":"uint256"}],"name":"claimBFX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"cycleIds","type":"uint256[]"}],"name":"claimBFXBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_x28","type":"address"},{"internalType":"uint256","name":"_x28Received","type":"uint256"}],"name":"createX28BonfirePool","outputs":[{"internalType":"address","name":"_x28BfxPool","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cycleSpentSBP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cycleStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cycleTotalSBP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cycleUsers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cyclesBFX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cyclesClaimedBFX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cyclesForfeitBFX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositRecycle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"devAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributionPercent","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"genesisAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getAllowedToken","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint24[]","name":"","type":"uint24[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"cycleId","type":"uint256"}],"name":"getClaimableBFX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"cycleId","type":"uint256"}],"name":"getVestingClaimable","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpAdder","outputs":[{"internalType":"contract BonFireLpAdder","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"}],"name":"mineBFX","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintLPTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"recycleMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"recyclePercent","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"recyclePoolAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address[]","name":"swapPath","type":"address[]"},{"internalType":"uint24[]","name":"feeTiers","type":"uint24[]"}],"name":"setAllowedToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"setBuyAndBurnContractAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"newPercent","type":"uint32"}],"name":"setDistributionPercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_newLpPercent","type":"uint32"}],"name":"setLpPercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newDevAddress","type":"address"}],"name":"setNewDevAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newGenesisAddress","type":"address"}],"name":"setNewGenesisAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"todaysX28","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBFXAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalVestingAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalX28Deposited","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userCycleClaimedBFX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userCycleClaimedVesting","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userCycleSBP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vestingClaimPercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"vestingCycleDistribution","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vestingPoolAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"x28BfxPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

608060408190526008805473da7d64289ff01e4ee816cc914c75c471a4e39ad06001600160a01b0319918216179091556009805473fbd4cc5a61d38b95eb6fb9530657c57c5cb27bce9216919091179055600f805461032063ffffffff199091161790556103e860108190556011819055601255611b586013556014805460ff191690556a295be96e64066972000000601555601680546001600160601b0319166808000004e200000000179055601980546001600160401b0319166507d000000190179055611388601a5561afd9388190039081908339810160408190526100e79161033a565b3360405180604001604052806007815260200166426f6e4669726560c81b815250604051806040016040528060038152602001620848cb60eb1b81525081600390816101339190610428565b5060046101408282610428565b50506001600555506001600160a01b03811661017657604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b61017f816102ce565b50818160405161018e90610320565b63ffffffff90921682526001600160a01b03166020820152604001604051809103906000f0801580156101c5573d6000803e3d6000fd5b50600a80546001600160a01b0319166001600160a01b039290921691909117905560405181906101f49061032d565b6001600160a01b039091168152602001604051809103906000f080158015610220573d6000803e3d6000fd5b50600b80546001600160a01b0319166001600160a01b03928316179055600a5460405163095ea7b360e01b8152911660048201526000196024820152735c47902c8c80779cb99235e42c354e53f38c3b0d9063095ea7b3906044016020604051808303816000875af115801561029a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102be91906104e6565b505063ffffffff16600e5561050f565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61588580614cc883390190565b610a8c8061a54d83390190565b6000806040838503121561034d57600080fd5b825163ffffffff8116811461036157600080fd5b60208401519092506001600160a01b038116811461037e57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806103b357607f821691505b6020821081036103d357634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561042357806000526020600020601f840160051c810160208510156104005750805b601f840160051c820191505b81811015610420576000815560010161040c565b50505b505050565b81516001600160401b0381111561044157610441610389565b6104558161044f845461039f565b846103d9565b6020601f82116001811461048957600083156104715750848201515b600019600385901b1c1916600184901b178455610420565b600084815260208120601f198516915b828110156104b95787850151825560209485019460019092019101610499565b50848210156104d75786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b6000602082840312156104f857600080fd5b8151801515811461050857600080fd5b9392505050565b6147aa8061051e6000396000f3fe6080604052600436106103d95760003560e01c80637d6b3253116101fd578063b820707611610118578063df0b3667116100ab578063f2fde38b1161007a578063f2fde38b14610c0c578063f425271214610c2c578063f64a017014610c3f578063fad1cb6b14610c5f578063feaec8f314610c8c57600080fd5b8063df0b366714610b9a578063e10f7c4f14610bb7578063e111a7ee14610bd7578063e3d3227d14610bf757600080fd5b8063cdea7737116100e7578063cdea773714610ae6578063ce7b325e14610afc578063d18f241014610b34578063dd62ed3e14610b5457600080fd5b8063b820707614610a70578063bab2f55214610a90578063c0181fa214610aa6578063c2e3219a14610ac657600080fd5b8063aa6df29911610190578063b4760d471161015f578063b4760d47146109f3578063b5d131ab14610a20578063b61c18a814610a36578063b7463d1014610a4c57600080fd5b8063aa6df29914610970578063aad5c02314610990578063ad492367146109b0578063b20af03f146109c657600080fd5b8063966fe914116101cc578063966fe9141461090357806398db42e114610919578063a7664df71461093a578063a9059cbb1461095057600080fd5b80637d6b325314610890578063853abc47146108b05780638da5cb5b146108d057806395d89b41146108ee57600080fd5b806337a293db116102f857806349666aea1161028b5780635a00661a1161025a5780635a00661a146107d85780636065fb331461080557806370a0823114610825578063715018a61461085b57806379cc67901461087057600080fd5b806349666aea1461071b57806352dca76d146107485780635679a0ed1461077e578063578b0226146107b357600080fd5b80633cbed3bb116102c75780633cbed3bb146106b257806342966c68146106c857806344c90ee0146106e857806348f2090b146106fe57600080fd5b806337a293db1461063f5780633a9693e11461065c5780633ad10ef61461067c5780633bc35b181461069c57600080fd5b80631201fdb71161037057806323b872dd1161033f57806323b872dd146105cd57806329c0c2e1146105ed578063313ce5671461060d578063335e536c1461062957600080fd5b80631201fdb71461053057806312e5682c1461054657806318160ddd146105805780631f7eb62b1461059557600080fd5b8063095ea7b3116103ac578063095ea7b3146104785780630af6e01a146104a85780630db7d820146104d6578063106cd7421461050357600080fd5b8063040a1bc7146103de57806306fdde031461040757806307ea027714610429578063080be2c114610461575b600080fd5b3480156103ea57600080fd5b506103f4601c5481565b6040519081526020015b60405180910390f35b34801561041357600080fd5b5061041c610cb9565b6040516103fe919061406e565b34801561043557600080fd5b506103f4610444366004614096565b602860209081526000928352604080842090915290825290205481565b34801561046d57600080fd5b50610476610d4b565b005b34801561048457600080fd5b50610498610493366004614096565b610d89565b60405190151581526020016103fe565b3480156104b457600080fd5b506104c86104c33660046140c2565b610da3565b6040516103fe9291906140df565b3480156104e257600080fd5b506103f46104f136600461416f565b60216020526000908152604090205481565b34801561050f57600080fd5b506103f461051e36600461416f565b601e6020526000908152604090205481565b34801561053c57600080fd5b506103f460075481565b34801561055257600080fd5b5060195461056b90640100000000900463ffffffff1681565b60405163ffffffff90911681526020016103fe565b34801561058c57600080fd5b506002546103f4565b3480156105a157600080fd5b506105b56105b0366004614096565b610ebc565b6040516001600160a01b0390911681526020016103fe565b3480156105d957600080fd5b506104986105e8366004614188565b61107d565b3480156105f957600080fd5b506104766106083660046142b2565b6110a1565b34801561061957600080fd5b50604051601281526020016103fe565b34801561063557600080fd5b506103f4600e5481565b34801561064b57600080fd5b5060165461056b9063ffffffff1681565b34801561066857600080fd5b506104766106773660046140c2565b61120e565b34801561068857600080fd5b506009546105b5906001600160a01b031681565b3480156106a857600080fd5b506103f460135481565b3480156106be57600080fd5b506103f460185481565b3480156106d457600080fd5b506104766106e336600461416f565b61129e565b3480156106f457600080fd5b506103f460125481565b34801561070a57600080fd5b5060195461056b9063ffffffff1681565b34801561072757600080fd5b506103f461073636600461416f565b60256020526000908152604090205481565b34801561075457600080fd5b506103f4610763366004614096565b60208080526000928352604080842090915290825290205481565b34801561078a57600080fd5b5061079e610799366004614096565b6112ab565b604080519283526020830191909152016103fe565b3480156107bf57600080fd5b5060165461056b90640100000000900463ffffffff1681565b3480156107e457600080fd5b506103f46107f336600461416f565b60266020526000908152604090205481565b34801561081157600080fd5b506008546105b5906001600160a01b031681565b34801561083157600080fd5b506103f46108403660046140c2565b6001600160a01b031660009081526020819052604090205490565b34801561086757600080fd5b506104766112c4565b34801561087c57600080fd5b5061047661088b366004614096565b6112d6565b34801561089c57600080fd5b506104766108ab3660046140c2565b6112ef565b3480156108bc57600080fd5b506104766108cb36600461438f565b61143d565b3480156108dc57600080fd5b506006546001600160a01b03166105b5565b3480156108fa57600080fd5b5061041c611577565b34801561090f57600080fd5b506103f4601b5481565b34801561092557600080fd5b5060195461049890600160401b900460ff1681565b34801561094657600080fd5b506103f460105481565b34801561095c57600080fd5b5061049861096b366004614096565b611586565b34801561097c57600080fd5b50600a546105b5906001600160a01b031681565b34801561099c57600080fd5b506104766109ab3660046140c2565b611594565b3480156109bc57600080fd5b506103f4601a5481565b3480156109d257600080fd5b506103f46109e136600461416f565b60226020526000908152604090205481565b3480156109ff57600080fd5b506103f4610a0e36600461416f565b60246020526000908152604090205481565b348015610a2c57600080fd5b506103f460115481565b348015610a4257600080fd5b506103f460155481565b348015610a5857600080fd5b5060165461056b90600160401b900463ffffffff1681565b348015610a7c57600080fd5b50600b546105b5906001600160a01b031681565b348015610a9c57600080fd5b506103f4600d5481565b348015610ab257600080fd5b506103f4610ac1366004614096565b611624565b348015610ad257600080fd5b50610476610ae136600461416f565b611637565b348015610af257600080fd5b506103f460175481565b348015610b0857600080fd5b506103f4610b17366004614096565b602760209081526000928352604080842090915290825290205481565b348015610b4057600080fd5b50600c546105b5906001600160a01b031681565b348015610b6057600080fd5b506103f4610b6f3660046143b5565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610ba657600080fd5b50600f5461056b9063ffffffff1681565b348015610bc357600080fd5b50610476610bd236600461416f565b611685565b348015610be357600080fd5b50610476610bf23660046143ee565b611d05565b348015610c0357600080fd5b506104766123eb565b348015610c1857600080fd5b50610476610c273660046140c2565b612481565b610476610c3a36600461447a565b6124bc565b348015610c4b57600080fd5b50610476610c5a36600461438f565b61304c565b348015610c6b57600080fd5b506103f4610c7a36600461416f565b60236020526000908152604090205481565b348015610c9857600080fd5b506103f4610ca736600461416f565b601f6020526000908152604090205481565b606060038054610cc8906144af565b80601f0160208091040260200160405190810160405280929190818152602001828054610cf4906144af565b8015610d415780601f10610d1657610100808354040283529160200191610d41565b820191906000526020600020905b815481529060010190602001808311610d2457829003601f168201915b5050505050905090565b600a546001600160a01b0316336001600160a01b031614610d7f57604051633579266f60e11b815260040160405180910390fd5b610d87613108565b565b600033610d97818585613352565b60019150505b92915050565b6001600160a01b0381166000908152601d60209081526040808320815181549384028101606090810184529281018481529294859490939192918391839083880182828015610e1b57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610dfd575b5050505050815260200160018201805480602002602001604051908101604052809291908181526020018280548015610e9d57602002820191906000526020600020906000905b82829054906101000a900462ffffff1662ffffff1681526020019060030190602082600201049283019260010382029150808411610e625790505b5050505050815250509050806000015181602001519250925050915091565b6000610ec661335f565b306000806001600160a01b0386168311610ee1578286610ee4565b85835b9092509050846b019d971e4fe8401e740000006000806001600160a01b03808716908b1614610f14578284610f17565b83835b90925090506000633b9aca00610f4884610f3985670de0b6b3a76400006144ff565b610f43919061452c565b61338a565b610f5690600160601b6144ff565b610f60919061452c565b6040516309f56ab160e11b81526001600160a01b03808a166004830152808916602483015261271060448301528216606482015290915073c36442b4a4522e871399cd717abdd847ab11fe889081906313ead562906084016020604051808303816000875af1158015610fd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffb919061454e565b600c80546001600160a01b0319166001600160a01b039290921691821790556040516332148f6760e01b815260646004820152909a508a906332148f6790602401600060405180830381600087803b15801561105657600080fd5b505af115801561106a573d6000803e3d6000fd5b5050505050505050505050505092915050565b60003361108b858285613472565b6110968585856134f0565b506001949350505050565b6008546001600160a01b031633148015906110c757506009546001600160a01b03163314155b80156110de57506006546001600160a01b03163314155b156110fc57604051639a7006a560e01b815260040160405180910390fd5b826001600160a01b03163b60000361112757604051630e800b5f60e01b815260040160405180910390fd5b805161113490600161456b565b8251146111965760405162461bcd60e51b815260206004820152602560248201527f496e76616c696420737761702070617468206f7220666565207469657273206c6044820152640cadccee8d60db1b60648201526084015b60405180910390fd5b60408051808201825283815260208082018490526001600160a01b0386166000908152601d82529290922081518051929391926111d69284920190613f01565b5060208281015180516111ef9260018501920190613f66565b50506040516000805160206147558339815191529150600090a1505050565b6008546001600160a01b0316336001600160a01b03161461124257604051639a7006a560e01b815260040160405180910390fd5b6001600160a01b03811661126957604051630e800b5f60e01b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b03831617905560405160008051602061475583398151915290600090a150565b6112a8338261354f565b50565b6000806112b88484613585565b915091505b9250929050565b6112cc613681565b610d8760006136ae565b6112e1823383613472565b6112eb828261354f565b5050565b6001600160a01b03811661131657604051630e800b5f60e01b815260040160405180910390fd5b806001600160a01b03163b60000361134157604051630e800b5f60e01b815260040160405180910390fd5b6008546001600160a01b0316331480159061136757506009546001600160a01b03163314155b1561138557604051639a7006a560e01b815260040160405180910390fd5b600a80546001600160a01b0319166001600160a01b03831690811790915560405163095ea7b360e01b815260048101919091526000196024820152735c47902c8c80779cb99235e42c354e53f38c3b0d9063095ea7b3906044016020604051808303816000875af11580156113fe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611422919061457e565b5060405160008051602061475583398151915290600090a150565b6008546001600160a01b0316331480159061146357506009546001600160a01b03163314155b1561148157604051639a7006a560e01b815260040160405180910390fd5b600f805463ffffffff191663ffffffff8316179055600d5461016f1061150257600f5461032063ffffffff90911611156114fd5760405162461bcd60e51b815260206004820181905260248201527f4d6178696d756d20382070657263656e7420746f204c5020616c6c6f7765642e604482015260640161118d565b61155d565b600f54606463ffffffff909116111561155d5760405162461bcd60e51b815260206004820181905260248201527f4d6178696d756d20312070657263656e7420746f204c5020616c6c6f7765642e604482015260640161118d565b60405160008051602061475583398151915290600090a150565b606060048054610cc8906144af565b600033610d978185856134f0565b6009546001600160a01b0316336001600160a01b0316146115c857604051639a7006a560e01b815260040160405180910390fd5b6001600160a01b0381166115ef57604051630e800b5f60e01b815260040160405180910390fd5b600980546001600160a01b0319166001600160a01b03831617905560405160008051602061475583398151915290600090a150565b60006116308383613700565b9392505050565b600a546001600160a01b0316336001600160a01b03161461166b57604051633579266f60e11b815260040160405180910390fd5b806018600082825461167d919061456b565b909155505050565b61168d613793565b611695613108565b600d5481036116b757604051632583f32d60e21b815260040160405180910390fd5b33600090815260208080526040808320848452909152812054908190036116f157604051630f6f17ed60e11b815260040160405180910390fd5b60006116fd3384613700565b90508060000361172057604051630f6f17ed60e11b815260040160405180910390fd5b60008061172d3386613585565b91509150600080600087600d5461174491906145a0565b90506000600982101561197657600061175e8360096145a0565b60008b8152601f602052604090205460648281038b028190049a830204965090915061178b908a9061456b565b60008b8152601e60205260409020541480156117a75750600087115b15611855576117be670de0b6b3a7640000886144ff565b60008b815260266020526040812080549091906117dc9084906145a0565b90915550506101708a1080156117f55750610167600d54115b1561183057866018600082825461180c919061456b565b9250508190555086601c600082825461182591906145a0565b9091555061191a9050565b6008611844670de0b6b3a7640000896144ff565b61184e919061452c565b915061191a565b6002611869670de0b6b3a7640000896144ff565b611873919061452c565b60008b815260266020526040812080549091906118919084906145a0565b90915550506101708a1080156118aa5750610167600d54115b156118ed576118ba60028861452c565b601860008282546118cb919061456b565b909155506118dc905060028861452c565b601c600082825461182591906145a0565b60086002611903670de0b6b3a76400008a6144ff565b61190d919061452c565b611917919061452c565b91505b60008a8152602460205260408120805487929061193890849061456b565b9250508190555084601b6000828254611951919061456b565b9250508190555084601c600082825461196a919061456b565b90915550611aca915050565b612710601a548761198791906144ff565b611991919061452c565b60008a8152601f60205260409020549093506119ae90899061456b565b60008a8152601e60205260409020541480156119ca5750600086115b15611a94576119e1670de0b6b3a7640000876144ff565b60008a815260266020526040812080549091906119ff9084906145a0565b909155505061017089108015611a185750610167600d54115b15611a6457611a2783876145a0565b60186000828254611a38919061456b565b90915550611a48905083876145a0565b601c6000828254611a5991906145a0565b90915550611aca9050565b6008670de0b6b3a7640000611a7985896145a0565b611a8391906144ff565b611a8d919061452c565b9050611aca565b611aa6670de0b6b3a7640000846144ff565b60008a81526026602052604081208054909190611ac49084906145a0565b90915550505b8415611b7f57611ae2670de0b6b3a7640000866144ff565b60008a81526026602052604081208054909190611b009084906145a0565b909155505061017089108015611b195750610167600d54115b15611b54578460186000828254611b30919061456b565b9250508190555084601c6000828254611b4991906145a0565b90915550611b7f9050565b6008611b68670de0b6b3a7640000876144ff565b611b72919061452c565b611b7c908261456b565b90505b60015b60088111611bd257816026600083600d54611b9d919061456b565b81526020019081526020016000206000828254611bba919061456b565b90915550819050611bca816145b3565b915050611b82565b506000898152601f6020526040812080548a9290611bf190849061456b565b90915550506000898152602160205260408120805460019290611c159084906145a0565b9091555050336000908152602080805260408083208c84528252808320839055602390915281208054899290611c4c90849061456b565b90915550503360008181526027602090815260408083208d845282528083208b9055928252602881528282208c8352905220839055611c8b848861456b565b60176000828254611c9c91906145a0565b90915550611cb690503033611cb1868b61456b565b6137bd565b337fd38d33d967f3a2e0946d29dabb8fc33918579eab49f2f2ab458ccb69f134a0c9611ce2858a61456b565b60405190815260200160405180910390a250505050505050506112a86001600555565b611d0d613793565b600080611d18613108565b60005b8351811015612392576000848281518110611d3857611d386145cc565b60200260200101519050600d548103611d6457604051632583f32d60e21b815260040160405180910390fd5b3360009081526020808052604080832084845290915281205490819003611d9e57604051630f6f17ed60e11b815260040160405180910390fd5b6000611daa3384613700565b905080600003611dcd57604051630f6f17ed60e11b815260040160405180910390fd5b600080611dda3386613585565b91509150600080600087600d54611df191906145a0565b905060006009821015612023576000611e0b8360096145a0565b60008b8152601f602052604090205460648281038b028190049a8302049650909150611e38908a9061456b565b60008b8152601e6020526040902054148015611e545750600087115b15611f0257611e6b670de0b6b3a7640000886144ff565b60008b81526026602052604081208054909190611e899084906145a0565b90915550506101708a108015611ea25750610167600d54115b15611edd578660186000828254611eb9919061456b565b9250508190555086601c6000828254611ed291906145a0565b90915550611fc79050565b6008611ef1670de0b6b3a7640000896144ff565b611efb919061452c565b9150611fc7565b6002611f16670de0b6b3a7640000896144ff565b611f20919061452c565b60008b81526026602052604081208054909190611f3e9084906145a0565b90915550506101708a108015611f575750610167600d54115b15611f9a57611f6760028861452c565b60186000828254611f78919061456b565b90915550611f89905060028861452c565b601c6000828254611ed291906145a0565b60086002611fb0670de0b6b3a76400008a6144ff565b611fba919061452c565b611fc4919061452c565b91505b60008a81526024602052604081208054879290611fe590849061456b565b9250508190555084601b6000828254611ffe919061456b565b9250508190555084601c6000828254612017919061456b565b9091555061218d915050565b612710601a548761203491906144ff565b61203e919061452c565b925082601c600082825461205291906145a0565b90915550506000898152601f602052604090205461207190899061456b565b60008a8152601e602052604090205414801561208d5750600086115b15612157576120a4670de0b6b3a7640000876144ff565b60008a815260266020526040812080549091906120c29084906145a0565b9091555050610170891080156120db5750610167600d54115b15612127576120ea83876145a0565b601860008282546120fb919061456b565b9091555061210b905083876145a0565b601c600082825461211c91906145a0565b9091555061218d9050565b6008670de0b6b3a764000061213c85896145a0565b61214691906144ff565b612150919061452c565b905061218d565b612169670de0b6b3a7640000846144ff565b60008a815260266020526040812080549091906121879084906145a0565b90915550505b8415612242576121a5670de0b6b3a7640000866144ff565b60008a815260266020526040812080549091906121c39084906145a0565b9091555050610170891080156121dc5750610167600d54115b156122175784601860008282546121f3919061456b565b9250508190555084601c600082825461220c91906145a0565b909155506122429050565b600861222b670de0b6b3a7640000876144ff565b612235919061452c565b61223f908261456b565b90505b60015b6008811161229557816026600083600d54612260919061456b565b8152602001908152602001600020600082825461227d919061456b565b9091555081905061228d816145b3565b915050612245565b506000898152601f6020526040812080548a92906122b490849061456b565b909155505060008981526021602052604081208054600192906122d89084906145a0565b9091555050336000908152602080805260408083208c8452825280832083905560239091528120805489929061230f90849061456b565b90915550503360008181526027602090815260408083208d845282528083208b9055928252602881528282208c835290522083905561234e848861456b565b6017600082825461235f91906145a0565b9091555061236f9050878d61456b565b9b5061237b838c61456b565b9a505060019098019750611d1b9650505050505050565b506123a23033611cb1848661456b565b337fd38d33d967f3a2e0946d29dabb8fc33918579eab49f2f2ab458ccb69f134a0c96123ce838561456b565b60405190815260200160405180910390a250506112a86001600555565b600a546001600160a01b0316336001600160a01b03161461241f57604051633579266f60e11b815260040160405180910390fd5b600c54600160a01b900460ff161561244a57604051639a7006a560e01b815260040160405180910390fd5b600a5461246c906001600160a01b03166b019d971e4fe8401e740000006138bd565b600c805460ff60a01b1916600160a01b179055565b612489613681565b6001600160a01b0381166124b357604051631e4fbdf760e01b81526000600482015260240161118d565b6112a8816136ae565b6124c4613793565b816000036124e5576040516307dba09d60e01b815260040160405180910390fd5b600e5442101561250857604051632d9618cd60e01b815260040160405180910390fd5b6001600160a01b03831661252f57604051630e800b5f60e01b815260040160405180910390fd5b6001600160a01b03831673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214801561257a5734831461257557604051636e065c6760e11b815260040160405180910390fd5b612599565b341561259957604051634440903560e11b815260040160405180910390fd5b80156126085773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156125ee57600080fd5b505af1158015612602573d6000803e3d6000fd5b50505050505b612610613108565b735c47902c8c80779cb99235e42c354e53f38c3b0d600080735c47902c8c80779cb99235e42c354e53f38c3b0c196001600160a01b038816016126745761266d735c47902c8c80779cb99235e42c354e53f38c3b0d3330896138f3565b5084612c43565b73f19308f923582a6f7c465e5ce7a9dc1bec6665b0196001600160a01b03881601612759576126b973f19308f923582a6f7c465e5ce7a9dc1bec6665b13330896138f3565b6126ec73f19308f923582a6f7c465e5ce7a9dc1bec6665b1735c47902c8c80779cb99235e42c354e53f38c3b0d886139fd565b6040516302c190dd60e61b815260048101879052735c47902c8c80779cb99235e42c354e53f38c3b0d9063b064374090602401600060405180830381600087803b15801561273957600080fd5b505af115801561274d573d6000803e3d6000fd5b50505050859050612c43565b6001600160a01b0387166000908152601d602090815260408083208151815460609481028201850184529281018381529093919284928491908401828280156127cb57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116127ad575b505050505081526020016001820180548060200260200160405190810160405280929190818152602001828054801561284d57602002820191906000526020600020906000905b82829054906101000a900462ffffff1662ffffff16815260200190600301906020826002010492830192600103820291508084116128125790505b505050505081525050905080600001515160000361287d5760405162c288c960e81b815260040160405180910390fd5b8461288e5761288e8833308a6138f3565b6128ad8873e592427a0aece92de3edee1f18e0157c05861564896139fd565b805151600203612a0457600060405180610100016040528083600001516000815181106128dc576128dc6145cc565b60200260200101516001600160a01b031681526020018360000151600181518110612909576129096145cc565b60200260200101516001600160a01b031681526020018360200151600081518110612936576129366145cc565b602002602001015162ffffff168152602001306001600160a01b0316815260200142815260200189815260200188815260200160006001600160a01b0316815250905073e592427a0aece92de3edee1f18e0157c058615646001600160a01b031663414bf389826040518263ffffffff1660e01b81526004016129b991906145e2565b6020604051808303816000875af11580156129d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fc919061465f565b935050612b85565b60008160000151600081518110612a1d57612a1d6145cc565b6020026020010151604051602001612a4d919060609190911b6bffffffffffffffffffffffff1916815260140190565b60408051601f19818403018152919052905060015b825151811015612ae05760208301518290612a7e6001846145a0565b81518110612a8e57612a8e6145cc565b602002602001015184600001518381518110612aac57612aac6145cc565b6020026020010151604051602001612ac693929190614678565b60408051601f198184030181529190529150600101612a62565b506040805160a0810182528281523060208201524281830152606081018a905260808101899052905163c04b8d5960e01b815273e592427a0aece92de3edee1f18e0157c058615649063c04b8d5990612b3d9084906004016146c4565b6020604051808303816000875af1158015612b5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b80919061465f565b945050505b82600003612ba657604051633495f12160e01b815260040160405180910390fd5b612bd973f19308f923582a6f7c465e5ce7a9dc1bec6665b1735c47902c8c80779cb99235e42c354e53f38c3b0d856139fd565b6040516302c190dd60e61b815260048101849052735c47902c8c80779cb99235e42c354e53f38c3b0d9063b064374090602401600060405180830381600087803b158015612c2657600080fd5b505af1158015612c3a573d6000803e3d6000fd5b50505050829150505b8060076000828254612c55919061456b565b9091555050600d5460009081526025602052604081208054839290612c7b90849061456b565b909155506000905062989680612c93836101716144ff565b612c9d919061452c565b905080600003612cc0576040516307dba09d60e01b815260040160405180910390fd5b612ccd3382600d54613af6565b600f5460009061271090612ce79063ffffffff16856144ff565b612cf1919061452c565b90506000612710612d04610190866144ff565b612d0e919061452c565b90506000612710612d21610190876144ff565b612d2b919061452c565b600b54909150612d5a90735c47902c8c80779cb99235e42c354e53f38c3b0d906001600160a01b0316856137bd565b600854612d8690735c47902c8c80779cb99235e42c354e53f38c3b0d906001600160a01b0316836137bd565b600954612db290735c47902c8c80779cb99235e42c354e53f38c3b0d906001600160a01b0316846137bd565b600a546040516370a0823160e01b81523060048201526001600160a01b0391821691630b79d60791908a16906370a0823190602401602060405180830381865afa158015612e04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e28919061465f565b6040518263ffffffff1660e01b8152600401612e4691815260200190565b600060405180830381600087803b158015612e6057600080fd5b505af1158015612e74573d6000803e3d6000fd5b50505050600a60009054906101000a90046001600160a01b03166001600160a01b031663d94439236040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ecb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eef919061457e565b158015612f755750600a546040516370a0823160e01b81526001600160a01b0391821660048201526ba18f07d736b90be550000000918916906370a0823190602401602060405180830381865afa158015612f4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f72919061465f565b10155b15612fee57600a546001600160a01b031663eaceee56612f9642603c61456b565b6040516001600160e01b031960e084901b16815263ffffffff919091166004820152602401600060405180830381600087803b158015612fd557600080fd5b505af1158015612fe9573d6000803e3d6000fd5b505050505b600d5460408051878152602081018790529081019190915233907f1d783d3c516a359115c8e877c897ef08d1251ca575516656d613e50e19079f049060600160405180910390a250505050505050506130476001600555565b505050565b6008546001600160a01b0316331480159061307257506009546001600160a01b03163314155b1561309057604051639a7006a560e01b815260040160405180910390fd5b6019805463ffffffff191663ffffffff83169081179091556064118015906130c457506019546103e863ffffffff90911611155b61155d5760405162461bcd60e51b815260206004820152601560248201527418903a37901898103832b931b2b73a1037b7363c9760591b604482015260640161118d565b60145460ff16151560000361313157613123306015546138bd565b6014805460ff191660011790555b62015180600e54613142919061456b565b4210610d8757601554600d5460009081526022602052604081208290556017805490919061317190849061456b565b9091555050601b54158015906131c95750601f60006001600d5461319591906145a0565b815260200190815260200160002054601e60006001600d546131b791906145a0565b81526020019081526020016000205414155b1561321f57670de0b6b3a7640000601b546131e491906144ff565b602660006001600d546131f791906145a0565b81526020019081526020016000206000828254613214919061456b565b90915550506000601b555b62015180600e54613230919061456b565b600e55600d5460070361324e576016805463ffffffff191660011790555b600d5461016f0361329f57600f805463ffffffff1916606417905561064060108190556011819055601255611450601355601980546801000013880000000068ffffffffff00000000199091161790555b601954600160401b900460ff166132f8576016546064906132c69063ffffffff168261471c565b63ffffffff166015546132d991906144ff565b6132e3919061452c565b60158190556132f39030906138bd565b61333b565b601954601854612710916133149163ffffffff909116906144ff565b61331e919061452c565b6015819055601880546000906133359084906145a0565b90915550505b600d805490600061334b836145b3565b9190505550565b6130478383836001613c58565b600a546001600160a01b03163314610d8757604051633579266f60e11b815260040160405180910390fd5b60008160000361339c57506000919050565b600060016133a984613d2d565b901c6001901b905060018184816133c2576133c2614516565b048201901c905060018184816133da576133da614516565b048201901c905060018184816133f2576133f2614516565b048201901c9050600181848161340a5761340a614516565b048201901c9050600181848161342257613422614516565b048201901c9050600181848161343a5761343a614516565b048201901c9050600181848161345257613452614516565b048201901c90506116308182858161346c5761346c614516565b04613dc1565b6001600160a01b0383811660009081526001602090815260408083209386168352929052205460001981146134ea57818110156134db57604051637dc7a0d960e11b81526001600160a01b0384166004820152602481018290526044810183905260640161118d565b6134ea84848484036000613c58565b50505050565b6001600160a01b03831661351a57604051634b637e8f60e11b81526000600482015260240161118d565b6001600160a01b0382166135445760405163ec442f0560e01b81526000600482015260240161118d565b613047838383613dd7565b6001600160a01b03821661357957604051634b637e8f60e11b81526000600482015260240161118d565b6112eb82600083613dd7565b6001600160a01b038216600090815260208080526040808320848452825280832054601f835281842054601e90935290832054839283916135c691906145a0565b6000868152602660205260409020549091508115806135e3575080155b806135ec575082155b1561360057600080945094505050506112bd565b600061360c8888613700565b9050600061361b8260066144ff565b90506000670de0b6b3a76400008561363388876144ff565b61363d919061452c565b613647919061452c565b90508181116136565780613658565b815b9750818111613668576000613672565b61367282826145a0565b96505050505050509250929050565b6006546001600160a01b03163314610d875760405163118cdaa760e01b815233600482015260240161118d565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600090815260208080526040808320848452825280832054601e909252822054600d548390850361373e575060155461374f565b506000848152602260205260409020545b81158061375a575080155b80613763575082155b156137745760009350505050610d9d565b8161377f84836144ff565b613789919061452c565b9695505050505050565b6002600554036137b657604051633ee5aeb560e01b815260040160405180910390fd5b6002600555565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916138199190614738565b6000604051808303816000865af19150503d8060008114613856576040519150601f19603f3d011682016040523d82523d6000602084013e61385b565b606091505b5091509150818015613885575080511580613885575080806020019051810190613885919061457e565b6138b65760405162461bcd60e51b815260206004820152600260248201526114d560f21b604482015260640161118d565b5050505050565b6001600160a01b0382166138e75760405163ec442f0560e01b81526000600482015260240161118d565b6112eb60008383613dd7565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291516000928392908816916139579190614738565b6000604051808303816000865af19150503d8060008114613994576040519150601f19603f3d011682016040523d82523d6000602084013e613999565b606091505b50915091508180156139c35750805115806139c35750808060200190518101906139c3919061457e565b6139f55760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640161118d565b505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151600092839290871691613a599190614738565b6000604051808303816000865af19150503d8060008114613a96576040519150601f19603f3d011682016040523d82523d6000602084013e613a9b565b606091505b5091509150818015613ac5575080511580613ac5575080806020019051810190613ac5919061457e565b6138b65760405162461bcd60e51b8152602060048201526002602482015261534160f01b604482015260640161118d565b60005b601654600160401b900463ffffffff168110156134ea5760165460009061271090613b33908490640100000000900463ffffffff166144ff565b613b3f906127106145a0565b613b4990866144ff565b613b53919061452c565b6001600160a01b038616600090815260208052604081209192509081613b79858761456b565b81526020019081526020016000205490508160206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008587613bbe919061456b565b81526020019081526020016000206000828254613bdb919061456b565b90915550829050601e6000613bf0868861456b565b81526020019081526020016000206000828254613c0d919061456b565b90915550506000819003613c4e57600160216000613c2b868861456b565b81526020019081526020016000206000828254613c48919061456b565b90915550505b5050600101613af9565b6001600160a01b038416613c825760405163e602df0560e01b81526000600482015260240161118d565b6001600160a01b038316613cac57604051634a1406b160e11b81526000600482015260240161118d565b6001600160a01b03808516600090815260016020908152604080832093871683529290522082905580156134ea57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051613d1f91815260200190565b60405180910390a350505050565b600080608083901c15613d4257608092831c92015b604083901c15613d5457604092831c92015b602083901c15613d6657602092831c92015b601083901c15613d7857601092831c92015b600883901c15613d8a57600892831c92015b600483901c15613d9c57600492831c92015b600283901c15613dae57600292831c92015b600183901c15610d9d5760010192915050565b6000818310613dd05781611630565b5090919050565b6001600160a01b038316613e02578060026000828254613df7919061456b565b90915550613e749050565b6001600160a01b03831660009081526020819052604090205481811015613e555760405163391434e360e21b81526001600160a01b0385166004820152602481018290526044810183905260640161118d565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b038216613e9057600280548290039055613eaf565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051613ef491815260200190565b60405180910390a3505050565b828054828255906000526020600020908101928215613f56579160200282015b82811115613f5657825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613f21565b50613f62929150614009565b5090565b82805482825590600052602060002090600901600a90048101928215613f565791602002820160005b83821115613fd157835183826101000a81548162ffffff021916908362ffffff1602179055509260200192600301602081600201049283019260010302613f8f565b80156140005782816101000a81549062ffffff0219169055600301602081600201049283019260010302613fd1565b5050613f629291505b5b80821115613f62576000815560010161400a565b60005b83811015614039578181015183820152602001614021565b50506000910152565b6000815180845261405a81602086016020860161401e565b601f01601f19169290920160200192915050565b6020815260006116306020830184614042565b6001600160a01b03811681146112a857600080fd5b600080604083850312156140a957600080fd5b82356140b481614081565b946020939093013593505050565b6000602082840312156140d457600080fd5b813561163081614081565b6040808252835190820181905260009060208501906060840190835b818110156141225783516001600160a01b03168352602093840193909201916001016140fb565b50508381036020808601919091528551808352918101925085019060005b8181101561416357825162ffffff16845260209384019390920191600101614140565b50919695505050505050565b60006020828403121561418157600080fd5b5035919050565b60008060006060848603121561419d57600080fd5b83356141a881614081565b925060208401356141b881614081565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715614208576142086141c9565b604052919050565b600067ffffffffffffffff82111561422a5761422a6141c9565b5060051b60200190565b600082601f83011261424557600080fd5b813561425861425382614210565b6141df565b8082825260208201915060208360051b86010192508583111561427a57600080fd5b602085015b838110156142a857803562ffffff8116811461429a57600080fd5b83526020928301920161427f565b5095945050505050565b6000806000606084860312156142c757600080fd5b83356142d281614081565b9250602084013567ffffffffffffffff8111156142ee57600080fd5b8401601f810186136142ff57600080fd5b803561430d61425382614210565b8082825260208201915060208360051b85010192508883111561432f57600080fd5b6020840193505b8284101561435a57833561434981614081565b825260209384019390910190614336565b9450505050604084013567ffffffffffffffff81111561437957600080fd5b61438586828701614234565b9150509250925092565b6000602082840312156143a157600080fd5b813563ffffffff8116811461163057600080fd5b600080604083850312156143c857600080fd5b82356143d381614081565b915060208301356143e381614081565b809150509250929050565b60006020828403121561440057600080fd5b813567ffffffffffffffff81111561441757600080fd5b8201601f8101841361442857600080fd5b803561443661425382614210565b8082825260208201915060208360051b85010192508683111561445857600080fd5b6020840193505b8284101561378957833582526020938401939091019061445f565b60008060006060848603121561448f57600080fd5b833561449a81614081565b95602085013595506040909401359392505050565b600181811c908216806144c357607f821691505b6020821081036144e357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610d9d57610d9d6144e9565b634e487b7160e01b600052601260045260246000fd5b60008261454957634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561456057600080fd5b815161163081614081565b80820180821115610d9d57610d9d6144e9565b60006020828403121561459057600080fd5b8151801515811461163057600080fd5b81810381811115610d9d57610d9d6144e9565b6000600182016145c5576145c56144e9565b5060010190565b634e487b7160e01b600052603260045260246000fd5b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff169083015260608084015191821690830152610100820190506080830151608083015260a083015160a083015260c083015160c083015260e083015161465860e08401826001600160a01b03169052565b5092915050565b60006020828403121561467157600080fd5b5051919050565b6000845161468a81846020890161401e565b60e89490941b6001600160e81b0319169190930190815260609190911b6bffffffffffffffffffffffff1916600382015260170192915050565b602081526000825160a060208401526146e060c0840182614042565b905060018060a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b63ffffffff8281168282160390811115610d9d57610d9d6144e9565b6000825161474a81846020870161401e565b919091019291505056fe3e1799d428897e6f54bdb61036ad40e2aa67a45b0181c60fe2f15a9d33a084d6a2646970667358221220cbcb521fe98915c3f4e5fbbcec03abf2a187883f1ceccbc88f094c48e379ffb464736f6c634300081a003360c060408190526a52b7d2dcc80cd2e4000000600355600780546001600160401b031916646400000064179055600d805463ffffffff167d01f40000009600000320000001f40000012c000000c80000009600000000179055600e80546001600160601b031916691388000009c4000005dc1790556010805464ffffffffff1916640a0a0a320a179055610320601155615885388190039081908339810160408190526100ab91610184565b6001600055806001600160a01b0381166100df57604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b6100e881610116565b505063ffffffff1660a0819052336080526005805464ffffffff0019166101009092029190911790556101d3565b600280546001600160a01b031916905561012f81610132565b50565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806040838503121561019757600080fd5b825163ffffffff811681146101ab57600080fd5b60208401519092506001600160a01b03811681146101c857600080fd5b809150509250929050565b60805160a05161558a6102fb600039600081816106fa015281816131ee0152818161327001526132d80152600081816106c00152818161080a015281816108e601528181610a6001528181610bea01528181610f4c01528181610fea0152818161147e0152818161151c0152818161189b01528181611ae401528181611b6a01528181611c0801528181611ec501528181611f6101528181612091015281816121190152818161218901528181612f7a01528181613412015281816134a50152818161356601528181613587015281816135c20152818161363b015281816136bd01528181613759015281816137e4015281816138b70152818161394401528181613a1001528181613a9b01528181613c2c01528181613cb70152613f1d015261558a6000f3fe608060405234801561001057600080fd5b506004361061030c5760003560e01c806389efbc021161019d578063c4542004116100e9578063eaceee56116100a2578063f38d00f01161007c578063f38d00f0146106f5578063f943f7481461071c578063fd115daf1461072c578063fee24d431461074357600080fd5b8063eaceee56146106a8578063ecb79b53146106bb578063f2fde38b146106e257600080fd5b8063c454200414610649578063c9f8be7114610660578063ca84e93414610668578063d882871514610671578063d94439231461067a578063e30c39781461069757600080fd5b80639f3d28a711610156578063ad1b63f411610130578063ad1b63f4146105bc578063bcc508cd14610610578063be68472614610623578063c1b309ec1461063657600080fd5b80639f3d28a714610589578063a803a8311461059c578063aa73e437146105af57600080fd5b806389efbc021461050c5780638da5cb5b1461051f578063917f343e1461053057806395d86fc2146105475780639be909811461055e5780639d403e471461057257600080fd5b806340f6ac311161025c5780636df8f1bc1161021557806371672f51116101ef57806371672f51146104d8578063782ee170146104eb57806379ba5097146104fb5780637a86e6981461050357600080fd5b80636df8f1bc146104a95780636fbaaa1e146104c0578063715018a6146104d057600080fd5b806340f6ac311461043f578063453df76a1461045c57806362be2065146104645780636831455c1461046d57806369087c9914610484578063696f9c811461049657600080fd5b80630e619456116102c95780631cf25aee116102a35780631cf25aee146104005780631d6ff0611461041757806331d9834d1461042e5780633875f4221461043657600080fd5b80630e619456146103955780631a932a2c146103ba5780631bea83fe146103cd57600080fd5b8063088e54a614610311578063090f8ad41461032d5780630b6b2b2c146103575780630b79d607146103605780630c2b2a28146103755780630d18480e1461038c575b600080fd5b61031a600b5481565b6040519081526020015b60405180910390f35b60055461034290610100900463ffffffff1681565b60405163ffffffff9091168152602001610324565b61031a60085481565b61037361036e366004614886565b610757565b005b600e5461034290600160201b900463ffffffff1681565b61031a60035481565b6010546103a89062010000900460ff1681565b60405160ff9091168152602001610324565b61031a6103c8366004614886565b610805565b6103e873c36442b4a4522e871399cd717abdd847ab11fe8881565b6040516001600160a01b039091168152602001610324565b600d5461034290600160401b900463ffffffff1681565b600d5461034290600160e01b900463ffffffff1681565b601154610342565b61031a600a5481565b610447610915565b60408051928352602083019190915201610324565b6103e8610a5c565b61031a60095481565b60075461034290600160201b900463ffffffff1681565b6010546103a890610100900460ff1681565b6103736104a436600461489f565b610ae5565b600d5461034290600160a01b900463ffffffff1681565b6007546103429063ffffffff1681565b610373610f36565b6103736104e63660046148de565b610f4a565b600d546103429063ffffffff1681565b610373611438565b61031a60065481565b61037361051a3660046149c0565b61147c565b6001546001600160a01b03166103e8565b600d5461034290600160201b900463ffffffff1681565b600d5461034290600160c01b900463ffffffff1681565b6010546103a8906301000000900460ff1681565b600e5461034290600160401b900463ffffffff1681565b610373610597366004614a31565b611753565b6103736105aa366004614a4e565b611b68565b6010546103a89060ff1681565b6105f06105ca366004614a31565b600c602052600090815260409020546001600160801b0380821691600160801b90041682565b604080516001600160801b03938416815292909116602083015201610324565b61031a61061e366004614886565b611d09565b61031a610631366004614886565b611d97565b61031a610644366004614886565b611e1f565b600d5461034290600160601b900463ffffffff1681565b610373611ead565b61031a600f5481565b61031a60115481565b6005546106879060ff1681565b6040519015158152602001610324565b6002546001600160a01b03166103e8565b6103736106b6366004614a31565b611fc8565b6103e87f000000000000000000000000000000000000000000000000000000000000000081565b6103736106f0366004614a80565b612469565b6103427f000000000000000000000000000000000000000000000000000000000000000081565b600e546103429063ffffffff1681565b600d5461034290600160801b900463ffffffff1681565b6010546103a890600160201b900460ff1681565b806000036107785760405163b4fa3fb360e01b815260040160405180910390fd5b6107926000805160206155358339815191523330846124da565b6040516370a0823160e01b8152306004820152600080516020615535833981519152906370a0823190602401602060405180830381865afa1580156107db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ff9190614a9d565b600f5550565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d18f24106040518163ffffffff1660e01b8152600401602060405180830381865afa158015610866573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088a9190614ab6565b9050610384600061089a836125dc565b90508163ffffffff168163ffffffff1610156108b4578091505b60006108c0848461279f565b50905060006108ce826129e3565b905061090a81886000805160206155358339815191527f0000000000000000000000000000000000000000000000000000000000000000612d05565b979650505050505050565b604080518082018252600480546001600160f81b038082168452600160f81b90910460ff161515602080850191909152845160808101865284519092168252309082019081526001600160801b0382860181815260608401828152965163fc6f786560e01b815284519581019590955291516001600160a01b031660248501529051811660448401529351909316606482015260009283929173c36442b4a4522e871399cd717abdd847ab11fe889063fc6f78659060840160408051808303816000875af11580156109eb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0f9190614ad3565b60208401519195509350600090610a27578385610a2a565b84845b509050610a4d600080516020615535833981519152610a47610a5c565b83612ddd565b610a55611ead565b5050509091565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b82070766040518163ffffffff1660e01b8152600401602060405180830381865afa158015610abc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae09190614ab6565b905090565b60055460ff16610b0857604051631864d7ab60e21b815260040160405180910390fd5b610b10610a5c565b6001600160a01b0316336001600160a01b031614610b4157604051631eb49d6d60e11b815260040160405180910390fd5b6040516370a0823160e01b8152306004820152600090600080516020615535833981519152906370a0823190602401602060405180830381865afa158015610b8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb19190614a9d565b9050610bcd6000805160206155358339815191523330866124da565b6000610be3610bdd600286614b23565b84612ed6565b9050610c247f000000000000000000000000000000000000000000000000000000000000000073c36442b4a4522e871399cd717abdd847ab11fe88836130ad565b610c5b60008051602061553583398151915273c36442b4a4522e871399cd717abdd847ab11fe88610c56600288614b23565b6130ad565b6040805160c081019091526004546001600160f81b0381168252600091906020820190600160f81b900460ff16610c925783610c9d565b610c9d600288614b23565b8152600454602090910190600160f81b900460ff16610cc657610cc1600288614b23565b610cc8565b835b8152600454602090910190600160f81b900460ff16610d17576010546064908590610cfb90610100900460ff1683614b37565b60ff16610d089190614b50565b610d129190614b23565b610d51565b6064610d24600289614b23565b601054610d3a90610100900460ff166064614b37565b60ff16610d479190614b50565b610d519190614b23565b8152600454602090910190600160f81b900460ff16610da9576064610d77600289614b23565b601054610d8d90610100900460ff166064614b37565b60ff16610d9a9190614b50565b610da49190614b23565b610dda565b6010546064908590610dc390610100900460ff1683614b37565b60ff16610dd09190614b50565b610dda9190614b23565b815260209081018690526040805163219f5d1760e01b8152835160048201529183015160248301528201516044820152606082015160648201526080820151608482015260a082015160a482015290915073c36442b4a4522e871399cd717abdd847ab11fe889063219f5d179060c4016060604051808303816000875af1158015610e69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8d9190614b7e565b50506040516370a0823160e01b8152306004820152600091508490600080516020615535833981519152906370a0823190602401602060405180830381865afa158015610ede573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f029190614a9d565b610f0c9190614bb3565b90508015610f2e57610f2e600080516020615535833981519152610a47610a5c565b505050505050565b610f3e6131a6565b610f4860006131d3565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636065fb336040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fa8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fcc9190614ab6565b6001600160a01b0316336001600160a01b03161415801561108057507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ad10ef66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611046573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061106a9190614ab6565b6001600160a01b0316336001600160a01b031614155b1561109e57604051631eb49d6d60e11b815260040160405180910390fd5b8a60118190555089600d60046101000a81548163ffffffff021916908363ffffffff16021790555088600d60086101000a81548163ffffffff021916908363ffffffff16021790555087600d600c6101000a81548163ffffffff021916908363ffffffff16021790555086600d60106101000a81548163ffffffff021916908363ffffffff16021790555085600d60146101000a81548163ffffffff021916908363ffffffff16021790555084600d60186101000a81548163ffffffff021916908363ffffffff16021790555083600d601c6101000a81548163ffffffff021916908363ffffffff16021790555082600e60006101000a81548163ffffffff021916908363ffffffff16021790555081600e60046101000a81548163ffffffff021916908363ffffffff16021790555080600e60086101000a81548163ffffffff021916908363ffffffff1602179055506000601154621b77406112029190614b23565b905060646011541015801561121b57506103e860115411155b6112925760405162461bcd60e51b815260206004820152603860248201527f4441494c595f414c4c4f434154494f4e206d757374206265206265747765656e60448201527f20313030202831252920616e642031303030202831302529000000000000000060648201526084015b60405180910390fd5b600d546064600160201b90910463ffffffff16108015906112c25750600d54600160201b900463ffffffff168110155b80156112df5750600d546064600160401b90910463ffffffff1610155b80156112fa5750600d54600160401b900463ffffffff168110155b80156113175750600d546064600160601b90910463ffffffff1610155b80156113325750600d54600160601b900463ffffffff168110155b801561134f5750600d546064600160801b90910463ffffffff1610155b801561136a5750600d54600160801b900463ffffffff168110155b80156113875750600d546064600160a01b90910463ffffffff1610155b80156113a25750600d54600160a01b900463ffffffff168110155b6113f95760405162461bcd60e51b815260206004820152602260248201527f4d756c7469706c696572206578636565647320616c6c6f776564206d6178696d604482015261756d60f01b6064820152608401611289565b6114016131ec565b6040517f3e1799d428897e6f54bdb61036ad40e2aa67a45b0181c60fe2f15a9d33a084d690600090a1505050505050505050505050565b60025433906001600160a01b031681146114705760405163118cdaa760e01b81526001600160a01b0382166004820152602401611289565b611479816131d3565b50565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636065fb336040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fe9190614ab6565b6001600160a01b0316336001600160a01b0316141580156115b257507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ad10ef66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611578573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159c9190614ab6565b6001600160a01b0316336001600160a01b031614155b156115d057604051631eb49d6d60e11b815260040160405180910390fd5b60648560ff1611806115e5575060028560ff16105b156116035760405163b4fa3fb360e01b815260040160405180910390fd5b60648460ff161180611618575060028460ff16105b156116365760405163b4fa3fb360e01b815260040160405180910390fd5b60648360ff16118061164b575060028360ff16105b156116695760405163b4fa3fb360e01b815260040160405180910390fd5b60648260ff16118061167e575060028260ff16105b1561169c5760405163b4fa3fb360e01b815260040160405180910390fd5b60648160ff1611806116b1575060028160ff16105b156116cf5760405163b4fa3fb360e01b815260040160405180910390fd5b6010805460ff87811661ffff1990921691909117610100878316021763ffff00001916620100008683160263ff0000001916176301000000858316021764ff000000001916600160201b918416919091021790556040517f3e1799d428897e6f54bdb61036ad40e2aa67a45b0181c60fe2f15a9d33a084d690600090a15050505050565b61175b6133e3565b6117636131ec565b60055460ff1661178657604051631864d7ab60e21b815260040160405180910390fd5b600d5463ffffffff166000908152600c602052604090208054600160801b90046001600160801b0316156117cd576040516331bbcb2160e11b815260040160405180910390fd5b60075481546000916064916117f19163ffffffff16906001600160801b0316614bc6565b6117fb9190614bef565b6001600160801b031690506000612710611816609684614b50565b6118209190614b23565b9050600061182e8284614bb3565b905061183a818661340d565b9050600080600080600061184e868b613630565b945094509450945094506118716000805160206155358339815191523389612ddd565b611879611ead565b6003546000805160206155358339815191526001600160a01b03166370a082317f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b82070766040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191b9190614ab6565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561195f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119839190614a9d565b106119f257611990610a5c565b604051636e0c63d960e01b815263ffffffff8c1660048201526001600160a01b039190911690636e0c63d990602401600060405180830381600087803b1580156119d957600080fd5b505af11580156119ed573d6000803e3d6000fd5b505050505b82600b6000828254611a049190614c1d565b9250508190555084600a6000828254611a1d9190614c1d565b925050819055508160096000828254611a369190614c1d565b90915550506040516370a0823160e01b8152306004820152600080516020615535833981519152906370a0823190602401602060405180830381865afa158015611a84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa89190614a9d565b600f556040513390859083907f1b3ed074dce570943c9d4e66776a060e8ac73af4f6b002482b09e561d90f038c90600090a4611ae2613db4565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663080be2c16040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611b3d57600080fd5b505af1158015611b51573d6000803e3d6000fd5b505050505050505050505050506114796001600055565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636065fb336040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bc6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bea9190614ab6565b6001600160a01b0316336001600160a01b031614158015611c9e57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ad10ef66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c889190614ab6565b6001600160a01b0316336001600160a01b031614155b15611cbc57604051631eb49d6d60e11b815260040160405180910390fd5b60ff81166003819055600211156114795760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081d1a1c995cda1bdb19607a1b6044820152606401611289565b600073763c4978b8536d5eb18fb846b91a2d3ae3e31b0c61038482611d2d836125dc565b90508163ffffffff168163ffffffff161015611d47578091505b6000611d53848461279f565b5090506000611d61826129e3565b905061090a81887396a5399d07896f757bd4c6ef56461f58db951862734687f007da484efe20d7a17e5b1d105cdbfca0eb612d05565b60007399f60479da6a49d55eba34893958cdaacc710ee961038482611dbb836125dc565b90508163ffffffff168163ffffffff161015611dd5578091505b6000611de1848461279f565b5090506000611def826129e3565b905061090a818860008051602061553583398151915273f19308f923582a6f7c465e5ce7a9dc1bec6665b1612d05565b60007325215d9ba4403b3da77ce50606b54577a71b789561038482611e43836125dc565b90508163ffffffff168163ffffffff161015611e5d578091505b6000611e69848461279f565b5090506000611e77826129e3565b905061090a818873f19308f923582a6f7c465e5ce7a9dc1bec6665b17396a5399d07896f757bd4c6ef56461f58db951862612d05565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015611f14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f389190614a9d565b905080600854611f489190614c1d565b600855604051630852cd8d60e31b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c6890602401600060405180830381600087803b158015611fad57600080fd5b505af1158015611fc1573d6000803e3d6000fd5b5050505050565b60055460ff1615611fec57604051630fd02b6d60e41b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526ba18f07d736b90be55000000090600080516020615535833981519152906370a0823190602401602060405180830381865afa158015612043573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120679190614a9d565b10156120865760405163c4160ecf60e01b815260040160405180910390fd5b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146120cf576040516380a0123d60e01b815260040160405180910390fd5b6005805460ff19166001179055604051631f7eb62b60e01b815260008051602061553583398151915260048201526ba18f07d736b90be55000000060248201526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690631f7eb62b906044016020604051808303816000875af1158015612162573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121869190614ab6565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e3d3227d6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156121e257600080fd5b505af11580156121f6573d6000803e3d6000fd5b505050506000806000806000806122256ba18f07d736b90be5500000006b019d971e4fe8401e74000000613f05565b9550955095509550955095506122508273c36442b4a4522e871399cd717abdd847ab11fe88886130ad565b61226f8173c36442b4a4522e871399cd717abdd847ab11fe88876130ad565b6000604051806101600160405280846001600160a01b03168152602001836001600160a01b0316815260200161271062ffffff16815260200160c880620d89e7196122ba9190614c30565b6122c49190614c6a565b60020b815260200160c8806122dc620d89e719614c8a565b6122e69190614c30565b6122f09190614c6a565b60020b8152602001888152602001878152602001868152602001858152602001306001600160a01b031681526020018963ffffffff168152509050600073c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166388316456836040518263ffffffff1660e01b815260040161236d9190614cac565b6080604051808303816000875af115801561238c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b09190614d70565b50506040805180820182526001600160f81b0384168082526000805160206155358339815191526001600160a01b038a1681146020909301839052600160f81b90920217600490815591516370a0823160e01b815230928101929092529293506370a082319150602401602060405180830381865afa158015612437573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061245b9190614a9d565b600f55505050505050505050565b6124716131a6565b600280546001600160a01b0383166001600160a01b031990911681179091556124a26001546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b179052915160009283929088169161253e9190614dd0565b6000604051808303816000865af19150503d806000811461257b576040519150601f19603f3d011682016040523d82523d6000602084013e612580565b606091505b50915091508180156125aa5750805115806125aa5750808060200190518101906125aa9190614dfc565b610f2e5760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b6044820152606401611289565b6000806000836001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa15801561261f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126439190614e29565b50505093509350505060008161ffff16116126855760405162461bcd60e51b81526020600482015260026024820152614e4960f01b6044820152606401611289565b6000806001600160a01b03861663252c09d7846126a3876001614ebd565b6126ad9190614ed7565b6040516001600160e01b031960e084901b16815261ffff9091166004820152602401608060405180830381865afa1580156126ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127109190614f0d565b9350505091508061278b5760405163252c09d760e01b8152600060048201526001600160a01b0387169063252c09d790602401608060405180830381865afa158015612760573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127849190614f0d565b5091935050505b6127958242614f65565b9695505050505050565b6000808263ffffffff166000036127dd5760405162461bcd60e51b8152602060048201526002602482015261042560f41b6044820152606401611289565b604080516002808252606082018352600092602083019080368337019050509050838160008151811061281257612812614f97565b602002602001019063ffffffff16908163ffffffff168152505060008160018151811061284157612841614f97565b602002602001019063ffffffff16908163ffffffff1681525050600080866001600160a01b031663883bdbfd846040518263ffffffff1660e01b815260040161288a9190614fad565b600060405180830381865afa1580156128a7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526128cf91908101906150c1565b915091506000826000815181106128e8576128e8614f97565b60200260200101518360018151811061290357612903614f97565b6020026020010151612915919061518c565b905060008260008151811061292c5761292c614f97565b60200260200101518360018151811061294757612947614f97565b602002602001015161295991906151b9565b905063ffffffff881661296c81846151d8565b975060008360060b12801561298c5750612986818461520d565b60060b15155b1561299f578761299b8161522f565b9850505b63ffffffff8916640100000000600160c01b03602084901b166129c96001600160a01b0383615252565b6129d39190615283565b9750505050505050509250929050565b60008060008360020b126129fa578260020b612a02565b8260020b6000035b9050620d89e8811115612a28576040516315e4079d60e11b815260040160405180910390fd5b600081600116600003612a3f57600160801b612a51565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615612a85576ffff97272373d413259a46990580e213a0260801c5b6004821615612aa4576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615612ac3576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615612ae2576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615612b01576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615612b20576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615612b3f576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615612b5f576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615612b7f576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615612b9f576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615612bbf576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615612bdf576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615612bff576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615612c1f576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615612c3f576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615612c60576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615612c80576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615612c9f576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615612cbc576b048a170391f7dc42444e8fa20260801c5b60008460020b1315612cdd578060001981612cd957612cd9614af7565b0490505b600160201b810615612cf0576001612cf3565b60005b60ff16602082901c0192505050919050565b60006001600160801b036001600160a01b03861611612d79576000612d336001600160a01b03871680614b50565b9050826001600160a01b0316846001600160a01b031610612d6257612d5d600160c01b8683613fa2565b612d71565b612d718186600160c01b613fa2565b915050612dd5565b6000612d936001600160a01b03871680600160401b613fa2565b9050826001600160a01b0316846001600160a01b031610612dc257612dbd600160801b8683613fa2565b612dd1565b612dd18186600160801b613fa2565b9150505b949350505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1790529151600092839290871691612e399190614dd0565b6000604051808303816000865af19150503d8060008114612e76576040519150601f19603f3d011682016040523d82523d6000602084013e612e7b565b606091505b5091509150818015612ea5575080511580612ea5575080806020019051810190612ea59190614dfc565b611fc15760405162461bcd60e51b815260206004820152600260248201526114d560f21b6044820152606401611289565b60405163095ea7b360e01b815273e592427a0aece92de3edee1f18e0157c058615646004820152602481018390526000906000805160206155358339815191529063095ea7b3906044016020604051808303816000875af1158015612f3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f639190614dfc565b5060006000805160206155358339815191526127107f0000000000000000000000000000000000000000000000000000000000000000604051602001612fab939291906152b2565b60405160208183030381529060405290506000612fc785610805565b601054909150600090606490612fe590610100900460ff1682614b37565b612ff29060ff1684614b50565b612ffc9190614b23565b6040805160a0810182528581523060208201528082018890526060810189905260808101839052905163c04b8d5960e01b81529192509073e592427a0aece92de3edee1f18e0157c058615649063c04b8d599061305d9084906004016152ed565b6020604051808303816000875af115801561307c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130a09190614a9d565b9450505050505b92915050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b17905291516000928392908716916131099190614dd0565b6000604051808303816000865af19150503d8060008114613146576040519150601f19603f3d011682016040523d82523d6000602084013e61314b565b606091505b50915091508180156131755750805115806131755750808060200190518101906131759190614dfc565b611fc15760405162461bcd60e51b8152602060048201526002602482015261534160f01b6044820152606401611289565b6001546001600160a01b03163314610f485760405163118cdaa760e01b8152336004820152602401611289565b600280546001600160a01b031916905561147981614067565b7f000000000000000000000000000000000000000000000000000000000000000063ffffffff1642101561323357604051631864d7ab60e21b815260040160405180910390fd5b600554600090610100900463ffffffff16156132665760055461326190610100900463ffffffff1642614bb3565b613296565b61329663ffffffff7f00000000000000000000000000000000000000000000000000000000000000001642614bb3565b90506000806000806000600560019054906101000a900463ffffffff1663ffffffff16600003613302576132cf8663ffffffff166140b9565b919650945092507f000000000000000000000000000000000000000000000000000000000000000091506001905061334b565b6101e063ffffffff8716111561334b576133218663ffffffff166140b9565b6005549297509095509350610100900463ffffffff16915060019050826133478161535c565b9350505b8015610f2e576133616101e061ffff851661537d565b61336b908361539c565b6005805463ffffffff9283166101000264ffffffff00199091161790556040805180820182526001600160801b03808816825260006020808401828152958b16808352600c909152939020915193518116600160801b02931692909217909155600d805463ffffffff19169091179055505050505050565b60026000540361340657604051633ee5aeb560e01b815260040160405180910390fd5b6002600055565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166312e5682c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561346e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061349291906153b8565b63ffffffff1611156136295760006127107f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166312e5682c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613501573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061352591906153b8565b6135359063ffffffff1686614b50565b61353f9190614b23565b905061354b8185614bb3565b9350600061355f828563ffffffff16612ed6565b90506135ac7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000083612ddd565b60405163617190cd60e11b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063c2e3219a90602401600060405180830381600087803b15801561360e57600080fd5b505af1158015613622573d6000803e3d6000fd5b5050505050505b5090919050565b6000806000806000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633bc35b186040518163ffffffff1660e01b8152600401602060405180830381865afa158015613697573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136bb9190614a9d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a7664df76040518163ffffffff1660e01b8152600401602060405180830381865afa158015613719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061373d9190614a9d565b6137479190614c1d565b61375390612710614bb3565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a7664df76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156137b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137d99190614a9d565b11156138b3576127107f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a7664df76040518163ffffffff1660e01b8152600401602060405180830381865afa158015613840573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138649190614a9d565b61386e908a614b50565b6138789190614b23565b95506138848689614bb3565b97506138b360008051602061553583398151915273a3144e7fcced79ce6ff6e14ae9d8df229417a7a288612ddd565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633bc35b186040518163ffffffff1660e01b8152600401602060405180830381865afa158015613913573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139379190614a9d565b11156139fa5760006127107f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633bc35b186040518163ffffffff1660e01b8152600401602060405180830381865afa1580156139a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139c49190614a9d565b6139ce908b614b50565b6139d89190614b23565b90506139e4818a614bb3565b98506139f6818963ffffffff16612ed6565b9550505b613a0a888863ffffffff16614160565b915060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166344c90ee06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613a6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a909190614a9d565b1115613c28576000817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166344c90ee06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613af7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b1b9190614a9d565b613b259085614b50565b613b2f9190614b23565b9050613b41818963ffffffff1661425e565b60405163095ea7b360e01b815273e9a53c43a0b58706e67341c4055de861e29ee943600482018190526024820183905291965063095ea7b3906044016020604051808303816000875af1158015613b9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bc09190614dfc565b50604051630852cd8d60e31b81526004810186905273e9a53c43a0b58706e67341c4055de861e29ee943906342966c6890602401600060405180830381600087803b158015613c0e57600080fd5b505af1158015613c22573d6000803e3d6000fd5b50505050505b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b5d131ab6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613c88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cac9190614a9d565b1115613da9576000817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b5d131ab6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d379190614a9d565b613d419085614b50565b613d4b9190614b23565b90506000613d5f828a63ffffffff166145e8565b9050613d71818a63ffffffff166146f9565b9450613da6734687f007da484efe20d7a17e5b1d105cdbfca0eb7314f485d6480d76fe31e9332ed4b87e704601b55287612ddd565b50505b509295509295909350565b6000613dc7670de0b6b3a7640000610805565b9050600654600003613dd95760068190555b60006006548211613deb576000613e0e565b600654613df88184614bb3565b613e0490612710614b50565b613e0e9190614b23565b600e54909150606490600160401b900463ffffffff168210613e405750600d54600160a01b900463ffffffff16613ee5565b600e54600160201b900463ffffffff168210613e6c5750600d54600160801b900463ffffffff16613ee5565b600e5463ffffffff168210613e915750600d54600160601b900463ffffffff16613ee5565b600d54600160e01b900463ffffffff168210613ebd5750600d54600160401b900463ffffffff16613ee5565b600d54600160c01b900463ffffffff168210613ee55750600d54600160201b900463ffffffff165b6007805463ffffffff191663ffffffff9290921691909117905550600655565b600080808080806000805160206155358339815191527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0381168210613f53578082613f56565b81815b90945092506001600160a01b0380851690831614613f7557888a613f78565b89895b9098509650613f868861480a565b613f8f8861480a565b989b979a50985092959194509092505050565b6000838302816000198587098281108382030391505080600003613fd957838281613fcf57613fcf614af7565b0492505050614060565b808411613ff95760405163227bc15360e01b815260040160405180910390fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008060006140c784614825565b600d549091506140e29061ffff83169063ffffffff1661539c565b6140ed90600161539c565b92506000612710601154600f546141049190614b50565b61410e9190614b23565b9050600061411d60b483614b23565b9050600061412f61ffff851683614bc6565b905061413b81836153d5565b9450600f54856001600160801b0316111561415657600f5494505b5050509193909250565b60405163095ea7b360e01b815273e592427a0aece92de3edee1f18e0157c058615646004820152602481018390526000906000805160206155358339815191529063095ea7b3906044016020604051808303816000875af11580156141c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141ed9190614dfc565b50600060008051602061553583398151915261271073f19308f923582a6f7c465e5ce7a9dc1bec6665b1604051602001614229939291906152b2565b6040516020818303038152906040529050600061424585611d97565b601054909150600090606490612fe59060ff1682614b37565b60405163095ea7b360e01b8152737a250d5630b4cf539739df2c5dacb4c659f2488d60048201526024810183905260009073f19308f923582a6f7c465e5ce7a9dc1bec6665b19063095ea7b3906044016020604051808303816000875af11580156142cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142f19190614dfc565b5060408051600280825260608201835260009260208301908036833701905050905073f19308f923582a6f7c465e5ce7a9dc1bec6665b18160008151811061433b5761433b614f97565b60200260200101906001600160a01b031690816001600160a01b03168152505073e9a53c43a0b58706e67341c4055de861e29ee9438160018151811061438357614383614f97565b6001600160a01b039092166020928302919091019091015260405163d06ca61f60e01b8152600090737a250d5630b4cf539739df2c5dacb4c659f2488d9063d06ca61f906143d79088908690600401615439565b600060405180830381865afa1580156143f4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261441c9190810190615452565b60105490915060009060649061443b9062010000900460ff1682614b37565b60ff168360018151811061445157614451614f97565b60200260200101516144639190614b50565b61446d9190614b23565b6040516370a0823160e01b815230600482015290915060009073e9a53c43a0b58706e67341c4055de861e29ee943906370a0823190602401602060405180830381865afa1580156144c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144e69190614a9d565b604051635c11d79560e01b8152909150737a250d5630b4cf539739df2c5dacb4c659f2488d90635c11d79590614528908a908690899030908d906004016154de565b600060405180830381600087803b15801561454257600080fd5b505af1158015614556573d6000803e3d6000fd5b50506040516370a0823160e01b81523060048201526000925083915073e9a53c43a0b58706e67341c4055de861e29ee943906370a0823190602401602060405180830381865afa1580156145ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145d29190614a9d565b6145dc9190614bb3565b98975050505050505050565b60405163095ea7b360e01b815273e592427a0aece92de3edee1f18e0157c0586156460048201526024810183905260009073f19308f923582a6f7c465e5ce7a9dc1bec6665b19063095ea7b3906044016020604051808303816000875af1158015614657573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061467b9190614dfc565b50600073f19308f923582a6f7c465e5ce7a9dc1bec6665b16127107396a5399d07896f757bd4c6ef56461f58db9518626040516020016146bd939291906152b2565b604051602081830303815290604052905060006146d985611e1f565b601054909150600090606490612fe5906301000000900460ff1682614b37565b60405163095ea7b360e01b815273e592427a0aece92de3edee1f18e0157c058615646004820152602481018390526000907396a5399d07896f757bd4c6ef56461f58db9518629063095ea7b3906044016020604051808303816000875af1158015614768573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061478c9190614dfc565b5060007396a5399d07896f757bd4c6ef56461f58db951862612710734687f007da484efe20d7a17e5b1d105cdbfca0eb6040516020016147ce939291906152b2565b604051602081830303815290604052905060006147ea85611d09565b601054909150600090606490612fe590600160201b900460ff1682614b37565b600061271061481b83612328614b50565b6130a79190614b23565b600554600090610100900463ffffffff16810361485f576101e0821115614857576148526101e083614b23565b6130a7565b600092915050565b6101e08211156148575760016148776101e084614b23565b614852919061551a565b919050565b60006020828403121561489857600080fd5b5035919050565b600080604083850312156148b257600080fd5b50508035926020909101359150565b63ffffffff8116811461147957600080fd5b8035614881816148c1565b60008060008060008060008060008060006101608c8e03121561490057600080fd5b8b359a5060208c0135614912816148c1565b995060408c0135614922816148c1565b985060608c0135614932816148c1565b975060808c0135614942816148c1565b965060a08c0135614952816148c1565b955060c08c0135614962816148c1565b945060e08c0135614972816148c1565b93506149816101008d016148d3565b92506149906101208d016148d3565b915061499f6101408d016148d3565b90509295989b509295989b9093969950565b60ff8116811461147957600080fd5b600080600080600060a086880312156149d857600080fd5b85356149e3816149b1565b945060208601356149f3816149b1565b93506040860135614a03816149b1565b92506060860135614a13816149b1565b91506080860135614a23816149b1565b809150509295509295909350565b600060208284031215614a4357600080fd5b8135614060816148c1565b600060208284031215614a6057600080fd5b8135614060816149b1565b6001600160a01b038116811461147957600080fd5b600060208284031215614a9257600080fd5b813561406081614a6b565b600060208284031215614aaf57600080fd5b5051919050565b600060208284031215614ac857600080fd5b815161406081614a6b565b60008060408385031215614ae657600080fd5b505080516020909101519092909150565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082614b3257614b32614af7565b500490565b60ff82811682821603908111156130a7576130a7614b0d565b80820281158282048414176130a7576130a7614b0d565b80516001600160801b038116811461488157600080fd5b600080600060608486031215614b9357600080fd5b614b9c84614b67565b602085015160409095015190969495509392505050565b818103818111156130a7576130a7614b0d565b6001600160801b038181168382160290811690818114614be857614be8614b0d565b5092915050565b60006001600160801b03831680614c0857614c08614af7565b806001600160801b0384160491505092915050565b808201808211156130a7576130a7614b0d565b60008160020b8360020b80614c4757614c47614af7565b627fffff19821460001982141615614c6157614c61614b0d565b90059392505050565b60008260020b8260020b028060020b9150808214614be857614be8614b0d565b60008160020b627fffff198103614ca357614ca3614b0d565b60000392915050565b81516001600160a01b0316815261016081016020830151614cd860208401826001600160a01b03169052565b506040830151614cef604084018262ffffff169052565b506060830151614d04606084018260020b9052565b506080830151614d19608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100830151610100830152610120830151614d606101208401826001600160a01b03169052565b5061014092830151919092015290565b60008060008060808587031215614d8657600080fd5b84519350614d9660208601614b67565b6040860151606090960151949790965092505050565b60005b83811015614dc7578181015183820152602001614daf565b50506000910152565b60008251614de2818460208701614dac565b9190910192915050565b8051801515811461488157600080fd5b600060208284031215614e0e57600080fd5b61406082614dec565b805161ffff8116811461488157600080fd5b600080600080600080600060e0888a031215614e4457600080fd5b8751614e4f81614a6b565b8097505060208801518060020b8114614e6757600080fd5b9550614e7560408901614e17565b9450614e8360608901614e17565b9350614e9160808901614e17565b925060a0880151614ea1816149b1565b9150614eaf60c08901614dec565b905092959891949750929550565b61ffff81811683821601908111156130a7576130a7614b0d565b600061ffff831680614eeb57614eeb614af7565b8061ffff84160691505092915050565b8051600681900b811461488157600080fd5b60008060008060808587031215614f2357600080fd5b8451614f2e816148c1565b9350614f3c60208601614efb565b92506040850151614f4c81614a6b565b9150614f5a60608601614dec565b905092959194509250565b63ffffffff82811682821603908111156130a7576130a7614b0d565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b602080825282518282018190526000918401906040840190835b81811015614feb57835163ffffffff16835260209384019390920191600101614fc7565b509095945050505050565b604051601f8201601f1916810167ffffffffffffffff8111828210171561501f5761501f614f81565b604052919050565b600067ffffffffffffffff82111561504157615041614f81565b5060051b60200190565b600082601f83011261505c57600080fd5b815161506f61506a82615027565b614ff6565b8082825260208201915060208360051b86010192508583111561509157600080fd5b602085015b838110156150b75780516150a981614a6b565b835260209283019201615096565b5095945050505050565b600080604083850312156150d457600080fd5b825167ffffffffffffffff8111156150eb57600080fd5b8301601f810185136150fc57600080fd5b805161510a61506a82615027565b8082825260208201915060208360051b85010192508783111561512c57600080fd5b6020840193505b828410156151555761514484614efb565b825260209384019390910190615133565b80955050505050602083015167ffffffffffffffff81111561517657600080fd5b6151828582860161504b565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff821317156130a7576130a7614b0d565b6001600160a01b0382811682821603908111156130a7576130a7614b0d565b60008160060b8360060b806151ef576151ef614af7565b667fffffffffffff19821460001982141615614c6157614c61614b0d565b60008260060b8061522057615220614af7565b808360060b0791505092915050565b60008160020b627fffff19810361524857615248614b0d565b6000190192915050565b6001600160c01b0381811683821681810290921691818304811482151761527b5761527b614b0d565b505092915050565b60006001600160c01b0383168061529c5761529c614af7565b6001600160c01b03929092169190910492915050565b606093841b6bffffffffffffffffffffffff19908116825260e89390931b6001600160e81b0319166014820152921b166017820152602b0190565b602081526000825160a0602084015280518060c08501526153158160e0860160208501614dac565b60018060a01b0360208601511660408501526040850151606085015260608501516080850152608085015160a085015260e0601f19601f8301168501019250505092915050565b600061ffff821661ffff810361537457615374614b0d565b60010192915050565b63ffffffff8181168382160290811690818114614be857614be8614b0d565b63ffffffff81811683821601908111156130a7576130a7614b0d565b6000602082840312156153ca57600080fd5b8151614060816148c1565b6001600160801b0381811683821601908111156130a7576130a7614b0d565b600081518084526020840193506020830160005b8281101561542f5781516001600160a01b0316865260209586019590910190600101615408565b5093949350505050565b828152604060208201526000612dd560408301846153f4565b60006020828403121561546457600080fd5b815167ffffffffffffffff81111561547b57600080fd5b8201601f8101841361548c57600080fd5b805161549a61506a82615027565b8082825260208201915060208360051b8501019250868311156154bc57600080fd5b6020840193505b828410156127955783518252602093840193909101906154c3565b85815284602082015260a0604082015260006154fd60a08301866153f4565b6001600160a01b0394909416606083015250608001529392505050565b61ffff82811682821603908111156130a7576130a7614b0d56fe0000000000000000000000005c47902c8c80779cb99235e42c354e53f38c3b0da264697066735822122016add4c546bfdb8550d3f32453a3e681fb3fc389fd740b854eff6c615fef72fa64736f6c634300081a003360a0604052604051610a8c380380610a8c833981016040819052610022916100d6565b806001600160a01b03811661005157604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b61005a8161006a565b5050600160025533608052610106565b600180546001600160a01b031916905561008381610086565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100e857600080fd5b81516001600160a01b03811681146100ff57600080fd5b9392505050565b60805161095061013c6000396000818160e60152818161011d015281816102890152818161041a015261051001526109506000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100a7578063e30c3978146100d0578063ecb79b53146100e1578063f2fde38b1461010857600080fd5b80636e0c63d914610082578063715018a61461009757806379ba50971461009f575b600080fd5b610095610090366004610870565b61011b565b005b610095610711565b610095610725565b6000546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b6001546001600160a01b03166100b4565b6100b47f000000000000000000000000000000000000000000000000000000000000000081565b61009561011636600461089e565b61076e565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663aa6df2996040518163ffffffff1660e01b8152600401602060405180830381865afa158015610179573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061019d91906108c2565b6001600160a01b0316336001600160a01b0316146101ce5760405163d035b5df60e01b815260040160405180910390fd5b6040516370a0823160e01b8152306004820152735c47902c8c80779cb99235e42c354e53f38c3b0d906370a0823190602401602060405180830381865afa15801561021d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024191906108df565b60000361026157604051633bf1830560e21b815260040160405180910390fd5b6000735c47902c8c80779cb99235e42c354e53f38c3b0d6001600160a01b031663dd62ed3e307f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663aa6df2996040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102e5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061030991906108c2565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015610354573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061037891906108df565b6040516370a0823160e01b8152306004820152909150735c47902c8c80779cb99235e42c354e53f38c3b0d906370a0823190602401602060405180830381865afa1580156103ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ee91906108df565b81101561050e57735c47902c8c80779cb99235e42c354e53f38c3b0d6001600160a01b031663095ea7b37f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663aa6df2996040518163ffffffff1660e01b8152600401602060405180830381865afa158015610476573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061049a91906108c2565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260001960248201526044016020604051808303816000875af11580156104e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050c91906108f8565b505b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663aa6df2996040518163ffffffff1660e01b8152600401602060405180830381865afa15801561056c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059091906108c2565b6040516370a0823160e01b81523060048201526001600160a01b03919091169063696f9c8190735c47902c8c80779cb99235e42c354e53f38c3b0d906370a0823190602401602060405180830381865afa1580156105f2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061691906108df565b846040518363ffffffff1660e01b815260040161063d929190918252602082015260400190565b600060405180830381600087803b15801561065757600080fd5b505af115801561066b573d6000803e3d6000fd5b50506040516370a0823160e01b8152306004820152339250735c47902c8c80779cb99235e42c354e53f38c3b0d91506370a0823190602401602060405180830381865afa1580156106c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e491906108df565b6040517f1d033aa3953be7bc445e2e5866882f09b140e31112143ef2466dc8b3ea6df25290600090a35050565b6107196107df565b610723600061080c565b565b60015433906001600160a01b031681146107625760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b61076b8161080c565b50565b6107766107df565b600180546001600160a01b0383166001600160a01b031990911681179091556107a76000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b031633146107235760405163118cdaa760e01b8152336004820152602401610759565b600180546001600160a01b031916905561076b81600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561088257600080fd5b5035919050565b6001600160a01b038116811461076b57600080fd5b6000602082840312156108b057600080fd5b81356108bb81610889565b9392505050565b6000602082840312156108d457600080fd5b81516108bb81610889565b6000602082840312156108f157600080fd5b5051919050565b60006020828403121561090a57600080fd5b815180151581146108bb57600080fdfea2646970667358221220ab30f871b5fe876a0a54c0072f83f7c535e8a5543fd9dc4c1f8a5795b512af6864736f6c634300081a003300000000000000000000000000000000000000000000000000000000678e811000000000000000000000000068e49e7088b9e22b173b525409b9a265f82c0517

Deployed Bytecode

0x6080604052600436106103d95760003560e01c80637d6b3253116101fd578063b820707611610118578063df0b3667116100ab578063f2fde38b1161007a578063f2fde38b14610c0c578063f425271214610c2c578063f64a017014610c3f578063fad1cb6b14610c5f578063feaec8f314610c8c57600080fd5b8063df0b366714610b9a578063e10f7c4f14610bb7578063e111a7ee14610bd7578063e3d3227d14610bf757600080fd5b8063cdea7737116100e7578063cdea773714610ae6578063ce7b325e14610afc578063d18f241014610b34578063dd62ed3e14610b5457600080fd5b8063b820707614610a70578063bab2f55214610a90578063c0181fa214610aa6578063c2e3219a14610ac657600080fd5b8063aa6df29911610190578063b4760d471161015f578063b4760d47146109f3578063b5d131ab14610a20578063b61c18a814610a36578063b7463d1014610a4c57600080fd5b8063aa6df29914610970578063aad5c02314610990578063ad492367146109b0578063b20af03f146109c657600080fd5b8063966fe914116101cc578063966fe9141461090357806398db42e114610919578063a7664df71461093a578063a9059cbb1461095057600080fd5b80637d6b325314610890578063853abc47146108b05780638da5cb5b146108d057806395d89b41146108ee57600080fd5b806337a293db116102f857806349666aea1161028b5780635a00661a1161025a5780635a00661a146107d85780636065fb331461080557806370a0823114610825578063715018a61461085b57806379cc67901461087057600080fd5b806349666aea1461071b57806352dca76d146107485780635679a0ed1461077e578063578b0226146107b357600080fd5b80633cbed3bb116102c75780633cbed3bb146106b257806342966c68146106c857806344c90ee0146106e857806348f2090b146106fe57600080fd5b806337a293db1461063f5780633a9693e11461065c5780633ad10ef61461067c5780633bc35b181461069c57600080fd5b80631201fdb71161037057806323b872dd1161033f57806323b872dd146105cd57806329c0c2e1146105ed578063313ce5671461060d578063335e536c1461062957600080fd5b80631201fdb71461053057806312e5682c1461054657806318160ddd146105805780631f7eb62b1461059557600080fd5b8063095ea7b3116103ac578063095ea7b3146104785780630af6e01a146104a85780630db7d820146104d6578063106cd7421461050357600080fd5b8063040a1bc7146103de57806306fdde031461040757806307ea027714610429578063080be2c114610461575b600080fd5b3480156103ea57600080fd5b506103f4601c5481565b6040519081526020015b60405180910390f35b34801561041357600080fd5b5061041c610cb9565b6040516103fe919061406e565b34801561043557600080fd5b506103f4610444366004614096565b602860209081526000928352604080842090915290825290205481565b34801561046d57600080fd5b50610476610d4b565b005b34801561048457600080fd5b50610498610493366004614096565b610d89565b60405190151581526020016103fe565b3480156104b457600080fd5b506104c86104c33660046140c2565b610da3565b6040516103fe9291906140df565b3480156104e257600080fd5b506103f46104f136600461416f565b60216020526000908152604090205481565b34801561050f57600080fd5b506103f461051e36600461416f565b601e6020526000908152604090205481565b34801561053c57600080fd5b506103f460075481565b34801561055257600080fd5b5060195461056b90640100000000900463ffffffff1681565b60405163ffffffff90911681526020016103fe565b34801561058c57600080fd5b506002546103f4565b3480156105a157600080fd5b506105b56105b0366004614096565b610ebc565b6040516001600160a01b0390911681526020016103fe565b3480156105d957600080fd5b506104986105e8366004614188565b61107d565b3480156105f957600080fd5b506104766106083660046142b2565b6110a1565b34801561061957600080fd5b50604051601281526020016103fe565b34801561063557600080fd5b506103f4600e5481565b34801561064b57600080fd5b5060165461056b9063ffffffff1681565b34801561066857600080fd5b506104766106773660046140c2565b61120e565b34801561068857600080fd5b506009546105b5906001600160a01b031681565b3480156106a857600080fd5b506103f460135481565b3480156106be57600080fd5b506103f460185481565b3480156106d457600080fd5b506104766106e336600461416f565b61129e565b3480156106f457600080fd5b506103f460125481565b34801561070a57600080fd5b5060195461056b9063ffffffff1681565b34801561072757600080fd5b506103f461073636600461416f565b60256020526000908152604090205481565b34801561075457600080fd5b506103f4610763366004614096565b60208080526000928352604080842090915290825290205481565b34801561078a57600080fd5b5061079e610799366004614096565b6112ab565b604080519283526020830191909152016103fe565b3480156107bf57600080fd5b5060165461056b90640100000000900463ffffffff1681565b3480156107e457600080fd5b506103f46107f336600461416f565b60266020526000908152604090205481565b34801561081157600080fd5b506008546105b5906001600160a01b031681565b34801561083157600080fd5b506103f46108403660046140c2565b6001600160a01b031660009081526020819052604090205490565b34801561086757600080fd5b506104766112c4565b34801561087c57600080fd5b5061047661088b366004614096565b6112d6565b34801561089c57600080fd5b506104766108ab3660046140c2565b6112ef565b3480156108bc57600080fd5b506104766108cb36600461438f565b61143d565b3480156108dc57600080fd5b506006546001600160a01b03166105b5565b3480156108fa57600080fd5b5061041c611577565b34801561090f57600080fd5b506103f4601b5481565b34801561092557600080fd5b5060195461049890600160401b900460ff1681565b34801561094657600080fd5b506103f460105481565b34801561095c57600080fd5b5061049861096b366004614096565b611586565b34801561097c57600080fd5b50600a546105b5906001600160a01b031681565b34801561099c57600080fd5b506104766109ab3660046140c2565b611594565b3480156109bc57600080fd5b506103f4601a5481565b3480156109d257600080fd5b506103f46109e136600461416f565b60226020526000908152604090205481565b3480156109ff57600080fd5b506103f4610a0e36600461416f565b60246020526000908152604090205481565b348015610a2c57600080fd5b506103f460115481565b348015610a4257600080fd5b506103f460155481565b348015610a5857600080fd5b5060165461056b90600160401b900463ffffffff1681565b348015610a7c57600080fd5b50600b546105b5906001600160a01b031681565b348015610a9c57600080fd5b506103f4600d5481565b348015610ab257600080fd5b506103f4610ac1366004614096565b611624565b348015610ad257600080fd5b50610476610ae136600461416f565b611637565b348015610af257600080fd5b506103f460175481565b348015610b0857600080fd5b506103f4610b17366004614096565b602760209081526000928352604080842090915290825290205481565b348015610b4057600080fd5b50600c546105b5906001600160a01b031681565b348015610b6057600080fd5b506103f4610b6f3660046143b5565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610ba657600080fd5b50600f5461056b9063ffffffff1681565b348015610bc357600080fd5b50610476610bd236600461416f565b611685565b348015610be357600080fd5b50610476610bf23660046143ee565b611d05565b348015610c0357600080fd5b506104766123eb565b348015610c1857600080fd5b50610476610c273660046140c2565b612481565b610476610c3a36600461447a565b6124bc565b348015610c4b57600080fd5b50610476610c5a36600461438f565b61304c565b348015610c6b57600080fd5b506103f4610c7a36600461416f565b60236020526000908152604090205481565b348015610c9857600080fd5b506103f4610ca736600461416f565b601f6020526000908152604090205481565b606060038054610cc8906144af565b80601f0160208091040260200160405190810160405280929190818152602001828054610cf4906144af565b8015610d415780601f10610d1657610100808354040283529160200191610d41565b820191906000526020600020905b815481529060010190602001808311610d2457829003601f168201915b5050505050905090565b600a546001600160a01b0316336001600160a01b031614610d7f57604051633579266f60e11b815260040160405180910390fd5b610d87613108565b565b600033610d97818585613352565b60019150505b92915050565b6001600160a01b0381166000908152601d60209081526040808320815181549384028101606090810184529281018481529294859490939192918391839083880182828015610e1b57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610dfd575b5050505050815260200160018201805480602002602001604051908101604052809291908181526020018280548015610e9d57602002820191906000526020600020906000905b82829054906101000a900462ffffff1662ffffff1681526020019060030190602082600201049283019260010382029150808411610e625790505b5050505050815250509050806000015181602001519250925050915091565b6000610ec661335f565b306000806001600160a01b0386168311610ee1578286610ee4565b85835b9092509050846b019d971e4fe8401e740000006000806001600160a01b03808716908b1614610f14578284610f17565b83835b90925090506000633b9aca00610f4884610f3985670de0b6b3a76400006144ff565b610f43919061452c565b61338a565b610f5690600160601b6144ff565b610f60919061452c565b6040516309f56ab160e11b81526001600160a01b03808a166004830152808916602483015261271060448301528216606482015290915073c36442b4a4522e871399cd717abdd847ab11fe889081906313ead562906084016020604051808303816000875af1158015610fd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffb919061454e565b600c80546001600160a01b0319166001600160a01b039290921691821790556040516332148f6760e01b815260646004820152909a508a906332148f6790602401600060405180830381600087803b15801561105657600080fd5b505af115801561106a573d6000803e3d6000fd5b5050505050505050505050505092915050565b60003361108b858285613472565b6110968585856134f0565b506001949350505050565b6008546001600160a01b031633148015906110c757506009546001600160a01b03163314155b80156110de57506006546001600160a01b03163314155b156110fc57604051639a7006a560e01b815260040160405180910390fd5b826001600160a01b03163b60000361112757604051630e800b5f60e01b815260040160405180910390fd5b805161113490600161456b565b8251146111965760405162461bcd60e51b815260206004820152602560248201527f496e76616c696420737761702070617468206f7220666565207469657273206c6044820152640cadccee8d60db1b60648201526084015b60405180910390fd5b60408051808201825283815260208082018490526001600160a01b0386166000908152601d82529290922081518051929391926111d69284920190613f01565b5060208281015180516111ef9260018501920190613f66565b50506040516000805160206147558339815191529150600090a1505050565b6008546001600160a01b0316336001600160a01b03161461124257604051639a7006a560e01b815260040160405180910390fd5b6001600160a01b03811661126957604051630e800b5f60e01b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b03831617905560405160008051602061475583398151915290600090a150565b6112a8338261354f565b50565b6000806112b88484613585565b915091505b9250929050565b6112cc613681565b610d8760006136ae565b6112e1823383613472565b6112eb828261354f565b5050565b6001600160a01b03811661131657604051630e800b5f60e01b815260040160405180910390fd5b806001600160a01b03163b60000361134157604051630e800b5f60e01b815260040160405180910390fd5b6008546001600160a01b0316331480159061136757506009546001600160a01b03163314155b1561138557604051639a7006a560e01b815260040160405180910390fd5b600a80546001600160a01b0319166001600160a01b03831690811790915560405163095ea7b360e01b815260048101919091526000196024820152735c47902c8c80779cb99235e42c354e53f38c3b0d9063095ea7b3906044016020604051808303816000875af11580156113fe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611422919061457e565b5060405160008051602061475583398151915290600090a150565b6008546001600160a01b0316331480159061146357506009546001600160a01b03163314155b1561148157604051639a7006a560e01b815260040160405180910390fd5b600f805463ffffffff191663ffffffff8316179055600d5461016f1061150257600f5461032063ffffffff90911611156114fd5760405162461bcd60e51b815260206004820181905260248201527f4d6178696d756d20382070657263656e7420746f204c5020616c6c6f7765642e604482015260640161118d565b61155d565b600f54606463ffffffff909116111561155d5760405162461bcd60e51b815260206004820181905260248201527f4d6178696d756d20312070657263656e7420746f204c5020616c6c6f7765642e604482015260640161118d565b60405160008051602061475583398151915290600090a150565b606060048054610cc8906144af565b600033610d978185856134f0565b6009546001600160a01b0316336001600160a01b0316146115c857604051639a7006a560e01b815260040160405180910390fd5b6001600160a01b0381166115ef57604051630e800b5f60e01b815260040160405180910390fd5b600980546001600160a01b0319166001600160a01b03831617905560405160008051602061475583398151915290600090a150565b60006116308383613700565b9392505050565b600a546001600160a01b0316336001600160a01b03161461166b57604051633579266f60e11b815260040160405180910390fd5b806018600082825461167d919061456b565b909155505050565b61168d613793565b611695613108565b600d5481036116b757604051632583f32d60e21b815260040160405180910390fd5b33600090815260208080526040808320848452909152812054908190036116f157604051630f6f17ed60e11b815260040160405180910390fd5b60006116fd3384613700565b90508060000361172057604051630f6f17ed60e11b815260040160405180910390fd5b60008061172d3386613585565b91509150600080600087600d5461174491906145a0565b90506000600982101561197657600061175e8360096145a0565b60008b8152601f602052604090205460648281038b028190049a830204965090915061178b908a9061456b565b60008b8152601e60205260409020541480156117a75750600087115b15611855576117be670de0b6b3a7640000886144ff565b60008b815260266020526040812080549091906117dc9084906145a0565b90915550506101708a1080156117f55750610167600d54115b1561183057866018600082825461180c919061456b565b9250508190555086601c600082825461182591906145a0565b9091555061191a9050565b6008611844670de0b6b3a7640000896144ff565b61184e919061452c565b915061191a565b6002611869670de0b6b3a7640000896144ff565b611873919061452c565b60008b815260266020526040812080549091906118919084906145a0565b90915550506101708a1080156118aa5750610167600d54115b156118ed576118ba60028861452c565b601860008282546118cb919061456b565b909155506118dc905060028861452c565b601c600082825461182591906145a0565b60086002611903670de0b6b3a76400008a6144ff565b61190d919061452c565b611917919061452c565b91505b60008a8152602460205260408120805487929061193890849061456b565b9250508190555084601b6000828254611951919061456b565b9250508190555084601c600082825461196a919061456b565b90915550611aca915050565b612710601a548761198791906144ff565b611991919061452c565b60008a8152601f60205260409020549093506119ae90899061456b565b60008a8152601e60205260409020541480156119ca5750600086115b15611a94576119e1670de0b6b3a7640000876144ff565b60008a815260266020526040812080549091906119ff9084906145a0565b909155505061017089108015611a185750610167600d54115b15611a6457611a2783876145a0565b60186000828254611a38919061456b565b90915550611a48905083876145a0565b601c6000828254611a5991906145a0565b90915550611aca9050565b6008670de0b6b3a7640000611a7985896145a0565b611a8391906144ff565b611a8d919061452c565b9050611aca565b611aa6670de0b6b3a7640000846144ff565b60008a81526026602052604081208054909190611ac49084906145a0565b90915550505b8415611b7f57611ae2670de0b6b3a7640000866144ff565b60008a81526026602052604081208054909190611b009084906145a0565b909155505061017089108015611b195750610167600d54115b15611b54578460186000828254611b30919061456b565b9250508190555084601c6000828254611b4991906145a0565b90915550611b7f9050565b6008611b68670de0b6b3a7640000876144ff565b611b72919061452c565b611b7c908261456b565b90505b60015b60088111611bd257816026600083600d54611b9d919061456b565b81526020019081526020016000206000828254611bba919061456b565b90915550819050611bca816145b3565b915050611b82565b506000898152601f6020526040812080548a9290611bf190849061456b565b90915550506000898152602160205260408120805460019290611c159084906145a0565b9091555050336000908152602080805260408083208c84528252808320839055602390915281208054899290611c4c90849061456b565b90915550503360008181526027602090815260408083208d845282528083208b9055928252602881528282208c8352905220839055611c8b848861456b565b60176000828254611c9c91906145a0565b90915550611cb690503033611cb1868b61456b565b6137bd565b337fd38d33d967f3a2e0946d29dabb8fc33918579eab49f2f2ab458ccb69f134a0c9611ce2858a61456b565b60405190815260200160405180910390a250505050505050506112a86001600555565b611d0d613793565b600080611d18613108565b60005b8351811015612392576000848281518110611d3857611d386145cc565b60200260200101519050600d548103611d6457604051632583f32d60e21b815260040160405180910390fd5b3360009081526020808052604080832084845290915281205490819003611d9e57604051630f6f17ed60e11b815260040160405180910390fd5b6000611daa3384613700565b905080600003611dcd57604051630f6f17ed60e11b815260040160405180910390fd5b600080611dda3386613585565b91509150600080600087600d54611df191906145a0565b905060006009821015612023576000611e0b8360096145a0565b60008b8152601f602052604090205460648281038b028190049a8302049650909150611e38908a9061456b565b60008b8152601e6020526040902054148015611e545750600087115b15611f0257611e6b670de0b6b3a7640000886144ff565b60008b81526026602052604081208054909190611e899084906145a0565b90915550506101708a108015611ea25750610167600d54115b15611edd578660186000828254611eb9919061456b565b9250508190555086601c6000828254611ed291906145a0565b90915550611fc79050565b6008611ef1670de0b6b3a7640000896144ff565b611efb919061452c565b9150611fc7565b6002611f16670de0b6b3a7640000896144ff565b611f20919061452c565b60008b81526026602052604081208054909190611f3e9084906145a0565b90915550506101708a108015611f575750610167600d54115b15611f9a57611f6760028861452c565b60186000828254611f78919061456b565b90915550611f89905060028861452c565b601c6000828254611ed291906145a0565b60086002611fb0670de0b6b3a76400008a6144ff565b611fba919061452c565b611fc4919061452c565b91505b60008a81526024602052604081208054879290611fe590849061456b565b9250508190555084601b6000828254611ffe919061456b565b9250508190555084601c6000828254612017919061456b565b9091555061218d915050565b612710601a548761203491906144ff565b61203e919061452c565b925082601c600082825461205291906145a0565b90915550506000898152601f602052604090205461207190899061456b565b60008a8152601e602052604090205414801561208d5750600086115b15612157576120a4670de0b6b3a7640000876144ff565b60008a815260266020526040812080549091906120c29084906145a0565b9091555050610170891080156120db5750610167600d54115b15612127576120ea83876145a0565b601860008282546120fb919061456b565b9091555061210b905083876145a0565b601c600082825461211c91906145a0565b9091555061218d9050565b6008670de0b6b3a764000061213c85896145a0565b61214691906144ff565b612150919061452c565b905061218d565b612169670de0b6b3a7640000846144ff565b60008a815260266020526040812080549091906121879084906145a0565b90915550505b8415612242576121a5670de0b6b3a7640000866144ff565b60008a815260266020526040812080549091906121c39084906145a0565b9091555050610170891080156121dc5750610167600d54115b156122175784601860008282546121f3919061456b565b9250508190555084601c600082825461220c91906145a0565b909155506122429050565b600861222b670de0b6b3a7640000876144ff565b612235919061452c565b61223f908261456b565b90505b60015b6008811161229557816026600083600d54612260919061456b565b8152602001908152602001600020600082825461227d919061456b565b9091555081905061228d816145b3565b915050612245565b506000898152601f6020526040812080548a92906122b490849061456b565b909155505060008981526021602052604081208054600192906122d89084906145a0565b9091555050336000908152602080805260408083208c8452825280832083905560239091528120805489929061230f90849061456b565b90915550503360008181526027602090815260408083208d845282528083208b9055928252602881528282208c835290522083905561234e848861456b565b6017600082825461235f91906145a0565b9091555061236f9050878d61456b565b9b5061237b838c61456b565b9a505060019098019750611d1b9650505050505050565b506123a23033611cb1848661456b565b337fd38d33d967f3a2e0946d29dabb8fc33918579eab49f2f2ab458ccb69f134a0c96123ce838561456b565b60405190815260200160405180910390a250506112a86001600555565b600a546001600160a01b0316336001600160a01b03161461241f57604051633579266f60e11b815260040160405180910390fd5b600c54600160a01b900460ff161561244a57604051639a7006a560e01b815260040160405180910390fd5b600a5461246c906001600160a01b03166b019d971e4fe8401e740000006138bd565b600c805460ff60a01b1916600160a01b179055565b612489613681565b6001600160a01b0381166124b357604051631e4fbdf760e01b81526000600482015260240161118d565b6112a8816136ae565b6124c4613793565b816000036124e5576040516307dba09d60e01b815260040160405180910390fd5b600e5442101561250857604051632d9618cd60e01b815260040160405180910390fd5b6001600160a01b03831661252f57604051630e800b5f60e01b815260040160405180910390fd5b6001600160a01b03831673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214801561257a5734831461257557604051636e065c6760e11b815260040160405180910390fd5b612599565b341561259957604051634440903560e11b815260040160405180910390fd5b80156126085773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156125ee57600080fd5b505af1158015612602573d6000803e3d6000fd5b50505050505b612610613108565b735c47902c8c80779cb99235e42c354e53f38c3b0d600080735c47902c8c80779cb99235e42c354e53f38c3b0c196001600160a01b038816016126745761266d735c47902c8c80779cb99235e42c354e53f38c3b0d3330896138f3565b5084612c43565b73f19308f923582a6f7c465e5ce7a9dc1bec6665b0196001600160a01b03881601612759576126b973f19308f923582a6f7c465e5ce7a9dc1bec6665b13330896138f3565b6126ec73f19308f923582a6f7c465e5ce7a9dc1bec6665b1735c47902c8c80779cb99235e42c354e53f38c3b0d886139fd565b6040516302c190dd60e61b815260048101879052735c47902c8c80779cb99235e42c354e53f38c3b0d9063b064374090602401600060405180830381600087803b15801561273957600080fd5b505af115801561274d573d6000803e3d6000fd5b50505050859050612c43565b6001600160a01b0387166000908152601d602090815260408083208151815460609481028201850184529281018381529093919284928491908401828280156127cb57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116127ad575b505050505081526020016001820180548060200260200160405190810160405280929190818152602001828054801561284d57602002820191906000526020600020906000905b82829054906101000a900462ffffff1662ffffff16815260200190600301906020826002010492830192600103820291508084116128125790505b505050505081525050905080600001515160000361287d5760405162c288c960e81b815260040160405180910390fd5b8461288e5761288e8833308a6138f3565b6128ad8873e592427a0aece92de3edee1f18e0157c05861564896139fd565b805151600203612a0457600060405180610100016040528083600001516000815181106128dc576128dc6145cc565b60200260200101516001600160a01b031681526020018360000151600181518110612909576129096145cc565b60200260200101516001600160a01b031681526020018360200151600081518110612936576129366145cc565b602002602001015162ffffff168152602001306001600160a01b0316815260200142815260200189815260200188815260200160006001600160a01b0316815250905073e592427a0aece92de3edee1f18e0157c058615646001600160a01b031663414bf389826040518263ffffffff1660e01b81526004016129b991906145e2565b6020604051808303816000875af11580156129d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fc919061465f565b935050612b85565b60008160000151600081518110612a1d57612a1d6145cc565b6020026020010151604051602001612a4d919060609190911b6bffffffffffffffffffffffff1916815260140190565b60408051601f19818403018152919052905060015b825151811015612ae05760208301518290612a7e6001846145a0565b81518110612a8e57612a8e6145cc565b602002602001015184600001518381518110612aac57612aac6145cc565b6020026020010151604051602001612ac693929190614678565b60408051601f198184030181529190529150600101612a62565b506040805160a0810182528281523060208201524281830152606081018a905260808101899052905163c04b8d5960e01b815273e592427a0aece92de3edee1f18e0157c058615649063c04b8d5990612b3d9084906004016146c4565b6020604051808303816000875af1158015612b5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b80919061465f565b945050505b82600003612ba657604051633495f12160e01b815260040160405180910390fd5b612bd973f19308f923582a6f7c465e5ce7a9dc1bec6665b1735c47902c8c80779cb99235e42c354e53f38c3b0d856139fd565b6040516302c190dd60e61b815260048101849052735c47902c8c80779cb99235e42c354e53f38c3b0d9063b064374090602401600060405180830381600087803b158015612c2657600080fd5b505af1158015612c3a573d6000803e3d6000fd5b50505050829150505b8060076000828254612c55919061456b565b9091555050600d5460009081526025602052604081208054839290612c7b90849061456b565b909155506000905062989680612c93836101716144ff565b612c9d919061452c565b905080600003612cc0576040516307dba09d60e01b815260040160405180910390fd5b612ccd3382600d54613af6565b600f5460009061271090612ce79063ffffffff16856144ff565b612cf1919061452c565b90506000612710612d04610190866144ff565b612d0e919061452c565b90506000612710612d21610190876144ff565b612d2b919061452c565b600b54909150612d5a90735c47902c8c80779cb99235e42c354e53f38c3b0d906001600160a01b0316856137bd565b600854612d8690735c47902c8c80779cb99235e42c354e53f38c3b0d906001600160a01b0316836137bd565b600954612db290735c47902c8c80779cb99235e42c354e53f38c3b0d906001600160a01b0316846137bd565b600a546040516370a0823160e01b81523060048201526001600160a01b0391821691630b79d60791908a16906370a0823190602401602060405180830381865afa158015612e04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e28919061465f565b6040518263ffffffff1660e01b8152600401612e4691815260200190565b600060405180830381600087803b158015612e6057600080fd5b505af1158015612e74573d6000803e3d6000fd5b50505050600a60009054906101000a90046001600160a01b03166001600160a01b031663d94439236040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ecb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eef919061457e565b158015612f755750600a546040516370a0823160e01b81526001600160a01b0391821660048201526ba18f07d736b90be550000000918916906370a0823190602401602060405180830381865afa158015612f4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f72919061465f565b10155b15612fee57600a546001600160a01b031663eaceee56612f9642603c61456b565b6040516001600160e01b031960e084901b16815263ffffffff919091166004820152602401600060405180830381600087803b158015612fd557600080fd5b505af1158015612fe9573d6000803e3d6000fd5b505050505b600d5460408051878152602081018790529081019190915233907f1d783d3c516a359115c8e877c897ef08d1251ca575516656d613e50e19079f049060600160405180910390a250505050505050506130476001600555565b505050565b6008546001600160a01b0316331480159061307257506009546001600160a01b03163314155b1561309057604051639a7006a560e01b815260040160405180910390fd5b6019805463ffffffff191663ffffffff83169081179091556064118015906130c457506019546103e863ffffffff90911611155b61155d5760405162461bcd60e51b815260206004820152601560248201527418903a37901898103832b931b2b73a1037b7363c9760591b604482015260640161118d565b60145460ff16151560000361313157613123306015546138bd565b6014805460ff191660011790555b62015180600e54613142919061456b565b4210610d8757601554600d5460009081526022602052604081208290556017805490919061317190849061456b565b9091555050601b54158015906131c95750601f60006001600d5461319591906145a0565b815260200190815260200160002054601e60006001600d546131b791906145a0565b81526020019081526020016000205414155b1561321f57670de0b6b3a7640000601b546131e491906144ff565b602660006001600d546131f791906145a0565b81526020019081526020016000206000828254613214919061456b565b90915550506000601b555b62015180600e54613230919061456b565b600e55600d5460070361324e576016805463ffffffff191660011790555b600d5461016f0361329f57600f805463ffffffff1916606417905561064060108190556011819055601255611450601355601980546801000013880000000068ffffffffff00000000199091161790555b601954600160401b900460ff166132f8576016546064906132c69063ffffffff168261471c565b63ffffffff166015546132d991906144ff565b6132e3919061452c565b60158190556132f39030906138bd565b61333b565b601954601854612710916133149163ffffffff909116906144ff565b61331e919061452c565b6015819055601880546000906133359084906145a0565b90915550505b600d805490600061334b836145b3565b9190505550565b6130478383836001613c58565b600a546001600160a01b03163314610d8757604051633579266f60e11b815260040160405180910390fd5b60008160000361339c57506000919050565b600060016133a984613d2d565b901c6001901b905060018184816133c2576133c2614516565b048201901c905060018184816133da576133da614516565b048201901c905060018184816133f2576133f2614516565b048201901c9050600181848161340a5761340a614516565b048201901c9050600181848161342257613422614516565b048201901c9050600181848161343a5761343a614516565b048201901c9050600181848161345257613452614516565b048201901c90506116308182858161346c5761346c614516565b04613dc1565b6001600160a01b0383811660009081526001602090815260408083209386168352929052205460001981146134ea57818110156134db57604051637dc7a0d960e11b81526001600160a01b0384166004820152602481018290526044810183905260640161118d565b6134ea84848484036000613c58565b50505050565b6001600160a01b03831661351a57604051634b637e8f60e11b81526000600482015260240161118d565b6001600160a01b0382166135445760405163ec442f0560e01b81526000600482015260240161118d565b613047838383613dd7565b6001600160a01b03821661357957604051634b637e8f60e11b81526000600482015260240161118d565b6112eb82600083613dd7565b6001600160a01b038216600090815260208080526040808320848452825280832054601f835281842054601e90935290832054839283916135c691906145a0565b6000868152602660205260409020549091508115806135e3575080155b806135ec575082155b1561360057600080945094505050506112bd565b600061360c8888613700565b9050600061361b8260066144ff565b90506000670de0b6b3a76400008561363388876144ff565b61363d919061452c565b613647919061452c565b90508181116136565780613658565b815b9750818111613668576000613672565b61367282826145a0565b96505050505050509250929050565b6006546001600160a01b03163314610d875760405163118cdaa760e01b815233600482015260240161118d565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600090815260208080526040808320848452825280832054601e909252822054600d548390850361373e575060155461374f565b506000848152602260205260409020545b81158061375a575080155b80613763575082155b156137745760009350505050610d9d565b8161377f84836144ff565b613789919061452c565b9695505050505050565b6002600554036137b657604051633ee5aeb560e01b815260040160405180910390fd5b6002600555565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916138199190614738565b6000604051808303816000865af19150503d8060008114613856576040519150601f19603f3d011682016040523d82523d6000602084013e61385b565b606091505b5091509150818015613885575080511580613885575080806020019051810190613885919061457e565b6138b65760405162461bcd60e51b815260206004820152600260248201526114d560f21b604482015260640161118d565b5050505050565b6001600160a01b0382166138e75760405163ec442f0560e01b81526000600482015260240161118d565b6112eb60008383613dd7565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291516000928392908816916139579190614738565b6000604051808303816000865af19150503d8060008114613994576040519150601f19603f3d011682016040523d82523d6000602084013e613999565b606091505b50915091508180156139c35750805115806139c35750808060200190518101906139c3919061457e565b6139f55760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640161118d565b505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151600092839290871691613a599190614738565b6000604051808303816000865af19150503d8060008114613a96576040519150601f19603f3d011682016040523d82523d6000602084013e613a9b565b606091505b5091509150818015613ac5575080511580613ac5575080806020019051810190613ac5919061457e565b6138b65760405162461bcd60e51b8152602060048201526002602482015261534160f01b604482015260640161118d565b60005b601654600160401b900463ffffffff168110156134ea5760165460009061271090613b33908490640100000000900463ffffffff166144ff565b613b3f906127106145a0565b613b4990866144ff565b613b53919061452c565b6001600160a01b038616600090815260208052604081209192509081613b79858761456b565b81526020019081526020016000205490508160206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008587613bbe919061456b565b81526020019081526020016000206000828254613bdb919061456b565b90915550829050601e6000613bf0868861456b565b81526020019081526020016000206000828254613c0d919061456b565b90915550506000819003613c4e57600160216000613c2b868861456b565b81526020019081526020016000206000828254613c48919061456b565b90915550505b5050600101613af9565b6001600160a01b038416613c825760405163e602df0560e01b81526000600482015260240161118d565b6001600160a01b038316613cac57604051634a1406b160e11b81526000600482015260240161118d565b6001600160a01b03808516600090815260016020908152604080832093871683529290522082905580156134ea57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051613d1f91815260200190565b60405180910390a350505050565b600080608083901c15613d4257608092831c92015b604083901c15613d5457604092831c92015b602083901c15613d6657602092831c92015b601083901c15613d7857601092831c92015b600883901c15613d8a57600892831c92015b600483901c15613d9c57600492831c92015b600283901c15613dae57600292831c92015b600183901c15610d9d5760010192915050565b6000818310613dd05781611630565b5090919050565b6001600160a01b038316613e02578060026000828254613df7919061456b565b90915550613e749050565b6001600160a01b03831660009081526020819052604090205481811015613e555760405163391434e360e21b81526001600160a01b0385166004820152602481018290526044810183905260640161118d565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b038216613e9057600280548290039055613eaf565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051613ef491815260200190565b60405180910390a3505050565b828054828255906000526020600020908101928215613f56579160200282015b82811115613f5657825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613f21565b50613f62929150614009565b5090565b82805482825590600052602060002090600901600a90048101928215613f565791602002820160005b83821115613fd157835183826101000a81548162ffffff021916908362ffffff1602179055509260200192600301602081600201049283019260010302613f8f565b80156140005782816101000a81549062ffffff0219169055600301602081600201049283019260010302613fd1565b5050613f629291505b5b80821115613f62576000815560010161400a565b60005b83811015614039578181015183820152602001614021565b50506000910152565b6000815180845261405a81602086016020860161401e565b601f01601f19169290920160200192915050565b6020815260006116306020830184614042565b6001600160a01b03811681146112a857600080fd5b600080604083850312156140a957600080fd5b82356140b481614081565b946020939093013593505050565b6000602082840312156140d457600080fd5b813561163081614081565b6040808252835190820181905260009060208501906060840190835b818110156141225783516001600160a01b03168352602093840193909201916001016140fb565b50508381036020808601919091528551808352918101925085019060005b8181101561416357825162ffffff16845260209384019390920191600101614140565b50919695505050505050565b60006020828403121561418157600080fd5b5035919050565b60008060006060848603121561419d57600080fd5b83356141a881614081565b925060208401356141b881614081565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715614208576142086141c9565b604052919050565b600067ffffffffffffffff82111561422a5761422a6141c9565b5060051b60200190565b600082601f83011261424557600080fd5b813561425861425382614210565b6141df565b8082825260208201915060208360051b86010192508583111561427a57600080fd5b602085015b838110156142a857803562ffffff8116811461429a57600080fd5b83526020928301920161427f565b5095945050505050565b6000806000606084860312156142c757600080fd5b83356142d281614081565b9250602084013567ffffffffffffffff8111156142ee57600080fd5b8401601f810186136142ff57600080fd5b803561430d61425382614210565b8082825260208201915060208360051b85010192508883111561432f57600080fd5b6020840193505b8284101561435a57833561434981614081565b825260209384019390910190614336565b9450505050604084013567ffffffffffffffff81111561437957600080fd5b61438586828701614234565b9150509250925092565b6000602082840312156143a157600080fd5b813563ffffffff8116811461163057600080fd5b600080604083850312156143c857600080fd5b82356143d381614081565b915060208301356143e381614081565b809150509250929050565b60006020828403121561440057600080fd5b813567ffffffffffffffff81111561441757600080fd5b8201601f8101841361442857600080fd5b803561443661425382614210565b8082825260208201915060208360051b85010192508683111561445857600080fd5b6020840193505b8284101561378957833582526020938401939091019061445f565b60008060006060848603121561448f57600080fd5b833561449a81614081565b95602085013595506040909401359392505050565b600181811c908216806144c357607f821691505b6020821081036144e357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610d9d57610d9d6144e9565b634e487b7160e01b600052601260045260246000fd5b60008261454957634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561456057600080fd5b815161163081614081565b80820180821115610d9d57610d9d6144e9565b60006020828403121561459057600080fd5b8151801515811461163057600080fd5b81810381811115610d9d57610d9d6144e9565b6000600182016145c5576145c56144e9565b5060010190565b634e487b7160e01b600052603260045260246000fd5b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff169083015260608084015191821690830152610100820190506080830151608083015260a083015160a083015260c083015160c083015260e083015161465860e08401826001600160a01b03169052565b5092915050565b60006020828403121561467157600080fd5b5051919050565b6000845161468a81846020890161401e565b60e89490941b6001600160e81b0319169190930190815260609190911b6bffffffffffffffffffffffff1916600382015260170192915050565b602081526000825160a060208401526146e060c0840182614042565b905060018060a01b0360208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b63ffffffff8281168282160390811115610d9d57610d9d6144e9565b6000825161474a81846020870161401e565b919091019291505056fe3e1799d428897e6f54bdb61036ad40e2aa67a45b0181c60fe2f15a9d33a084d6a2646970667358221220cbcb521fe98915c3f4e5fbbcec03abf2a187883f1ceccbc88f094c48e379ffb464736f6c634300081a0033

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

00000000000000000000000000000000000000000000000000000000678e811000000000000000000000000068e49e7088b9e22b173b525409b9a265f82c0517

-----Decoded View---------------
Arg [0] : _startTimestamp (uint32): 1737392400
Arg [1] : _owner (address): 0x68E49E7088B9E22b173B525409b9a265F82c0517

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000678e8110
Arg [1] : 00000000000000000000000068e49e7088b9e22b173b525409b9a265f82c0517


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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