Contract 0xB689edEb40B03b205ee53DA549032762ffa36488

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x52a2c7ec368bfa66bbc90574abf6ca7e66129114034b9329c80cfd7e0c8583770x60806040184206202022-07-24 6:54:2572 days 2 hrs ago0x60e788ee9a094c402b6cec03e3fce0ef90944b87 IN  Create: BattleflyAtlasStakerV020 ETH0.009799812128 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x24f8e88d20e67974b1b35f04b2da48381a95d1324982298c11ca32cd1181ea76189753602022-07-30 20:26:2965 days 13 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0xa2282683d5522e3f1316bc1ab869295f269fa61586e134b89c42d2d2cf096eb7189664092022-07-30 17:49:4765 days 15 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0xa2282683d5522e3f1316bc1ab869295f269fa61586e134b89c42d2d2cf096eb7189664092022-07-30 17:49:4765 days 15 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0xa2282683d5522e3f1316bc1ab869295f269fa61586e134b89c42d2d2cf096eb7189664092022-07-30 17:49:4765 days 15 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x42132547c6ef644cb68a34aef8bc1fd5d57400706e09fc8539e498dc9fb40f86189660852022-07-30 17:44:3465 days 15 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x42132547c6ef644cb68a34aef8bc1fd5d57400706e09fc8539e498dc9fb40f86189660852022-07-30 17:44:3465 days 15 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x9b943c202d089a8849fb8e2a1f33a596459f5673a57652ddbd87b3c2c1419a77189658962022-07-30 17:40:1465 days 16 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x9b943c202d089a8849fb8e2a1f33a596459f5673a57652ddbd87b3c2c1419a77189658962022-07-30 17:40:1465 days 16 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x9b943c202d089a8849fb8e2a1f33a596459f5673a57652ddbd87b3c2c1419a77189658962022-07-30 17:40:1465 days 16 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x9b943c202d089a8849fb8e2a1f33a596459f5673a57652ddbd87b3c2c1419a77189658962022-07-30 17:40:1465 days 16 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x1d6ea254493a3523808eea0a503d8949f15828f47042258c538433e961af1b95189653302022-07-30 17:30:3365 days 16 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x1d6ea254493a3523808eea0a503d8949f15828f47042258c538433e961af1b95189653302022-07-30 17:30:3365 days 16 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x1d6ea254493a3523808eea0a503d8949f15828f47042258c538433e961af1b95189653302022-07-30 17:30:3365 days 16 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x1d6ea254493a3523808eea0a503d8949f15828f47042258c538433e961af1b95189653302022-07-30 17:30:3365 days 16 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0xd166e6f438a449c6fc91675e44d643d85c07e998473d5ea8bd2a716080e7671e189633432022-07-30 16:58:2165 days 16 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0xd166e6f438a449c6fc91675e44d643d85c07e998473d5ea8bd2a716080e7671e189633432022-07-30 16:58:2165 days 16 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x35db6a71723b2de059b2b1e5d2237f6acd6a0e2732c079c0fb0f135bb012efd0189612332022-07-30 16:22:0465 days 17 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x35db6a71723b2de059b2b1e5d2237f6acd6a0e2732c079c0fb0f135bb012efd0189612332022-07-30 16:22:0465 days 17 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0xfa2ad918830bfa48d47abed75c39918e242cddb5e6e1efd5a55d4716c01f45b6189609472022-07-30 16:18:3265 days 17 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0xfa2ad918830bfa48d47abed75c39918e242cddb5e6e1efd5a55d4716c01f45b6189609472022-07-30 16:18:3265 days 17 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0xfa6aedcf04d62fe6254379127dee2505cae5824effa0c9f761c707fa31b51f90189602042022-07-30 16:06:4965 days 17 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0xfa6aedcf04d62fe6254379127dee2505cae5824effa0c9f761c707fa31b51f90189602042022-07-30 16:06:4965 days 17 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0xb620f1ba1baaf949bb2a9410b9679a5de6320c2d7b645f7a8e0094949e9efb65189583052022-07-30 15:40:0365 days 18 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0xb620f1ba1baaf949bb2a9410b9679a5de6320c2d7b645f7a8e0094949e9efb65189583052022-07-30 15:40:0365 days 18 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
0x8719a107e34dd4a5cc66daccf10d319979321a18857cfe595beb2804a2889a72188921222022-07-29 18:49:1666 days 14 hrs ago 0x419c20605be94f728a03a7fbceb8a4f3412b2693 0xb689edeb40b03b205ee53da549032762ffa364880 ETH
[ Download CSV Export 
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:
BattleflyAtlasStakerV02

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion
File 1 of 24 : BattleflyAtlasStakerV02.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155HolderUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import "./interfaces/IAtlasMine.sol";
import "./interfaces/IBattleflyAtlasStakerV02.sol";
import "./interfaces/IVault.sol";
import "./libraries/BattleflyAtlasStakerUtils.sol";
import "./interfaces/vaults/IBattleflyTreasuryFlywheelVault.sol";

/// @custom:oz-upgrades-unsafe-allow external-library-linking
contract BattleflyAtlasStakerV02 is
    IBattleflyAtlasStakerV02,
    Initializable,
    OwnableUpgradeable,
    ERC1155HolderUpgradeable,
    ERC721HolderUpgradeable,
    ReentrancyGuardUpgradeable
{
    using AddressUpgradeable for address;
    using SafeCastUpgradeable for uint256;
    using SafeCastUpgradeable for int256;
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet;

    // ========== CONSTANTS ==========

    uint96 public constant FEE_DENOMINATOR = 10000;
    uint256 public constant ONE = 1e28;
    address public BATTLEFLY_BOT;

    IERC20Upgradeable public override MAGIC;
    IAtlasMine public ATLAS_MINE;
    IBattleflyTreasuryFlywheelVault public TREASURY_VAULT;

    IAtlasMine.Lock[] public LOCKS;
    IAtlasMine.Lock[] public allowedLocks;

    // ========== Operator States ==========
    uint256 public override currentDepositId;
    uint64 public override currentEpoch;
    uint256 public pausedUntil;
    uint256 public nextExecution;

    /**
     * @dev active positionIds in AtlasMine for this contract.
     *
     */
    EnumerableSetUpgradeable.UintSet private activePositionIds;

    /**
     * @dev Total emissions harvested from Atlas Mine for a particular lock period and epoch
     *      { lock } => { epoch } => { emissions }
     */
    mapping(IAtlasMine.Lock => mapping(uint64 => uint256)) private totalEmissionsAtEpochForLock;

    /**
     * @dev Total amount of magic staked in Atlas Mine for a particular lock period and epoch
     *      { lock } => { epoch } => { magic }
     */
    mapping(IAtlasMine.Lock => mapping(uint64 => uint256)) private totalStakedAtEpochForLock;

    /**
     * @dev Total amount of emissions per share in magic for a particular lock period and epoch
     *      { lock } => { epoch } => { emissionsPerShare }
     */
    mapping(IAtlasMine.Lock => mapping(uint64 => uint256)) private totalPerShareAtEpochForLock;

    /**
     * @dev Total amount of unstaked Magic at a particular epoch
     *      { epoch } => { unstaked magic }
     */
    mapping(uint64 => uint256) private unstakeAmountAtEpoch;

    /**
     * @dev Legion ERC721 NFT stakers data
     *      { tokenId } => { depositor }
     */
    mapping(uint256 => address) public legionStakers;

    /**
     * @dev TREASURE ERC1155 NFT stakers data
     *      { tokenId } => { depositor } => { deposit amount }
     */
    mapping(uint256 => mapping(address => uint256)) public treasureStakers;

    /**
     * @dev Vaultstakes per depositId
     *      { depositId } => { VaultStake }
     */
    mapping(uint256 => VaultStake) public vaultStakes;

    /**
     * @dev Vaults' all deposits
     *      { address } => { depositId }
     */
    mapping(address => EnumerableSetUpgradeable.UintSet) private depositIdByVault;

    /**
     * @dev Magic amount that is not staked to AtlasMine
     *      { Lock } => { unstaked amount }
     */
    mapping(IAtlasMine.Lock => uint256) public unstakedAmount;

    // ========== Access Control States ==========
    mapping(address => bool) public superAdmins;

    /**
     * @dev Whitelisted vaults
     *      { vault address } => { Vault }
     */
    mapping(address => Vault) public vaults;

    function initialize(
        address _magic,
        address _atlasMine,
        address _treasury,
        address _battleflyBot,
        IAtlasMine.Lock[] memory _allowedLocks
    ) external initializer {
        __ERC1155Holder_init();
        __ERC721Holder_init();
        __Ownable_init();
        __ReentrancyGuard_init();

        require(_magic != address(0), "BattleflyAtlasStaker: invalid address");
        require(_atlasMine != address(0), "BattleflyAtlasStaker: invalid address");
        MAGIC = IERC20Upgradeable(_magic);
        ATLAS_MINE = IAtlasMine(_atlasMine);

        superAdmins[msg.sender] = true;
        LOCKS = [
            IAtlasMine.Lock.twoWeeks,
            IAtlasMine.Lock.oneMonth,
            IAtlasMine.Lock.threeMonths,
            IAtlasMine.Lock.sixMonths,
            IAtlasMine.Lock.twelveMonths
        ];

        nextExecution = block.timestamp;

        setTreasury(_treasury);
        setBattleflyBot(_battleflyBot);
        setAllowedLocks(_allowedLocks);

        approveLegion(true);
        approveTreasure(true);
    }

    // ============================== Vault Operations ==============================

    /**
     * @dev deposit an amount of MAGIC in the AtlasStaker for a particular lock period
     */
    function deposit(uint256 _amount, IAtlasMine.Lock _lock)
        external
        override
        onlyWhitelistedVaults
        nonReentrant
        whenNotPaused
        onlyAvailableLock(_lock)
        returns (uint256)
    {
        require(_amount > 0, "BattflyAtlasStaker: cannot deposit 0");
        // Transfer MAGIC from Vault
        MAGIC.safeTransferFrom(msg.sender, address(this), _amount);

        uint256 newDepositId = ++currentDepositId;
        _deposit(newDepositId, _amount, _lock);
        return newDepositId;
    }

    /**
     * @dev withdraw a vaultstake from the AtlasStaker with a specific depositId
     */
    function withdraw(uint256 _depositId) public override nonReentrant whenNotPaused returns (uint256 amount) {
        VaultStake memory vaultStake = vaultStakes[_depositId];
        require(vaultStake.vault == msg.sender, "BattleflyAtlasStaker: caller is not a correct vault");
        // withdraw can only happen if the retention period has passed.
        require(canWithdraw(_depositId), "BattleflyAtlasStaker: position is locked");

        amount = vaultStake.amount;
        // Withdraw MAGIC to user
        MAGIC.safeTransfer(msg.sender, amount);

        // claim remaining emissions
        (uint256 emission, ) = getClaimableEmission(_depositId);
        if (emission > 0) {
            amount += _claim(_depositId);
        }

        // Reset vault stake data
        delete vaultStakes[_depositId];
        depositIdByVault[msg.sender].remove(_depositId);
        emit WithdrawPosition(msg.sender, amount, _depositId);
    }

    /**
     * @dev Claim emissions from a vaultstake in the AtlasStaker with a specific depositId
     */
    function claim(uint256 _depositId) public override nonReentrant whenNotPaused returns (uint256 amount) {
        amount = _claim(_depositId);
    }

    /**
     * @dev Request a withdrawal for a specific depositId. This is required because the vaultStake will be restaked in blocks of 2 weeks after the unlock period has passed.
     * This function is used to notify the AtlasStaker that it should not restake the vaultStake on the next iteration and the initial stake becomes unlocked.
     */
    function requestWithdrawal(uint256 _depositId) public override nonReentrant whenNotPaused returns (uint64) {
        VaultStake storage vaultStake = vaultStakes[_depositId];
        require(vaultStake.vault == msg.sender, "BattleflyAtlasStaker: caller is not a correct vault");
        require(vaultStake.retentionUnlock == 0, "BattleflyAtlasStaker: withdrawal already requested");
        // Every epoch is 1 day; We can start requesting for a withdrawal 14 days before the unlock period.
        require(currentEpoch >= (vaultStake.unlockAt - 14), "BattleflyAtlasStaker: position not yet unlockable");

        // We set the retention period before the withdrawal can happen to the nearest epoch in the future
        uint64 retentionUnlock = currentEpoch < vaultStake.unlockAt
            ? vaultStake.unlockAt
            : currentEpoch + (14 - ((currentEpoch - vaultStake.unlockAt) % 14));
        vaultStake.retentionUnlock = retentionUnlock - 1 == currentEpoch ? retentionUnlock + 14 : retentionUnlock;
        unstakeAmountAtEpoch[vaultStake.retentionUnlock - 1] += vaultStake.amount;
        emit RequestWithdrawal(msg.sender, vaultStake.retentionUnlock, _depositId);
        return vaultStake.retentionUnlock;
    }

    // ============================== Super Admin Operations ==============================

    /**
     * @dev Execute the daily cron job to deposit funds to AtlasMine & claim emissions from AtlasMine
     *      The Battlefly CRON BOT will use this function to execute deposit/claim.
     */
    function executeAll() external onlyBattleflyBot {
        require(block.timestamp >= nextExecution, "BattleflyAtlasStaker: Executed less than 24h ago");
        // set to 24 hours - 5 minutes to take blockchain tx delays into account.
        nextExecution = block.timestamp + 86100;

        // Harvest all positions from AtlasMine
        _executeHarvestAll();

        // Withdraw all positions from AtlasMine
        _executeWithdrawAll();

        // Possibly correct the amount to be deposited due to users withdrawing their stake.
        _correctForUserWithdrawals();

        // Stake all funds to AtlasMine
        _executeDepositAll();
    }

    /**
     * @dev Approve TREASURE ERC1155 NFT transfer to deposit into AtlasMine contract
     */
    function approveTreasure(bool _approve) public onlySuperAdmin {
        getTREASURE().setApprovalForAll(address(ATLAS_MINE), _approve);
    }

    /**
     * @dev Approve LEGION ERC721 NFT transfer to deposit into AtlasMine contract
     */
    function approveLegion(bool _approve) public onlySuperAdmin {
        getLEGION().setApprovalForAll(address(ATLAS_MINE), _approve);
    }

    /**
     * @dev Stake TREASURE ERC1155 NFT
     */
    function stakeTreasure(uint256 _tokenId, uint256 _amount) external onlySuperAdmin nonReentrant {
        require(_amount > 0, "BattleflyAtlasStaker: Invalid TREASURE amount");

        // Caller's balance check already implemented in _safeTransferFrom() in ERC1155Upgradeable contract
        getTREASURE().safeTransferFrom(msg.sender, address(this), _tokenId, _amount, "");
        treasureStakers[_tokenId][msg.sender] += _amount;

        // Token Approval is already done in constructor
        ATLAS_MINE.stakeTreasure(_tokenId, _amount);
        emit StakedTreasure(msg.sender, _tokenId, _amount);
    }

    /**
     * @dev Unstake TREASURE ERC1155 NFT
     */
    function unstakeTreasure(uint256 _tokenId, uint256 _amount) external onlySuperAdmin nonReentrant {
        require(_amount > 0, "BattleflyAtlasStaker: Invalid TREASURE amount");
        require(treasureStakers[_tokenId][msg.sender] >= _amount, "BattleflyAtlasStaker: Invalid TREASURE amount");
        // Unstake TREASURE from AtlasMine
        ATLAS_MINE.unstakeTreasure(_tokenId, _amount);

        // Transfer TREASURE to the staker
        getTREASURE().safeTransferFrom(address(this), msg.sender, _tokenId, _amount, "");
        treasureStakers[_tokenId][msg.sender] -= _amount;
        emit UnstakedTreasure(msg.sender, _tokenId, _amount);
    }

    /**
     * @dev Stake LEGION ERC721 NFT
     */
    function stakeLegion(uint256 _tokenId) external onlySuperAdmin nonReentrant {
        // TokenId ownership validation is already implemented in safeTransferFrom function
        getLEGION().safeTransferFrom(msg.sender, address(this), _tokenId, "");
        legionStakers[_tokenId] = msg.sender;

        // Token Approval is already done in constructor
        ATLAS_MINE.stakeLegion(_tokenId);
        emit StakedLegion(msg.sender, _tokenId);
    }

    /**
     * @dev Unstake LEGION ERC721 NFT
     */
    function unstakeLegion(uint256 _tokenId) external onlySuperAdmin nonReentrant {
        require(legionStakers[_tokenId] == msg.sender, "BattleflyAtlasStaker: Invalid staker");
        // Unstake LEGION from AtlasMine
        ATLAS_MINE.unstakeLegion(_tokenId);

        // Transfer LEGION to the staker
        getLEGION().safeTransferFrom(address(this), msg.sender, _tokenId, "");
        legionStakers[_tokenId] = address(0);
        emit UnstakedLegion(msg.sender, _tokenId);
    }

    // ============================== Owner Operations ==============================

    /**
     * @dev Add super admin permission
     */
    function addSuperAdmin(address _admin) public onlyOwner {
        require(!superAdmins[_admin], "BattleflyAtlasStaker: admin already exists");
        superAdmins[_admin] = true;
        emit AddedSuperAdmin(_admin);
    }

    /**
     * @dev Batch adding super admin permission
     */
    function addSuperAdmins(address[] calldata _admins) external onlyOwner {
        for (uint256 i = 0; i < _admins.length; i++) {
            addSuperAdmin(_admins[i]);
        }
    }

    /**
     * @dev Remove super admin permission
     */
    function removeSuperAdmin(address _admin) public onlyOwner {
        require(superAdmins[_admin], "BattleflyAtlasStaker: admin does not exist");
        superAdmins[_admin] = false;
        emit RemovedSuperAdmin(_admin);
    }

    /**
     * @dev Batch removing super admin permission
     */
    function removeSuperAdmins(address[] calldata _admins) external onlyOwner {
        for (uint256 i = 0; i < _admins.length; i++) {
            removeSuperAdmin(_admins[i]);
        }
    }

    /**
     * @dev Add vault address
     */
    function addVault(address _vault, Vault calldata _vaultData) public onlyOwner {
        require(!vaults[_vault].enabled, "BattleflyAtlasStaker: vault is already added");
        require(_vaultData.fee + _vaultData.claimRate == FEE_DENOMINATOR, "BattleflyAtlasStaker: invalid vault info");

        Vault storage vault = vaults[_vault];
        vault.fee = _vaultData.fee;
        vault.claimRate = _vaultData.claimRate;
        vault.enabled = true;
        emit AddedVault(_vault, vault.fee, vault.claimRate);
    }

    /**
     * @dev Remove vault address
     */
    function removeVault(address _vault) public onlyOwner {
        Vault storage vault = vaults[_vault];
        require(vault.enabled, "BattleflyAtlasStaker: vault does not exist");
        vault.enabled = false;
        emit RemovedVault(_vault);
    }

    /**
     * @dev Set allowed locks
     */
    function setAllowedLocks(IAtlasMine.Lock[] memory _locks) public onlyOwner {
        allowedLocks = _locks;
    }

    /**
     * @dev Set treasury wallet address
     */
    function setTreasury(address _treasury) public onlyOwner {
        require(_treasury != address(0), "BattleflyAtlasStaker: invalid address");
        TREASURY_VAULT = IBattleflyTreasuryFlywheelVault(_treasury);
        emit SetTreasury(_treasury);
    }

    /**
     * @dev Set daily bot address
     */
    function setBattleflyBot(address _battleflyBot) public onlyOwner {
        require(_battleflyBot != address(0), "BattleflyAtlasStaker: invalid address");
        BATTLEFLY_BOT = _battleflyBot;
        emit SetBattleflyBot(_battleflyBot);
    }

    function setPause(bool _paused) external override onlyOwner {
        pausedUntil = _paused ? block.timestamp + 48 hours : 0;
        emit SetPause(_paused);
    }

    // ============================== VIEW ==============================

    /**
     * @dev Validate the lock period
     */
    function isValidLock(IAtlasMine.Lock _lock) public view returns (bool) {
        for (uint256 i = 0; i < allowedLocks.length; i++) {
            if (allowedLocks[i] == _lock) {
                return true;
            }
        }
        return false;
    }

    /**
     * @dev Get AtlasMine TREASURE ERC1155 NFT address
     */
    function getTREASURE() public view returns (IERC1155Upgradeable) {
        return IERC1155Upgradeable(ATLAS_MINE.treasure());
    }

    /**
     * @dev Get AtlasMine LEGION ERC721 NFT address
     */
    function getLEGION() public view returns (IERC721Upgradeable) {
        return IERC721Upgradeable(ATLAS_MINE.legion());
    }

    /**
     * @dev Get Unstaked MAGIC amount
     */
    function getUnstakedAmount() public view returns (uint256 amount) {
        IAtlasMine.Lock[] memory locks = LOCKS;
        for (uint256 i = 0; i < locks.length; i++) {
            amount += unstakedAmount[locks[i]];
        }
    }

    /**
     * @dev Get claimable MAGIC emission.
     * Emissions are:
     *      Emissions from normal lock period +
     *      Emissions from retention period -
     *      Already received emissions
     */
    function getClaimableEmission(uint256 _depositId) public view override returns (uint256 emission, uint256 fee) {
        VaultStake memory vaultStake = vaultStakes[_depositId];
        if (currentEpoch > 0) {
            uint64 retentionLock = vaultStake.retentionUnlock == 0 ? currentEpoch + 1 : vaultStake.retentionUnlock;
            uint64 x = vaultStake.retentionUnlock == 0 || vaultStake.retentionUnlock != vaultStake.unlockAt ? 0 : 1;
            emission =
                _getEmissionsForPeriod(vaultStake.amount, vaultStake.lockAt, vaultStake.unlockAt - x, vaultStake.lock) +
                _getEmissionsForPeriod(vaultStake.amount, vaultStake.unlockAt, retentionLock, vaultStake.lock) -
                vaultStake.paidEmission;
        }
        Vault memory vault = vaults[vaultStake.vault];
        fee = (emission * vault.fee) / FEE_DENOMINATOR;
        emission -= fee;
    }

    /**
     * @dev Get staked amount
     */
    function getDepositedAmount(uint256[] memory _depositIds) public view returns (uint256 amount) {
        for (uint256 i = 0; i < _depositIds.length; i++) {
            amount += vaultStakes[_depositIds[i]].amount;
        }
    }

    /**
     * @dev Get allowed locks
     */
    function getAllowedLocks() public view override returns (IAtlasMine.Lock[] memory) {
        return allowedLocks;
    }

    /**
     * @dev Get vault staked data
     */
    function getVaultStake(uint256 _depositId) public view override returns (VaultStake memory) {
        return vaultStakes[_depositId];
    }

    /**
     * @dev Gets the lock period in epochs
     */
    function getLockPeriod(IAtlasMine.Lock _lock) external view override returns (uint64 epoch) {
        return BattleflyAtlasStakerUtils.getLockPeriod(_lock, ATLAS_MINE) / 1 days;
    }

    /**
     * @dev Check if a vaultStake can be withdrawn
     */
    function canWithdraw(uint256 _depositId) public view override returns (bool withdrawable) {
        VaultStake memory vaultStake = vaultStakes[_depositId];
        withdrawable = (vaultStake.retentionUnlock > 0) && (vaultStake.retentionUnlock <= currentEpoch);
    }

    /**
     * @dev Check if a vaultStake can request a withdrawal
     */
    function canRequestWithdrawal(uint256 _depositId) public view override returns (bool requestable) {
        VaultStake memory vaultStake = vaultStakes[_depositId];
        requestable = (vaultStake.retentionUnlock == 0) && (currentEpoch >= (vaultStake.unlockAt - 14));
    }

    /**
     * @dev Get the depositIds of a user
     */
    function depositIdsOfVault(address vault) public view override returns (uint256[] memory depositIds) {
        return depositIdByVault[vault].values();
    }

    // ============================== Internal ==============================

    /**
     * @dev recalculate and update the emissions per share per lock period and per epoch
     *      1 share is 1 wei of Magic.
     */
    function _updateEmissionsForEpoch() private returns (uint256 totalEmission) {
        uint256[] memory positionIds = activePositionIds.values();

        // Total emissions of the current epoch are at least as much as the total emissions of the previous epoch
        for (uint256 i = 0; i < LOCKS.length; i++) {
            totalEmissionsAtEpochForLock[LOCKS[i]][currentEpoch] = currentEpoch > 0
                ? totalEmissionsAtEpochForLock[LOCKS[i]][currentEpoch - 1]
                : 0;
        }

        // Calculate the total amount of pending emissions and the total deposited amount for each lock period in the current epoch
        for (uint256 j = 0; j < positionIds.length; j++) {
            uint256 pendingRewards = ATLAS_MINE.pendingRewardsPosition(address(this), positionIds[j]);
            (, uint256 currentAmount, , , , , IAtlasMine.Lock _lock) = ATLAS_MINE.userInfo(
                address(this),
                positionIds[j]
            );
            totalEmission += pendingRewards;
            totalEmissionsAtEpochForLock[_lock][currentEpoch] += pendingRewards;
            totalStakedAtEpochForLock[_lock][currentEpoch] += currentAmount;
        }

        // Calculate the accrued emissions per share by (totalEmission * 1e18) / totalStaked
        // Set the total emissions to the accrued emissions of the current epoch + the previous epochs
        for (uint256 k = 0; k < LOCKS.length; k++) {
            uint256 totalStaked = totalStakedAtEpochForLock[LOCKS[k]][currentEpoch];
            if (totalStaked > 0) {
                uint256 accruedRewardsPerShare = (totalEmission * ONE) / totalStaked;
                totalPerShareAtEpochForLock[LOCKS[k]][currentEpoch] = currentEpoch > 0
                    ? totalPerShareAtEpochForLock[LOCKS[k]][currentEpoch - 1] + accruedRewardsPerShare
                    : accruedRewardsPerShare;
            } else {
                totalPerShareAtEpochForLock[LOCKS[k]][currentEpoch] = currentEpoch > 0
                    ? totalPerShareAtEpochForLock[LOCKS[k]][currentEpoch - 1]
                    : 0;
            }
        }
    }

    /**
     * @dev get the total amount of emissions of a certain period between two epochs.
     */
    function _getEmissionsForPeriod(
        uint256 amount,
        uint64 startEpoch,
        uint64 stopEpoch,
        IAtlasMine.Lock lock
    ) private view returns (uint256 emissions) {
        if (stopEpoch >= startEpoch && currentEpoch >= startEpoch) {
            uint256 totalEmissions = (amount * totalPerShareAtEpochForLock[lock][currentEpoch - 1]);
            uint256 emissionsTillExclusion = (amount * totalPerShareAtEpochForLock[lock][stopEpoch - 1]);
            uint256 emissionsTillInclusion = (amount * totalPerShareAtEpochForLock[lock][startEpoch - 1]);
            uint256 emissionsFromExclusion = emissionsTillExclusion > 0 ? (totalEmissions - emissionsTillExclusion) : 0;
            emissions = (totalEmissions - emissionsFromExclusion - emissionsTillInclusion) / ONE;
        }
    }

    /**
     * @dev Deposit MAGIC to AtlasMine
     */
    function _deposit(
        uint256 _depositId,
        uint256 _amount,
        IAtlasMine.Lock _lock
    ) private returns (uint256) {
        // We only deposit to AtlasMine in the next epoch. We can unlock after the lock period has passed.
        uint64 lockAt = currentEpoch + 1;
        uint64 unlockAt = currentEpoch + 1 + (BattleflyAtlasStakerUtils.getLockPeriod(_lock, ATLAS_MINE) / 1 days);

        vaultStakes[_depositId] = VaultStake(lockAt, unlockAt, 0, _amount, 0, msg.sender, _lock);
        // Updated unstaked MAGIC amount
        unstakedAmount[_lock] += _amount;
        depositIdByVault[msg.sender].add(_depositId);
        emit NewDeposit(msg.sender, _amount, unlockAt, _depositId);
        return unlockAt;
    }

    /**
     * @dev Claim emissions for a depositId
     */
    function _claim(uint256 _depositId) internal returns (uint256) {
        VaultStake storage vaultStake = vaultStakes[_depositId];
        require(vaultStake.vault == msg.sender, "BattleflyAtlasStaker: caller is not a correct vault");

        (uint256 emission, uint256 fee) = getClaimableEmission(_depositId);
        if (emission > 0) {
            MAGIC.safeTransfer(msg.sender, emission);
            if (fee > 0) {
                MAGIC.approve(address(TREASURY_VAULT), fee);
                TREASURY_VAULT.topupMagic(fee);
            }
            uint256 amount = emission + fee;
            vaultStake.paidEmission += amount;
            emit ClaimEmission(msg.sender, emission, _depositId);
        }
        return emission;
    }

    /**
     * @dev Execute the daily cron job to harvest all emissions from AtlasMine
     */
    function _executeHarvestAll() internal {
        uint256 pendingHarvest = _updateEmissionsForEpoch();
        uint256 preHarvest = MAGIC.balanceOf(address(this));
        for (uint64 i = 0; i < activePositionIds.length(); i++) {
            ATLAS_MINE.harvestPosition(activePositionIds.at(i));
        }
        uint256 harvested = MAGIC.balanceOf(address(this)) - preHarvest;
        require(pendingHarvest == harvested, "BattleflyAtlasStaker: pending harvest and actual harvest are not equal");
        // Increment the epoch
        currentEpoch++;
    }

    /**
     * @dev Possibly correct the amount to be deposited due to users withdrawing their stake.
     */
    function _correctForUserWithdrawals() internal {
        if (unstakedAmount[IAtlasMine.Lock.twoWeeks] >= unstakeAmountAtEpoch[currentEpoch]) {
            unstakedAmount[IAtlasMine.Lock.twoWeeks] -= unstakeAmountAtEpoch[currentEpoch];
        } else {
            //If not enough withdrawals available from current epoch, request more from the next epoch
            unstakeAmountAtEpoch[currentEpoch + 1] += (unstakeAmountAtEpoch[currentEpoch] -
                unstakedAmount[IAtlasMine.Lock.twoWeeks]);
            unstakedAmount[IAtlasMine.Lock.twoWeeks] = 0;
        }
    }

    /**
     * @dev Execute the daily cron job to deposit all to AtlasMine
     */
    function _executeDepositAll() internal {
        uint256 unstaked;
        for (uint256 i = 0; i < LOCKS.length; i++) {
            uint256 amount = unstakedAmount[LOCKS[i]];
            if (amount > 0) {
                unstaked += amount;
                MAGIC.safeApprove(address(ATLAS_MINE), amount);
                ATLAS_MINE.deposit(amount, LOCKS[i]);
                activePositionIds.add(ATLAS_MINE.currentId(address(this)));
                unstakedAmount[LOCKS[i]] = 0;
            }
        }
        emit DepositedAllToMine(unstaked);
    }

    /**
     * @dev Execute the daily cron job to withdraw all positions from AtlasMine
     */
    function _executeWithdrawAll() internal {
        uint256[] memory depositIds = activePositionIds.values();
        for (uint256 i = 0; i < depositIds.length; i++) {
            (uint256 amount, , , uint256 lockedUntil, , , IAtlasMine.Lock lock) = ATLAS_MINE.userInfo(
                address(this),
                depositIds[i]
            );
            uint256 totalLockedPeriod = lockedUntil + ATLAS_MINE.getVestingTime(lock);

            // If the position is available to withdraw
            if (totalLockedPeriod <= block.timestamp) {
                ATLAS_MINE.withdrawPosition(depositIds[i], type(uint256).max);
                activePositionIds.remove(depositIds[i]);
                // Directly register for restaking, unless a withdrawal is requested (we correct this in _correctForUserWithdrawals())
                unstakedAmount[IAtlasMine.Lock.twoWeeks] += uint256(amount);
            }
        }
    }

    // ============================== Modifiers ==============================

    modifier onlySuperAdmin() {
        require(superAdmins[msg.sender], "BattleflyAtlasStaker: caller is not a super admin");
        _;
    }

    modifier onlyWhitelistedVaults() {
        require(vaults[msg.sender].enabled, "BattleflyAtlasStaker: caller is not whitelisted");
        _;
    }

    modifier onlyAvailableLock(IAtlasMine.Lock _lock) {
        require(isValidLock(_lock), "BattleflyAtlasStaker: invalid lock period");
        _;
    }

    modifier onlyBattleflyBot() {
        require(msg.sender == BATTLEFLY_BOT, "BattleflyAtlasStaker: caller is not a battlefly bot");
        _;
    }

    modifier whenNotPaused() {
        require(block.timestamp > pausedUntil, "BattleflyAtlasStaker: contract paused");
        _;
    }
}

File 2 of 24 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
    using AddressUpgradeable for address;

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

    function safeTransferFrom(
        IERC20Upgradeable 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(
        IERC20Upgradeable 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(
        IERC20Upgradeable 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(
        IERC20Upgradeable 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(IERC20Upgradeable 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 4 of 24 : IERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 5 of 24 : ERC1155HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.0;

import "./ERC1155ReceiverUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 *
 * @dev _Available since v3.1._
 */
contract ERC1155HolderUpgradeable is Initializable, ERC1155ReceiverUpgradeable {
    function __ERC1155Holder_init() internal onlyInitializing {
    }

    function __ERC1155Holder_init_unchained() internal onlyInitializing {
    }
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }

    /**
     * @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 6 of 24 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

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

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

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

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the 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 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 the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

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

File 7 of 24 : ERC721HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

import "../IERC721ReceiverUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
 */
contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable {
    function __ERC721Holder_init() internal onlyInitializing {
    }

    function __ERC721Holder_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }

    /**
     * @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 8 of 24 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * 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 prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

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

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = _setInitializedVersion(1);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        bool isTopLevelCall = _setInitializedVersion(version);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(version);
        }
    }

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

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        _setInitializedVersion(type(uint8).max);
    }

    function _setInitializedVersion(uint8 version) private returns (bool) {
        // 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, and for the lowest level
        // of initializers, because in other contexts the contract may have been reentered.
        if (_initializing) {
            require(
                version == 1 && !AddressUpgradeable.isContract(address(this)),
                "Initializable: contract is already initialized"
            );
            return false;
        } else {
            require(_initialized < version, "Initializable: contract is already initialized");
            _initialized = version;
            return true;
        }
    }
}

File 9 of 24 : 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 10 of 24 : SafeCastUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCastUpgradeable {
    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

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

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

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

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

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

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

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128) {
        require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits");
        return int128(value);
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64) {
        require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits");
        return int64(value);
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32) {
        require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits");
        return int32(value);
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16) {
        require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits");
        return int16(value);
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8) {
        require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits");
        return int8(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 11 of 24 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}

File 12 of 24 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

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

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

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

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

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

File 13 of 24 : 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;
}

File 14 of 24 : IAtlasMine.sol
// SPDX-License-Identifier: MIT
pragma solidity >0.8.0;

interface IAtlasMine {
    enum Lock {
        twoWeeks,
        oneMonth,
        threeMonths,
        sixMonths,
        twelveMonths
    }
    struct UserInfo {
        uint256 originalDepositAmount;
        uint256 depositAmount;
        uint256 lpAmount;
        uint256 lockedUntil;
        uint256 vestingLastUpdate;
        int256 rewardDebt;
        Lock lock;
    }

    function treasure() external view returns (address);

    function legion() external view returns (address);

    function unlockAll() external view returns (bool);

    function boosts(address user) external view returns (uint256);

    function userInfo(address user, uint256 depositId)
        external
        view
        returns (
            uint256 originalDepositAmount,
            uint256 depositAmount,
            uint256 lpAmount,
            uint256 lockedUntil,
            uint256 vestingLastUpdate,
            int256 rewardDebt,
            Lock lock
        );

    function getLockBoost(Lock _lock) external pure returns (uint256 boost, uint256 timelock);

    function getVestingTime(Lock _lock) external pure returns (uint256 vestingTime);

    function stakeTreasure(uint256 _tokenId, uint256 _amount) external;

    function unstakeTreasure(uint256 _tokenId, uint256 _amount) external;

    function stakeLegion(uint256 _tokenId) external;

    function unstakeLegion(uint256 _tokenId) external;

    function withdrawPosition(uint256 _depositId, uint256 _amount) external returns (bool);

    function withdrawAll() external;

    function pendingRewardsAll(address _user) external view returns (uint256 pending);

    function deposit(uint256 _amount, Lock _lock) external;

    function harvestAll() external;

    function harvestPosition(uint256 _depositId) external;

    function currentId(address _user) external view returns (uint256);

    function pendingRewardsPosition(address _user, uint256 _depositId) external view returns (uint256);

    function getAllUserDepositIds(address) external view returns (uint256[] memory);
}

File 15 of 24 : IBattleflyAtlasStakerV02.sol
// SPDX-License-Identifier: MIT
pragma solidity >0.8.0;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "./IAtlasMine.sol";

interface IBattleflyAtlasStakerV02 {
    struct Vault {
        uint16 fee;
        uint16 claimRate;
        bool enabled;
    }

    struct VaultStake {
        uint64 lockAt;
        uint64 unlockAt;
        uint64 retentionUnlock;
        uint256 amount;
        uint256 paidEmission;
        address vault;
        IAtlasMine.Lock lock;
    }

    function MAGIC() external returns (IERC20Upgradeable);

    function deposit(uint256, IAtlasMine.Lock) external returns (uint256);

    function withdraw(uint256) external returns (uint256);

    function claim(uint256) external returns (uint256);

    function requestWithdrawal(uint256) external returns (uint64);

    function currentDepositId() external view returns (uint256);

    function getAllowedLocks() external view returns (IAtlasMine.Lock[] memory);

    function getVaultStake(uint256) external view returns (VaultStake memory);

    function getClaimableEmission(uint256) external view returns (uint256, uint256);

    function canWithdraw(uint256 _depositId) external view returns (bool withdrawable);

    function canRequestWithdrawal(uint256 _depositId) external view returns (bool requestable);

    function currentEpoch() external view returns (uint64 epoch);

    function getLockPeriod(IAtlasMine.Lock) external view returns (uint64 epoch);

    function setPause(bool _paused) external;

    function depositIdsOfVault(address vault) external view returns (uint256[] memory depositIds);

    // ========== Events ==========
    event AddedSuperAdmin(address who);
    event RemovedSuperAdmin(address who);

    event AddedVault(address indexed vault, uint16 fee, uint16 claimRate);
    event RemovedVault(address indexed vault);

    event StakedTreasure(address staker, uint256 tokenId, uint256 amount);
    event UnstakedTreasure(address staker, uint256 tokenId, uint256 amount);

    event StakedLegion(address staker, uint256 tokenId);
    event UnstakedLegion(address staker, uint256 tokenId);

    event SetTreasury(address treasury);
    event SetBattleflyBot(address bot);

    event NewDeposit(address indexed vault, uint256 amount, uint256 unlockedAt, uint256 indexed depositId);
    event WithdrawPosition(address indexed vault, uint256 amount, uint256 indexed depositId);
    event ClaimEmission(address indexed vault, uint256 amount, uint256 indexed depositId);
    event RequestWithdrawal(address indexed vault, uint64 withdrawalEpoch, uint256 indexed depositId);

    event DepositedAllToMine(uint256 amount);

    event SetPause(bool paused);
}

File 16 of 24 : IVault.sol
// SPDX-License-Identifier: MIT
pragma solidity >0.8.0;

interface IVault {
    function isAutoCompounded(uint256) external view returns (bool);

    function updatePosition(uint256) external;
}

File 17 of 24 : BattleflyAtlasStakerUtils.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../interfaces/IAtlasMine.sol";

library BattleflyAtlasStakerUtils {
    /**
     * @dev Get lock period
     *      Need to consider about adding 1 more day to lock period regarding the daily cron job
     */
    function getLockPeriod(IAtlasMine.Lock _lock, IAtlasMine ATLAS_MINE) external pure returns (uint64) {
        if (_lock == IAtlasMine.Lock.twoWeeks) {
            return 14 days + 1 days + uint64(ATLAS_MINE.getVestingTime(_lock));
        }
        if (_lock == IAtlasMine.Lock.oneMonth) {
            return 30 days + 1 days + uint64(ATLAS_MINE.getVestingTime(_lock));
        }
        if (_lock == IAtlasMine.Lock.threeMonths) {
            return 90 days + 1 days + uint64(ATLAS_MINE.getVestingTime(_lock));
        }
        if (_lock == IAtlasMine.Lock.sixMonths) {
            return 180 days + 1 days + uint64(ATLAS_MINE.getVestingTime(_lock));
        }
        if (_lock == IAtlasMine.Lock.twelveMonths) {
            return 365 days + 1 days + uint64(ATLAS_MINE.getVestingTime(_lock));
        }

        revert("BattleflyAtlasStaker: Invalid Lock");
    }
}

File 18 of 24 : IBattleflyTreasuryFlywheelVault.sol
// SPDX-License-Identifier: MIT
pragma solidity >0.8.0;
import "../IAtlasMine.sol";

interface IBattleflyTreasuryFlywheelVault {
    struct UserStake {
        uint64 lockAt;
        uint256 amount;
        address owner;
        IAtlasMine.Lock lock;
    }

    function deposit(uint128 _amount) external returns (uint256 atlasStakerDepositId);

    function withdraw(uint256[] memory _depositIds, address user) external returns (uint256 amount);

    function withdrawAll(address user) external returns (uint256 amount);

    function requestWithdrawal(uint256[] memory _depositIds) external;

    function claim(uint256 _depositId, address user) external returns (uint256 emission);

    function claimAll(address user) external returns (uint256 amount);

    function claimAllAndRestake() external returns (uint256 amount);

    function topupMagic(uint256 amount) external;

    function getAllowedLocks() external view returns (IAtlasMine.Lock[] memory);

    function getClaimableEmission(uint256) external view returns (uint256);

    function canRequestWithdrawal(uint256 _depositId) external view returns (bool requestable);

    function canWithdraw(uint256 _depositId) external view returns (bool withdrawable);

    function initialUnlock(uint256 _depositId) external view returns (uint64 epoch);

    function retentionUnlock(uint256 _depositId) external view returns (uint64 epoch);

    function getCurrentEpoch() external view returns (uint64 epoch);

    function getDepositIds() external view returns (uint256[] memory ids);

    function getName() external pure returns (string memory);
}

File 19 of 24 : IERC165Upgradeable.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 IERC165Upgradeable {
    /**
     * @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 20 of 24 : ERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../IERC1155ReceiverUpgradeable.sol";
import "../../../utils/introspection/ERC165Upgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155ReceiverUpgradeable is Initializable, ERC165Upgradeable, IERC1155ReceiverUpgradeable {
    function __ERC1155Receiver_init() internal onlyInitializing {
    }

    function __ERC1155Receiver_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
        return interfaceId == type(IERC1155ReceiverUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @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 21 of 24 : IERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev _Available since v3.1._
 */
interface IERC1155ReceiverUpgradeable is IERC165Upgradeable {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

File 22 of 24 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

    /**
     * @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 23 of 24 : IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (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 IERC721ReceiverUpgradeable {
    /**
     * @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 `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

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

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 100
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {
    "contracts/libraries/BattleflyAtlasStakerUtils.sol": {
      "BattleflyAtlasStakerUtils": "0xf42e9ae018dbcb2fcd88de7fb4d3d4f5c16ada68"
    }
  }
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"who","type":"address"}],"name":"AddedSuperAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"uint16","name":"fee","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"claimRate","type":"uint16"}],"name":"AddedVault","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"ClaimEmission","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositedAllToMine","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unlockedAt","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"NewDeposit","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":false,"internalType":"address","name":"who","type":"address"}],"name":"RemovedSuperAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"}],"name":"RemovedVault","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"uint64","name":"withdrawalEpoch","type":"uint64"},{"indexed":true,"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"RequestWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"bot","type":"address"}],"name":"SetBattleflyBot","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"paused","type":"bool"}],"name":"SetPause","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"treasury","type":"address"}],"name":"SetTreasury","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"StakedLegion","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"StakedTreasure","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"UnstakedLegion","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UnstakedTreasure","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"WithdrawPosition","type":"event"},{"inputs":[],"name":"ATLAS_MINE","outputs":[{"internalType":"contract IAtlasMine","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BATTLEFLY_BOT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_DENOMINATOR","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"LOCKS","outputs":[{"internalType":"enum IAtlasMine.Lock","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAGIC","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TREASURY_VAULT","outputs":[{"internalType":"contract IBattleflyTreasuryFlywheelVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_admin","type":"address"}],"name":"addSuperAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_admins","type":"address[]"}],"name":"addSuperAdmins","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_vault","type":"address"},{"components":[{"internalType":"uint16","name":"fee","type":"uint16"},{"internalType":"uint16","name":"claimRate","type":"uint16"},{"internalType":"bool","name":"enabled","type":"bool"}],"internalType":"struct IBattleflyAtlasStakerV02.Vault","name":"_vaultData","type":"tuple"}],"name":"addVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allowedLocks","outputs":[{"internalType":"enum IAtlasMine.Lock","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_approve","type":"bool"}],"name":"approveLegion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_approve","type":"bool"}],"name":"approveTreasure","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositId","type":"uint256"}],"name":"canRequestWithdrawal","outputs":[{"internalType":"bool","name":"requestable","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositId","type":"uint256"}],"name":"canWithdraw","outputs":[{"internalType":"bool","name":"withdrawable","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositId","type":"uint256"}],"name":"claim","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentDepositId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentEpoch","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"enum IAtlasMine.Lock","name":"_lock","type":"uint8"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"}],"name":"depositIdsOfVault","outputs":[{"internalType":"uint256[]","name":"depositIds","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"executeAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAllowedLocks","outputs":[{"internalType":"enum IAtlasMine.Lock[]","name":"","type":"uint8[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositId","type":"uint256"}],"name":"getClaimableEmission","outputs":[{"internalType":"uint256","name":"emission","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_depositIds","type":"uint256[]"}],"name":"getDepositedAmount","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLEGION","outputs":[{"internalType":"contract IERC721Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum IAtlasMine.Lock","name":"_lock","type":"uint8"}],"name":"getLockPeriod","outputs":[{"internalType":"uint64","name":"epoch","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTREASURE","outputs":[{"internalType":"contract IERC1155Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUnstakedAmount","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositId","type":"uint256"}],"name":"getVaultStake","outputs":[{"components":[{"internalType":"uint64","name":"lockAt","type":"uint64"},{"internalType":"uint64","name":"unlockAt","type":"uint64"},{"internalType":"uint64","name":"retentionUnlock","type":"uint64"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"paidEmission","type":"uint256"},{"internalType":"address","name":"vault","type":"address"},{"internalType":"enum IAtlasMine.Lock","name":"lock","type":"uint8"}],"internalType":"struct IBattleflyAtlasStakerV02.VaultStake","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_magic","type":"address"},{"internalType":"address","name":"_atlasMine","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"address","name":"_battleflyBot","type":"address"},{"internalType":"enum IAtlasMine.Lock[]","name":"_allowedLocks","type":"uint8[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum IAtlasMine.Lock","name":"_lock","type":"uint8"}],"name":"isValidLock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"legionStakers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextExecution","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pausedUntil","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_admin","type":"address"}],"name":"removeSuperAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_admins","type":"address[]"}],"name":"removeSuperAdmins","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_vault","type":"address"}],"name":"removeVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositId","type":"uint256"}],"name":"requestWithdrawal","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum IAtlasMine.Lock[]","name":"_locks","type":"uint8[]"}],"name":"setAllowedLocks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_battleflyBot","type":"address"}],"name":"setBattleflyBot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"stakeLegion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stakeTreasure","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"superAdmins","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"treasureStakers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"unstakeLegion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unstakeTreasure","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum IAtlasMine.Lock","name":"","type":"uint8"}],"name":"unstakedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"vaultStakes","outputs":[{"internalType":"uint64","name":"lockAt","type":"uint64"},{"internalType":"uint64","name":"unlockAt","type":"uint64"},{"internalType":"uint64","name":"retentionUnlock","type":"uint64"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"paidEmission","type":"uint256"},{"internalType":"address","name":"vault","type":"address"},{"internalType":"enum IAtlasMine.Lock","name":"lock","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"vaults","outputs":[{"internalType":"uint16","name":"fee","type":"uint16"},{"internalType":"uint16","name":"claimRate","type":"uint16"},{"internalType":"bool","name":"enabled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositId","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50615f9f80620000216000396000f3fe608060405234801561001057600080fd5b50600436106103185760003560e01c80639cd7465d116101a9578063c7ed4995116100ef578063e2a2189a1161009d578063e2a2189a14610848578063e3bb7d621461085b578063f0f442601461086e578063f23a6e6114610881578063f2bff7ba146108a0578063f2fde38b146108c1578063fbe85f06146108d4578063fe41d056146108e757600080fd5b8063c7ed4995146107a4578063ceb68c23146107b7578063cf0d5af3146107ca578063d387c08b146107dd578063d73792a914610805578063da748b101461082b578063dd550bb41461083557600080fd5b8063b3292ff011610157578063b3292ff0146106fc578063b4104d101461070f578063b759d60314610719578063b942bbfd1461072c578063bc197c811461074c578063bedb86fb1461076b578063c2ee3a081461077e578063c3508ceb1461079157600080fd5b80639cd7465d146106175780639ee679e814610643578063a378ff3e14610656578063a622ee7c1461065e578063ad25cb42146106bd578063ae17e73a146106e1578063b244fdcb146106f457600080fd5b80633ce279651161026e5780635e41813d1161021c5780635e41813d14610584578063654cfdff1461059857806367888796146105ab578063715018a6146105be57806371dbc3f5146105c657806376671808146105d05780638da5cb5b146105fc5780638f20400b1461060457600080fd5b80633ce279651461047c578063447fbd83146104a65780634552f9b4146104ba5780634902e4aa1461053657806349408b6a1461054957806351370cce1461056957806355d606881461057c57600080fd5b806327a1a414116102cb57806327a1a414146103da5780632840aac6146103fa5780632a5286f81461040d5780632bf96853146104225780632e1a7d4d14610435578063379607f5146104565780633cd5bba21461046957600080fd5b80623934971461031d57806301ffc9a71461033b5780630559f46d1461035e5780630a7b4b2e1461037157806312a132e414610385578063150b7a021461039957806317640841146103c5575b600080fd5b6103256108fa565b6040516103329190615808565b60405180910390f35b61034e61034936600461563a565b61097d565b6040519015158152602001610332565b61034e61036c366004615662565b6109b4565b61016254610325906001600160a01b031681565b61015f54610325906001600160a01b031681565b6103ac6103a7366004615421565b610a6e565b6040516001600160e01b03199091168152602001610332565b6103d86103d3366004615723565b610a7f565b005b6103ed6103e83660046156a0565b610c46565b6040516103329190615944565b6103d8610408366004615300565b610c7b565b610415610e15565b60405161033291906158c1565b6103d8610430366004615723565b610eac565b6104486104433660046156a0565b611093565b604051908152602001610332565b6104486104643660046156a0565b61131b565b6103d861047736600461552f565b61137e565b61032561048a3660046156a0565b61016f602052600090815260409020546001600160a01b031681565b61016154610325906001600160a01b031681565b6105236104c83660046156a0565b6101716020526000908152604090208054600182015460028301546003909301546001600160401b0380841694600160401b8504821694600160801b900490911692916001600160a01b03811690600160a01b900460ff1687565b6040516103329796959493929190615c82565b6103d86105443660046152c8565b611407565b61055c6105573660046156a0565b61150e565b6040516103329190615c07565b6103d861057736600461552f565b611617565b61032561169b565b61016054610325906001600160a01b031681565b6104486105a63660046156ff565b6116e1565b6103d86105b93660046156a0565b6118aa565b6103d8611a2e565b6104486101685481565b610166546105e4906001600160401b031681565b6040516001600160401b039091168152602001610332565b610325611a69565b6103d8610612366004615602565b611a78565b6104486106253660046156d0565b61017060209081526000928352604080842090915290825290205481565b6105e46106513660046156a0565b611b1a565b6103d8611e5a565b61069a61066c3660046152c8565b6101756020526000908152604090205461ffff8082169162010000810490911690600160201b900460ff1683565b6040805161ffff9485168152939092166020840152151590820152606001610332565b61034e6106cb3660046152c8565b6101746020526000908152604090205460ff1681565b6103d86106ef366004615602565b611f5c565b610448611f94565b6103d861070a3660046152c8565b6120d3565b6104486101655481565b6105e4610727366004615662565b6121d3565b61073f61073a3660046152c8565b61227c565b604051610332919061590c565b6103ac61075a366004615385565b63bc197c8160e01b95945050505050565b6103d8610779366004615602565b6122a1565b6104486b204fce5e3e2502611000000081565b6103d861079f3660046154f0565b61231f565b6104486107b23660046155d0565b61252a565b6103d86107c53660046152c8565b61259b565b6103ed6107d83660046156a0565b612692565b6107f06107eb3660046156a0565b6126a3565b60408051928352602083019190915201610332565b61080e61271081565b6040516bffffffffffffffffffffffff9091168152602001610332565b6104486101675481565b61034e6108433660046156a0565b6128e7565b6103d86108563660046156a0565b6129f2565b6103d861086936600461559e565b612bd6565b6103d861087c3660046152c8565b612c1d565b6103ac61088f36600461548a565b63f23a6e6160e01b95945050505050565b6104486108ae366004615662565b6101736020526000908152604090205481565b6103d86108cf3660046152c8565b612cbe565b61034e6108e23660046156a0565b612d5e565b6103d86108f53660046152c8565b612e5e565b610161546040805163675857eb60e01b815290516000926001600160a01b03169163675857eb916004808301926020929190829003018186803b15801561094057600080fd5b505afa158015610954573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097891906152e4565b905090565b60006001600160e01b03198216630271189760e51b14806109ae57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000805b61016454811015610a65578260048111156109e357634e487b7160e01b600052602160045260246000fd5b6101648281548110610a0557634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff166004811115610a4457634e487b7160e01b600052602160045260246000fd5b1415610a535750600192915050565b80610a5d81615e4f565b9150506109b8565b50600092915050565b630a85bd0160e11b5b949350505050565b336000908152610174602052604090205460ff16610ab85760405162461bcd60e51b8152600401610aaf90615b46565b60405180910390fd5b600261012d541415610adc5760405162461bcd60e51b8152600401610aaf90615bd0565b600261012d5580610aff5760405162461bcd60e51b8152600401610aaf906159ab565b610b0761169b565b6001600160a01b031663f242432a333085856040518563ffffffff1660e01b8152600401610b38949392919061584f565b600060405180830381600087803b158015610b5257600080fd5b505af1158015610b66573d6000803e3d6000fd5b50505060008381526101706020908152604080832033845290915281208054849350909190610b96908490615d51565b909155505061016154604051631764084160e01b815260048101849052602481018390526001600160a01b0390911690631764084190604401600060405180830381600087803b158015610be957600080fd5b505af1158015610bfd573d6000803e3d6000fd5b505050507fdea55b3f8f5e14216b6bf5c440264d158ceccaba8f63825145e886b89641f83c338383604051610c34939291906158a0565b60405180910390a15050600161012d55565b6101648181548110610c5757600080fd5b9060005260206000209060209182820401919006915054906101000a900460ff1681565b6000610c876001612eff565b90508015610c9f576000805461ff0019166101001790555b610ca7612f87565b610caf612f87565b610cb7612fae565b610cbf612fdd565b6001600160a01b038616610ce55760405162461bcd60e51b8152600401610aaf90615a87565b6001600160a01b038516610d0b5760405162461bcd60e51b8152600401610aaf90615a87565b61016080546001600160a01b038881166001600160a01b0319928316179092556101618054928816929091169190911790553360009081526101746020526040808220805460ff19166001179055805160a08101909152908190815260200160018152602001600281526020016003815260200160049052610d929061016390600561502f565b504261016855610da184612c1d565b610daa83612e5e565b610db382612bd6565b610dbd6001611a78565b610dc76001611f5c565b8015610e0d576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050565b6060610164805480602002602001604051908101604052809291908181526020018280548015610ea257602002820191906000526020600020906000905b82829054906101000a900460ff166004811115610e8057634e487b7160e01b600052602160045260246000fd5b815260206001928301818104948501949093039092029101808411610e535790505b5050505050905090565b336000908152610174602052604090205460ff16610edc5760405162461bcd60e51b8152600401610aaf90615b46565b600261012d541415610f005760405162461bcd60e51b8152600401610aaf90615bd0565b600261012d5580610f235760405162461bcd60e51b8152600401610aaf906159ab565b600082815261017060209081526040808320338452909152902054811115610f5d5760405162461bcd60e51b8152600401610aaf906159ab565b61016154604051632bf9685360e01b815260048101849052602481018390526001600160a01b0390911690632bf9685390604401600060405180830381600087803b158015610fab57600080fd5b505af1158015610fbf573d6000803e3d6000fd5b50505050610fcb61169b565b6001600160a01b031663f242432a303385856040518563ffffffff1660e01b8152600401610ffc949392919061584f565b600060405180830381600087803b15801561101657600080fd5b505af115801561102a573d6000803e3d6000fd5b5050506000838152610170602090815260408083203384529091528120805484935090919061105a908490615de4565b90915550506040517fc64276330b756300336c807bd0aeb07274dea0bbc81451cbb85ee2f554930bc490610c34903390859085906158a0565b6000600261012d5414156110b95760405162461bcd60e51b8152600401610aaf90615bd0565b600261012d556101675442116110e15760405162461bcd60e51b8152600401610aaf90615b01565b600082815261017160209081526040808320815160e08101835281546001600160401b038082168352600160401b8204811695830195909552600160801b900490931691830191909152600181015460608301526002810154608083015260038101546001600160a01b03811660a084015260c0830190600160a01b900460ff16600481111561118157634e487b7160e01b600052602160045260246000fd5b60048111156111a057634e487b7160e01b600052602160045260246000fd5b90525060a08101519091506001600160a01b031633146111d25760405162461bcd60e51b8152600401610aaf906159f8565b6111db83612d5e565b6112385760405162461bcd60e51b815260206004820152602860248201527f426174746c65666c7941746c61735374616b65723a20706f736974696f6e20696044820152671cc81b1bd8dad95960c21b6064820152608401610aaf565b606081015161016054909250611258906001600160a01b0316338461300c565b6000611263846126a3565b50905080156112825761127584613062565b61127f9084615d51565b92505b60008481526101716020908152604080832080546001600160c01b0319168155600181018490556002810184905560030180546001600160a81b031916905533835261017290915290206112d69085613225565b50604051838152849033907f8cacab7d7fb32aac23831829b37ce880cacc9d880c564b79b60a5de058fe75879060200160405180910390a35050600161012d55919050565b6000600261012d5414156113415760405162461bcd60e51b8152600401610aaf90615bd0565b600261012d556101675442116113695760405162461bcd60e51b8152600401610aaf90615b01565b61137282613062565b600161012d5592915050565b33611387611a69565b6001600160a01b0316146113ad5760405162461bcd60e51b8152600401610aaf90615acc565b60005b81811015611402576113f08383838181106113db57634e487b7160e01b600052603260045260246000fd5b905060200201602081019061070a91906152c8565b806113fa81615e4f565b9150506113b0565b505050565b33611410611a69565b6001600160a01b0316146114365760405162461bcd60e51b8152600401610aaf90615acc565b6001600160a01b0381166000908152610174602052604090205460ff166114b25760405162461bcd60e51b815260206004820152602a60248201527f426174746c65666c7941746c61735374616b65723a2061646d696e20646f6573604482015269081b9bdd08195e1a5cdd60b21b6064820152608401610aaf565b6001600160a01b0381166000908152610174602052604090819020805460ff19169055517f24e782bd6e6df37a12480621b37c0eab087a1fd2df42401316fce90f8de1365490611503908390615808565b60405180910390a150565b61154b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526101716020908152604091829020825160e08101845281546001600160401b038082168352600160401b8204811694830194909452600160801b900490921692820192909252600182015460608201526002820154608082015260038201546001600160a01b03811660a083015290919060c0830190600160a01b900460ff1660048111156115ef57634e487b7160e01b600052602160045260246000fd5b600481111561160e57634e487b7160e01b600052602160045260246000fd5b90525092915050565b33611620611a69565b6001600160a01b0316146116465760405162461bcd60e51b8152600401610aaf90615acc565b60005b818110156114025761168983838381811061167457634e487b7160e01b600052603260045260246000fd5b905060200201602081019061054491906152c8565b8061169381615e4f565b915050611649565b61016154604080516372907e3f60e11b815290516000926001600160a01b03169163e520fc7e916004808301926020929190829003018186803b15801561094057600080fd5b3360009081526101756020526040812054600160201b900460ff1661174e5760405162461bcd60e51b815260206004820152602f6024820152600080516020615f2a83398151915260448201526e1b9bdd081dda1a5d195b1a5cdd1959608a1b6064820152608401610aaf565b600261012d5414156117725760405162461bcd60e51b8152600401610aaf90615bd0565b600261012d5561016754421161179a5760405162461bcd60e51b8152600401610aaf90615b01565b816117a4816109b4565b6118025760405162461bcd60e51b815260206004820152602960248201527f426174746c65666c7941746c61735374616b65723a20696e76616c6964206c6f60448201526818dac81c195c9a5bd960ba1b6064820152608401610aaf565b6000841161185e5760405162461bcd60e51b8152602060048201526024808201527f42617474666c7941746c61735374616b65723a2063616e6e6f74206465706f736044820152630697420360e41b6064820152608401610aaf565b61016054611877906001600160a01b0316333087613231565b60006101656000815461188990615e4f565b9182905550905061189b81868661326f565b50600161012d55949350505050565b336000908152610174602052604090205460ff166118da5760405162461bcd60e51b8152600401610aaf90615b46565b600261012d5414156118fe5760405162461bcd60e51b8152600401610aaf90615bd0565b600261012d5561190c6108fa565b6001600160a01b031663b88d4fde3330846040518463ffffffff1660e01b815260040161193b9392919061581c565b600060405180830381600087803b15801561195557600080fd5b505af1158015611969573d6000803e3d6000fd5b505050600082815261016f60205260409081902080546001600160a01b031916331790556101615490516333c443cb60e11b8152600481018490526001600160a01b039091169150636788879690602401600060405180830381600087803b1580156119d457600080fd5b505af11580156119e8573d6000803e3d6000fd5b505050507f0aec8a28b899f02fff4666e860ccc9d95c86dd12219147350a084b83c970955e3382604051611a1d929190615887565b60405180910390a150600161012d55565b33611a37611a69565b6001600160a01b031614611a5d5760405162461bcd60e51b8152600401610aaf90615acc565b611a676000613583565b565b6033546001600160a01b031690565b336000908152610174602052604090205460ff16611aa85760405162461bcd60e51b8152600401610aaf90615b46565b611ab06108fa565b6101615460405163a22cb46560e01b81526001600160a01b039182166004820152831515602482015291169063a22cb46590604401600060405180830381600087803b158015611aff57600080fd5b505af1158015611b13573d6000803e3d6000fd5b5050505050565b6000600261012d541415611b405760405162461bcd60e51b8152600401610aaf90615bd0565b600261012d55610167544211611b685760405162461bcd60e51b8152600401610aaf90615b01565b60008281526101716020526040902060038101546001600160a01b03163314611ba35760405162461bcd60e51b8152600401610aaf906159f8565b8054600160801b90046001600160401b031615611c1d5760405162461bcd60e51b815260206004820152603260248201527f426174746c65666c7941746c61735374616b65723a207769746864726177616c60448201527108185b1c9958591e481c995c5d595cdd195960721b6064820152608401610aaf565b8054611c3b90600e90600160401b90046001600160401b0316615dfb565b610166546001600160401b0391821691161015611cb45760405162461bcd60e51b815260206004820152603160248201527f426174746c65666c7941746c61735374616b65723a20706f736974696f6e206e6044820152706f742079657420756e6c6f636b61626c6560781b6064820152608401610aaf565b8054610166546000916001600160401b03600160401b9091048116911610611d2d57815461016654600e91611cfc916001600160401b03600160401b90920482169116615dfb565b611d069190615e91565b611d1190600e615dfb565b61016654611d2891906001600160401b0316615d69565b611d40565b8154600160401b90046001600160401b03165b610166549091506001600160401b0316611d5b600183615dfb565b6001600160401b031614611d6f5780611d7a565b611d7a81600e615d69565b825467ffffffffffffffff60801b1916600160801b6001600160401b039283168102919091178085556001808601549361016e93600093611dbf939291900416615dfb565b6001600160401b03166001600160401b031681526020019081526020016000206000828254611dee9190615d51565b90915550508154604051600160801b9091046001600160401b03168152849033907fac63edbf49809ca6afc9c581ccc3745c2781e803cc0736e473af3c8323c4fa749060200160405180910390a35054600161012d55600160801b90046001600160401b031692915050565b61015f546001600160a01b03163314611ebf5760405162461bcd60e51b81526020600482015260336024820152600080516020615f2a8339815191526044820152721b9bdd08184818985d1d1b19599b1e48189bdd606a1b6064820152608401610aaf565b61016854421015611f2b5760405162461bcd60e51b815260206004820152603060248201527f426174746c65666c7941746c61735374616b65723a204578656375746564206c60448201526f657373207468616e203234682061676f60801b6064820152608401610aaf565b611f384262015054615d51565b61016855611f446135d5565b611f4c61386b565b611f54613b1e565b611a67613c54565b336000908152610174602052604090205460ff16611f8c5760405162461bcd60e51b8152600401610aaf90615b46565b611ab061169b565b60008061016380548060200260200160405190810160405280929190818152602001828054801561202257602002820191906000526020600020906000905b82829054906101000a900460ff16600481111561200057634e487b7160e01b600052602160045260246000fd5b815260206001928301818104948501949093039092029101808411611fd35790505b5050505050905060005b81518110156120ce57610173600083838151811061205a57634e487b7160e01b600052603260045260246000fd5b6020026020010151600481111561208157634e487b7160e01b600052602160045260246000fd5b60048111156120a057634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054836120ba9190615d51565b9250806120c681615e4f565b91505061202c565b505090565b336120dc611a69565b6001600160a01b0316146121025760405162461bcd60e51b8152600401610aaf90615acc565b6001600160a01b0381166000908152610174602052604090205460ff161561217f5760405162461bcd60e51b815260206004820152602a60248201527f426174746c65666c7941746c61735374616b65723a2061646d696e20616c72656044820152696164792065786973747360b01b6064820152608401610aaf565b6001600160a01b0381166000908152610174602052604090819020805460ff19166001179055517f5504b5ad8f7c71da32cba75c5b9a0040fed1cccf1f38151e522be29dde8ced5590611503908390615808565b610161546040516306bdb14160e51b8152600091620151809173f42e9ae018dbcb2fcd88de7fb4d3d4f5c16ada689163d7b62820916122229187916001600160a01b0390911690600401615952565b60206040518083038186803b15801561223a57600080fd5b505af415801561224e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227291906157a3565b6109ae9190615d9f565b6001600160a01b0381166000908152610172602052604090206060906109ae90613f46565b336122aa611a69565b6001600160a01b0316146122d05760405162461bcd60e51b8152600401610aaf90615acc565b806122dc5760006122e9565b6122e9426202a300615d51565b6101675560405181151581527f140eb9f8b591138e129e4caf389c92df4f0545b902523eee9e63153ecdb2026e90602001611503565b33612328611a69565b6001600160a01b03161461234e5760405162461bcd60e51b8152600401610aaf90615acc565b6001600160a01b03821660009081526101756020526040902054600160201b900460ff16156123d45760405162461bcd60e51b815260206004820152602c60248201527f426174746c65666c7941746c61735374616b65723a207661756c74206973206160448201526b1b1c9958591e48185919195960a21b6064820152608401610aaf565b6127106123e7604083016020840161567e565b6123f4602084018461567e565b6123fe9190615d2b565b61ffff16146124605760405162461bcd60e51b815260206004820152602860248201527f426174746c65666c7941746c61735374616b65723a20696e76616c6964207661604482015267756c7420696e666f60c01b6064820152608401610aaf565b6001600160a01b038216600090815261017560209081526040909120906124899083018361567e565b815461ffff191661ffff919091161781556124aa604083016020840161567e565b8154600160201b64ffffff0000199091166201000061ffff938416810264ff00000000191691909117919091178084556040805182851681529290910490921660208201526001600160a01b038516917f88f322ac4cea3a0612aa513a9abee150d6a508f7cc26b09e72aa17c92ae9dd06910160405180910390a2505050565b6000805b825181101561259557610171600084838151811061255c57634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060010154826125819190615d51565b91508061258d81615e4f565b91505061252e565b50919050565b336125a4611a69565b6001600160a01b0316146125ca5760405162461bcd60e51b8152600401610aaf90615acc565b6001600160a01b0381166000908152610175602052604090208054600160201b900460ff1661264e5760405162461bcd60e51b815260206004820152602a60248201527f426174746c65666c7941746c61735374616b65723a207661756c7420646f6573604482015269081b9bdd08195e1a5cdd60b21b6064820152608401610aaf565b805464ff00000000191681556040516001600160a01b038316907fa40a7d97cd4243d8bcd193dc4d709afc3717750c5996d9e7216d1a5e0288c49490600090a25050565b6101638181548110610c5757600080fd5b600081815261017160209081526040808320815160e08101835281546001600160401b038082168352600160401b8204811695830195909552600160801b900490931691830191909152600181015460608301526002810154608083015260038101546001600160a01b03811660a084015283928392909160c0830190600160a01b900460ff16600481111561274957634e487b7160e01b600052602160045260246000fd5b600481111561276857634e487b7160e01b600052602160045260246000fd5b905250610166549091506001600160401b03161561286357600081604001516001600160401b03166000146127a15781604001516127b9565b610166546127b9906001600160401b03166001615d69565b9050600082604001516001600160401b0316600014806127f3575082602001516001600160401b031683604001516001600160401b031614155b6127fe576001612801565b60005b60ff169050826080015161282384606001518560200151858760c00151613f53565b61284a856060015186600001518588602001516128409190615dfb565b8860c00151613f53565b6128549190615d51565b61285e9190615de4565b945050505b60a08101516001600160a01b0316600090815261017560209081526040918290208251606081018452905461ffff80821680845262010000830490911693830193909352600160201b900460ff16151592810192909252612710906128c89086615dc5565b6128d29190615d8b565b92506128de8385615de4565b93505050915091565b600081815261017160209081526040808320815160e08101835281546001600160401b038082168352600160401b8204811695830195909552600160801b900490931691830191909152600181015460608301526002810154608083015260038101546001600160a01b03811660a08401528392919060c0830190600160a01b900460ff16600481111561298b57634e487b7160e01b600052602160045260246000fd5b60048111156129aa57634e487b7160e01b600052602160045260246000fd5b90525060408101519091506001600160401b03161580156129eb5750600e81602001516129d79190615dfb565b610166546001600160401b03918216911610155b9392505050565b336000908152610174602052604090205460ff16612a225760405162461bcd60e51b8152600401610aaf90615b46565b600261012d541415612a465760405162461bcd60e51b8152600401610aaf90615bd0565b600261012d55600081815261016f60205260409020546001600160a01b03163314612abf5760405162461bcd60e51b8152602060048201526024808201527f426174746c65666c7941746c61735374616b65723a20496e76616c696420737460448201526330b5b2b960e11b6064820152608401610aaf565b610161546040516371510c4d60e11b8152600481018390526001600160a01b039091169063e2a2189a90602401600060405180830381600087803b158015612b0657600080fd5b505af1158015612b1a573d6000803e3d6000fd5b50505050612b266108fa565b6001600160a01b031663b88d4fde3033846040518463ffffffff1660e01b8152600401612b559392919061581c565b600060405180830381600087803b158015612b6f57600080fd5b505af1158015612b83573d6000803e3d6000fd5b505050600082815261016f60205260409081902080546001600160a01b0319169055517f5906690a16d08cc3d97e140294084c924c75b0efbc60f2687ca5e641ca4cc4429150611a1d9033908490615887565b33612bdf611a69565b6001600160a01b031614612c055760405162461bcd60e51b8152600401610aaf90615acc565b8051612c19906101649060208401906150f1565b5050565b33612c26611a69565b6001600160a01b031614612c4c5760405162461bcd60e51b8152600401610aaf90615acc565b6001600160a01b038116612c725760405162461bcd60e51b8152600401610aaf90615a87565b61016280546001600160a01b0319166001600160a01b0383161790556040517fcb7ef3e545f5cdb893f5c568ba710fe08f336375a2d9fd66e161033f8fc09ef390611503908390615808565b33612cc7611a69565b6001600160a01b031614612ced5760405162461bcd60e51b8152600401610aaf90615acc565b6001600160a01b038116612d525760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610aaf565b612d5b81613583565b50565b600081815261017160209081526040808320815160e08101835281546001600160401b038082168352600160401b8204811695830195909552600160801b900490931691830191909152600181015460608301526002810154608083015260038101546001600160a01b03811660a08401528392919060c0830190600160a01b900460ff166004811115612e0257634e487b7160e01b600052602160045260246000fd5b6004811115612e2157634e487b7160e01b600052602160045260246000fd5b815250509050600081604001516001600160401b03161180156129eb57506101665460408201516001600160401b03918216911611159392505050565b33612e67611a69565b6001600160a01b031614612e8d5760405162461bcd60e51b8152600401610aaf90615acc565b6001600160a01b038116612eb35760405162461bcd60e51b8152600401610aaf90615a87565b61015f80546001600160a01b0319166001600160a01b0383161790556040517f199f16fb356880d437cf372126b46eca6db4bd5f300b1394a78316135bb7a41190611503908390615808565b60008054610100900460ff1615612f46578160ff166001148015612f225750303b155b612f3e5760405162461bcd60e51b8152600401610aaf90615a39565b506000919050565b60005460ff808416911610612f6d5760405162461bcd60e51b8152600401610aaf90615a39565b506000805460ff191660ff92909216919091179055600190565b600054610100900460ff16611a675760405162461bcd60e51b8152600401610aaf90615b85565b600054610100900460ff16612fd55760405162461bcd60e51b8152600401610aaf90615b85565b611a6761418c565b600054610100900460ff166130045760405162461bcd60e51b8152600401610aaf90615b85565b611a676141bc565b6114028363a9059cbb60e01b848460405160240161302b929190615887565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526141eb565b60008181526101716020526040812060038101546001600160a01b0316331461309d5760405162461bcd60e51b8152600401610aaf906159f8565b6000806130a9856126a3565b9092509050811561321d57610160546130cc906001600160a01b0316338461300c565b80156131bd57610160546101625460405163095ea7b360e01b81526001600160a01b039283169263095ea7b39261310a929116908590600401615887565b602060405180830381600087803b15801561312457600080fd5b505af1158015613138573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061315c919061561e565b50610162546040516370055ee160e11b8152600481018390526001600160a01b039091169063e00abdc290602401600060405180830381600087803b1580156131a457600080fd5b505af11580156131b8573d6000803e3d6000fd5b505050505b60006131c98284615d51565b9050808460020160008282546131df9190615d51565b9091555050604051838152869033907f0650561c2c329ee37faeeafc49128db4c6a001e6e955f41394ca9b855da5dd739060200160405180910390a3505b509392505050565b60006129eb83836142bd565b6040516001600160a01b03808516602483015283166044820152606481018290526132699085906323b872dd60e01b9060840161302b565b50505050565b61016654600090819061328c906001600160401b03166001615d69565b610161546040516306bdb14160e51b8152919250600091620151809173f42e9ae018dbcb2fcd88de7fb4d3d4f5c16ada689163d7b62820916132dc9189916001600160a01b031690600401615952565b60206040518083038186803b1580156132f457600080fd5b505af4158015613308573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061332c91906157a3565b6133369190615d9f565b6101665461334e906001600160401b03166001615d69565b6133589190615d69565b90506040518060e00160405280836001600160401b03168152602001826001600160401b0316815260200160006001600160401b0316815260200186815260200160008152602001336001600160a01b031681526020018560048111156133cf57634e487b7160e01b600052602160045260246000fd5b9052600087815261017160209081526040918290208351815492850151938501516001600160401b03908116600160801b0267ffffffffffffffff60801b19958216600160401b026001600160801b031990951691909216179290921792909216178155606082015160018201556080820151600282015560a08201516003820180546001600160a01b039092166001600160a01b031983168117825560c0850151926001600160a81b03191617600160a01b8360048111156134a257634e487b7160e01b600052602160045260246000fd5b02179055509050508461017360008660048111156134d057634e487b7160e01b600052602160045260246000fd5b60048111156134ef57634e487b7160e01b600052602160045260246000fd5b8152602001908152602001600020600082825461350c9190615d51565b90915550503360009081526101726020526040902061352b90876143e1565b50604080518681526001600160401b0383166020820152879133917f632498135bdb1c11bee743dc04f2ffc8ae33cd6fb3d25fe0941ae402b068fda8910160405180910390a36001600160401b031695945050505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006135df6143ed565b610160546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190613616903090600401615808565b60206040518083038186803b15801561362e57600080fd5b505afa158015613642573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061366691906156b8565b905060005b613676610169614caa565b816001600160401b0316101561371057610161546001600160a01b03166320f8e94e6136ad6101696001600160401b038516614cb4565b6040518263ffffffff1660e01b81526004016136cb91815260200190565b600060405180830381600087803b1580156136e557600080fd5b505af11580156136f9573d6000803e3d6000fd5b50505050808061370890615e6a565b91505061366b565b50610160546040516370a0823160e01b815260009183916001600160a01b03909116906370a0823190613747903090600401615808565b60206040518083038186803b15801561375f57600080fd5b505afa158015613773573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379791906156b8565b6137a19190615de4565b90508083146138275760405162461bcd60e51b815260206004820152604660248201527f426174746c65666c7941746c61735374616b65723a2070656e64696e6720686160448201527f727665737420616e642061637475616c206861727665737420617265206e6f7460648201526508195c5d585b60d21b608482015260a401610aaf565b61016680546001600160401b031690600061384183615e6a565b91906101000a8154816001600160401b0302191690836001600160401b0316021790555050505050565b6000613878610169613f46565b905060005b8151811015612c1957610161548251600091829182916001600160a01b0316906321ce919d9030908890889081106138c557634e487b7160e01b600052603260045260246000fd5b60200260200101516040518363ffffffff1660e01b81526004016138ea929190615887565b60e06040518083038186803b15801561390257600080fd5b505afa158015613916573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061393a9190615744565b61016154604051632f623e7760e01b8152979a5093985096506000956001600160a01b039093169450632f623e77935061397b928792506004019050615944565b60206040518083038186803b15801561399357600080fd5b505afa1580156139a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139cb91906156b8565b6139d59084615d51565b9050428111613b07576101615486516001600160a01b039091169063d82b99d790889088908110613a1657634e487b7160e01b600052603260045260246000fd5b60200260200101516000196040518363ffffffff1660e01b8152600401613a47929190918252602082015260400190565b602060405180830381600087803b158015613a6157600080fd5b505af1158015613a75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a99919061561e565b50613ad6868681518110613abd57634e487b7160e01b600052603260045260246000fd5b602002602001015161016961322590919063ffffffff16565b506000808052610173602052600080516020615f4a8339815191528054869290613b01908490615d51565b90915550505b505050508080613b1690615e4f565b91505061387d565b610166546001600160401b0316600090815261016e602090815260408220549180526101739052600080516020615f4a8339815191525410613bad57610166546001600160401b0316600090815261016e60209081526040822054828052610173909152600080516020615f4a833981519152805491929091613ba2908490615de4565b90915550611a679050565b600080516020615f4a83398151915254610166546001600160401b0316600090815261016e6020526040902054613be49190615de4565b6101665461016e90600090613c03906001600160401b03166001615d69565b6001600160401b03166001600160401b031681526020019081526020016000206000828254613c329190615d51565b90915550506000808052610173602052600080516020615f4a83398151915255565b6000805b61016354811015613f1557600061017360006101638481548110613c8c57634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff166004811115613ccb57634e487b7160e01b600052602160045260246000fd5b6004811115613cea57634e487b7160e01b600052602160045260246000fd5b81526020019081526020016000205490506000811115613f0257613d0e8184615d51565b6101615461016054919450613d30916001600160a01b03908116911683614cc0565b6101615461016380546001600160a01b039092169163654cfdff91849186908110613d6b57634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff166040518363ffffffff1660e01b8152600401613da8929190615c6e565b600060405180830381600087803b158015613dc257600080fd5b505af1158015613dd6573d6000803e3d6000fd5b50506101615460405163114cdc7d60e11b8152613e6893506001600160a01b039091169150632299b8fa90613e0f903090600401615808565b60206040518083038186803b158015613e2757600080fd5b505afa158015613e3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e5f91906156b8565b610169906143e1565b50600061017360006101638581548110613e9257634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff166004811115613ed157634e487b7160e01b600052602160045260246000fd5b6004811115613ef057634e487b7160e01b600052602160045260246000fd5b81526020810191909152604001600020555b5080613f0d81615e4f565b915050613c58565b506040518181527ffc4dc798d5d57e362d01d51ff8e468bee06988650c4e1ebcad33ddd2341d0fdd90602001611503565b606060006129eb83614dd3565b6000836001600160401b0316836001600160401b031610158015613f865750610166546001600160401b03808616911610155b15610a7757600061016d6000846004811115613fb257634e487b7160e01b600052602160045260246000fd5b6004811115613fd157634e487b7160e01b600052602160045260246000fd5b81526020810191909152604001600090812061016654909190613fff906001906001600160401b0316615dfb565b6001600160401b031681526020810191909152604001600020546140239087615dc5565b9050600061016d600085600481111561404c57634e487b7160e01b600052602160045260246000fd5b600481111561406b57634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002060006001876140889190615dfb565b6001600160401b031681526020810191909152604001600020546140ac9088615dc5565b9050600061016d60008660048111156140d557634e487b7160e01b600052602160045260246000fd5b60048111156140f457634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002060006001896141119190615dfb565b6001600160401b031681526020810191909152604001600020546141359089615dc5565b90506000808311614147576000614151565b6141518385615de4565b90506b204fce5e3e250261100000008261416b8387615de4565b6141759190615de4565b61417f9190615d8b565b9998505050505050505050565b600054610100900460ff166141b35760405162461bcd60e51b8152600401610aaf90615b85565b611a6733613583565b600054610100900460ff166141e35760405162461bcd60e51b8152600401610aaf90615b85565b600161012d55565b6000614240826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614e2f9092919063ffffffff16565b805190915015611402578080602001905181019061425e919061561e565b6114025760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610aaf565b600081815260018301602052604081205480156143d05760006142e1600183615de4565b85549091506000906142f590600190615de4565b905081811461437657600086600001828154811061432357634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508087600001848154811061435457634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061439557634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506109ae565b60009150506109ae565b5092915050565b60006129eb8383614e3e565b6000806143fb610169613f46565b905060005b610163548110156145b957610166546001600160401b03166144235760006144f8565b61016b6000610163838154811061444a57634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff16600481111561448957634e487b7160e01b600052602160045260246000fd5b60048111156144a857634e487b7160e01b600052602160045260246000fd5b815260208101919091526040016000908120610166549091906144d6906001906001600160401b0316615dfb565b6001600160401b03166001600160401b03168152602001908152602001600020545b61016b6000610163848154811061451f57634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff16600481111561455e57634e487b7160e01b600052602160045260246000fd5b600481111561457d57634e487b7160e01b600052602160045260246000fd5b815260208082019290925260409081016000908120610166546001600160401b03168252909252902055806145b181615e4f565b915050614400565b5060005b8151811015614861576101615482516000916001600160a01b03169063fd90904c90309086908690811061460157634e487b7160e01b600052603260045260246000fd5b60200260200101516040518363ffffffff1660e01b8152600401614626929190615887565b60206040518083038186803b15801561463e57600080fd5b505afa158015614652573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061467691906156b8565b61016154845191925060009182916001600160a01b0316906321ce919d9030908890889081106146b657634e487b7160e01b600052603260045260246000fd5b60200260200101516040518363ffffffff1660e01b81526004016146db929190615887565b60e06040518083038186803b1580156146f357600080fd5b505afa158015614707573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061472b9190615744565b96505050505092505082866147409190615d51565b95508261016b600083600481111561476857634e487b7160e01b600052602160045260246000fd5b600481111561478757634e487b7160e01b600052602160045260246000fd5b815260208082019290925260409081016000908120610166546001600160401b03168252909252812080549091906147c0908490615d51565b9091555082905061016c60008360048111156147ec57634e487b7160e01b600052602160045260246000fd5b600481111561480b57634e487b7160e01b600052602160045260246000fd5b815260208082019290925260409081016000908120610166546001600160401b0316825290925281208054909190614844908490615d51565b92505081905550505050808061485990615e4f565b9150506145bd565b5060005b610163548110156120ce57600061016c6000610163848154811061489957634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff1660048111156148d857634e487b7160e01b600052602160045260246000fd5b60048111156148f757634e487b7160e01b600052602160045260246000fd5b815260208082019290925260409081016000908120610166546001600160401b0316825290925290205490508015614afa576000816149426b204fce5e3e2502611000000087615dc5565b61494c9190615d8b565b610166549091506001600160401b03166149665780614a45565b8061016d6000610163868154811061498e57634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff1660048111156149cd57634e487b7160e01b600052602160045260246000fd5b60048111156149ec57634e487b7160e01b600052602160045260246000fd5b81526020810191909152604001600090812061016654909190614a1a906001906001600160401b0316615dfb565b6001600160401b03166001600160401b0316815260200190815260200160002054614a459190615d51565b61016d60006101638681548110614a6c57634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff166004811115614aab57634e487b7160e01b600052602160045260246000fd5b6004811115614aca57634e487b7160e01b600052602160045260246000fd5b815260208082019290925260409081016000908120610166546001600160401b0316825290925290205550614c97565b610166546001600160401b0316614b12576000614be7565b61016d60006101638481548110614b3957634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff166004811115614b7857634e487b7160e01b600052602160045260246000fd5b6004811115614b9757634e487b7160e01b600052602160045260246000fd5b81526020810191909152604001600090812061016654909190614bc5906001906001600160401b0316615dfb565b6001600160401b03166001600160401b03168152602001908152602001600020545b61016d60006101638581548110614c0e57634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff166004811115614c4d57634e487b7160e01b600052602160045260246000fd5b6004811115614c6c57634e487b7160e01b600052602160045260246000fd5b815260208082019290925260409081016000908120610166546001600160401b031682529092529020555b5080614ca281615e4f565b915050614865565b60006109ae825490565b60006129eb8383614e8d565b801580614d495750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015614d0f57600080fd5b505afa158015614d23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d4791906156b8565b155b614db45760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610aaf565b6114028363095ea7b360e01b848460405160240161302b929190615887565b606081600001805480602002602001604051908101604052809291908181526020018280548015614e2357602002820191906000526020600020905b815481526020019060010190808311614e0f575b50505050509050919050565b6060610a778484600085614ec5565b6000818152600183016020526040812054614e85575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556109ae565b5060006109ae565b6000826000018281548110614eb257634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b606082471015614f265760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610aaf565b6001600160a01b0385163b614f7d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610aaf565b600080866001600160a01b03168587604051614f9991906157ec565b60006040518083038185875af1925050503d8060008114614fd6576040519150601f19603f3d011682016040523d82523d6000602084013e614fdb565b606091505b5091509150614feb828286614ff6565b979650505050505050565b606083156150055750816129eb565b8251156150155782518084602001fd5b8160405162461bcd60e51b8152600401610aaf9190615978565b82805482825590600052602060002090601f016020900481019282156150e15791602002820160005b838211156150b257835183826101000a81548160ff0219169083600481111561509157634e487b7160e01b600052602160045260246000fd5b02179055509260200192600101602081600001049283019260010302615058565b80156150df5782816101000a81549060ff02191690556001016020816000010492830192600103026150b2565b505b506150ed929150615174565b5090565b82805482825590600052602060002090601f016020900481019282156150e15791602002820160005b838211156150b257835183826101000a81548160ff0219169083600481111561515357634e487b7160e01b600052602160045260246000fd5b0217905550926020019260010160208160000104928301926001030261511a565b5b808211156150ed5760008155600101615175565b600082601f830112615199578081fd5b813560206151ae6151a983615d08565b615cd8565b80838252828201915082860187848660051b89010111156151cd578586fd5b855b858110156151f45781356151e281615f1c565b845292840192908401906001016151cf565b5090979650505050505050565b600082601f830112615211578081fd5b813560206152216151a983615d08565b80838252828201915082860187848660051b8901011115615240578586fd5b855b858110156151f457813584529284019290840190600101615242565b600082601f83011261526e578081fd5b81356001600160401b0381111561528757615287615ee3565b61529a601f8201601f1916602001615cd8565b8181528460208386010111156152ae578283fd5b816020850160208301379081016020019190915292915050565b6000602082840312156152d9578081fd5b81356129eb81615ef9565b6000602082840312156152f5578081fd5b81516129eb81615ef9565b600080600080600060a08688031215615317578081fd5b853561532281615ef9565b9450602086013561533281615ef9565b9350604086013561534281615ef9565b9250606086013561535281615ef9565b915060808601356001600160401b0381111561536c578182fd5b61537888828901615189565b9150509295509295909350565b600080600080600060a0868803121561539c578081fd5b85356153a781615ef9565b945060208601356153b781615ef9565b935060408601356001600160401b03808211156153d2578283fd5b6153de89838a01615201565b945060608801359150808211156153f3578283fd5b6153ff89838a01615201565b93506080880135915080821115615414578283fd5b506153788882890161525e565b60008060008060808587031215615436578384fd5b843561544181615ef9565b9350602085013561545181615ef9565b92506040850135915060608501356001600160401b03811115615472578182fd5b61547e8782880161525e565b91505092959194509250565b600080600080600060a086880312156154a1578283fd5b85356154ac81615ef9565b945060208601356154bc81615ef9565b9350604086013592506060860135915060808601356001600160401b038111156154e4578182fd5b6153788882890161525e565b6000808284036080811215615503578283fd5b833561550e81615ef9565b92506060601f1982011215615521578182fd5b506020830190509250929050565b60008060208385031215615541578182fd5b82356001600160401b0380821115615557578384fd5b818501915085601f83011261556a578384fd5b813581811115615578578485fd5b8660208260051b850101111561558c578485fd5b60209290920196919550909350505050565b6000602082840312156155af578081fd5b81356001600160401b038111156155c4578182fd5b610a7784828501615189565b6000602082840312156155e1578081fd5b81356001600160401b038111156155f6578182fd5b610a7784828501615201565b600060208284031215615613578081fd5b81356129eb81615f0e565b60006020828403121561562f578081fd5b81516129eb81615f0e565b60006020828403121561564b578081fd5b81356001600160e01b0319811681146129eb578182fd5b600060208284031215615673578081fd5b81356129eb81615f1c565b60006020828403121561568f578081fd5b813561ffff811681146129eb578182fd5b6000602082840312156156b1578081fd5b5035919050565b6000602082840312156156c9578081fd5b5051919050565b600080604083850312156156e2578182fd5b8235915060208301356156f481615ef9565b809150509250929050565b60008060408385031215615711578182fd5b8235915060208301356156f481615f1c565b60008060408385031215615735578182fd5b50508035926020909101359150565b600080600080600080600060e0888a03121561575e578485fd5b875196506020880151955060408801519450606088015193506080880151925060a0880151915060c088015161579381615f1c565b8091505092959891949750929550565b6000602082840312156157b4578081fd5b81516001600160401b03811681146129eb578182fd5b600581106157e857634e487b7160e01b600052602160045260246000fd5b9052565b600082516157fe818460208701615e23565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260806060820181905260009082015260a00190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a06080820181905260009082015260c00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b6020808252825182820181905260009190848201906040850190845b81811015615900576158f08385516157ca565b92840192918401916001016158dd565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561590057835183529284019291840191600101615928565b602081016109ae82846157ca565b6040810161596082856157ca565b6001600160a01b039290921660209190910152919050565b6020815260008251806020840152615997816040850160208701615e23565b601f01601f19169190910160400192915050565b6020808252602d908201527f426174746c65666c7941746c61735374616b65723a20496e76616c696420545260408201526c115054d5549148185b5bdd5b9d609a1b606082015260800190565b6020808252603390820152600080516020615f2a8339815191526040820152721b9bdd08184818dbdc9c9958dd081d985d5b1d606a1b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526025908201527f426174746c65666c7941746c61735374616b65723a20696e76616c6964206164604082015264647265737360d81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526025908201527f426174746c65666c7941746c61735374616b65723a20636f6e74726163742070604082015264185d5cd95960da1b606082015260800190565b6020808252603190820152600080516020615f2a8339815191526040820152703737ba10309039bab832b91030b236b4b760791b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600060e0820190506001600160401b0380845116835280602085015116602084015280604085015116604084015250606083015160608301526080830151608083015260018060a01b0360a08401511660a083015260c08301516143da60c08401826157ca565b828152604081016129eb60208301846157ca565b6001600160401b03888116825287811660208301528616604082015260608101859052608081018490526001600160a01b03831660a082015260e08101615ccc60c08301846157ca565b98975050505050505050565b604051601f8201601f191681016001600160401b0381118282101715615d0057615d00615ee3565b604052919050565b60006001600160401b03821115615d2157615d21615ee3565b5060051b60200190565b600061ffff808316818516808303821115615d4857615d48615eb7565b01949350505050565b60008219821115615d6457615d64615eb7565b500190565b60006001600160401b03808316818516808303821115615d4857615d48615eb7565b600082615d9a57615d9a615ecd565b500490565b60006001600160401b0380841680615db957615db9615ecd565b92169190910492915050565b6000816000190483118215151615615ddf57615ddf615eb7565b500290565b600082821015615df657615df6615eb7565b500390565b60006001600160401b0383811690831681811015615e1b57615e1b615eb7565b039392505050565b60005b83811015615e3e578181015183820152602001615e26565b838111156132695750506000910152565b6000600019821415615e6357615e63615eb7565b5060010190565b60006001600160401b0380831681811415615e8757615e87615eb7565b6001019392505050565b60006001600160401b0380841680615eab57615eab615ecd565b92169190910692915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114612d5b57600080fd5b8015158114612d5b57600080fd5b60058110612d5b57600080fdfe426174746c65666c7941746c61735374616b65723a2063616c6c657220697320fcf585ebf245559081586028dc1f6957af0fe01c671b0ab080ffcf4b3dff3a7ba2646970667358221220cc5c72eb9597c9c64d6a99764b9b93ec7129431e012ef74fd99f30f2e075f17664736f6c63430008040033

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.