Contract 0xb6865617ab85e47daf84157364df3e87686a6ab9

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x9d666ce70207293e939a7d3e9a5a9730d34d84af7f91e292fe85b94977959d140x60a06040164334952022-06-24 0:26:226 days 10 hrs ago0xf6386b60fdd7d1e97ab4770837e3f1761250ddfd IN  Create: SodaStationV30 AVAX0.1357159925 27.5
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
SodaStationV3

Compiler Version
v0.8.15+commit.e14f2714

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 34 : SodaStationV3.sol
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;

// Open Zeppelin libraries for controlling upgradability and access.
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./libraries/BoringERC20.sol";

import "./Chef.sol";
import "./Upgrade.sol";
import "./Soda.sol";
import "./Pizza.sol";

contract SodaStationV3 is Initializable, UUPSUpgradeable, OwnableUpgradeable {
    using BoringERC20 for IERC20;
    using BoringERC20 for Soda;

    // Constants
    address public constant DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD;
    uint256 public constant YIELDSPS = 11574074074075; // 1 Soda per day
    uint256 public constant NUMBER_ID = 0;
    uint256 public constant SIZE_ID = 1;
    uint256 public constant DURABILITY_ID = 2;
    uint256 public constant BOOST_ID = 3;
    uint256 public constant REPAIR_ID = 4;

    // Staking

    mapping(uint256 => address) public stakedChefs; // tokenId => owner

    mapping(address => uint256) public stationSoda; // address => soda
    mapping(address => uint256) public startTimeStamp; // address => startTimeStamp
    mapping(address => uint256[2]) public numberOfStaked; // address => [number of chefs, number of master chefs]


    // Enumeration
    mapping(address => mapping(uint256 => uint256)) public ownedChefStakes; // (address, index) => tokenid
    mapping(uint256 => uint256) public ownedChefStakesIndex; // tokenId => index in its owner's stake list
    mapping(address => uint256) public ownedChefStakesBalance; // address => stake count

    struct StationCups {
        uint256 cupId;
        address owner;
        uint256 cupType;
        uint256 claims;
        uint256 repairs;
    }

    mapping(uint256 => StationCups) public stationCups; // tokenId => StationCups
    mapping(address => mapping(uint256 => uint256)) public ownedCups; // (address, index) => cupId
    mapping(uint256 => uint256) private ownedCupsIndex; // tokenId => index in its owner's stake list
    mapping(address => uint256) public ownedCupsBalance; // address => stake count
    uint256 public currentCupId;

    // Leveling
    mapping(address => uint256) public scrapsDeposited; // address => total amount of scraps deposited
    mapping(address => uint256) public skillPoints; // address => skill points available
    mapping(address => uint256[5]) public skillsLearned; // address => skill learned.

    struct CupType {
        uint256 id;
        uint256 tier;
        uint256 yield;
        uint256 durability;
        uint256 scraps;
        uint256 lpCost;
        IERC20 lpToken;
    }
    mapping(uint256 => CupType) public cupTypes;
    uint256 public currentLevelIndex;

    // Var
    uint256 public startTime;
    Chef public chef;
    Upgrade public upgrade;
    Soda public soda;
    uint256 public masterChefBonus;
    address public mafiaAddress;
    uint256 public refrigeratorTax;
    address public refrigeratorAddress;

    // Var leveling
    uint256[6] public numberSkillValue;
    uint256[6] public sizeSkillValue;
    uint256[4] public durabilitySkillValue;
    uint256[4] public boostSkillValue;
    uint256[4] public repairSkillValue;
    uint256[5] public MAX_SKILL_LEVEL;
    uint256[20] public stationLevels;

    function initialize(Chef _chef, Upgrade _upgrade, Soda _soda, address _refrigeratorAddress) public initializer {
        chef = _chef;
        soda = _soda;
        upgrade = _upgrade;
        refrigeratorAddress = _refrigeratorAddress;
        masterChefBonus = 10;
        refrigeratorTax = 10;
        stationLevels = [0,1,2,4,6,9,12,16,20,25,30,36,42,49,56,64,72,81,90,100];
        numberSkillValue = [3,5,8,12,16,20];
        sizeSkillValue = [0,2,4,6,8,100];
        durabilitySkillValue = [0,1,2,4];
        boostSkillValue = [0,5,10,20];
        repairSkillValue = [0,10,20,30];
        MAX_SKILL_LEVEL = [
            numberSkillValue.length - 1,
            sizeSkillValue.length - 1,
            durabilitySkillValue.length - 1,
            boostSkillValue.length - 1,
            repairSkillValue.length - 1
        ];

      ///@dev as there is no constructor, we need to initialise the OwnableUpgradeable explicitly
       __Ownable_init();
    }
    ///@dev required by the OZ UUPS module
    function _authorizeUpgrade(address) internal override onlyOwner {}

    // EVENTS
    event receivedSkillPoints(address owner, uint256 cupsScraped, uint256 skillPoints);
    event skillLearned(address owner, uint256 skillGroup, uint256 skillLevel);
    event respec(address owner, uint256 level);

    event cupRepaired(address owner, uint256 cupId, uint256 repairs);
    event cupCreated(address owner, uint256 cupId, uint256 cupType);
    event claimed(address owner, uint256 totalClaimed);

    // Setters
    function setRefrigeratorTax(uint256 _refrigeratorTax) external onlyOwner {
        refrigeratorTax = _refrigeratorTax;
    }
    function setChef(Chef _chef) external onlyOwner {
        chef = _chef;
    }
    function setUpgrade(Upgrade _upgrade) external onlyOwner {
        upgrade = _upgrade;
    }
    function setSoda(Soda _soda) external onlyOwner {
        soda = _soda;
    } 
    function setMasterChefBonus(uint256 _masterChefBonus) external onlyOwner {
        masterChefBonus = _masterChefBonus;
    }
    function setNumberSkillValue(uint256 _index, uint256 _value) external onlyOwner {
        numberSkillValue[_index] = _value;
    }
    function setSizeSkillValue(uint256 _index, uint256 _value) external onlyOwner {
        sizeSkillValue[_index] = _value;
    }
    function setDurabilitySkillValue(uint256 _index, uint256 _value) external onlyOwner {
        durabilitySkillValue[_index] = _value;
    }
    function setBoostSkillValue(uint256 _index, uint256 _value) external onlyOwner {
        boostSkillValue[_index] = _value;
    }
    function setRepairSkillValue(uint256 _index, uint256 _value) external onlyOwner {
        repairSkillValue[_index] = _value;
    }
    function setStationLevels(uint256 _index, uint256 _newValue) external onlyOwner {
        stationLevels[_index] = _newValue;
    }

    // Internal Views
    /**
    * Returns the level based on the total scraps deposited
    */
    function _getLevel(address _owner) internal view returns (uint256) {
        uint256 totalSoda = scrapsDeposited[_owner];
        uint256 maxId = stationLevels.length - 1;

        for (uint256 i = 0; i < maxId; i++) {
            if (totalSoda < stationLevels[i+1]) {
                    return i+1;
            }
        }
        return stationLevels.length;
    }
    // Level views
    function getNumberSkillModifier(address _owner) public view returns (uint256) {
        uint256 skill = skillsLearned[_owner][NUMBER_ID];
        return numberSkillValue[skill];
    }
    function getSizeSkillModifier(address _owner) public view returns (uint256) {
        uint256 skill = skillsLearned[_owner][SIZE_ID];
        return sizeSkillValue[skill];
    }
    function getDurabilitySkillModifier(address _owner) public view returns (uint256) {
        uint256 skill = skillsLearned[_owner][DURABILITY_ID];
        return durabilitySkillValue[skill];
    }
    function getBoostSkillModifier(address _owner) public view returns (uint256) {
        uint256 skill = skillsLearned[_owner][BOOST_ID];
        return boostSkillValue[skill];
    }
    function getRepairSkillModifier(address _owner) public view returns (uint256) {
        uint256 skill = skillsLearned[_owner][REPAIR_ID];
        return repairSkillValue[skill];
    }
    function getLevel(address _owner) public view returns (uint256) {
        return _getLevel(_owner);
    }
    function getScrapsDepositedInLevel(address _owner) public view returns (uint256) {
        uint256 level = _getLevel(_owner);
        uint256 totalSoda = scrapsDeposited[_owner];
        if(level == stationLevels.length){
            return 0;
        }

        return totalSoda - stationLevels[level-1];
    }
    function getScrapsToNextLevel(address _owner) public view returns (uint256) {
        uint256 level = _getLevel(_owner);
        if(level == stationLevels.length){
            return 0;
        }
        return stationLevels[level] - stationLevels[level-1];
    }
    function getSkillPoints(address _owner) public view returns (uint256) {
        return skillPoints[_owner];
    }
    function getSkillsLearned(address _owner) public view returns (
        uint256 number,
        uint256 size,
        uint256 durability,
        uint256 boost,
        uint256 repair   
    ) {
        uint256[5] memory skills = skillsLearned[_owner];

        number = skills[NUMBER_ID];
        size = skills[SIZE_ID]; 
        durability = skills[DURABILITY_ID]; 
        boost = skills[BOOST_ID]; 
        repair = skills[REPAIR_ID];
    }

    // Station Views
    function getTotalMasterChefBonus(address _owner) public view returns (uint256) {
        return numberOfStaked[_owner][1] * masterChefBonus;
    }

    function getSodaAccrued(address _owner) public view returns (uint256) {
        return getSodaAccruedForSPD(_owner, getTotalSPD(_owner));
    }

    function getSodaAccruedForSPD(address _owner, uint256 _spd) internal view returns (uint256) {
        if(numberOfStaked[_owner][0]+numberOfStaked[_owner][1] < ownedCupsBalance[_owner]){
            return stationSoda[_owner];
        }
        uint256 endTimeForBoost = endTimeEnergyBoost[_owner];
        uint256 startTimeOwner = startTimeStamp[_owner];
        uint256 endTime = block.timestamp;
        if(endTimeForBoost <= startTimeOwner) {
            uint256 delta = endTime - startTimeOwner;
            return stationSoda[_owner] + YIELDSPS * _spd * delta * (100 + getBoostSkillModifier(_owner)) *  (100 + getTotalMasterChefBonus(_owner)) / 10000;
        }

        if(endTimeForBoost >= endTime) {
            uint256 delta = endTime - startTimeOwner;
            return stationSoda[_owner] + YIELDSPS * _spd * delta * (100 + energyDrinkModifier) * (100 + getBoostSkillModifier(_owner)) *  (100 + getTotalMasterChefBonus(_owner)) / 1000000;
        }

        uint256 delta1 = endTimeForBoost - startTimeOwner;
        uint256 a = YIELDSPS * _spd * delta1 * (100 + energyDrinkModifier) * (100 + getBoostSkillModifier(_owner)) *  (100 + getTotalMasterChefBonus(_owner)) / 1000000;
        
        uint256 delta2 = endTime - endTimeForBoost;
        uint256 b = YIELDSPS * _spd * delta2 * (100 + getBoostSkillModifier(_owner)) *  (100 + getTotalMasterChefBonus(_owner)) / 10000;

        return stationSoda[_owner] + a + b;

    }

    function getTotalSPD(address _owner) public view returns (uint256) {
        uint256 totalSPD;
        uint256 durabilityBonus = getDurabilitySkillModifier(_owner);
        for (uint256 i = 0; i < ownedCupsBalance[_owner]; i++) {
            StationCups memory cup = stationCups[ownedCups[_owner][i]];
            if(cup.claims <=  cupTypes[cup.cupType].durability + durabilityBonus){
                totalSPD += cupTypes[cup.cupType].yield;
            }
        }
        return totalSPD;

    }

    // Create cup Externals
    // Need to approve Tool and LP first
    function createCupForPlayer(uint256 _cupType, uint256[] calldata _upgradeIds) external {
        address owner = msg.sender;
        require(_cupType < currentLevelIndex, "invalid cup type");

        uint256 discount = getSizeSkillModifier(owner);

        _updateState(owner);

        CupType memory cupType = cupTypes[_cupType];
        uint256 upgradeLength = _upgradeIds.length;
        uint256 transactionCost = cupType.lpCost * upgradeLength * (100 - discount)/100;
        require (cupType.lpToken.balanceOf(owner) >= transactionCost, "not have enough tokens");
        
        cupType.lpToken.safeTransferFrom(address(owner), DEAD_ADDRESS, transactionCost);

        require(ownedCupsBalance[owner] + upgradeLength <= getNumberSkillModifier(owner), "invalid number of cups");

        for (uint256 i = 0; i < upgradeLength; i++) {
            uint256 upgradeId = _upgradeIds[i];

            require(upgrade.ownerOf(upgradeId) == owner, "You don't own this tool");
            require(upgrade.getLevel(upgradeId) == cupType.tier, "You can't use this tool for this cup size");

            _addCupToStation(owner, _cupType);

            upgrade.transferFrom(owner, DEAD_ADDRESS, upgradeId);

            emit cupCreated(owner, currentCupId-1, _cupType);
        }
    }
    function _addCupToStation(address _owner, uint256 _cupType) internal {
        stationCups[currentCupId] = StationCups(currentCupId, _owner, _cupType, 0, 0);
        ownedCups[_owner][ownedCupsBalance[_owner]] = currentCupId;
        ownedCupsIndex[currentCupId] = ownedCupsBalance[_owner];
        ownedCupsBalance[_owner]++;
        currentCupId++;
    }
    function _removeCupFromStation(uint256 _cupId, address _owner) internal {
        delete stationCups[_cupId];
        
        uint256 lastTokenIndex = ownedCupsBalance[_owner] - 1;
        uint256 tokenIndex = ownedCupsIndex[_cupId];

        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = ownedCups[_owner][lastTokenIndex];

            ownedCups[_owner][tokenIndex] = lastTokenId;
            ownedCupsIndex[lastTokenId] = tokenIndex;
        }

        delete ownedCupsIndex[_cupId];
        delete ownedCups[_owner][lastTokenIndex];
        ownedCupsBalance[_owner]--;
    }

    // Level Externals
    /**
    * Scraps the Cup to add to levels.
    */
    function scrapCups(uint256[] calldata _cupIds) external {
        address owner = msg.sender;
        require(gameStarted(), "The game has not started");

        _updateState(owner);

        uint256 amount;
        uint256 cupsLength = _cupIds.length;
        for (uint256 i = 0; i < cupsLength; i++) {
            uint256 cupId = _cupIds[i];
            StationCups memory cup = stationCups[cupId];
            require(cup.owner == owner, "You don't own this cup");

            _removeCupFromStation(cupId, owner);

            amount += cupTypes[cup.cupType].scraps;

        }

        uint256 levelBefore = _getLevel(owner);
        scrapsDeposited[owner] += amount;
        uint256 levelAfter = _getLevel(owner);
        skillPoints[owner] += levelAfter - levelBefore;

        emit receivedSkillPoints(owner, cupsLength, levelAfter - levelBefore);
    }

    /**
    *  Spend skill point based on the skill group and skill level. Can only spend 1 point at a time.
    */
    function spendSkillPoints(uint256 _skillGroup, uint256 _skillLevel) external {
        address sender = msg.sender;

        require(skillPoints[sender] > 0, "Not enough skill points");
        require (_skillGroup <= MAX_SKILL_LEVEL.length - 1, "Invalid Skill Group");
        require(_skillLevel >= 1 && _skillLevel <= MAX_SKILL_LEVEL[_skillGroup], "Invalid Skill Level");
        
        uint256 currentSkillLevel = skillsLearned[sender][_skillGroup];
        require(_skillLevel == currentSkillLevel + 1, "Invalid Skill Level jump"); //can only level up 1 point at a time

        skillsLearned[sender][_skillGroup] = _skillLevel;
        skillPoints[sender]--;

        emit skillLearned(sender, _skillGroup, _skillLevel);
    }

    function resetSkills(uint256 _cupId) external {
        address owner = msg.sender;
        uint256 level = _getLevel(owner);
        require (level > 1, "you are still at level 1");

        _updateState(owner);

        StationCups memory cup = stationCups[_cupId];
        require(cup.owner == owner, "You don't own this cup");
        _removeCupFromStation(_cupId, owner);

        skillsLearned[owner][NUMBER_ID] = 0;
        skillsLearned[owner][SIZE_ID] = 0;
        skillsLearned[owner][DURABILITY_ID] = 0;
        skillsLearned[owner][BOOST_ID] = 0;
        skillsLearned[owner][REPAIR_ID] = 0;

        skillPoints[owner] = level - 1;

        emit respec(owner, level);

    }

    // Need to approve the LP 
    function repairCups(uint256[] calldata _cupIds) external {
        address owner = msg.sender;

        uint256 repairSkillModifier = getRepairSkillModifier(owner);
        uint256 discount = getSizeSkillModifier(owner);

        _updateState(owner);

        uint256 cupsLength = _cupIds.length;
        for (uint256 i = 0; i < cupsLength; i++) {
            uint256 cupId = _cupIds[i];
            StationCups storage cup = stationCups[cupId];
            require(cup.owner == owner, "You don't own this cup");
            CupType memory cupType = cupTypes[cup.cupType];
            uint256 repairCost = (cupType.lpCost + cup.repairs * cupType.lpCost / 4)*(100 - discount)/100;  
            repairCost =  repairCost * (100 - repairSkillModifier)/100;
            cupType.lpToken.safeTransferFrom(address(owner), DEAD_ADDRESS, repairCost);

            cup.claims = 0;
            cup.repairs++;

            emit cupRepaired(owner, cupId, cup.repairs-1);
        }

    }

    //Claim
    function _claimSoda(address _owner) internal {
        uint256 totalSPD;
        uint256 durabilityBonus = getDurabilitySkillModifier(_owner);
        for (uint256 i = 0; i < ownedCupsBalance[_owner]; i++) {
            StationCups memory cup = stationCups[ownedCups[_owner][i]];
            if(cup.claims <=  cupTypes[cup.cupType].durability + durabilityBonus){
                totalSPD += cupTypes[cup.cupType].yield;
                stationCups[ownedCups[_owner][i]].claims++;
            }
        }

        uint256 totalClaimed = getSodaAccruedForSPD(_owner, totalSPD);

        delete stationSoda[_owner];

        startTimeStamp[_owner] = block.timestamp;

        uint256 taxAmountRefrigerator = totalClaimed * refrigeratorTax / 100;

        soda.safeTransfer(_owner, totalClaimed - taxAmountRefrigerator);
        soda.safeTransfer(refrigeratorAddress, taxAmountRefrigerator);

        emit claimed(_owner, totalClaimed);

    }

    function claimSoda() public {
        address owner = msg.sender;
        _claimSoda(owner);
    }

    function _updateState(address _owner) internal {
        stationSoda[_owner] = getSodaAccrued(_owner);
        startTimeStamp[_owner] = block.timestamp;
    }

    function unstakeChef(uint256[] calldata _chefIds) public {
        address owner = msg.sender;

        _updateState(owner);

        uint256 chefLength = _chefIds.length;
        for (uint256 i = 0; i < chefLength; i++) { //unstake chefs
            uint256 chefId = _chefIds[i];

            require(stakedChefs[chefId] == owner, "You don't own this token");

            if(chef.getType(chefId) == chef.MASTER_CHEF_TYPE()){
                numberOfStaked[owner][1]--; 
            } else {
                numberOfStaked[owner][0]--;
            }

            _removeChefFromStation(chefId, owner);

            chef.transferFrom(address(this), owner, chefId);

        }

    }

    // Stake
    // Need to approve chef first
    function stakeChefs(uint256[] calldata _chefIds) public {
        require(gameStarted(), "The game has not started");

        address owner = msg.sender;

        _updateState(owner);

        uint256 chefLength = _chefIds.length;
        for (uint256 i = 0; i < chefLength; i++) { //stakes chef
            uint256 chefId = _chefIds[i];

            require(chef.ownerOf(chefId) == owner, "You don't own this token");

            if(chef.getType(chefId) == chef.MASTER_CHEF_TYPE()){
                numberOfStaked[owner][1]++;
            } else {
                numberOfStaked[owner][0]++;
            }

            _addChefToStation(chefId, owner);

            chef.transferFrom(owner, address(this), chefId);
        }

    }

    function _addChefToStation(uint256 _tokenId, address _owner) internal {
        stakedChefs[_tokenId] = _owner;
        uint256 length = ownedChefStakesBalance[_owner];
        ownedChefStakes[_owner][length] = _tokenId;
        ownedChefStakesIndex[_tokenId] = length;
        ownedChefStakesBalance[_owner]++;
    }

    function _removeChefFromStation(uint256 _chefId, address _owner) internal {
        delete stakedChefs[_chefId];

        uint256 lastTokenIndex = ownedChefStakesBalance[_owner] - 1;
        uint256 tokenIndex = ownedChefStakesIndex[_chefId];

        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = ownedChefStakes[_owner][lastTokenIndex];

            ownedChefStakes[_owner][tokenIndex] = lastTokenId;
            ownedChefStakesIndex[lastTokenId] = tokenIndex;
        }

        delete ownedChefStakesIndex[_chefId];
        delete ownedChefStakes[_owner][lastTokenIndex];
        ownedChefStakesBalance[_owner]--;
    }


    // Admin
    // Need to approve first
    function depositRewards(uint256 _amount) external onlyOwner {
        require(_amount > 0, 'Deposit value must be greater than 0.');
        soda.safeTransferFrom(address(msg.sender), address(this), _amount);
    }
    function withdrawRewards(uint256 _amount) external onlyOwner {
        require(_amount <= soda.balanceOf(address(this)), 'not enough soda');
        // Withdraw rewards
        soda.safeTransfer(address(msg.sender), _amount);
    }

    function addCup(uint256 _tier, uint256 _yield, uint256 _durability, uint256 _scraps, uint256 _lpCost, IERC20 _lpToken) external onlyOwner {
        cupTypes[currentLevelIndex] = CupType({ id: currentLevelIndex, tier: _tier, yield: _yield, durability: _durability, scraps: _scraps, lpCost: _lpCost, lpToken: _lpToken });
        currentLevelIndex++;
    }

    function changeCup(uint256 _index, uint256 _tier, uint256 _yield, uint256 _durability, uint256 _scraps, uint256 _lpCost, IERC20 _lpToken) external onlyOwner {
        require(_index <= currentLevelIndex, "invalid cup level");
        cupTypes[_index] = CupType({ id: _index, tier: _tier, yield: _yield, durability: _durability, scraps: _scraps, lpCost: _lpCost, lpToken: _lpToken });
    }

    function gameStarted() public view returns (bool) {
        return startTime != 0 && block.timestamp >= startTime;
    }

    function setStartTime(uint256 _startTime) external onlyOwner {
        require (_startTime >= block.timestamp, "startTime cannot be in the past");
        startTime = _startTime;
    }

    // Aggregated views
    struct StakedChefInfo {
        uint256 chefId;
        uint256 chefType;
    }

    function batchedStakesOfOwner(
        address _owner,
        uint256 _offset,
        uint256 _maxSize
    ) public view returns (StakedChefInfo[] memory) {
        if (_offset >= ownedChefStakesBalance[_owner]) {
            return new StakedChefInfo[](0);
        }

        uint256 outputSize = _maxSize;
        if (_offset + _maxSize >= ownedChefStakesBalance[_owner]) {
            outputSize = ownedChefStakesBalance[_owner] - _offset;
        }
        StakedChefInfo[] memory outputs = new StakedChefInfo[](outputSize);

        for (uint256 i = 0; i < outputSize; i++) {
            uint256 chefId = ownedChefStakes[_owner][_offset + i];

            outputs[i] = StakedChefInfo({
                chefId: chefId,
                chefType: chef.getType(chefId)
            });
        }

        return outputs;
    }

    struct StationCupInfo {
        uint256 cupId;
        uint256 cupType;
        uint256 yield;
        uint256 claims;
        uint256 durability;
        uint256 repairs;
        uint256 repairCost;
    }

    function batchedCupsOfOwner(
        address _owner,
        uint256 _offset,
        uint256 _maxSize
    ) public view returns (StationCupInfo[] memory) {
        if (_offset >= ownedCupsBalance[_owner]) {
            return new StationCupInfo[](0);
        }

        uint256 outputSize = _maxSize;
        if (_offset + _maxSize >= ownedCupsBalance[_owner]) {
            outputSize = ownedCupsBalance[_owner] - _offset;
        }
        StationCupInfo[] memory outputs = new StationCupInfo[](outputSize);

        uint256 durabilityBonus = getDurabilitySkillModifier(_owner);
        uint256 discount = getSizeSkillModifier(_owner);
        uint256 repairSkillModifier = getRepairSkillModifier(_owner);

        for (uint256 i = 0; i < outputSize; i++) {
            uint256 cupId = ownedCups[_owner][_offset + i];
            StationCups memory cup = stationCups[cupId];
            CupType memory cupType = cupTypes[cup.cupType];
            uint256 durability = cupType.durability + durabilityBonus;

            uint256 repairCost = (cupType.lpCost + cup.repairs * cupType.lpCost / 4)*(100 - discount)/100;
            repairCost =  repairCost * (100 - repairSkillModifier)/100;

            outputs[i] = StationCupInfo({
                cupId: cupId,
                cupType: cup.cupType,
                yield: cupType.yield,
                claims: cup.claims,
                durability: durability,
                repairs: cup.repairs,
                repairCost: repairCost
            });
        }

        return outputs;
    }

    function batchedCupsTypes() public view returns (CupType[] memory) {

        CupType[] memory outputs = new CupType[](currentLevelIndex);

        for (uint256 i = 0; i < currentLevelIndex; i++) {
            outputs[i] = cupTypes[i];
        }

        return outputs;
    }

    uint256 public energyDrinkModifier;
    function setEnergyDrinkModifier(uint256 _energyDrinkModifier) external onlyOwner {
        energyDrinkModifier = _energyDrinkModifier;
    }
    uint256 public energyDrinkCost;
    function setEnergyDrinkCost(uint256 _energyDrinkCost) external onlyOwner {
        energyDrinkCost = _energyDrinkCost;
    }

    mapping(address => uint256) public endTimeEnergyBoost; // address => end time for energy boost

    Pizza public pizza;
    function setPizza(Pizza _pizza) external onlyOwner {
        pizza = _pizza;
    }

    function energyDrink() public {
        address _owner = msg.sender;
        uint256 costToReset = getTotalSPD(_owner)  * energyDrinkCost * (100 + getBoostSkillModifier(_owner)) *  (100 + getTotalMasterChefBonus(_owner)) / 10000;
        require(pizza.balanceOf(_owner) >= costToReset, "not enough PIZZA");

        pizza.transferFrom(address(_owner), DEAD_ADDRESS, costToReset);

        _updateState(_owner);

        endTimeEnergyBoost[_owner] = block.timestamp + 24*60*60;
    }

}

