false
true
0

Contract Address Details

0x244154F58e9Bf6C15c3a09846eFB7bEcFe92A880

Contract Name
Cashier
Creator
0x9266f0–e444ba at 0xc2615e–0b5af7
Balance
0.066 PLS ( )
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
26733071
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
Cashier




Optimization enabled
true
Compiler version
v0.7.6+commit.7338295f




Optimization runs
200
EVM Version
istanbul




Verified at
2026-06-08T06:12:29.895373Z

Constructor Arguments

0000000000000000000000000a393aef6dbcd7e7088acf323f9d28b093b9ab5a00000000000000000000000019c10a47c9356efd0e4377411db627636ee9e3c6000000000000000000000000cf6d79e65c49a93a42dd8c474b46998eea4adec8000000000000000000000000de41a99562ada9ee04d9750c99a91c1181ebd875

Arg [0] (address) : 0x0a393aef6dbcd7e7088acf323f9d28b093b9ab5a
Arg [1] (address) : 0x19c10a47c9356efd0e4377411db627636ee9e3c6
Arg [2] (address) : 0xcf6d79e65c49a93a42dd8c474b46998eea4adec8
Arg [3] (address) : 0xde41a99562ada9ee04d9750c99a91c1181ebd875

              

contracts/Cashier.sol

// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity 0.7.6;

import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./interfaces/IVoucherKernel.sol";
import "./interfaces/ICashier.sol";
import {Entity, PaymentMethod, VoucherState, VoucherDetails, isStatus, determineStatus} from "./UsingHelpers.sol";


/**
 * @title Contract for managing funds
 * Roughly following OpenZeppelin's Escrow at https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/payment/
 */
