ETH Price: $3,120.32 (-0.05%)

Contract

0xf2525fD84e3579EfC7eCC160fb8d025b8EE7d5C2
 
Transaction Hash
Method
Block
From
To
Withdraw155984552022-09-23 20:32:23788 days ago1663965143IN
0xf2525fD8...b8EE7d5C2
0 ETH0.000159115.43017856
Withdraw155984502022-09-23 20:31:23788 days ago1663965083IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0004955.62529423
Withdraw144230422022-03-20 11:40:42975 days ago1647776442IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0011599213.1815224
Withdraw143333272022-03-06 12:29:58989 days ago1646569798IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0017304319.66491819
Withdraw133961462021-10-11 8:04:451136 days ago1633939485IN
0xf2525fD8...b8EE7d5C2
0 ETH0.005145672.57968796
Withdraw133437952021-10-03 3:09:371144 days ago1633230577IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0087598751.96672679
Withdraw132360962021-09-16 9:58:241161 days ago1631786304IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0046495552.83829578
Withdraw130771072021-08-22 19:49:581185 days ago1629661798IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0034280348.35306123
Withdraw130737602021-08-22 7:25:131186 days ago1629617113IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0015651822.07713365
Withdraw130716402021-08-21 23:33:191186 days ago1629588799IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0048544626.14606585
Withdraw130616232021-08-20 10:32:241188 days ago1629455544IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0020997523.86196827
Withdraw130545342021-08-19 8:09:061189 days ago1629360546IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0063526634.22715844
Withdraw130539732021-08-19 6:00:391189 days ago1629352839IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0019229527.12354911
Withdraw130539702021-08-19 6:00:211189 days ago1629352821IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0017819321.89679802
Withdraw130539702021-08-19 6:00:211189 days ago1629352821IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0022614121.75336429
Withdraw130283662021-08-15 7:23:261193 days ago1629012206IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0028787632.71467071
Withdraw130206472021-08-14 2:31:461194 days ago1628908306IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0031341435.61693469
Withdraw129990482021-08-10 18:19:131197 days ago1628619553IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0027676339.03797751
Withdraw129965612021-08-10 9:23:461198 days ago1628587426IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0025397931.20949033
Withdraw129963692021-08-10 8:44:191198 days ago1628585059IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0036958342
Withdraw129923982021-08-09 17:49:031198 days ago1628531343IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0050157757
Withdraw129712942021-08-06 11:59:451201 days ago1628251185IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0024638828
Withdraw129629432021-08-05 4:43:571203 days ago1628138637IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0010636636.3
Withdraw129629432021-08-05 4:43:571203 days ago1628138637IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0010255735
Withdraw129629262021-08-05 4:39:581203 days ago1628138398IN
0xf2525fD8...b8EE7d5C2
0 ETH0.0010255735
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
KingDecks

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 11 : KingDecks.sol
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "./libraries/TokenList.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

/**
 * It accepts deposits of a pre-defined ERC-20 token(s), the "deposit" token.
 * The deposit token will be repaid with another ERC-20 token, the "repay"
 * token (e.g. a stable-coin), at a pre-defined rate.
 *
 * On top of the deposit token, a particular NFT (ERC-721) instance may be
 * required to be deposited as well. If so, this exact NFT will be returned.
 *
 * Note the `treasury` account that borrows and repays tokens.
 */