File 2 of 34 : BoringERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

// solhint-disable avoid-low-level-calls

library BoringERC20 {
    bytes4 private constant SIG_SYMBOL = 0x95d89b41; // symbol()
    bytes4 private constant SIG_NAME = 0x06fdde03; // name()
    bytes4 private constant SIG_DECIMALS = 0x313ce567; // decimals()
    bytes4 private constant SIG_TRANSFER = 0xa9059cbb; // transfer(address,uint256)
    bytes4 private constant SIG_TRANSFER_FROM = 0x23b872dd; // transferFrom(address,address,uint256)

    function returnDataToString(bytes memory data) internal pure returns (string memory) {
        if (data.length >= 64) {
            return abi.decode(data, (string));
        } else if (data.length == 32) {
            uint8 i = 0;
            while (i < 32 && data[i] != 0) {
                i++;
            }
            bytes memory bytesArray = new bytes(i);
            for (i = 0; i < 32 && data[i] != 0; i++) {
                bytesArray[i] = data[i];
            }
            return string(bytesArray);
        } else {
            return "???";
        }
    }

    /// @notice Provides a safe ERC20.symbol version which returns '???' as fallback string.
    /// @param token The address of the ERC-20 token contract.
    /// @return (string) Token symbol.
    function safeSymbol(IERC20 token) internal view returns (string memory) {
        (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_SYMBOL));
        return success ? returnDataToString(data) : "???";
    }

    /// @notice Provides a safe ERC20.name version which returns '???' as fallback string.
    /// @param token The address of the ERC-20 token contract.
    /// @return (string) Token name.
    function safeName(IERC20 token) internal view returns (string memory) {
        (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_NAME));
        return success ? returnDataToString(data) : "???";
    }

    /// @notice Provides a safe ERC20.decimals version which returns '18' as fallback value.
    /// @param token The address of the ERC-20 token contract.
    /// @return (uint8) Token decimals.
    function safeDecimals(IERC20 token) internal view returns (uint8) {
        (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(SIG_DECIMALS));
        return success && data.length == 32 ? abi.decode(data, (uint8)) : 18;
    }

    /// @notice Provides a safe ERC20.transfer version for different ERC-20 implementations.
    /// Reverts on a failed transfer.
    /// @param token The address of the ERC-20 token.
    /// @param to Transfer tokens to.
    /// @param amount The token amount.
    function safeTransfer(
        IERC20 token,
        address to,
        uint256 amount
    ) internal {
        (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(SIG_TRANSFER, to, amount));
        require(success && (data.length == 0 || abi.decode(data, (bool))), "BoringERC20: Transfer failed");
    }

    /// @notice Provides a safe ERC20.transferFrom version for different ERC-20 implementations.
    /// Reverts on a failed transfer.
    /// @param token The address of the ERC-20 token.
    /// @param from Transfer tokens from.
    /// @param to Transfer tokens to.
    /// @param amount The token amount.
    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 amount
    ) internal {
        (bool success, bytes memory data) = address(token).call(
            abi.encodeWithSelector(SIG_TRANSFER_FROM, from, to, amount)
        );
        require(success && (data.length == 0 || abi.decode(data, (bool))), "BoringERC20: TransferFrom failed");
    }
}