contract Cashier is ICashier, ReentrancyGuard, Ownable, Pausable {
    using SafeERC20 for IERC20;
    using Address for address payable;
    using SafeMath for uint256;

    address private voucherKernel;
    address private bosonRouterAddress;
    address private voucherSetTokenAddress;   //ERC1155 contract representing voucher sets    
    address private voucherTokenAddress;     //ERC721 contract representing vouchers;
    bool private disasterState;

    enum PaymentType {PAYMENT, DEPOSIT_SELLER, DEPOSIT_BUYER}
    enum Role {ISSUER, HOLDER}

    mapping(address => uint256) private escrow; // both types of deposits AND payments >> can be released token-by-token if checks pass
    // slashedDepositPool can be obtained through getEscrowAmount(poolAddress)
    mapping(address => mapping(address => uint256)) private escrowTokens; //token address => mgsSender => amount

    uint256 internal constant CANCELFAULT_SPLIT = 2; //for POC purposes, this is hardcoded; e.g. each party gets depositSe / 2

    event LogBosonRouterSet(address _newBosonRouter, address _triggeredBy);

    event LogVoucherTokenContractSet(address _newTokenContract, address _triggeredBy);

    event LogVoucherSetTokenContractSet(address _newTokenContract, address _triggeredBy);

    event LogVoucherKernelSet(address _newVoucherKernel, address _triggeredBy);

    event LogWithdrawal(address _caller, address _payee, uint256 _payment);

    event LogAmountDistribution(
        uint256 indexed _tokenIdVoucher,
        address _to,
        uint256 _payment,
        PaymentType _type
    );

    event LogDisasterStateSet(bool _disasterState, address _triggeredBy);
    event LogWithdrawEthOnDisaster(uint256 _amount, address _triggeredBy);
    event LogWithdrawTokensOnDisaster(
        uint256 _amount,
        address _tokenAddress,
        address _triggeredBy
    );

    modifier onlyFromRouter() {
        require(msg.sender == bosonRouterAddress, "UNAUTHORIZED_BR");
        _;
    }

    modifier notZeroAddress(address _addressToCheck) {
        require(_addressToCheck != address(0), "0A");
        _;
    }

    /**
     * @notice The caller must be the Vouchers token contract, otherwise reverts.
     */
    modifier onlyVoucherTokenContract() {
        require(msg.sender == voucherTokenAddress, "UNAUTHORIZED_VOUCHER_TOKEN_ADDRESS"); // Unauthorized token address
        _;
    }

     /**
     * @notice The caller must be the Voucher Sets token contract, otherwise reverts.
     */
    modifier onlyVoucherSetTokenContract() {
        require(msg.sender == voucherSetTokenAddress, "UNAUTHORIZED_VOUCHER_SET_TOKEN_ADDRESS"); // Unauthorized token address
        _;
    }

    /**
     * @notice Construct and initialze the contract. Iniialises associated contract addresses. Iniialises disaster state to false.    
     * @param _bosonRouterAddress address of the associated BosonRouter contract
     * @param _voucherKernel address of the associated VocherKernal contract instance
     * @param _voucherSetTokenAddress address of the associated ERC1155 contract instance
     * @param _voucherTokenAddress address of the associated ERC721 contract instance

     */
    constructor(address _bosonRouterAddress, address _voucherKernel, address _voucherSetTokenAddress, address _voucherTokenAddress) 
        notZeroAddress(_bosonRouterAddress)
        notZeroAddress(_voucherKernel)
        notZeroAddress(_voucherSetTokenAddress)
        notZeroAddress(_voucherTokenAddress)
    {
        bosonRouterAddress = _bosonRouterAddress;
        voucherKernel = _voucherKernel;
        voucherSetTokenAddress = _voucherSetTokenAddress;
        voucherTokenAddress = _voucherTokenAddress;
        emit LogBosonRouterSet(_bosonRouterAddress, msg.sender);
        emit LogVoucherKernelSet(_voucherKernel, msg.sender);
        emit LogVoucherSetTokenContractSet(_voucherSetTokenAddress, msg.sender);
        emit LogVoucherTokenContractSet(_voucherTokenAddress, msg.sender);
    }

    /**
     * @notice Pause the process of interaction with voucherID's (ERC-721), in case of emergency.
     * Only BR contract is in control of this function.
     */
    function pause() external override onlyFromRouter {
        _pause();
    }

    /**
     * @notice Unpause the process of interaction with voucherID's (ERC-721).
     * Only BR contract is in control of this function.
     */
    function unpause() external override onlyFromRouter {
        _unpause();
    }

    /**
     * @notice If once disaster state has been set to true, the contract could never be unpaused.
     */
    function canUnpause() external view override returns (bool) {
        return !disasterState;
    }

    /**
     * @notice Once this functions is triggered, contracts cannot be unpaused anymore
     * Only BR contract is in control of this function.
     */
    function setDisasterState() external onlyOwner whenPaused {
        require(!disasterState, "Disaster state is already set");
        disasterState = true;
        emit LogDisasterStateSet(disasterState, msg.sender);
    }

    /**
     * @notice In case of a disaster this function allow the caller to withdraw all pooled funds kept in the escrow for the address provided. Funds are sent in ETH
     */
    function withdrawEthOnDisaster() external whenPaused nonReentrant {
        require(disasterState, "Owner did not allow manual withdraw");

        uint256 amount = escrow[msg.sender];

        require(amount > 0, "ESCROW_EMPTY");
        escrow[msg.sender] = 0;
        msg.sender.sendValue(amount);

        emit LogWithdrawEthOnDisaster(amount, msg.sender);
    }

    /**
     * @notice In case of a disaster this function allow the caller to withdraw all pooled funds kept in the escrowTokens for the address provided.
     * @param _token address of a token, that the caller sent the funds, while interacting with voucher or voucher-set
     */
    function withdrawTokensOnDisaster(address _token)
        external
        whenPaused
        nonReentrant
        notZeroAddress(_token)
    {
        require(disasterState, "Owner did not allow manual withdraw");

        uint256 amount = escrowTokens[_token][msg.sender];
        require(amount > 0, "ESCROW_EMPTY");
        escrowTokens[_token][msg.sender] = 0;

        SafeERC20.safeTransfer(IERC20(_token), msg.sender, amount);
        emit LogWithdrawTokensOnDisaster(amount, _token, msg.sender);
    }

    /**
     * @notice Trigger withdrawals of what funds are releasable
     * The caller of this function triggers transfers to all involved entities (pool, issuer, token holder), also paying for gas.
     * @param _tokenIdVoucher  ID of a voucher token (ERC-721) to try withdraw funds from
     */
    function withdraw(uint256 _tokenIdVoucher)
        external
        override
        nonReentrant
        whenNotPaused
    {
        bool released = distributeAndWithdraw(_tokenIdVoucher, Entity.ISSUER);
        released = distributeAndWithdraw(_tokenIdVoucher, Entity.HOLDER) || released;
        released = distributeAndWithdraw(_tokenIdVoucher, Entity.POOL) || released;
        require (released, "NOTHING_TO_WITHDRAW");
    }

    /**
     * @notice Trigger withdrawals of what funds are releasable for chosen entity {ISSUER, HOLDER, POOL}
     * @param _tokenIdVoucher  ID of a voucher token (ERC-721) to try withdraw funds from
     * @param _to               recipient, one of {ISSUER, HOLDER, POOL}
     */
     function withdrawSingle(uint256 _tokenIdVoucher, Entity _to)
        external
        override
        nonReentrant
        whenNotPaused
    {
        require (distributeAndWithdraw(_tokenIdVoucher, _to),
            "NOTHING_TO_WITHDRAW");

    }

    /**
     * @notice Calcuate how much should entity receive and transfer funds to its address
     * @param _tokenIdVoucher  ID of a voucher token (ERC-721) to try withdraw funds from
     * @param _to recipient, one of {ISSUER, HOLDER, POOL}
     */
    function distributeAndWithdraw(uint256 _tokenIdVoucher, Entity _to)
        internal
        returns (bool)
    {
        VoucherDetails memory voucherDetails;

        require(_tokenIdVoucher != 0, "UNSPECIFIED_ID");

        voucherDetails.tokenIdVoucher = _tokenIdVoucher;
        voucherDetails.tokenIdSupply = IVoucherKernel(voucherKernel)
            .getIdSupplyFromVoucher(voucherDetails.tokenIdVoucher);
        voucherDetails.paymentMethod = IVoucherKernel(voucherKernel)
            .getVoucherPaymentMethod(voucherDetails.tokenIdSupply);

        (
            voucherDetails.currStatus.status,
            voucherDetails.currStatus.isPaymentReleased,
            voucherDetails.currStatus.isDepositsReleased,
            ,
        ) = IVoucherKernel(voucherKernel).getVoucherStatus(
            voucherDetails.tokenIdVoucher
        );

        (
            voucherDetails.price,
            voucherDetails.depositSe,
            voucherDetails.depositBu
        ) = IVoucherKernel(voucherKernel).getOrderCosts(
            voucherDetails.tokenIdSupply
        );

        voucherDetails.issuer = payable(
            IVoucherKernel(voucherKernel).getVoucherSeller(
                _tokenIdVoucher
            )
        );
        voucherDetails.holder = payable(
            IVoucherKernel(voucherKernel).getVoucherHolder(
                voucherDetails.tokenIdVoucher
            )
        );

        bool paymentReleased;
        //process the RELEASE OF PAYMENTS - only depends on the redeemed/not-redeemed, a voucher need not be in the final status
        if (!voucherDetails.currStatus.isPaymentReleased) {
            paymentReleased = releasePayments(voucherDetails, _to);
        }

        //process the RELEASE OF DEPOSITS - only when vouchers are in the FINAL status
        bool depositReleased;
        uint256 releasedAmount;
        if (
            !IVoucherKernel(voucherKernel).isDepositReleased(_tokenIdVoucher, _to) &&
            isStatus(voucherDetails.currStatus.status, VoucherState.FINAL)
        ) {
            (depositReleased, releasedAmount) = releaseDeposits(voucherDetails, _to);
        }

        // WITHDRAW
        if (paymentReleased) {
            _withdrawPayments(
                _to == Entity.ISSUER ? voucherDetails.issuer : voucherDetails.holder,
                voucherDetails.price,
                voucherDetails.paymentMethod,
                voucherDetails.tokenIdSupply
            );
        }
                    
        if (depositReleased) {
            _withdrawDeposits(
                _to == Entity.ISSUER ? voucherDetails.issuer : _to == Entity.HOLDER ? voucherDetails.holder : owner(),
                releasedAmount,
                voucherDetails.paymentMethod,
                voucherDetails.tokenIdSupply
            );
        }

        return paymentReleased || depositReleased;
    }

    /**
     * @notice Release of payments, for a voucher which payments had not been released already.
     * Based on the voucher status(e.g. redeemed, refunded, etc), the voucher price will be sent to either buyer or seller.
     * @param _voucherDetails keeps all required information of the voucher which the payment should be released for.
     * @param _to             recipient, one of {ISSUER, HOLDER, POOL}
     */
    function releasePayments(VoucherDetails memory _voucherDetails, Entity _to) internal returns (bool){
        if (_to == Entity.ISSUER &&
            isStatus(_voucherDetails.currStatus.status, VoucherState.REDEEM)) {
            releasePayment(_voucherDetails, Role.ISSUER);
            return true;
        } 
        
        if (
            _to == Entity.HOLDER &&
            (isStatus(_voucherDetails.currStatus.status, VoucherState.REFUND) ||
            isStatus(_voucherDetails.currStatus.status, VoucherState.EXPIRE) ||
            (isStatus(_voucherDetails.currStatus.status, VoucherState.CANCEL_FAULT) &&
                !isStatus(_voucherDetails.currStatus.status, VoucherState.REDEEM)))
        ) { 
            releasePayment(_voucherDetails, Role.HOLDER);
            return true;
        }
        return false;
    }

    /**
     * @notice Following function `releasePayments`, if certain conditions for the voucher status are met, the voucher price will be sent to the seller or the buyer
     * @param _voucherDetails keeps all required information of the voucher which the payment should be released for.
     */
    function releasePayment(VoucherDetails memory _voucherDetails, Role _role) internal {
        if (
            _voucherDetails.paymentMethod == PaymentMethod.ETHETH ||
            _voucherDetails.paymentMethod == PaymentMethod.ETHTKN
        ) {
            escrow[_voucherDetails.holder] = escrow[_voucherDetails.holder].sub(
                _voucherDetails.price
            );
        }

        if (
            _voucherDetails.paymentMethod == PaymentMethod.TKNETH ||
            _voucherDetails.paymentMethod == PaymentMethod.TKNTKN
        ) {
            address addressTokenPrice =
                IVoucherKernel(voucherKernel).getVoucherPriceToken(
                    _voucherDetails.tokenIdSupply
                );

            escrowTokens[addressTokenPrice][
                _voucherDetails.holder
            ] = escrowTokens[addressTokenPrice][_voucherDetails.holder].sub(
                _voucherDetails.price
            );
        }

        IVoucherKernel(voucherKernel).setPaymentReleased(
            _voucherDetails.tokenIdVoucher
        );

        emit LogAmountDistribution(
            _voucherDetails.tokenIdVoucher,
            _role == Role.ISSUER ? _voucherDetails.issuer : _voucherDetails.holder,
            _voucherDetails.price,
            PaymentType.PAYMENT
        );
    }

    /**
     * @notice Release of deposits, for a voucher which deposits had not been released already, and had been marked as `finalized`
     * Based on the voucher status(e.g. complained, redeemed, refunded, etc), the voucher deposits will be sent to either buyer, seller, or pool owner.
     * Depending on the payment type (e.g ETH, or Token) escrow funds will be held in the `escrow` || escrowTokens mappings
     * @param _voucherDetails keeps all required information of the voucher which the deposits should be released for.
     * @param _to             recipient, one of {ISSUER, HOLDER, POOL}
     */
    function releaseDeposits(VoucherDetails memory _voucherDetails, Entity _to) internal returns (bool _released, uint256 _amount){
        //first, depositSe
        if (isStatus(_voucherDetails.currStatus.status, VoucherState.COMPLAIN)) {
            //slash depositSe
            _amount = distributeIssuerDepositOnHolderComplain(_voucherDetails, _to);
            
        } else if(_to != Entity.POOL) {
            if (                
                isStatus(_voucherDetails.currStatus.status, VoucherState.CANCEL_FAULT)) {
                //slash depositSe
                _amount = distributeIssuerDepositOnIssuerCancel(_voucherDetails, _to);
            } else if (_to == Entity.ISSUER) { // happy path, seller gets the whole seller deposit
                //release depositSe
                _amount = distributeFullIssuerDeposit(_voucherDetails);
            }
            
        }

        //second, depositBu
        if (            
            isStatus(_voucherDetails.currStatus.status, VoucherState.REDEEM) ||
            isStatus(_voucherDetails.currStatus.status, VoucherState.CANCEL_FAULT)
        ) {
            //release depositBu
            if (_to == Entity.HOLDER) {
            _amount = _amount.add(distributeFullHolderDeposit(_voucherDetails));
            }
        } else if (_to == Entity.POOL){
            //slash depositBu
            _amount = _amount.add(distributeHolderDepositOnNotRedeemedNotCancelled(_voucherDetails));
        }

        _released = _amount > 0;

        if (_released) {
            IVoucherKernel(voucherKernel).setDepositsReleased(
                _voucherDetails.tokenIdVoucher, _to, _amount
            );
        }
    }

    /**
     * @notice Release of deposits, for a voucher which deposits had not been released already, and had been marked as `finalized`
     * Based on the voucher status(e.g. complained, redeemed, refunded, etc), the voucher deposits will be sent to either buyer, seller, or pool owner.
     * Depending on the payment type (e.g ETH, or Token) escrow funds will be held in the `escrow` || escrowTokens mappings
     * @param _paymentMethod payment method that should be used to determine, how to do the payouts
     * @param _entity        address which ecrows is reduced
     * @param _amount        amount to be released from escrow
     * @param _tokenIdSupply an ID of a supply token (ERC-1155) which will be burned and deposits will be returned for
     */
    function reduceEscrowAmountDeposits(PaymentMethod _paymentMethod, address _entity, uint256 _amount, uint256 _tokenIdSupply) internal {
            if (
                _paymentMethod == PaymentMethod.ETHETH ||
                _paymentMethod == PaymentMethod.TKNETH
            ) {
                escrow[_entity] = escrow[_entity]
                    .sub(_amount);
            }

            if (
                _paymentMethod == PaymentMethod.ETHTKN ||
                _paymentMethod == PaymentMethod.TKNTKN
            ) {
                address addressTokenDeposits =
                    IVoucherKernel(voucherKernel).getVoucherDepositToken(
                        _tokenIdSupply
                    );

                escrowTokens[addressTokenDeposits][
                    _entity
                ] = escrowTokens[addressTokenDeposits][_entity]
                    .sub(_amount);
            }
    }

    /**
     * @notice Following function `releaseDeposits` this function will be triggered if a voucher had been complained by the buyer.
     * Also checks if the voucher had been cancelled
     * @param _voucherDetails keeps all required information of the voucher which the payment should be released for.
     * @param _to             recipient, one of {ISSUER, HOLDER, POOL}
     */
    function distributeIssuerDepositOnHolderComplain(
        VoucherDetails memory _voucherDetails,
        Entity _to
    ) internal 
        returns (uint256){
        uint256 toDistribute;
        address recipient;
        if (isStatus(_voucherDetails.currStatus.status, VoucherState.CANCEL_FAULT)) {
            //appease the conflict three-ways
            uint256 tFraction = _voucherDetails.depositSe.div(CANCELFAULT_SPLIT);


            if (_to == Entity.HOLDER) { //Bu gets, say, a half                
                toDistribute = tFraction;
                recipient = _voucherDetails.holder;
            } else if (_to == Entity.ISSUER) {  //Se gets, say, a quarter
                toDistribute = tFraction.div(CANCELFAULT_SPLIT);
                recipient = _voucherDetails.issuer;
            } else { //slashing the rest
                toDistribute = (_voucherDetails.depositSe.sub(tFraction)).sub(
                    tFraction.div(CANCELFAULT_SPLIT)
                );
                recipient = owner();
            }

        } else if (_to == Entity.POOL){
            //slash depositSe
            toDistribute = _voucherDetails.depositSe;
            recipient = owner();
        } else {
            return 0;
        }

        reduceEscrowAmountDeposits(_voucherDetails.paymentMethod, _voucherDetails.issuer, toDistribute, _voucherDetails.tokenIdSupply);

        emit LogAmountDistribution(
            _voucherDetails.tokenIdVoucher,
            recipient,
            toDistribute,
            PaymentType.DEPOSIT_SELLER
        );

        return toDistribute;
    }

    /**
     * @notice Following function `releaseDeposits` this function will be triggered if a voucher had been cancelled by the seller.
     * Will be triggered if the voucher had not been complained.
     * @param _voucherDetails keeps all required information of the voucher which the deposits should be released for.
     * @param _to             recipient, one of {ISSUER, HOLDER, POOL}
     */
    function distributeIssuerDepositOnIssuerCancel(
        VoucherDetails memory _voucherDetails,
        Entity _to
    ) internal 
        returns (uint256)
    {
        uint256 toDistribute;
        address recipient;
        if (_to == Entity.HOLDER) { //Bu gets, say, a half                
        toDistribute = _voucherDetails.depositSe.sub(
                _voucherDetails.depositSe.div(CANCELFAULT_SPLIT)
            );
            recipient = _voucherDetails.holder;
        } else {  //Se gets, say, a half
            toDistribute = _voucherDetails.depositSe.div(CANCELFAULT_SPLIT);
            recipient = _voucherDetails.issuer;
        } 

        reduceEscrowAmountDeposits(_voucherDetails.paymentMethod, _voucherDetails.issuer, toDistribute, _voucherDetails.tokenIdSupply);

        emit LogAmountDistribution(
            _voucherDetails.tokenIdVoucher,
            recipient,
            toDistribute,
            PaymentType.DEPOSIT_SELLER
        );

        return toDistribute;   
    }

    /**
     * @notice Following function `releaseDeposits` this function will be triggered if no complain, nor cancel had been made.
     * All seller deposit is returned to seller.
     * @param _voucherDetails keeps all required information of the voucher which the deposits should be released for.
     */
    function distributeFullIssuerDeposit(VoucherDetails memory _voucherDetails)
        internal returns (uint256)
    {
        reduceEscrowAmountDeposits(_voucherDetails.paymentMethod, _voucherDetails.issuer, _voucherDetails.depositSe, _voucherDetails.tokenIdSupply);
      
        emit LogAmountDistribution(
            _voucherDetails.tokenIdVoucher,
            _voucherDetails.issuer,
            _voucherDetails.depositSe,
            PaymentType.DEPOSIT_SELLER
        );

        return _voucherDetails.depositSe;
    }

    /**
     * @notice Following function `releaseDeposits` this function will be triggered if voucher had been redeemed, or the seller had cancelled.
     * All buyer deposit is returned to buyer.
     * @param _voucherDetails keeps all required information of the voucher which the deposits should be released for.
     */
    function distributeFullHolderDeposit(VoucherDetails memory _voucherDetails)
        internal
        returns (uint256)
    {
        reduceEscrowAmountDeposits(_voucherDetails.paymentMethod, _voucherDetails.holder, _voucherDetails.depositBu, _voucherDetails.tokenIdSupply);
        
        emit LogAmountDistribution(
            _voucherDetails.tokenIdVoucher,
            _voucherDetails.holder,
            _voucherDetails.depositBu,
            PaymentType.DEPOSIT_BUYER
        );

        return _voucherDetails.depositBu;
    }

    /**
     * @notice Following function `releaseDeposits` this function will be triggered if voucher had not been redeemed or cancelled after finalization.
     * @param _voucherDetails keeps all required information of the voucher which the deposits should be released for.
     * All buyer deposit goes to Boson.
     */
    function distributeHolderDepositOnNotRedeemedNotCancelled(
        VoucherDetails memory _voucherDetails        
    ) internal returns (uint256){
        reduceEscrowAmountDeposits(_voucherDetails.paymentMethod, _voucherDetails.holder, _voucherDetails.depositBu, _voucherDetails.tokenIdSupply);       

        emit LogAmountDistribution(
            _voucherDetails.tokenIdVoucher,
            owner(),
            _voucherDetails.depositBu,
            PaymentType.DEPOSIT_BUYER
        );

        return _voucherDetails.depositBu;
    }

    /**
     * @notice External function for withdrawing deposits. Caller must be the seller of the goods, otherwise reverts.
     * @notice Seller triggers withdrawals of remaining deposits for a given supply, in case the voucher set is no longer in exchange.
     * @param _tokenIdSupply an ID of a supply token (ERC-1155) which will be burned and deposits will be returned for
     * @param _burnedQty burned quantity that the deposits should be withdrawn for
     * @param _messageSender owner of the voucher set
     */
    function withdrawDepositsSe(
        uint256 _tokenIdSupply,
        uint256 _burnedQty,
        address payable _messageSender
    ) external override nonReentrant onlyFromRouter notZeroAddress(_messageSender) {
        require(IVoucherKernel(voucherKernel).getSupplyHolder(_tokenIdSupply) == _messageSender, "UNAUTHORIZED_V");

        uint256 deposit =
            IVoucherKernel(voucherKernel).getSellerDeposit(_tokenIdSupply);

        uint256 depositAmount = deposit.mul(_burnedQty);

        PaymentMethod paymentMethod =
            IVoucherKernel(voucherKernel).getVoucherPaymentMethod(
                _tokenIdSupply
            );

        if (paymentMethod == PaymentMethod.ETHETH || paymentMethod == PaymentMethod.TKNETH) {
            escrow[_messageSender] = escrow[_messageSender].sub(depositAmount);
        }

        if (paymentMethod == PaymentMethod.ETHTKN || paymentMethod == PaymentMethod.TKNTKN) {
            address addressTokenDeposits =
                IVoucherKernel(voucherKernel).getVoucherDepositToken(
                    _tokenIdSupply
                );

            escrowTokens[addressTokenDeposits][_messageSender] = escrowTokens[
                addressTokenDeposits
            ][_messageSender]
                .sub(depositAmount);
        }

        _withdrawDeposits(
            _messageSender,
            depositAmount,
            paymentMethod,
            _tokenIdSupply
        );
    }

    /**
     * @notice Internal function for withdrawing payments.
     * As unbelievable as it is, neither .send() nor .transfer() are now secure to use due to EIP-1884
     *  So now transferring funds via the last remaining option: .call()
     *  See https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/
     * @param _recipient    address of the account receiving funds from the escrow
     * @param _amount       amount to be released from escrow
     * @param _paymentMethod payment method that should be used to determine, how to do the payouts
     * @param _tokenIdSupply       _tokenIdSupply of the voucher set this is related to
     */
    function _withdrawPayments(
        address _recipient,
        uint256 _amount,
        PaymentMethod _paymentMethod,
        uint256 _tokenIdSupply
    ) internal
      notZeroAddress(_recipient)
    {
        if (_paymentMethod == PaymentMethod.ETHETH || _paymentMethod == PaymentMethod.ETHTKN) {
            payable(_recipient).sendValue(_amount);
            emit LogWithdrawal(msg.sender, _recipient, _amount);
        }

        if (_paymentMethod == PaymentMethod.TKNETH || _paymentMethod == PaymentMethod.TKNTKN) {
            address addressTokenPrice =
                IVoucherKernel(voucherKernel).getVoucherPriceToken(
                    _tokenIdSupply
                );

            SafeERC20.safeTransfer(
                IERC20(addressTokenPrice),
                _recipient,
                _amount
            );
        }
    }

    /**
     * @notice Internal function for withdrawing deposits.
     * @param _recipient    address of the account receiving funds from the escrow
     * @param _amount       amount to be released from escrow
     * @param _paymentMethod       payment method that should be used to determine, how to do the payouts
     * @param _tokenIdSupply       _tokenIdSupply of the voucher set this is related to
     */
    function _withdrawDeposits(
        address _recipient,
        uint256 _amount,
        PaymentMethod _paymentMethod,
        uint256 _tokenIdSupply
    ) internal    
      notZeroAddress(_recipient)
    {
        require(_amount > 0, "NO_FUNDS_TO_WITHDRAW");

        if (_paymentMethod == PaymentMethod.ETHETH || _paymentMethod == PaymentMethod.TKNETH) {
            payable(_recipient).sendValue(_amount);
            emit LogWithdrawal(msg.sender, _recipient, _amount);
        }

        if (_paymentMethod == PaymentMethod.ETHTKN || _paymentMethod == PaymentMethod.TKNTKN) {
            address addressTokenDeposits =
                IVoucherKernel(voucherKernel).getVoucherDepositToken(
                    _tokenIdSupply
                );

            SafeERC20.safeTransfer(
                IERC20(addressTokenDeposits),
                _recipient,
                _amount
            );
        }
    }

    /**
     * @notice Set the address of the BR contract
     * @param _bosonRouterAddress   The address of the Boson Route contract
     */
    function setBosonRouterAddress(address _bosonRouterAddress)
        external
        override
        onlyOwner
        whenPaused
        notZeroAddress(_bosonRouterAddress)
    {
        bosonRouterAddress = _bosonRouterAddress;

        emit LogBosonRouterSet(_bosonRouterAddress, msg.sender);
    }

    /**
     * @notice Set the address of the Vouchers token contract, an ERC721 contract
     * @param _voucherTokenAddress   The address of the Vouchers token contract
     */
    function setVoucherTokenAddress(address _voucherTokenAddress)
        external
        override
        onlyOwner
        notZeroAddress(_voucherTokenAddress)
        whenPaused
    {
        voucherTokenAddress = _voucherTokenAddress;
        emit LogVoucherTokenContractSet(_voucherTokenAddress, msg.sender);
    }

   /**
     * @notice Set the address of the Voucher Sets token contract, an ERC1155 contract
     * @param _voucherSetTokenAddress   The address of the Vouchers token contract
     */
    function setVoucherSetTokenAddress(address _voucherSetTokenAddress)
        external
        override
        onlyOwner
        notZeroAddress(_voucherSetTokenAddress)
        whenPaused
    {
        voucherSetTokenAddress = _voucherSetTokenAddress;
        emit LogVoucherSetTokenContractSet(_voucherSetTokenAddress, msg.sender);
    }

    /**
     * @notice Update the amount in escrow of an address with the new value, based on VoucherSet/Voucher interaction
     * @param _account  The address of an account to update
     */
    function addEscrowAmount(address _account)
        external
        override
        payable
        onlyFromRouter
    {
        escrow[_account] = escrow[_account].add(msg.value);
    }

    /**
     * @notice Update the amount in escrowTokens of an address with the new value, based on VoucherSet/Voucher interaction
     * @param _token  The address of a token to query
     * @param _account  The address of an account to query
     * @param _newAmount  New amount to be set
     */
    function addEscrowTokensAmount(
        address _token,
        address _account,
        uint256 _newAmount
    ) external override onlyFromRouter {
        escrowTokens[_token][_account] =  escrowTokens[_token][_account].add(_newAmount);
    }

    /**
     * @notice Hook which will be triggered when a _tokenIdVoucher will be transferred. Escrow funds should be allocated to the new owner.
     * @param _from prev owner of the _tokenIdVoucher
     * @param _to next owner of the _tokenIdVoucher
     * @param _tokenIdVoucher _tokenIdVoucher that has been transferred
     */
    function onVoucherTransfer(
        address _from,
        address _to,
        uint256 _tokenIdVoucher
    ) external override nonReentrant onlyVoucherTokenContract {
        address tokenAddress;

        uint256 tokenSupplyId =
            IVoucherKernel(voucherKernel).getIdSupplyFromVoucher(
                _tokenIdVoucher
            );

        PaymentMethod paymentType =
            IVoucherKernel(voucherKernel).getVoucherPaymentMethod(
                tokenSupplyId
            );

        (uint256 price, uint256 depositBu) =
            IVoucherKernel(voucherKernel).getBuyerOrderCosts(tokenSupplyId);

        if (paymentType == PaymentMethod.ETHETH) {
            uint256 totalAmount = price.add(depositBu);

            //Reduce _from escrow amount and increase _to escrow amount
            escrow[_from] = escrow[_from].sub(totalAmount);
            escrow[_to] = escrow[_to].add(totalAmount);
        }

        if (paymentType == PaymentMethod.ETHTKN) {
            //Reduce _from escrow amount and increase _to escrow amount - price
            escrow[_from] = escrow[_from].sub(price);
            escrow[_to] = escrow[_to].add(price);

            tokenAddress = IVoucherKernel(voucherKernel).getVoucherDepositToken(
                tokenSupplyId
            );

            //Reduce _from escrow token amount and increase _to escrow token amount - deposit
            escrowTokens[tokenAddress][_from] = escrowTokens[tokenAddress][_from].sub(depositBu);
            escrowTokens[tokenAddress][_to] = escrowTokens[tokenAddress][_to].add(depositBu);

        }

        if (paymentType == PaymentMethod.TKNETH) {
            tokenAddress = IVoucherKernel(voucherKernel).getVoucherPriceToken(
                tokenSupplyId
            );        

            //Reduce _from escrow token amount and increase _to escrow token amount - price 
            escrowTokens[tokenAddress][_from] = escrowTokens[tokenAddress][_from].sub(price);
            escrowTokens[tokenAddress][_to] = escrowTokens[tokenAddress][_to].add(price);

            //Reduce _from escrow amount and increase _to escrow amount - deposit
            escrow[_from] = escrow[_from].sub(depositBu);
            escrow[_to] = escrow[_to].add(depositBu);
        }

        if (paymentType == PaymentMethod.TKNTKN) {
            tokenAddress = IVoucherKernel(voucherKernel).getVoucherPriceToken(
                tokenSupplyId
            );

            //Reduce _from escrow token amount and increase _to escrow token amount - price 
            escrowTokens[tokenAddress][_from] = escrowTokens[tokenAddress][_from].sub(price);
            escrowTokens[tokenAddress][_to] = escrowTokens[tokenAddress][_to].add(price);

            tokenAddress = IVoucherKernel(voucherKernel).getVoucherDepositToken(
                tokenSupplyId
            );

            //Reduce _from escrow token amount and increase _to escrow token amount - deposit 
            escrowTokens[tokenAddress][_from] = escrowTokens[tokenAddress][_from].sub(depositBu);
            escrowTokens[tokenAddress][_to] = escrowTokens[tokenAddress][_to].add(depositBu);

        }
    }

    /**
     * @notice After the transfer happens the _tokenSupplyId should be updated in the promise. Escrow funds for the seller's deposits (If in ETH) should be allocated to the new owner as well.
     * @param _from prev owner of the _tokenSupplyId
     * @param _to nex owner of the _tokenSupplyId
     * @param _tokenSupplyId _tokenSupplyId for transfer
     * @param _value qty which has been transferred
     */
    function onVoucherSetTransfer(
        address _from,
        address _to,
        uint256 _tokenSupplyId,
        uint256 _value
    ) external override nonReentrant onlyVoucherSetTokenContract {
        PaymentMethod paymentType =
            IVoucherKernel(voucherKernel).getVoucherPaymentMethod(
                _tokenSupplyId
            );

        uint256 depositSe;
        uint256 totalAmount;

        if (paymentType == PaymentMethod.ETHETH || paymentType == PaymentMethod.TKNETH) {
            depositSe = IVoucherKernel(voucherKernel).getSellerDeposit(
                _tokenSupplyId
            );
            totalAmount = depositSe.mul(_value);

            //Reduce _from escrow amount and increase _to escrow amount
            escrow[_from] = escrow[_from].sub(totalAmount);
            escrow[_to] = escrow[_to].add(totalAmount);
        }

        if (paymentType == PaymentMethod.ETHTKN || paymentType == PaymentMethod.TKNTKN) {
            address tokenDepositAddress =
                IVoucherKernel(voucherKernel).getVoucherDepositToken(
                    _tokenSupplyId
                );

            depositSe = IVoucherKernel(voucherKernel).getSellerDeposit(
                _tokenSupplyId
            );
            totalAmount = depositSe.mul(_value);

            //Reduce _from escrow token amount and increase _to escrow token amount - deposit
            escrowTokens[tokenDepositAddress][_from] = escrowTokens[tokenDepositAddress][_from].sub(totalAmount);
            escrowTokens[tokenDepositAddress][_to] = escrowTokens[tokenDepositAddress][_to].add(totalAmount);
        }

        IVoucherKernel(voucherKernel).setSupplyHolderOnTransfer(
            _tokenSupplyId,
            _to
        );
    }

    // // // // // // // //
    // GETTERS
    // // // // // // // //

    /**
     * @notice Get the address of Voucher Kernel contract
     * @return Address of Voucher Kernel contract
     */
    function getVoucherKernelAddress() 
        external 
        view 
        override
        returns (address)
    {
        return voucherKernel;
    }

    /**
     * @notice Get the address of Boson Router contract
     * @return Address of Boson Router contract
     */
    function getBosonRouterAddress() 
        external 
        view 
        override
        returns (address)
    {
        return bosonRouterAddress;
    }

    /**
     * @notice Get the address of the Vouchers token contract, an ERC721 contract
     * @return Address of Vouchers contract
     */
    function getVoucherTokenAddress() 
        external 
        view 
        override
        returns (address)
    {
        return voucherTokenAddress;
    }

    /**
     * @notice Get the address of the VoucherSets token contract, an ERC155 contract
     * @return Address of VoucherSets contract
     */
    function getVoucherSetTokenAddress() 
        external 
        view 
        override
        returns (address)
    {
        return voucherSetTokenAddress;
    }

    /**
     * @notice Ensure whether or not contract has been set to disaster state 
     * @return disasterState
     */
    function isDisasterStateSet() external view override returns(bool) {
        return disasterState;
    }

    /**
     * @notice Get the amount in escrow of an address
     * @param _account  The address of an account to query
     * @return          The balance in escrow
     */
    function getEscrowAmount(address _account)
        external
        view
        override
        returns (uint256)
    {
        return escrow[_account];
    }

    /**
     * @notice Get the amount in escrow of an address
     * @param _token  The address of a token to query
     * @param _account  The address of an account to query
     * @return          The balance in escrow
     */
    function getEscrowTokensAmount(address _token, address _account)
        external
        view
        override
        returns (uint256)
    {
        return escrowTokens[_token][_account];
    }

    /**
     * @notice Set the address of the VoucherKernel contract
     * @param _voucherKernelAddress   The address of the VoucherKernel contract
     */
    function setVoucherKernelAddress(address _voucherKernelAddress)
        external
        override
        onlyOwner
        notZeroAddress(_voucherKernelAddress)
        whenPaused
    {
        voucherKernel = _voucherKernelAddress;

        emit LogVoucherKernelSet(_voucherKernelAddress, msg.sender);
    }
}
        