contract KingDecks is Ownable, ReentrancyGuard, TokenList {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    // On a deposit withdrawal, a user receives the "repay" token
    // (but not the originally deposited ERC-20 token).
    // The amount (in the  "repay" token units) to be repaid is:
    // `amountDue = Deposit.amount * TermSheet.rate/1e+9`                (1)

    // If interim withdrawals allowed, the amount which can not be withdrawn
    // before the deposit period ends is:
    // `minBalance = Deposit.amountDue * Deposit.lockedShare / 65535`    (2)
    //
    // (note: `TermSheet.earlyRepayableShare` defines `Deposit.lockedShare`)

    // Limit on the deposited ERC-20 token amount
    struct Limit {
        // Min token amount to deposit
        uint224 minAmount;
        // Max deposit amount multiplier, scaled by 1e+4
        // (no limit, if set to 0):
        // `maxAmount = minAmount * maxAmountFactor/1e4`
        uint32 maxAmountFactor;
    }

    // Terms of deposit(s)
    struct TermSheet {
        // Remaining number of deposits allowed under this term sheet
        // (if set to zero, deposits disabled; 255 - no limitations applied)
        uint8 availableQty;
        // ID of the ERC-20 token to deposit
        uint8 inTokenId;
        // ID of the ERC-721 token (contract) to deposit
        // (if set to 0, no ERC-721 token is required to be deposited)
        uint8 nfTokenId;
        // ID of the ERC-20 token to return instead of the deposited token
        uint8 outTokenId;
        // Maximum amount that may be withdrawn before the deposit period ends,
        // in 1/255 shares of the deposit amount.
        // The amount linearly increases from zero to this value with time.
        // (if set to zero, early withdrawals are disabled)
        uint8 earlyRepayableShare;
        // Fees on early withdrawal, in 1/255 shares of the amount withdrawn
        // (fees linearly decline to zero towards the repayment time)
        // (if set to zero, no fees charged)
        uint8 earlyWithdrawFees;
        // ID of the deposit amount limit (equals to: index in `_limits` + 1)
        // (if set to 0, no limitations on the amount applied)
        uint16 limitId;
        // Deposit period in hours
        uint16 depositHours;
        // Min time between interim (early) withdrawals
        // (if set to 0, no limits on interim withdrawal time)
        uint16 minInterimHours;
        // Rate to compute the "repay" amount, scaled by 1e+9 (see (1))
        uint64 rate;
        // Bit-mask for NFT IDs (in the range 1..64) allowed to deposit
        // (if set to 0, no limitations on NFT IDs applied)
        uint64 allowedNftNumBitMask;
    }

    // Parameters of a deposit
    struct Deposit {
        uint176 amountDue;      // Amount due, in "repay" token units
        uint32 maturityTime;    // Time the final withdrawal is allowed since
        uint32 lastWithdrawTime;// Time of the most recent interim withdrawal
        uint16 lockedShare;     // in 1/65535 shares of `amountDue` (see (2))
        // Note:
        // - the depositor account and the deposit ID linked via mappings
        // - other props (eg.: `termsId`) encoded within the ID of a deposit
    }

    // Deposits of a user
    struct UserDeposits {
        // Set of (unique) deposit IDs
        uint256[] ids;
        // Mapping from deposit ID to deposit data
        mapping(uint256 => Deposit) data;
    }

    // Number of deposits made so far
    uint32 public depositQty;

    // Account that controls the tokens deposited
    address public treasury;

    // Limits on "deposit" token amount
    Limit[] private _limits;

    // Info on each TermSheet
    TermSheet[] internal _termSheets;

    // Mappings from a "repay" token ID to the total amount due
    mapping(uint256 => uint256) public totalDue; // in "repay" token units

    // Mapping from user account to user deposits
    mapping(address => UserDeposits) internal _deposits;

    event NewDeposit(
        uint256 indexed inTokenId,
        uint256 indexed outTokenId,
        address indexed user,
        uint256 depositId,
        uint256 termsId,
        uint256 amount, // amount deposited (in deposit token units)
        uint256 amountDue, // amount to be returned (in "repay" token units)
        uint256 maturityTime // UNIX-time when the deposit is unlocked
    );

    // User withdraws the deposit
    event Withdraw(
        address indexed user,
        uint256 depositId,
        uint256 amount // amount sent to user (in deposit token units)
    );

    event InterimWithdraw(
        address indexed user,
        uint256 depositId,
        uint256 amount, // amount sent to user (in "repay" token units)
        uint256 fees // withheld fees (in "repay" token units)
    );

    // termsId is the index in the `_termSheets` array + 1
    event NewTermSheet(uint256 indexed termsId);
    event TermsEnabled(uint256 indexed termsId);
    event TermsDisabled(uint256 indexed termsId);

    constructor(address _treasury) public {
        _setTreasury(_treasury);
    }

    function depositIds(
        address user
    ) external view returns (uint256[] memory) {
        _revertZeroAddress(user);
        UserDeposits storage userDeposits = _deposits[user];
        return userDeposits.ids;
    }

    function depositData(
        address user,
        uint256 depositId
    ) external view returns(uint256 termsId, Deposit memory params) {
        params = _deposits[_nonZeroAddr(user)].data[depositId];
        termsId = 0;
        if (params.maturityTime !=0) {
            (termsId, , , ) = _decodeDepositId(depositId);
        }
    }

    function termSheet(
        uint256 termsId
    ) external view returns (TermSheet memory) {
        return _termSheets[_validTermsID(termsId) - 1];
    }

    function termSheetsNum() external view returns (uint256) {
        return _termSheets.length;
    }

    function allTermSheets() external view returns(TermSheet[] memory) {
        return _termSheets;
    }

    function depositLimit(
        uint256 limitId
    ) external view returns (Limit memory) {
        return _limits[_validLimitID(limitId) - 1];
    }

    function depositLimitsNum() external view returns (uint256) {
        return _limits.length;
    }

    function getTokenData(
        uint256 tokenId
    ) external view returns(address, TokenType, uint8 decimals) {
        return _token(uint8(tokenId));
    }

    function isAcceptableNft(
        uint256 termsId,
        address nftContract,
        uint256 nftId
    ) external view returns(bool) {
        TermSheet memory tS = _termSheets[_validTermsID(termsId) - 1];
        if (tS.nfTokenId != 0 && _tokenAddr(tS.nfTokenId) == nftContract) {
            return _isAllowedNftId(nftId, tS.allowedNftNumBitMask);
        }
        return false;
    }

    function idsToBitmask(
        uint256[] memory ids
    ) pure external returns(uint256 bitmask) {
        bitmask = 0;
        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            require(id != 0 && id <= 64, "KDecks:unsupported NFT ID");
            bitmask = bitmask | (id == 1 ? 1 : 2 << (id - 2));
        }
    }

    function computeEarlyWithdrawal(
        address user,
        uint256 depositId
    ) external view returns (uint256 amountToUser, uint256 fees) {
        Deposit memory _deposit = _deposits[user].data[depositId];
        require(_deposit.amountDue != 0, "KDecks:unknown or repaid deposit");

        (uint256 termsId, , , ) = _decodeDepositId(depositId);
        TermSheet memory tS = _termSheets[termsId - 1];

        (amountToUser, fees, ) = _computeEarlyWithdrawal(_deposit, tS, now);
    }

    function deposit(
        uint256 termsId,    // term sheet ID
        uint256 amount,     // amount in deposit token units
        uint256 nftId       // ID of the NFT instance (0 if no NFT required)
    ) public nonReentrant {
        TermSheet memory tS = _termSheets[_validTermsID(termsId) - 1];
        require(tS.availableQty != 0, "KDecks:terms disabled or unknown");

        if (tS.availableQty != 255) {
            _termSheets[termsId - 1].availableQty = --tS.availableQty;
            if ( tS.availableQty == 0) emit TermsDisabled(termsId);
        }

        if (tS.limitId != 0) {
            Limit memory l = _limits[tS.limitId - 1];
            require(amount >= l.minAmount, "KDecks:too small deposit amount");
            if (l.maxAmountFactor != 0) {
                require(
                    amount <=
                        uint256(l.minAmount).mul(l.maxAmountFactor) / 1e4,
                    "KDecks:too big deposit amount"
                );
            }
        }

        uint256 serialNum = depositQty + 1;
        depositQty = uint32(serialNum); // overflow risk ignored

        uint256 depositId = _encodeDepositId(
            serialNum,
            termsId,
            tS.outTokenId,
            tS.nfTokenId,
            nftId
        );

        address tokenIn;
        uint256 amountDue;
        {
            uint8 decimalsIn;
            (tokenIn,, decimalsIn) = _token(tS.inTokenId);
            (,, uint8 decimalsOut) = _token(tS.outTokenId);
            amountDue = _amountOut(amount, tS.rate, decimalsIn, decimalsOut);
        }

        require(amountDue < 2**178, "KDecks:O2");
        uint32 maturityTime = safe32(now.add(uint256(tS.depositHours) *3600));

        if (tS.nfTokenId == 0) {
            require(nftId == 0, "KDecks:unexpected non-zero nftId");
        } else {
            require(
                nftId < 2**16 &&
                _isAllowedNftId(nftId, tS.allowedNftNumBitMask),
                "KDecks:disallowed NFT instance"
            );
            IERC721(_tokenAddr(tS.nfTokenId))
                .safeTransferFrom(msg.sender, address(this), nftId, _NFT_PASS);
        }

        IERC20(tokenIn).safeTransferFrom(msg.sender, treasury, amount);

        // inverted and re-scaled from 255 to 65535
        uint256 lockedShare = uint(255 - tS.earlyRepayableShare) * 65535/255;
        _registerDeposit(
            _deposits[msg.sender],
            depositId,
            Deposit(
                uint176(amountDue),
                maturityTime,
                safe32(now),
                uint16(lockedShare)
            )
        );
        totalDue[tS.outTokenId] = totalDue[tS.outTokenId].add(amountDue);

        emit NewDeposit(
            tS.inTokenId,
            tS.outTokenId,
            msg.sender,
            depositId,
            termsId,
            amount,
            amountDue,
            maturityTime
        );
    }

    // Entirely withdraw the deposit (when the deposit period ends)
    function withdraw(uint256 depositId) public nonReentrant {
        _withdraw(depositId, false);
    }

    // Early withdrawal of the unlocked "repay" token amount (beware of fees!!)
    function interimWithdraw(uint256 depositId) public nonReentrant {
        _withdraw(depositId, true);
    }

    function addTerms(TermSheet[] memory termSheets) public onlyOwner {
        for (uint256 i = 0; i < termSheets.length; i++) {
            _addTermSheet(termSheets[i]);
        }
    }

    function updateAvailableQty(
        uint256 termsId,
        uint256 newQty
    ) external onlyOwner {
        require(newQty <= 255, "KDecks:INVALID_availableQty");
        _termSheets[_validTermsID(termsId) - 1].availableQty = uint8(newQty);
        if (newQty == 0) {
            emit TermsDisabled(termsId);
        } else {
            emit TermsEnabled(termsId);
        }
    }

    function addLimits(Limit[] memory limits) public onlyOwner {
        // Risk of `limitId` (16 bits) overflow ignored
        for (uint256 i = 0; i < limits.length; i++) {
            _addLimit(limits[i]);
        }
    }

    function addTokens(
        address[] memory addresses,
        TokenType[] memory types,
        uint8[] memory decimals
    ) external onlyOwner {
        _addTokens(addresses, types, decimals);
    }

    function setTreasury(address _treasury) public onlyOwner {
        _setTreasury(_treasury);
    }

    // Save occasional airdrop or mistakenly transferred tokens
    function transferFromContract(IERC20 token, uint256 amount, address to)
        external
        onlyOwner
    {
        _revertZeroAddress(to);
        token.safeTransfer(to, amount);
    }

    // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
    bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;
    // Equals to `bytes4(keccak256("KingDecks"))`
    bytes private constant _NFT_PASS = abi.encodePacked(bytes4(0xb0e68bdd));

    // Implementation of the ERC721 Receiver
    function onERC721Received(address, address, uint256, bytes calldata data)
        external
        pure
        returns (bytes4)
    {
        // Only accept transfers with _NFT_PASS passed as `data`
        return (data.length == 4 && data[0] == 0xb0 && data[3] == 0xdd)
        ? _ERC721_RECEIVED
        : bytes4(0);
    }

    // Other parameters, except `serialNum`, encoded for gas saving & UI sake
    function _encodeDepositId(
        uint256 serialNum,  // Incremental num, unique for every deposit
        uint256 termsId,    // ID of the applicable term sheet
        uint256 outTokenId, // ID of the ERC-20 token to repay deposit in
        uint256 nfTokenId,  // ID of the deposited ERC-721 token (contract)
        uint256 nftId       // ID of the deposited ERC-721 token instance
    ) internal pure returns (uint256 depositId) {
        depositId = nftId
        | (nfTokenId << 16)
        | (outTokenId << 24)
        | (termsId << 32)
        | (serialNum << 48);
    }

    function _decodeDepositId(uint256 depositId) internal pure
    returns (
        uint16 termsId,
        uint8 outTokenId,
        uint8 nfTokenId,
        uint16 nftId
    ) {
        termsId = uint16(depositId >> 32);
        outTokenId = uint8(depositId >> 24);
        nfTokenId = uint8(depositId >> 16);
        nftId = uint16(depositId);
    }

    function _withdraw(uint256 depositId, bool isInterim) internal {
        UserDeposits storage userDeposits = _deposits[msg.sender];
        Deposit memory _deposit = userDeposits.data[depositId];

        require(_deposit.amountDue != 0, "KDecks:unknown or repaid deposit");

        uint256 amountToUser;
        uint256 amountDue = 0;
        uint256 fees = 0;

        (
            uint16 termsId,
            uint8 outTokenId,
            uint8 nfTokenId,
            uint16 nftId
        ) = _decodeDepositId(depositId);

        if (isInterim) {
            TermSheet memory tS = _termSheets[termsId - 1];
            require(
                now >= uint256(_deposit.lastWithdrawTime) + tS.minInterimHours * 3600,
                "KDecks:withdrawal not yet allowed"
            );

            uint256 lockedShare;
            (amountToUser, fees, lockedShare) = _computeEarlyWithdrawal(
                _deposit,
                tS,
                now
            );
            amountDue = uint256(_deposit.amountDue).sub(amountToUser).sub(fees);
            _deposit.lockedShare = uint16(lockedShare);

            emit InterimWithdraw(msg.sender, depositId, amountToUser, fees);
        } else {
            require(now >= _deposit.maturityTime, "KDecks:deposit is locked");
            amountToUser = uint256(_deposit.amountDue);

            if (nftId != 0) {
                IERC721(_tokenAddr(nfTokenId)).safeTransferFrom(
                    address(this),
                    msg.sender,
                    nftId,
                    _NFT_PASS
                );
            }
            _deregisterDeposit(userDeposits, depositId);

            emit Withdraw(msg.sender, depositId, amountToUser);
        }

        _deposit.lastWithdrawTime = safe32(now);
        _deposit.amountDue = uint176(amountDue);
        userDeposits.data[depositId] = _deposit;

        totalDue[outTokenId] = totalDue[outTokenId]
            .sub(amountToUser)
            .sub(fees);

        IERC20(_tokenAddr(outTokenId))
            .safeTransferFrom(treasury, msg.sender, amountToUser);
    }

    function _computeEarlyWithdrawal(
        Deposit memory d,
        TermSheet memory tS,
        uint256 timeNow
    ) internal pure returns (
        uint256 amountToUser,
        uint256 fees,
        uint256 newlockedShare
    ) {
        require(d.lockedShare != 65535, "KDecks:early withdrawals banned");

        amountToUser = 0;
        fees = 0;
        newlockedShare = 0;

        if (timeNow > d.lastWithdrawTime && timeNow < d.maturityTime) {
            // values are too small for overflow; if not, safemath used
            {
                uint256 timeSincePrev = timeNow - d.lastWithdrawTime;
                uint256 timeLeftPrev = d.maturityTime - d.lastWithdrawTime;
                uint256 repayable = uint256(d.amountDue)
                    .mul(65535 - d.lockedShare)
                    / 65535;

                amountToUser = repayable.mul(timeSincePrev).div(timeLeftPrev);
                newlockedShare = uint256(65535).sub(
                    repayable.sub(amountToUser)
                    .mul(65535)
                    .div(uint256(d.amountDue).sub(amountToUser))
                );
            }
            {
                uint256 term = uint256(tS.depositHours) * 3600; // can't be 0
                uint256 timeLeft = d.maturityTime - timeNow;
                fees = amountToUser
                    .mul(uint256(tS.earlyWithdrawFees))
                    .mul(timeLeft)
                    / term // fee rate linearly drops to 0
                    / 255; // `earlyWithdrawFees` scaled down

            }
            amountToUser = amountToUser.sub(fees); // fees withheld
        }
    }

    function _amountOut(
        uint256 amount,
        uint64 rate,
        uint8 decIn,
        uint8 decOut
    ) internal pure returns(uint256 out) {
        if (decOut > decIn + 9) { // rate is scaled (multiplied) by 1e9
            out = amount.mul(rate).mul(10 ** uint256(decOut - decIn - 9));
        } else {
            out = amount.mul(rate).div(10 ** uint256(decIn + 9 - decOut));
        }
        return out;
    }

    function _addTermSheet(TermSheet memory tS) internal {
        (, TokenType _type,) = _token(tS.inTokenId);
        require(_type == TokenType.Erc20, "KDecks:INVALID_DEPOSIT_TOKEN");
        (, _type,) = _token(tS.outTokenId);
        require(_type == TokenType.Erc20, "KDecks:INVALID_REPAY_TOKEN");
        if (tS.nfTokenId != 0) {
            (, _type,) = _token(tS.nfTokenId);
            require(_type == TokenType.Erc721, "KDecks:INVALID_NFT_TOKEN");
        }
        if (tS.earlyRepayableShare == 0) {
            require(
                tS.earlyWithdrawFees == 0 && tS.minInterimHours == 0,
                "KDecks:INCONSISTENT_PARAMS"
            );
        }

        if (tS.limitId != 0) _validLimitID(tS.limitId);
        require(
             tS.depositHours != 0 && tS.rate != 0,
            "KDecks:INVALID_ZERO_PARAM"
        );

        // Risk of termsId (16 bits) overflow ignored
        _termSheets.push(tS);

        emit NewTermSheet(_termSheets.length);
        if (tS.availableQty != 0 ) emit TermsEnabled(_termSheets.length);
    }

    function _addLimit(Limit memory l) internal {
        require(l.minAmount != 0, "KDecks:INVALID_minAmount");
        _limits.push(l);
    }

    function _isAllowedNftId(
        uint256 nftId,
        uint256 allowedBitMask
    ) internal pure returns(bool) {
        if (allowedBitMask == 0) return true;
        uint256 idBitMask = nftId == 1 ? 1 : (2 << (nftId - 2));
        return (allowedBitMask & idBitMask) != 0;
    }

    function _registerDeposit(
        UserDeposits storage userDeposits,
        uint256 depositId,
        Deposit memory _deposit
    ) internal {
        userDeposits.data[depositId] = _deposit;
        userDeposits.ids.push(depositId);
    }

    function _deregisterDeposit(
        UserDeposits storage userDeposits,
        uint256 depositId
    ) internal {
        _removeArrayElement(userDeposits.ids, depositId);
    }

    // Assuming the given array does contain the given element
    function _removeArrayElement(uint256[] storage arr, uint256 el) internal {
        uint256 lastIndex = arr.length - 1;
        if (lastIndex != 0) {
            uint256 replaced = arr[lastIndex];
            if (replaced != el) {
                // Shift elements until the one being removed is replaced
                do {
                    uint256 replacing = replaced;
                    replaced = arr[lastIndex - 1];
                    lastIndex--;
                    arr[lastIndex] = replacing;
                } while (replaced != el && lastIndex != 0);
            }
        }
        // Remove the last (and quite probably the only) element
        arr.pop();
    }

    function _setTreasury(address _treasury) internal {
        _revertZeroAddress(_treasury);
        treasury = _treasury;
    }

    function _revertZeroAddress(address _address) private pure {
        require(_address != address(0), "KDecks:ZERO_ADDRESS");
    }

    function _nonZeroAddr(address _address) private pure returns (address) {
        _revertZeroAddress(_address);
        return _address;
    }

    function _validTermsID(uint256 termsId) private view returns (uint256) {
        require(
            termsId != 0 && termsId <= _termSheets.length,
            "KDecks:INVALID_TERMS_ID"
        );
        return termsId;
    }

    function _validLimitID(uint256 limitId) private view returns (uint256) {
        require(
            limitId != 0 && limitId <= _limits.length,
            "KDecks:INVALID_LIMITS_ID"
        );
        return limitId;
    }

    function safe32(uint256 n) private pure returns (uint32) {
        require(n < 2**32, "KDecks:UNSAFE_UINT32");
        return uint32(n);
    }
}

File 2 of 11 : TokenList.sol
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