File 3 of 34 : Upgrade.sol
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

import "./Pizza.sol";
import "./Soda.sol";

contract Upgrade is ERC721Enumerable, Ownable, Pausable {
    using SafeERC20 for IERC20;
    using Strings for uint256;


    struct UpgradeInfo {
        uint256 tokenId;
        uint256 level;
        uint256 yield;
    }
    // Struct

    struct Level {
        uint256 supply;
        uint256 maxSupply;
        uint256 pricePizza;
        uint256 priceSoda;
        uint256 yield;
    }

    // Var

    Pizza pizza;
    Soda soda;
    address public pizzeriaAddress;

    string public BASE_URI;

    uint256 public startTime;

    mapping(uint256 => Level) public levels;
    uint256 currentLevelIndex;

    uint256 public upgradesMinted = 0;

    uint256 public constant LP_TAX_PERCENT = 2;

    mapping(uint256 => uint256) private tokenLevel;

    // Events

    event onUpgradeCreated(uint256 level);

    // Constructor

    constructor(Pizza _pizza, Soda _soda, string memory _BASE_URI) ERC721("Pizza Game Chef Tools", "PIZZA-GAME-CHEF-TOOL") {
        pizza = _pizza;
        soda = _soda;
        BASE_URI = _BASE_URI;
        
        // first three upgrades
        levels[0] = Level({ supply: 0, maxSupply: 2500, pricePizza: 3000 * 1e18, priceSoda: 50 * 1e18, yield: 1 });
        levels[1] = Level({ supply: 0, maxSupply: 2200, pricePizza: 10000 * 1e18, priceSoda: 80 * 1e18, yield: 3 });
        levels[2] = Level({ supply: 0, maxSupply: 2000, pricePizza: 20000 * 1e18, priceSoda: 110 * 1e18, yield: 5 });
        currentLevelIndex = 2;
    }

    // Views

    function mintingStarted() public view returns (bool) {
        return startTime != 0 && block.timestamp > startTime;
    }

    function getYield(uint256 _tokenId) public view returns (uint256) {
        require(_exists(_tokenId), "token does not exist");
        return levels[tokenLevel[_tokenId]].yield;
    }

    function getLevel(uint256 _tokenId) public view returns (uint256) {
        require(_exists(_tokenId), "token does not exist");
        return tokenLevel[_tokenId];
    }

    function _baseURI() internal view virtual override returns (string memory) {
        return BASE_URI;
    }

    function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
        require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
        uint256 levelFixed = tokenLevel[_tokenId] + 1;
        return string(abi.encodePacked(_baseURI(), "/", levelFixed.toString(), ".json"));
    }

    function isApprovedForAll(address _owner, address _operator) public view override(ERC721, IERC721) returns (bool) {
        if (pizzeriaAddress != address(0) && _operator == pizzeriaAddress) return true;
        return super.isApprovedForAll(_owner, _operator);
    }

    // ADMIN

    function addLevel(uint256 _maxSupply, uint256 _pricePizza, uint256 _priceSoda, uint256 _yield) external onlyOwner {
        currentLevelIndex++;
        levels[currentLevelIndex] = Level({ supply: 0, maxSupply: _maxSupply, pricePizza: _pricePizza, priceSoda: _priceSoda, yield: _yield });
    }

    function changeLevel(uint256 _index, uint256 _maxSupply, uint256 _pricePizza, uint256 _priceSoda, uint256 _yield) external onlyOwner {
        require(_index <= currentLevelIndex, "invalid level");
        levels[_index] = Level({ supply: 0, maxSupply: _maxSupply, pricePizza: _pricePizza, priceSoda: _priceSoda, yield: _yield });
    }

    function setPizza(Pizza _pizza) external onlyOwner {
        pizza = _pizza;
    }

    function setSoda(Soda _soda) external onlyOwner {
        soda = _soda;
    }

    function setPizzeriaAddress(address _pizzeriaAddress) external onlyOwner {
        pizzeriaAddress = _pizzeriaAddress;
    }

    function setStartTime(uint256 _startTime) external onlyOwner {
        require(_startTime > block.timestamp, "startTime must be in future");
        require(!mintingStarted(), "minting already started");
        startTime = _startTime;
    }

    function setBaseURI(string calldata _BASE_URI) external onlyOwner {
        BASE_URI = _BASE_URI;
    }

    function forwardERC20s(IERC20 _token, uint256 _amount, address target) external onlyOwner {
        _token.safeTransfer(target, _amount);
    }

    // Minting

    function _createUpgrades(uint256 qty, uint256 level, address to) internal {
        for (uint256 i = 0; i < qty; i++) {
            upgradesMinted += 1;
            levels[level].supply += 1;
            tokenLevel[upgradesMinted] = level;
            _safeMint(to, upgradesMinted);
            emit onUpgradeCreated(level);
        }
    }

    function mintUpgrade(uint256 _level, uint256 _qty) external whenNotPaused {
        require(mintingStarted(), "Tools sales are not open");
        require (_qty > 0 && _qty <= 10, "quantity must be between 1 and 10");
        require(_level <= currentLevelIndex, "invalid level");
        require ((levels[_level].supply + _qty) <= levels[_level].maxSupply, "you can't mint that many right now");

        uint256 transactionCostPizza = levels[_level].pricePizza * _qty;
        uint256 transactionCostSoda = levels[_level].priceSoda * _qty;
        require (pizza.balanceOf(_msgSender()) >= transactionCostPizza, "not have enough PIZZA");
        require (soda.balanceOf(_msgSender()) >= transactionCostSoda, "not have enough SODA");

        _createUpgrades(_qty, _level, _msgSender());

        pizza.burn(_msgSender(), transactionCostPizza * (100 - LP_TAX_PERCENT) / 100);
        soda.burn(_msgSender(), transactionCostSoda * (100 - LP_TAX_PERCENT) / 100);

        pizza.transferForUpgradesFees(_msgSender(), transactionCostPizza * LP_TAX_PERCENT / 100);
        soda.transferForUpgradesFees(_msgSender(), transactionCostSoda * LP_TAX_PERCENT / 100);
    }

    // Returns information for multiples upgrades
    function batchedUpgradesOfOwner(address _owner, uint256 _offset, uint256 _maxSize) public view returns (UpgradeInfo[] memory) {
        if (_offset >= balanceOf(_owner)) {
            return new UpgradeInfo[](0);
        }

        uint256 outputSize = _maxSize;
        if (_offset + _maxSize >= balanceOf(_owner)) {
            outputSize = balanceOf(_owner) - _offset;
        }
        UpgradeInfo[] memory upgrades = new UpgradeInfo[](outputSize);

        for (uint256 i = 0; i < outputSize; i++) {
            uint256 tokenId = tokenOfOwnerByIndex(_owner, _offset + i); // tokenOfOwnerByIndex comes from IERC721Enumerable

            upgrades[i] = UpgradeInfo({
                tokenId: tokenId,
                level: tokenLevel[tokenId],
                yield: levels[tokenLevel[tokenId]].yield
            });
        }
        return upgrades;
    }

}

File 4 of 34 : Soda.sol
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

// Supply cap of 15,000,000
contract Soda is ERC20Capped(15_000_000 * 1e18), Ownable {

    address public upgradeAddress;
    address public pizzeriaAddress;

    constructor() ERC20("Soda", "SODA") {}

    function setUpgradeAddress(address _upgradeAddress) external onlyOwner {
        upgradeAddress = _upgradeAddress;
    }

    function setPizzeriaAddress(address _pizzeriaAddress) external onlyOwner {
        pizzeriaAddress = _pizzeriaAddress;
    }

    // external

    function mint(address _to, uint256 _amount) external onlyOwner {
        require(_to != address(0));
        _mint(_to, _amount);
    }

    function burn(address _from, uint256 _amount) external {
        require(upgradeAddress != address(0) && pizzeriaAddress != address(0), "missing initial requirements");
        require(_msgSender() == upgradeAddress || _msgSender() == pizzeriaAddress, "msgsender does not have permission");
        _burn(_from, _amount);
    }

    function transferForUpgradesFees(address _from, uint256 _amount) external {
        require(upgradeAddress != address(0), "missing initial requirements");
        require(_msgSender() == upgradeAddress, "only the upgrade contract can call transferForUpgradesFees");
        _transfer(_from, upgradeAddress, _amount);
    }
}