/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT

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

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

    uint256 private _status;

    constructor () {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and 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;
    }
}
          

/SafeERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.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");
        }
    }
}
          

/IERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.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);
}
          

/Pausable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "./Context.sol";

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

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

    bool private _paused;

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

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

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

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

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

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

/Ownable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

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

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

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

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

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

/Context.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with 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;
    }
}
          

/Address.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

        uint256 size;
        // 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");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

/SafeMath.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.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, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

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

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

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

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

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        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) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        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, reverting 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) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

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

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

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * 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);
        return a / b;
    }

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

/IVoucherKernel.sol

// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity 0.7.6;

import "./../UsingHelpers.sol";

interface IVoucherKernel {
    /**
     * @notice Pause the process of interaction with voucherID's (ERC-721), in case of emergency.
     * Only Cashier contract is in control of this function.
     */
    function pause() external;

    /**
     * @notice Unpause the process of interaction with voucherID's (ERC-721).
     * Only Cashier contract is in control of this function.
     */
    function unpause() external;

    /**
     * @notice Creating a new promise for goods or services.
     * Can be reused, e.g. for making different batches of these (but not in prototype).
     * @param _seller      seller of the promise
     * @param _validFrom   Start of valid period
     * @param _validTo     End of valid period
     * @param _price       Price (payment amount)
     * @param _depositSe   Seller's deposit
     * @param _depositBu   Buyer's deposit
     */
    function createTokenSupplyId(
        address _seller,
        uint256 _validFrom,
        uint256 _validTo,
        uint256 _price,
        uint256 _depositSe,
        uint256 _depositBu,
        uint256 _quantity
    ) external returns (uint256);

    /**
     * @notice Creates a Payment method struct recording the details on how the seller requires to receive Price and Deposits for a certain Voucher Set.
     * @param _tokenIdSupply     _tokenIdSupply of the voucher set this is related to
     * @param _paymentMethod  might be ETHETH, ETHTKN, TKNETH or TKNTKN
     * @param _tokenPrice   token address which will hold the funds for the price of the voucher
     * @param _tokenDeposits   token address which will hold the funds for the deposits of the voucher
     */
    function createPaymentMethod(
        uint256 _tokenIdSupply,
        PaymentMethod _paymentMethod,
        address _tokenPrice,
        address _tokenDeposits
    ) external;

    /**
     * @notice Mark voucher token that the payment was released
     * @param _tokenIdVoucher   ID of the voucher token
     */
    function setPaymentReleased(uint256 _tokenIdVoucher) external;

    /**
     * @notice Mark voucher token that the deposits were released
     * @param _tokenIdVoucher   ID of the voucher token
     * @param _to               recipient, one of {ISSUER, HOLDER, POOL}
     * @param _amount           amount that was released in the transaction
     */
    function setDepositsReleased(
        uint256 _tokenIdVoucher,
        Entity _to,
        uint256 _amount
    ) external;

    /**
     * @notice Tells if part of the deposit, belonging to entity, was released already
     * @param _tokenIdVoucher   ID of the voucher token
     * @param _to               recipient, one of {ISSUER, HOLDER, POOL}
     */
    function isDepositReleased(uint256 _tokenIdVoucher, Entity _to)
        external
        returns (bool);

    /**
     * @notice Redemption of the vouchers promise
     * @param _tokenIdVoucher   ID of the voucher
     * @param _messageSender owner of the voucher
     */
    function redeem(uint256 _tokenIdVoucher, address _messageSender) external;

    /**
     * @notice Refunding a voucher
     * @param _tokenIdVoucher   ID of the voucher
     * @param _messageSender owner of the voucher
     */
    function refund(uint256 _tokenIdVoucher, address _messageSender) external;

    /**
     * @notice Issue a complain for a voucher
     * @param _tokenIdVoucher   ID of the voucher
     * @param _messageSender owner of the voucher
     */
    function complain(uint256 _tokenIdVoucher, address _messageSender) external;

    /**
     * @notice Cancel/Fault transaction by the Seller, admitting to a fault or backing out of the deal
     * @param _tokenIdVoucher   ID of the voucher
     * @param _messageSender owner of the voucher set (seller)
     */
    function cancelOrFault(uint256 _tokenIdVoucher, address _messageSender)
        external;

    /**
     * @notice Cancel/Fault transaction by the Seller, cancelling the remaining uncommitted voucher set so that seller prevents buyers from committing to vouchers for items no longer in exchange.
     * @param _tokenIdSupply   ID of the voucher
     * @param _issuer   owner of the voucher
     */
    function cancelOrFaultVoucherSet(uint256 _tokenIdSupply, address _issuer)
        external
        returns (uint256);

    /**
     * @notice Fill Voucher Order, iff funds paid, then extract & mint NFT to the voucher holder
     * @param _tokenIdSupply   ID of the supply token (ERC-1155)
     * @param _issuer          Address of the token's issuer
     * @param _holder          Address of the recipient of the voucher (ERC-721)
     * @param _paymentMethod   method being used for that particular order that needs to be fulfilled
     */
    function fillOrder(
        uint256 _tokenIdSupply,
        address _issuer,
        address _holder,
        PaymentMethod _paymentMethod
    ) external;

    /**
     * @notice Mark voucher token as expired
     * @param _tokenIdVoucher   ID of the voucher token
     */
    function triggerExpiration(uint256 _tokenIdVoucher) external;

    /**
     * @notice Mark voucher token to the final status
     * @param _tokenIdVoucher   ID of the voucher token
     */
    function triggerFinalizeVoucher(uint256 _tokenIdVoucher) external;

    /**
     * @notice Set the address of the new holder of a _tokenIdSupply on transfer
     * @param _tokenIdSupply   _tokenIdSupply which will be transferred
     * @param _newSeller   new holder of the supply
     */
    function setSupplyHolderOnTransfer(
        uint256 _tokenIdSupply,
        address _newSeller
    ) external;

    /**
     * @notice Set the general cancelOrFault period, should be used sparingly as it has significant consequences. Here done simply for demo purposes.
     * @param _cancelFaultPeriod   the new value for cancelOrFault period (in number of seconds)
     */
    function setCancelFaultPeriod(uint256 _cancelFaultPeriod) external;

    /**
     * @notice Set the address of the Boson Router contract
     * @param _bosonRouterAddress   The address of the BR contract
     */
    function setBosonRouterAddress(address _bosonRouterAddress) external;

    /**
     * @notice Set the address of the Cashier contract
     * @param _cashierAddress   The address of the Cashier contract
     */
    function setCashierAddress(address _cashierAddress) external;

    /**
     * @notice Set the address of the Vouchers token contract, an ERC721 contract
     * @param _voucherTokenAddress   The address of the Vouchers token contract
     */
    function setVoucherTokenAddress(address _voucherTokenAddress) external;

    /**
     * @notice Set the address of the Voucher Sets token contract, an ERC1155 contract
     * @param _voucherSetTokenAddress   The address of the Voucher Sets token contract
     */
    function setVoucherSetTokenAddress(address _voucherSetTokenAddress)
        external;

    /**
     * @notice Set the general complain period, should be used sparingly as it has significant consequences. Here done simply for demo purposes.
     * @param _complainPeriod   the new value for complain period (in number of seconds)
     */
    function setComplainPeriod(uint256 _complainPeriod) external;

    /**
     * @notice Get the promise ID at specific index
     * @param _idx  Index in the array of promise keys
     * @return      Promise ID
     */
    function getPromiseKey(uint256 _idx) external view returns (bytes32);

    /**
     * @notice Get the address of the token where the price for the supply is held
     * @param _tokenIdSupply   ID of the voucher token
     * @return                  Address of the token
     */
    function getVoucherPriceToken(uint256 _tokenIdSupply)
        external
        view
        returns (address);

