false
false

Contract Address Details

0x9b5A4a3cF82F6860fB26c2626b0278071e7997a9

Contract Name
AlphaKeysFactory
Creator
0x6600ca–5bc300 at 0xf74e8a–01213a
Balance
0 BVM
Tokens
Fetching tokens...
Transactions
3 Transactions
Transfers
0 Transfers
Gas Used
120,846
Last Balance Update
13937355
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
AlphaKeysFactory




Optimization enabled
true
Compiler version
v0.8.19+commit.7dd6d404




Optimization runs
200
EVM Version
default




Verified at
2023-10-14T02:30:01.067082Z

contracts/AlphaKeysFactory.sol

Sol2uml
new
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;

import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import {ECDSAUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import {SafeMathUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import {AddressUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";

import {BlockContext} from "./base/BlockContext.sol";
import {Multicall} from "./base/Multicall.sol";

import {IAlphaKeysFactory} from "./interfaces/IAlphaKeysFactory.sol";
import {AlphaKeysFactoryStorage} from "./storage/AlphaKeysFactoryStorage.sol";
import {IAlphaKeysToken} from "./interfaces/IAlphaKeysToken.sol";
import {IAlphaKeysVault} from "./interfaces/IAlphaKeysVault.sol";

import {NumberMath} from "./libraries/NumberMath.sol";
import {ThreeThreeTypes} from "./libraries/ThreeThreeTypes.sol";
import {TokenTypes} from "./libraries/TokenTypes.sol";
import {LimitOrderTypes} from "./libraries/LimitOrderTypes.sol";

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

import {TransferHelper} from "./libraries/TransferHelper.sol";

contract AlphaKeysFactory is
    IAlphaKeysFactory,
    BlockContext,
    Multicall,
    OwnableUpgradeable,
    ReentrancyGuardUpgradeable,
    AlphaKeysFactoryStorage
{
    using SafeMathUpgradeable for uint256;
    using NumberMath for uint256;
    using AddressUpgradeable for address;
    //
    modifier onlyAdmin() {
        require(_msgSender() == _admin, "AKF_NA");
        _;
    }

    modifier onlyToken(address token) {
        require(token != address(0), "AKF_TZ");
        require(
            (_keysPlayers[token] != address(0) || _keysTwitters[token] > 0),
            "AKF_BT"
        );
        _;
    }

    modifier onlyPlayer(address player) {
        require(player != address(0), "AKF_PZ");
        require((_playerKeys[player] != address(0)), "AKF_BP");
        _;
    }

    modifier notContract() {
        // caller is contract
        require(!_msgSender().isContract(), "AKF_CIC");
        _;
    }

    receive() external payable {}

    function initialize() external initializer {
        __Ownable_init();
        __ReentrancyGuard_init();
        //
        _protocolFeeDestination = _msgSender();
        _protocolFeeRatio = 50000;
        _playerFeeRatio = 50000;
        _admin = _msgSender();
    }

    function getAlphaKeysTokenImplementation()
        external
        view
        override
        returns (address)
    {
        return _playerShareTokenImplementation;
    }

    function setAlphaKeysTokenImplementation(
        address playerShareTokenImplementationArg
    ) external onlyOwner {
        _playerShareTokenImplementation = playerShareTokenImplementationArg;
    }

    function setAdmin(address admin) external onlyOwner {
        _admin = admin;
    }

    function getAdmin() external view returns (address) {
        return _admin;
    }

    function setBTC(address btc) external onlyOwner {
        require(btc.isContract(), "AKF_BINC");
        _btc = btc;
    }

    function getBTC() external view override returns (address) {
        return _btc;
    }

    function setVault(address vault) external onlyOwner {
        require(vault.isContract(), "AKF_VINC");
        _vault = vault;
    }

    function getVault() external view override returns (address) {
        return _vault;
    }

    function setBTCPrice(uint256 btcPrice) external onlyOwner {
        _btcPrice = btcPrice;
    }

    function getBTCPrice() external view returns (uint256) {
        return _btcPrice;
    }

    function getPlayerKeys(address player) external view returns (address) {
        return _playerKeys[player];
    }

    function getKeysPlayer(address token) external view returns (address) {
        return _keysPlayers[token];
    }

    function getTwitterKeys(uint256 twitterId) external view returns (address) {
        return _twitterKeys[twitterId];
    }

    function getKeysTwitters(address token) external view returns (uint256) {
        return _keysTwitters[token];
    }

    function setProtocolFeeRatio(uint24 protocolFeeRatio) external onlyOwner {
        _protocolFeeRatio = protocolFeeRatio;
    }

    function getProtocolFeeRatio() external view returns (uint24) {
        return _protocolFeeRatio;
    }

    function setPlayerFeeRatio(uint24 playerFeeRatio) external onlyOwner {
        _playerFeeRatio = playerFeeRatio;
    }

    function getPlayerFeeRatio() external view returns (uint24) {
        return _playerFeeRatio;
    }

    function getProtocolFeeDestination()
        external
        view
        override
        returns (address)
    {
        return _protocolFeeDestination;
    }

    function setProtocolFeeDestination(
        address protocolFeeDestination
    ) external onlyOwner {
        _protocolFeeDestination = protocolFeeDestination;
    }

    // for create token

    function getCreateForTwitterMessageHash(
        uint256 twitterId,
        string calldata name,
        string calldata symbol
    ) public view returns (bytes32) {
        uint256 chainId;
        assembly {
            chainId := chainid()
        }
        return
            keccak256(
                abi.encode(address(this), chainId, twitterId, name, symbol)
            );
    }

    function _verifyCreateTokenSigner(
        uint256 twitterId,
        string calldata name,
        string calldata symbol,
        bytes memory signature
    ) internal view returns (address, bytes32) {
        bytes32 messageHash = getCreateForTwitterMessageHash(
            twitterId,
            name,
            symbol
        );
        address signer = ECDSAUpgradeable.recover(
            ECDSAUpgradeable.toEthSignedMessageHash(messageHash),
            signature
        );
        // GP_NA: Signer Is Not ADmin
        require(signer == _admin, "AKF_NA");
        return (signer, messageHash);
    }

    function createAlphaKeysForV2(
        uint256 twitterId,
        address player,
        string calldata name,
        string calldata symbol
    ) external nonReentrant onlyAdmin {
        require(twitterId > 0, "AKF_TZV");
        require(_playerKeys[player] == address(0), "AKF_PNZA");
        require(_twitterKeys[twitterId] == address(0), "AKF_TNZA");
        //
        IAlphaKeysToken token = IAlphaKeysToken(
            address(new AlphaKeysTokenProxy())
        );
        token.initialize(address(this), player, name, symbol);
        //
        _playerKeys[player] = address(token);
        _keysPlayers[address(token)] = player;
        _twitterKeys[twitterId] = address(token);
        _keysTwitters[address(token)] = twitterId;
        //
        emit AlphaKeysCreatedV2(player, address(token), twitterId);
    }

    function createAlphaKeysForTwitter(
        uint256 twitterId,
        string calldata name,
        string calldata symbol,
        bytes memory signature
    ) external notContract nonReentrant {
        require(_twitterKeys[twitterId] == address(0), "AKF_TNZA");
        _verifyCreateTokenSigner(twitterId, name, symbol, signature);
        //
        IAlphaKeysToken token = IAlphaKeysToken(
            address(new AlphaKeysTokenProxy())
        );
        token.initialize(address(this), address(0), name, symbol);
        _twitterKeys[twitterId] = address(token);
        _keysTwitters[address(token)] = twitterId;
        //
        emit AlphaKeysCreatedForTwitter(address(0), address(token), twitterId);
    }

    function updateKeysPlayer(
        address token,
        address newPlayer
    ) external nonReentrant onlyAdmin {
        require(_playerKeys[newPlayer] == address(0), "AKF_PNZA");
        address oldPlayer = _keysPlayers[token];
        _playerKeys[oldPlayer] = address(0);
        //
        IAlphaKeysToken tokenIns = IAlphaKeysToken(token);
        tokenIns.updateNewPlayer(newPlayer);
        //
        _keysPlayers[token] = newPlayer;
        _playerKeys[newPlayer] = token;
    }

    function updateTwitterId(
        uint256 twitterId,
        address token
    ) external onlyAdmin onlyToken(token) {
        if (
            _twitterKeys[twitterId] == address(0) && _keysTwitters[token] == 0
        ) {
            _twitterKeys[twitterId] = token;
            _keysTwitters[token] = twitterId;
        }
    }

    // for migrate BTC

    function refundTC(uint256 amount) external nonReentrant onlyOwner {
        TransferHelper.safeTransferETH(owner(), amount);
    }

    function refundBTC(uint256 amount) external nonReentrant onlyOwner {
        address btc = _btc;
        TransferHelper.safeTransfer(btc, owner(), amount);
    }

    function requestFund(
        address token,
        address from,
        uint256 amount
    ) external onlyToken(_msgSender()) {
        if (amount > 0) {
            address vault = _vault;
            if (from == address(this)) {
                TransferHelper.safeTransfer(token, vault, amount);
            } else if (from != vault) {
                TransferHelper.safeTransferFrom(token, from, vault, amount);
            }
        }
    }

    function requestRefund(
        address token,
        address to,
        uint256 amount
    ) external onlyToken(_msgSender()) {
        if (amount > 0) {
            address vault = _vault;
            if (to != vault) {
                TransferHelper.safeTransferFrom(token, vault, to, amount);
            }
        }
    }

    // for buy keys

    function _buyKeysForV2ByToken(
        address token,
        address from,
        uint256 amountX18,
        uint256 buyPriceAfterFeeMax,
        address recipient,
        TokenTypes.OrderType orderType
    ) internal onlyToken(token) returns (uint256) {
        uint256 buyPriceAfterFee = IAlphaKeysToken(token).getBuyPriceAfterFeeV2(
            amountX18
        );
        require(buyPriceAfterFeeMax >= buyPriceAfterFee, "AKF_BBP");
        //
        IAlphaKeysToken(token).permitBuyKeysForV2(
            from,
            amountX18,
            recipient,
            orderType
        );
        return buyPriceAfterFee;
    }

    function _buyKeysForV2ByToken(
        address token,
        address from,
        uint256 amountX18,
        address recipient,
        TokenTypes.OrderType orderType
    ) internal onlyToken(token) {
        IAlphaKeysToken(token).permitBuyKeysForV2(
            from,
            amountX18,
            recipient,
            orderType
        );
    }

    function _sellKeysForV2ByToken(
        address token,
        address from,
        uint256 amountX18,
        uint256 sellPriceAfterFeeMin,
        address recipient,
        TokenTypes.OrderType orderType
    ) internal onlyToken(token) {
        require(
            sellPriceAfterFeeMin <=
                IAlphaKeysToken(token).getSellPriceAfterFeeV2(amountX18),
            "AKF_BSP"
        );
        IAlphaKeysToken(token).permitSellKeysForV2(
            from,
            amountX18,
            recipient,
            orderType
        );
    }

    function _sellKeysForV2ByToken(
        address token,
        address from,
        uint256 amountX18,
        address recipient,
        TokenTypes.OrderType orderType
    ) internal onlyToken(token) {
        IAlphaKeysToken(token).permitSellKeysForV2(
            from,
            amountX18,
            recipient,
            orderType
        );
    }

    function buyKeysForV2ByTwitterId(
        uint256 twitterId,
        uint256 amountX18,
        uint256 buyPriceAfterFeeMax,
        address recipient
    ) external notContract nonReentrant {
        address token = _twitterKeys[twitterId];
        _buyKeysForV2ByToken(
            token,
            _msgSender(),
            amountX18,
            buyPriceAfterFeeMax,
            recipient,
            TokenTypes.OrderType.SpotOrder
        );
    }

    function buyKeysV2ByToken(
        address token,
        uint256 amountX18,
        uint256 buyPriceAfterFeeMax
    ) external notContract nonReentrant {
        _buyKeysForV2ByToken(
            token,
            _msgSender(),
            amountX18,
            buyPriceAfterFeeMax,
            _msgSender(),
            TokenTypes.OrderType.SpotOrder
        );
    }

    function buyKeysForV2ByToken(
        address token,
        uint256 amountX18,
        uint256 buyPriceAfterFeeMax,
        address recipient
    ) external notContract nonReentrant {
        _buyKeysForV2ByToken(
            token,
            _msgSender(),
            amountX18,
            buyPriceAfterFeeMax,
            recipient,
            TokenTypes.OrderType.SpotOrder
        );
    }

    function sellKeysV2ByToken(
        address token,
        uint256 amountX18,
        uint256 sellPriceAfterFeeMin
    ) external notContract nonReentrant {
        _sellKeysForV2ByToken(
            token,
            _msgSender(),
            amountX18,
            sellPriceAfterFeeMin,
            _msgSender(),
            TokenTypes.OrderType.SpotOrder
        );
    }

    function sellKeysForV2ByToken(
        address token,
        uint256 amountX18,
        uint256 sellPriceAfterFeeMin,
        address recipient
    ) external notContract nonReentrant {
        _sellKeysForV2ByToken(
            token,
            _msgSender(),
            amountX18,
            sellPriceAfterFeeMin,
            recipient,
            TokenTypes.OrderType.SpotOrder
        );
    }

    // for gas station

    function getGasOrderMessageHash(
        uint256 nonce,
        address trader,
        uint256 amountBTC,
        uint256 rate,
        uint256 deadline
    ) public view returns (bytes32) {
        uint256 chainId;
        assembly {
            chainId := chainid()
        }
        return
            keccak256(
                abi.encode(
                    address(this),
                    chainId,
                    nonce,
                    trader,
                    amountBTC,
                    rate,
                    deadline
                )
            );
    }

    function _verifyGasOrderTrader(
        uint256 nonce,
        address trader,
        uint256 amountBTC,
        uint256 rate,
        uint256 deadline,
        bytes memory signature
    ) internal view returns (address, bytes32) {
        bytes32 messageHash = getGasOrderMessageHash(
            nonce,
            trader,
            amountBTC,
            rate,
            deadline
        );
        address signer = ECDSAUpgradeable.recover(
            ECDSAUpgradeable.toEthSignedMessageHash(messageHash),
            signature
        );
        // GP_NA: Signer Is Not ADmin
        require(signer == trader, "AKF_NT");
        return (signer, messageHash);
    }

    function requestTC(
        uint256 nonce,
        address trader,
        uint256 amountBTC,
        uint256 rate,
        uint256 deadline,
        bytes memory signature
    ) external notContract nonReentrant {
        require(amountBTC <= (0.00005 ether), "AKF_IA");
        require(!_usedNonces[trader][nonce], "AKF_BN");
        _usedNonces[trader][nonce] = true;
        //
        uint256 btcPrice = _btcPrice;
        require(rate == btcPrice && btcPrice > 0, "AKF_BR");
        //
        require(deadline >= _blockTimestamp(), "AKF_BD");
        //
        _verifyGasOrderTrader(
            nonce,
            trader,
            amountBTC,
            rate,
            deadline,
            signature
        );
        address btc = _btc;
        require(
            IERC20Upgradeable(btc).balanceOf(trader) >= amountBTC,
            "AKF_IBB"
        );
        //
        uint256 amountTC = amountBTC.mulPrice(btcPrice);
        //
        TransferHelper.safeTransferFrom(_btc, trader, address(this), amountBTC);
        TransferHelper.safeTransferETH(trader, amountTC);
        //
        emit TCRequested(trader, nonce, amountBTC, amountTC);
    }

    // for 3 3 order book

    function createThreeThreeOrderId(
        address tokenA,
        address tokenB,
        uint256 amount,
        uint256 buyPriceBAfterFeeMax
    ) public view returns (bytes32) {
        uint256 chainId;
        assembly {
            chainId := chainid()
        }
        return
            keccak256(
                abi.encode(
                    address(this),
                    chainId,
                    tokenA,
                    tokenB,
                    amount,
                    buyPriceBAfterFeeMax,
                    _blockNumber()
                )
            );
    }

    function getOrder(
        bytes32 orderId
    ) public view returns (ThreeThreeTypes.Order memory order) {
        return _threeThreeOrders[orderId];
    }

    // function threeThreeRequest(
    //     address tokenB,
    //     uint256 amount,
    //     uint256 buyPriceBAfterFeeMax
    // )
    //     external
    //     notContract
    //     nonReentrant
    //     onlyPlayer(_msgSender())
    //     onlyToken(tokenB)
    // {
    //     require(amount >= NumberMath.PRICE_UNIT, "AKF_ANV");
    //     //
    //     require(
    //         buyPriceBAfterFeeMax >=
    //             IAlphaKeysToken(tokenB).getBuyPriceAfterFeeV2(amount),
    //         "AKF_BBPM"
    //     );
    //     //
    //     address tokenA = _playerKeys[_msgSender()];
    //     require(tokenA != tokenB, "AKF_NET");
    //     //
    //     address ownerA = IAlphaKeysToken(tokenA).getPlayer();
    //     //
    //     require(_msgSender() == ownerA, "AKF_NOA");
    //     require(
    //         IERC20Upgradeable(_btc).balanceOf(ownerA) >= buyPriceBAfterFeeMax,
    //         "AKF_OANEB"
    //     );
    //     //
    //     bytes32 orderId = createThreeThreeOrderId(
    //         tokenA,
    //         tokenB,
    //         amount,
    //         buyPriceBAfterFeeMax
    //     );
    //     //
    //     require(_threeThreeOrders[orderId].tokenA == address(0), "AKF_BOI");
    //     //
    //     address ownerB = IAlphaKeysToken(tokenB).getPlayer();
    //     //
    //     _threeThreeOrders[orderId] = ThreeThreeTypes.Order({
    //         status: ThreeThreeTypes.OrderStatus.Unfilled,
    //         tokenA: tokenA,
    //         ownerA: ownerA,
    //         tokenB: tokenB,
    //         ownerB: ownerB,
    //         amount: amount,
    //         buyPriceBAfterFeeMax: buyPriceBAfterFeeMax,
    //         locked: true,
    //         amountA: 0,
    //         amountB: 0
    //     });
    //     //
    //     TransferHelper.safeTransferFrom(
    //         _btc,
    //         ownerA,
    //         _vault,
    //         buyPriceBAfterFeeMax
    //     );
    //     //
    //     emit ThreeThreeRequested(
    //         orderId,
    //         tokenA,
    //         ownerA,
    //         tokenB,
    //         ownerB,
    //         amount,
    //         buyPriceBAfterFeeMax
    //     );
    // }

    // function threeThreeTrade(
    //     bytes32 orderId,
    //     uint256 buyPriceAAfterFeeMax
    // ) external notContract nonReentrant {
    //     require(buyPriceAAfterFeeMax > 0, "AKF_BPNZ");
    //     //
    //     ThreeThreeTypes.Order storage order = _threeThreeOrders[orderId];
    //     //
    //     require(
    //         order.status == ThreeThreeTypes.OrderStatus.Unfilled,
    //         "AKF_BOS"
    //     );
    //     require(!order.locked, "AKF_BOT");
    //     //
    //     address tokenB = order.tokenB;
    //     address ownerB = IAlphaKeysToken(tokenB).getPlayer();
    //     //
    //     require(_msgSender() == ownerB, "AKF_NOB");
    //     // save ownerB
    //     order.ownerB = ownerB;
    //     order.status = ThreeThreeTypes.OrderStatus.Filled;
    //     //
    //     address ownerA = order.ownerA;
    //     address tokenA = order.tokenA;
    //     uint256 amount = order.amount;
    //     uint256 buyPriceBAfterFeeMax = order.buyPriceBAfterFeeMax;
    //     //
    //     address vault = _vault;
    //     //
    //     uint256 buyPriceAfterFee = _buyKeysForV2ByToken(
    //         tokenB,
    //         vault,
    //         amount,
    //         buyPriceBAfterFeeMax,
    //         ownerA,
    //         TokenTypes.OrderType.ThreeThreeOrder
    //     );
    //     uint256 refundAmount = buyPriceBAfterFeeMax.sub(buyPriceAfterFee);
    //     if (refundAmount > 0) {
    //         TransferHelper.safeTransferFrom(_btc, vault, ownerA, refundAmount);
    //     }
    //     //
    //     _buyKeysForV2ByToken(
    //         tokenA,
    //         ownerB,
    //         amount,
    //         buyPriceAAfterFeeMax,
    //         ownerB,
    //         TokenTypes.OrderType.ThreeThreeOrder
    //     );
    //     //
    //     emit ThreeThreeTrade(orderId, tokenA, ownerA, tokenB, ownerB, amount);
    //     //
    //     IAlphaKeysToken(tokenA).permitLock30D(ownerB, amount);
    //     IAlphaKeysToken(tokenB).permitLock30D(ownerA, amount);
    // }

    function threeThreeRequestBTC(
        address tokenB,
        uint256 buyPriceBAfterFeeMax
    )
        external
        notContract
        nonReentrant
        onlyPlayer(_msgSender())
        onlyToken(tokenB)
    {
        require(buyPriceBAfterFeeMax > 0, "AKF_BPNZ");
        //
        address tokenA = _playerKeys[_msgSender()];
        require(tokenA != tokenB, "AKF_NET");
        //
        require(
            buyPriceBAfterFeeMax >=
                IAlphaKeysToken(tokenA).getBuyPriceAfterFeeV2(
                    NumberMath.PRICE_UNIT
                ) &&
                buyPriceBAfterFeeMax >=
                IAlphaKeysToken(tokenB).getBuyPriceAfterFeeV2(
                    NumberMath.PRICE_UNIT
                ),
            "AKF_BBPM"
        );
        //
        address ownerA = IAlphaKeysToken(tokenA).getPlayer();
        //
        require(_msgSender() == ownerA, "AKF_NOA");
        require(
            IERC20Upgradeable(_btc).balanceOf(ownerA) >= buyPriceBAfterFeeMax,
            "AKF_OANEB"
        );
        //
        bytes32 orderId = createThreeThreeOrderId(
            tokenA,
            tokenB,
            0,
            buyPriceBAfterFeeMax
        );
        //
        require(_threeThreeOrders[orderId].tokenA == address(0), "AKF_BOI");
        //
        address ownerB = IAlphaKeysToken(tokenB).getPlayer();
        //
        _threeThreeOrders[orderId] = ThreeThreeTypes.Order({
            status: ThreeThreeTypes.OrderStatus.Unfilled,
            tokenA: tokenA,
            ownerA: ownerA,
            tokenB: tokenB,
            ownerB: ownerB,
            amount: 0,
            buyPriceBAfterFeeMax: buyPriceBAfterFeeMax,
            locked: true,
            amountA: 0,
            amountB: 0
        });
        //
        TransferHelper.safeTransferFrom(
            _btc,
            ownerA,
            _vault,
            buyPriceBAfterFeeMax
        );
        //
        emit ThreeThreeRequested(
            orderId,
            tokenA,
            ownerA,
            tokenB,
            ownerB,
            0,
            buyPriceBAfterFeeMax
        );
    }

    function threeThreeTradeBTC(
        bytes32 orderId
    ) external notContract nonReentrant {
        ThreeThreeTypes.Order storage order = _threeThreeOrders[orderId];
        //
        require(
            order.status == ThreeThreeTypes.OrderStatus.Unfilled,
            "AKF_BOS"
        );
        require(order.locked, "AKF_ONL");
        require(order.amount == 0, "AKF_ONR");
        //
        address tokenB = order.tokenB;
        address ownerB = IAlphaKeysToken(tokenB).getPlayer();
        //
        require(_msgSender() == ownerB, "AKF_NOB");
        // save ownerB
        order.ownerB = ownerB;
        order.status = ThreeThreeTypes.OrderStatus.Filled;
        //
        address ownerA = order.ownerA;
        address tokenA = order.tokenA;
        uint256 buyPriceBAfterFeeMax = order.buyPriceBAfterFeeMax;
        uint24 protocolFeeRatioA = IAlphaKeysToken(tokenA)
            .getProtocolFeeRatio();
        uint24 playerFeeRatioA = IAlphaKeysToken(tokenA).getPlayerFeeRatio();
        uint256 amountA = NumberMath.getBuyAmountMaxWithCash(
            protocolFeeRatioA,
            playerFeeRatioA,
            tokenA,
            buyPriceBAfterFeeMax
        );
        uint24 protocolFeeRatioB = IAlphaKeysToken(tokenB)
            .getProtocolFeeRatio();
        uint24 playerFeeRatioB = IAlphaKeysToken(tokenB).getPlayerFeeRatio();
        uint256 amountB = NumberMath.getBuyAmountMaxWithCash(
            protocolFeeRatioB,
            playerFeeRatioB,
            tokenB,
            buyPriceBAfterFeeMax
        );
        order.amountA = amountA;
        order.amountB = amountB;
        // AKF_BANM: buy amount not min
        require(amountA > 0 && amountB > 0, "AKF_BANM");
        //
        address vault = _vault;
        //
        uint256 buyPriceAfterFee = _buyKeysForV2ByToken(
            tokenB,
            vault,
            amountB,
            buyPriceBAfterFeeMax,
            ownerA,
            TokenTypes.OrderType.ThreeThreeOrder
        );
        uint256 refundAmount = buyPriceBAfterFeeMax.sub(buyPriceAfterFee);
        if (refundAmount > 0) {
            TransferHelper.safeTransferFrom(_btc, vault, ownerA, refundAmount);
        }
        //
        _buyKeysForV2ByToken(
            tokenA,
            ownerB,
            amountA,
            buyPriceBAfterFeeMax,
            ownerB,
            TokenTypes.OrderType.ThreeThreeOrder
        );
        //
        emit ThreeThreeTradeBTC(
            orderId,
            tokenA,
            ownerA,
            tokenB,
            ownerB,
            amountA,
            amountB
        );
        //
        IAlphaKeysToken(tokenA).permitLock30D(ownerB, amountA);
        IAlphaKeysToken(tokenB).permitLock30D(ownerA, amountB);
    }

    function threeThreeCancel(
        bytes32 orderId
    ) external notContract nonReentrant {
        ThreeThreeTypes.Order storage order = _threeThreeOrders[orderId];
        //
        require(
            order.status == ThreeThreeTypes.OrderStatus.Unfilled,
            "AKF_BOS"
        );
        require(order.locked, "AKF_ONL");
        //
        address tokenA = order.tokenA;
        require(tokenA != address(0), "AKF_ITA");
        //
        address ownerA = IAlphaKeysToken(tokenA).getPlayer();
        require(_msgSender() == ownerA, "AKF_IOA");
        //
        order.status = ThreeThreeTypes.OrderStatus.Cancelled;
        //
        TransferHelper.safeTransferFrom(
            _btc,
            _vault,
            ownerA,
            order.buyPriceBAfterFeeMax
        );
        //
        emit ThreeThreeCancelled(orderId, tokenA, ownerA);
    }

    function threeThreeReject(
        bytes32 orderId
    ) external notContract nonReentrant {
        ThreeThreeTypes.Order storage order = _threeThreeOrders[orderId];
        //
        require(
            order.status == ThreeThreeTypes.OrderStatus.Unfilled,
            "AKF_BOS"
        );
        require(order.locked, "AKF_ONL");
        //
        address tokenB = order.tokenB;
        require(tokenB != address(0), "AKF_ITB");
        //
        address ownerB = IAlphaKeysToken(tokenB).getPlayer();
        require(_msgSender() == ownerB, "AKF_IOB");
        //
        address tokenA = order.tokenA;
        require(tokenA != address(0), "AKF_ITA");
        address ownerA = IAlphaKeysToken(tokenA).getPlayer();
        //
        order.status = ThreeThreeTypes.OrderStatus.Rejected;
        //
        TransferHelper.safeTransferFrom(
            _btc,
            _vault,
            ownerA,
            order.buyPriceBAfterFeeMax
        );
        //
        emit ThreeThreeRejected(orderId, tokenB, ownerB);
    }

    // for limit order

    function limitOrderCreate(
        uint256 nonce,
        address token,
        bool isBuy,
        uint256 amount,
        uint256 triggerPrice,
        uint256 buyPriceAfterFeeMax
    ) external notContract nonReentrant {
        address trader = _msgSender();
        LimitOrderTypes.Order storage order = _limitOrders[trader][nonce];
        require(order.trader == address(0), "AKF_BT");
        require(amount > 0 && buyPriceAfterFeeMax > 0, "AKF_BR");
        //
        order.trader = trader;
        order.token = token;
        order.isBuy = isBuy;
        order.amount = amount;
        order.triggerPrice = triggerPrice;
        order.buyPriceAfterFeeMax = buyPriceAfterFeeMax;
        order.status = LimitOrderTypes.OrderStatus.Unfilled;
        //
        TransferHelper.safeTransferFrom(
            _btc,
            trader,
            _vault,
            buyPriceAfterFeeMax
        );
        //
        emit LimitOrderCreated(
            nonce,
            trader,
            token,
            isBuy,
            amount,
            triggerPrice,
            buyPriceAfterFeeMax
        );
    }

    function limitOrderFill(
        uint256 nonce,
        address trader
    ) external notContract nonReentrant {
        LimitOrderTypes.Order storage order = _limitOrders[trader][nonce];
        require(order.trader == trader, "AKF_BT");
        require(
            order.status == LimitOrderTypes.OrderStatus.Unfilled,
            "AKF_BOS"
        );
        //
        _limitOrders[trader][nonce].status = LimitOrderTypes.OrderStatus.Filled;
        // fill order
        address token = order.token;
        uint256 triggerPrice = order.triggerPrice;
        uint256 amount = order.amount;
        bool isBuy = order.isBuy;
        uint256 buyPriceAfterFeeMax = order.buyPriceAfterFeeMax;
        //
        if (isBuy) {
            require(
                IAlphaKeysToken(token).getBuyPriceV2(NumberMath.ONE_ETHER) <=
                    triggerPrice,
                "AKF_BTBP"
            );
            // fill order
            address vault = _vault;
            uint256 buyPriceAfterFee = _buyKeysForV2ByToken(
                token,
                vault,
                amount,
                buyPriceAfterFeeMax,
                trader,
                TokenTypes.OrderType.LimitOrder
            );
            // refund
            uint256 refundAmount = buyPriceAfterFeeMax.sub(buyPriceAfterFee);
            if (refundAmount > 0) {
                address btc = _btc;
                TransferHelper.safeTransferFrom(
                    btc,
                    vault,
                    trader,
                    refundAmount
                );
            }
        } else {
            require(
                IAlphaKeysToken(token).getBuyPriceV2(NumberMath.ONE_ETHER) >=
                    triggerPrice,
                "AKF_BTSP"
            );
            _sellKeysForV2ByToken(
                token,
                trader,
                amount,
                trader,
                TokenTypes.OrderType.LimitOrder
            );
        }
        emit LimitOrderFilled(nonce, trader, token, isBuy, amount);
    }

    function limitOrderCancel(uint256 nonce) external notContract nonReentrant {
        address trader = _msgSender();
        LimitOrderTypes.Order storage order = _limitOrders[trader][nonce];
        require(order.trader == trader, "AKF_BT");
        require(
            order.status == LimitOrderTypes.OrderStatus.Unfilled,
            "AKF_BOS"
        );
        order.status = LimitOrderTypes.OrderStatus.Cancelled;
        //
        TransferHelper.safeTransferFrom(
            _btc,
            _vault,
            trader,
            order.buyPriceAfterFeeMax
        );
        //
        emit LimitOrderCancelled(nonce, trader);
    }
}
        

contracts/interfaces/IAlphaKeysFactory.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;

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

interface IAlphaKeysFactory is IAlphaKeysFactoryImpl {
    //
    event AlphaKeysCreated(address indexed player, address indexed token);
    event AlphaKeysCreatedV2(
        address indexed player,
        address indexed token,
        uint256 indexed twitterId
    );
    event AlphaKeysCreatedForTwitter(
        address indexed player,
        address indexed token,
        uint256 indexed twitterId
    );

    event TCRequested(
        address indexed trader,
        uint256 indexed nonce,
        uint256 amountBTC,
        uint256 amountTC
    );

    event ThreeThreeRequested(
        bytes32 indexed orderId,
        address indexed tokenA,
        address ownerA,
        address indexed tokenB,
        address ownerB,
        uint256 amount,
        uint256 buyPriceBAfterFeeMax
    );

    event ThreeThreeTrade(
        bytes32 indexed orderId,
        address indexed tokenA,
        address ownerA,
        address indexed tokenB,
        address ownerB,
        uint256 amount
    );

    event ThreeThreeTradeBTC(
        bytes32 indexed orderId,
        address indexed tokenA,
        address ownerA,
        address indexed tokenB,
        address ownerB,
        uint256 amountA,
        uint256 amountB
    );

    event ThreeThreeCancelled(
        bytes32 indexed orderId,
        address indexed tokenA,
        address ownerA
    );

    event ThreeThreeRejected(
        bytes32 indexed orderId,
        address indexed tokenB,
        address ownerB
    );

    event LimitOrderCreated(
        uint256 indexed nonce,
        address indexed trader,
        address indexed token,
        bool isBuy,
        uint256 amount,
        uint256 triggerPrice,
        uint256 buyPriceAfterFeeMax
    );

    event LimitOrderFilled(
        uint256 indexed nonce,
        address indexed trader,
        address indexed token,
        bool isBuy,
        uint256 amount
    );

    event LimitOrderCancelled(uint256 indexed nonce, address indexed trader);

    //
    function getBTC() external view returns (address);

    function getVault() external view returns (address);

    function getProtocolFeeRatio() external view returns (uint24);

    function getPlayerFeeRatio() external view returns (uint24);

    function getProtocolFeeDestination() external view returns (address);

    function requestFund(address token, address from, uint256 amount) external;

    function requestRefund(address token, address to, uint256 amount) external;
}
          

contracts/interfaces/IAlphaKeysFactoryImpl.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;

interface IAlphaKeysFactoryImpl {
    function getAlphaKeysTokenImplementation()
        external
        view
        returns (address);
}
          

@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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 Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        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;
}
          

@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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]
 * ```solidity
 * 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.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 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.
     *
     * 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.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * 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.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _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.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}
          

@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

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

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

@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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);
}
          

@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [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://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
          

@openzeppelin/contracts-upgradeable/utils/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;
}
          

@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol

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

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";
import "./math/SignedMathUpgradeable.sol";

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

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

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

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

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

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

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

@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol

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

pragma solidity ^0.8.0;

import "../StringsUpgradeable.sol";

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

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

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

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

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

        return (signer, RecoverError.NoError);
    }

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

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32")
            mstore(0x1c, hash)
            message := keccak256(0x00, 0x3c)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, "\x19\x01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            data := keccak256(ptr, 0x42)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Data with intended validator, created from a
     * `validator` and `data` according to the version 0 of EIP-191.
     *
     * See {recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x00", validator, data));
    }
}
          

@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol

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

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

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

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

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

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

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

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

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

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

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

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

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

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

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

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

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

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

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

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

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

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

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

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

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

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

contracts/interfaces/IAlphaKeysToken.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;

import {TokenTypes} from "../libraries/TokenTypes.sol";

interface IAlphaKeysToken {
    //
    event Trade(
        address trader,
        address player,
        bool isBuy,
        uint256 shareAmount,
        uint256 tcAmount,
        uint256 protocolFeeAmount,
        uint256 playerFeeAmount,
        uint256 supply
    );

    event TradeV2(
        address trader,
        address player,
        bool isBuy,
        uint256 shareAmount,
        uint256 tcAmount,
        uint256 protocolFeeAmount,
        uint256 playerFeeAmount,
        uint256 supply
    );

    event TradeV3(
        address trader,
        address player,
        bool isBuy,
        uint256 shareAmount,
        uint256 btcAmount,
        uint256 protocolBtcFeeAmount,
        uint256 playerBtcFeeAmount,
        uint256 supply
    );

    event TradeV4(
        address trader,
        address player,
        bool isBuy,
        uint256 shareAmount,
        uint256 btcAmount,
        uint256 protocolBtcFeeAmount,
        uint256 playerBtcFeeAmount,
        uint256 supply,
        TokenTypes.OrderType orderType,
        bytes32 orderId
    );

    event PlayerUpdated(address indexed oldPlayer, address indexed newPlayer);

    event BTCMigrated(uint256 amountTC, uint256 amountBTC);

    event LockedTs(
        address user,
        uint256 amount,
        uint256 duationTs,
        uint256 expiredTs
    );

    event PlayerFeeRatioUpdated(uint24 playerFeeRatio);

    //
    function initialize(
        address factory,
        address manager,
        string calldata name,
        string calldata symbol
    ) external;

    function getPlayer() external view returns (address);

    function getProtocolFeeRatio() external view returns (uint24);

    function getPlayerFeeRatio() external view returns (uint24);

    function getBuyPriceAfterFeeV2(
        uint256 amountX18
    ) external view returns (uint256);

    function getBuyPriceV2(uint256 amountX18) external view returns (uint256);

    function getSellPriceAfterFeeV2(
        uint256 amountX18
    ) external view returns (uint256);

    function updateNewPlayer(address newPlayer) external;

    function permitBuyKeysForV2(
        address from,
        uint256 amountX18,
        address recipient,
        TokenTypes.OrderType orderType
    ) external;

    function permitSellKeysForV2(
        address from,
        uint256 amountX18,
        address recipient,
        TokenTypes.OrderType orderType
    ) external;

    function permitLock30D(address user, uint256 amount) external;
}
          

contracts/interfaces/IAlphaKeysVault.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;

import {TokenTypes} from "../libraries/TokenTypes.sol";

interface IAlphaKeysVault {
}
          

@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMathUpgradeable {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

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

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

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

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

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}
          

@openzeppelin/contracts-upgradeable/utils/math/SignedMathUpgradeable.sol

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

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMathUpgradeable {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

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

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

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}
          

@openzeppelin/contracts/proxy/Proxy.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)

pragma solidity ^0.8.0;

/**
 * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
 * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
 * be specified by overriding the virtual {_implementation} function.
 *
 * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
 * different contract through the {_delegate} function.
 *
 * The success and return data of the delegated call will be returned back to the caller of the proxy.
 */
abstract contract Proxy {
    /**
     * @dev Delegates the current call to `implementation`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _delegate(address implementation) internal virtual {
        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    /**
     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
     * and {_fallback} should delegate.
     */
    function _implementation() internal view virtual returns (address);

    /**
     * @dev Delegates the current call to the address returned by `_implementation()`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _fallback() internal virtual {
        _beforeFallback();
        _delegate(_implementation());
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
     * function in the contract matches the call data.
     */
    fallback() external payable virtual {
        _fallback();
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
     * is empty.
     */
    receive() external payable virtual {
        _fallback();
    }

    /**
     * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
     * call, or as part of the Solidity `fallback` or `receive` functions.
     *
     * If overridden should call `super._beforeFallback()`.
     */
    function _beforeFallback() internal virtual {}
}
          

contracts/AlphaKeysTokenProxy.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import {Proxy} from "@openzeppelin/contracts/proxy/Proxy.sol";
import {IAlphaKeysFactoryImpl} from "./interfaces/IAlphaKeysFactoryImpl.sol";

/**
 * @title AlphaKeysTokenProxy
 * @author 0xkongamoto
 */
contract AlphaKeysTokenProxy is Proxy {
    //
    IAlphaKeysFactoryImpl public immutable factory;

    // ======== Constructor =========
    constructor() {
        factory = IAlphaKeysFactoryImpl(msg.sender);
    }

    /**
     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
     * and {_fallback} should delegate.
     */
    function _implementation()
        internal
        view
        virtual
        override
        returns (address impl)
    {
        return factory.getAlphaKeysTokenImplementation();
    }
}
          

contracts/base/BlockContext.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;

abstract contract BlockContext {
    function _blockTimestamp() internal view virtual returns (uint256) {
        // Reply from Arbitrum
        // block.timestamp returns timestamp at the time at which the sequencer receives the tx.
        // It may not actually correspond to a particular L1 block
        return block.timestamp;
    }

    function _blockNumber() internal view virtual returns (uint256) {
        return block.number;
    }
}
          

contracts/base/Multicall.sol

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >0.8.0;

/// @title Multicall
/// @notice Enables calling multiple methods in a single call to the contract
abstract contract Multicall {
    function multicall(
        bytes[] calldata data
    ) public payable returns (bytes[] memory results) {
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            (bool success, bytes memory result) = address(this).delegatecall(
                data[i]
            );

            if (!success) {
                // Next 5 lines from https://ethereum.stackexchange.com/a/83577
                if (result.length < 68) revert();
                assembly {
                    result := add(result, 0x04)
                }
                revert(abi.decode(result, (string)));
            }

            results[i] = result;
        }
    }
}
          

contracts/libraries/LimitOrderTypes.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

library LimitOrderTypes {
    enum OrderStatus {
        Unfilled,
        Filled,
        CancelledNotRefund,
        Cancelled
    }

    struct Order {
        OrderStatus status;
        address trader;
        address token;
        bool isBuy;
        uint256 amount;
        uint256 triggerPrice;
        uint256 buyPriceAfterFeeMax;
    }
}
          

contracts/libraries/NumberMath.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import {SafeMathUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

library NumberMath {
    // CONST
    uint256 internal constant RATIO = 1e6;
    using SafeMathUpgradeable for uint256;

    uint256 internal constant ONE_ETHER = 1 ether;
    uint256 internal constant PRICE_UNIT = 0.1 ether;
    uint256 internal constant NUMBER_UNIT_PER_ONE_ETHER =
        ONE_ETHER / PRICE_UNIT;

    uint256 internal constant PRICE_BTC_PER_TC = 0.000416666666666667 ether; // 1 BTC = 2400 TC
    uint256 internal constant PRICE_TC_PER_BTC = 2400 ether; // 1 BTC = 2400 TC
    uint256 internal constant PRICE_KEYS_DENOMINATOR = 264000;

    uint256 internal constant TS_30_DAYS = 30 days;

    //
    function mulRatio(
        uint256 value,
        uint24 ratio
    ) internal pure returns (uint256) {
        return value.mul(ratio).div(RATIO);
    }

    function mulEther(uint256 value) internal pure returns (uint256) {
        return value.mul(1 ether);
    }

    function divEther(uint256 value) internal pure returns (uint256) {
        return value.div(1 ether);
    }

    function mulPrice(
        uint256 value,
        uint256 rate
    ) internal pure returns (uint256) {
        return value.mul(rate).div(1 ether);
    }

    function getPriceV2(
        uint256 supply,
        uint256 amount
    ) internal pure returns (uint256) {
        uint256 sum1 = supply == 0
            ? 0
            : ((supply - NUMBER_UNIT_PER_ONE_ETHER) *
                supply *
                (2 *
                    (supply - NUMBER_UNIT_PER_ONE_ETHER) +
                    NUMBER_UNIT_PER_ONE_ETHER)) / 6;
        uint256 sum2 = supply == 0 && amount == 1
            ? 0
            : ((supply - NUMBER_UNIT_PER_ONE_ETHER + amount) *
                (supply + amount) *
                (2 *
                    (supply - NUMBER_UNIT_PER_ONE_ETHER + amount) +
                    NUMBER_UNIT_PER_ONE_ETHER)) / 6;
        uint256 summation = sum2 - sum1;
        return
            (summation * ONE_ETHER) /
            PRICE_KEYS_DENOMINATOR /
            (NUMBER_UNIT_PER_ONE_ETHER *
                NUMBER_UNIT_PER_ONE_ETHER *
                NUMBER_UNIT_PER_ONE_ETHER);
    }

    function getBuyPriceV2(
        uint256 supply,
        uint256 amountX18
    ) internal pure returns (uint256) {
        return
            getPriceV2(supply.div(PRICE_UNIT), amountX18.div(PRICE_UNIT)).add(
                1
            );
    }

    function getBuyPriceV2AfterFee(
        uint24 protocolFeeRatio,
        uint24 playerFeeRatio,
        uint256 supply,
        uint256 amountX18
    ) internal pure returns (uint256) {
        //
        uint256 price = getBuyPriceV2(supply, amountX18);
        uint256 protocolFee = mulRatio(price, protocolFeeRatio);
        uint256 playerFee = mulRatio(price, playerFeeRatio);
        return price.add(protocolFee).add(playerFee);
    }

    function getBuyAmountMaxWithCash(
        uint24 protocolFeeRatio,
        uint24 playerFeeRatio,
        address token,
        uint256 buyPriceAfterFeeMax
    ) internal view returns (uint256) {
        uint256 supply = IERC20Upgradeable(token).totalSupply();
        uint256 amount = 0;
        while (true) {
            uint256 buyPriceAfterFee = getBuyPriceV2AfterFee(
                protocolFeeRatio,
                playerFeeRatio,
                supply,
                amount.add(ONE_ETHER)
            );
            if (buyPriceAfterFee > buyPriceAfterFeeMax) {
                while (true) {
                    buyPriceAfterFee = getBuyPriceV2AfterFee(
                        protocolFeeRatio,
                        playerFeeRatio,
                        supply,
                        amount.add(PRICE_UNIT)
                    );
                    if (buyPriceAfterFee > buyPriceAfterFeeMax) {
                        break;
                    }
                    amount = amount.add(PRICE_UNIT);
                }
                break;
            }
            amount = amount.add(ONE_ETHER);
        }
        return amount;
    }
}
          

contracts/libraries/ThreeThreeTypes.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

library ThreeThreeTypes {
    enum OrderStatus {
        Unfilled,
        Filled,
        Cancelled,
        Rejected
    }

    struct Order {
        OrderStatus status;
        address tokenA;
        address ownerA;
        address tokenB;
        address ownerB;
        uint256 amount;
        uint256 buyPriceBAfterFeeMax;
        bool locked;
        uint256 amountA;
        uint256 amountB;
    }
}
          

contracts/libraries/TokenTypes.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

library TokenTypes {
    enum OrderType {
        SpotOrder,
        ThreeThreeOrder,
        LimitOrder,
        WatchlistOrder
    }

    struct Locked {
        uint256 amount;
        uint256 expiredTs;
    }
}
          

contracts/libraries/TransferHelper.sol

// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity >=0.8.0;

// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('approve(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::safeApprove: approve failed'
        );
    }

    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transfer(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::safeTransfer: transfer failed'
        );
    }

    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::transferFrom: transferFrom failed'
        );
    }

    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
    }
}
          

contracts/storage/AlphaKeysFactoryStorage.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;

import {ThreeThreeTypes} from "../libraries/ThreeThreeTypes.sol";
import {LimitOrderTypes} from "../libraries/LimitOrderTypes.sol";

abstract contract AlphaKeysFactoryStorage {
    //
    address internal _playerShareTokenImplementation;
    //
    uint24 internal _protocolFeeRatio;
    uint24 internal _playerFeeRatio;
    address internal _protocolFeeDestination;
    //
    mapping(address => address) internal _playerKeys;
    mapping(address => address) internal _keysPlayers;
    mapping(uint256 => address) internal _twitterKeys;
    mapping(address => uint256) internal _keysTwitters;
    //
    address internal _admin;
    address internal _btc;
    uint256 internal _btcPrice;
    // for gas
    mapping(address => mapping(uint256 => bool)) _usedNonces;
    // three three model
    mapping(bytes32 => ThreeThreeTypes.Order) _threeThreeOrders;
    // vault address
    address internal _vault;
    address internal _swapRouter;
    // limit orders
    mapping(address => mapping(uint256 => LimitOrderTypes.Order)) _limitOrders;
}
          

Compiler Settings

{"viaIR":true,"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{}}
              

Contract ABI

[{"type":"event","name":"AlphaKeysCreated","inputs":[{"type":"address","name":"player","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"AlphaKeysCreatedForTwitter","inputs":[{"type":"address","name":"player","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"twitterId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"AlphaKeysCreatedV2","inputs":[{"type":"address","name":"player","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"twitterId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"LimitOrderCancelled","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256","indexed":true},{"type":"address","name":"trader","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"LimitOrderCreated","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256","indexed":true},{"type":"address","name":"trader","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"bool","name":"isBuy","internalType":"bool","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"triggerPrice","internalType":"uint256","indexed":false},{"type":"uint256","name":"buyPriceAfterFeeMax","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LimitOrderFilled","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256","indexed":true},{"type":"address","name":"trader","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"bool","name":"isBuy","internalType":"bool","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TCRequested","inputs":[{"type":"address","name":"trader","internalType":"address","indexed":true},{"type":"uint256","name":"nonce","internalType":"uint256","indexed":true},{"type":"uint256","name":"amountBTC","internalType":"uint256","indexed":false},{"type":"uint256","name":"amountTC","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ThreeThreeCancelled","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32","indexed":true},{"type":"address","name":"tokenA","internalType":"address","indexed":true},{"type":"address","name":"ownerA","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"ThreeThreeRejected","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32","indexed":true},{"type":"address","name":"tokenB","internalType":"address","indexed":true},{"type":"address","name":"ownerB","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"ThreeThreeRequested","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32","indexed":true},{"type":"address","name":"tokenA","internalType":"address","indexed":true},{"type":"address","name":"ownerA","internalType":"address","indexed":false},{"type":"address","name":"tokenB","internalType":"address","indexed":true},{"type":"address","name":"ownerB","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"buyPriceBAfterFeeMax","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ThreeThreeTrade","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32","indexed":true},{"type":"address","name":"tokenA","internalType":"address","indexed":true},{"type":"address","name":"ownerA","internalType":"address","indexed":false},{"type":"address","name":"tokenB","internalType":"address","indexed":true},{"type":"address","name":"ownerB","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ThreeThreeTradeBTC","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32","indexed":true},{"type":"address","name":"tokenA","internalType":"address","indexed":true},{"type":"address","name":"ownerA","internalType":"address","indexed":false},{"type":"address","name":"tokenB","internalType":"address","indexed":true},{"type":"address","name":"ownerB","internalType":"address","indexed":false},{"type":"uint256","name":"amountA","internalType":"uint256","indexed":false},{"type":"uint256","name":"amountB","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"buyKeysForV2ByToken","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"amountX18","internalType":"uint256"},{"type":"uint256","name":"buyPriceAfterFeeMax","internalType":"uint256"},{"type":"address","name":"recipient","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"buyKeysForV2ByTwitterId","inputs":[{"type":"uint256","name":"twitterId","internalType":"uint256"},{"type":"uint256","name":"amountX18","internalType":"uint256"},{"type":"uint256","name":"buyPriceAfterFeeMax","internalType":"uint256"},{"type":"address","name":"recipient","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"buyKeysV2ByToken","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"amountX18","internalType":"uint256"},{"type":"uint256","name":"buyPriceAfterFeeMax","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createAlphaKeysForTwitter","inputs":[{"type":"uint256","name":"twitterId","internalType":"uint256"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"symbol","internalType":"string"},{"type":"bytes","name":"signature","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createAlphaKeysForV2","inputs":[{"type":"uint256","name":"twitterId","internalType":"uint256"},{"type":"address","name":"player","internalType":"address"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"symbol","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"createThreeThreeOrderId","inputs":[{"type":"address","name":"tokenA","internalType":"address"},{"type":"address","name":"tokenB","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"buyPriceBAfterFeeMax","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getAdmin","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getAlphaKeysTokenImplementation","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getBTC","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getBTCPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getCreateForTwitterMessageHash","inputs":[{"type":"uint256","name":"twitterId","internalType":"uint256"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"symbol","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getGasOrderMessageHash","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"address","name":"trader","internalType":"address"},{"type":"uint256","name":"amountBTC","internalType":"uint256"},{"type":"uint256","name":"rate","internalType":"uint256"},{"type":"uint256","name":"deadline","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getKeysPlayer","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getKeysTwitters","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"order","internalType":"struct ThreeThreeTypes.Order","components":[{"type":"uint8","name":"status","internalType":"enum ThreeThreeTypes.OrderStatus"},{"type":"address","name":"tokenA","internalType":"address"},{"type":"address","name":"ownerA","internalType":"address"},{"type":"address","name":"tokenB","internalType":"address"},{"type":"address","name":"ownerB","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"buyPriceBAfterFeeMax","internalType":"uint256"},{"type":"bool","name":"locked","internalType":"bool"},{"type":"uint256","name":"amountA","internalType":"uint256"},{"type":"uint256","name":"amountB","internalType":"uint256"}]}],"name":"getOrder","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint24","name":"","internalType":"uint24"}],"name":"getPlayerFeeRatio","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getPlayerKeys","inputs":[{"type":"address","name":"player","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getProtocolFeeDestination","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint24","name":"","internalType":"uint24"}],"name":"getProtocolFeeRatio","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getTwitterKeys","inputs":[{"type":"uint256","name":"twitterId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getVault","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"limitOrderCancel","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"limitOrderCreate","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"address","name":"token","internalType":"address"},{"type":"bool","name":"isBuy","internalType":"bool"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"triggerPrice","internalType":"uint256"},{"type":"uint256","name":"buyPriceAfterFeeMax","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"limitOrderFill","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"address","name":"trader","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[{"type":"bytes[]","name":"results","internalType":"bytes[]"}],"name":"multicall","inputs":[{"type":"bytes[]","name":"data","internalType":"bytes[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"refundBTC","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"refundTC","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"requestFund","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"address","name":"from","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"requestRefund","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"requestTC","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"address","name":"trader","internalType":"address"},{"type":"uint256","name":"amountBTC","internalType":"uint256"},{"type":"uint256","name":"rate","internalType":"uint256"},{"type":"uint256","name":"deadline","internalType":"uint256"},{"type":"bytes","name":"signature","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"sellKeysForV2ByToken","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"amountX18","internalType":"uint256"},{"type":"uint256","name":"sellPriceAfterFeeMin","internalType":"uint256"},{"type":"address","name":"recipient","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"sellKeysV2ByToken","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"amountX18","internalType":"uint256"},{"type":"uint256","name":"sellPriceAfterFeeMin","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setAdmin","inputs":[{"type":"address","name":"admin","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setAlphaKeysTokenImplementation","inputs":[{"type":"address","name":"playerShareTokenImplementationArg","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBTC","inputs":[{"type":"address","name":"btc","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBTCPrice","inputs":[{"type":"uint256","name":"btcPrice","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPlayerFeeRatio","inputs":[{"type":"uint24","name":"playerFeeRatio","internalType":"uint24"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setProtocolFeeDestination","inputs":[{"type":"address","name":"protocolFeeDestination","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setProtocolFeeRatio","inputs":[{"type":"uint24","name":"protocolFeeRatio","internalType":"uint24"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setVault","inputs":[{"type":"address","name":"vault","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"threeThreeCancel","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"threeThreeReject","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"threeThreeRequestBTC","inputs":[{"type":"address","name":"tokenB","internalType":"address"},{"type":"uint256","name":"buyPriceBAfterFeeMax","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"threeThreeTradeBTC","inputs":[{"type":"bytes32","name":"orderId","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateKeysPlayer","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"address","name":"newPlayer","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateTwitterId","inputs":[{"type":"uint256","name":"twitterId","internalType":"uint256"},{"type":"address","name":"token","internalType":"address"}]},{"type":"receive","stateMutability":"payable"}]
              

Contract Creation Code

0x6080806040523461001657614cc2908161001c8239f35b600080fdfe608060405260043610156200001d575b36156200001b57600080fd5b005b60003560e01c806309c7a25c14620003a0578063284be215146200039a5780632b806fba14620003945780633f566994146200038e5780635778472a14620003885780635b315883146200038257806366454421146200037c5780636817031b14620003765780636e5bf35e14620003705780636e9960c3146200036a578063704b6c021462000364578063715018a6146200035e5780637150238214620003585780637187f90f146200035257806374567f0f146200034c5780637aabab0714620003465780637cf4626b14620003405780638129fc1c146200033a578063826db8ac14620003345780638b3aaecd146200032e5780638b71c3cf14620003285780638d928af814620003225780638da5cb5b146200031c5780638db462fc14620003165780639020597a146200031057806396910b91146200030a578063a10786b01462000304578063a14c0d6214620002fe578063a43aa23614620002f8578063a4bf9d0614620002f2578063a541daf614620002ec578063a8b8a55d14620002e6578063ac9650d814620002e0578063b479b15e14620002da578063b8a946e614620002d4578063bab1fbaa14620002ce578063bb36d59a14620002c8578063cce05ddf14620002c2578063cdb1e3ca14620002bc578063ced7a53914620002b6578063d021a6e714620002b0578063d1ce35e314620002aa578063d39869f214620002a4578063d590be2f146200029e578063da6c85491462000298578063dd0bcbe31462000292578063dd22db80146200028c578063e62854c71462000286578063eeaf2b7d14620002805763f2fde38b036200000f5762002bae565b62002b1c565b62002af1565b62002ad1565b62002a6f565b6200293e565b620027be565b6200272b565b620026dd565b6200252a565b62002318565b62002166565b62001f49565b62001f00565b62001eca565b62001a65565b620017d2565b620016af565b620015d2565b62001524565b620013c0565b620012e0565b620011ea565b6200119d565b6200115a565b620010f3565b620010c8565b6200109d565b62001072565b6200102e565b62000fe1565b62000f93565b62000e90565b62000e0b565b62000dc2565b62000d8b565b62000d04565b62000a72565b620009dd565b62000990565b62000965565b62000924565b6200089f565b6200085f565b62000802565b620006d9565b62000479565b62000410565b620003d6565b34620003c5576020366003190112620003c557620003bd62002c48565b600435609f55005b600080fd5b6000910312620003c557565b34620003c5576000366003190112620003c557602062ffffff60975460a01c16604051908152f35b6001600160a01b03811603620003c557565b34620003c5576020366003190112620003c55760206004356200043381620003fe565b60018060a01b03809116600052609a825260406000205416604051908152f35b6060906003190112620003c5576004356200046e81620003fe565b906024359060443590565b34620003c5576200048a3662000453565b9062000498333b156200306f565b620004a262003018565b6001600160a01b0392831690620004bb8215156200331b565b600093828552609a60205260408520541615801590620005dc575b620004e19062003351565b604051633a947e3560e11b815260048101829052602081602481865afa80156200059b5785946200051d928692620005a5575b50111562003717565b813b15620005a157604051630b0a293f60e11b81523360048201819052602482019290925260448101919091526000606482015291908290818381608481015b03925af180156200059b576200057d575b506200057a6001606555565b80f35b806200058d620005949262002060565b80620003ca565b386200056e565b62002f9a565b5050fd5b620005cc91925060203d8111620005d4575b620005c38183620020ca565b810190620036d0565b903862000514565b503d620005b7565b50609c60205260408420541515620004d6565b6020906003190112620003c55760043590565b634e487b7160e01b600052602160045260246000fd5b600411156200062357565b62000602565b90620006358262000618565b52565b9190916101408101926200064e82825162000629565b6020818101516001600160a01b0316908301526040818101516001600160a01b0316908301526060818101516001600160a01b0316908301526080818101516001600160a01b03169083015260a081015160a083015260c081015160c0830152620006c260e082015160e084019015159052565b610100808201519083015261012080910151910152565b34620003c557620007fe620006ee36620005ef565b604051620006fc8162002074565b60086040600080845280602085015280828501528060608501528060808501528060a08501528060c08501528060e08501526101009481868601528161012080960152815260a16020522062000751620020ec565b936200077982546200076760ff8216886200398d565b841c6001600160a01b03166020870152565b60018201546001600160a01b0316604086015260028201546001600160a01b0316606086015260038201546001600160a01b03166080860152600482015460a0860152600582015460c0860152620007e2620007d9600684015460ff1690565b151560e0870152565b6007820154908501520154908201526040519182918262000638565b0390f35b34620003c5576000366003190112620003c557602062ffffff60975460b81c16604051908152f35b6080906003190112620003c5576004356200084581620003fe565b9060243590604435906064356200085c81620003fe565b90565b34620003c5576200089762000874366200082a565b9262000885929192333b156200306f565b6200088f62003018565b339062003387565b506001606555005b34620003c5576020366003190112620003c557600435620008c081620003fe565b620008ca62002c48565b803b15620008f45760a280546001600160a01b0319166001600160a01b0392909216919091179055005b60405162461bcd60e51b8152602060048201526008602482015267414b465f56494e4360c01b6044820152606490fd5b34620003c5576020366003190112620003c5576004356200094581620003fe565b60018060a01b0316600052609c6020526020604060002054604051908152f35b34620003c5576000366003190112620003c557609d546040516001600160a01b039091168152602090f35b34620003c5576020366003190112620003c557600435620009b181620003fe565b620009bb62002c48565b609d80546001600160a01b0319166001600160a01b0392909216919091179055005b34620003c55760008060031936011262000a3f57620009fb62002c48565b603380546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b9181601f84011215620003c5578235916001600160401b038311620003c55760208381860195010111620003c557565b34620003c5576080366003190112620003c55760243560043562000a9682620003fe565b6001600160401b0391604435838111620003c55762000aba90369060040162000a42565b9091606435858111620003c55762000ad790369060040162000a42565b9362000ae262003018565b609d546001600160a01b03949062000afe908616331462002ebd565b62000b0b87151562002ef3565b62000b468562000b3e62000b318760018060a01b03166000526099602052604060002090565b546001600160a01b031690565b161562002f2a565b62000b7a62000b7362000b6762000b318a600052609b602052604060002090565b6001600160a01b031690565b1562002f62565b6040516101d5808201998a11828b101762000ccd5762004ab8823980600099039089f09182156200059b578589931696873b1562000cc95762000bd590604051958694859463100b506960e11b865289306004880162002fe5565b038183885af180156200059b5762000cb2575b506001600160a01b038116600090815260996020526040902062000c289084905b80546001600160a01b0319166001600160a01b03909216919091179055565b6001600160a01b0383166000908152609a6020526040902062000c4d90829062000c09565b62000c678362000c0986600052609b602052604060002090565b6001600160a01b0383166000908152609c60205260409020849055167fc7e08e9d26d634e7a8c5a116d4312ad4ea4f5de2b728546828d8a3449ed8f6d48480a46200057a6001606555565b806200058d62000cc29262002060565b3862000be8565b8380fd5b6200204a565b6060906003190112620003c55760043562000cee81620003fe565b9060243562000cfd81620003fe565b9060443590565b34620003c55762000d153662000cd3565b9062000d233315156200331b565b336000908152609a60205260409020546001600160a01b039081161580159062000d77575b62000d539062003351565b8262000d5b57005b8060a25416809183160362000d6c57005b6200001b9362004920565b50609c602052604060002054151562000d48565b34620003c5576200089762000da03662000453565b9062000dae333b156200306f565b62000db862003018565b3392339062003387565b34620003c5576020366003190112620003c55762000ddf62003018565b62000de962002c48565b60335462000e0490600435906001600160a01b031662004a16565b6001606555005b34620003c5576020366003190112620003c55760043562000e2c81620003fe565b62000e3662002c48565b803b1562000e6057609e80546001600160a01b0319166001600160a01b0392909216919091179055005b60405162461bcd60e51b8152602060048201526008602482015267414b465f42494e4360c01b6044820152606490fd5b34620003c55760008060031936011262000a3f57805462000ecb60ff8260081c16158092819362000f76575b811562000f53575b5062002cea565b8062000edf600160ff196000541617600055565b62000f38575b62000eef62002d4e565b62000ef75780f35b62000f0861ff001960005416600055565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a180f35b62000f4d61010061ff00196000541617600055565b62000ee5565b303b1591508162000f67575b503862000ec4565b6001915060ff16143862000f5f565b600160ff821610915062000ebc565b62ffffff811603620003c557565b34620003c5576020366003190112620003c55760043562000fb48162000f85565b62000fbe62002c48565b6097805462ffffff60b81b191660b89290921b62ffffff60b81b16919091179055005b34620003c5576020366003190112620003c5576004356200100281620003fe565b6200100c62002c48565b609780546001600160a01b0319166001600160a01b0392909216919091179055005b34620003c55760a0366003190112620003c55760206200106a6024356200105581620003fe565b6084359060643590604435906004356200374e565b604051908152f35b34620003c5576000366003190112620003c55760a2546040516001600160a01b039091168152602090f35b34620003c5576000366003190112620003c5576033546040516001600160a01b039091168152602090f35b34620003c5576000366003190112620003c5576098546040516001600160a01b039091168152602090f35b34620003c5576060366003190112620003c5576001600160401b03602435818111620003c5576200112990369060040162000a42565b604492919235918211620003c5576020926200114e6200106a93369060040162000a42565b92909160043562002e58565b34620003c5576020366003190112620003c55760206004356200117d81620003fe565b60018060a01b038091166000526099825260406000205416604051908152f35b34620003c5576020366003190112620003c557600435620011be81620003fe565b620011c862002c48565b609880546001600160a01b0319166001600160a01b0392909216919091179055005b34620003c557604080600319360112620003c557600435602435916200121083620003fe565b609d546001600160a01b0393906200122c908516331462002ebd565b838116936200123d8515156200331b565b600094808652602091609a835280858820541615801590620012cf575b620012659062003351565b858752609b835284872054161580620012bc575b62001282578580f35b848652609b825283862080546001600160a01b0319166001600160a01b0390941693909317909255609c9185525282205538808080808580f35b50808652609c8252838620541562001279565b50609c83528487205415156200125a565b34620003c5576020366003190112620003c55760043562001303333b156200306f565b6200130d62003018565b60009033825260a4602052604082208183526020526200138f604083206200135d60ff82546200134a3360018060a01b038360081c161462003351565b16620013568162000618565b1562004037565b805460ff19166003178155609e546001600160a01b031660a2546004906001600160a01b031692015491339162004920565b33907f34cf495316dbb07c8286e6c6b35542a47854aaf8050f2dd51ab0347b855582978380a36200057a6001606555565b34620003c5576040366003190112620003c557600435620013e181620003fe565b60243590620013f082620003fe565b620013fa62003018565b609d546001600160a01b039062001415908216331462002ebd565b6200143b8162000b3e62000b318660018060a01b03166000526099602052604060002090565b6200148e6200147e6200146462000b318560018060a01b0316600052609a602052604060002090565b6001600160a01b0316600090815260996020526040902090565b80546001600160a01b0319169055565b811691823b15620003c55760405163033f2ed560e61b81526001600160a01b0382166004820152926000908490602490829084905af19081156200059b57620015029362000c09926200150d575b506001600160a01b0383166000908152609a602052604090206200146490829062000c09565b6200001b6001606555565b806200058d6200151d9262002060565b38620014dc565b34620003c5576040366003190112620003c5576004356200154581620003fe565b62001552333b156200306f565b6200155c62003018565b3315620015a457336000908152609960205260409020546200150291906200159a9062001592906001600160a01b031662000b67565b151562003998565b60243590620039ce565b60405162461bcd60e51b815260206004820152600660248201526520a5a32fa82d60d11b6044820152606490fd5b34620003c5576000366003190112620003c5576097546040516001600160a01b039091168152602090f35b60005b838110620016115750506000910152565b818101518382015260200162001600565b906020916200163d81518092818552858086019101620015fd565b601f01601f1916010190565b602080820190808352835180925260408301928160408460051b8301019501936000915b8483106200167e5750505050505090565b90919293949584806200169e600193603f198682030187528a5162001622565b98019301930191949392906200166d565b6020366003190112620003c557600480356001600160401b0391828211620003c55736602383011215620003c55781810135928311620003c557602490818301928236918660051b010111620003c5576200170a84620043bc565b9360005b818110620017265760405180620007fe888262001649565b6000806200173683858962004434565b604093916200174a8551809381936200447f565b0390305af4906200175a6200448d565b9182901562001791575050906200178b916200177782896200453d565b526200178481886200453d565b506200440e565b6200170e565b868387926044825110620003c55782620017ce9385620017b89401518301019101620044c2565b925162461bcd60e51b815292839283016200452a565b0390fd5b34620003c5576040366003190112620003c557600435602435620017f681620003fe565b62001803333b156200306f565b6200180d62003018565b6001600160a01b038116600090815260a4602052604090206200183c9083905b90600052602052604060002090565b9182549160018060a01b036200186360ff828416956200134a87858360081c161462003351565b6200189662001889846200182d8560018060a01b031660005260a4602052604060002090565b805460ff19166001179055565b6001850154908116946003810154600460ff60028401549460a01c169201549382600014620019c657604051630f0acbd160e01b8152670de0b6b3a76400006004820152946020866024818c5afa9081156200059b576200192b8a9462001951937f7907d0bab36c44f1455bd336290d15ba6eeab66d9a59d0416b5fd857771df69999600091620019a3575b501115620042b1565b60a2546200194a908490839089906001600160a01b03168098620034b4565b906200418f565b908162001982575b5050505b604080519115158252602082019290925290819081015b0390a46200001b6001606555565b609e546200199a93906001600160a01b031662004920565b38808062001959565b620019bf915060203d8111620005d457620005c38183620020ca565b3862001922565b604051630f0acbd160e01b8152670de0b6b3a764000060048201529194506020826024818b5afa9182156200059b577f7907d0bab36c44f1455bd336290d15ba6eeab66d9a59d0416b5fd857771df6999562001a3c9362001a339260009162001a42575b50101562004279565b838189620042e9565b6200195d565b62001a5e915060203d8111620005d457620005c38183620020ca565b3862001a2a565b34620003c55762001a7636620005ef565b62001a83333b156200306f565b62001a8d62003018565b62001aa28160005260a1602052604060002090565b9062001abe62001ab3835460ff1690565b620013568162000618565b62001ad762001ad1600684015460ff1690565b6200406e565b62001ae7600483015415620040a5565b6002820154604051633308f42d60e01b8152926001600160a01b0392909183169060208086600481865afa9586156200059b5760009662001e94575b5062001b338587163314620040dc565b6003840180546001600160a01b0319166001600160a01b038816179055835460ff1916600117845560018401546001600160a01b0316845490929060081c6001600160a01b03169060058601546040519163284be21560e01b9485845280846004818d89165afa9283156200059b578a9460009462001e70575b506040518281600481635b31588360e01b998a82528b165afa80156200059b57828862001be8928f98879560009262001e4c575b506200459d565b9760046040518097819382528d165afa9485156200059b578b9460009662001e26575b50829060046040518097819382528d165afa9081156200059b5762001c45818b8f97948f9989968e9860009362001df0575b50506200459d565b8b896007839e01556008015589818c8a15159562001c949262001c8d928862001ca89962001de6575b62001c79906200412b565b60a2546001600160a01b03168096620035c2565b836200418f565b8a8162001dc5575b505050878288620035c2565b50604080516001600160a01b038881168252939093166020840152820185905260608201889052828716928416917fbf7251dfdcdaa7bf1bd728412bab243e14ae75865dd5516648e1c8a51ad2d72190608090a48581163b15620003c557604051630615077d60e41b8082526001600160a01b0398909816600482015260248101929092526000908290604490829084908a165af180156200059b5762001dae575b508382163b15620003c5576040519485526001600160a01b031660048501526024840191909152600091839160449183918591165af180156200059b5762001d97576200001b6001606555565b806200058d62001da79262002060565b3862001502565b806200058d62001dbe9262002060565b3862001d4a565b609e5462001ddd93906001600160a01b031662004920565b38808a62001c9c565b5080151562001c6e565b62001e15929350803d1062001e1e575b62001e0c8183620020ca565b81019062004113565b90388062001c3d565b503d62001e00565b8391965062001e4490823d841162001e1e5762001e0c8183620020ca565b959062001c0b565b62001e68919250863d881162001e1e5762001e0c8183620020ca565b903862001be1565b62001e8c919450823d841162001e1e5762001e0c8183620020ca565b923862001bad565b8162001eba9297503d881162001ec2575b62001eb18183620020ca565b81019062003e72565b943862001b23565b503d62001ea5565b34620003c5576020366003190112620003c557600435600052609b602052602060018060a01b0360406000205416604051908152f35b34620003c5576020366003190112620003c55762001f1d62003018565b62001f2762002c48565b609e5460335462000e0491600435916001600160a01b0390811691166200482f565b34620003c55762001f5a366200082a565b62001f67333b156200306f565b62001f7162003018565b6001600160a01b0393841662001f898115156200331b565b600094818652609a6020526040862054161580159062002037575b62001faf9062003351565b604051633a947e3560e11b815260048101859052602081602481855afa80156200059b57869462001fea928692620005a55750111562003717565b803b156200203357604051630b0a293f60e11b815233600482015260248101949094526001600160a01b039091166044840152600060648401528290818381608481016200055d565b8280fd5b50609c6020526040852054151562001fa4565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811162000ccd57604052565b61014081019081106001600160401b0382111762000ccd57604052565b61010081019081106001600160401b0382111762000ccd57604052565b60a081019081106001600160401b0382111762000ccd57604052565b90601f801991011681019081106001600160401b0382111762000ccd57604052565b60405190620020fb8262002074565b565b6001600160401b03811162000ccd57601f01601f191660200190565b81601f82011215620003c5578035906200213382620020fd565b92620021436040519485620020ca565b82845260208383010111620003c557816000926020809301838601378301015290565b34620003c5576080366003190112620003c5576001600160401b03600435602435828111620003c5576200219f90369060040162000a42565b604435848111620003c557620021ba90369060040162000a42565b929091606435868111620003c557620021d890369060040162002119565b91620021e6333b156200306f565b620021f062003018565b6200222d60018060a01b039362002222856200221a62000b318b600052609b602052604060002090565b161562002f62565b868685858b620030a6565b50506040516101d5808201988911828a101762000ccd5762004ab8823980600098039088f09283156200059b5787931694853b1562000cc9576200228890604051958694859463100b506960e11b8652306004870162002fa6565b038183865af180156200059b5762002301575b50620022b68162000c0984600052609b602052604060002090565b6001600160a01b0381166000908152609c60205260409020829055827f0fda88fcc31b35d80e62f303bc442eecd55f84ad381eef53826fd5bc48e5b7fe8180a46200057a6001606555565b806200058d620023119262002060565b386200229b565b34620003c55760c0366003190112620003c5576004356024356200233c81620003fe565b604435906064359060a4356084356001600160401b038211620003c5576200236d6200242e92369060040162002119565b906200237b333b156200306f565b6200238562003018565b62002399652d79883d200087111562003795565b620023d8620023d2620023ce620023c78a6200182d8960018060a01b031660005260a0602052604060002090565b5460ff1690565b1590565b620037cb565b620023fe62001889886200182d8760018060a01b031660005260a0602052604060002090565b609f54948581148062002520575b620024179062003801565b620024254283101562003837565b868589620038a4565b5050609e546040516370a0823160e01b81526001600160a01b03838116600483015292918316602082602481845afa9182156200059b5786670de0b6b3a7640000620024bd7f05c966387bde83883f64200b4d9f73042dd5dbe77e737d0e39db4f391b54bb1f98620024b684620024ef98620024c897600091620024fd575b5010156200386d565b8362004589565b049285309162004920565b620024d4818462004a16565b60405193849316958360209093929193604081019481520152565b0390a36200001b6001606555565b62002519915060203d8111620005d457620005c38183620020ca565b38620024ad565b508515156200240c565b34620003c5576200253b36620005ef565b62002548333b156200306f565b6200255262003018565b620025678160005260a1602052604060002090565b908154916200257e60ff8416620013568162000618565b6200259162001ad1600683015460ff1690565b60028101546001600160a01b0390811693620025af8515156200420b565b604051633308f42d60e01b8082529260209081836004818b5afa9283156200059b57600093620026b9575b508293620025ed82849516331462004242565b60081c1693620025ff8515156200419d565b60046040518096819382525afa9384156200059b577fd3bb236a8c097c79eea15f66e43bf3984e6672bd5d434c74b4cb6b70c834508b94620024ef946200267d9360009262002697575b5050815460ff19166003178255609e546001600160a01b03165b60a254600590930154926001600160a01b03169062004920565b6040516001600160a01b0390911681529081906020820190565b620026b19250803d1062001ec25762001eb18183620020ca565b388062002649565b829350620026d690833d851162001ec25762001eb18183620020ca565b92620025da565b34620003c5576020366003190112620003c557600435620026fe8162000f85565b6200270862002c48565b6097805462ffffff60a01b191660a09290921b62ffffff60a01b16919091179055005b34620003c5576080366003190112620003c55760206004356200274e81620003fe565b602435906200275d82620003fe565b604051908382019230845246604084015260018060a01b03809216606084015216608082015260443560a082015260643560c08201524360e082015260e08152620027a88162002091565b519020604051908152f35b80151503620003c557565b34620003c55760c0366003190112620003c557602435600435620027e282620003fe565b60443590620027f182620027b3565b7f43b998e47453d980655a7f5405259ce1526efb62b8777e639f7ad6dee421c3cb60643593608435906200197460a4356200282e333b156200306f565b6200283862003018565b33600090815260a460205260409020620028549087906200182d565b80546001600160a01b039591620028e391620028769060081c88161562003351565b8a15158062002934575b6200288b9062003801565b805460018201805460ff60a01b8d151560a01b166001600160a81b03199182166001600160a01b038b161717909155600283018d9055600383018590556004830186905516610100600160a81b033360081b16179055565b609e546200290b9083906001600160a01b031660a2546001600160a01b031690339062004920565b604051948594169833988590949392606092608083019615158352602083015260408201520152565b5083151562002880565b34620003c5576200294f36620005ef565b6200295c333b156200306f565b6200296662003018565b6200297b8160005260a1602052604060002090565b908154916200299260ff8416620013568162000618565b620029a562001ad1600683015460ff1690565b60018060a01b03809360081c1692620029c08415156200419d565b604051633308f42d60e01b815290602082600481885afa80156200059b577f0240ef67b9a39238db2f92fc057c26bce3d089137a6fbf3c728f4c6078258ddf93620024ef9360009262002a42575b5062002a2382936200267d93163314620041d4565b805460ff19166002178155609e5483906001600160a01b031662002663565b6200267d925062002a6762002a239160203d811162001ec25762001eb18183620020ca565b925062002a0e565b34620003c5576080366003190112620003c5576200089760643562002a9481620003fe565b62002aa1333b156200306f565b62002aab62003018565b600435600052609b6020526044356024353360018060a01b036040600020541662003387565b34620003c5576000366003190112620003c5576020609f54604051908152f35b34620003c5576000366003190112620003c557609e546040516001600160a01b039091168152602090f35b34620003c55762002b2d3662000cd3565b9062002b3b3315156200331b565b336000908152609a60205260409020546001600160a01b03919082161580159062002b9a575b62002b6c9062003351565b8262002b7457005b60a254821691811630810362002b915750506200001b926200482f565b820362000d6c57005b50609c602052604060002054151562002b61565b34620003c5576020366003190112620003c55760043562002bcf81620003fe565b62002bd962002c48565b6001600160a01b0381161562002bf4576200001b9062002ca1565b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b6033546001600160a01b0316330362002c5d57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b603380546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b1562002cf257565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b62002d6c60ff60005460081c1662002d668162002dd6565b62002dd6565b62002d773362002ca1565b62002d8f60ff60005460081c1662002d668162002dd6565b60016065556bffffffffffffffffffffffff60a01b33816098541617609855640c35000c3560a41b65ffffffffffff60a01b1960975416176097553390609d541617609d55565b1562002dde57565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b908060209392818452848401376000828201840152601f01601f1916010190565b939162002eaa62002eb79394929462002e956040519687946020860199308b52466040880152606087015260a0608087015260c086019162002e37565b90601f1994858584030160a086015262002e37565b03908101835282620020ca565b51902090565b1562002ec557565b60405162461bcd60e51b8152602060048201526006602482015265414b465f4e4160d01b6044820152606490fd5b1562002efb57565b60405162461bcd60e51b815260206004820152600760248201526620a5a32faa2d2b60c91b6044820152606490fd5b1562002f3257565b60405162461bcd60e51b8152602060048201526008602482015267414b465f504e5a4160c01b6044820152606490fd5b1562002f6a57565b60405162461bcd60e51b8152602060048201526008602482015267414b465f544e5a4160c01b6044820152606490fd5b6040513d6000823e3d90fd5b93916200085c959362002fd69260018060a01b031686526000602087015260806040870152608086019162002e37565b92606081850391015262002e37565b949290936200085c969462002fd69360018060a01b03809216885216602087015260806040870152608086019162002e37565b6002606554146200302a576002606555565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b156200307757565b60405162461bcd60e51b8152602060048201526007602482015266414b465f43494360c81b6044820152606490fd5b92620030c092620031049592620030fb9598979862002e58565b93620030f5857f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c60002090565b6200325b565b9190916200312f565b609d5462003120906001600160a01b0383811691161462002ebd565b9190565b600511156200062357565b6200313a8162003124565b80620031435750565b6200314e8162003124565b600181036200319c5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b620031a78162003124565b60028103620031f55760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b806200320360039262003124565b146200320b57565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b9060418151146000146200328c5762003288916020820151906060604084015193015160001a9062003296565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116200330f5791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156200059b5781516001600160a01b0381161562003309579190565b50600190565b50505050600090600390565b156200332357565b60405162461bcd60e51b815260206004820152600660248201526520a5a32faa2d60d11b6044820152606490fd5b156200335957565b60405162461bcd60e51b81526020600482015260066024820152651052d197d09560d21b6044820152606490fd5b9094936001600160a01b03929091831690620033a58215156200331b565b600093828552609a60205260408520541615801590620034a1575b620033cb9062003351565b60405163f2d9492f60e01b81526004810182905294602086602481865afa9586156200059b57859662003477575b508562003408911015620036e0565b813b1562000cc957604051630f08f3ff60e11b81526001600160a01b039788166004820152602481019190915295909116604486015260006064860152929391928290818381608481015b03925af180156200059b5762003467575090565b806200058d6200085c9262002060565b62003408919650620034999060203d8111620005d457620005c38183620020ca565b9590620033f9565b50609c60205260408420541515620033c0565b9094936001600160a01b03929091831690620034d28215156200331b565b600093828552609a60205260408520541615801590620035af575b620034f89062003351565b60405163f2d9492f60e01b81526004810182905294602086602481865afa9586156200059b57859662003585575b508562003535911015620036e0565b813b1562000cc957604051630f08f3ff60e11b81526001600160a01b0397881660048201526024810191909152959091166044860152600260648601529293919282908183816084810162003453565b62003535919650620035a79060203d8111620005d457620005c38183620020ca565b959062003526565b50609c60205260408420541515620034ed565b9094936001600160a01b03929091831690620035e08215156200331b565b600093828552609a60205260408520541615801590620036bd575b620036069062003351565b60405163f2d9492f60e01b81526004810182905294602086602481865afa9586156200059b57859662003693575b508562003643911015620036e0565b813b1562000cc957604051630f08f3ff60e11b81526001600160a01b0397881660048201526024810191909152959091166044860152600160648601529293919282908183816084810162003453565b62003643919650620036b59060203d8111620005d457620005c38183620020ca565b959062003634565b50609c60205260408420541515620035fb565b90816020910312620003c5575190565b15620036e857565b60405162461bcd60e51b81526020600482015260076024820152660414b465f4242560cc1b6044820152606490fd5b156200371f57565b60405162461bcd60e51b81526020600482015260076024820152660414b465f4253560cc1b6044820152606490fd5b9391929092604051936020850195308752466040870152606086015260018060a01b0316608085015260a084015260c083015260e082015260e0815262002eb78162002091565b156200379d57565b60405162461bcd60e51b8152602060048201526006602482015265414b465f494160d01b6044820152606490fd5b15620037d357565b60405162461bcd60e51b815260206004820152600660248201526520a5a32fa12760d11b6044820152606490fd5b156200380957565b60405162461bcd60e51b815260206004820152600660248201526520a5a32fa12960d11b6044820152606490fd5b156200383f57565b60405162461bcd60e51b81526020600482015260066024820152651052d197d09160d21b6044820152606490fd5b156200387557565b60405162461bcd60e51b815260206004820152600760248201526620a5a32fa4a12160c91b6044820152606490fd5b938193620038f493620038bf93620038fd979998996200374e565b94620030f5867f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c60002090565b9290926200312f565b6001600160a01b039081169082160362003915579190565b60405162461bcd60e51b81526020600482015260066024820152651052d197d39560d21b6044820152606490fd5b909160405191602083019330855246604085015260018060a01b038092166060850152166080830152600060a083015260c08201524360e082015260e0815262002eb78162002091565b620006358262000618565b15620039a057565b60405162461bcd60e51b81526020600482015260066024820152650414b465f42560d41b6044820152606490fd5b6001600160a01b038181169290620039e88415156200331b565b600091848352602093609a85526040948386862054161580159062003dba575b62003a139062003351565b62003a2083151562003dcb565b33600090815260996020526040902062003a3a9062000b31565b928484169662003a4d8989141562003e03565b805163f2d9492f60e01b80825267016345785d8a000060048301529084816024818d5afa9081156200059b57899162003d98575b508310158062003d3c575b62003a98915062003e3a565b805192633308f42d60e01b9788855281856004818d5afa9485156200059b57819562003d18575b5062003acf888616331462003e8a565b609e5462003ae89062000b67906001600160a01b031681565b83516370a0823160e01b81526001600160a01b0387166004820152908390829060249082905afa998a156200059b5762003b778d9a62003b6f62003b4d8962003b5f9f8e62003b478f9284908d9b8d9162003cf6575b50101562003ec1565b62003943565b9d8e60005260a1602052604060002090565b5460081c6001600160a01b031690565b161562003efa565b60048551809b819382525afa9586156200059b577f1b88229ac738467a5b6ad4f608a992b440ec8757a7f6a0e987379e4d51e41f7298829762003cb8575b509062003c0b62003c5c939262003bed62003cb398999a62003bd6620020ec565b8581526001600160a01b0390911695810195909552565b6001600160a01b038916848701526001600160a01b03166060840152565b6001600160a01b03881660808301528060a08301528460c083015262003c3460e0830160019052565b8061010083015261012082015262003c568960005260a1602052604060002090565b62003f4b565b609e5462003c849083906001600160a01b031660a25487906001600160a01b03169162004920565b516001600160a01b03938416815293909216602084015260006040840152606083019190915281906080820190565b0390a4565b62003cb396975083929162003bed62003ce862003c0b9362003c5c973d881162001ec25762001eb18183620020ca565b999850509192935062003bb5565b62003d1191508c8d3d10620005d457620005c38183620020ca565b3862003b3e565b62003d34919550823d841162001ec25762001eb18183620020ca565b933862003abf565b50815190815267016345785d8a0000600482015283816024818d5afa80156200059b5762003a9891899162003d76575b5083101562003a8c565b62003d919150853d8711620005d457620005c38183620020ca565b3862003d6c565b62003db39150853d8711620005d457620005c38183620020ca565b3862003a81565b50609c815285852054151562003a08565b1562003dd357565b60405162461bcd60e51b815260206004820152600860248201526720a5a32fa128272d60c11b6044820152606490fd5b1562003e0b57565b60405162461bcd60e51b81526020600482015260076024820152661052d197d3915560ca1b6044820152606490fd5b1562003e4257565b60405162461bcd60e51b8152602060048201526008602482015267414b465f4242504d60c01b6044820152606490fd5b90816020910312620003c557516200085c81620003fe565b1562003e9257565b60405162461bcd60e51b8152602060048201526007602482015266414b465f4e4f4160c81b6044820152606490fd5b1562003ec957565b60405162461bcd60e51b815260206004820152600960248201526820a5a32fa7a0a722a160b91b6044820152606490fd5b1562003f0257565b60405162461bcd60e51b8152602060048201526007602482015266414b465f424f4960c81b6044820152606490fd5b9062003f3d8162000618565b60ff80198354169116179055565b9061012060089162003f6a815162003f638162000618565b8562003f31565b602081015162003f9f906001600160a01b03168554610100600160a81b03191660089190911b610100600160a81b0316178555565b60408101516001850180546001600160a01b039283166001600160a01b0319918216179091556060830151600287018054918416918316919091179055608083015160038701805491909316911617905560a0810151600485015560c0810151600585015560e081015162004025901515600686019060ff801983541691151516179055565b61010081015160078501550151910155565b156200403f57565b60405162461bcd60e51b8152602060048201526007602482015266414b465f424f5360c81b6044820152606490fd5b156200407657565b60405162461bcd60e51b81526020600482015260076024820152661052d197d3d39360ca1b6044820152606490fd5b15620040ad57565b60405162461bcd60e51b815260206004820152600760248201526620a5a32fa7a72960c91b6044820152606490fd5b15620040e457565b60405162461bcd60e51b815260206004820152600760248201526620a5a32fa727a160c91b6044820152606490fd5b90816020910312620003c557516200085c8162000f85565b156200413357565b60405162461bcd60e51b8152602060048201526008602482015267414b465f42414e4d60c01b6044820152606490fd5b634e487b7160e01b600052601160045260246000fd5b6009198101919082116200418957565b62004163565b919082039182116200418957565b15620041a557565b60405162461bcd60e51b8152602060048201526007602482015266414b465f49544160c81b6044820152606490fd5b15620041dc57565b60405162461bcd60e51b8152602060048201526007602482015266414b465f494f4160c81b6044820152606490fd5b156200421357565b60405162461bcd60e51b815260206004820152600760248201526620a5a32fa4aa2160c91b6044820152606490fd5b156200424a57565b60405162461bcd60e51b815260206004820152600760248201526620a5a32fa4a7a160c91b6044820152606490fd5b156200428157565b60405162461bcd60e51b81526020600482015260086024820152670414b465f425453560c41b6044820152606490fd5b15620042b957565b60405162461bcd60e51b81526020600482015260086024820152670414b465f425442560c41b6044820152606490fd5b9093926001600160a01b03929091831690620043078215156200331b565b600093828552609a6020526040852054161580159062004391575b6200432d9062003351565b813b1562000cc957604051630b0a293f60e11b81526001600160a01b03968716600482015260248101919091529190941660448201526002606482015291928290608490829084905af180156200059b57620043865750565b620020fb9062002060565b50609c6020526040842054151562004322565b6001600160401b03811162000ccd5760051b60200190565b90620043c882620043a4565b620043d76040519182620020ca565b8281528092620043ea601f1991620043a4565b019060005b828110620043fc57505050565b806060602080938501015201620043ef565b6000198114620041895760010190565b634e487b7160e01b600052603260045260246000fd5b9190811015620044795760051b81013590601e1981360301821215620003c55701908135916001600160401b038311620003c5576020018236038113620003c5579190565b6200441e565b908092918237016000815290565b3d15620044bd573d90620044a182620020fd565b91620044b16040519384620020ca565b82523d6000602084013e565b606090565b602081830312620003c5578051906001600160401b038211620003c5570181601f82011215620003c5578051620044f981620020fd565b92620045096040519485620020ca565b81845260208284010111620003c5576200085c9160208085019101620015fd565b9060206200085c92818152019062001622565b8051821015620044795760209160051b010190565b600181901b91906001600160ff1b038116036200418957565b90670de0b6b3a7640000918281029281840414901517156200418957565b818102929181159184041417156200418957565b6040516318160ddd60e01b8152919392909190602090829060049082906001600160a01b03165afa9081156200059b5760009162004650575b5060005b83620045f3620045ea8362004673565b848887620046cb565b116200460a57620046049062004673565b620045da565b939291905b82620046286200461f8762004689565b838786620046cb565b1162004649576200463f6200462893949562004689565b949392506200460f565b5050505090565b6200466c915060203d8111620005d457620005c38183620020ca565b38620045d6565b90670de0b6b3a764000082018092116200418957565b9067016345785d8a000082018092116200418957565b90600182018092116200418957565b90600a82018092116200418957565b919082018092116200418957565b91906200473e620047386200473062004727620047216200085c986200476d9767016345785d8a000080910491049080159182600014620047df576000925b80620047d4575b156200477357505060006200418f565b6200456b565b62040740900490565b6103e8900490565b6200469f565b9262004765620f424091826200475b62ffffff8093168862004589565b0493168562004589565b0492620046bd565b620046bd565b81620047ad620047c1620047bb846200476d620047b4620047a1620047c7986200476d620047ce9b62004179565b620047ad8489620046bd565b9062004589565b9562004179565b62004552565b620046ae565b6006900490565b6200418f565b506001811462004711565b62004810620047c7620047fd84620047f78162004179565b62004589565b620047ad620047c1620047bb8762004179565b926200470a565b90816020910312620003c557516200085c81620027b3565b60405163a9059cbb60e01b602082019081526001600160a01b03939093166024820152604480820194909452928352600092839290839062004873606482620020ca565b51925af1620048816200448d565b81620048ec575b50156200489157565b60405162461bcd60e51b815260206004820152602d60248201527f5472616e7366657248656c7065723a3a736166655472616e736665723a20747260448201526c185b9cd9995c8819985a5b1959609a1b6064820152608490fd5b805180159250821562004903575b50503862004888565b62004918925060208091830101910162004817565b3880620048fa565b9091600080949381946040519160208301946323b872dd60e01b865260018060a01b0380921660248501521660448301526064820152606481526200496581620020ae565b51925af1620049736200448d565b81620049e2575b50156200498357565b60405162461bcd60e51b815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a207472604482015270185b9cd9995c919c9bdb4819985a5b1959607a1b6064820152608490fd5b8051801592508215620049f9575b5050386200497a565b62004a0e925060208091830101910162004817565b3880620049f0565b60405160208101908082106001600160401b0383111762000ccd576000938493848094938194604052525af162004a4c6200448d565b501562004a5557565b60405162461bcd60e51b815260206004820152603460248201527f5472616e7366657248656c7065723a3a736166655472616e736665724554483a60448201527308115512081d1c985b9cd9995c8819985a5b195960621b6064820152608490fdfe60a0806040523461002857336080526101a7908161002e823960805181818160410152608b0152f35b600080fdfe60806040526004361015610018575b3661007657610076565b6000803560e01c63c45a01551461002f575061000e565b346100735780600319360112610073577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166080908152602090f35b80fd5b60405163a8b8a55d60e01b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115610122576000916100ca575b5061012e565b60203d811161011b575b601f8101601f1916820167ffffffffffffffff81118382101761010757610101935060405281019061014d565b386100c4565b634e487b7160e01b84526041600452602484fd5b503d6100d4565b6040513d6000823e3d90fd5b6000808092368280378136915af43d82803e15610149573d90f35b3d90fd5b9081602091031261016c57516001600160a01b038116810361016c5790565b600080fdfea26469706673582212202144b141b34a6ae867daf0fa9374097fc97aacff3e58749d364914bfcd8836e664736f6c63430008130033a26469706673582212203db21c1f71aaffd624e1b6e0cdd3136345263bcf7592551bb2e7be26b5b67e8d64736f6c63430008130033

Deployed ByteCode

0x608060405260043610156200001d575b36156200001b57600080fd5b005b60003560e01c806309c7a25c14620003a0578063284be215146200039a5780632b806fba14620003945780633f566994146200038e5780635778472a14620003885780635b315883146200038257806366454421146200037c5780636817031b14620003765780636e5bf35e14620003705780636e9960c3146200036a578063704b6c021462000364578063715018a6146200035e5780637150238214620003585780637187f90f146200035257806374567f0f146200034c5780637aabab0714620003465780637cf4626b14620003405780638129fc1c146200033a578063826db8ac14620003345780638b3aaecd146200032e5780638b71c3cf14620003285780638d928af814620003225780638da5cb5b146200031c5780638db462fc14620003165780639020597a146200031057806396910b91146200030a578063a10786b01462000304578063a14c0d6214620002fe578063a43aa23614620002f8578063a4bf9d0614620002f2578063a541daf614620002ec578063a8b8a55d14620002e6578063ac9650d814620002e0578063b479b15e14620002da578063b8a946e614620002d4578063bab1fbaa14620002ce578063bb36d59a14620002c8578063cce05ddf14620002c2578063cdb1e3ca14620002bc578063ced7a53914620002b6578063d021a6e714620002b0578063d1ce35e314620002aa578063d39869f214620002a4578063d590be2f146200029e578063da6c85491462000298578063dd0bcbe31462000292578063dd22db80146200028c578063e62854c71462000286578063eeaf2b7d14620002805763f2fde38b036200000f5762002bae565b62002b1c565b62002af1565b62002ad1565b62002a6f565b6200293e565b620027be565b6200272b565b620026dd565b6200252a565b62002318565b62002166565b62001f49565b62001f00565b62001eca565b62001a65565b620017d2565b620016af565b620015d2565b62001524565b620013c0565b620012e0565b620011ea565b6200119d565b6200115a565b620010f3565b620010c8565b6200109d565b62001072565b6200102e565b62000fe1565b62000f93565b62000e90565b62000e0b565b62000dc2565b62000d8b565b62000d04565b62000a72565b620009dd565b62000990565b62000965565b62000924565b6200089f565b6200085f565b62000802565b620006d9565b62000479565b62000410565b620003d6565b34620003c5576020366003190112620003c557620003bd62002c48565b600435609f55005b600080fd5b6000910312620003c557565b34620003c5576000366003190112620003c557602062ffffff60975460a01c16604051908152f35b6001600160a01b03811603620003c557565b34620003c5576020366003190112620003c55760206004356200043381620003fe565b60018060a01b03809116600052609a825260406000205416604051908152f35b6060906003190112620003c5576004356200046e81620003fe565b906024359060443590565b34620003c5576200048a3662000453565b9062000498333b156200306f565b620004a262003018565b6001600160a01b0392831690620004bb8215156200331b565b600093828552609a60205260408520541615801590620005dc575b620004e19062003351565b604051633a947e3560e11b815260048101829052602081602481865afa80156200059b5785946200051d928692620005a5575b50111562003717565b813b15620005a157604051630b0a293f60e11b81523360048201819052602482019290925260448101919091526000606482015291908290818381608481015b03925af180156200059b576200057d575b506200057a6001606555565b80f35b806200058d620005949262002060565b80620003ca565b386200056e565b62002f9a565b5050fd5b620005cc91925060203d8111620005d4575b620005c38183620020ca565b810190620036d0565b903862000514565b503d620005b7565b50609c60205260408420541515620004d6565b6020906003190112620003c55760043590565b634e487b7160e01b600052602160045260246000fd5b600411156200062357565b62000602565b90620006358262000618565b52565b9190916101408101926200064e82825162000629565b6020818101516001600160a01b0316908301526040818101516001600160a01b0316908301526060818101516001600160a01b0316908301526080818101516001600160a01b03169083015260a081015160a083015260c081015160c0830152620006c260e082015160e084019015159052565b610100808201519083015261012080910151910152565b34620003c557620007fe620006ee36620005ef565b604051620006fc8162002074565b60086040600080845280602085015280828501528060608501528060808501528060a08501528060c08501528060e08501526101009481868601528161012080960152815260a16020522062000751620020ec565b936200077982546200076760ff8216886200398d565b841c6001600160a01b03166020870152565b60018201546001600160a01b0316604086015260028201546001600160a01b0316606086015260038201546001600160a01b03166080860152600482015460a0860152600582015460c0860152620007e2620007d9600684015460ff1690565b151560e0870152565b6007820154908501520154908201526040519182918262000638565b0390f35b34620003c5576000366003190112620003c557602062ffffff60975460b81c16604051908152f35b6080906003190112620003c5576004356200084581620003fe565b9060243590604435906064356200085c81620003fe565b90565b34620003c5576200089762000874366200082a565b9262000885929192333b156200306f565b6200088f62003018565b339062003387565b506001606555005b34620003c5576020366003190112620003c557600435620008c081620003fe565b620008ca62002c48565b803b15620008f45760a280546001600160a01b0319166001600160a01b0392909216919091179055005b60405162461bcd60e51b8152602060048201526008602482015267414b465f56494e4360c01b6044820152606490fd5b34620003c5576020366003190112620003c5576004356200094581620003fe565b60018060a01b0316600052609c6020526020604060002054604051908152f35b34620003c5576000366003190112620003c557609d546040516001600160a01b039091168152602090f35b34620003c5576020366003190112620003c557600435620009b181620003fe565b620009bb62002c48565b609d80546001600160a01b0319166001600160a01b0392909216919091179055005b34620003c55760008060031936011262000a3f57620009fb62002c48565b603380546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b9181601f84011215620003c5578235916001600160401b038311620003c55760208381860195010111620003c557565b34620003c5576080366003190112620003c55760243560043562000a9682620003fe565b6001600160401b0391604435838111620003c55762000aba90369060040162000a42565b9091606435858111620003c55762000ad790369060040162000a42565b9362000ae262003018565b609d546001600160a01b03949062000afe908616331462002ebd565b62000b0b87151562002ef3565b62000b468562000b3e62000b318760018060a01b03166000526099602052604060002090565b546001600160a01b031690565b161562002f2a565b62000b7a62000b7362000b6762000b318a600052609b602052604060002090565b6001600160a01b031690565b1562002f62565b6040516101d5808201998a11828b101762000ccd5762004ab8823980600099039089f09182156200059b578589931696873b1562000cc95762000bd590604051958694859463100b506960e11b865289306004880162002fe5565b038183885af180156200059b5762000cb2575b506001600160a01b038116600090815260996020526040902062000c289084905b80546001600160a01b0319166001600160a01b03909216919091179055565b6001600160a01b0383166000908152609a6020526040902062000c4d90829062000c09565b62000c678362000c0986600052609b602052604060002090565b6001600160a01b0383166000908152609c60205260409020849055167fc7e08e9d26d634e7a8c5a116d4312ad4ea4f5de2b728546828d8a3449ed8f6d48480a46200057a6001606555565b806200058d62000cc29262002060565b3862000be8565b8380fd5b6200204a565b6060906003190112620003c55760043562000cee81620003fe565b9060243562000cfd81620003fe565b9060443590565b34620003c55762000d153662000cd3565b9062000d233315156200331b565b336000908152609a60205260409020546001600160a01b039081161580159062000d77575b62000d539062003351565b8262000d5b57005b8060a25416809183160362000d6c57005b6200001b9362004920565b50609c602052604060002054151562000d48565b34620003c5576200089762000da03662000453565b9062000dae333b156200306f565b62000db862003018565b3392339062003387565b34620003c5576020366003190112620003c55762000ddf62003018565b62000de962002c48565b60335462000e0490600435906001600160a01b031662004a16565b6001606555005b34620003c5576020366003190112620003c55760043562000e2c81620003fe565b62000e3662002c48565b803b1562000e6057609e80546001600160a01b0319166001600160a01b0392909216919091179055005b60405162461bcd60e51b8152602060048201526008602482015267414b465f42494e4360c01b6044820152606490fd5b34620003c55760008060031936011262000a3f57805462000ecb60ff8260081c16158092819362000f76575b811562000f53575b5062002cea565b8062000edf600160ff196000541617600055565b62000f38575b62000eef62002d4e565b62000ef75780f35b62000f0861ff001960005416600055565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a180f35b62000f4d61010061ff00196000541617600055565b62000ee5565b303b1591508162000f67575b503862000ec4565b6001915060ff16143862000f5f565b600160ff821610915062000ebc565b62ffffff811603620003c557565b34620003c5576020366003190112620003c55760043562000fb48162000f85565b62000fbe62002c48565b6097805462ffffff60b81b191660b89290921b62ffffff60b81b16919091179055005b34620003c5576020366003190112620003c5576004356200100281620003fe565b6200100c62002c48565b609780546001600160a01b0319166001600160a01b0392909216919091179055005b34620003c55760a0366003190112620003c55760206200106a6024356200105581620003fe565b6084359060643590604435906004356200374e565b604051908152f35b34620003c5576000366003190112620003c55760a2546040516001600160a01b039091168152602090f35b34620003c5576000366003190112620003c5576033546040516001600160a01b039091168152602090f35b34620003c5576000366003190112620003c5576098546040516001600160a01b039091168152602090f35b34620003c5576060366003190112620003c5576001600160401b03602435818111620003c5576200112990369060040162000a42565b604492919235918211620003c5576020926200114e6200106a93369060040162000a42565b92909160043562002e58565b34620003c5576020366003190112620003c55760206004356200117d81620003fe565b60018060a01b038091166000526099825260406000205416604051908152f35b34620003c5576020366003190112620003c557600435620011be81620003fe565b620011c862002c48565b609880546001600160a01b0319166001600160a01b0392909216919091179055005b34620003c557604080600319360112620003c557600435602435916200121083620003fe565b609d546001600160a01b0393906200122c908516331462002ebd565b838116936200123d8515156200331b565b600094808652602091609a835280858820541615801590620012cf575b620012659062003351565b858752609b835284872054161580620012bc575b62001282578580f35b848652609b825283862080546001600160a01b0319166001600160a01b0390941693909317909255609c9185525282205538808080808580f35b50808652609c8252838620541562001279565b50609c83528487205415156200125a565b34620003c5576020366003190112620003c55760043562001303333b156200306f565b6200130d62003018565b60009033825260a4602052604082208183526020526200138f604083206200135d60ff82546200134a3360018060a01b038360081c161462003351565b16620013568162000618565b1562004037565b805460ff19166003178155609e546001600160a01b031660a2546004906001600160a01b031692015491339162004920565b33907f34cf495316dbb07c8286e6c6b35542a47854aaf8050f2dd51ab0347b855582978380a36200057a6001606555565b34620003c5576040366003190112620003c557600435620013e181620003fe565b60243590620013f082620003fe565b620013fa62003018565b609d546001600160a01b039062001415908216331462002ebd565b6200143b8162000b3e62000b318660018060a01b03166000526099602052604060002090565b6200148e6200147e6200146462000b318560018060a01b0316600052609a602052604060002090565b6001600160a01b0316600090815260996020526040902090565b80546001600160a01b0319169055565b811691823b15620003c55760405163033f2ed560e61b81526001600160a01b0382166004820152926000908490602490829084905af19081156200059b57620015029362000c09926200150d575b506001600160a01b0383166000908152609a602052604090206200146490829062000c09565b6200001b6001606555565b806200058d6200151d9262002060565b38620014dc565b34620003c5576040366003190112620003c5576004356200154581620003fe565b62001552333b156200306f565b6200155c62003018565b3315620015a457336000908152609960205260409020546200150291906200159a9062001592906001600160a01b031662000b67565b151562003998565b60243590620039ce565b60405162461bcd60e51b815260206004820152600660248201526520a5a32fa82d60d11b6044820152606490fd5b34620003c5576000366003190112620003c5576097546040516001600160a01b039091168152602090f35b60005b838110620016115750506000910152565b818101518382015260200162001600565b906020916200163d81518092818552858086019101620015fd565b601f01601f1916010190565b602080820190808352835180925260408301928160408460051b8301019501936000915b8483106200167e5750505050505090565b90919293949584806200169e600193603f198682030187528a5162001622565b98019301930191949392906200166d565b6020366003190112620003c557600480356001600160401b0391828211620003c55736602383011215620003c55781810135928311620003c557602490818301928236918660051b010111620003c5576200170a84620043bc565b9360005b818110620017265760405180620007fe888262001649565b6000806200173683858962004434565b604093916200174a8551809381936200447f565b0390305af4906200175a6200448d565b9182901562001791575050906200178b916200177782896200453d565b526200178481886200453d565b506200440e565b6200170e565b868387926044825110620003c55782620017ce9385620017b89401518301019101620044c2565b925162461bcd60e51b815292839283016200452a565b0390fd5b34620003c5576040366003190112620003c557600435602435620017f681620003fe565b62001803333b156200306f565b6200180d62003018565b6001600160a01b038116600090815260a4602052604090206200183c9083905b90600052602052604060002090565b9182549160018060a01b036200186360ff828416956200134a87858360081c161462003351565b6200189662001889846200182d8560018060a01b031660005260a4602052604060002090565b805460ff19166001179055565b6001850154908116946003810154600460ff60028401549460a01c169201549382600014620019c657604051630f0acbd160e01b8152670de0b6b3a76400006004820152946020866024818c5afa9081156200059b576200192b8a9462001951937f7907d0bab36c44f1455bd336290d15ba6eeab66d9a59d0416b5fd857771df69999600091620019a3575b501115620042b1565b60a2546200194a908490839089906001600160a01b03168098620034b4565b906200418f565b908162001982575b5050505b604080519115158252602082019290925290819081015b0390a46200001b6001606555565b609e546200199a93906001600160a01b031662004920565b38808062001959565b620019bf915060203d8111620005d457620005c38183620020ca565b3862001922565b604051630f0acbd160e01b8152670de0b6b3a764000060048201529194506020826024818b5afa9182156200059b577f7907d0bab36c44f1455bd336290d15ba6eeab66d9a59d0416b5fd857771df6999562001a3c9362001a339260009162001a42575b50101562004279565b838189620042e9565b6200195d565b62001a5e915060203d8111620005d457620005c38183620020ca565b3862001a2a565b34620003c55762001a7636620005ef565b62001a83333b156200306f565b62001a8d62003018565b62001aa28160005260a1602052604060002090565b9062001abe62001ab3835460ff1690565b620013568162000618565b62001ad762001ad1600684015460ff1690565b6200406e565b62001ae7600483015415620040a5565b6002820154604051633308f42d60e01b8152926001600160a01b0392909183169060208086600481865afa9586156200059b5760009662001e94575b5062001b338587163314620040dc565b6003840180546001600160a01b0319166001600160a01b038816179055835460ff1916600117845560018401546001600160a01b0316845490929060081c6001600160a01b03169060058601546040519163284be21560e01b9485845280846004818d89165afa9283156200059b578a9460009462001e70575b506040518281600481635b31588360e01b998a82528b165afa80156200059b57828862001be8928f98879560009262001e4c575b506200459d565b9760046040518097819382528d165afa9485156200059b578b9460009662001e26575b50829060046040518097819382528d165afa9081156200059b5762001c45818b8f97948f9989968e9860009362001df0575b50506200459d565b8b896007839e01556008015589818c8a15159562001c949262001c8d928862001ca89962001de6575b62001c79906200412b565b60a2546001600160a01b03168096620035c2565b836200418f565b8a8162001dc5575b505050878288620035c2565b50604080516001600160a01b038881168252939093166020840152820185905260608201889052828716928416917fbf7251dfdcdaa7bf1bd728412bab243e14ae75865dd5516648e1c8a51ad2d72190608090a48581163b15620003c557604051630615077d60e41b8082526001600160a01b0398909816600482015260248101929092526000908290604490829084908a165af180156200059b5762001dae575b508382163b15620003c5576040519485526001600160a01b031660048501526024840191909152600091839160449183918591165af180156200059b5762001d97576200001b6001606555565b806200058d62001da79262002060565b3862001502565b806200058d62001dbe9262002060565b3862001d4a565b609e5462001ddd93906001600160a01b031662004920565b38808a62001c9c565b5080151562001c6e565b62001e15929350803d1062001e1e575b62001e0c8183620020ca565b81019062004113565b90388062001c3d565b503d62001e00565b8391965062001e4490823d841162001e1e5762001e0c8183620020ca565b959062001c0b565b62001e68919250863d881162001e1e5762001e0c8183620020ca565b903862001be1565b62001e8c919450823d841162001e1e5762001e0c8183620020ca565b923862001bad565b8162001eba9297503d881162001ec2575b62001eb18183620020ca565b81019062003e72565b943862001b23565b503d62001ea5565b34620003c5576020366003190112620003c557600435600052609b602052602060018060a01b0360406000205416604051908152f35b34620003c5576020366003190112620003c55762001f1d62003018565b62001f2762002c48565b609e5460335462000e0491600435916001600160a01b0390811691166200482f565b34620003c55762001f5a366200082a565b62001f67333b156200306f565b62001f7162003018565b6001600160a01b0393841662001f898115156200331b565b600094818652609a6020526040862054161580159062002037575b62001faf9062003351565b604051633a947e3560e11b815260048101859052602081602481855afa80156200059b57869462001fea928692620005a55750111562003717565b803b156200203357604051630b0a293f60e11b815233600482015260248101949094526001600160a01b039091166044840152600060648401528290818381608481016200055d565b8280fd5b50609c6020526040852054151562001fa4565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811162000ccd57604052565b61014081019081106001600160401b0382111762000ccd57604052565b61010081019081106001600160401b0382111762000ccd57604052565b60a081019081106001600160401b0382111762000ccd57604052565b90601f801991011681019081106001600160401b0382111762000ccd57604052565b60405190620020fb8262002074565b565b6001600160401b03811162000ccd57601f01601f191660200190565b81601f82011215620003c5578035906200213382620020fd565b92620021436040519485620020ca565b82845260208383010111620003c557816000926020809301838601378301015290565b34620003c5576080366003190112620003c5576001600160401b03600435602435828111620003c5576200219f90369060040162000a42565b604435848111620003c557620021ba90369060040162000a42565b929091606435868111620003c557620021d890369060040162002119565b91620021e6333b156200306f565b620021f062003018565b6200222d60018060a01b039362002222856200221a62000b318b600052609b602052604060002090565b161562002f62565b868685858b620030a6565b50506040516101d5808201988911828a101762000ccd5762004ab8823980600098039088f09283156200059b5787931694853b1562000cc9576200228890604051958694859463100b506960e11b8652306004870162002fa6565b038183865af180156200059b5762002301575b50620022b68162000c0984600052609b602052604060002090565b6001600160a01b0381166000908152609c60205260409020829055827f0fda88fcc31b35d80e62f303bc442eecd55f84ad381eef53826fd5bc48e5b7fe8180a46200057a6001606555565b806200058d620023119262002060565b386200229b565b34620003c55760c0366003190112620003c5576004356024356200233c81620003fe565b604435906064359060a4356084356001600160401b038211620003c5576200236d6200242e92369060040162002119565b906200237b333b156200306f565b6200238562003018565b62002399652d79883d200087111562003795565b620023d8620023d2620023ce620023c78a6200182d8960018060a01b031660005260a0602052604060002090565b5460ff1690565b1590565b620037cb565b620023fe62001889886200182d8760018060a01b031660005260a0602052604060002090565b609f54948581148062002520575b620024179062003801565b620024254283101562003837565b868589620038a4565b5050609e546040516370a0823160e01b81526001600160a01b03838116600483015292918316602082602481845afa9182156200059b5786670de0b6b3a7640000620024bd7f05c966387bde83883f64200b4d9f73042dd5dbe77e737d0e39db4f391b54bb1f98620024b684620024ef98620024c897600091620024fd575b5010156200386d565b8362004589565b049285309162004920565b620024d4818462004a16565b60405193849316958360209093929193604081019481520152565b0390a36200001b6001606555565b62002519915060203d8111620005d457620005c38183620020ca565b38620024ad565b508515156200240c565b34620003c5576200253b36620005ef565b62002548333b156200306f565b6200255262003018565b620025678160005260a1602052604060002090565b908154916200257e60ff8416620013568162000618565b6200259162001ad1600683015460ff1690565b60028101546001600160a01b0390811693620025af8515156200420b565b604051633308f42d60e01b8082529260209081836004818b5afa9283156200059b57600093620026b9575b508293620025ed82849516331462004242565b60081c1693620025ff8515156200419d565b60046040518096819382525afa9384156200059b577fd3bb236a8c097c79eea15f66e43bf3984e6672bd5d434c74b4cb6b70c834508b94620024ef946200267d9360009262002697575b5050815460ff19166003178255609e546001600160a01b03165b60a254600590930154926001600160a01b03169062004920565b6040516001600160a01b0390911681529081906020820190565b620026b19250803d1062001ec25762001eb18183620020ca565b388062002649565b829350620026d690833d851162001ec25762001eb18183620020ca565b92620025da565b34620003c5576020366003190112620003c557600435620026fe8162000f85565b6200270862002c48565b6097805462ffffff60a01b191660a09290921b62ffffff60a01b16919091179055005b34620003c5576080366003190112620003c55760206004356200274e81620003fe565b602435906200275d82620003fe565b604051908382019230845246604084015260018060a01b03809216606084015216608082015260443560a082015260643560c08201524360e082015260e08152620027a88162002091565b519020604051908152f35b80151503620003c557565b34620003c55760c0366003190112620003c557602435600435620027e282620003fe565b60443590620027f182620027b3565b7f43b998e47453d980655a7f5405259ce1526efb62b8777e639f7ad6dee421c3cb60643593608435906200197460a4356200282e333b156200306f565b6200283862003018565b33600090815260a460205260409020620028549087906200182d565b80546001600160a01b039591620028e391620028769060081c88161562003351565b8a15158062002934575b6200288b9062003801565b805460018201805460ff60a01b8d151560a01b166001600160a81b03199182166001600160a01b038b161717909155600283018d9055600383018590556004830186905516610100600160a81b033360081b16179055565b609e546200290b9083906001600160a01b031660a2546001600160a01b031690339062004920565b604051948594169833988590949392606092608083019615158352602083015260408201520152565b5083151562002880565b34620003c5576200294f36620005ef565b6200295c333b156200306f565b6200296662003018565b6200297b8160005260a1602052604060002090565b908154916200299260ff8416620013568162000618565b620029a562001ad1600683015460ff1690565b60018060a01b03809360081c1692620029c08415156200419d565b604051633308f42d60e01b815290602082600481885afa80156200059b577f0240ef67b9a39238db2f92fc057c26bce3d089137a6fbf3c728f4c6078258ddf93620024ef9360009262002a42575b5062002a2382936200267d93163314620041d4565b805460ff19166002178155609e5483906001600160a01b031662002663565b6200267d925062002a6762002a239160203d811162001ec25762001eb18183620020ca565b925062002a0e565b34620003c5576080366003190112620003c5576200089760643562002a9481620003fe565b62002aa1333b156200306f565b62002aab62003018565b600435600052609b6020526044356024353360018060a01b036040600020541662003387565b34620003c5576000366003190112620003c5576020609f54604051908152f35b34620003c5576000366003190112620003c557609e546040516001600160a01b039091168152602090f35b34620003c55762002b2d3662000cd3565b9062002b3b3315156200331b565b336000908152609a60205260409020546001600160a01b03919082161580159062002b9a575b62002b6c9062003351565b8262002b7457005b60a254821691811630810362002b915750506200001b926200482f565b820362000d6c57005b50609c602052604060002054151562002b61565b34620003c5576020366003190112620003c55760043562002bcf81620003fe565b62002bd962002c48565b6001600160a01b0381161562002bf4576200001b9062002ca1565b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b6033546001600160a01b0316330362002c5d57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b603380546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b1562002cf257565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b62002d6c60ff60005460081c1662002d668162002dd6565b62002dd6565b62002d773362002ca1565b62002d8f60ff60005460081c1662002d668162002dd6565b60016065556bffffffffffffffffffffffff60a01b33816098541617609855640c35000c3560a41b65ffffffffffff60a01b1960975416176097553390609d541617609d55565b1562002dde57565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b908060209392818452848401376000828201840152601f01601f1916010190565b939162002eaa62002eb79394929462002e956040519687946020860199308b52466040880152606087015260a0608087015260c086019162002e37565b90601f1994858584030160a086015262002e37565b03908101835282620020ca565b51902090565b1562002ec557565b60405162461bcd60e51b8152602060048201526006602482015265414b465f4e4160d01b6044820152606490fd5b1562002efb57565b60405162461bcd60e51b815260206004820152600760248201526620a5a32faa2d2b60c91b6044820152606490fd5b1562002f3257565b60405162461bcd60e51b8152602060048201526008602482015267414b465f504e5a4160c01b6044820152606490fd5b1562002f6a57565b60405162461bcd60e51b8152602060048201526008602482015267414b465f544e5a4160c01b6044820152606490fd5b6040513d6000823e3d90fd5b93916200085c959362002fd69260018060a01b031686526000602087015260806040870152608086019162002e37565b92606081850391015262002e37565b949290936200085c969462002fd69360018060a01b03809216885216602087015260806040870152608086019162002e37565b6002606554146200302a576002606555565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b156200307757565b60405162461bcd60e51b8152602060048201526007602482015266414b465f43494360c81b6044820152606490fd5b92620030c092620031049592620030fb9598979862002e58565b93620030f5857f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c60002090565b6200325b565b9190916200312f565b609d5462003120906001600160a01b0383811691161462002ebd565b9190565b600511156200062357565b6200313a8162003124565b80620031435750565b6200314e8162003124565b600181036200319c5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b620031a78162003124565b60028103620031f55760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b806200320360039262003124565b146200320b57565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b9060418151146000146200328c5762003288916020820151906060604084015193015160001a9062003296565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116200330f5791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156200059b5781516001600160a01b0381161562003309579190565b50600190565b50505050600090600390565b156200332357565b60405162461bcd60e51b815260206004820152600660248201526520a5a32faa2d60d11b6044820152606490fd5b156200335957565b60405162461bcd60e51b81526020600482015260066024820152651052d197d09560d21b6044820152606490fd5b9094936001600160a01b03929091831690620033a58215156200331b565b600093828552609a60205260408520541615801590620034a1575b620033cb9062003351565b60405163f2d9492f60e01b81526004810182905294602086602481865afa9586156200059b57859662003477575b508562003408911015620036e0565b813b1562000cc957604051630f08f3ff60e11b81526001600160a01b039788166004820152602481019190915295909116604486015260006064860152929391928290818381608481015b03925af180156200059b5762003467575090565b806200058d6200085c9262002060565b62003408919650620034999060203d8111620005d457620005c38183620020ca565b9590620033f9565b50609c60205260408420541515620033c0565b9094936001600160a01b03929091831690620034d28215156200331b565b600093828552609a60205260408520541615801590620035af575b620034f89062003351565b60405163f2d9492f60e01b81526004810182905294602086602481865afa9586156200059b57859662003585575b508562003535911015620036e0565b813b1562000cc957604051630f08f3ff60e11b81526001600160a01b0397881660048201526024810191909152959091166044860152600260648601529293919282908183816084810162003453565b62003535919650620035a79060203d8111620005d457620005c38183620020ca565b959062003526565b50609c60205260408420541515620034ed565b9094936001600160a01b03929091831690620035e08215156200331b565b600093828552609a60205260408520541615801590620036bd575b620036069062003351565b60405163f2d9492f60e01b81526004810182905294602086602481865afa9586156200059b57859662003693575b508562003643911015620036e0565b813b1562000cc957604051630f08f3ff60e11b81526001600160a01b0397881660048201526024810191909152959091166044860152600160648601529293919282908183816084810162003453565b62003643919650620036b59060203d8111620005d457620005c38183620020ca565b959062003634565b50609c60205260408420541515620035fb565b90816020910312620003c5575190565b15620036e857565b60405162461bcd60e51b81526020600482015260076024820152660414b465f4242560cc1b6044820152606490fd5b156200371f57565b60405162461bcd60e51b81526020600482015260076024820152660414b465f4253560cc1b6044820152606490fd5b9391929092604051936020850195308752466040870152606086015260018060a01b0316608085015260a084015260c083015260e082015260e0815262002eb78162002091565b156200379d57565b60405162461bcd60e51b8152602060048201526006602482015265414b465f494160d01b6044820152606490fd5b15620037d357565b60405162461bcd60e51b815260206004820152600660248201526520a5a32fa12760d11b6044820152606490fd5b156200380957565b60405162461bcd60e51b815260206004820152600660248201526520a5a32fa12960d11b6044820152606490fd5b156200383f57565b60405162461bcd60e51b81526020600482015260066024820152651052d197d09160d21b6044820152606490fd5b156200387557565b60405162461bcd60e51b815260206004820152600760248201526620a5a32fa4a12160c91b6044820152606490fd5b938193620038f493620038bf93620038fd979998996200374e565b94620030f5867f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c60002090565b9290926200312f565b6001600160a01b039081169082160362003915579190565b60405162461bcd60e51b81526020600482015260066024820152651052d197d39560d21b6044820152606490fd5b909160405191602083019330855246604085015260018060a01b038092166060850152166080830152600060a083015260c08201524360e082015260e0815262002eb78162002091565b620006358262000618565b15620039a057565b60405162461bcd60e51b81526020600482015260066024820152650414b465f42560d41b6044820152606490fd5b6001600160a01b038181169290620039e88415156200331b565b600091848352602093609a85526040948386862054161580159062003dba575b62003a139062003351565b62003a2083151562003dcb565b33600090815260996020526040902062003a3a9062000b31565b928484169662003a4d8989141562003e03565b805163f2d9492f60e01b80825267016345785d8a000060048301529084816024818d5afa9081156200059b57899162003d98575b508310158062003d3c575b62003a98915062003e3a565b805192633308f42d60e01b9788855281856004818d5afa9485156200059b57819562003d18575b5062003acf888616331462003e8a565b609e5462003ae89062000b67906001600160a01b031681565b83516370a0823160e01b81526001600160a01b0387166004820152908390829060249082905afa998a156200059b5762003b778d9a62003b6f62003b4d8962003b5f9f8e62003b478f9284908d9b8d9162003cf6575b50101562003ec1565b62003943565b9d8e60005260a1602052604060002090565b5460081c6001600160a01b031690565b161562003efa565b60048551809b819382525afa9586156200059b577f1b88229ac738467a5b6ad4f608a992b440ec8757a7f6a0e987379e4d51e41f7298829762003cb8575b509062003c0b62003c5c939262003bed62003cb398999a62003bd6620020ec565b8581526001600160a01b0390911695810195909552565b6001600160a01b038916848701526001600160a01b03166060840152565b6001600160a01b03881660808301528060a08301528460c083015262003c3460e0830160019052565b8061010083015261012082015262003c568960005260a1602052604060002090565b62003f4b565b609e5462003c849083906001600160a01b031660a25487906001600160a01b03169162004920565b516001600160a01b03938416815293909216602084015260006040840152606083019190915281906080820190565b0390a4565b62003cb396975083929162003bed62003ce862003c0b9362003c5c973d881162001ec25762001eb18183620020ca565b999850509192935062003bb5565b62003d1191508c8d3d10620005d457620005c38183620020ca565b3862003b3e565b62003d34919550823d841162001ec25762001eb18183620020ca565b933862003abf565b50815190815267016345785d8a0000600482015283816024818d5afa80156200059b5762003a9891899162003d76575b5083101562003a8c565b62003d919150853d8711620005d457620005c38183620020ca565b3862003d6c565b62003db39150853d8711620005d457620005c38183620020ca565b3862003a81565b50609c815285852054151562003a08565b1562003dd357565b60405162461bcd60e51b815260206004820152600860248201526720a5a32fa128272d60c11b6044820152606490fd5b1562003e0b57565b60405162461bcd60e51b81526020600482015260076024820152661052d197d3915560ca1b6044820152606490fd5b1562003e4257565b60405162461bcd60e51b8152602060048201526008602482015267414b465f4242504d60c01b6044820152606490fd5b90816020910312620003c557516200085c81620003fe565b1562003e9257565b60405162461bcd60e51b8152602060048201526007602482015266414b465f4e4f4160c81b6044820152606490fd5b1562003ec957565b60405162461bcd60e51b815260206004820152600960248201526820a5a32fa7a0a722a160b91b6044820152606490fd5b1562003f0257565b60405162461bcd60e51b8152602060048201526007602482015266414b465f424f4960c81b6044820152606490fd5b9062003f3d8162000618565b60ff80198354169116179055565b9061012060089162003f6a815162003f638162000618565b8562003f31565b602081015162003f9f906001600160a01b03168554610100600160a81b03191660089190911b610100600160a81b0316178555565b60408101516001850180546001600160a01b039283166001600160a01b0319918216179091556060830151600287018054918416918316919091179055608083015160038701805491909316911617905560a0810151600485015560c0810151600585015560e081015162004025901515600686019060ff801983541691151516179055565b61010081015160078501550151910155565b156200403f57565b60405162461bcd60e51b8152602060048201526007602482015266414b465f424f5360c81b6044820152606490fd5b156200407657565b60405162461bcd60e51b81526020600482015260076024820152661052d197d3d39360ca1b6044820152606490fd5b15620040ad57565b60405162461bcd60e51b815260206004820152600760248201526620a5a32fa7a72960c91b6044820152606490fd5b15620040e457565b60405162461bcd60e51b815260206004820152600760248201526620a5a32fa727a160c91b6044820152606490fd5b90816020910312620003c557516200085c8162000f85565b156200413357565b60405162461bcd60e51b8152602060048201526008602482015267414b465f42414e4d60c01b6044820152606490fd5b634e487b7160e01b600052601160045260246000fd5b6009198101919082116200418957565b62004163565b919082039182116200418957565b15620041a557565b60405162461bcd60e51b8152602060048201526007602482015266414b465f49544160c81b6044820152606490fd5b15620041dc57565b60405162461bcd60e51b8152602060048201526007602482015266414b465f494f4160c81b6044820152606490fd5b156200421357565b60405162461bcd60e51b815260206004820152600760248201526620a5a32fa4aa2160c91b6044820152606490fd5b156200424a57565b60405162461bcd60e51b815260206004820152600760248201526620a5a32fa4a7a160c91b6044820152606490fd5b156200428157565b60405162461bcd60e51b81526020600482015260086024820152670414b465f425453560c41b6044820152606490fd5b15620042b957565b60405162461bcd60e51b81526020600482015260086024820152670414b465f425442560c41b6044820152606490fd5b9093926001600160a01b03929091831690620043078215156200331b565b600093828552609a6020526040852054161580159062004391575b6200432d9062003351565b813b1562000cc957604051630b0a293f60e11b81526001600160a01b03968716600482015260248101919091529190941660448201526002606482015291928290608490829084905af180156200059b57620043865750565b620020fb9062002060565b50609c6020526040842054151562004322565b6001600160401b03811162000ccd5760051b60200190565b90620043c882620043a4565b620043d76040519182620020ca565b8281528092620043ea601f1991620043a4565b019060005b828110620043fc57505050565b806060602080938501015201620043ef565b6000198114620041895760010190565b634e487b7160e01b600052603260045260246000fd5b9190811015620044795760051b81013590601e1981360301821215620003c55701908135916001600160401b038311620003c5576020018236038113620003c5579190565b6200441e565b908092918237016000815290565b3d15620044bd573d90620044a182620020fd565b91620044b16040519384620020ca565b82523d6000602084013e565b606090565b602081830312620003c5578051906001600160401b038211620003c5570181601f82011215620003c5578051620044f981620020fd565b92620045096040519485620020ca565b81845260208284010111620003c5576200085c9160208085019101620015fd565b9060206200085c92818152019062001622565b8051821015620044795760209160051b010190565b600181901b91906001600160ff1b038116036200418957565b90670de0b6b3a7640000918281029281840414901517156200418957565b818102929181159184041417156200418957565b6040516318160ddd60e01b8152919392909190602090829060049082906001600160a01b03165afa9081156200059b5760009162004650575b5060005b83620045f3620045ea8362004673565b848887620046cb565b116200460a57620046049062004673565b620045da565b939291905b82620046286200461f8762004689565b838786620046cb565b1162004649576200463f6200462893949562004689565b949392506200460f565b5050505090565b6200466c915060203d8111620005d457620005c38183620020ca565b38620045d6565b90670de0b6b3a764000082018092116200418957565b9067016345785d8a000082018092116200418957565b90600182018092116200418957565b90600a82018092116200418957565b919082018092116200418957565b91906200473e620047386200473062004727620047216200085c986200476d9767016345785d8a000080910491049080159182600014620047df576000925b80620047d4575b156200477357505060006200418f565b6200456b565b62040740900490565b6103e8900490565b6200469f565b9262004765620f424091826200475b62ffffff8093168862004589565b0493168562004589565b0492620046bd565b620046bd565b81620047ad620047c1620047bb846200476d620047b4620047a1620047c7986200476d620047ce9b62004179565b620047ad8489620046bd565b9062004589565b9562004179565b62004552565b620046ae565b6006900490565b6200418f565b506001811462004711565b62004810620047c7620047fd84620047f78162004179565b62004589565b620047ad620047c1620047bb8762004179565b926200470a565b90816020910312620003c557516200085c81620027b3565b60405163a9059cbb60e01b602082019081526001600160a01b03939093166024820152604480820194909452928352600092839290839062004873606482620020ca565b51925af1620048816200448d565b81620048ec575b50156200489157565b60405162461bcd60e51b815260206004820152602d60248201527f5472616e7366657248656c7065723a3a736166655472616e736665723a20747260448201526c185b9cd9995c8819985a5b1959609a1b6064820152608490fd5b805180159250821562004903575b50503862004888565b62004918925060208091830101910162004817565b3880620048fa565b9091600080949381946040519160208301946323b872dd60e01b865260018060a01b0380921660248501521660448301526064820152606481526200496581620020ae565b51925af1620049736200448d565b81620049e2575b50156200498357565b60405162461bcd60e51b815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a207472604482015270185b9cd9995c919c9bdb4819985a5b1959607a1b6064820152608490fd5b8051801592508215620049f9575b5050386200497a565b62004a0e925060208091830101910162004817565b3880620049f0565b60405160208101908082106001600160401b0383111762000ccd576000938493848094938194604052525af162004a4c6200448d565b501562004a5557565b60405162461bcd60e51b815260206004820152603460248201527f5472616e7366657248656c7065723a3a736166655472616e736665724554483a60448201527308115512081d1c985b9cd9995c8819985a5b195960621b6064820152608490fdfe60a0806040523461002857336080526101a7908161002e823960805181818160410152608b0152f35b600080fdfe60806040526004361015610018575b3661007657610076565b6000803560e01c63c45a01551461002f575061000e565b346100735780600319360112610073577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166080908152602090f35b80fd5b60405163a8b8a55d60e01b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115610122576000916100ca575b5061012e565b60203d811161011b575b601f8101601f1916820167ffffffffffffffff81118382101761010757610101935060405281019061014d565b386100c4565b634e487b7160e01b84526041600452602484fd5b503d6100d4565b6040513d6000823e3d90fd5b6000808092368280378136915af43d82803e15610149573d90f35b3d90fd5b9081602091031261016c57516001600160a01b038116810361016c5790565b600080fdfea26469706673582212202144b141b34a6ae867daf0fa9374097fc97aacff3e58749d364914bfcd8836e664736f6c63430008130033a26469706673582212203db21c1f71aaffd624e1b6e0cdd3136345263bcf7592551bb2e7be26b5b67e8d64736f6c63430008130033