File 5 of 34 : Pizza.sol
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract Pizza is ERC20("Pizza", "PIZZA"), Ownable {
    uint256 public constant ONE_PIZZA = 1e18;
    uint256 public constant NUM_PROMOTIONAL_PIZZA = 500_000;
    uint256 public constant NUM_PIZZA_SODA_LP = 20_000_000;

    uint256 public NUM_PIZZA_AVAX_LP = 34_000_000;

    address public freezerAddress;
    address public pizzeriaAddress;
    address public chefAddress;
    address public upgradeAddress;

    bool public promotionalPizzaMinted = false;
    bool public avaxLPPizzaMinted = false;
    bool public sodaLPPizzaMinted = false;

    // ADMIN

    /**
     * pizzeria yields pizza
     */
    function setPizzeriaAddress(address _pizzeriaAddress) external onlyOwner {
        pizzeriaAddress = _pizzeriaAddress;
    }

    function setFreezerAddress(address _freezerAddress) external onlyOwner {
        freezerAddress = _freezerAddress;
    }

    function setUpgradeAddress(address _upgradeAddress) external onlyOwner {
        upgradeAddress = _upgradeAddress;
    }

    /**
     * chef consumes pizza
     * chef address can only be set once
     */
    function setChefAddress(address _chefAddress) external onlyOwner {
        require(address(chefAddress) == address(0), "chef address already set");
        chefAddress = _chefAddress;
    }

    function mintPromotionalPizza(address _to) external onlyOwner {
        require(!promotionalPizzaMinted, "promotional pizza has already been minted");
        promotionalPizzaMinted = true;
        _mint(_to, NUM_PROMOTIONAL_PIZZA * ONE_PIZZA);
    }

    function mintAvaxLPPizza() external onlyOwner {
        require(!avaxLPPizzaMinted, "avax pizza LP has already been minted");
        avaxLPPizzaMinted = true;
        _mint(owner(), NUM_PIZZA_AVAX_LP * ONE_PIZZA);
    }

    function mintSodaLPPizza() external onlyOwner {
        require(!sodaLPPizzaMinted, "soda pizza LP has already been minted");
        sodaLPPizzaMinted = true;
        _mint(owner(), NUM_PIZZA_SODA_LP * ONE_PIZZA);
    }

    function setNumPizzaAvaxLp(uint256 _numPizzaAvaxLp) external onlyOwner {
        NUM_PIZZA_AVAX_LP = _numPizzaAvaxLp;
    }

    // external

    function mint(address _to, uint256 _amount) external {
        require(pizzeriaAddress != address(0) && chefAddress != address(0) && freezerAddress != address(0) && upgradeAddress != address(0), "missing initial requirements");
        require(_msgSender() == pizzeriaAddress,"msgsender does not have permission");
        _mint(_to, _amount);
    }

    function burn(address _from, uint256 _amount) external {
        require(chefAddress != address(0) && freezerAddress != address(0) && upgradeAddress != address(0), "missing initial requirements");
        require(
            _msgSender() == chefAddress 
            || _msgSender() == freezerAddress 
            || _msgSender() == upgradeAddress,
            "msgsender does not have permission"
        );
        _burn(_from, _amount);
    }

    function transferToFreezer(address _from, uint256 _amount) external {
        require(freezerAddress != address(0), "missing initial requirements");
        require(_msgSender() == freezerAddress, "only the freezer contract can call transferToFreezer");
        _transfer(_from, freezerAddress, _amount);
    }

    function transferForUpgradesFees(address _from, uint256 _amount) external {
        require(upgradeAddress != address(0), "missing initial requirements");
        require(_msgSender() == upgradeAddress, "only the upgrade contract can call transferForUpgradesFees");
        _transfer(_from, upgradeAddress, _amount);
    }
}

File 6 of 34 : Chef.sol
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";

import "./Pizza.sol";

contract Chef is ERC721Enumerable, Ownable, Pausable {
    using SafeERC20 for IERC20;
    using Strings for uint256;

    struct ChefInfo {
        uint256 tokenId;
        uint256 chefType;
    }

    // CONSTANTS

    uint256 public constant CHEF_PRICE_WHITELIST = 1 ether;
    uint256 public constant CHEF_PRICE_AVAX = 1.5 ether;

    uint256 public constant WHITELIST_CHEFS = 1000; 
    uint256 public constant CHEFS_PER_PIZZA_MINT_LEVEL = 5000;

    uint256 public constant MAXIMUM_MINTS_PER_WHITELIST_ADDRESS = 4;

    uint256 public constant NUM_GEN0_CHEFS = 10_000;
    uint256 public constant NUM_GEN1_CHEFS = 10_000;

    uint256 public constant CHEF_TYPE = 1;
    uint256 public constant MASTER_CHEF_TYPE = 2;

    uint256 public constant CHEF_YIELD = 1;
    uint256 public constant MASTER_CHEF_YIELD = 3;

    uint256 public constant PROMOTIONAL_CHEFS = 50;

    // VAR

    // external contracts
    Pizza public pizza;
    address public pizzeriaAddress;
    address public chefTypeOracleAddress;

    // metadata URI
    string public BASE_URI;

    // chef type definitions (normal or master?)
    mapping(uint256 => uint256) public tokenTypes; // maps tokenId to its type
    mapping(uint256 => uint256) public typeYields; // maps chef type to yield

    // mint tracking
    uint256 public chefsMintedWithAVAX;
    uint256 public chefsMintedWithPIZZA;
    uint256 public chefsMintedWhitelist;
    uint256 public chefsMintedPromotional;
    uint256 public chefsMinted = 50; // First 50 ids are reserved for the promotional chefs

    // mint control timestamps
    uint256 public startTimeWhitelist;
    uint256 public startTimeAVAX;
    uint256 public startTimePIZZA;

    // PIZZA mint price tracking
    uint256 public currentPIZZAMintCost = 20_000 * 1e18;

    // whitelist
    bytes32 public merkleRoot;
    mapping(address => uint256) public whitelistClaimed;

    // EVENTS

    event onChefCreated(uint256 tokenId);
    event onChefRevealed(uint256 tokenId, uint256 chefType);

    /**
     * requires pizza, chefType oracle address
     * pizza: for liquidity bootstrapping and spending on chefs
     * chefTypeOracleAddress: external chef generator uses secure RNG
     */
    constructor(Pizza _pizza, address _chefTypeOracleAddress, string memory _BASE_URI) ERC721("Pizza Game Chefs", "PIZZA-GAME-CHEF") {
        require(address(_pizza) != address(0));
        require(_chefTypeOracleAddress != address(0));

        // set required contract references
        pizza = _pizza;
        chefTypeOracleAddress = _chefTypeOracleAddress;

        // set base uri
        BASE_URI = _BASE_URI;

        // initialize token yield values for each chef type
        typeYields[CHEF_TYPE] = CHEF_YIELD;
        typeYields[MASTER_CHEF_TYPE] = MASTER_CHEF_YIELD;
    }

    // VIEWS

    // minting status

    function mintingStartedWhitelist() public view returns (bool) {
        return startTimeWhitelist != 0 && block.timestamp >= startTimeWhitelist;
    }

    function mintingStartedAVAX() public view returns (bool) {
        return startTimeAVAX != 0 && block.timestamp >= startTimeAVAX;
    }

    function mintingStartedPIZZA() public view returns (bool) {
        return startTimePIZZA != 0 && block.timestamp >= startTimePIZZA;
    }

    // metadata

    function _baseURI() internal view virtual override returns (string memory) {
        return BASE_URI;
    }

    function getYield(uint256 _tokenId) public view returns (uint256) {
        require (_exists(_tokenId), "token does not exist");
        return typeYields[tokenTypes[_tokenId]];
    }

    function getType(uint256 _tokenId) public view returns (uint256) {
        require (_exists(_tokenId), "token does not exist");
        return tokenTypes[_tokenId];
    }

    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require (_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
        return string(abi.encodePacked(_baseURI(), "/", tokenId.toString(), ".json"));
    }

    // override

    function isApprovedForAll(address _owner, address _operator) public view override(ERC721, IERC721) returns (bool) {
        // pizzeria must be able to stake and unstake
        if (pizzeriaAddress != address(0) && _operator == pizzeriaAddress) return true;
        return super.isApprovedForAll(_owner, _operator);
    }

    // ADMIN

    function setPizzeriaAddress(address _pizzeriaAddress) external onlyOwner {
        pizzeriaAddress = _pizzeriaAddress;
    }

    function setPizza(address _pizza) external onlyOwner {
        pizza = Pizza(_pizza);
    }

    function setchefTypeOracleAddress(address _chefTypeOracleAddress) external onlyOwner {
        chefTypeOracleAddress = _chefTypeOracleAddress;
    }

    function setStartTimeWhitelist(uint256 _startTime) external onlyOwner {
        require (_startTime >= block.timestamp, "startTime cannot be in the past");
        startTimeWhitelist = _startTime;
    }

    function setStartTimeAVAX(uint256 _startTime) external onlyOwner {
        require (_startTime >= block.timestamp, "startTime cannot be in the past");
        startTimeAVAX = _startTime;
    }

    function setStartTimePIZZA(uint256 _startTime) external onlyOwner {
        require (_startTime >= block.timestamp, "startTime cannot be in the past");
        startTimePIZZA = _startTime;
    }

    function setBaseURI(string calldata _BASE_URI) external onlyOwner {
        BASE_URI = _BASE_URI;
    }

    /**
     * @dev merkle root for WL wallets
     */
    function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner {
        merkleRoot = _merkleRoot;
    }

    /**
     * @dev allows owner to send ERC20s held by this contract to target
     */
    function forwardERC20s(IERC20 _token, uint256 _amount, address target) external onlyOwner {
        _token.safeTransfer(target, _amount);
    }

    /**
     * @dev allows owner to withdraw AVAX
     */
    function withdrawAVAX(uint256 _amount) external payable onlyOwner {
        require(address(this).balance >= _amount, "not enough AVAX");
        address payable to = payable(_msgSender());
        (bool sent, ) = to.call{value: _amount}("");
        require(sent, "Failed to send AVAX");
    }

    // MINTING

    function _createChef(address to, uint256 tokenId) internal {
        require (chefsMinted <= NUM_GEN0_CHEFS + NUM_GEN1_CHEFS, "cannot mint anymore chefs");
        _safeMint(to, tokenId);

        emit onChefCreated(tokenId);
    }

    function _createChefs(uint256 qty, address to) internal {
        for (uint256 i = 0; i < qty; i++) {
            chefsMinted += 1;
            _createChef(to, chefsMinted);
        }
    }

    /**
     * @dev as an anti cheat mechanism, an external automation will generate the NFT metadata and set the chef types via rng
     * - Using an external source of randomness ensures our mint cannot be cheated
     * - The external automation is open source and can be found on pizza game's github
     * - Once the mint is finished, it is provable that this randomness was not tampered with by providing the seed
     * - Chef type can be set only once
     */
    function setChefType(uint256 tokenId, uint256 chefType) external {
        require(_msgSender() == chefTypeOracleAddress, "msgsender does not have permission");
        require(tokenTypes[tokenId] == 0, "that token's type has already been set");
        require(chefType == CHEF_TYPE || chefType == MASTER_CHEF_TYPE, "invalid chef type");

        tokenTypes[tokenId] = chefType;
        emit onChefRevealed(tokenId, chefType);
    }

    /**
     * @dev Promotional GEN0 minting 
     * Can mint maximum of PROMOTIONAL_CHEFS
     * All chefs minted are from the same chefType
     */
    function mintPromotional(uint256 qty, uint256 chefType, address target) external onlyOwner {
        require (qty > 0, "quantity must be greater than 0");
        require ((chefsMintedPromotional + qty) <= PROMOTIONAL_CHEFS, "you can't mint that many right now");
        require(chefType == CHEF_TYPE || chefType == MASTER_CHEF_TYPE, "invalid chef type");

        for (uint256 i = 0; i < qty; i++) {
            chefsMintedPromotional += 1;
            require(tokenTypes[chefsMintedPromotional] == 0, "that token's type has already been set");
            tokenTypes[chefsMintedPromotional] = chefType;
            _createChef(target, chefsMintedPromotional);
        }
    }

    /**
     * @dev Whitelist GEN0 minting
     * We implement a hard limit on the whitelist chefs.
     */
    function mintWhitelist(bytes32[] calldata _merkleProof, uint256 qty) external payable whenNotPaused {
        // check most basic requirements
        require(merkleRoot != 0, "missing root");
        require(mintingStartedWhitelist(), "cannot mint right now");
        require (!mintingStartedAVAX(), "whitelist minting is closed");

        // check if address belongs in whitelist
        bytes32 leaf = keccak256(abi.encodePacked(_msgSender()));
        require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), "this address does not have permission");

        // check more advanced requirements
        require(qty > 0 && qty <= MAXIMUM_MINTS_PER_WHITELIST_ADDRESS, "quantity must be between 1 and 4");
        require((chefsMintedWhitelist + qty) <= WHITELIST_CHEFS, "you can't mint that many right now");
        require((whitelistClaimed[_msgSender()] + qty) <= MAXIMUM_MINTS_PER_WHITELIST_ADDRESS, "this address can't mint any more whitelist chefs");

        // check price
        require(msg.value >= CHEF_PRICE_WHITELIST * qty, "not enough AVAX");

        chefsMintedWhitelist += qty;
        whitelistClaimed[_msgSender()] += qty;

        // mint chefs
        _createChefs(qty, _msgSender());
    }

    /**
     * @dev GEN0 minting
     */
    function mintChefWithAVAX(uint256 qty) external payable whenNotPaused {
        require (mintingStartedAVAX(), "cannot mint right now");
        require (qty > 0 && qty <= 10, "quantity must be between 1 and 10");
        require ((chefsMintedWithAVAX + qty) <= (NUM_GEN0_CHEFS - chefsMintedWhitelist - PROMOTIONAL_CHEFS), "you can't mint that many right now");

        // calculate the transaction cost
        uint256 transactionCost = CHEF_PRICE_AVAX * qty;
        require (msg.value >= transactionCost, "not enough AVAX");

        chefsMintedWithAVAX += qty;

        // mint chefs
        _createChefs(qty, _msgSender());
    }

    /**
     * @dev GEN1 minting 
     */
    function mintChefWithPIZZA(uint256 qty) external whenNotPaused {
        require (mintingStartedPIZZA(), "cannot mint right now");
        require (qty > 0 && qty <= 10, "quantity must be between 1 and 10");
        require ((chefsMintedWithPIZZA + qty) <= NUM_GEN1_CHEFS, "you can't mint that many right now");

        // calculate transaction costs
        uint256 transactionCostPIZZA = currentPIZZAMintCost * qty;
        require (pizza.balanceOf(_msgSender()) >= transactionCostPIZZA, "not enough PIZZA");

        // raise the mint level and cost when this mint would place us in the next level
        // if you mint in the cost transition you get a discount =)
        if(chefsMintedWithPIZZA <= CHEFS_PER_PIZZA_MINT_LEVEL && chefsMintedWithPIZZA + qty > CHEFS_PER_PIZZA_MINT_LEVEL) {
            currentPIZZAMintCost = currentPIZZAMintCost * 2;
        }

        chefsMintedWithPIZZA += qty;

        // spend pizza
        pizza.burn(_msgSender(), transactionCostPIZZA);

        // mint chefs
        _createChefs(qty, _msgSender());
    }

    // Returns information for multiples chefs
    function batchedChefsOfOwner(address _owner, uint256 _offset, uint256 _maxSize) public view returns (ChefInfo[] memory) {
        if (_offset >= balanceOf(_owner)) {
            return new ChefInfo[](0);
        }

        uint256 outputSize = _maxSize;
        if (_offset + _maxSize >= balanceOf(_owner)) {
            outputSize = balanceOf(_owner) - _offset;
        }
        ChefInfo[] memory chefs = new ChefInfo[](outputSize);

        for (uint256 i = 0; i < outputSize; i++) {
            uint256 tokenId = tokenOfOwnerByIndex(_owner, _offset + i); // tokenOfOwnerByIndex comes from IERC721Enumerable

            chefs[i] = ChefInfo({
                tokenId: tokenId,
                chefType: tokenTypes[tokenId]
            });
        }

        return chefs;
    }
}