contract TokenList {

    // "Listed" (hard-coded) tokens
    address private constant KingAddr = 0x5a731151d6510Eb475cc7a0072200cFfC9a3bFe5;
    address private constant KingNftAddr = 0x4c9c971fbEFc93E0900988383DC050632dEeC71E;
    address private constant QueenNftAddr = 0x3068b3313281f63536042D24562896d080844c95;
    address private constant KnightNftAddr = 0xF85C874eA05E2225982b48c93A7C7F701065D91e;
    address private constant KingWerewolfNftAddr = 0x39C8788B19b0e3CeFb3D2f38c9063b03EB1E2A5a;
    address private constant QueenVampzNftAddr = 0x440116abD7338D9ccfdc8b9b034F5D726f615f6d;
    address private constant KnightMummyNftAddr = 0x91cC2cf7B0BD7ad99C0D8FA4CdfC93C15381fb2d;
    //
    address private constant UsdtAddr = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
    address private constant UsdcAddr = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
    address private constant DaiAddr = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
    address private constant WethAddr = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
    address private constant WbtcAddr = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;
    address private constant NewKingAddr = 0xd2057d71fE3F5b0dc1E3e7722940E1908Fc72078;

    // Index of _extraTokens[0] + 1
    uint256 private constant extraTokensStartId = 33;

    enum TokenType {unknown, Erc20, Erc721, Erc1155}

    struct Token {
        address addr;
        TokenType _type;
        uint8 decimals;
    }

    // Extra tokens (addition to the hard-coded tokens list)
    Token[] private _extraTokens;

    function _listedToken(
        uint8 tokenId
    ) internal pure virtual returns(address, TokenType, uint8 decimals) {
        if (tokenId == 1) return (KingAddr, TokenType.Erc20, 18);
        if (tokenId == 2) return (UsdtAddr, TokenType.Erc20, 6);
        if (tokenId == 3) return (UsdcAddr, TokenType.Erc20, 6);
        if (tokenId == 4) return (DaiAddr, TokenType.Erc20, 18);
        if (tokenId == 5) return (WethAddr, TokenType.Erc20, 18);
        if (tokenId == 6) return (WbtcAddr, TokenType.Erc20, 8);
        if (tokenId == 7) return (NewKingAddr, TokenType.Erc20, 18);

        if (tokenId == 16) return (KingNftAddr, TokenType.Erc721, 0);
        if (tokenId == 17) return (QueenNftAddr, TokenType.Erc721, 0);
        if (tokenId == 18) return (KnightNftAddr, TokenType.Erc721, 0);
        if (tokenId == 19) return (KingWerewolfNftAddr, TokenType.Erc721, 0);
        if (tokenId == 20) return (QueenVampzNftAddr, TokenType.Erc721, 0);
        if (tokenId == 21) return (KnightMummyNftAddr, TokenType.Erc721, 0);

        return (address(0), TokenType.unknown, 0);
    }

    function _tokenAddr(uint8 tokenId) internal view returns(address) {
        (address addr,, ) = _token(tokenId);
        return addr;
    }

    function _token(
        uint8 tokenId
    ) internal view returns(address, TokenType, uint8 decimals) {
        if (tokenId < extraTokensStartId) return _listedToken(tokenId);

        uint256 i = tokenId - extraTokensStartId;
        Token memory token = _extraTokens[i];
        return (token.addr, token._type, token.decimals);
    }

    function _addTokens(
        address[] memory addresses,
        TokenType[] memory types,
        uint8[] memory decimals
    ) internal {
        require(
            addresses.length == types.length && addresses.length == decimals.length,
            "TokList:INVALID_LISTS_LENGTHS"
        );
        require(
            addresses.length + _extraTokens.length + extraTokensStartId <= 256,
            "TokList:TOO_MANY_TOKENS"
        );
        for (uint256 i = 0; i < addresses.length; i++) {
            require(addresses[i] != address(0), "TokList:INVALID_TOKEN_ADDRESS");
            require(types[i] != TokenType.unknown, "TokList:INVALID_TOKEN_TYPE");
            _extraTokens.push(Token(addresses[i], types[i], decimals[i]));
        }
    }
}

File 3 of 11 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 4 of 11 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../GSN/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
contract Ownable is Context {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

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

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = 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");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 5 of 11 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

File 6 of 11 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @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) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @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 sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

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

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts 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) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts 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) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts 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 mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 7 of 11 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

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

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

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 8 of 11 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

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

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

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

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

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

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

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

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

File 9 of 11 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

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

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

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

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

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

File 10 of 11 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 11 of 11 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @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].
 */
contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

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

    uint256 private _status;

    constructor () internal {
        _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 make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fees","type":"uint256"}],"name":"InterimWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"inTokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"outTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"termsId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountDue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maturityTime","type":"uint256"}],"name":"NewDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"termsId","type":"uint256"}],"name":"NewTermSheet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"termsId","type":"uint256"}],"name":"TermsDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"termsId","type":"uint256"}],"name":"TermsEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"components":[{"internalType":"uint224","name":"minAmount","type":"uint224"},{"internalType":"uint32","name":"maxAmountFactor","type":"uint32"}],"internalType":"struct KingDecks.Limit[]","name":"limits","type":"tuple[]"}],"name":"addLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"availableQty","type":"uint8"},{"internalType":"uint8","name":"inTokenId","type":"uint8"},{"internalType":"uint8","name":"nfTokenId","type":"uint8"},{"internalType":"uint8","name":"outTokenId","type":"uint8"},{"internalType":"uint8","name":"earlyRepayableShare","type":"uint8"},{"internalType":"uint8","name":"earlyWithdrawFees","type":"uint8"},{"internalType":"uint16","name":"limitId","type":"uint16"},{"internalType":"uint16","name":"depositHours","type":"uint16"},{"internalType":"uint16","name":"minInterimHours","type":"uint16"},{"internalType":"uint64","name":"rate","type":"uint64"},{"internalType":"uint64","name":"allowedNftNumBitMask","type":"uint64"}],"internalType":"struct KingDecks.TermSheet[]","name":"termSheets","type":"tuple[]"}],"name":"addTerms","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"enum TokenList.TokenType[]","name":"types","type":"uint8[]"},{"internalType":"uint8[]","name":"decimals","type":"uint8[]"}],"name":"addTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allTermSheets","outputs":[{"components":[{"internalType":"uint8","name":"availableQty","type":"uint8"},{"internalType":"uint8","name":"inTokenId","type":"uint8"},{"internalType":"uint8","name":"nfTokenId","type":"uint8"},{"internalType":"uint8","name":"outTokenId","type":"uint8"},{"internalType":"uint8","name":"earlyRepayableShare","type":"uint8"},{"internalType":"uint8","name":"earlyWithdrawFees","type":"uint8"},{"internalType":"uint16","name":"limitId","type":"uint16"},{"internalType":"uint16","name":"depositHours","type":"uint16"},{"internalType":"uint16","name":"minInterimHours","type":"uint16"},{"internalType":"uint64","name":"rate","type":"uint64"},{"internalType":"uint64","name":"allowedNftNumBitMask","type":"uint64"}],"internalType":"struct KingDecks.TermSheet[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"computeEarlyWithdrawal","outputs":[{"internalType":"uint256","name":"amountToUser","type":"uint256"},{"internalType":"uint256","name":"fees","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"termsId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"depositData","outputs":[{"internalType":"uint256","name":"termsId","type":"uint256"},{"components":[{"internalType":"uint176","name":"amountDue","type":"uint176"},{"internalType":"uint32","name":"maturityTime","type":"uint32"},{"internalType":"uint32","name":"lastWithdrawTime","type":"uint32"},{"internalType":"uint16","name":"lockedShare","type":"uint16"}],"internalType":"struct KingDecks.Deposit","name":"params","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"depositIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"limitId","type":"uint256"}],"name":"depositLimit","outputs":[{"components":[{"internalType":"uint224","name":"minAmount","type":"uint224"},{"internalType":"uint32","name":"maxAmountFactor","type":"uint32"}],"internalType":"struct KingDecks.Limit","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositLimitsNum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositQty","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTokenData","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"enum TokenList.TokenType","name":"","type":"uint8"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"idsToBitmask","outputs":[{"internalType":"uint256","name":"bitmask","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"interimWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"termsId","type":"uint256"},{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"name":"isAcceptableNft","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"termsId","type":"uint256"}],"name":"termSheet","outputs":[{"components":[{"internalType":"uint8","name":"availableQty","type":"uint8"},{"internalType":"uint8","name":"inTokenId","type":"uint8"},{"internalType":"uint8","name":"nfTokenId","type":"uint8"},{"internalType":"uint8","name":"outTokenId","type":"uint8"},{"internalType":"uint8","name":"earlyRepayableShare","type":"uint8"},{"internalType":"uint8","name":"earlyWithdrawFees","type":"uint8"},{"internalType":"uint16","name":"limitId","type":"uint16"},{"internalType":"uint16","name":"depositHours","type":"uint16"},{"internalType":"uint16","name":"minInterimHours","type":"uint16"},{"internalType":"uint64","name":"rate","type":"uint64"},{"internalType":"uint64","name":"allowedNftNumBitMask","type":"uint64"}],"internalType":"struct KingDecks.TermSheet","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"termSheetsNum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalDue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"transferFromContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"termsId","type":"uint256"},{"internalType":"uint256","name":"newQty","type":"uint256"}],"name":"updateAvailableQty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositId","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b506040516200409338038062004093833981016040819052620000349162000111565b600062000040620000a0565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600180556200009981620000a4565b5062000178565b3390565b620000af81620000dc565b600380546001600160a01b0390921664010000000002600160201b600160c01b0319909216919091179055565b6001600160a01b0381166200010e5760405162461bcd60e51b8152600401620001059062000141565b60405180910390fd5b50565b60006020828403121562000123578081fd5b81516001600160a01b03811681146200013a578182fd5b9392505050565b60208082526013908201527f4b4465636b733a5a45524f5f4144445245535300000000000000000000000000604082015260600190565b613f0b80620001886000396000f3fe608060405234801561001057600080fd5b50600436106101a75760003560e01c8063700a969e116100f9578063d609bcb811610097578063e5eeb32c11610071578063e5eeb32c146103bf578063ebf304d3146103d2578063f0f44260146103e5578063f2fde38b146103f8576101a7565b8063d609bcb814610377578063d632a5d91461038c578063d81ad859146103ac576101a7565b80638da5cb5b116100d35780638da5cb5b14610325578063918fd4d21461032d578063a6b7180114610340578063b09afec114610355576101a7565b8063700a969e146102f5578063715018a61461031557806373242ff01461031d576101a7565b80632b295b3911610166578063380edc4a11610140578063380edc4a1461027e5780635b9297c41461029f5780635e53043c146102bf57806361d027b3146102e0576101a7565b80632b295b39146102455780632e1a7d4d1461025857806337429cba1461026b576101a7565b806238c4d8146101ac578062aeef8a146101ca5780630ac5c36a146101df5780630d3830dd146101f25780630febeed914610205578063150b7a0214610225575b600080fd5b6101b461040b565b6040516101c19190613d9f565b60405180910390f35b6101dd6101d8366004613336565b610411565b005b6101dd6101ed366004613315565b6109e2565b6101dd6102003660046132c6565b610ad3565b6102186102133660046132c6565b610b10565b6040516101c19190613d90565b610238610233366004612e33565b610bf6565b6040516101c19190613624565b6101dd610253366004612ef7565b610c78565b6101dd6102663660046132c6565b610cbd565b6101dd610279366004612fdb565b610cf0565b61029161028c366004612ecc565b610d55565b6040516101c1929190613da8565b6102b26102ad3660046132de565b610e03565b6040516101c19190613619565b6102d26102cd366004612ecc565b610f43565b6040516101c1929190613df1565b6102e86110e8565b6040516101c191906134a7565b6103086103033660046132c6565b6110fe565b6040516101c19190613d6a565b6101dd61115c565b6101b46111db565b6102e86111e1565b6101b461033b3660046131d6565b6111f0565b61034861126e565b6040516101c19190613592565b6103686103633660046132c6565b61136a565b6040516101c193929190613548565b61037f611386565b6040516101c19190613e3e565b61039f61039a366004612e17565b611392565b6040516101c191906135e1565b6101dd6103ba366004613285565b61140c565b6101b46103cd3660046132c6565b61145e565b6101dd6103e0366004613078565b611470565b6101dd6103f3366004612e17565b6114d5565b6101dd610406366004612e17565b611516565b60055490565b6002600154141561043d5760405162461bcd60e51b815260040161043490613cc5565b60405180910390fd5b600260015561044a612bd1565b60056001610457866115cc565b038154811061046257fe5b60009182526020918290206040805161016081018252919092015460ff8082168084526101008084048316968501969096526201000083048216948401949094526301000000820481166060840152600160201b820481166080840152600160281b82041660a083015261ffff600160301b8204811660c0840152600160401b8204811660e0840152600160501b820416938201939093526001600160401b03600160601b84048116610120830152600160a01b9093049092166101408301529091506105415760405162461bcd60e51b81526004016104349061364c565b805160ff908116146105bb57805160ff60001991820116808352600580549192909190870190811061056f57fe5b6000918252602090912001805460ff191660ff9283161790558151166105bb5760405184907fc87b2d8df2c2fc232146effca27a0c5aa06a9a4677e1014f088b72d45ca01a2f90600090a25b60c081015161ffff16156106aa576105d1612c2d565b600460018360c001510361ffff16815481106105e957fe5b6000918252602091829020604080518082019091529101546001600160e01b038116808352600160e01b90910463ffffffff169282019290925291508410156106445760405162461bcd60e51b8152600401610434906139d1565b602081015163ffffffff16156106a857612710610681826020015163ffffffff1683600001516001600160e01b03166115ff90919063ffffffff16565b8161068857fe5b048411156106a85760405162461bcd60e51b815260040161043490613963565b505b6003805463ffffffff19811663ffffffff918216600101909116908117909155606082015160408301516000916106ec918491899160ff918216911688611642565b905060008060006107008660200151611661565b606089015192955092506000916107179150611661565b9250505061072c89886101200151848461171f565b92505050600160b21b81106107535760405162461bcd60e51b815260040161043490613b85565b600061077c6107778760e0015161ffff16610e10024261179590919063ffffffff16565b6117ba565b9050856040015160ff16600014156107b15786156107ac5760405162461bcd60e51b815260040161043490613a76565b610889565b62010000871080156107d657506107d6878761014001516001600160401b03166117df565b6107f25760405162461bcd60e51b815260040161043490613887565b6107ff8660400151611814565b6001600160a01b031663b88d4fde33308a63b0e68bdd60e01b6040516020016108289190613476565b6040516020818303038152906040526040518563ffffffff1660e01b815260040161085694939291906134bb565b600060405180830381600087803b15801561087057600080fd5b505af1158015610884573d6000803e3d6000fd5b505050505b6003546108ad906001600160a01b03858116913391600160201b909104168b61182a565b600060ff876080015160ff0360ff1661ffff02816108c757fe5b04905061093a60076000336001600160a01b03166001600160a01b03168152602001908152602001600020866040518060800160405280876001600160b01b031681526020018663ffffffff168152602001610922426117ba565b63ffffffff1681526020018561ffff16815250611888565b606087015160ff1660009081526006602052604090205461095b9084611795565b60066000896060015160ff16815260200190815260200160002081905550336001600160a01b0316876060015160ff16886020015160ff167fe4d59bb5fdd5c1536b016756c2f95a294d1c1c93ded8cdfa14a4effca047eb46888e8e89896040516109ca959493929190613e15565b60405180910390a45050600180555050505050505050565b6109ea61192a565b6000546001600160a01b03908116911614610a175760405162461bcd60e51b815260040161043490613b23565b60ff811115610a385760405162461bcd60e51b815260040161043490613ba8565b8060056001610a46856115cc565b0381548110610a5157fe5b6000918252602090912001805460ff191660ff9290921691909117905580610aa35760405182907fc87b2d8df2c2fc232146effca27a0c5aa06a9a4677e1014f088b72d45ca01a2f90600090a2610acf565b60405182907f0e7a48c601b1a627275b6d51f24200a652a0018fafe123b6d2d7c0bfbe54f12490600090a25b5050565b60026001541415610af65760405162461bcd60e51b815260040161043490613cc5565b6002600181905550610b0981600161192e565b5060018055565b610b18612bd1565b60056001610b25846115cc565b0381548110610b3057fe5b60009182526020918290206040805161016081018252919092015460ff80821683526101008083048216958401959095526201000082048116938301939093526301000000810483166060830152600160201b810483166080830152600160281b810490921660a082015261ffff600160301b8304811660c0830152600160401b8304811660e0830152600160501b830416928101929092526001600160401b03600160601b82048116610120840152600160a01b909104166101408201529050919050565b6000600482148015610c2b575082826000818110610c1057fe5b9050013560f81c60f81b6001600160f81b03191660b060f81b145b8015610c5a575082826003818110610c3f57fe5b9050013560f81c60f81b6001600160f81b03191660dd60f81b145b610c65576000610c6e565b630a85bd0160e11b5b9695505050505050565b610c8061192a565b6000546001600160a01b03908116911614610cad5760405162461bcd60e51b815260040161043490613b23565b610cb8838383611e1f565b505050565b60026001541415610ce05760405162461bcd60e51b815260040161043490613cc5565b6002600155610b0981600061192e565b610cf861192a565b6000546001600160a01b03908116911614610d255760405162461bcd60e51b815260040161043490613b23565b60005b8151811015610acf57610d4d828281518110610d4057fe5b6020026020010151611ffc565b600101610d28565b6000610d5f612c44565b60076000610d6c86612093565b6001600160a01b03168152602080820192909252604090810160009081208682526001018352818120825160808101845290546001600160b01b0381168252600160b01b810463ffffffff908116958301869052600160d01b82041693820193909352600160f01b90920461ffff1660608301529350915015610dfc57610df28361209e565b50505061ffff1691505b9250929050565b6000610e0d612bd1565b60056001610e1a876115cc565b0381548110610e2557fe5b60009182526020918290206040805161016081018252919092015460ff808216835261010080830482169584019590955262010000820481169383018490526301000000820481166060840152600160201b820481166080840152600160281b82041660a083015261ffff600160301b8204811660c0840152600160401b8204811660e0840152600160501b820416938201939093526001600160401b03600160601b84048116610120830152600160a01b90930490921661014083015290915015801590610f115750836001600160a01b0316610f068260400151611814565b6001600160a01b0316145b15610f3657610f2e838261014001516001600160401b03166117df565b915050610f3c565b60009150505b9392505050565b600080610f4e612c44565b506001600160a01b0384166000908152600760209081526040808320868452600101825291829020825160808101845290546001600160b01b038116808352600160b01b820463ffffffff90811694840194909452600160d01b820490931693820193909352600160f01b90920461ffff166060830152610fe15760405162461bcd60e51b815260040161043490613776565b6000610fec8561209e565b50505061ffff169050610ffd612bd1565b6005600183038154811061100d57fe5b60009182526020918290206040805161016081018252919092015460ff80821683526101008083048216958401959095526201000082048116938301939093526301000000810483166060830152600160201b810483166080830152600160281b810490921660a082015261ffff600160301b8304811660c0830152600160401b8304811660e0830152600160501b830416928101929092526001600160401b03600160601b82048116610120840152600160a01b9091041661014082015290506110d98382426120b2565b50909890975095505050505050565b600354600160201b90046001600160a01b031681565b611106612c2d565b600460016111138461221d565b038154811061111e57fe5b6000918252602091829020604080518082019091529101546001600160e01b0381168252600160e01b900463ffffffff169181019190915292915050565b61116461192a565b6000546001600160a01b039081169116146111915760405162461bcd60e51b815260040161043490613b23565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60045490565b6000546001600160a01b031690565b6000805b825181101561126857600083828151811061120b57fe5b6020026020010151905080600014158015611227575060408111155b6112435760405162461bcd60e51b8152600401610434906136f9565b8060011461125857600260011982011b61125b565b60015b90921791506001016111f4565b50919050565b60606005805480602002602001604051908101604052809291908181526020016000905b8282101561136157600084815260209081902060408051610160810182529185015460ff80821684526101008083048216858701526201000083048216938501939093526301000000820481166060850152600160201b820481166080850152600160281b82041660a084015261ffff600160301b8204811660c0850152600160401b8204811660e0850152600160501b820416918301919091526001600160401b03600160601b82048116610120840152600160a01b90910416610140820152825260019092019101611292565b50505050905090565b600080600061137884611661565b9250925092505b9193909250565b60035463ffffffff1681565b606061139d8261224c565b6001600160a01b03821660009081526007602090815260409182902080548351818402810184019094528084529092918391908301828280156113ff57602002820191906000526020600020905b8154815260200190600101908083116113eb575b5050505050915050919050565b61141461192a565b6000546001600160a01b039081169116146114415760405162461bcd60e51b815260040161043490613b23565b61144a8161224c565b610cb86001600160a01b0384168284612272565b60066020526000908152604090205481565b61147861192a565b6000546001600160a01b039081169116146114a55760405162461bcd60e51b815260040161043490613b23565b60005b8151811015610acf576114cd8282815181106114c057fe5b6020026020010151612291565b6001016114a8565b6114dd61192a565b6000546001600160a01b0390811691161461150a5760405162461bcd60e51b815260040161043490613b23565b6115138161261e565b50565b61151e61192a565b6000546001600160a01b0390811691161461154b5760405162461bcd60e51b815260040161043490613b23565b6001600160a01b0381166115715760405162461bcd60e51b815260040161043490613730565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600081158015906115df57506005548211155b6115fb5760405162461bcd60e51b815260040161043490613c16565b5090565b60008261160e5750600061163c565b8282028284828161161b57fe5b04146116395760405162461bcd60e51b815260040161043490613ae2565b90505b92915050565b60109190911b1760189190911b1760209190911b1760309190911b1790565b600080600060218460ff1610156116865761167b84612654565b92509250925061137f565b60201960ff851601611696612c6b565b600282815481106116a357fe5b60009182526020918290206040805160608101909152910180546001600160a01b03811683529192909190830190600160a01b900460ff1660038111156116e657fe5b60038111156116f157fe5b81529054600160a81b900460ff16602091820152815190820151604090920151909891975095509350505050565b60008260090160ff168260ff1611156117625761175b60ff6008198585030116600a0a611755876001600160401b0388166115ff565b906115ff565b905061178d565b61178a60ff83850360090116600a0a611784876001600160401b0388166115ff565b906128ca565b90505b949350505050565b6000828201838110156116395760405162461bcd60e51b8152600401610434906137e2565b6000600160201b82106115fb5760405162461bcd60e51b815260040161043490613c97565b6000816117ee5750600161163c565b60008360011461180557600260011985011b611808565b60015b90921615159392505050565b60008061182083611661565b5090949350505050565b611882846323b872dd60e01b85858560405160240161184b93929190613524565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261290c565b50505050565b60008281526001848101602090815260408084208551815487850151938801516060909801516001600160b01b03199091166001600160b01b039092169190911763ffffffff60b01b1916600160b01b63ffffffff948516021763ffffffff60d01b1916600160d01b9390971692909202959095176001600160f01b0316600160f01b61ffff9092169190910217909355845490810185559381522090910155565b3390565b336000908152600760205260409020611945612c44565b506000838152600182016020908152604091829020825160808101845290546001600160b01b038116808352600160b01b820463ffffffff90811694840194909452600160d01b820490931693820193909352600160f01b90920461ffff1660608301526119c55760405162461bcd60e51b815260040161043490613776565b60008080808080806119d68b61209e565b93509350935093508915611b88576119ec612bd1565b60056001860361ffff1681548110611a0057fe5b60009182526020918290206040805161016081018252919092015460ff80821683526101008083048216958401959095526201000082048116838501526301000000820481166060840152600160201b820481166080840152600160281b82041660a083015261ffff600160301b8204811660c0840152600160401b8204811660e0840152600160501b820481169483018590526001600160401b03600160601b83048116610120850152600160a01b909204909116610140830152918c015190935063ffffffff16610e109092021601421015611af05760405162461bcd60e51b815260040161043490613681565b6000611afd8a83426120b2565b8c51929b509098509150611b26908890611b20906001600160b01b03168c61299b565b9061299b565b9750808a6060019061ffff16908161ffff1681525050336001600160a01b03167feca4e94347e342f159876b86afa249ebf5d21bf1cb9246d53181f7a14bc3d0128e8b8a604051611b7993929190613dff565b60405180910390a25050611caa565b876020015163ffffffff16421015611bb25760405162461bcd60e51b8152600401610434906136c2565b87516001600160b01b0316965061ffff811615611c5c57611bd282611814565b6001600160a01b031663b88d4fde30338463b0e68bdd60e01b604051602001611bfb9190613476565b6040516020818303038152906040526040518563ffffffff1660e01b8152600401611c2994939291906134ee565b600060405180830381600087803b158015611c4357600080fd5b505af1158015611c57573d6000803e3d6000fd5b505050505b611c66898c6129dd565b336001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5688c89604051611ca1929190613df1565b60405180910390a25b611cb3426117ba565b886040019063ffffffff16908163ffffffff16815250508588600001906001600160b01b031690816001600160b01b031681525050878960010160008d815260200190815260200160002060008201518160000160006101000a8154816001600160b01b0302191690836001600160b01b0316021790555060208201518160000160166101000a81548163ffffffff021916908363ffffffff160217905550604082015181600001601a6101000a81548163ffffffff021916908363ffffffff160217905550606082015181600001601e6101000a81548161ffff021916908361ffff160217905550905050611dcc85611b2089600660008860ff1681526020019081526020016000205461299b90919063ffffffff16565b60ff8416600090815260066020526040902055600354611e1290600160201b90046001600160a01b03163389611e0187611814565b6001600160a01b031692919061182a565b5050505050505050505050565b81518351148015611e31575080518351145b611e4d5760405162461bcd60e51b815260040161043490613d33565b600254835161010091016021011115611e785760405162461bcd60e51b815260040161043490613a08565b60005b83518110156118825760006001600160a01b0316848281518110611e9b57fe5b60200260200101516001600160a01b03161415611eca5760405162461bcd60e51b81526004016104349061399a565b6000838281518110611ed857fe5b60200260200101516003811115611eeb57fe5b1415611f095760405162461bcd60e51b8152600401610434906138f5565b60026040518060600160405280868481518110611f2257fe5b60200260200101516001600160a01b03168152602001858481518110611f4457fe5b60200260200101516003811115611f5757fe5b8152602001848481518110611f6857fe5b60209081029190910181015160ff1690915282546001810184556000938452928190208251930180546001600160a01b0319166001600160a01b03909416939093178084559082015191929190829060ff60a01b1916600160a01b836003811115611fcf57fe5b021790555060409190910151815460ff909116600160a81b0260ff60a81b19909116179055600101611e7b565b80516001600160e01b03166120235760405162461bcd60e51b815260040161043490613a3f565b6004805460018101825560009190915281517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b909101805460209093015163ffffffff16600160e01b026001600160e01b039283166001600160e01b031990941693909317909116919091179055565b60006115fb8261224c565b602081901c91601882901c91601081901c91565b6000806000856060015161ffff1661ffff14156120e15760405162461bcd60e51b8152600401610434906137ab565b600092506000915060009050856040015163ffffffff168411801561210f5750856020015163ffffffff1684105b1561221457604086015160208701516060880151885163ffffffff80851689039490930383169260009261ffff92612158926001600160b01b039091169184038416906115ff16565b8161215f57fe5b0490506121708261178483866115ff565b89519096506121a9906121a090612190906001600160b01b03168961299b565b61178461ffff611755868c61299b565b61ffff9061299b565b935050505060008560e0015161ffff16610e10029050600085886020015163ffffffff1603905060ff826121f1836117558b60a0015160ff168a6115ff90919063ffffffff16565b816121f857fe5b048161220057fe5b04935061221191508490508361299b565b92505b93509350939050565b6000811580159061223057506004548211155b6115fb5760405162461bcd60e51b815260040161043490613819565b6001600160a01b0381166115135760405162461bcd60e51b815260040161043490613b58565b610cb88363a9059cbb60e01b848460405160240161184b929190613579565b60006122a08260200151611661565b509150600190508160038111156122b357fe5b146122d05760405162461bcd60e51b81526004016104349061392c565b6122dd8260600151611661565b509150600190508160038111156122f057fe5b1461230d5760405162461bcd60e51b8152600401610434906138be565b604082015160ff1615612357576123278260400151611661565b5091506002905081600381111561233a57fe5b146123575760405162461bcd60e51b815260040161043490613cfc565b608082015160ff1661239b5760a082015160ff1615801561237f575061010082015161ffff16155b61239b5760405162461bcd60e51b815260040161043490613850565b60c082015161ffff16156123bc576123ba8260c0015161ffff1661221d565b505b60e082015161ffff16158015906123e057506101208201516001600160401b031615155b6123fc5760405162461bcd60e51b815260040161043490613aab565b6005829080600181540180825580915050600190039060005260206000200160009091909190915060008201518160000160006101000a81548160ff021916908360ff16021790555060208201518160000160016101000a81548160ff021916908360ff16021790555060408201518160000160026101000a81548160ff021916908360ff16021790555060608201518160000160036101000a81548160ff021916908360ff16021790555060808201518160000160046101000a81548160ff021916908360ff16021790555060a08201518160000160056101000a81548160ff021916908360ff16021790555060c08201518160000160066101000a81548161ffff021916908361ffff16021790555060e08201518160000160086101000a81548161ffff021916908361ffff16021790555061010082015181600001600a6101000a81548161ffff021916908361ffff16021790555061012082015181600001600c6101000a8154816001600160401b0302191690836001600160401b031602179055506101408201518160000160146101000a8154816001600160401b0302191690836001600160401b0316021790555050506005805490507fe3b342825606ced2ad4891a1a90a7d334e74562c04a795f84000cb106c38922760405160405180910390a2815160ff1615610acf576005546040517f0e7a48c601b1a627275b6d51f24200a652a0018fafe123b6d2d7c0bfbe54f12490600090a25050565b6126278161224c565b600380546001600160a01b03909216600160201b02640100000000600160c01b0319909216919091179055565b60008060008360ff16600114156126885750735a731151d6510eb475cc7a0072200cffc9a3bfe5915060019050601261137f565b8360ff16600214156126b7575073dac17f958d2ee523a2206206994597c13d831ec7915060019050600661137f565b8360ff16600314156126e6575073a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48915060019050600661137f565b8360ff16600414156127155750736b175474e89094c44da98b954eedeac495271d0f915060019050601261137f565b8360ff1660051415612744575073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2915060019050601261137f565b8360ff16600614156127735750732260fac5e5542a773aa44fbcfedf7c193bc2c599915060019050600861137f565b8360ff16600714156127a2575073d2057d71fe3f5b0dc1e3e7722940e1908fc72078915060019050601261137f565b8360ff16601014156127d15750734c9c971fbefc93e0900988383dc050632deec71e915060029050600061137f565b8360ff16601114156128005750733068b3313281f63536042d24562896d080844c95915060029050600061137f565b8360ff166012141561282f575073f85c874ea05e2225982b48c93a7c7f701065d91e915060029050600061137f565b8360ff166013141561285e57507339c8788b19b0e3cefb3d2f38c9063b03eb1e2a5a915060029050600061137f565b8360ff166014141561288d575073440116abd7338d9ccfdc8b9b034f5d726f615f6d915060029050600061137f565b8360ff16601514156128bc57507391cc2cf7b0bd7ad99c0d8fa4cdfc93c15381fb2d915060029050600061137f565b506000938493508392509050565b600061163983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506129e7565b6060612961826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a1e9092919063ffffffff16565b805190915015610cb8578080602001905181019061297f9190613265565b610cb85760405162461bcd60e51b815260040161043490613c4d565b600061163983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612a2d565b610acf8282612a59565b60008183612a085760405162461bcd60e51b81526004016104349190613639565b506000838581612a1457fe5b0495945050505050565b606061178d8484600085612b07565b60008184841115612a515760405162461bcd60e51b81526004016104349190613639565b505050900390565b8154600019018015612ae2576000838281548110612a7357fe5b90600052602060002001549050828114612ae0575b6000819050846001840381548110612a9c57fe5b9060005260206000200154915082806001900393505080858481548110612abf57fe5b60009182526020909120015550808314801590612adb57508115155b612a88575b505b82805480612aec57fe5b60019003818190600052602060002001600090559055505050565b6060612b1285612bcb565b612b2e5760405162461bcd60e51b815260040161043490613bdf565b60006060866001600160a01b03168587604051612b4b919061348b565b60006040518083038185875af1925050503d8060008114612b88576040519150601f19603f3d011682016040523d82523d6000602084013e612b8d565b606091505b50915091508115612ba157915061178d9050565b805115612bb15780518082602001fd5b8360405162461bcd60e51b81526004016104349190613639565b3b151590565b6040805161016081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081018290526101008101829052610120810182905261014081019190915290565b604080518082019091526000808252602082015290565b60408051608081018252600080825260208201819052918101829052606081019190915290565b6040805160608101909152600080825260208201908152600060209091015290565b803561163c81613ec0565b600082601f830112612ca8578081fd5b8135612cbb612cb682613e75565b613e4f565b818152915060208083019084810181840286018201871015612cdc57600080fd5b6000805b85811015612d0857823560048110612cf6578283fd5b85529383019391830191600101612ce0565b50505050505092915050565b600082601f830112612d24578081fd5b8135612d32612cb682613e75565b818152915060208083019084810181840286018201871015612d5357600080fd5b60005b84811015612d7a57612d688883612e06565b84529282019290820190600101612d56565b505050505092915050565b600060408284031215612d96578081fd5b612da06040613e4f565b905081356001600160e01b0381168114612db957600080fd5b8152602082013563ffffffff81168114612dd257600080fd5b602082015292915050565b803561ffff8116811461163c57600080fd5b80356001600160401b038116811461163c57600080fd5b803560ff8116811461163c57600080fd5b600060208284031215612e28578081fd5b813561163981613ec0565b600080600080600060808688031215612e4a578081fd5b8535612e5581613ec0565b94506020860135612e6581613ec0565b93506040860135925060608601356001600160401b0380821115612e87578283fd5b818801915088601f830112612e9a578283fd5b813581811115612ea8578384fd5b896020828501011115612eb9578384fd5b9699959850939650602001949392505050565b60008060408385031215612ede578182fd5b8235612ee981613ec0565b946020939093013593505050565b600080600060608486031215612f0b578081fd5b83356001600160401b0380821115612f21578283fd5b818601915086601f830112612f34578283fd5b8135612f42612cb682613e75565b80828252602080830192508086018b828387028901011115612f62578788fd5b8796505b84871015612f8c57612f788c82612c8d565b845260019690960195928101928101612f66565b509097508801359350505080821115612fa3578283fd5b612faf87838801612c98565b93506040860135915080821115612fc4578283fd5b50612fd186828701612d14565b9150509250925092565b60006020808385031215612fed578182fd5b82356001600160401b03811115613002578283fd5b8301601f81018513613012578283fd5b8035613020612cb682613e75565b818152838101908385016040808502860187018a101561303e578788fd5b8795505b8486101561306a576130548a83612d85565b8452600195909501949286019290810190613042565b509098975050505050505050565b6000602080838503121561308a578182fd5b82356001600160401b0381111561309f578283fd5b8301601f810185136130af578283fd5b80356130bd612cb682613e75565b81815283810190838501610160808502860187018a10156130dc578788fd5b8795505b8486101561306a5780828b0312156130f6578788fd5b6130ff81613e4f565b6131098b84612e06565b81526131178b898501612e06565b8882015260406131298c828601612e06565b90820152606061313b8c858301612e06565b90820152608061314d8c858301612e06565b9082015260a061315f8c858301612e06565b9082015260c06131718c858301612ddd565b9082015260e06131838c858301612ddd565b908201526101006131968c858301612ddd565b908201526101206131a98c858301612def565b908201526101406131bc8c858301612def565b9082015284526001959095019492860192908101906130e0565b600060208083850312156131e8578182fd5b82356001600160401b038111156131fd578283fd5b8301601f8101851361320d578283fd5b803561321b612cb682613e75565b8181528381019083850185840285018601891015613237578687fd5b8694505b8385101561325957803583526001949094019391850191850161323b565b50979650505050505050565b600060208284031215613276578081fd5b81518015158114611639578182fd5b600080600060608486031215613299578081fd5b83356132a481613ec0565b92506020840135915060408401356132bb81613ec0565b809150509250925092565b6000602082840312156132d7578081fd5b5035919050565b6000806000606084860312156132f2578081fd5b83359250602084013561330481613ec0565b929592945050506040919091013590565b60008060408385031215613327578182fd5b50508035926020909101359150565b60008060006060848603121561334a578081fd5b505081359360208301359350604090920135919050565b60008151808452613379816020860160208601613e94565b601f01601f19169290920160200192915050565b61339882825161346f565b60208101516133aa602084018261346f565b5060408101516133bd604084018261346f565b5060608101516133d0606084018261346f565b5060808101516133e3608084018261346f565b5060a08101516133f660a084018261346f565b5060c081015161340960c084018261345a565b5060e081015161341c60e084018261345a565b50610100808201516134308285018261345a565b50506101208082015161344582850182613462565b50506101408082015161188282850182613462565b61ffff169052565b6001600160401b03169052565b60ff169052565b6001600160e01b031991909116815260040190565b6000825161349d818460208701613e94565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090610c6e90830184613361565b6001600160a01b0385811682528416602082015261ffff83166040820152608060608201819052600090610c6e90830184613361565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0384168152606081016004841061356257fe5b83602083015260ff83166040830152949350505050565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156135d5576135c183855161338d565b9284019261016092909201916001016135ae565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156135d5578351835292840192918401916001016135fd565b901515815260200190565b6001600160e01b031991909116815260200190565b6000602082526116396020830184613361565b6020808252818101527f4b4465636b733a7465726d732064697361626c6564206f7220756e6b6e6f776e604082015260600190565b60208082526021908201527f4b4465636b733a7769746864726177616c206e6f742079657420616c6c6f77656040820152601960fa1b606082015260800190565b60208082526018908201527f4b4465636b733a6465706f736974206973206c6f636b65640000000000000000604082015260600190565b60208082526019908201527f4b4465636b733a756e737570706f72746564204e465420494400000000000000604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252818101527f4b4465636b733a756e6b6e6f776e206f7220726570616964206465706f736974604082015260600190565b6020808252601f908201527f4b4465636b733a6561726c79207769746864726177616c732062616e6e656400604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526018908201527f4b4465636b733a494e56414c49445f4c494d4954535f49440000000000000000604082015260600190565b6020808252601a908201527f4b4465636b733a494e434f4e53495354454e545f504152414d53000000000000604082015260600190565b6020808252601e908201527f4b4465636b733a646973616c6c6f776564204e465420696e7374616e63650000604082015260600190565b6020808252601a908201527f4b4465636b733a494e56414c49445f52455041595f544f4b454e000000000000604082015260600190565b6020808252601a908201527f546f6b4c6973743a494e56414c49445f544f4b454e5f54595045000000000000604082015260600190565b6020808252601c908201527f4b4465636b733a494e56414c49445f4445504f5349545f544f4b454e00000000604082015260600190565b6020808252601d908201527f4b4465636b733a746f6f20626967206465706f73697420616d6f756e74000000604082015260600190565b6020808252601d908201527f546f6b4c6973743a494e56414c49445f544f4b454e5f41444452455353000000604082015260600190565b6020808252601f908201527f4b4465636b733a746f6f20736d616c6c206465706f73697420616d6f756e7400604082015260600190565b60208082526017908201527f546f6b4c6973743a544f4f5f4d414e595f544f4b454e53000000000000000000604082015260600190565b60208082526018908201527f4b4465636b733a494e56414c49445f6d696e416d6f756e740000000000000000604082015260600190565b6020808252818101527f4b4465636b733a756e6578706563746564206e6f6e2d7a65726f206e66744964604082015260600190565b60208082526019908201527f4b4465636b733a494e56414c49445f5a45524f5f504152414d00000000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601390820152724b4465636b733a5a45524f5f4144445245535360681b604082015260600190565b60208082526009908201526825a232b1b5b99d279960b91b604082015260600190565b6020808252601b908201527f4b4465636b733a494e56414c49445f617661696c61626c655174790000000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526017908201527f4b4465636b733a494e56414c49445f5445524d535f4944000000000000000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526014908201527325a232b1b5b99d2aa729a0a322afaaa4a72a199960611b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526018908201527f4b4465636b733a494e56414c49445f4e46545f544f4b454e0000000000000000604082015260600190565b6020808252601d908201527f546f6b4c6973743a494e56414c49445f4c495354535f4c454e47544853000000604082015260600190565b81516001600160e01b0316815260209182015163ffffffff169181019190915260400190565b610160810161163c828461338d565b90815260200190565b91825280516001600160b01b031660208084019190915281015163ffffffff90811660408085019190915282015116606080840191909152015161ffff16608082015260a00190565b918252602082015260400190565b9283526020830191909152604082015260600190565b94855260208501939093526040840191909152606083015263ffffffff16608082015260a00190565b63ffffffff91909116815260200190565b6040518181016001600160401b0381118282101715613e6d57600080fd5b604052919050565b60006001600160401b03821115613e8a578081fd5b5060209081020190565b60005b83811015613eaf578181015183820152602001613e97565b838111156118825750506000910152565b6001600160a01b038116811461151357600080fdfea26469706673582212200e36b560ff5ec5ba9bf56f05d39d278a1686dfbf49f803a78fb157474d4f65b864736f6c634300060c0033000000000000000000000000d31e459ac72e2ccad9a35b5b3367cfb4bab0274f

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101a75760003560e01c8063700a969e116100f9578063d609bcb811610097578063e5eeb32c11610071578063e5eeb32c146103bf578063ebf304d3146103d2578063f0f44260146103e5578063f2fde38b146103f8576101a7565b8063d609bcb814610377578063d632a5d91461038c578063d81ad859146103ac576101a7565b80638da5cb5b116100d35780638da5cb5b14610325578063918fd4d21461032d578063a6b7180114610340578063b09afec114610355576101a7565b8063700a969e146102f5578063715018a61461031557806373242ff01461031d576101a7565b80632b295b3911610166578063380edc4a11610140578063380edc4a1461027e5780635b9297c41461029f5780635e53043c146102bf57806361d027b3146102e0576101a7565b80632b295b39146102455780632e1a7d4d1461025857806337429cba1461026b576101a7565b806238c4d8146101ac578062aeef8a146101ca5780630ac5c36a146101df5780630d3830dd146101f25780630febeed914610205578063150b7a0214610225575b600080fd5b6101b461040b565b6040516101c19190613d9f565b60405180910390f35b6101dd6101d8366004613336565b610411565b005b6101dd6101ed366004613315565b6109e2565b6101dd6102003660046132c6565b610ad3565b6102186102133660046132c6565b610b10565b6040516101c19190613d90565b610238610233366004612e33565b610bf6565b6040516101c19190613624565b6101dd610253366004612ef7565b610c78565b6101dd6102663660046132c6565b610cbd565b6101dd610279366004612fdb565b610cf0565b61029161028c366004612ecc565b610d55565b6040516101c1929190613da8565b6102b26102ad3660046132de565b610e03565b6040516101c19190613619565b6102d26102cd366004612ecc565b610f43565b6040516101c1929190613df1565b6102e86110e8565b6040516101c191906134a7565b6103086103033660046132c6565b6110fe565b6040516101c19190613d6a565b6101dd61115c565b6101b46111db565b6102e86111e1565b6101b461033b3660046131d6565b6111f0565b61034861126e565b6040516101c19190613592565b6103686103633660046132c6565b61136a565b6040516101c193929190613548565b61037f611386565b6040516101c19190613e3e565b61039f61039a366004612e17565b611392565b6040516101c191906135e1565b6101dd6103ba366004613285565b61140c565b6101b46103cd3660046132c6565b61145e565b6101dd6103e0366004613078565b611470565b6101dd6103f3366004612e17565b6114d5565b6101dd610406366004612e17565b611516565b60055490565b6002600154141561043d5760405162461bcd60e51b815260040161043490613cc5565b60405180910390fd5b600260015561044a612bd1565b60056001610457866115cc565b038154811061046257fe5b60009182526020918290206040805161016081018252919092015460ff8082168084526101008084048316968501969096526201000083048216948401949094526301000000820481166060840152600160201b820481166080840152600160281b82041660a083015261ffff600160301b8204811660c0840152600160401b8204811660e0840152600160501b820416938201939093526001600160401b03600160601b84048116610120830152600160a01b9093049092166101408301529091506105415760405162461bcd60e51b81526004016104349061364c565b805160ff908116146105bb57805160ff60001991820116808352600580549192909190870190811061056f57fe5b6000918252602090912001805460ff191660ff9283161790558151166105bb5760405184907fc87b2d8df2c2fc232146effca27a0c5aa06a9a4677e1014f088b72d45ca01a2f90600090a25b60c081015161ffff16156106aa576105d1612c2d565b600460018360c001510361ffff16815481106105e957fe5b6000918252602091829020604080518082019091529101546001600160e01b038116808352600160e01b90910463ffffffff169282019290925291508410156106445760405162461bcd60e51b8152600401610434906139d1565b602081015163ffffffff16156106a857612710610681826020015163ffffffff1683600001516001600160e01b03166115ff90919063ffffffff16565b8161068857fe5b048411156106a85760405162461bcd60e51b815260040161043490613963565b505b6003805463ffffffff19811663ffffffff918216600101909116908117909155606082015160408301516000916106ec918491899160ff918216911688611642565b905060008060006107008660200151611661565b606089015192955092506000916107179150611661565b9250505061072c89886101200151848461171f565b92505050600160b21b81106107535760405162461bcd60e51b815260040161043490613b85565b600061077c6107778760e0015161ffff16610e10024261179590919063ffffffff16565b6117ba565b9050856040015160ff16600014156107b15786156107ac5760405162461bcd60e51b815260040161043490613a76565b610889565b62010000871080156107d657506107d6878761014001516001600160401b03166117df565b6107f25760405162461bcd60e51b815260040161043490613887565b6107ff8660400151611814565b6001600160a01b031663b88d4fde33308a63b0e68bdd60e01b6040516020016108289190613476565b6040516020818303038152906040526040518563ffffffff1660e01b815260040161085694939291906134bb565b600060405180830381600087803b15801561087057600080fd5b505af1158015610884573d6000803e3d6000fd5b505050505b6003546108ad906001600160a01b03858116913391600160201b909104168b61182a565b600060ff876080015160ff0360ff1661ffff02816108c757fe5b04905061093a60076000336001600160a01b03166001600160a01b03168152602001908152602001600020866040518060800160405280876001600160b01b031681526020018663ffffffff168152602001610922426117ba565b63ffffffff1681526020018561ffff16815250611888565b606087015160ff1660009081526006602052604090205461095b9084611795565b60066000896060015160ff16815260200190815260200160002081905550336001600160a01b0316876060015160ff16886020015160ff167fe4d59bb5fdd5c1536b016756c2f95a294d1c1c93ded8cdfa14a4effca047eb46888e8e89896040516109ca959493929190613e15565b60405180910390a45050600180555050505050505050565b6109ea61192a565b6000546001600160a01b03908116911614610a175760405162461bcd60e51b815260040161043490613b23565b60ff811115610a385760405162461bcd60e51b815260040161043490613ba8565b8060056001610a46856115cc565b0381548110610a5157fe5b6000918252602090912001805460ff191660ff9290921691909117905580610aa35760405182907fc87b2d8df2c2fc232146effca27a0c5aa06a9a4677e1014f088b72d45ca01a2f90600090a2610acf565b60405182907f0e7a48c601b1a627275b6d51f24200a652a0018fafe123b6d2d7c0bfbe54f12490600090a25b5050565b60026001541415610af65760405162461bcd60e51b815260040161043490613cc5565b6002600181905550610b0981600161192e565b5060018055565b610b18612bd1565b60056001610b25846115cc565b0381548110610b3057fe5b60009182526020918290206040805161016081018252919092015460ff80821683526101008083048216958401959095526201000082048116938301939093526301000000810483166060830152600160201b810483166080830152600160281b810490921660a082015261ffff600160301b8304811660c0830152600160401b8304811660e0830152600160501b830416928101929092526001600160401b03600160601b82048116610120840152600160a01b909104166101408201529050919050565b6000600482148015610c2b575082826000818110610c1057fe5b9050013560f81c60f81b6001600160f81b03191660b060f81b145b8015610c5a575082826003818110610c3f57fe5b9050013560f81c60f81b6001600160f81b03191660dd60f81b145b610c65576000610c6e565b630a85bd0160e11b5b9695505050505050565b610c8061192a565b6000546001600160a01b03908116911614610cad5760405162461bcd60e51b815260040161043490613b23565b610cb8838383611e1f565b505050565b60026001541415610ce05760405162461bcd60e51b815260040161043490613cc5565b6002600155610b0981600061192e565b610cf861192a565b6000546001600160a01b03908116911614610d255760405162461bcd60e51b815260040161043490613b23565b60005b8151811015610acf57610d4d828281518110610d4057fe5b6020026020010151611ffc565b600101610d28565b6000610d5f612c44565b60076000610d6c86612093565b6001600160a01b03168152602080820192909252604090810160009081208682526001018352818120825160808101845290546001600160b01b0381168252600160b01b810463ffffffff908116958301869052600160d01b82041693820193909352600160f01b90920461ffff1660608301529350915015610dfc57610df28361209e565b50505061ffff1691505b9250929050565b6000610e0d612bd1565b60056001610e1a876115cc565b0381548110610e2557fe5b60009182526020918290206040805161016081018252919092015460ff808216835261010080830482169584019590955262010000820481169383018490526301000000820481166060840152600160201b820481166080840152600160281b82041660a083015261ffff600160301b8204811660c0840152600160401b8204811660e0840152600160501b820416938201939093526001600160401b03600160601b84048116610120830152600160a01b90930490921661014083015290915015801590610f115750836001600160a01b0316610f068260400151611814565b6001600160a01b0316145b15610f3657610f2e838261014001516001600160401b03166117df565b915050610f3c565b60009150505b9392505050565b600080610f4e612c44565b506001600160a01b0384166000908152600760209081526040808320868452600101825291829020825160808101845290546001600160b01b038116808352600160b01b820463ffffffff90811694840194909452600160d01b820490931693820193909352600160f01b90920461ffff166060830152610fe15760405162461bcd60e51b815260040161043490613776565b6000610fec8561209e565b50505061ffff169050610ffd612bd1565b6005600183038154811061100d57fe5b60009182526020918290206040805161016081018252919092015460ff80821683526101008083048216958401959095526201000082048116938301939093526301000000810483166060830152600160201b810483166080830152600160281b810490921660a082015261ffff600160301b8304811660c0830152600160401b8304811660e0830152600160501b830416928101929092526001600160401b03600160601b82048116610120840152600160a01b9091041661014082015290506110d98382426120b2565b50909890975095505050505050565b600354600160201b90046001600160a01b031681565b611106612c2d565b600460016111138461221d565b038154811061111e57fe5b6000918252602091829020604080518082019091529101546001600160e01b0381168252600160e01b900463ffffffff169181019190915292915050565b61116461192a565b6000546001600160a01b039081169116146111915760405162461bcd60e51b815260040161043490613b23565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60045490565b6000546001600160a01b031690565b6000805b825181101561126857600083828151811061120b57fe5b6020026020010151905080600014158015611227575060408111155b6112435760405162461bcd60e51b8152600401610434906136f9565b8060011461125857600260011982011b61125b565b60015b90921791506001016111f4565b50919050565b60606005805480602002602001604051908101604052809291908181526020016000905b8282101561136157600084815260209081902060408051610160810182529185015460ff80821684526101008083048216858701526201000083048216938501939093526301000000820481166060850152600160201b820481166080850152600160281b82041660a084015261ffff600160301b8204811660c0850152600160401b8204811660e0850152600160501b820416918301919091526001600160401b03600160601b82048116610120840152600160a01b90910416610140820152825260019092019101611292565b50505050905090565b600080600061137884611661565b9250925092505b9193909250565b60035463ffffffff1681565b606061139d8261224c565b6001600160a01b03821660009081526007602090815260409182902080548351818402810184019094528084529092918391908301828280156113ff57602002820191906000526020600020905b8154815260200190600101908083116113eb575b5050505050915050919050565b61141461192a565b6000546001600160a01b039081169116146114415760405162461bcd60e51b815260040161043490613b23565b61144a8161224c565b610cb86001600160a01b0384168284612272565b60066020526000908152604090205481565b61147861192a565b6000546001600160a01b039081169116146114a55760405162461bcd60e51b815260040161043490613b23565b60005b8151811015610acf576114cd8282815181106114c057fe5b6020026020010151612291565b6001016114a8565b6114dd61192a565b6000546001600160a01b0390811691161461150a5760405162461bcd60e51b815260040161043490613b23565b6115138161261e565b50565b61151e61192a565b6000546001600160a01b0390811691161461154b5760405162461bcd60e51b815260040161043490613b23565b6001600160a01b0381166115715760405162461bcd60e51b815260040161043490613730565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600081158015906115df57506005548211155b6115fb5760405162461bcd60e51b815260040161043490613c16565b5090565b60008261160e5750600061163c565b8282028284828161161b57fe5b04146116395760405162461bcd60e51b815260040161043490613ae2565b90505b92915050565b60109190911b1760189190911b1760209190911b1760309190911b1790565b600080600060218460ff1610156116865761167b84612654565b92509250925061137f565b60201960ff851601611696612c6b565b600282815481106116a357fe5b60009182526020918290206040805160608101909152910180546001600160a01b03811683529192909190830190600160a01b900460ff1660038111156116e657fe5b60038111156116f157fe5b81529054600160a81b900460ff16602091820152815190820151604090920151909891975095509350505050565b60008260090160ff168260ff1611156117625761175b60ff6008198585030116600a0a611755876001600160401b0388166115ff565b906115ff565b905061178d565b61178a60ff83850360090116600a0a611784876001600160401b0388166115ff565b906128ca565b90505b949350505050565b6000828201838110156116395760405162461bcd60e51b8152600401610434906137e2565b6000600160201b82106115fb5760405162461bcd60e51b815260040161043490613c97565b6000816117ee5750600161163c565b60008360011461180557600260011985011b611808565b60015b90921615159392505050565b60008061182083611661565b5090949350505050565b611882846323b872dd60e01b85858560405160240161184b93929190613524565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261290c565b50505050565b60008281526001848101602090815260408084208551815487850151938801516060909801516001600160b01b03199091166001600160b01b039092169190911763ffffffff60b01b1916600160b01b63ffffffff948516021763ffffffff60d01b1916600160d01b9390971692909202959095176001600160f01b0316600160f01b61ffff9092169190910217909355845490810185559381522090910155565b3390565b336000908152600760205260409020611945612c44565b506000838152600182016020908152604091829020825160808101845290546001600160b01b038116808352600160b01b820463ffffffff90811694840194909452600160d01b820490931693820193909352600160f01b90920461ffff1660608301526119c55760405162461bcd60e51b815260040161043490613776565b60008080808080806119d68b61209e565b93509350935093508915611b88576119ec612bd1565b60056001860361ffff1681548110611a0057fe5b60009182526020918290206040805161016081018252919092015460ff80821683526101008083048216958401959095526201000082048116838501526301000000820481166060840152600160201b820481166080840152600160281b82041660a083015261ffff600160301b8204811660c0840152600160401b8204811660e0840152600160501b820481169483018590526001600160401b03600160601b83048116610120850152600160a01b909204909116610140830152918c015190935063ffffffff16610e109092021601421015611af05760405162461bcd60e51b815260040161043490613681565b6000611afd8a83426120b2565b8c51929b509098509150611b26908890611b20906001600160b01b03168c61299b565b9061299b565b9750808a6060019061ffff16908161ffff1681525050336001600160a01b03167feca4e94347e342f159876b86afa249ebf5d21bf1cb9246d53181f7a14bc3d0128e8b8a604051611b7993929190613dff565b60405180910390a25050611caa565b876020015163ffffffff16421015611bb25760405162461bcd60e51b8152600401610434906136c2565b87516001600160b01b0316965061ffff811615611c5c57611bd282611814565b6001600160a01b031663b88d4fde30338463b0e68bdd60e01b604051602001611bfb9190613476565b6040516020818303038152906040526040518563ffffffff1660e01b8152600401611c2994939291906134ee565b600060405180830381600087803b158015611c4357600080fd5b505af1158015611c57573d6000803e3d6000fd5b505050505b611c66898c6129dd565b336001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5688c89604051611ca1929190613df1565b60405180910390a25b611cb3426117ba565b886040019063ffffffff16908163ffffffff16815250508588600001906001600160b01b031690816001600160b01b031681525050878960010160008d815260200190815260200160002060008201518160000160006101000a8154816001600160b01b0302191690836001600160b01b0316021790555060208201518160000160166101000a81548163ffffffff021916908363ffffffff160217905550604082015181600001601a6101000a81548163ffffffff021916908363ffffffff160217905550606082015181600001601e6101000a81548161ffff021916908361ffff160217905550905050611dcc85611b2089600660008860ff1681526020019081526020016000205461299b90919063ffffffff16565b60ff8416600090815260066020526040902055600354611e1290600160201b90046001600160a01b03163389611e0187611814565b6001600160a01b031692919061182a565b5050505050505050505050565b81518351148015611e31575080518351145b611e4d5760405162461bcd60e51b815260040161043490613d33565b600254835161010091016021011115611e785760405162461bcd60e51b815260040161043490613a08565b60005b83518110156118825760006001600160a01b0316848281518110611e9b57fe5b60200260200101516001600160a01b03161415611eca5760405162461bcd60e51b81526004016104349061399a565b6000838281518110611ed857fe5b60200260200101516003811115611eeb57fe5b1415611f095760405162461bcd60e51b8152600401610434906138f5565b60026040518060600160405280868481518110611f2257fe5b60200260200101516001600160a01b03168152602001858481518110611f4457fe5b60200260200101516003811115611f5757fe5b8152602001848481518110611f6857fe5b60209081029190910181015160ff1690915282546001810184556000938452928190208251930180546001600160a01b0319166001600160a01b03909416939093178084559082015191929190829060ff60a01b1916600160a01b836003811115611fcf57fe5b021790555060409190910151815460ff909116600160a81b0260ff60a81b19909116179055600101611e7b565b80516001600160e01b03166120235760405162461bcd60e51b815260040161043490613a3f565b6004805460018101825560009190915281517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b909101805460209093015163ffffffff16600160e01b026001600160e01b039283166001600160e01b031990941693909317909116919091179055565b60006115fb8261224c565b602081901c91601882901c91601081901c91565b6000806000856060015161ffff1661ffff14156120e15760405162461bcd60e51b8152600401610434906137ab565b600092506000915060009050856040015163ffffffff168411801561210f5750856020015163ffffffff1684105b1561221457604086015160208701516060880151885163ffffffff80851689039490930383169260009261ffff92612158926001600160b01b039091169184038416906115ff16565b8161215f57fe5b0490506121708261178483866115ff565b89519096506121a9906121a090612190906001600160b01b03168961299b565b61178461ffff611755868c61299b565b61ffff9061299b565b935050505060008560e0015161ffff16610e10029050600085886020015163ffffffff1603905060ff826121f1836117558b60a0015160ff168a6115ff90919063ffffffff16565b816121f857fe5b048161220057fe5b04935061221191508490508361299b565b92505b93509350939050565b6000811580159061223057506004548211155b6115fb5760405162461bcd60e51b815260040161043490613819565b6001600160a01b0381166115135760405162461bcd60e51b815260040161043490613b58565b610cb88363a9059cbb60e01b848460405160240161184b929190613579565b60006122a08260200151611661565b509150600190508160038111156122b357fe5b146122d05760405162461bcd60e51b81526004016104349061392c565b6122dd8260600151611661565b509150600190508160038111156122f057fe5b1461230d5760405162461bcd60e51b8152600401610434906138be565b604082015160ff1615612357576123278260400151611661565b5091506002905081600381111561233a57fe5b146123575760405162461bcd60e51b815260040161043490613cfc565b608082015160ff1661239b5760a082015160ff1615801561237f575061010082015161ffff16155b61239b5760405162461bcd60e51b815260040161043490613850565b60c082015161ffff16156123bc576123ba8260c0015161ffff1661221d565b505b60e082015161ffff16158015906123e057506101208201516001600160401b031615155b6123fc5760405162461bcd60e51b815260040161043490613aab565b6005829080600181540180825580915050600190039060005260206000200160009091909190915060008201518160000160006101000a81548160ff021916908360ff16021790555060208201518160000160016101000a81548160ff021916908360ff16021790555060408201518160000160026101000a81548160ff021916908360ff16021790555060608201518160000160036101000a81548160ff021916908360ff16021790555060808201518160000160046101000a81548160ff021916908360ff16021790555060a08201518160000160056101000a81548160ff021916908360ff16021790555060c08201518160000160066101000a81548161ffff021916908361ffff16021790555060e08201518160000160086101000a81548161ffff021916908361ffff16021790555061010082015181600001600a6101000a81548161ffff021916908361ffff16021790555061012082015181600001600c6101000a8154816001600160401b0302191690836001600160401b031602179055506101408201518160000160146101000a8154816001600160401b0302191690836001600160401b0316021790555050506005805490507fe3b342825606ced2ad4891a1a90a7d334e74562c04a795f84000cb106c38922760405160405180910390a2815160ff1615610acf576005546040517f0e7a48c601b1a627275b6d51f24200a652a0018fafe123b6d2d7c0bfbe54f12490600090a25050565b6126278161224c565b600380546001600160a01b03909216600160201b02640100000000600160c01b0319909216919091179055565b60008060008360ff16600114156126885750735a731151d6510eb475cc7a0072200cffc9a3bfe5915060019050601261137f565b8360ff16600214156126b7575073dac17f958d2ee523a2206206994597c13d831ec7915060019050600661137f565b8360ff16600314156126e6575073a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48915060019050600661137f565b8360ff16600414156127155750736b175474e89094c44da98b954eedeac495271d0f915060019050601261137f565b8360ff1660051415612744575073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2915060019050601261137f565b8360ff16600614156127735750732260fac5e5542a773aa44fbcfedf7c193bc2c599915060019050600861137f565b8360ff16600714156127a2575073d2057d71fe3f5b0dc1e3e7722940e1908fc72078915060019050601261137f565b8360ff16601014156127d15750734c9c971fbefc93e0900988383dc050632deec71e915060029050600061137f565b8360ff16601114156128005750733068b3313281f63536042d24562896d080844c95915060029050600061137f565b8360ff166012141561282f575073f85c874ea05e2225982b48c93a7c7f701065d91e915060029050600061137f565b8360ff166013141561285e57507339c8788b19b0e3cefb3d2f38c9063b03eb1e2a5a915060029050600061137f565b8360ff166014141561288d575073440116abd7338d9ccfdc8b9b034f5d726f615f6d915060029050600061137f565b8360ff16601514156128bc57507391cc2cf7b0bd7ad99c0d8fa4cdfc93c15381fb2d915060029050600061137f565b506000938493508392509050565b600061163983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506129e7565b6060612961826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a1e9092919063ffffffff16565b805190915015610cb8578080602001905181019061297f9190613265565b610cb85760405162461bcd60e51b815260040161043490613c4d565b600061163983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612a2d565b610acf8282612a59565b60008183612a085760405162461bcd60e51b81526004016104349190613639565b506000838581612a1457fe5b0495945050505050565b606061178d8484600085612b07565b60008184841115612a515760405162461bcd60e51b81526004016104349190613639565b505050900390565b8154600019018015612ae2576000838281548110612a7357fe5b90600052602060002001549050828114612ae0575b6000819050846001840381548110612a9c57fe5b9060005260206000200154915082806001900393505080858481548110612abf57fe5b60009182526020909120015550808314801590612adb57508115155b612a88575b505b82805480612aec57fe5b60019003818190600052602060002001600090559055505050565b6060612b1285612bcb565b612b2e5760405162461bcd60e51b815260040161043490613bdf565b60006060866001600160a01b03168587604051612b4b919061348b565b60006040518083038185875af1925050503d8060008114612b88576040519150601f19603f3d011682016040523d82523d6000602084013e612b8d565b606091505b50915091508115612ba157915061178d9050565b805115612bb15780518082602001fd5b8360405162461bcd60e51b81526004016104349190613639565b3b151590565b6040805161016081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081018290526101008101829052610120810182905261014081019190915290565b604080518082019091526000808252602082015290565b60408051608081018252600080825260208201819052918101829052606081019190915290565b6040805160608101909152600080825260208201908152600060209091015290565b803561163c81613ec0565b600082601f830112612ca8578081fd5b8135612cbb612cb682613e75565b613e4f565b818152915060208083019084810181840286018201871015612cdc57600080fd5b6000805b85811015612d0857823560048110612cf6578283fd5b85529383019391830191600101612ce0565b50505050505092915050565b600082601f830112612d24578081fd5b8135612d32612cb682613e75565b818152915060208083019084810181840286018201871015612d5357600080fd5b60005b84811015612d7a57612d688883612e06565b84529282019290820190600101612d56565b505050505092915050565b600060408284031215612d96578081fd5b612da06040613e4f565b905081356001600160e01b0381168114612db957600080fd5b8152602082013563ffffffff81168114612dd257600080fd5b602082015292915050565b803561ffff8116811461163c57600080fd5b80356001600160401b038116811461163c57600080fd5b803560ff8116811461163c57600080fd5b600060208284031215612e28578081fd5b813561163981613ec0565b600080600080600060808688031215612e4a578081fd5b8535612e5581613ec0565b94506020860135612e6581613ec0565b93506040860135925060608601356001600160401b0380821115612e87578283fd5b818801915088601f830112612e9a578283fd5b813581811115612ea8578384fd5b896020828501011115612eb9578384fd5b9699959850939650602001949392505050565b60008060408385031215612ede578182fd5b8235612ee981613ec0565b946020939093013593505050565b600080600060608486031215612f0b578081fd5b83356001600160401b0380821115612f21578283fd5b818601915086601f830112612f34578283fd5b8135612f42612cb682613e75565b80828252602080830192508086018b828387028901011115612f62578788fd5b8796505b84871015612f8c57612f788c82612c8d565b845260019690960195928101928101612f66565b509097508801359350505080821115612fa3578283fd5b612faf87838801612c98565b93506040860135915080821115612fc4578283fd5b50612fd186828701612d14565b9150509250925092565b60006020808385031215612fed578182fd5b82356001600160401b03811115613002578283fd5b8301601f81018513613012578283fd5b8035613020612cb682613e75565b818152838101908385016040808502860187018a101561303e578788fd5b8795505b8486101561306a576130548a83612d85565b8452600195909501949286019290810190613042565b509098975050505050505050565b6000602080838503121561308a578182fd5b82356001600160401b0381111561309f578283fd5b8301601f810185136130af578283fd5b80356130bd612cb682613e75565b81815283810190838501610160808502860187018a10156130dc578788fd5b8795505b8486101561306a5780828b0312156130f6578788fd5b6130ff81613e4f565b6131098b84612e06565b81526131178b898501612e06565b8882015260406131298c828601612e06565b90820152606061313b8c858301612e06565b90820152608061314d8c858301612e06565b9082015260a061315f8c858301612e06565b9082015260c06131718c858301612ddd565b9082015260e06131838c858301612ddd565b908201526101006131968c858301612ddd565b908201526101206131a98c858301612def565b908201526101406131bc8c858301612def565b9082015284526001959095019492860192908101906130e0565b600060208083850312156131e8578182fd5b82356001600160401b038111156131fd578283fd5b8301601f8101851361320d578283fd5b803561321b612cb682613e75565b8181528381019083850185840285018601891015613237578687fd5b8694505b8385101561325957803583526001949094019391850191850161323b565b50979650505050505050565b600060208284031215613276578081fd5b81518015158114611639578182fd5b600080600060608486031215613299578081fd5b83356132a481613ec0565b92506020840135915060408401356132bb81613ec0565b809150509250925092565b6000602082840312156132d7578081fd5b5035919050565b6000806000606084860312156132f2578081fd5b83359250602084013561330481613ec0565b929592945050506040919091013590565b60008060408385031215613327578182fd5b50508035926020909101359150565b60008060006060848603121561334a578081fd5b505081359360208301359350604090920135919050565b60008151808452613379816020860160208601613e94565b601f01601f19169290920160200192915050565b61339882825161346f565b60208101516133aa602084018261346f565b5060408101516133bd604084018261346f565b5060608101516133d0606084018261346f565b5060808101516133e3608084018261346f565b5060a08101516133f660a084018261346f565b5060c081015161340960c084018261345a565b5060e081015161341c60e084018261345a565b50610100808201516134308285018261345a565b50506101208082015161344582850182613462565b50506101408082015161188282850182613462565b61ffff169052565b6001600160401b03169052565b60ff169052565b6001600160e01b031991909116815260040190565b6000825161349d818460208701613e94565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090610c6e90830184613361565b6001600160a01b0385811682528416602082015261ffff83166040820152608060608201819052600090610c6e90830184613361565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0384168152606081016004841061356257fe5b83602083015260ff83166040830152949350505050565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156135d5576135c183855161338d565b9284019261016092909201916001016135ae565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156135d5578351835292840192918401916001016135fd565b901515815260200190565b6001600160e01b031991909116815260200190565b6000602082526116396020830184613361565b6020808252818101527f4b4465636b733a7465726d732064697361626c6564206f7220756e6b6e6f776e604082015260600190565b60208082526021908201527f4b4465636b733a7769746864726177616c206e6f742079657420616c6c6f77656040820152601960fa1b606082015260800190565b60208082526018908201527f4b4465636b733a6465706f736974206973206c6f636b65640000000000000000604082015260600190565b60208082526019908201527f4b4465636b733a756e737570706f72746564204e465420494400000000000000604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252818101527f4b4465636b733a756e6b6e6f776e206f7220726570616964206465706f736974604082015260600190565b6020808252601f908201527f4b4465636b733a6561726c79207769746864726177616c732062616e6e656400604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526018908201527f4b4465636b733a494e56414c49445f4c494d4954535f49440000000000000000604082015260600190565b6020808252601a908201527f4b4465636b733a494e434f4e53495354454e545f504152414d53000000000000604082015260600190565b6020808252601e908201527f4b4465636b733a646973616c6c6f776564204e465420696e7374616e63650000604082015260600190565b6020808252601a908201527f4b4465636b733a494e56414c49445f52455041595f544f4b454e000000000000604082015260600190565b6020808252601a908201527f546f6b4c6973743a494e56414c49445f544f4b454e5f54595045000000000000604082015260600190565b6020808252601c908201527f4b4465636b733a494e56414c49445f4445504f5349545f544f4b454e00000000604082015260600190565b6020808252601d908201527f4b4465636b733a746f6f20626967206465706f73697420616d6f756e74000000604082015260600190565b6020808252601d908201527f546f6b4c6973743a494e56414c49445f544f4b454e5f41444452455353000000604082015260600190565b6020808252601f908201527f4b4465636b733a746f6f20736d616c6c206465706f73697420616d6f756e7400604082015260600190565b60208082526017908201527f546f6b4c6973743a544f4f5f4d414e595f544f4b454e53000000000000000000604082015260600190565b60208082526018908201527f4b4465636b733a494e56414c49445f6d696e416d6f756e740000000000000000604082015260600190565b6020808252818101527f4b4465636b733a756e6578706563746564206e6f6e2d7a65726f206e66744964604082015260600190565b60208082526019908201527f4b4465636b733a494e56414c49445f5a45524f5f504152414d00000000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601390820152724b4465636b733a5a45524f5f4144445245535360681b604082015260600190565b60208082526009908201526825a232b1b5b99d279960b91b604082015260600190565b6020808252601b908201527f4b4465636b733a494e56414c49445f617661696c61626c655174790000000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526017908201527f4b4465636b733a494e56414c49445f5445524d535f4944000000000000000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526014908201527325a232b1b5b99d2aa729a0a322afaaa4a72a199960611b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526018908201527f4b4465636b733a494e56414c49445f4e46545f544f4b454e0000000000000000604082015260600190565b6020808252601d908201527f546f6b4c6973743a494e56414c49445f4c495354535f4c454e47544853000000604082015260600190565b81516001600160e01b0316815260209182015163ffffffff169181019190915260400190565b610160810161163c828461338d565b90815260200190565b91825280516001600160b01b031660208084019190915281015163ffffffff90811660408085019190915282015116606080840191909152015161ffff16608082015260a00190565b918252602082015260400190565b9283526020830191909152604082015260600190565b94855260208501939093526040840191909152606083015263ffffffff16608082015260a00190565b63ffffffff91909116815260200190565b6040518181016001600160401b0381118282101715613e6d57600080fd5b604052919050565b60006001600160401b03821115613e8a578081fd5b5060209081020190565b60005b83811015613eaf578181015183820152602001613e97565b838111156118825750506000910152565b6001600160a01b038116811461151357600080fdfea26469706673582212200e36b560ff5ec5ba9bf56f05d39d278a1686dfbf49f803a78fb157474d4f65b864736f6c634300060c0033

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

000000000000000000000000d31e459ac72e2ccad9a35b5b3367cfb4bab0274f

-----Decoded View---------------
Arg [0] : _treasury (address): 0xD31e459Ac72E2ccAD9A35b5b3367cfB4BaB0274F

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000d31e459ac72e2ccad9a35b5b3367cfb4bab0274f


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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