    /**
     * @notice Get the address of the token where the deposits for the supply are held
     * @param _tokenIdSupply   ID of the voucher token
     * @return                  Address of the token
     */
    function getVoucherDepositToken(uint256 _tokenIdSupply)
        external
        view
        returns (address);

    /**
     * @notice Get Buyer costs required to make an order for a supply token
     * @param _tokenIdSupply   ID of the supply token
     * @return                  returns a tuple (Payment amount, Buyer's deposit)
     */
    function getBuyerOrderCosts(uint256 _tokenIdSupply)
        external
        view
        returns (uint256, uint256);

    /**
     * @notice Get Seller deposit
     * @param _tokenIdSupply   ID of the supply token
     * @return                  returns sellers deposit
     */
    function getSellerDeposit(uint256 _tokenIdSupply)
        external
        view
        returns (uint256);

    /**
     * @notice Get the promise ID from a voucher token
     * @param _tokenIdVoucher   ID of the voucher token
     * @return                  ID of the promise
     */
    function getIdSupplyFromVoucher(uint256 _tokenIdVoucher)
        external
        pure
        returns (uint256);

    /**
     * @notice Get the promise ID from a voucher token
     * @param _tokenIdVoucher   ID of the voucher token
     * @return                  ID of the promise
     */
    function getPromiseIdFromVoucherId(uint256 _tokenIdVoucher)
        external
        view
        returns (bytes32);

    /**
     * @notice Get all necessary funds for a supply token
     * @param _tokenIdSupply   ID of the supply token
     * @return                  returns a tuple (Payment amount, Seller's deposit, Buyer's deposit)
     */
    function getOrderCosts(uint256 _tokenIdSupply)
        external
        view
        returns (
            uint256,
            uint256,
            uint256
        );

    /**
     * @notice Get the remaining quantity left in supply of tokens (e.g ERC-721 left in ERC-1155) of an account
     * @param _tokenSupplyId  Token supply ID
     * @param _owner    holder of the Token Supply
     * @return          remaining quantity
     */
    function getRemQtyForSupply(uint256 _tokenSupplyId, address _owner)
        external
        view
        returns (uint256);

    /**
     * @notice Get the payment method for a particular _tokenIdSupply
     * @param _tokenIdSupply   ID of the voucher supply token
     * @return                  payment method
     */
    function getVoucherPaymentMethod(uint256 _tokenIdSupply)
        external
        view
        returns (PaymentMethod);

    /**
     * @notice Get the current status of a voucher
     * @param _tokenIdVoucher   ID of the voucher token
     * @return                  Status of the voucher (via enum)
     */
    function getVoucherStatus(uint256 _tokenIdVoucher)
        external
        view
        returns (
            uint8,
            bool,
            bool,
            uint256,
            uint256
        );

    /**
     * @notice Get the holder of a supply
     * @param _tokenIdSupply    _tokenIdSupply ID of the order (aka VoucherSet) which is mapped to the corresponding Promise.
     * @return                  Address of the holder
     */
    function getSupplyHolder(uint256 _tokenIdSupply)
        external
        view
        returns (address);

    /**
     * @notice Get the issuer of a voucher
     * @param _voucherTokenId ID of the voucher token
     * @return                Address of the seller, when voucher was created
     */
    function getVoucherSeller(uint256 _voucherTokenId)
        external
        view
        returns (address);

    /**
     * @notice Get the holder of a voucher
     * @param _tokenIdVoucher   ID of the voucher token
     * @return                  Address of the holder
     */
    function getVoucherHolder(uint256 _tokenIdVoucher)
        external
        view
        returns (address);

    /**
     * @notice Checks whether a voucher is in valid period for redemption (between start date and end date)
     * @param _tokenIdVoucher ID of the voucher token
     */
    function isInValidityPeriod(uint256 _tokenIdVoucher)
        external
        view
        returns (bool);

    /**
     * @notice Checks whether a voucher is in valid state to be transferred. If either payments or deposits are released, voucher could not be transferred
     * @param _tokenIdVoucher ID of the voucher token
     */
    function isVoucherTransferable(uint256 _tokenIdVoucher)
        external
        view
        returns (bool);

    /**
     * @notice Get address of the Boson Router contract to which this contract points
     * @return Address of the Boson Router contract
     */
    function getBosonRouterAddress() external view returns (address);

    /**
     * @notice Get address of the Cashier contract to which this contract points
     * @return Address of the Cashier contract
     */
    function getCashierAddress() external view returns (address);

    /**
     * @notice Get the token nonce for a seller
     * @param _seller Address of the seller
     * @return The seller's
     */
    function getTokenNonce(address _seller) external view returns (uint256);

    /**
     * @notice Get the current type Id
     * @return type Id
     */
    function getTypeId() external view returns (uint256);

    /**
     * @notice Get the complain period
     * @return complain period
     */
    function getComplainPeriod() external view returns (uint256);

    /**
     * @notice Get the cancel or fault period
     * @return cancel or fault period
     */
    function getCancelFaultPeriod() external view returns (uint256);

    /**
     * @notice Get promise data not retrieved by other accessor functions
     * @param _promiseKey   ID of the promise
     * @return promise data not returned by other accessor methods
     */
    function getPromiseData(bytes32 _promiseKey)
        external
        view
        returns (
            bytes32,
            uint256,
            uint256,
            uint256,
            uint256
        );

    /**
     * @notice Get the promise ID from a voucher set
     * @param _tokenIdSupply   ID of the voucher token
     * @return                  ID of the promise
     */
    function getPromiseIdFromSupplyId(uint256 _tokenIdSupply)
        external
        view
        returns (bytes32);

    /**
     * @notice Get the address of the Vouchers token contract, an ERC721 contract
     * @return Address of Vouchers contract
     */
    function getVoucherTokenAddress() external view returns (address);

    /**
     * @notice Get the address of the VoucherSets token contract, an ERC155 contract
     * @return Address of VoucherSets contract
     */
    function getVoucherSetTokenAddress() external view returns (address);
}
          

/ICashier.sol

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

pragma solidity 0.7.6;

import "./../UsingHelpers.sol";

interface ICashier {
    /**
     * @notice Pause the Cashier && the Voucher Kernel contracts in case of emergency.
     * All functions related to creating new batch, requestVoucher or withdraw will be paused, hence cannot be executed.
     * There is special function for withdrawing funds if contract is paused.
     */
    function pause() external;

    /**
     * @notice Unpause the Cashier && the Voucher Kernel contracts.
     * All functions related to creating new batch, requestVoucher or withdraw will be unpaused.
     */
    function unpause() external;

    function canUnpause() external view returns (bool);

    /**
     * @notice Trigger withdrawals of what funds are releasable
     * The caller of this function triggers transfers to all involved entities (pool, issuer, token holder), also paying for gas.
     * @dev This function would be optimized a lot, here verbose for readability.
     * @param _tokenIdVoucher  ID of a voucher token (ERC-721) to try withdraw funds from
     */
    function withdraw(uint256 _tokenIdVoucher) external;

    function withdrawSingle(uint256 _tokenIdVoucher, Entity _to) external;

    /**
     * @notice External function for withdrawing deposits. Caller must be the seller of the goods, otherwise reverts.
     * @notice Seller triggers withdrawals of remaining deposits for a given supply, in case the voucher set is no longer in exchange.
     * @param _tokenIdSupply an ID of a supply token (ERC-1155) which will be burned and deposits will be returned for
     * @param _burnedQty burned quantity that the deposits should be withdrawn for
     * @param _messageSender owner of the voucher set
     */
    function withdrawDepositsSe(
        uint256 _tokenIdSupply,
        uint256 _burnedQty,
        address payable _messageSender
    ) external;

    /**
     * @notice Get the amount in escrow of an address
     * @param _account  The address of an account to query
     * @return          The balance in escrow
     */
    function getEscrowAmount(address _account) external view returns (uint256);

    /**
     * @notice Update the amount in escrow of an address with the new value, based on VoucherSet/Voucher interaction
     * @param _account  The address of an account to query
     */
    function addEscrowAmount(address _account) external payable;

    /**
     * @notice Update the amount in escrowTokens of an address with the new value, based on VoucherSet/Voucher interaction
     * @param _token  The address of a token to query
     * @param _account  The address of an account to query
     * @param _newAmount  New amount to be set
     */
    function addEscrowTokensAmount(
        address _token,
        address _account,
        uint256 _newAmount
    ) external;

    /**
     * @notice Hook which will be triggered when a _tokenIdVoucher will be transferred. Escrow funds should be allocated to the new owner.
     * @param _from prev owner of the _tokenIdVoucher
     * @param _to next owner of the _tokenIdVoucher
     * @param _tokenIdVoucher _tokenIdVoucher that has been transferred
     */
    function onVoucherTransfer(
        address _from,
        address _to,
        uint256 _tokenIdVoucher
    ) external;

    /**
     * @notice After the transfer happens the _tokenSupplyId should be updated in the promise. Escrow funds for the deposits (If in ETH) should be allocated to the new owner as well.
     * @param _from prev owner of the _tokenSupplyId
     * @param _to next owner of the _tokenSupplyId
     * @param _tokenSupplyId _tokenSupplyId for transfer
     * @param _value qty which has been transferred
     */
    function onVoucherSetTransfer(
        address _from,
        address _to,
        uint256 _tokenSupplyId,
        uint256 _value
    ) external;

    /**
     * @notice Get the address of Voucher Kernel contract
     * @return Address of Voucher Kernel contract
     */
    function getVoucherKernelAddress() external view returns (address);

    /**
     * @notice Get the address of Boson Router contract
     * @return Address of Boson Router contract
     */
    function getBosonRouterAddress() external view returns (address);

    /**
     * @notice Get the address of the Vouchers contract, an ERC721 contract
     * @return Address of Vouchers contract
     */
    function getVoucherTokenAddress() external view returns (address);

    /**
     * @notice Get the address of the VoucherSets token contract, an ERC155 contract
     * @return Address of VoucherSets contract
     */
    function getVoucherSetTokenAddress() external view returns (address);

    /**
     * @notice Ensure whether or not contract has been set to disaster state
     * @return disasterState
     */
    function isDisasterStateSet() external view returns (bool);

    /**
     * @notice Get the amount in escrow of an address
     * @param _token  The address of a token to query
     * @param _account  The address of an account to query
     * @return          The balance in escrow
     */
    function getEscrowTokensAmount(address _token, address _account)
        external
        view
        returns (uint256);

    /**
     * @notice Set the address of the BR contract
     * @param _bosonRouterAddress   The address of the Cashier contract
     */
    function setBosonRouterAddress(address _bosonRouterAddress) external;

    /**
     * @notice Set the address of the VoucherKernel contract
     * @param _voucherKernelAddress   The address of the VoucherKernel contract
     */
    function setVoucherKernelAddress(address _voucherKernelAddress) external;

    /**
     * @notice Set the address of the Vouchers token contract, an ERC721 contract
     * @param _voucherTokenAddress   The address of the Vouchers token contract
     */
    function setVoucherTokenAddress(address _voucherTokenAddress) external;

    /**
     * @notice Set the address of the Voucher Sets token contract, an ERC1155 contract
     * @param _voucherSetTokenAddress   The address of the Voucher Sets token contract
     */
    function setVoucherSetTokenAddress(address _voucherSetTokenAddress)
        external;
}
          

/UsingHelpers.sol

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

pragma solidity 0.7.6;

// Those are the payment methods we are using throughout the system.
// Depending on how to user choose to interact with it's funds we store the method, so we could distribute its tokens afterwise
enum PaymentMethod {
    ETHETH,
    ETHTKN,
    TKNETH,
    TKNTKN
}

enum Entity {ISSUER, HOLDER, POOL}

enum VoucherState {FINAL, CANCEL_FAULT, COMPLAIN, EXPIRE, REFUND, REDEEM, COMMIT}
/*  Status of the voucher in 8 bits:
    [6:COMMITTED] [5:REDEEMED] [4:REFUNDED] [3:EXPIRED] [2:COMPLAINED] [1:CANCELORFAULT] [0:FINAL]
*/

enum Condition {NOT_SET, BALANCE, OWNERSHIP} //Describes what kind of condition must be met for a conditional commit

struct ConditionalCommitInfo {
    uint256 conditionalTokenId;
    uint256 threshold;
    Condition condition;
    address gateAddress;
    bool registerConditionalCommit;
}

uint8 constant ONE = 1;

struct VoucherDetails {
    uint256 tokenIdSupply;
    uint256 tokenIdVoucher;
    address issuer;
    address holder;
    uint256 price;
    uint256 depositSe;
    uint256 depositBu;
    PaymentMethod paymentMethod;
    VoucherStatus currStatus;
}

struct VoucherStatus {
    address seller;
    uint8 status;
    bool isPaymentReleased;
    bool isDepositsReleased;
    DepositsReleased depositReleased;
    uint256 complainPeriodStart;
    uint256 cancelFaultPeriodStart;
}

struct DepositsReleased {
    uint8 status;
    uint248 releasedAmount;
}

/**
    * @notice Based on its lifecycle, voucher can have many different statuses. Checks whether a voucher is in Committed state.
    * @param _status current status of a voucher.
    */
function isStateCommitted(uint8 _status) pure returns (bool) {
    return _status == determineStatus(0, VoucherState.COMMIT);
}

/**
    * @notice Based on its lifecycle, voucher can have many different statuses. Checks whether a voucher is in RedemptionSigned state.
    * @param _status current status of a voucher.
    */
function isStateRedemptionSigned(uint8 _status)
    pure
    returns (bool)
{
    return _status == determineStatus(determineStatus(0, VoucherState.COMMIT), VoucherState.REDEEM);
}

/**
    * @notice Based on its lifecycle, voucher can have many different statuses. Checks whether a voucher is in Refunded state.
    * @param _status current status of a voucher.
    */
function isStateRefunded(uint8 _status) pure returns (bool) {
    return _status == determineStatus(determineStatus(0, VoucherState.COMMIT), VoucherState.REFUND);
}

/**
    * @notice Based on its lifecycle, voucher can have many different statuses. Checks whether a voucher is in Expired state.
    * @param _status current status of a voucher.
    */
function isStateExpired(uint8 _status) pure returns (bool) {
    return _status == determineStatus(determineStatus(0, VoucherState.COMMIT), VoucherState.EXPIRE);
}

/**
    * @notice Based on its lifecycle, voucher can have many different statuses. Checks the current status a voucher is at.
    * @param _status current status of a voucher.
    * @param _idx status to compare.
    */
function isStatus(uint8 _status, VoucherState _idx) pure returns (bool) {
    return (_status >> uint8(_idx)) & ONE == 1;
}

/**
    * @notice Set voucher status.
    * @param _status previous status.
    * @param _changeIdx next status.
    */
function determineStatus(uint8 _status, VoucherState _changeIdx)
    pure
    returns (uint8)
{
    return _status | (ONE << uint8(_changeIdx));
}
          

Compiler Settings