File 7 of 34 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * 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[EIP 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 8 of 34 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 9 of 34 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Trees proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            bytes32 proofElement = proof[i];
            if (computedHash <= proofElement) {
                // Hash(current computed hash + current element of the proof)
                computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
            } else {
                // Hash(current element of the proof + current computed hash)
                computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
            }
        }
        return computedHash;
    }
}

File 10 of 34 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

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

File 11 of 34 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

File 12 of 34 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 13 of 34 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../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 14 of 34 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../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 tokenId);

    /**
     * @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 15 of 34 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
        return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, tokenId);

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

File 16 of 34 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 17 of 34 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 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`, checking first that contract recipients
     * are aware of the ERC721 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * 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 Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @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 caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

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

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

File 18 of 34 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits a {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}

File 19 of 34 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

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

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 20 of 34 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
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 21 of 34 : ERC20Capped.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Capped.sol)

pragma solidity ^0.8.0;

import "../ERC20.sol";

/**
 * @dev Extension of {ERC20} that adds a cap to the supply of tokens.
 */
abstract contract ERC20Capped is ERC20 {
    uint256 private immutable _cap;

    /**
     * @dev Sets the value of the `cap`. This value is immutable, it can only be
     * set once during construction.
     */
    constructor(uint256 cap_) {
        require(cap_ > 0, "ERC20Capped: cap is 0");
        _cap = cap_;
    }

    /**
     * @dev Returns the cap on the token's total supply.
     */
    function cap() public view virtual returns (uint256) {
        return _cap;
    }

    /**
     * @dev See {ERC20-_mint}.
     */
    function _mint(address account, uint256 amount) internal virtual override {
        require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded");
        super._mint(account, amount);
    }
}

File 22 of 34 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