{"remappings":[],"optimizer":{"runs":200,"enabled":true},"metadata":{"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"istanbul","compilationTarget":{"contracts/Cashier.sol":"Cashier"}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_bosonRouterAddress","internalType":"address"},{"type":"address","name":"_voucherKernel","internalType":"address"},{"type":"address","name":"_voucherSetTokenAddress","internalType":"address"},{"type":"address","name":"_voucherTokenAddress","internalType":"address"}]},{"type":"event","name":"LogAmountDistribution","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256","indexed":true},{"type":"address","name":"_to","internalType":"address","indexed":false},{"type":"uint256","name":"_payment","internalType":"uint256","indexed":false},{"type":"uint8","name":"_type","internalType":"enum Cashier.PaymentType","indexed":false}],"anonymous":false},{"type":"event","name":"LogBosonRouterSet","inputs":[{"type":"address","name":"_newBosonRouter","internalType":"address","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogDisasterStateSet","inputs":[{"type":"bool","name":"_disasterState","internalType":"bool","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogVoucherKernelSet","inputs":[{"type":"address","name":"_newVoucherKernel","internalType":"address","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogVoucherSetTokenContractSet","inputs":[{"type":"address","name":"_newTokenContract","internalType":"address","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogVoucherTokenContractSet","inputs":[{"type":"address","name":"_newTokenContract","internalType":"address","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogWithdrawEthOnDisaster","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogWithdrawTokensOnDisaster","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false},{"type":"address","name":"_tokenAddress","internalType":"address","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogWithdrawal","inputs":[{"type":"address","name":"_caller","internalType":"address","indexed":false},{"type":"address","name":"_payee","internalType":"address","indexed":false},{"type":"uint256","name":"_payment","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"payable","outputs":[],"name":"addEscrowAmount","inputs":[{"type":"address","name":"_account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addEscrowTokensAmount","inputs":[{"type":"address","name":"_token","internalType":"address"},{"type":"address","name":"_account","internalType":"address"},{"type":"uint256","name":"_newAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"canUnpause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getBosonRouterAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getEscrowAmount","inputs":[{"type":"address","name":"_account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getEscrowTokensAmount","inputs":[{"type":"address","name":"_token","internalType":"address"},{"type":"address","name":"_account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getVoucherKernelAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getVoucherSetTokenAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getVoucherTokenAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isDisasterStateSet","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"onVoucherSetTransfer","inputs":[{"type":"address","name":"_from","internalType":"address"},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_tokenSupplyId","internalType":"uint256"},{"type":"uint256","name":"_value","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"onVoucherTransfer","inputs":[{"type":"address","name":"_from","internalType":"address"},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBosonRouterAddress","inputs":[{"type":"address","name":"_bosonRouterAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDisasterState","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setVoucherKernelAddress","inputs":[{"type":"address","name":"_voucherKernelAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setVoucherSetTokenAddress","inputs":[{"type":"address","name":"_voucherSetTokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setVoucherTokenAddress","inputs":[{"type":"address","name":"_voucherTokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawDepositsSe","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"},{"type":"uint256","name":"_burnedQty","internalType":"uint256"},{"type":"address","name":"_messageSender","internalType":"address payable"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawEthOnDisaster","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawSingle","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"},{"type":"uint8","name":"_to","internalType":"enum Entity"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawTokensOnDisaster","inputs":[{"type":"address","name":"_token","internalType":"address"}]}]
              

Contract Creation Code

0x60806040523480156200001157600080fd5b506040516200459238038062004592833981810160405260808110156200003757600080fd5b5080516020820151604083015160609093015160016000908155929391926200005f6200031a565b600180546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001805460ff60a01b19169055836001600160a01b038116620000fc576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b836001600160a01b0381166200013e576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b836001600160a01b03811662000180576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b836001600160a01b038116620001c2576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600380546001600160a01b03808b166001600160a01b03199283168117909355600280548b8316908416179055600480548a831690841617905560058054918916919092161790556040805191825233602083015280517fac81fe7dd460bb5162a4a7d8fb92a13bd2baf450914fc6b1c4cc3180eba55af09281900390910190a1604080516001600160a01b038916815233602082015281517f94d4208cb05337821fef5da6205084b70818af988524d8a2609a53a1ac1033d1929181900390910190a1604080516001600160a01b038816815233602082015281517f44c64b6c77fcb5df7b63c64b6346b9674961739187051adbf249bf8133974cad929181900390910190a1604080516001600160a01b038716815233602082015281517fb54ffecf5d152884be12f7742b1a1f9e4baa17fc9e2e9586546450645a59a38d929181900390910190a150505050505050506200031e565b3390565b614264806200032e6000396000f3fe6080604052600436106101b75760003560e01c80638da5cb5b116100ec578063c5e0a9bb1161008a578063d95be43a11610064578063d95be43a14610594578063e13f44bf146105c7578063e3f5d2d5146105fa578063f2fde38b1461060f576101b7565b8063c5e0a9bb146104e5578063c8b186c91461052e578063d135836514610561576101b7565b8063a98af766116100c6578063a98af76614610437578063ae04884e1461046a578063b3b3baa71461047f578063bd17de40146104b2576101b7565b80638da5cb5b146103ca5780639093e03e146103df57806397f9e52a14610422576101b7565b80635321847e116101595780636bac352b116101335780636bac352b14610376578063715018a61461038b5780637c727088146103a05780638456cb59146103b5576101b7565b80635321847e146102f9578063598e2e0c146103385780635c975abb14610361576101b7565b80632e1a7d4d116101955780632e1a7d4d14610274578063352c00f51461029e57806336a166f6146102cf5780633f4ba83a146102e4576101b7565b80631429dae8146101bc57806319946845146102015780632a95071614610227575b600080fd5b3480156101c857600080fd5b506101ff600480360360608110156101df57600080fd5b506001600160a01b03813581169160208101359091169060400135610642565b005b6101ff6004803603602081101561021757600080fd5b50356001600160a01b03166106f4565b34801561023357600080fd5b506102626004803603604081101561024a57600080fd5b506001600160a01b0381358116916020013516610784565b60408051918252519081900360200190f35b34801561028057600080fd5b506101ff6004803603602081101561029757600080fd5b50356107b1565b3480156102aa57600080fd5b506102b36108d3565b604080516001600160a01b039092168252519081900360200190f35b3480156102db57600080fd5b506101ff6108e2565b3480156102f057600080fd5b506101ff610a45565b34801561030557600080fd5b506101ff6004803603606081101561031c57600080fd5b50803590602081013590604001356001600160a01b0316610aa0565b34801561034457600080fd5b5061034d610ec8565b604080519115158252519081900360200190f35b34801561036d57600080fd5b5061034d610ed8565b34801561038257600080fd5b506102b3610ee8565b34801561039757600080fd5b506101ff610ef7565b3480156103ac57600080fd5b506101ff610fa3565b3480156103c157600080fd5b506101ff61112a565b3480156103d657600080fd5b506102b3611183565b3480156103eb57600080fd5b506101ff6004803603606081101561040257600080fd5b506001600160a01b03813581169160208101359091169060400135611192565b34801561042e57600080fd5b506102b3611970565b34801561044357600080fd5b506101ff6004803603602081101561045a57600080fd5b50356001600160a01b031661197f565b34801561047657600080fd5b5061034d611ac4565b34801561048b57600080fd5b506101ff600480360360208110156104a257600080fd5b50356001600160a01b0316611ad5565b3480156104be57600080fd5b506101ff600480360360208110156104d557600080fd5b50356001600160a01b0316611c1a565b3480156104f157600080fd5b506101ff6004803603608081101561050857600080fd5b506001600160a01b03813581169160208101359091169060408101359060600135611d5f565b34801561053a57600080fd5b506101ff6004803603604081101561055157600080fd5b508035906020013560ff166121c9565b34801561056d57600080fd5b506102626004803603602081101561058457600080fd5b50356001600160a01b03166122b2565b3480156105a057600080fd5b506101ff600480360360208110156105b757600080fd5b50356001600160a01b03166122cd565b3480156105d357600080fd5b506101ff600480360360208110156105ea57600080fd5b50356001600160a01b0316612412565b34801561060657600080fd5b506102b3612616565b34801561061b57600080fd5b506101ff6004803603602081101561063257600080fd5b50356001600160a01b0316612625565b6003546001600160a01b03163314610693576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b6001600160a01b038084166000908152600760209081526040808320938616835292905220546106c39082612728565b6001600160a01b03938416600090815260076020908152604080832095909616825293909352929091209190915550565b6003546001600160a01b03163314610745576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b6001600160a01b0381166000908152600660205260409020546107689034612728565b6001600160a01b03909116600090815260066020526040902055565b6001600160a01b038083166000908152600760209081526040808320938516835292905220545b92915050565b600260005414156107f7576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b6002600055610804610ed8565b15610849576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000610856826000612789565b9050610863826001612789565b8061086b5750805b9050610878826002612789565b806108805750805b9050806108ca576040805162461bcd60e51b81526020600482015260136024820152724e4f5448494e475f544f5f574954484452415760681b604482015290519081900360640190fd5b50506001600055565b6004546001600160a01b031690565b6108ea612cbf565b6001600160a01b03166108fb611183565b6001600160a01b031614610944576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b61094c610ed8565b61098b576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b600554600160a01b900460ff16156109ea576040805162461bcd60e51b815260206004820152601d60248201527f446973617374657220737461746520697320616c726561647920736574000000604482015290519081900360640190fd5b6005805460ff60a01b1916600160a01b90811791829055604080519190920460ff161515815233602082015281517fdf38caf468609827a33cd8703b08fca23e51107a2ad8d4f7587bc0be15a2ee9e929181900390910190a1565b6003546001600160a01b03163314610a96576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b610a9e612cc3565b565b60026000541415610ae6576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b60026000556003546001600160a01b03163314610b3c576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b806001600160a01b038116610b7d576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b60025460408051631f38585f60e01b81526004810187905290516001600160a01b03808616931691631f38585f916024808301926020929190829003018186803b158015610bca57600080fd5b505afa158015610bde573d6000803e3d6000fd5b505050506040513d6020811015610bf457600080fd5b50516001600160a01b031614610c42576040805162461bcd60e51b815260206004820152600e60248201526d2aa720aaaa2427a924ad22a22fab60911b604482015290519081900360640190fd5b60025460408051638810632360e01b81526004810187905290516000926001600160a01b0316916388106323916024808301926020929190829003018186803b158015610c8e57600080fd5b505afa158015610ca2573d6000803e3d6000fd5b505050506040513d6020811015610cb857600080fd5b505190506000610cc88286612d5d565b60025460408051631cf7955d60e01b8152600481018a905290519293506000926001600160a01b0390921691631cf7955d91602480820192602092909190829003018186803b158015610d1a57600080fd5b505afa158015610d2e573d6000803e3d6000fd5b505050506040513d6020811015610d4457600080fd5b505190506000816003811115610d5657fe5b1480610d6d57506002816003811115610d6b57fe5b145b15610daf576001600160a01b038516600090815260066020526040902054610d959083612db6565b6001600160a01b0386166000908152600660205260409020555b6001816003811115610dbd57fe5b1480610dd457506003816003811115610dd257fe5b145b15610eae5760025460408051639a751bbd60e01b8152600481018a905290516000926001600160a01b031691639a751bbd916024808301926020929190829003018186803b158015610e2557600080fd5b505afa158015610e39573d6000803e3d6000fd5b505050506040513d6020811015610e4f57600080fd5b50516001600160a01b038082166000908152600760209081526040808320938b1683529290522054909150610e849084612db6565b6001600160a01b039182166000908152600760209081526040808320948a16835293905291909120555b610eba8583838a612e13565b505060016000555050505050565b600554600160a01b900460ff1690565b600154600160a01b900460ff1690565b6005546001600160a01b031690565b610eff612cbf565b6001600160a01b0316610f10611183565b6001600160a01b031614610f59576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600180546001600160a01b0319169055565b610fab610ed8565b610fea576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b60026000541415611030576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b6002600055600554600160a01b900460ff1661107d5760405162461bcd60e51b81526004018080602001828103825260238152602001806140fb6023913960400191505060405180910390fd5b33600090815260066020526040902054806110ce576040805162461bcd60e51b815260206004820152600c60248201526b455343524f575f454d50545960a01b604482015290519081900360640190fd5b336000818152600660205260408120556110e89082612fde565b6040805182815233602082015281517fb04d37d3296a34ef094bb4da3e1025abae58c3f53fd6b638c1d0174b3a9d509b929181900390910190a1506001600055565b6003546001600160a01b0316331461117b576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b610a9e6130c8565b6001546001600160a01b031690565b600260005414156111d8576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b60026000556005546001600160a01b031633146112265760405162461bcd60e51b81526004018080602001828103825260228152602001806140d96022913960400191505060405180910390fd5b6002546040805163035e54d560e31b815260048101849052905160009283926001600160a01b0390911691631af2a6a891602480820192602092909190829003018186803b15801561127757600080fd5b505afa15801561128b573d6000803e3d6000fd5b505050506040513d60208110156112a157600080fd5b505160025460408051631cf7955d60e01b81526004810184905290519293506000926001600160a01b0390921691631cf7955d91602480820192602092909190829003018186803b1580156112f557600080fd5b505afa158015611309573d6000803e3d6000fd5b505050506040513d602081101561131f57600080fd5b505160025460408051633eb53ba560e21b815260048101869052815193945060009384936001600160a01b03169263fad4ee949260248082019391829003018186803b15801561136e57600080fd5b505afa158015611382573d6000803e3d6000fd5b505050506040513d604081101561139857600080fd5b508051602090910151909250905060008360038111156113b457fe5b14156114365760006113c68383612728565b6001600160a01b038a166000908152600660205260409020549091506113ec9082612db6565b6001600160a01b03808b1660009081526006602052604080822093909355908a168152205461141b9082612728565b6001600160a01b038916600090815260066020526040902055505b600183600381111561144457fe5b14156115ba576001600160a01b03881660009081526006602052604090205461146d9083612db6565b6001600160a01b03808a16600090815260066020526040808220939093559089168152205461149c9083612728565b6001600160a01b03808916600090815260066020908152604091829020939093556002548151639a751bbd60e01b8152600481018990529151921692639a751bbd92602480840193829003018186803b1580156114f857600080fd5b505afa15801561150c573d6000803e3d6000fd5b505050506040513d602081101561152257600080fd5b50516001600160a01b038082166000908152600760209081526040808320938d16835292905220549095506115579082612db6565b6001600160a01b0386811660009081526007602090815260408083208d8516845290915280822093909355908916815220546115939082612728565b6001600160a01b038087166000908152600760209081526040808320938c16835292905220555b60028360038111156115c857fe5b141561173e576002546040805163e875a61360e01b81526004810187905290516001600160a01b039092169163e875a61391602480820192602092909190829003018186803b15801561161a57600080fd5b505afa15801561162e573d6000803e3d6000fd5b505050506040513d602081101561164457600080fd5b50516001600160a01b038082166000908152600760209081526040808320938d16835292905220549095506116799083612db6565b6001600160a01b0386811660009081526007602090815260408083208d8516845290915280822093909355908916815220546116b59083612728565b6001600160a01b0380871660009081526007602090815260408083208c85168452825280832094909455918b168152600690915220546116f59082612db6565b6001600160a01b03808a1660009081526006602052604080822093909355908916815220546117249082612728565b6001600160a01b0388166000908152600660205260409020555b600383600381111561174c57fe5b1415611961576002546040805163e875a61360e01b81526004810187905290516001600160a01b039092169163e875a61391602480820192602092909190829003018186803b15801561179e57600080fd5b505afa1580156117b2573d6000803e3d6000fd5b505050506040513d60208110156117c857600080fd5b50516001600160a01b038082166000908152600760209081526040808320938d16835292905220549095506117fd9083612db6565b6001600160a01b0386811660009081526007602090815260408083208d8516845290915280822093909355908916815220546118399083612728565b6001600160a01b0380871660009081526007602090815260408083208c85168452825291829020939093556002548151639a751bbd60e01b8152600481018990529151921692639a751bbd92602480840193829003018186803b15801561189f57600080fd5b505afa1580156118b3573d6000803e3d6000fd5b505050506040513d60208110156118c957600080fd5b50516001600160a01b038082166000908152600760209081526040808320938d16835292905220549095506118fe9082612db6565b6001600160a01b0386811660009081526007602090815260408083208d85168452909152808220939093559089168152205461193a9082612728565b6001600160a01b038087166000908152600760209081526040808320938c16835292905220555b50506001600055505050505050565b6003546001600160a01b031690565b611987612cbf565b6001600160a01b0316611998611183565b6001600160a01b0316146119e1576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b806001600160a01b038116611a22576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b611a2a610ed8565b611a69576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517f44c64b6c77fcb5df7b63c64b6346b9674961739187051adbf249bf8133974cad9281900390910190a15050565b600554600160a01b900460ff161590565b611add612cbf565b6001600160a01b0316611aee611183565b6001600160a01b031614611b37576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b806001600160a01b038116611b78576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b611b80610ed8565b611bbf576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517fb54ffecf5d152884be12f7742b1a1f9e4baa17fc9e2e9586546450645a59a38d9281900390910190a15050565b611c22612cbf565b6001600160a01b0316611c33611183565b6001600160a01b031614611c7c576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b611c84610ed8565b611cc3576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b806001600160a01b038116611d04576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517fac81fe7dd460bb5162a4a7d8fb92a13bd2baf450914fc6b1c4cc3180eba55af09281900390910190a15050565b60026000541415611da5576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b60026000556004546001600160a01b03163314611df35760405162461bcd60e51b815260040180806020018281038252602681526020018061417e6026913960400191505060405180910390fd5b60025460408051631cf7955d60e01b81526004810185905290516000926001600160a01b031691631cf7955d916024808301926020929190829003018186803b158015611e3f57600080fd5b505afa158015611e53573d6000803e3d6000fd5b505050506040513d6020811015611e6957600080fd5b5051905060008080836003811115611e7d57fe5b1480611e9457506002836003811115611e9257fe5b145b15611f8c5760025460408051638810632360e01b81526004810188905290516001600160a01b0390921691638810632391602480820192602092909190829003018186803b158015611ee557600080fd5b505afa158015611ef9573d6000803e3d6000fd5b505050506040513d6020811015611f0f57600080fd5b50519150611f1d8285612d5d565b6001600160a01b038816600090815260066020526040902054909150611f439082612db6565b6001600160a01b038089166000908152600660205260408082209390935590881681522054611f729082612728565b6001600160a01b0387166000908152600660205260409020555b6001836003811115611f9a57fe5b1480611fb157506003836003811115611faf57fe5b145b1561214e5760025460408051639a751bbd60e01b81526004810188905290516000926001600160a01b031691639a751bbd916024808301926020929190829003018186803b15801561200257600080fd5b505afa158015612016573d6000803e3d6000fd5b505050506040513d602081101561202c57600080fd5b505160025460408051638810632360e01b8152600481018a905290519293506001600160a01b0390911691638810632391602480820192602092909190829003018186803b15801561207d57600080fd5b505afa158015612091573d6000803e3d6000fd5b505050506040513d60208110156120a757600080fd5b505192506120b58386612d5d565b6001600160a01b038083166000908152600760209081526040808320938d16835292905220549092506120e89083612db6565b6001600160a01b0382811660009081526007602090815260408083208d8516845290915280822093909355908916815220546121249083612728565b6001600160a01b039182166000908152600760209081526040808320948b16835293905291909120555b600254604080516388c2560760e01b8152600481018890526001600160a01b038981166024830152915191909216916388c2560791604480830192600092919082900301818387803b1580156121a357600080fd5b505af11580156121b7573d6000803e3d6000fd5b50506001600055505050505050505050565b6002600054141561220f576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b600260005561221c610ed8565b15612261576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b61226b8282612789565b6108ca576040805162461bcd60e51b81526020600482015260136024820152724e4f5448494e475f544f5f574954484452415760681b604482015290519081900360640190fd5b6001600160a01b031660009081526006602052604090205490565b6122d5612cbf565b6001600160a01b03166122e6611183565b6001600160a01b03161461232f576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b806001600160a01b038116612370576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b612378610ed8565b6123b7576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b600280546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517f94d4208cb05337821fef5da6205084b70818af988524d8a2609a53a1ac1033d19281900390910190a15050565b61241a610ed8565b612459576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b6002600054141561249f576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b6002600055806001600160a01b0381166124e5576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600554600160a01b900460ff1661252d5760405162461bcd60e51b81526004018080602001828103825260238152602001806140fb6023913960400191505060405180910390fd5b6001600160a01b038216600090815260076020908152604080832033845290915290205480612592576040805162461bcd60e51b815260206004820152600c60248201526b455343524f575f454d50545960a01b604482015290519081900360640190fd5b6001600160a01b03831660009081526007602090815260408083203380855292528220919091556125c590849083613151565b604080518281526001600160a01b0385166020820152338183015290517f7e5dd3919ea79fc8c93a49edf5656ab20f89df3e419fde48c90a90765f7605a69181900360600190a15050600160005550565b6002546001600160a01b031690565b61262d612cbf565b6001600160a01b031661263e611183565b6001600160a01b031614612687576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b6001600160a01b0381166126cc5760405162461bcd60e51b81526004018080602001828103825260268152602001806140936026913960400191505060405180910390fd5b6001546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b600082820183811015612782576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6000612793613fa9565b836127d6576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b60208082018590526002546040805163035e54d560e31b81526004810188905290516001600160a01b0390921692631af2a6a892602480840193829003018186803b15801561282457600080fd5b505afa158015612838573d6000803e3d6000fd5b505050506040513d602081101561284e57600080fd5b505180825260025460408051631cf7955d60e01b81526004810193909352516001600160a01b0390911691631cf7955d916024808301926020929190829003018186803b15801561289e57600080fd5b505afa1580156128b2573d6000803e3d6000fd5b505050506040513d60208110156128c857600080fd5b505160e082019060038111156128da57fe5b908160038111156128e757fe5b905250600254602082015160408051630c969ea160e21b81526004810192909252516001600160a01b039092169163325a7a849160248082019260a092909190829003018186803b15801561293b57600080fd5b505afa15801561294f573d6000803e3d6000fd5b505050506040513d60a081101561296557600080fd5b5080516020808301516040938401516101008601519015156060828101919091529115158186015260ff90931692909101919091526002548351835163d887b4e760e01b8152600481019190915292516001600160a01b039091169263d887b4e7926024808301939192829003018186803b1580156129e357600080fd5b505afa1580156129f7573d6000803e3d6000fd5b505050506040513d6060811015612a0d57600080fd5b50805160208083015160409384015160c086015260a0850152608084019190915260025482516326efff5360e11b81526004810188905292516001600160a01b0390911692634ddffea6926024808301939192829003018186803b158015612a7457600080fd5b505afa158015612a88573d6000803e3d6000fd5b505050506040513d6020811015612a9e57600080fd5b50516001600160a01b039081166040808401919091526002546020848101518351637baca8e760e11b815260048101919091529251919093169263f75951ce9260248082019391829003018186803b158015612af957600080fd5b505afa158015612b0d573d6000803e3d6000fd5b505050506040513d6020811015612b2357600080fd5b50516001600160a01b0316606082015261010081015160400151600090612b5157612b4e82856131a3565b90505b600280546040516349b3b46560e11b81526004810188815260009384936001600160a01b03169263936768ca928b928b92602401908390811115612b9157fe5b815260200192505050602060405180830381600087803b158015612bb457600080fd5b505af1158015612bc8573d6000803e3d6000fd5b505050506040513d6020811015612bde57600080fd5b5051158015612bfc5750612bfc84610100015160200151600061327a565b15612c1157612c0b84876132a2565b90925090505b8215612c4e57612c4e6000876002811115612c2857fe5b14612c37578460600151612c3d565b84604001515b608086015160e08701518751613442565b8115612cab57612cab6000876002811115612c6557fe5b14612c95576001876002811115612c7857fe5b14612c8a57612c85611183565b612c90565b84606001515b612c9b565b84604001515b828660e001518760000151612e13565b8280612cb45750815b979650505050505050565b3390565b612ccb610ed8565b612d0a576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612d40612cbf565b604080516001600160a01b039092168252519081900360200190a1565b600082612d6c575060006107ab565b82820282848281612d7957fe5b04146127825760405162461bcd60e51b81526004018080602001828103825260218152602001806141a46021913960400191505060405180910390fd5b600082821115612e0d576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b836001600160a01b038116612e54576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b60008411612ea0576040805162461bcd60e51b81526020600482015260146024820152734e4f5f46554e44535f544f5f574954484452415760601b604482015290519081900360640190fd5b6000836003811115612eae57fe5b1480612ec557506002836003811115612ec357fe5b145b15612f2657612edd6001600160a01b03861685612fde565b604080513381526001600160a01b038716602082015280820186905290517f0ec497a8ae5b1ba29c60470ef651def995fac3deebbdcc56c47a4e5f51a4c2bd9181900360600190a15b6001836003811115612f3457fe5b1480612f4b57506003836003811115612f4957fe5b145b15612fd75760025460408051639a751bbd60e01b81526004810185905290516000926001600160a01b031691639a751bbd916024808301926020929190829003018186803b158015612f9c57600080fd5b505afa158015612fb0573d6000803e3d6000fd5b505050506040513d6020811015612fc657600080fd5b50519050612fd5818787613151565b505b5050505050565b80471015613033576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d806000811461307e576040519150601f19603f3d011682016040523d82523d6000602084013e613083565b606091505b50509050806130c35760405162461bcd60e51b815260040180806020018281038252603a81526020018061411e603a913960400191505060405180910390fd5b505050565b6130d0610ed8565b15613115576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612d40612cbf565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526130c390849061357f565b6000808260028111156131b257fe5b1480156131ce57506131ce83610100015160200151600561327a565b156131e6576131de836000613630565b5060016107ab565b60018260028111156131f457fe5b148015613261575061321083610100015160200151600461327a565b8061322a575061322a83610100015160200151600361327a565b80613261575061324483610100015160200151600161327a565b8015613261575061325f83610100015160200151600561327a565b155b15613271576131de836001613630565b50600092915050565b6000600182600681111561328a57fe5b60ff168460ff16901c1660ff16600114905092915050565b6000806132b984610100015160200151600261327a565b156132cf576132c88484613897565b9050613325565b60028360028111156132dd57fe5b14613325576132f684610100015160200151600161327a565b15613305576132c884846139f4565b600083600281111561331357fe5b14156133255761332284613a6a565b90505b61333984610100015160200151600561327a565b80613353575061335384610100015160200151600161327a565b1561338757600183600281111561336657fe5b14156133825761337f61337885613ae7565b8290612728565b90505b6133aa565b600283600281111561339557fe5b14156133aa576133a761337885613b64565b90505b80158015925061343b576002805460208601516040516353a572ed60e11b8152600481018281526001600160a01b039093169363a74ae5da938892879260249091019084908111156133f857fe5b81526020018281526020019350505050600060405180830381600087803b15801561342257600080fd5b505af1158015613436573d6000803e3d6000fd5b505050505b9250929050565b836001600160a01b038116613483576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600083600381111561349157fe5b14806134a8575060018360038111156134a657fe5b145b15613509576134c06001600160a01b03861685612fde565b604080513381526001600160a01b038716602082015280820186905290517f0ec497a8ae5b1ba29c60470ef651def995fac3deebbdcc56c47a4e5f51a4c2bd9181900360600190a15b600283600381111561351757fe5b148061352e5750600383600381111561352c57fe5b145b15612fd7576002546040805163e875a61360e01b81526004810185905290516000926001600160a01b03169163e875a613916024808301926020929190829003018186803b158015612f9c57600080fd5b60006135d4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613bc59092919063ffffffff16565b8051909150156130c3578080602001905160208110156135f357600080fd5b50516130c35760405162461bcd60e51b815260040180806020018281038252602a815260200180614205602a913960400191505060405180910390fd5b60008260e00151600381111561364257fe5b148061365d575060018260e00151600381111561365b57fe5b145b156136ab57608082015160608301516001600160a01b031660009081526006602052604090205461368d91612db6565b60608301516001600160a01b03166000908152600660205260409020555b60028260e0015160038111156136bd57fe5b14806136d8575060038260e0015160038111156136d657fe5b145b156137c35760025482516040805163e875a61360e01b81526004810192909252516000926001600160a01b03169163e875a613916024808301926020929190829003018186803b15801561372b57600080fd5b505afa15801561373f573d6000803e3d6000fd5b505050506040513d602081101561375557600080fd5b505160808401516001600160a01b03808316600090815260076020908152604080832060608a0151909416835292905220549192506137949190612db6565b6001600160a01b0391821660009081526007602090815260408083206060880151909516835293905291909120555b600254602083015160408051633aaa4a8b60e11b81526004810192909252516001600160a01b039092169163755495169160248082019260009290919082900301818387803b15801561381557600080fd5b505af1158015613829573d6000803e3d6000fd5b5050505060208201516000805160206141e5833981519152600083600181111561384f57fe5b1461385e578360600151613864565b83604001515b6080850151604080516001600160a01b039390931683526020830191909152600082820152519081900360600190a25050565b60008060006138b085610100015160200151600161327a565b156139505760a08501516000906138c8906002613bdc565b905060018560028111156138d857fe5b14156138ed578092508560600151915061394a565b60008560028111156138fb57fe5b141561391a5761390c816002613bdc565b92508560400151915061394a565b61393d613928826002613bdc565b60a08801516139379084612db6565b90612db6565b9250613947611183565b91505b50613985565b600284600281111561395e57fe5b141561397a578460a001519150613973611183565b9050613985565b6000925050506107ab565b61399d8560e001518660400151848860000151613c43565b84602001516000805160206141e58339815191528284600160405180846001600160a01b031681526020018381526020018260028111156139da57fe5b8152602001935050505060405180910390a2509392505050565b600080806001846002811115613a0657fe5b1415613a395760a0850151613a2b90613a20906002613bdc565b60a087015190612db6565b915084606001519050613985565b60a0850151613a49906002613bdc565b91508460400151905061399d8560e001518660400151848860000151613c43565b6000613a888260e0015183604001518460a001518560000151613c43565b81602001516000805160206141e583398151915283604001518460a00151600160405180846001600160a01b03168152602001838152602001826002811115613acd57fe5b8152602001935050505060405180910390a25060a0015190565b6000613b058260e0015183606001518460c001518560000151613c43565b81602001516000805160206141e583398151915283606001518460c00151600260405180846001600160a01b03168152602001838152602001826002811115613b4a57fe5b8152602001935050505060405180910390a25060c0015190565b6000613b828260e0015183606001518460c001518560000151613c43565b81602001516000805160206141e5833981519152613b9e611183565b60c0850151604080516001600160a01b038416815260208101839052600291810182613b4a565b6060613bd48484600085613daf565b949350505050565b6000808211613c32576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381613c3b57fe5b049392505050565b6000846003811115613c5157fe5b1480613c6857506002846003811115613c6657fe5b145b15613caa576001600160a01b038316600090815260066020526040902054613c909083612db6565b6001600160a01b0384166000908152600660205260409020555b6001846003811115613cb857fe5b1480613ccf57506003846003811115613ccd57fe5b145b15613da95760025460408051639a751bbd60e01b81526004810184905290516000926001600160a01b031691639a751bbd916024808301926020929190829003018186803b158015613d2057600080fd5b505afa158015613d34573d6000803e3d6000fd5b505050506040513d6020811015613d4a57600080fd5b50516001600160a01b03808216600090815260076020908152604080832093891683529290522054909150613d7f9084612db6565b6001600160a01b039182166000908152600760209081526040808320948816835293905291909120555b50505050565b606082471015613df05760405162461bcd60e51b81526004018080602001828103825260268152602001806141586026913960400191505060405180910390fd5b613df985613eff565b613e4a576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310613e885780518252601f199092019160209182019101613e69565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613eea576040519150601f19603f3d011682016040523d82523d6000602084013e613eef565b606091505b5091509150612cb4828286613f05565b3b151590565b60608315613f14575081612782565b825115613f245782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613f6e578181015183820152602001613f56565b50505050905090810190601f168015613f9b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b604051806101200160405280600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000600381111561400557fe5b8152602001614012614017565b905290565b6040805160e08101825260008082526020820181905291810182905260608101919091526080810161404761405b565b815260200160008152602001600081525090565b60408051808201909152600080825260208201529056fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c004f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735061757361626c653a206e6f7420706175736564000000000000000000000000554e415554484f52495a45445f564f55434845525f544f4b454e5f414444524553534f776e657220646964206e6f7420616c6c6f77206d616e75616c207769746864726177416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c554e415554484f52495a45445f564f55434845525f5345545f544f4b454e5f41444452455353536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572e6e743e535fe193128a1e1839b7c1f313bb203d9cbb58e4c955d5e9a8a8f0fc25361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220f49ed375208bbfc4ef7345cec450baabcf3ea0491cbedce0adbce63502122d4064736f6c634300070600330000000000000000000000000a393aef6dbcd7e7088acf323f9d28b093b9ab5a00000000000000000000000019c10a47c9356efd0e4377411db627636ee9e3c6000000000000000000000000cf6d79e65c49a93a42dd8c474b46998eea4adec8000000000000000000000000de41a99562ada9ee04d9750c99a91c1181ebd875

Deployed ByteCode

0x6080604052600436106101b75760003560e01c80638da5cb5b116100ec578063c5e0a9bb1161008a578063d95be43a11610064578063d95be43a14610594578063e13f44bf146105c7578063e3f5d2d5146105fa578063f2fde38b1461060f576101b7565b8063c5e0a9bb146104e5578063c8b186c91461052e578063d135836514610561576101b7565b8063a98af766116100c6578063a98af76614610437578063ae04884e1461046a578063b3b3baa71461047f578063bd17de40146104b2576101b7565b80638da5cb5b146103ca5780639093e03e146103df57806397f9e52a14610422576101b7565b80635321847e116101595780636bac352b116101335780636bac352b14610376578063715018a61461038b5780637c727088146103a05780638456cb59146103b5576101b7565b80635321847e146102f9578063598e2e0c146103385780635c975abb14610361576101b7565b80632e1a7d4d116101955780632e1a7d4d14610274578063352c00f51461029e57806336a166f6146102cf5780633f4ba83a146102e4576101b7565b80631429dae8146101bc57806319946845146102015780632a95071614610227575b600080fd5b3480156101c857600080fd5b506101ff600480360360608110156101df57600080fd5b506001600160a01b03813581169160208101359091169060400135610642565b005b6101ff6004803603602081101561021757600080fd5b50356001600160a01b03166106f4565b34801561023357600080fd5b506102626004803603604081101561024a57600080fd5b506001600160a01b0381358116916020013516610784565b60408051918252519081900360200190f35b34801561028057600080fd5b506101ff6004803603602081101561029757600080fd5b50356107b1565b3480156102aa57600080fd5b506102b36108d3565b604080516001600160a01b039092168252519081900360200190f35b3480156102db57600080fd5b506101ff6108e2565b3480156102f057600080fd5b506101ff610a45565b34801561030557600080fd5b506101ff6004803603606081101561031c57600080fd5b50803590602081013590604001356001600160a01b0316610aa0565b34801561034457600080fd5b5061034d610ec8565b604080519115158252519081900360200190f35b34801561036d57600080fd5b5061034d610ed8565b34801561038257600080fd5b506102b3610ee8565b34801561039757600080fd5b506101ff610ef7565b3480156103ac57600080fd5b506101ff610fa3565b3480156103c157600080fd5b506101ff61112a565b3480156103d657600080fd5b506102b3611183565b3480156103eb57600080fd5b506101ff6004803603606081101561040257600080fd5b506001600160a01b03813581169160208101359091169060400135611192565b34801561042e57600080fd5b506102b3611970565b34801561044357600080fd5b506101ff6004803603602081101561045a57600080fd5b50356001600160a01b031661197f565b34801561047657600080fd5b5061034d611ac4565b34801561048b57600080fd5b506101ff600480360360208110156104a257600080fd5b50356001600160a01b0316611ad5565b3480156104be57600080fd5b506101ff600480360360208110156104d557600080fd5b50356001600160a01b0316611c1a565b3480156104f157600080fd5b506101ff6004803603608081101561050857600080fd5b506001600160a01b03813581169160208101359091169060408101359060600135611d5f565b34801561053a57600080fd5b506101ff6004803603604081101561055157600080fd5b508035906020013560ff166121c9565b34801561056d57600080fd5b506102626004803603602081101561058457600080fd5b50356001600160a01b03166122b2565b3480156105a057600080fd5b506101ff600480360360208110156105b757600080fd5b50356001600160a01b03166122cd565b3480156105d357600080fd5b506101ff600480360360208110156105ea57600080fd5b50356001600160a01b0316612412565b34801561060657600080fd5b506102b3612616565b34801561061b57600080fd5b506101ff6004803603602081101561063257600080fd5b50356001600160a01b0316612625565b6003546001600160a01b03163314610693576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b6001600160a01b038084166000908152600760209081526040808320938616835292905220546106c39082612728565b6001600160a01b03938416600090815260076020908152604080832095909616825293909352929091209190915550565b6003546001600160a01b03163314610745576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b6001600160a01b0381166000908152600660205260409020546107689034612728565b6001600160a01b03909116600090815260066020526040902055565b6001600160a01b038083166000908152600760209081526040808320938516835292905220545b92915050565b600260005414156107f7576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b6002600055610804610ed8565b15610849576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000610856826000612789565b9050610863826001612789565b8061086b5750805b9050610878826002612789565b806108805750805b9050806108ca576040805162461bcd60e51b81526020600482015260136024820152724e4f5448494e475f544f5f574954484452415760681b604482015290519081900360640190fd5b50506001600055565b6004546001600160a01b031690565b6108ea612cbf565b6001600160a01b03166108fb611183565b6001600160a01b031614610944576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b61094c610ed8565b61098b576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b600554600160a01b900460ff16156109ea576040805162461bcd60e51b815260206004820152601d60248201527f446973617374657220737461746520697320616c726561647920736574000000604482015290519081900360640190fd5b6005805460ff60a01b1916600160a01b90811791829055604080519190920460ff161515815233602082015281517fdf38caf468609827a33cd8703b08fca23e51107a2ad8d4f7587bc0be15a2ee9e929181900390910190a1565b6003546001600160a01b03163314610a96576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b610a9e612cc3565b565b60026000541415610ae6576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b60026000556003546001600160a01b03163314610b3c576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b806001600160a01b038116610b7d576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b60025460408051631f38585f60e01b81526004810187905290516001600160a01b03808616931691631f38585f916024808301926020929190829003018186803b158015610bca57600080fd5b505afa158015610bde573d6000803e3d6000fd5b505050506040513d6020811015610bf457600080fd5b50516001600160a01b031614610c42576040805162461bcd60e51b815260206004820152600e60248201526d2aa720aaaa2427a924ad22a22fab60911b604482015290519081900360640190fd5b60025460408051638810632360e01b81526004810187905290516000926001600160a01b0316916388106323916024808301926020929190829003018186803b158015610c8e57600080fd5b505afa158015610ca2573d6000803e3d6000fd5b505050506040513d6020811015610cb857600080fd5b505190506000610cc88286612d5d565b60025460408051631cf7955d60e01b8152600481018a905290519293506000926001600160a01b0390921691631cf7955d91602480820192602092909190829003018186803b158015610d1a57600080fd5b505afa158015610d2e573d6000803e3d6000fd5b505050506040513d6020811015610d4457600080fd5b505190506000816003811115610d5657fe5b1480610d6d57506002816003811115610d6b57fe5b145b15610daf576001600160a01b038516600090815260066020526040902054610d959083612db6565b6001600160a01b0386166000908152600660205260409020555b6001816003811115610dbd57fe5b1480610dd457506003816003811115610dd257fe5b145b15610eae5760025460408051639a751bbd60e01b8152600481018a905290516000926001600160a01b031691639a751bbd916024808301926020929190829003018186803b158015610e2557600080fd5b505afa158015610e39573d6000803e3d6000fd5b505050506040513d6020811015610e4f57600080fd5b50516001600160a01b038082166000908152600760209081526040808320938b1683529290522054909150610e849084612db6565b6001600160a01b039182166000908152600760209081526040808320948a16835293905291909120555b610eba8583838a612e13565b505060016000555050505050565b600554600160a01b900460ff1690565b600154600160a01b900460ff1690565b6005546001600160a01b031690565b610eff612cbf565b6001600160a01b0316610f10611183565b6001600160a01b031614610f59576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600180546001600160a01b0319169055565b610fab610ed8565b610fea576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b60026000541415611030576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b6002600055600554600160a01b900460ff1661107d5760405162461bcd60e51b81526004018080602001828103825260238152602001806140fb6023913960400191505060405180910390fd5b33600090815260066020526040902054806110ce576040805162461bcd60e51b815260206004820152600c60248201526b455343524f575f454d50545960a01b604482015290519081900360640190fd5b336000818152600660205260408120556110e89082612fde565b6040805182815233602082015281517fb04d37d3296a34ef094bb4da3e1025abae58c3f53fd6b638c1d0174b3a9d509b929181900390910190a1506001600055565b6003546001600160a01b0316331461117b576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b610a9e6130c8565b6001546001600160a01b031690565b600260005414156111d8576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b60026000556005546001600160a01b031633146112265760405162461bcd60e51b81526004018080602001828103825260228152602001806140d96022913960400191505060405180910390fd5b6002546040805163035e54d560e31b815260048101849052905160009283926001600160a01b0390911691631af2a6a891602480820192602092909190829003018186803b15801561127757600080fd5b505afa15801561128b573d6000803e3d6000fd5b505050506040513d60208110156112a157600080fd5b505160025460408051631cf7955d60e01b81526004810184905290519293506000926001600160a01b0390921691631cf7955d91602480820192602092909190829003018186803b1580156112f557600080fd5b505afa158015611309573d6000803e3d6000fd5b505050506040513d602081101561131f57600080fd5b505160025460408051633eb53ba560e21b815260048101869052815193945060009384936001600160a01b03169263fad4ee949260248082019391829003018186803b15801561136e57600080fd5b505afa158015611382573d6000803e3d6000fd5b505050506040513d604081101561139857600080fd5b508051602090910151909250905060008360038111156113b457fe5b14156114365760006113c68383612728565b6001600160a01b038a166000908152600660205260409020549091506113ec9082612db6565b6001600160a01b03808b1660009081526006602052604080822093909355908a168152205461141b9082612728565b6001600160a01b038916600090815260066020526040902055505b600183600381111561144457fe5b14156115ba576001600160a01b03881660009081526006602052604090205461146d9083612db6565b6001600160a01b03808a16600090815260066020526040808220939093559089168152205461149c9083612728565b6001600160a01b03808916600090815260066020908152604091829020939093556002548151639a751bbd60e01b8152600481018990529151921692639a751bbd92602480840193829003018186803b1580156114f857600080fd5b505afa15801561150c573d6000803e3d6000fd5b505050506040513d602081101561152257600080fd5b50516001600160a01b038082166000908152600760209081526040808320938d16835292905220549095506115579082612db6565b6001600160a01b0386811660009081526007602090815260408083208d8516845290915280822093909355908916815220546115939082612728565b6001600160a01b038087166000908152600760209081526040808320938c16835292905220555b60028360038111156115c857fe5b141561173e576002546040805163e875a61360e01b81526004810187905290516001600160a01b039092169163e875a61391602480820192602092909190829003018186803b15801561161a57600080fd5b505afa15801561162e573d6000803e3d6000fd5b505050506040513d602081101561164457600080fd5b50516001600160a01b038082166000908152600760209081526040808320938d16835292905220549095506116799083612db6565b6001600160a01b0386811660009081526007602090815260408083208d8516845290915280822093909355908916815220546116b59083612728565b6001600160a01b0380871660009081526007602090815260408083208c85168452825280832094909455918b168152600690915220546116f59082612db6565b6001600160a01b03808a1660009081526006602052604080822093909355908916815220546117249082612728565b6001600160a01b0388166000908152600660205260409020555b600383600381111561174c57fe5b1415611961576002546040805163e875a61360e01b81526004810187905290516001600160a01b039092169163e875a61391602480820192602092909190829003018186803b15801561179e57600080fd5b505afa1580156117b2573d6000803e3d6000fd5b505050506040513d60208110156117c857600080fd5b50516001600160a01b038082166000908152600760209081526040808320938d16835292905220549095506117fd9083612db6565b6001600160a01b0386811660009081526007602090815260408083208d8516845290915280822093909355908916815220546118399083612728565b6001600160a01b0380871660009081526007602090815260408083208c85168452825291829020939093556002548151639a751bbd60e01b8152600481018990529151921692639a751bbd92602480840193829003018186803b15801561189f57600080fd5b505afa1580156118b3573d6000803e3d6000fd5b505050506040513d60208110156118c957600080fd5b50516001600160a01b038082166000908152600760209081526040808320938d16835292905220549095506118fe9082612db6565b6001600160a01b0386811660009081526007602090815260408083208d85168452909152808220939093559089168152205461193a9082612728565b6001600160a01b038087166000908152600760209081526040808320938c16835292905220555b50506001600055505050505050565b6003546001600160a01b031690565b611987612cbf565b6001600160a01b0316611998611183565b6001600160a01b0316146119e1576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b806001600160a01b038116611a22576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b611a2a610ed8565b611a69576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517f44c64b6c77fcb5df7b63c64b6346b9674961739187051adbf249bf8133974cad9281900390910190a15050565b600554600160a01b900460ff161590565b611add612cbf565b6001600160a01b0316611aee611183565b6001600160a01b031614611b37576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b806001600160a01b038116611b78576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b611b80610ed8565b611bbf576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517fb54ffecf5d152884be12f7742b1a1f9e4baa17fc9e2e9586546450645a59a38d9281900390910190a15050565b611c22612cbf565b6001600160a01b0316611c33611183565b6001600160a01b031614611c7c576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b611c84610ed8565b611cc3576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b806001600160a01b038116611d04576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517fac81fe7dd460bb5162a4a7d8fb92a13bd2baf450914fc6b1c4cc3180eba55af09281900390910190a15050565b60026000541415611da5576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b60026000556004546001600160a01b03163314611df35760405162461bcd60e51b815260040180806020018281038252602681526020018061417e6026913960400191505060405180910390fd5b60025460408051631cf7955d60e01b81526004810185905290516000926001600160a01b031691631cf7955d916024808301926020929190829003018186803b158015611e3f57600080fd5b505afa158015611e53573d6000803e3d6000fd5b505050506040513d6020811015611e6957600080fd5b5051905060008080836003811115611e7d57fe5b1480611e9457506002836003811115611e9257fe5b145b15611f8c5760025460408051638810632360e01b81526004810188905290516001600160a01b0390921691638810632391602480820192602092909190829003018186803b158015611ee557600080fd5b505afa158015611ef9573d6000803e3d6000fd5b505050506040513d6020811015611f0f57600080fd5b50519150611f1d8285612d5d565b6001600160a01b038816600090815260066020526040902054909150611f439082612db6565b6001600160a01b038089166000908152600660205260408082209390935590881681522054611f729082612728565b6001600160a01b0387166000908152600660205260409020555b6001836003811115611f9a57fe5b1480611fb157506003836003811115611faf57fe5b145b1561214e5760025460408051639a751bbd60e01b81526004810188905290516000926001600160a01b031691639a751bbd916024808301926020929190829003018186803b15801561200257600080fd5b505afa158015612016573d6000803e3d6000fd5b505050506040513d602081101561202c57600080fd5b505160025460408051638810632360e01b8152600481018a905290519293506001600160a01b0390911691638810632391602480820192602092909190829003018186803b15801561207d57600080fd5b505afa158015612091573d6000803e3d6000fd5b505050506040513d60208110156120a757600080fd5b505192506120b58386612d5d565b6001600160a01b038083166000908152600760209081526040808320938d16835292905220549092506120e89083612db6565b6001600160a01b0382811660009081526007602090815260408083208d8516845290915280822093909355908916815220546121249083612728565b6001600160a01b039182166000908152600760209081526040808320948b16835293905291909120555b600254604080516388c2560760e01b8152600481018890526001600160a01b038981166024830152915191909216916388c2560791604480830192600092919082900301818387803b1580156121a357600080fd5b505af11580156121b7573d6000803e3d6000fd5b50506001600055505050505050505050565b6002600054141561220f576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b600260005561221c610ed8565b15612261576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b61226b8282612789565b6108ca576040805162461bcd60e51b81526020600482015260136024820152724e4f5448494e475f544f5f574954484452415760681b604482015290519081900360640190fd5b6001600160a01b031660009081526006602052604090205490565b6122d5612cbf565b6001600160a01b03166122e6611183565b6001600160a01b03161461232f576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b806001600160a01b038116612370576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b612378610ed8565b6123b7576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b600280546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517f94d4208cb05337821fef5da6205084b70818af988524d8a2609a53a1ac1033d19281900390910190a15050565b61241a610ed8565b612459576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b6002600054141561249f576040805162461bcd60e51b815260206004820152601f6024820152600080516020614073833981519152604482015290519081900360640190fd5b6002600055806001600160a01b0381166124e5576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600554600160a01b900460ff1661252d5760405162461bcd60e51b81526004018080602001828103825260238152602001806140fb6023913960400191505060405180910390fd5b6001600160a01b038216600090815260076020908152604080832033845290915290205480612592576040805162461bcd60e51b815260206004820152600c60248201526b455343524f575f454d50545960a01b604482015290519081900360640190fd5b6001600160a01b03831660009081526007602090815260408083203380855292528220919091556125c590849083613151565b604080518281526001600160a01b0385166020820152338183015290517f7e5dd3919ea79fc8c93a49edf5656ab20f89df3e419fde48c90a90765f7605a69181900360600190a15050600160005550565b6002546001600160a01b031690565b61262d612cbf565b6001600160a01b031661263e611183565b6001600160a01b031614612687576040805162461bcd60e51b815260206004820181905260248201526000805160206141c5833981519152604482015290519081900360640190fd5b6001600160a01b0381166126cc5760405162461bcd60e51b81526004018080602001828103825260268152602001806140936026913960400191505060405180910390fd5b6001546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b600082820183811015612782576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6000612793613fa9565b836127d6576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b60208082018590526002546040805163035e54d560e31b81526004810188905290516001600160a01b0390921692631af2a6a892602480840193829003018186803b15801561282457600080fd5b505afa158015612838573d6000803e3d6000fd5b505050506040513d602081101561284e57600080fd5b505180825260025460408051631cf7955d60e01b81526004810193909352516001600160a01b0390911691631cf7955d916024808301926020929190829003018186803b15801561289e57600080fd5b505afa1580156128b2573d6000803e3d6000fd5b505050506040513d60208110156128c857600080fd5b505160e082019060038111156128da57fe5b908160038111156128e757fe5b905250600254602082015160408051630c969ea160e21b81526004810192909252516001600160a01b039092169163325a7a849160248082019260a092909190829003018186803b15801561293b57600080fd5b505afa15801561294f573d6000803e3d6000fd5b505050506040513d60a081101561296557600080fd5b5080516020808301516040938401516101008601519015156060828101919091529115158186015260ff90931692909101919091526002548351835163d887b4e760e01b8152600481019190915292516001600160a01b039091169263d887b4e7926024808301939192829003018186803b1580156129e357600080fd5b505afa1580156129f7573d6000803e3d6000fd5b505050506040513d6060811015612a0d57600080fd5b50805160208083015160409384015160c086015260a0850152608084019190915260025482516326efff5360e11b81526004810188905292516001600160a01b0390911692634ddffea6926024808301939192829003018186803b158015612a7457600080fd5b505afa158015612a88573d6000803e3d6000fd5b505050506040513d6020811015612a9e57600080fd5b50516001600160a01b039081166040808401919091526002546020848101518351637baca8e760e11b815260048101919091529251919093169263f75951ce9260248082019391829003018186803b158015612af957600080fd5b505afa158015612b0d573d6000803e3d6000fd5b505050506040513d6020811015612b2357600080fd5b50516001600160a01b0316606082015261010081015160400151600090612b5157612b4e82856131a3565b90505b600280546040516349b3b46560e11b81526004810188815260009384936001600160a01b03169263936768ca928b928b92602401908390811115612b9157fe5b815260200192505050602060405180830381600087803b158015612bb457600080fd5b505af1158015612bc8573d6000803e3d6000fd5b505050506040513d6020811015612bde57600080fd5b5051158015612bfc5750612bfc84610100015160200151600061327a565b15612c1157612c0b84876132a2565b90925090505b8215612c4e57612c4e6000876002811115612c2857fe5b14612c37578460600151612c3d565b84604001515b608086015160e08701518751613442565b8115612cab57612cab6000876002811115612c6557fe5b14612c95576001876002811115612c7857fe5b14612c8a57612c85611183565b612c90565b84606001515b612c9b565b84604001515b828660e001518760000151612e13565b8280612cb45750815b979650505050505050565b3390565b612ccb610ed8565b612d0a576040805162461bcd60e51b815260206004820152601460248201526000805160206140b9833981519152604482015290519081900360640190fd5b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612d40612cbf565b604080516001600160a01b039092168252519081900360200190a1565b600082612d6c575060006107ab565b82820282848281612d7957fe5b04146127825760405162461bcd60e51b81526004018080602001828103825260218152602001806141a46021913960400191505060405180910390fd5b600082821115612e0d576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b836001600160a01b038116612e54576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b60008411612ea0576040805162461bcd60e51b81526020600482015260146024820152734e4f5f46554e44535f544f5f574954484452415760601b604482015290519081900360640190fd5b6000836003811115612eae57fe5b1480612ec557506002836003811115612ec357fe5b145b15612f2657612edd6001600160a01b03861685612fde565b604080513381526001600160a01b038716602082015280820186905290517f0ec497a8ae5b1ba29c60470ef651def995fac3deebbdcc56c47a4e5f51a4c2bd9181900360600190a15b6001836003811115612f3457fe5b1480612f4b57506003836003811115612f4957fe5b145b15612fd75760025460408051639a751bbd60e01b81526004810185905290516000926001600160a01b031691639a751bbd916024808301926020929190829003018186803b158015612f9c57600080fd5b505afa158015612fb0573d6000803e3d6000fd5b505050506040513d6020811015612fc657600080fd5b50519050612fd5818787613151565b505b5050505050565b80471015613033576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d806000811461307e576040519150601f19603f3d011682016040523d82523d6000602084013e613083565b606091505b50509050806130c35760405162461bcd60e51b815260040180806020018281038252603a81526020018061411e603a913960400191505060405180910390fd5b505050565b6130d0610ed8565b15613115576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612d40612cbf565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526130c390849061357f565b6000808260028111156131b257fe5b1480156131ce57506131ce83610100015160200151600561327a565b156131e6576131de836000613630565b5060016107ab565b60018260028111156131f457fe5b148015613261575061321083610100015160200151600461327a565b8061322a575061322a83610100015160200151600361327a565b80613261575061324483610100015160200151600161327a565b8015613261575061325f83610100015160200151600561327a565b155b15613271576131de836001613630565b50600092915050565b6000600182600681111561328a57fe5b60ff168460ff16901c1660ff16600114905092915050565b6000806132b984610100015160200151600261327a565b156132cf576132c88484613897565b9050613325565b60028360028111156132dd57fe5b14613325576132f684610100015160200151600161327a565b15613305576132c884846139f4565b600083600281111561331357fe5b14156133255761332284613a6a565b90505b61333984610100015160200151600561327a565b80613353575061335384610100015160200151600161327a565b1561338757600183600281111561336657fe5b14156133825761337f61337885613ae7565b8290612728565b90505b6133aa565b600283600281111561339557fe5b14156133aa576133a761337885613b64565b90505b80158015925061343b576002805460208601516040516353a572ed60e11b8152600481018281526001600160a01b039093169363a74ae5da938892879260249091019084908111156133f857fe5b81526020018281526020019350505050600060405180830381600087803b15801561342257600080fd5b505af1158015613436573d6000803e3d6000fd5b505050505b9250929050565b836001600160a01b038116613483576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600083600381111561349157fe5b14806134a8575060018360038111156134a657fe5b145b15613509576134c06001600160a01b03861685612fde565b604080513381526001600160a01b038716602082015280820186905290517f0ec497a8ae5b1ba29c60470ef651def995fac3deebbdcc56c47a4e5f51a4c2bd9181900360600190a15b600283600381111561351757fe5b148061352e5750600383600381111561352c57fe5b145b15612fd7576002546040805163e875a61360e01b81526004810185905290516000926001600160a01b03169163e875a613916024808301926020929190829003018186803b158015612f9c57600080fd5b60006135d4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613bc59092919063ffffffff16565b8051909150156130c3578080602001905160208110156135f357600080fd5b50516130c35760405162461bcd60e51b815260040180806020018281038252602a815260200180614205602a913960400191505060405180910390fd5b60008260e00151600381111561364257fe5b148061365d575060018260e00151600381111561365b57fe5b145b156136ab57608082015160608301516001600160a01b031660009081526006602052604090205461368d91612db6565b60608301516001600160a01b03166000908152600660205260409020555b60028260e0015160038111156136bd57fe5b14806136d8575060038260e0015160038111156136d657fe5b145b156137c35760025482516040805163e875a61360e01b81526004810192909252516000926001600160a01b03169163e875a613916024808301926020929190829003018186803b15801561372b57600080fd5b505afa15801561373f573d6000803e3d6000fd5b505050506040513d602081101561375557600080fd5b505160808401516001600160a01b03808316600090815260076020908152604080832060608a0151909416835292905220549192506137949190612db6565b6001600160a01b0391821660009081526007602090815260408083206060880151909516835293905291909120555b600254602083015160408051633aaa4a8b60e11b81526004810192909252516001600160a01b039092169163755495169160248082019260009290919082900301818387803b15801561381557600080fd5b505af1158015613829573d6000803e3d6000fd5b5050505060208201516000805160206141e5833981519152600083600181111561384f57fe5b1461385e578360600151613864565b83604001515b6080850151604080516001600160a01b039390931683526020830191909152600082820152519081900360600190a25050565b60008060006138b085610100015160200151600161327a565b156139505760a08501516000906138c8906002613bdc565b905060018560028111156138d857fe5b14156138ed578092508560600151915061394a565b60008560028111156138fb57fe5b141561391a5761390c816002613bdc565b92508560400151915061394a565b61393d613928826002613bdc565b60a08801516139379084612db6565b90612db6565b9250613947611183565b91505b50613985565b600284600281111561395e57fe5b141561397a578460a001519150613973611183565b9050613985565b6000925050506107ab565b61399d8560e001518660400151848860000151613c43565b84602001516000805160206141e58339815191528284600160405180846001600160a01b031681526020018381526020018260028111156139da57fe5b8152602001935050505060405180910390a2509392505050565b600080806001846002811115613a0657fe5b1415613a395760a0850151613a2b90613a20906002613bdc565b60a087015190612db6565b915084606001519050613985565b60a0850151613a49906002613bdc565b91508460400151905061399d8560e001518660400151848860000151613c43565b6000613a888260e0015183604001518460a001518560000151613c43565b81602001516000805160206141e583398151915283604001518460a00151600160405180846001600160a01b03168152602001838152602001826002811115613acd57fe5b8152602001935050505060405180910390a25060a0015190565b6000613b058260e0015183606001518460c001518560000151613c43565b81602001516000805160206141e583398151915283606001518460c00151600260405180846001600160a01b03168152602001838152602001826002811115613b4a57fe5b8152602001935050505060405180910390a25060c0015190565b6000613b828260e0015183606001518460c001518560000151613c43565b81602001516000805160206141e5833981519152613b9e611183565b60c0850151604080516001600160a01b038416815260208101839052600291810182613b4a565b6060613bd48484600085613daf565b949350505050565b6000808211613c32576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381613c3b57fe5b049392505050565b6000846003811115613c5157fe5b1480613c6857506002846003811115613c6657fe5b145b15613caa576001600160a01b038316600090815260066020526040902054613c909083612db6565b6001600160a01b0384166000908152600660205260409020555b6001846003811115613cb857fe5b1480613ccf57506003846003811115613ccd57fe5b145b15613da95760025460408051639a751bbd60e01b81526004810184905290516000926001600160a01b031691639a751bbd916024808301926020929190829003018186803b158015613d2057600080fd5b505afa158015613d34573d6000803e3d6000fd5b505050506040513d6020811015613d4a57600080fd5b50516001600160a01b03808216600090815260076020908152604080832093891683529290522054909150613d7f9084612db6565b6001600160a01b039182166000908152600760209081526040808320948816835293905291909120555b50505050565b606082471015613df05760405162461bcd60e51b81526004018080602001828103825260268152602001806141586026913960400191505060405180910390fd5b613df985613eff565b613e4a576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310613e885780518252601f199092019160209182019101613e69565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613eea576040519150601f19603f3d011682016040523d82523d6000602084013e613eef565b606091505b5091509150612cb4828286613f05565b3b151590565b60608315613f14575081612782565b825115613f245782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613f6e578181015183820152602001613f56565b50505050905090810190601f168015613f9b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b604051806101200160405280600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000600381111561400557fe5b8152602001614012614017565b905290565b6040805160e08101825260008082526020820181905291810182905260608101919091526080810161404761405b565b815260200160008152602001600081525090565b60408051808201909152600080825260208201529056fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c004f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735061757361626c653a206e6f7420706175736564000000000000000000000000554e415554484f52495a45445f564f55434845525f544f4b454e5f414444524553534f776e657220646964206e6f7420616c6c6f77206d616e75616c207769746864726177416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c554e415554484f52495a45445f564f55434845525f5345545f544f4b454e5f41444452455353536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572e6e743e535fe193128a1e1839b7c1f313bb203d9cbb58e4c955d5e9a8a8f0fc25361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220f49ed375208bbfc4ef7345cec450baabcf3ea0491cbedce0adbce63502122d4064736f6c63430007060033