File 23 of 34 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.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}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * 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.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * 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 override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override 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 value {ERC20} uses, unless this function is
     * 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 override returns (uint8) {
        return 18;
    }

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        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}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        unchecked {
            _approve(sender, _msgSender(), currentAllowance - amount);
        }

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(_msgSender(), spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * 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.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` 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.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 24 of 34 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

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

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

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

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

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

File 25 of 34 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../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.
 *
 * By default, the owner account will be the one that deploys the contract. 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;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing 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 {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _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 26 of 34 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

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

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

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

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

File 27 of 34 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 28 of 34 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 29 of 34 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate that the this implementation remains valid after an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 30 of 34 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 31 of 34 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 32 of 34 : ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 33 of 34 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 34 of 34 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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.
 *
 * By default, the owner account will be the one that deploys the contract. 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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing 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 {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _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);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

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

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"totalClaimed","type":"uint256"}],"name":"claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"cupId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cupType","type":"uint256"}],"name":"cupCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"cupId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"repairs","type":"uint256"}],"name":"cupRepaired","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"cupsScraped","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"skillPoints","type":"uint256"}],"name":"receivedSkillPoints","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"level","type":"uint256"}],"name":"respec","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"skillGroup","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"skillLevel","type":"uint256"}],"name":"skillLearned","type":"event"},{"inputs":[],"name":"BOOST_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEAD_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DURABILITY_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"MAX_SKILL_LEVEL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NUMBER_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REPAIR_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SIZE_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"YIELDSPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tier","type":"uint256"},{"internalType":"uint256","name":"_yield","type":"uint256"},{"internalType":"uint256","name":"_durability","type":"uint256"},{"internalType":"uint256","name":"_scraps","type":"uint256"},{"internalType":"uint256","name":"_lpCost","type":"uint256"},{"internalType":"contract IERC20","name":"_lpToken","type":"address"}],"name":"addCup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_offset","type":"uint256"},{"internalType":"uint256","name":"_maxSize","type":"uint256"}],"name":"batchedCupsOfOwner","outputs":[{"components":[{"internalType":"uint256","name":"cupId","type":"uint256"},{"internalType":"uint256","name":"cupType","type":"uint256"},{"internalType":"uint256","name":"yield","type":"uint256"},{"internalType":"uint256","name":"claims","type":"uint256"},{"internalType":"uint256","name":"durability","type":"uint256"},{"internalType":"uint256","name":"repairs","type":"uint256"},{"internalType":"uint256","name":"repairCost","type":"uint256"}],"internalType":"struct SodaStationV3.StationCupInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"batchedCupsTypes","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"tier","type":"uint256"},{"internalType":"uint256","name":"yield","type":"uint256"},{"internalType":"uint256","name":"durability","type":"uint256"},{"internalType":"uint256","name":"scraps","type":"uint256"},{"internalType":"uint256","name":"lpCost","type":"uint256"},{"internalType":"contract IERC20","name":"lpToken","type":"address"}],"internalType":"struct SodaStationV3.CupType[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_offset","type":"uint256"},{"internalType":"uint256","name":"_maxSize","type":"uint256"}],"name":"batchedStakesOfOwner","outputs":[{"components":[{"internalType":"uint256","name":"chefId","type":"uint256"},{"internalType":"uint256","name":"chefType","type":"uint256"}],"internalType":"struct SodaStationV3.StakedChefInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"boostSkillValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_tier","type":"uint256"},{"internalType":"uint256","name":"_yield","type":"uint256"},{"internalType":"uint256","name":"_durability","type":"uint256"},{"internalType":"uint256","name":"_scraps","type":"uint256"},{"internalType":"uint256","name":"_lpCost","type":"uint256"},{"internalType":"contract IERC20","name":"_lpToken","type":"address"}],"name":"changeCup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"chef","outputs":[{"internalType":"contract Chef","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimSoda","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cupType","type":"uint256"},{"internalType":"uint256[]","name":"_upgradeIds","type":"uint256[]"}],"name":"createCupForPlayer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cupTypes","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"tier","type":"uint256"},{"internalType":"uint256","name":"yield","type":"uint256"},{"internalType":"uint256","name":"durability","type":"uint256"},{"internalType":"uint256","name":"scraps","type":"uint256"},{"internalType":"uint256","name":"lpCost","type":"uint256"},{"internalType":"contract IERC20","name":"lpToken","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentCupId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentLevelIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"durabilitySkillValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"endTimeEnergyBoost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"energyDrink","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"energyDrinkCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"energyDrinkModifier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gameStarted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getBoostSkillModifier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getDurabilitySkillModifier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getNumberSkillModifier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getRepairSkillModifier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getScrapsDepositedInLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getScrapsToNextLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getSizeSkillModifier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getSkillPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getSkillsLearned","outputs":[{"internalType":"uint256","name":"number","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"durability","type":"uint256"},{"internalType":"uint256","name":"boost","type":"uint256"},{"internalType":"uint256","name":"repair","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getSodaAccrued","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getTotalMasterChefBonus","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"getTotalSPD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract Chef","name":"_chef","type":"address"},{"internalType":"contract Upgrade","name":"_upgrade","type":"address"},{"internalType":"contract Soda","name":"_soda","type":"address"},{"internalType":"address","name":"_refrigeratorAddress","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mafiaAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"masterChefBonus","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"numberOfStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"numberSkillValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"ownedChefStakes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ownedChefStakesBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"ownedChefStakesIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"ownedCups","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ownedCupsBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pizza","outputs":[{"internalType":"contract Pizza","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refrigeratorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refrigeratorTax","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_cupIds","type":"uint256[]"}],"name":"repairCups","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"repairSkillValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cupId","type":"uint256"}],"name":"resetSkills","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_cupIds","type":"uint256[]"}],"name":"scrapCups","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"scrapsDeposited","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setBoostSkillValue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Chef","name":"_chef","type":"address"}],"name":"setChef","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setDurabilitySkillValue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_energyDrinkCost","type":"uint256"}],"name":"setEnergyDrinkCost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_energyDrinkModifier","type":"uint256"}],"name":"setEnergyDrinkModifier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_masterChefBonus","type":"uint256"}],"name":"setMasterChefBonus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setNumberSkillValue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Pizza","name":"_pizza","type":"address"}],"name":"setPizza","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_refrigeratorTax","type":"uint256"}],"name":"setRefrigeratorTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setRepairSkillValue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"setSizeSkillValue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Soda","name":"_soda","type":"address"}],"name":"setSoda","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_startTime","type":"uint256"}],"name":"setStartTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_newValue","type":"uint256"}],"name":"setStationLevels","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Upgrade","name":"_upgrade","type":"address"}],"name":"setUpgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"sizeSkillValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"skillPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"skillsLearned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"soda","outputs":[{"internalType":"contract Soda","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_skillGroup","type":"uint256"},{"internalType":"uint256","name":"_skillLevel","type":"uint256"}],"name":"spendSkillPoints","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_chefIds","type":"uint256[]"}],"name":"stakeChefs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakedChefs","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"startTimeStamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stationCups","outputs":[{"internalType":"uint256","name":"cupId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"cupType","type":"uint256"},{"internalType":"uint256","name":"claims","type":"uint256"},{"internalType":"uint256","name":"repairs","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stationLevels","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stationSoda","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_chefIds","type":"uint256[]"}],"name":"unstakeChef","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"upgrade","outputs":[{"internalType":"contract Upgrade","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawRewards","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040523060805234801561001457600080fd5b506080516158516200004d600039600081816115da0152818161161a015281816118240152818161186401526118f701526158516000f3fe60806040526004361061050d5760003560e01c806385b109bd11610297578063bcc64d6711610165578063ecf337e9116100cc578063f41e6f4511610085578063f41e6f451461115e578063f6a27b6c1461117e578063f8c8765e146111ab578063f99e487a146111cb578063f9d1d670146111eb578063fe94a4e51461120b57600080fd5b8063ecf337e914611090578063ef0eedcf146110b0578063f01706a4146110d0578063f08b7bed146110f0578063f2c0c5f91461111e578063f2fde38b1461113e57600080fd5b8063cff3a2941161011e578063cff3a29414610f75578063d48dae9414610f8a578063d55ec69714610fb7578063dba6922b14610fd7578063dcacd77e1461105b578063e4e052f61461107b57600080fd5b8063bcc64d6714610eb3578063bdc64fdd14610ed3578063c56adf8614610ef3578063c58853bb14610f13578063c616146814610f35578063cf17bb0d14610f5557600080fd5b8063976031d411610209578063ab911287116101c2578063ab91128714610dd6578063b03ee24d14610df6578063b10b44c714610e23578063b417193f14610e43578063b63a1e2814610e70578063b94e7b2614610e8657600080fd5b8063976031d414610cf95780639967818b14610d1957806399f0816814610d465780639bbf3e5214610d7c578063a810c0a714610d96578063a95789b814610db657600080fd5b80638c599a6f1161025b5780638c599a6f14610c445780638da5cb5b14610c595780638fa8c13014610c7757806391352f0e14610ca45780639342c8f414610cc457806395faafdc14610ce457600080fd5b806385b109bd14610b8e5780638736eb1b14610bae5780638a1edd7c14610bce5780638bdc141a14610bee5780638bdf67f214610c2457600080fd5b806349f6aa46116103df57806362667a651161034657806374daa818116102ff57806374daa81814610ac057806378e9792514610ae05780637e9312c514610af65780637fc5853114610b2e578063817c896614610b4e5780638183755214610b6e57600080fd5b806362667a6514610a095780636387b23414610a1e578063646aa35114610a3e57806364c5bc1f14610a5e5780636ea13dbd14610a8b578063715018a614610aab57600080fd5b806352d1902d1161039857806352d1902d146109625780635795db3f146109775780635c74c2391461098d5780635e123ce4146109ae5780635ead3f6f146109d3578063604af1d6146109e957600080fd5b806349f6aa461461082b5780634c0a964b1461084b5780634c3c3db5146108835780634ce634eb146109225780634e6fd6c4146109395780634f1ef2861461094f57600080fd5b80632d8b0ff511610483578063394ca9c71161043c578063394ca9c7146107615780633b617e26146107a95780633e0a322d146107c0578063429f4161146107e057806346a98b55146107f65780634934168c1461081657600080fd5b80632d8b0ff5146106945780632ec46318146106b457806330f078b1146106d457806331456495146106f4578063340f6293146107145780633659cfe61461074157600080fd5b80631fc8bc5d116104d55780631fc8bc5d146105d4578063234b35a9146105f4578063258b5e9a146106145780632731f3c214610634578063290b433a146106545780632d5183a91461067457600080fd5b806304a89e5714610512578063112efd5b1461053457806312e502421461055c578063156ef1231461057c5780631c90fc68146105b4575b600080fd5b34801561051e57600080fd5b5061053261052d366004614fe8565b61122b565b005b34801561054057600080fd5b50610549600281565b6040519081526020015b60405180910390f35b34801561056857600080fd5b50610549610577366004615005565b611280565b34801561058857600080fd5b5060df5461059c906001600160a01b031681565b6040516001600160a01b039091168152602001610553565b3480156105c057600080fd5b506105496105cf366004615031565b6112a5565b3480156105e057600080fd5b5060db5461059c906001600160a01b031681565b34801561060057600080fd5b5061054961060f366004614fe8565b6112bc565b34801561062057600080fd5b5061053261062f36600461504a565b6112f4565b34801561064057600080fd5b5061054961064f366004614fe8565b611338565b34801561066057600080fd5b5060dd5461059c906001600160a01b031681565b34801561068057600080fd5b5061053261068f36600461504a565b611367565b3480156106a057600080fd5b506105326106af366004615031565b6113a5565b3480156106c057600080fd5b506105496106cf366004614fe8565b6113d5565b3480156106e057600080fd5b506105496106ef366004615031565b611439565b34801561070057600080fd5b5061053261070f366004615031565b611449565b34801561072057600080fd5b5061054961072f366004614fe8565b60ca6020526000908152604090205481565b34801561074d57600080fd5b5061053261075c366004614fe8565b6115d0565b34801561076d57600080fd5b5061078161077c366004614fe8565b6116af565b604080519586526020860194909452928401919091526060830152608082015260a001610553565b3480156107b557600080fd5b506105496101135481565b3480156107cc57600080fd5b506105326107db366004615031565b61173f565b3480156107ec57600080fd5b5061054960de5481565b34801561080257600080fd5b50610532610811366004614fe8565b6117be565b34801561082257600080fd5b50610549600081565b34801561083757600080fd5b50610549610846366004615031565b61180a565b34801561085757600080fd5b50610549610866366004615005565b60cd60209081526000928352604080842090915290825290205481565b34801561088f57600080fd5b506108e461089e366004615031565b60d860205260009081526040902080546001820154600283015460038401546004850154600586015460069096015494959394929391929091906001600160a01b031687565b604080519788526020880196909652948601939093526060850191909152608084015260a08301526001600160a01b031660c082015260e001610553565b34801561092e57600080fd5b506105496101145481565b34801561094557600080fd5b5061059c61dead81565b61053261095d366004615082565b61181a565b34801561096e57600080fd5b506105496118ea565b34801561098357600080fd5b5061054960e05481565b34801561099957600080fd5b506101165461059c906001600160a01b031681565b3480156109ba57600080fd5b506109c361199d565b6040519015158152602001610553565b3480156109df57600080fd5b5061054960d45481565b3480156109f557600080fd5b50610532610a04366004615192565b6119b9565b348015610a1557600080fd5b50610549600181565b348015610a2a57600080fd5b50610532610a39366004615031565b611e95565b348015610a4a57600080fd5b50610549610a59366004614fe8565b611ec4565b348015610a6a57600080fd5b50610a7e610a793660046151de565b611f30565b6040516105539190615213565b348015610a9757600080fd5b50610549610aa6366004614fe8565b612146565b348015610ab757600080fd5b5061053261223f565b348015610acc57600080fd5b50610549610adb366004615031565b612275565b348015610aec57600080fd5b5061054960da5481565b348015610b0257600080fd5b50610549610b11366004615005565b60d160209081526000928352604080842090915290825290205481565b348015610b3a57600080fd5b50610549610b49366004615031565b612285565b348015610b5a57600080fd5b50610549610b69366004614fe8565b612295565b348015610b7a57600080fd5b50610532610b89366004615031565b6122a6565b348015610b9a57600080fd5b50610549610ba9366004615031565b6122d5565b348015610bba57600080fd5b50610532610bc9366004615262565b6122e5565b348015610bda57600080fd5b50610532610be9366004615031565b6125fb565b348015610bfa57600080fd5b5061059c610c09366004615031565b60c9602052600090815260409020546001600160a01b031681565b348015610c3057600080fd5b50610532610c3f366004615031565b61262b565b348015610c5057600080fd5b506105326126cb565b348015610c6557600080fd5b506097546001600160a01b031661059c565b348015610c8357600080fd5b50610c97610c923660046151de565b612895565b60405161055391906152a4565b348015610cb057600080fd5b50610532610cbf36600461504a565b612c31565b348015610cd057600080fd5b50610532610cdf366004615031565b612e54565b348015610cf057600080fd5b50610549600481565b348015610d0557600080fd5b50610532610d14366004614fe8565b612f42565b348015610d2557600080fd5b50610549610d34366004615031565b60ce6020526000908152604090205481565b348015610d5257600080fd5b50610549610d61366004614fe8565b6001600160a01b0316600090815260d6602052604090205490565b348015610d8857600080fd5b50610549650a86cc92e3db81565b348015610da257600080fd5b50610549610db1366004614fe8565b612f8e565b348015610dc257600080fd5b5060e15461059c906001600160a01b031681565b348015610de257600080fd5b50610532610df1366004615262565b612fbd565b348015610e0257600080fd5b50610549610e11366004614fe8565b60d36020526000908152604090205481565b348015610e2f57600080fd5b50610549610e3e366004615005565b613222565b348015610e4f57600080fd5b50610549610e5e366004614fe8565b60cb6020526000908152604090205481565b348015610e7c57600080fd5b5061054960d95481565b348015610e9257600080fd5b50610549610ea1366004614fe8565b60d56020526000908152604090205481565b348015610ebf57600080fd5b50610549610ece366004614fe8565b61323e565b348015610edf57600080fd5b50610532610eee366004615319565b61326a565b348015610eff57600080fd5b50610532610f0e366004615262565b613342565b348015610f1f57600080fd5b50610f28613556565b604051610553919061536e565b348015610f4157600080fd5b50610532610f5036600461504a565b61369f565b348015610f6157600080fd5b50610532610f7036600461504a565b6136dd565b348015610f8157600080fd5b5061053261371b565b348015610f9657600080fd5b50610549610fa5366004614fe8565b60cf6020526000908152604090205481565b348015610fc357600080fd5b5060dc5461059c906001600160a01b031681565b348015610fe357600080fd5b5061102b610ff2366004615031565b60d0602052600090815260409020805460018201546002830154600384015460049094015492936001600160a01b039092169290919085565b604080519586526001600160a01b039094166020860152928401919091526060830152608082015260a001610553565b34801561106757600080fd5b50610549611076366004614fe8565b613725565b34801561108757600080fd5b50610549600381565b34801561109c57600080fd5b506105326110ab366004614fe8565b61374f565b3480156110bc57600080fd5b506105326110cb36600461504a565b61379c565b3480156110dc57600080fd5b506105496110eb366004614fe8565b6137da565b3480156110fc57600080fd5b5061054961110b366004614fe8565b6101156020526000908152604090205481565b34801561112a57600080fd5b50610549611139366004614fe8565b61380d565b34801561114a57600080fd5b50610532611159366004614fe8565b613821565b34801561116a57600080fd5b5061053261117936600461504a565b6138b9565b34801561118a57600080fd5b50610549611199366004614fe8565b60d66020526000908152604090205481565b3480156111b757600080fd5b506105326111c63660046153ec565b6138f7565b3480156111d757600080fd5b506105326111e6366004615262565b613c50565b3480156111f757600080fd5b50610532611206366004615448565b613e5e565b34801561121757600080fd5b50610549611226366004615031565b613f62565b6097546001600160a01b0316331461125e5760405162461bcd60e51b8152600401611255906154a8565b60405180910390fd5b60db80546001600160a01b0319166001600160a01b0392909216919091179055565b60cc602052816000526040600020816002811061129c57600080fd5b01549150829050565b60ee81600481106112b557600080fd5b0154905081565b6001600160a01b038116600090815260d7602052604081206002015460ee81600481106112eb576112eb6154dd565b01549392505050565b6097546001600160a01b0316331461131e5760405162461bcd60e51b8152600401611255906154a8565b8060f28360048110611332576113326154dd565b01555050565b6001600160a01b038116600090815260d7602052604081206003015460f281600481106112eb576112eb6154dd565b6097546001600160a01b031633146113915760405162461bcd60e51b8152600401611255906154a8565b8060e28360068110611332576113326154dd565b6097546001600160a01b031633146113cf5760405162461bcd60e51b8152600401611255906154a8565b61011355565b6000806113e183613f72565b9050601481036113f45750600092915050565b60ff611401600183615509565b60148110611411576114116154dd565b015460ff8260148110611426576114266154dd565b01546114329190615509565b9392505050565b60e881600681106112b557600080fd5b33600061145582613f72565b9050600181116114a75760405162461bcd60e51b815260206004820152601860248201527f796f7520617265207374696c6c206174206c6576656c203100000000000000006044820152606401611255565b6114b082613ffc565b600083815260d06020908152604091829020825160a0810184528154815260018201546001600160a01b03908116938201849052600283015494820194909452600382015460608201526004909101546080820152918416146115255760405162461bcd60e51b815260040161125590615520565b61152f848461402f565b6001600160a01b038316600090815260d760205260408120818155600180820183905560028201839055600382018390556004909101919091556115739083615509565b6001600160a01b038416600081815260d660209081526040918290209390935580519182529181018490527f368a2f7ca65548f6d12e89fb0e783a1a73e53164519cf1b75c74a51ef9ef323391015b60405180910390a150505050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036116185760405162461bcd60e51b815260040161125590615550565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166116616000805160206157d5833981519152546001600160a01b031690565b6001600160a01b0316146116875760405162461bcd60e51b81526004016112559061559c565b61169081614130565b604080516000808252602082019092526116ac9183919061415a565b50565b6001600160a01b038116600090815260d76020526040808220815160a0810192839052839283928392839283929060059082845b8154815260200190600101908083116116e3575050505050905080600060058110611710576117106154dd565b602090810291909101519082015160408301516060840151608090940151929a91995097509195509350915050565b6097546001600160a01b031633146117695760405162461bcd60e51b8152600401611255906154a8565b428110156117b95760405162461bcd60e51b815260206004820152601f60248201527f737461727454696d652063616e6e6f7420626520696e207468652070617374006044820152606401611255565b60da55565b6097546001600160a01b031633146117e85760405162461bcd60e51b8152600401611255906154a8565b60dd80546001600160a01b0319166001600160a01b0392909216919091179055565b60ff81601481106112b557600080fd5b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036118625760405162461bcd60e51b815260040161125590615550565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166118ab6000805160206157d5833981519152546001600160a01b031690565b6001600160a01b0316146118d15760405162461bcd60e51b81526004016112559061559c565b6118da82614130565b6118e68282600161415a565b5050565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461198a5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401611255565b506000805160206157d583398151915290565b600060da546000141580156119b4575060da544210155b905090565b60d954339084106119ff5760405162461bcd60e51b815260206004820152601060248201526f696e76616c696420637570207479706560801b6044820152606401611255565b6000611a0a82612f8e565b9050611a1582613ffc565b600085815260d860209081526040808320815160e081018352815481526001820154938101939093526002810154918301919091526003810154606083015260048101546080830152600581015460a0830152600601546001600160a01b031660c08201529084906064611a898582615509565b838560a00151611a9991906155e8565b611aa391906155e8565b611aad9190615607565b60c08401516040516370a0823160e01b81526001600160a01b0388811660048301529293508392909116906370a0823190602401602060405180830381865afa158015611afe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b229190615629565b1015611b695760405162461bcd60e51b81526020600482015260166024820152756e6f74206861766520656e6f75676820746f6b656e7360501b6044820152606401611255565b60c0830151611b85906001600160a01b03168661dead846142ca565b611b8e8561323e565b6001600160a01b038616600090815260d36020526040902054611bb2908490615642565b1115611bf95760405162461bcd60e51b8152602060048201526016602482015275696e76616c6964206e756d626572206f66206375707360501b6044820152606401611255565b60005b82811015611e8a576000888883818110611c1857611c186154dd565b60dc546040516331a9108f60e11b815260209290920293909301356004820181905293506001600160a01b038a811693169150636352211e90602401602060405180830381865afa158015611c71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c95919061565a565b6001600160a01b031614611ceb5760405162461bcd60e51b815260206004820152601760248201527f596f7520646f6e2774206f776e207468697320746f6f6c0000000000000000006044820152606401611255565b602085015160dc54604051630219207560e61b8152600481018490526001600160a01b03909116906386481d4090602401602060405180830381865afa158015611d39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5d9190615629565b14611dbc5760405162461bcd60e51b815260206004820152602960248201527f596f752063616e277420757365207468697320746f6f6c20666f722074686973604482015268206375702073697a6560b81b6064820152608401611255565b611dc6878b6143f2565b60dc546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90611dfc908a9061dead908690600401615677565b600060405180830381600087803b158015611e1657600080fd5b505af1158015611e2a573d6000803e3d6000fd5b505050507f0a080f5c4271f75b56c4ed66c410cea4891826883ec2fa9bbfefca8dcf7a05ef87600160d454611e5f9190615509565b8c604051611e6f9392919061569b565b60405180910390a15080611e82816156bc565b915050611bfc565b505050505050505050565b6097546001600160a01b03163314611ebf5760405162461bcd60e51b8152600401611255906154a8565b60e055565b600080611ed083613f72565b6001600160a01b038416600090815260d560205260409020549091506013198201611eff575060009392505050565b60ff611f0c600184615509565b60148110611f1c57611f1c6154dd565b0154611f289082615509565b949350505050565b6001600160a01b038316600090815260cf60205260409020546060908310611f97576040805160008082526020820190925290611f8f565b6040805180820190915260008082526020820152815260200190600190039081611f685790505b509050611432565b6001600160a01b038416600090815260cf60205260409020548290611fbc8286615642565b10611fe8576001600160a01b038516600090815260cf6020526040902054611fe5908590615509565b90505b60008167ffffffffffffffff8111156120035761200361506c565b60405190808252806020026020018201604052801561204857816020015b60408051808201909152600080825260208201528152602001906001900390816120215790505b50905060005b8281101561213c576001600160a01b038716600090815260cd6020526040812081612079848a615642565b81526020808201929092526040908101600020548151808301835281815260db549251630806d56f60e31b815260048101839052919450928301916001600160a01b031690634036ab7890602401602060405180830381865afa1580156120e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121089190615629565b81525083838151811061211d5761211d6154dd565b6020026020010181905250508080612134906156bc565b91505061204e565b5095945050505050565b6000806000612154846112bc565b905060005b6001600160a01b038516600090815260d36020526040902054811015612236576001600160a01b03808616600090815260d160209081526040808320858452825280832054835260d08252808320815160a08101835281548152600182015490951685840152600281015485830181905260038083015460608801526004909201546080870152845260d890925290912001546121f7908490615642565b81606001511161222357604080820151600090815260d860205220600201546122209085615642565b93505b508061222e816156bc565b915050612159565b50909392505050565b6097546001600160a01b031633146122695760405162461bcd60e51b8152600401611255906154a8565b61227360006144c8565b565b60f281600481106112b557600080fd5b60e281600681106112b557600080fd5b60006122a082613f72565b92915050565b6097546001600160a01b031633146122d05760405162461bcd60e51b8152600401611255906154a8565b60de55565b60fa81600581106112b557600080fd5b6122ed61199d565b6123345760405162461bcd60e51b8152602060048201526018602482015277151a194819d85b59481a185cc81b9bdd081cdd185c9d195960421b6044820152606401611255565b3361233e81613ffc565b8160005b818110156125f457600085858381811061235e5761235e6154dd565b60db546040516331a9108f60e11b815260209290920293909301356004820181905293506001600160a01b0387811693169150636352211e90602401602060405180830381865afa1580156123b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123db919061565a565b6001600160a01b03161461242c5760405162461bcd60e51b81526020600482015260186024820152772cb7ba903237b713ba1037bbb7103a3434b9903a37b5b2b760411b6044820152606401611255565b60db60009054906101000a90046001600160a01b03166001600160a01b0316639a36b7a96040518163ffffffff1660e01b8152600401602060405180830381865afa15801561247f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a39190615629565b60db54604051630806d56f60e31b8152600481018490526001600160a01b0390911690634036ab7890602401602060405180830381865afa1580156124ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125109190615629565b03612546576001600160a01b038416600090815260cc6020526040812060010180549161253c836156bc565b9190505550612570565b6001600160a01b038416600090815260cc6020526040812080549161256a836156bc565b91905055505b61257a818561451a565b60db546040516323b872dd60e01b81526001600160a01b03909116906323b872dd906125ae90879030908690600401615677565b600060405180830381600087803b1580156125c857600080fd5b505af11580156125dc573d6000803e3d6000fd5b505050505080806125ec906156bc565b915050612342565b5050505050565b6097546001600160a01b031633146126255760405162461bcd60e51b8152600401611255906154a8565b61011455565b6097546001600160a01b031633146126555760405162461bcd60e51b8152600401611255906154a8565b600081116126b35760405162461bcd60e51b815260206004820152602560248201527f4465706f7369742076616c7565206d757374206265206772656174657220746860448201526430b710181760d91b6064820152608401611255565b60dd546116ac906001600160a01b03163330846142ca565b3360006127106126da83613725565b6126e5906064615642565b6126ee84611338565b6126f9906064615642565b6101145461270686612146565b61271091906155e8565b61271a91906155e8565b61272491906155e8565b61272e9190615607565b610116546040516370a0823160e01b81526001600160a01b0385811660048301529293508392909116906370a0823190602401602060405180830381865afa15801561277e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127a29190615629565b10156127e35760405162461bcd60e51b815260206004820152601060248201526f6e6f7420656e6f7567682050495a5a4160801b6044820152606401611255565b610116546040516323b872dd60e01b81526001600160a01b03909116906323b872dd9061281a90859061dead908690600401615677565b6020604051808303816000875af1158015612839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061285d91906156d5565b5061286782613ffc565b6128744262015180615642565b6001600160a01b039092166000908152610115602052604090209190915550565b6001600160a01b038316600090815260d360205260409020546060908310612927576040805160008082526020820190925290611f8f565b61290d6040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001906001900390816128cd579050509050611432565b6001600160a01b038416600090815260d36020526040902054829061294c8286615642565b10612978576001600160a01b038516600090815260d36020526040902054612975908590615509565b90505b60008167ffffffffffffffff8111156129935761299361506c565b604051908082528060200260200182016040528015612a0457816020015b6129f16040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001906001900390816129b15790505b5090506000612a12876112bc565b90506000612a1f88612f8e565b90506000612a2c896137da565b905060005b85811015612c23576001600160a01b038a16600090815260d16020526040812081612a5c848d615642565b8152602080820192909252604090810160009081205480825260d08452828220835160a08082018652825482526001808401546001600160a01b03908116848a0152600280860154858a018190526003808801546060808901919091526004988901546080808a0191909152928b5260d88d528b8b208c5160e081018e5281548152968101549d87019d909d52928c01549a85019a909a52988a0154908301819052948901549782019790975260058801549181019190915260069096015490941660c0860152909450919291612b34908990615642565b905060006064612b448982615509565b60048560a001518760800151612b5a91906155e8565b612b649190615607565b8560a00151612b739190615642565b612b7d91906155e8565b612b879190615607565b90506064612b958882615509565b612b9f90836155e8565b612ba99190615607565b90506040518060e0016040528086815260200185604001518152602001846040015181526020018560600151815260200183815260200185608001518152602001828152508a8781518110612c0057612c006154dd565b602002602001018190525050505050508080612c1b906156bc565b915050612a31565b509298975050505050505050565b33600081815260d66020526040902054612c8d5760405162461bcd60e51b815260206004820152601760248201527f4e6f7420656e6f75676820736b696c6c20706f696e74730000000000000000006044820152606401611255565b612c9960016005615509565b831115612cde5760405162461bcd60e51b81526020600482015260136024820152720496e76616c696420536b696c6c2047726f757606c1b6044820152606401611255565b60018210158015612d03575060fa8360058110612cfd57612cfd6154dd565b01548211155b612d455760405162461bcd60e51b8152602060048201526013602482015272125b9d985b1a590814dada5b1b0813195d995b606a1b6044820152606401611255565b6001600160a01b038116600090815260d7602052604081208460058110612d6e57612d6e6154dd565b01549050612d7d816001615642565b8314612dcb5760405162461bcd60e51b815260206004820152601860248201527f496e76616c696420536b696c6c204c6576656c206a756d7000000000000000006044820152606401611255565b6001600160a01b038216600090815260d76020526040902083908560058110612df657612df66154dd565b01556001600160a01b038216600090815260d660205260408120805491612e1c836156f7565b91905055507f02fea7e54a35a3ee09c63260b2dd902669f9c351cc6b0ec6b15f84f361fa80008285856040516115c29392919061569b565b6097546001600160a01b03163314612e7e5760405162461bcd60e51b8152600401611255906154a8565b60dd546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015612ec6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eea9190615629565b811115612f2b5760405162461bcd60e51b815260206004820152600f60248201526e6e6f7420656e6f75676820736f646160881b6044820152606401611255565b60dd546116ac906001600160a01b03163383614593565b6097546001600160a01b03163314612f6c5760405162461bcd60e51b8152600401611255906154a8565b60dc80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116600090815260d7602052604081206001015460e881600681106112eb576112eb6154dd565b33612fc781613ffc565b8160005b818110156125f4576000858583818110612fe757612fe76154dd565b60209081029290920135600081815260c9909352604090922054919250506001600160a01b0385811691161461305a5760405162461bcd60e51b81526020600482015260186024820152772cb7ba903237b713ba1037bbb7103a3434b9903a37b5b2b760411b6044820152606401611255565b60db60009054906101000a90046001600160a01b03166001600160a01b0316639a36b7a96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130d19190615629565b60db54604051630806d56f60e31b8152600481018490526001600160a01b0390911690634036ab7890602401602060405180830381865afa15801561311a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061313e9190615629565b03613174576001600160a01b038416600090815260cc6020526040812060010180549161316a836156f7565b919050555061319e565b6001600160a01b038416600090815260cc60205260408120805491613198836156f7565b91905055505b6131a881856146a7565b60db546040516323b872dd60e01b81526001600160a01b03909116906323b872dd906131dc90309088908690600401615677565b600060405180830381600087803b1580156131f657600080fd5b505af115801561320a573d6000803e3d6000fd5b5050505050808061321a906156bc565b915050612fcb565b60d7602052816000526040600020816005811061129c57600080fd5b6001600160a01b038116600090815260d7602052604081205460e281600681106112eb576112eb6154dd565b6097546001600160a01b031633146132945760405162461bcd60e51b8152600401611255906154a8565b6040805160e08101825260d9805480835260208084018b81528486018b8152606086018b8152608087018b815260a088018b81526001600160a01b038b811660c08b01908152600098895260d890975299872098518955935160018901559151600288015551600387015551600486015551600585015551600690930180546001600160a01b031916939094169290921790925581549190613335836156bc565b9190505550505050505050565b33600061334e826137da565b9050600061335b83612f8e565b905061336683613ffc565b8360005b8181101561354d576000878783818110613386576133866154dd565b60209081029290920135600081815260d090935260409092206001810154929350916001600160a01b0389811691161490506133d45760405162461bcd60e51b815260040161125590615520565b600280820154600090815260d860209081526040808320815160e0810183528154815260018201549381019390935293840154908201526003830154606082015260048301546080820152600583015460a08201526006909201546001600160a01b031660c083015260646134498882615509565b60048460a00151866004015461345f91906155e8565b6134699190615607565b8460a001516134789190615642565b61348291906155e8565b61348c9190615607565b9050606461349a8982615509565b6134a490836155e8565b6134ae9190615607565b60c08301519091506134cd906001600160a01b03168a61dead846142ca565b600060038401819055600484018054916134e6836156bc565b91905055507f054c3f2472912f0cd81c399b9cc4a5d1540370f2257d5332d36c1a229824fadd89856001866004015461351f9190615509565b60405161352e9392919061569b565b60405180910390a1505050508080613545906156bc565b91505061336a565b50505050505050565b6060600060d95467ffffffffffffffff8111156135755761357561506c565b6040519080825280602002602001820160405280156135ef57816020015b6135dc6040518060e0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b8152602001906001900390816135935790505b50905060005b60d95481101561369957600081815260d86020908152604091829020825160e081018452815481526001820154928101929092526002810154928201929092526003820154606082015260048201546080820152600582015460a08201526006909101546001600160a01b031660c0820152825183908390811061367b5761367b6154dd565b60200260200101819052508080613691906156bc565b9150506135f5565b50919050565b6097546001600160a01b031633146136c95760405162461bcd60e51b8152600401611255906154a8565b8060f68360048110611332576113326154dd565b6097546001600160a01b031633146137075760405162461bcd60e51b8152600401611255906154a8565b8060ee8360048110611332576113326154dd565b336116ac81614781565b60de546001600160a01b038216600090815260cc602052604081206001015490916122a0916155e8565b6097546001600160a01b031633146137795760405162461bcd60e51b8152600401611255906154a8565b61011680546001600160a01b0319166001600160a01b0392909216919091179055565b6097546001600160a01b031633146137c65760405162461bcd60e51b8152600401611255906154a8565b8060ff8360148110611332576113326154dd565b6001600160a01b038116600090815260d760205260408120819060040154905060f681600481106112eb576112eb6154dd565b60006122a08261381c84612146565b61498d565b6097546001600160a01b0316331461384b5760405162461bcd60e51b8152600401611255906154a8565b6001600160a01b0381166138b05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401611255565b6116ac816144c8565b6097546001600160a01b031633146138e35760405162461bcd60e51b8152600401611255906154a8565b8060e88360068110611332576113326154dd565b600054610100900460ff166139125760005460ff1615613916565b303b155b6139795760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401611255565b600054610100900460ff1615801561399b576000805461ffff19166101011790555b60db80546001600160a01b038088166001600160a01b03199283161790925560dd805486841690831617905560dc805487841690831617905560e1805492851692909116919091179055600a60de81905560e0908155604080516102808101825260008152600160208201526002818301526004606082015260066080820152600960a0820152600c60c0820152601092810192909252601461010083018190526019610120840152601e6101408401526024610160840152602a61018084015260316101a084015260386101c08401526101e083019190915260486102008301526051610220830152605a6102408301526064610260830152613aa19160ff91614ee9565b506040805160c0810182526003815260056020820152600891810191909152600c606082015260106080820152601460a0820152613ae39060e2906006614f2c565b506040805160c081018252600081526002602082015260049181019190915260066060820181905260086080830152606460a0830152613b259160e891614f2c565b50604080516080810182526000815260016020820152600291810191909152600460608201819052613b599160ee91614f5e565b50604080516080810182526000815260056020820152600a9181019190915260146060820152613b8d9060f2906004614f5e565b506040805160808101825260008152600a6020820152601491810191909152601e6060820152613bc19060f6906004614f5e565b506040518060a0016040528060016006613bdb9190615509565b8152602001613bec60016006615509565b8152602001613bfd60016004615509565b8152602001613c0e60016004615509565b8152602001613c1f60016004615509565b9052613c2f9060fa906005614f90565b50613c38614c64565b80156125f4576000805461ff00191690555050505050565b33613c5961199d565b613ca05760405162461bcd60e51b8152602060048201526018602482015277151a194819d85b59481a185cc81b9bdd081cdd185c9d195960421b6044820152606401611255565b613ca981613ffc565b600082815b81811015613d8d576000868683818110613cca57613cca6154dd565b60209081029290920135600081815260d08452604090819020815160a0810183528154815260018201546001600160a01b039081169682018790526002830154938201939093526003820154606082015260049091015460808201529194509092908816149050613d4d5760405162461bcd60e51b815260040161125590615520565b613d57828761402f565b604080820151600090815260d86020522060040154613d769086615642565b945050508080613d85906156bc565b915050613cae565b506000613d9984613f72565b6001600160a01b038516600090815260d56020526040812080549293508592909190613dc6908490615642565b9091555060009050613dd785613f72565b9050613de38282615509565b6001600160a01b038616600090815260d6602052604081208054909190613e0b908490615642565b909155507fd8f433803ffa7bf6c0ee5bdb8fefd01ce91c93334b599063fc19360a55858f7890508584613e3e8585615509565b604051613e4d9392919061569b565b60405180910390a150505050505050565b6097546001600160a01b03163314613e885760405162461bcd60e51b8152600401611255906154a8565b60d954871115613ece5760405162461bcd60e51b81526020600482015260116024820152701a5b9d985b1a590818dd5c081b195d995b607a1b6044820152606401611255565b6040805160e0810182528881526020808201988952818301978852606082019687526080820195865260a082019485526001600160a01b0393841660c0830190815260009a8b5260d890915291909820975188559551600188015593516002870155915160038601555160048501555160058401559051600690920180546001600160a01b03191692909116919091179055565b60f681600481106112b557600080fd5b6001600160a01b038116600090815260d5602052604081205481613f9860016014615509565b905060005b81811015613ff15760ff613fb2826001615642565b60148110613fc257613fc26154dd565b0154831015613fdf57613fd6816001615642565b95945050505050565b80613fe9816156bc565b915050613f9d565b506014949350505050565b6140058161380d565b6001600160a01b03909116600090815260ca602090815260408083209390935560cb905220429055565b600082815260d060209081526040808320838155600180820180546001600160a01b0319169055600282018590556003820185905560049091018490556001600160a01b038516845260d390925282205461408a9190615509565b600084815260d260205260409020549091508082146140dd576001600160a01b038316600090815260d160209081526040808320858452825280832054848452818420819055835260d290915290208190555b600084815260d2602090815260408083208390556001600160a01b03861680845260d183528184208685528352818420849055835260d39091528120805491614125836156f7565b919050555050505050565b6097546001600160a01b031633146116ac5760405162461bcd60e51b8152600401611255906154a8565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156141925761418d83614c93565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156141ec575060408051601f3d908101601f191682019092526141e991810190615629565b60015b61424f5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401611255565b6000805160206157d583398151915281146142be5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401611255565b5061418d838383614d2f565b600080856001600160a01b03166323b872dd60e01b8686866040516024016142f493929190615677565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051614332919061573a565b6000604051808303816000865af19150503d806000811461436f576040519150601f19603f3d011682016040523d82523d6000602084013e614374565b606091505b509150915081801561439e57508051158061439e57508080602001905181019061439e91906156d5565b6143ea5760405162461bcd60e51b815260206004820181905260248201527f426f72696e6745524332303a205472616e7366657246726f6d206661696c65646044820152606401611255565b505050505050565b6040805160a08101825260d480548083526001600160a01b03868116602080860182815286880189815260006060890181815260808a0182815297825260d085528a822099518a55925160018a0180546001600160a01b03191691909716179095555160028801555160038701559251600490950194909455915483835260d1825284832060d380845286852080548652918452868520839055815492855260d284529584208290559383529390526144aa836156bc565b909155505060d480549060006144bf836156bc565b91905055505050565b609780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600082815260c96020908152604080832080546001600160a01b0319166001600160a01b03861690811790915580845260cf808452828520805460cd8652848720818852865284872089905588875260ce865293862084905591855290925281549092909190614589836156bc565b9190505550505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916145ef919061573a565b6000604051808303816000865af19150503d806000811461462c576040519150601f19603f3d011682016040523d82523d6000602084013e614631565b606091505b509150915081801561465b57508051158061465b57508080602001905181019061465b91906156d5565b6125f45760405162461bcd60e51b815260206004820152601c60248201527f426f72696e6745524332303a205472616e73666572206661696c6564000000006044820152606401611255565b600082815260c96020908152604080832080546001600160a01b03191690556001600160a01b038416835260cf9091528120546146e690600190615509565b600084815260ce6020526040902054909150808214614739576001600160a01b038316600090815260cd60209081526040808320858452825280832054848452818420819055835260ce90915290208190555b600084815260ce602090815260408083208390556001600160a01b03861680845260cd83528184208685528352818420849055835260cf9091528120805491614125836156f7565b60008061478d836112bc565b905060005b6001600160a01b038416600090815260d360205260409020548110156148b1576001600160a01b03808516600090815260d160209081526040808320858452825280832054835260d08252808320815160a08101835281548152600182015490951685840152600281015485830181905260038083015460608801526004909201546080870152845260d89092529091200154614830908490615642565b81606001511161489e57604080820151600090815260d860205220600201546148599085615642565b6001600160a01b038616600090815260d160209081526040808320868452825280832054835260d09091528120600301805492965090614898836156bc565b91905055505b50806148a9816156bc565b915050614792565b5060006148be848461498d565b6001600160a01b038516600090815260ca6020908152604080832083905560cb909152812042905560e054919250906064906148fa90846155e8565b6149049190615607565b9050614927856149148385615509565b60dd546001600160a01b03169190614593565b60e15460dd54614944916001600160a01b03918216911683614593565b604080516001600160a01b0387168152602081018490527f4dd6c8de072db5939c4dc757de920d64bcbef063a41150ae51deb4f125032ddf910160405180910390a15050505050565b6001600160a01b038216600090815260d3602090815260408083205460cc9092528220600181015490546149c19190615642565b10156149e657506001600160a01b038216600090815260ca60205260409020546122a0565b6001600160a01b0383166000908152610115602090815260408083205460cb9092529091205442818311614ab4576000614a208383615509565b9050612710614a2e88613725565b614a39906064615642565b614a4289611338565b614a4d906064615642565b83614a5e8a650a86cc92e3db6155e8565b614a6891906155e8565b614a7291906155e8565b614a7c91906155e8565b614a869190615607565b6001600160a01b038816600090815260ca6020526040902054614aa99190615642565b9450505050506122a0565b808310614b1f576000614ac78383615509565b9050620f4240614ad688613725565b614ae1906064615642565b614aea89611338565b614af5906064615642565b61011354614b04906064615642565b84614b158b650a86cc92e3db6155e8565b614a5e91906155e8565b6000614b2b8385615509565b90506000620f4240614b3c89613725565b614b47906064615642565b614b508a611338565b614b5b906064615642565b61011354614b6a906064615642565b85614b7b8c650a86cc92e3db6155e8565b614b8591906155e8565b614b8f91906155e8565b614b9991906155e8565b614ba391906155e8565b614bad9190615607565b90506000614bbb8685615509565b90506000612710614bcb8b613725565b614bd6906064615642565b614bdf8c611338565b614bea906064615642565b84614bfb8d650a86cc92e3db6155e8565b614c0591906155e8565b614c0f91906155e8565b614c1991906155e8565b614c239190615607565b6001600160a01b038b16600090815260ca60205260409020549091508190614c4c908590615642565b614c569190615642565b9a9950505050505050505050565b600054610100900460ff16614c8b5760405162461bcd60e51b815260040161125590615756565b612273614d5a565b6001600160a01b0381163b614d005760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401611255565b6000805160206157d583398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b614d3883614d8a565b600082511180614d455750805b1561418d57614d548383614dca565b50505050565b600054610100900460ff16614d815760405162461bcd60e51b815260040161125590615756565b612273336144c8565b614d9381614c93565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b614e325760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401611255565b600080846001600160a01b031684604051614e4d919061573a565b600060405180830381855af49150503d8060008114614e88576040519150601f19603f3d011682016040523d82523d6000602084013e614e8d565b606091505b5091509150613fd682826040518060600160405280602781526020016157f56027913960608315614ebf575081611432565b825115614ecf5782518084602001fd5b8160405162461bcd60e51b815260040161125591906157a1565b8260148101928215614f1c579160200282015b82811115614f1c578251829060ff16905591602001919060010190614efc565b50614f28929150614fbe565b5090565b8260068101928215614f1c5791602002820182811115614f1c578251829060ff16905591602001919060010190614efc565b8260048101928215614f1c5791602002820182811115614f1c578251829060ff16905591602001919060010190614efc565b8260058101928215614f1c579160200282015b82811115614f1c578251825591602001919060010190614fa3565b5b80821115614f285760008155600101614fbf565b6001600160a01b03811681146116ac57600080fd5b600060208284031215614ffa57600080fd5b813561143281614fd3565b6000806040838503121561501857600080fd5b823561502381614fd3565b946020939093013593505050565b60006020828403121561504357600080fd5b5035919050565b6000806040838503121561505d57600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561509557600080fd5b82356150a081614fd3565b9150602083013567ffffffffffffffff808211156150bd57600080fd5b818501915085601f8301126150d157600080fd5b8135818111156150e3576150e361506c565b604051601f8201601f19908116603f0116810190838211818310171561510b5761510b61506c565b8160405282815288602084870101111561512457600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60008083601f84011261515857600080fd5b50813567ffffffffffffffff81111561517057600080fd5b6020830191508360208260051b850101111561518b57600080fd5b9250929050565b6000806000604084860312156151a757600080fd5b83359250602084013567ffffffffffffffff8111156151c557600080fd5b6151d186828701615146565b9497909650939450505050565b6000806000606084860312156151f357600080fd5b83356151fe81614fd3565b95602085013595506040909401359392505050565b602080825282518282018190526000919060409081850190868401855b8281101561525557815180518552860151868501529284019290850190600101615230565b5091979650505050505050565b6000806020838503121561527557600080fd5b823567ffffffffffffffff81111561528c57600080fd5b61529885828601615146565b90969095509350505050565b602080825282518282018190526000919060409081850190868401855b828110156152555781518051855286810151878601528581015186860152606080820151908601526080808201519086015260a0808201519086015260c0908101519085015260e090930192908501906001016152c1565b60008060008060008060c0878903121561533257600080fd5b863595506020870135945060408701359350606087013592506080870135915060a087013561536081614fd3565b809150509295509295509295565b602080825282518282018190526000919060409081850190868401855b828110156152555781518051855286810151878601528581015186860152606080820151908601526080808201519086015260a0808201519086015260c0908101516001600160a01b03169085015260e0909301929085019060010161538b565b6000806000806080858703121561540257600080fd5b843561540d81614fd3565b9350602085013561541d81614fd3565b9250604085013561542d81614fd3565b9150606085013561543d81614fd3565b939692955090935050565b600080600080600080600060e0888a03121561546357600080fd5b873596506020880135955060408801359450606088013593506080880135925060a0880135915060c088013561549881614fd3565b8091505092959891949750929550565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008282101561551b5761551b6154f3565b500390565b6020808252601690820152750596f7520646f6e2774206f776e2074686973206375760541b604082015260600190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6000816000190483118215151615615602576156026154f3565b500290565b60008261562457634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561563b57600080fd5b5051919050565b60008219821115615655576156556154f3565b500190565b60006020828403121561566c57600080fd5b815161143281614fd3565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039390931683526020830191909152604082015260600190565b6000600182016156ce576156ce6154f3565b5060010190565b6000602082840312156156e757600080fd5b8151801515811461143257600080fd5b600081615706576157066154f3565b506000190190565b60005b83811015615729578181015183820152602001615711565b83811115614d545750506000910152565b6000825161574c81846020870161570e565b9190910192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208152600082518060208401526157c081604085016020870161570e565b601f01601f1916919091016040019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220fcc896653d273db9687cf4d9dca3ba1aa7ced41880e2f3d216a25d339fe03f2a64736f6c634300080f0033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.