Contract 0x5C126F8F6107b2da41dAA8b7E4c3f4a01098A6db

Contract Overview

Balance:
0 Ether
Txn Hash
Method
Block
From
To
Value
0xd15e0e829b3b9622bde860a75ef0ec688f3e1aba15d93b296f19170ed61ae628Create89678962021-07-20 4:52:41349 days 20 hrs ago0x532dfc6ff1fcaf0d95ff6faa857a517476ca7ff9 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0005451
0x163a5dfa31ca22da740647b615b973c9b6b2f7f17b00b5eb26cae1aeb672562bCreate88761992021-07-04 6:30:12365 days 18 hrs ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0005451
0xe13b7946f5e8a6b91fdd14f6a6ecb855b0bff70a299601902e59ced671a1f494Create88756872021-07-04 4:22:03365 days 20 hrs ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0005451
0xd74d941068018646e6afbdba1d8e6721bae7c1c33844518752e51aa075dd6f2eCreate88756322021-07-04 4:08:17365 days 21 hrs ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0005451
0xab103bed36ddd43969f183b6209f80868b7cf6fe3f5a6db4bb4da66ba69f48e8Create87577032021-06-13 16:30:18386 days 8 hrs ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0005451
0xea41f76bcf27fa821adc31b0d230a1971d4d9afceb6afc4c3baa4bef0c4ea980Create87544732021-06-13 3:02:45386 days 22 hrs ago0x0ea2bc676f7dd63864bb2c3a338496a61eddfb57 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0005451
0x9d30cfc50b05daa8ef37dc20f07fc0f976d5076cc2bcd9c59fe13d440f8cdb4dCreate87544402021-06-13 2:54:30386 days 22 hrs ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0005451
0xa377d47a8a31215ad7f4313f0100d6df44b2cde2efc49339900287a7391f2a4bCreate87543602021-06-13 2:34:29386 days 22 hrs ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0005451
0x38f98433a1f5e8cf6d27705376a02f2d23e85133bb880d68021cbb198b943a6eCreate87516752021-06-12 15:22:41387 days 9 hrs ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0005451
0x817fe57fadf7d26a535ffcea9ffbf899382d0976ba582ef2ca2bbb6d29b78283Create87347422021-06-09 16:47:09390 days 8 hrs ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.000315831
0x96c503647eb022dd83fc7c158459c73489ba1b6f65609fa8adcc459895105fdaCreate87312442021-06-09 2:12:24390 days 22 hrs ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.000544981
0xef6ae6f94bc704e0cbfa6b8db579fb01592df5c254565cec68bb3fe91ae030aaCreate87307022021-06-08 23:56:53391 days 1 hr ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.000544981
0xe60fe294fa11256ed3874feb867562b7c3201f99d2ea76af88a4a9888c7b03d8Create87305522021-06-08 23:19:23391 days 1 hr ago0xf133a12f4fa06bc90166ed87d3528c6f14ba2734 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.000544981
0x68164a5b289db19619e224f87b82922666f910900b0c941082b5b6b35c2f9572Create87301032021-06-08 21:27:04391 days 3 hrs ago0x8cec18a718afe0491322a4871b8126df40f364b3 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0005451
0x8afdc73ef1a1fe23a657ceb2c6bb26cbd52d2675ad1ecc8685cbbf4d8cbeabfcCreate87300232021-06-08 21:07:03391 days 4 hrs ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.000544981
0x7b608c469be2a859de37f57ee75ef4bea2fec6cc4d079d96990b90e71e7ac801Create87295432021-06-08 19:07:01391 days 6 hrs ago0xe1c91911b2da2f79ae580a85408d27df46bfc3c7 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.000544981
0x35c94e2e3bfe69f9fc6b198bc6413abb242a6fcf10e7336c12b4ce979117981dCreate86495512021-05-25 21:42:39405 days 3 hrs ago0x05db4be3a9d6f08230254ec9693bbef0c9de3858 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0054500610
0x6199fa1ff6ded306a7edc27e2e6dd7d7ea90d6084826574019b71153cdbf159eCreate86494982021-05-25 21:29:24405 days 3 hrs ago0x05db4be3a9d6f08230254ec9693bbef0c9de3858 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0054500610
0x26ff0bc67fe1711db0f85213cac14ac7a2596128eed0b605cb7b21deaca8bc9eCreate86494962021-05-25 21:28:54405 days 3 hrs ago0x05db4be3a9d6f08230254ec9693bbef0c9de3858 IN  0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db0 Ether0.0054500610
0xc268ce01441040e4c59fad8d5f8bec346cd391813238661092d88f4f20f052940x6080604086491322021-05-25 19:57:52405 days 5 hrs ago0x05db4be3a9d6f08230254ec9693bbef0c9de3858 IN  Create: PodFactory0 Ether0.003579871
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xd15e0e829b3b9622bde860a75ef0ec688f3e1aba15d93b296f19170ed61ae62889678962021-07-20 4:52:41349 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xf3647105b582a9335a90e1c78ce214d04a8a5ce20 Ether
0xd15e0e829b3b9622bde860a75ef0ec688f3e1aba15d93b296f19170ed61ae62889678962021-07-20 4:52:41349 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xf3647105b582a9335a90e1c78ce214d04a8a5ce20 Ether
0xd15e0e829b3b9622bde860a75ef0ec688f3e1aba15d93b296f19170ed61ae62889678962021-07-20 4:52:41349 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xf3647105b582a9335a90e1c78ce214d04a8a5ce20 Ether
0xd15e0e829b3b9622bde860a75ef0ec688f3e1aba15d93b296f19170ed61ae62889678962021-07-20 4:52:41349 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xf94ee6cdc66172f49a8adf3e60a1cb00c0bb8a590 Ether
0xd15e0e829b3b9622bde860a75ef0ec688f3e1aba15d93b296f19170ed61ae62889678962021-07-20 4:52:41349 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0x5d5af77cf99f7015e615f9b3286a27c5b60907070 Ether
0xd15e0e829b3b9622bde860a75ef0ec688f3e1aba15d93b296f19170ed61ae62889678962021-07-20 4:52:41349 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xf3647105b582a9335a90e1c78ce214d04a8a5ce20 Ether
0xd15e0e829b3b9622bde860a75ef0ec688f3e1aba15d93b296f19170ed61ae62889678962021-07-20 4:52:41349 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xf3647105b582a9335a90e1c78ce214d04a8a5ce20 Ether
0xd15e0e829b3b9622bde860a75ef0ec688f3e1aba15d93b296f19170ed61ae62889678962021-07-20 4:52:41349 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db  Contract Creation0 Ether
0x163a5dfa31ca22da740647b615b973c9b6b2f7f17b00b5eb26cae1aeb672562b88761992021-07-04 6:30:12365 days 18 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0x32f0e7575d6d8bba2a9647daa272e1b9cae10c930 Ether
0x163a5dfa31ca22da740647b615b973c9b6b2f7f17b00b5eb26cae1aeb672562b88761992021-07-04 6:30:12365 days 18 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0x32f0e7575d6d8bba2a9647daa272e1b9cae10c930 Ether
0x163a5dfa31ca22da740647b615b973c9b6b2f7f17b00b5eb26cae1aeb672562b88761992021-07-04 6:30:12365 days 18 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0x32f0e7575d6d8bba2a9647daa272e1b9cae10c930 Ether
0x163a5dfa31ca22da740647b615b973c9b6b2f7f17b00b5eb26cae1aeb672562b88761992021-07-04 6:30:12365 days 18 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xf94ee6cdc66172f49a8adf3e60a1cb00c0bb8a590 Ether
0x163a5dfa31ca22da740647b615b973c9b6b2f7f17b00b5eb26cae1aeb672562b88761992021-07-04 6:30:12365 days 18 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0x5d5af77cf99f7015e615f9b3286a27c5b60907070 Ether
0x163a5dfa31ca22da740647b615b973c9b6b2f7f17b00b5eb26cae1aeb672562b88761992021-07-04 6:30:12365 days 18 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0x32f0e7575d6d8bba2a9647daa272e1b9cae10c930 Ether
0x163a5dfa31ca22da740647b615b973c9b6b2f7f17b00b5eb26cae1aeb672562b88761992021-07-04 6:30:12365 days 18 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0x32f0e7575d6d8bba2a9647daa272e1b9cae10c930 Ether
0x163a5dfa31ca22da740647b615b973c9b6b2f7f17b00b5eb26cae1aeb672562b88761992021-07-04 6:30:12365 days 18 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db  Contract Creation0 Ether
0xe13b7946f5e8a6b91fdd14f6a6ecb855b0bff70a299601902e59ced671a1f49488756872021-07-04 4:22:03365 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xc17045a1de25e3d81d035ed9c8c4945d9f788d5f0 Ether
0xe13b7946f5e8a6b91fdd14f6a6ecb855b0bff70a299601902e59ced671a1f49488756872021-07-04 4:22:03365 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xc17045a1de25e3d81d035ed9c8c4945d9f788d5f0 Ether
0xe13b7946f5e8a6b91fdd14f6a6ecb855b0bff70a299601902e59ced671a1f49488756872021-07-04 4:22:03365 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xc17045a1de25e3d81d035ed9c8c4945d9f788d5f0 Ether
0xe13b7946f5e8a6b91fdd14f6a6ecb855b0bff70a299601902e59ced671a1f49488756872021-07-04 4:22:03365 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xf94ee6cdc66172f49a8adf3e60a1cb00c0bb8a590 Ether
0xe13b7946f5e8a6b91fdd14f6a6ecb855b0bff70a299601902e59ced671a1f49488756872021-07-04 4:22:03365 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0x5d5af77cf99f7015e615f9b3286a27c5b60907070 Ether
0xe13b7946f5e8a6b91fdd14f6a6ecb855b0bff70a299601902e59ced671a1f49488756872021-07-04 4:22:03365 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xc17045a1de25e3d81d035ed9c8c4945d9f788d5f0 Ether
0xe13b7946f5e8a6b91fdd14f6a6ecb855b0bff70a299601902e59ced671a1f49488756872021-07-04 4:22:03365 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xc17045a1de25e3d81d035ed9c8c4945d9f788d5f0 Ether
0xe13b7946f5e8a6b91fdd14f6a6ecb855b0bff70a299601902e59ced671a1f49488756872021-07-04 4:22:03365 days 20 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db  Contract Creation0 Ether
0xd74d941068018646e6afbdba1d8e6721bae7c1c33844518752e51aa075dd6f2e88756322021-07-04 4:08:17365 days 21 hrs ago 0x5c126f8f6107b2da41daa8b7e4c3f4a01098a6db 0xd17b60bd6eae809de81fd14fee27aef41c9b89880 Ether
[ Download CSV Export 
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
PodFactory

Compiler Version
v0.7.0+commit.9e61f92b

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 27 : PodFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.8.0;

// Libraries
import "./external/ProxyFactory.sol";

// Internal Interfaces
import "./TokenDropFactory.sol";

// Clone Contracts
import "./Pod.sol";
import "./TokenDrop.sol";

/**
 * @title PodFactory (ProxyFactory) - Clones a Pod Instance
 * @notice Reduces gas costs and collectively increases that chances winning for PoolTogether users, while keeping user POOL distributions to users.
 * @dev The PodFactory creates/initializes connected Pod and TokenDrop smart contracts. Pods stores tokens, tickets, prizePool and other essential references.
 * @author Kames Geraghty
 */
contract PodFactory is ProxyFactory {
    /**
     * @notice TokenDropFactory reference
     */
    TokenDropFactory public tokenDropFactory;

    /**
     * @notice Contract template for deploying proxied Pods
     */
    Pod public podInstance;

    /***********************************|
    |   Events                          |
    |__________________________________*/
    /**
     * @dev Emitted when a new Pod and TokenDrop pair is created.
     */
    event LogCreatedPodAndTokenDrop(Pod indexed pod, TokenDrop indexed drop);

    /***********************************|
    |   Constructor                     |
    |__________________________________*/
    /**
     * @notice Initializes the Pod Factory with an instance of the Pod and TokenDropFactory reference.
     * @dev Initializes the Pod Factory with an instance of the Pod and TokenDropFactory reference.
     * @param _tokenDropFactory Target PrizePool for deposits and withdraws
     */
    constructor(TokenDropFactory _tokenDropFactory) {
        require(
            address(_tokenDropFactory) != address(0),
            "PodFactory:invalid-token-drop-factory"
        );
        // Pod Instance
        podInstance = new Pod();

        // Reference TokenDropFactory
        tokenDropFactory = _tokenDropFactory;
    }

    /**
     * @notice Create a new Pod Clone using the Pod instance.
     * @dev The Pod Smart Contact is created and initialized using the PodFactory.
     * @param _prizePool Target PrizePool for deposits and withdraws.
     * @param _ticket Non-sponsored PrizePool ticket - is verified during initialization.
     * @param _faucet  TokenFaucet address that distributes reward token for PrizePool deposits.
     * @param _manager Manages the Pod's non-core assets (ERC20 and ERC721 tokens).
     * @param _decimals Set the Pod decimals to match the underlying asset.
     * @return pod Pod address
     */
    function create(
        address _prizePool,
        address _ticket,
        address _faucet,
        address _manager,
        uint8 _decimals
    ) external returns (address pod) {
        // Pod Deploy
        Pod _pod = Pod(deployMinimal(address(podInstance), ""));

        // Pod Initialize
        _pod.initialize(_prizePool, _ticket, _decimals);

        // Pod Set Manager
        _pod.setManager(_manager);

        // Governance managed PrizePools include TokenFaucets, which "drip" an asset token.
        // Community managed PrizePools might NOT have a TokenFaucet, and thus don't require a TokenDrop.
        TokenDrop _drop;
        if (address(_faucet) != address(0)) {
            TokenFaucet faucet = TokenFaucet(_faucet);

            // Create TokenDrop instance
            _drop = tokenDropFactory.create(
                IERC20Upgradeable(_pod),
                IERC20Upgradeable(faucet.asset())
            );

            // Set Pod TokenFacuet
            _pod.setTokenFaucet(faucet);

            // Set Pod TokenDrop
            _pod.setTokenDrop(_drop);
        }

        // Update Pod owner from factory to msg.sender
        _pod.transferOwnership(msg.sender);

        // Emit LogCreatedPodAndTokenDrop
        emit LogCreatedPodAndTokenDrop(_pod, _drop);

        // Return Pod/TokenDrop addresses
        return (address(_pod));
    }
}

File 2 of 27 : ProxyFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.8.0;

// solium-disable security/no-inline-assembly
// solium-disable security/no-low-level-calls
contract ProxyFactory {
    event ProxyCreated(address proxy);

    function deployMinimal(address _logic, bytes memory _data)
        public
        returns (address proxy)
    {
        // Adapted from https://github.com/optionality/clone-factory/blob/32782f82dfc5a00d103a7e61a17a5dedbd1e8e9d/contracts/CloneFactory.sol
        bytes20 targetBytes = bytes20(_logic);
        assembly {
            let clone := mload(0x40)
            mstore(
                clone,
                0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
            )
            mstore(add(clone, 0x14), targetBytes)
            mstore(
                add(clone, 0x28),
                0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
            )
            proxy := create(0, clone, 0x37)
        }

        // Check Proxy instance is not 0x0000000000000000000000000000000000000000
        require(address(proxy) != address(0), "ProxyFactory:invalid-address");

        // Emit ProxyCreated
        emit ProxyCreated(address(proxy));

        if (_data.length > 0) {
            (bool success, ) = proxy.call(_data);
            require(success, "ProxyFactory/constructor-call-failed");
        }
    }
}

File 3 of 27 : TokenDropFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.8.0;

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

// Libraries
import "./external/ProxyFactory.sol";

// Clone Contracts
import "./Pod.sol";
import "./TokenDrop.sol";

/**
 * @title TokenDropFactory (ProxyFactory) - Clones a TokenDrop Instance
 * @notice Create a TokenDrop smart contract, which is associated with Pod smart contract for distribution of an asset token (i.e. POOL).
 * @dev The PodFactory creates/initializes TokenDrop smart contract. The factory will generally be called from the PodFactory smart contract directly.
 * @author Kames Geraghty
 */
contract TokenDropFactory is ProxyFactory {
    /***********************************|
    |   Constants                       |
    |__________________________________*/
    /**
     * @notice Contract template for deploying proxied Comptrollers
     */
    TokenDrop public tokenDropInstance;

    /***********************************|
    |   Constructor                     |
    |__________________________________*/
    /**
     * @notice Initializes the TokenDropFactory.
     * @dev Initializes the Factory with a TokenDrop instance.
     */
    constructor() {
        // TokenDrop Instance
        tokenDropInstance = new TokenDrop();
    }

    /**
     * @notice Create a TokenDrop smart contract
     * @dev Creates and initializes the TokenDrop Smart Contract with the measure (i.e. Pod) and asset (i.e. POOL) variables
     * @param _measure The token being tracked to calculate user asset rewards
     * @param _asset The token being rewarded when maintaining a positive balance of the "measure" token
     */
    function create(IERC20Upgradeable _measure, IERC20Upgradeable _asset)
        external
        returns (TokenDrop)
    {
        // TokenDrop Deployed
        TokenDrop tokenDrop =
            TokenDrop(deployMinimal(address(tokenDropInstance), ""));

        // TokenDrop Initialize
        tokenDrop.initialize(_measure, _asset);

        // Return TokenDrop addresses
        return tokenDrop;
    }
}

File 4 of 27 : Pod.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.8.0;

// Libraries
import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol";

// Module Interfaces
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

// Internal Interfaces
import "./IPod.sol";
import "./TokenDrop.sol";
import "./IPodManager.sol";
import "./TokenDropFactory.sol";

// External Interfaces
import "./interfaces/TokenFaucet.sol";
import "./interfaces/IPrizePool.sol";
import "./interfaces/IPrizeStrategyMinimal.sol";

/**
 * @title Pod (Initialize, ERC20Upgradeable, OwnableUpgradeable, IPod) - Reduce User Gas Costs and Increase Odds of Winning via Collective Deposits.
 * @notice Pods turn PoolTogether deposits into shares and enable batched deposits, reudcing gas costs and collectively increasing odds  winning.
 * @dev Pods is a ERC20 token with additional features: shares (representing deposits), batched deposits into PoolTogether PrizePools and claimable rewards.
 * @author Kames Geraghty
 */
contract Pod is
    IPod,
    ERC20Upgradeable,
    OwnableUpgradeable,
    ReentrancyGuardUpgradeable
{
    /***********************************|
    |   Libraries                       |
    |__________________________________*/
    using SafeMathUpgradeable for uint256;
    using SafeERC20Upgradeable for IERC20Upgradeable;

    /***********************************|
    |   Constants                       |
    |__________________________________*/
    // Public
    IERC20Upgradeable public token;
    IERC20Upgradeable public ticket;

    TokenFaucet public faucet;
    TokenDrop public tokenDrop;
    address public manager;

    // Private
    IPrizePool private _prizePool;

    /***********************************|
    |   Events                          |
    |__________________________________*/
    /**
     * @dev Emitted when user deposits into Pod float.
     */
    event Deposited(address indexed user, uint256 amount, uint256 shares);

    /**
     * @dev Emitted when user withdraws from the Pod.
     */
    event Withdrawal(address indexed user, uint256 amount, uint256 shares);

    /**
     * @dev Emitted when batch is executed.
     */
    event BatchFloat(uint256 amount);

    /**
     * @dev Emitted when reward asset is claimed by a user.
     */
    event Claimed(address indexed user, uint256 balance);

    /**
     * @dev Emitted when reward asset is claimed by the POD.
     */
    event PodClaimed(uint256 amount);

    /**
     * @dev Emitted when the Pod TokenDrop is set by owner.
     */
    event TokenDropSet(TokenDrop indexed drop);

    /**
     * @dev Emitted when the Pod TokenFaucet is set by owner.
     */
    event TokenFaucetSet(TokenFaucet indexed drop);

    /**
     * @dev Emitted when an ERC20 is withdrawn.
     */
    event ERC20Withdrawn(IERC20Upgradeable indexed target, uint256 amount);

    /**
     * @dev Emitted when an ERC721 is withdrawn.
     */
    event ERC721Withdrawn(IERC721Upgradeable indexed target, uint256 tokenId);

    /**
     * @dev Emitted when Pod manager is transfered.
     */
    event ManagementTransferred(
        address indexed previousmanager,
        address indexed newmanager
    );

    /***********************************|
    |   Modifiers                       |
    |__________________________________*/

    /**
     * @dev Checks is the caller is a manager or owner.
     */

    modifier onlyOwnerOrManager() {
        address _sender = _msgSender();
        require(
            manager == _sender || owner() == _sender,
            "Pod:manager-unauthorized"
        );
        _;
    }

    /**
     * @dev Pause deposits during aware period. Prevents "frontrunning" for deposits into a winning Pod.
     */
    modifier pauseDepositsDuringAwarding() {
        require(
            !IPrizeStrategyMinimal(_prizePool.prizeStrategy()).isRngRequested(),
            "Cannot deposit while prize is being awarded"
        );
        _;
    }

    /***********************************|
    |   Initialize                      |
    |__________________________________*/

    /**
     * @notice Initialize the Pod Smart Contact with the target PrizePool configuration.
     * @dev The Pod Smart Contact is created and initialized using the PodFactory.
     * @param _prizePoolTarget Target PrizePool for deposits and withdraws
     * @param _ticket Non-sponsored PrizePool ticket - is verified during initialization.
     * @param _decimals Set the Pod decimals to match the underlying asset.
     */
    function initialize(
        address _prizePoolTarget,
        address _ticket,
        uint8 _decimals
    ) external initializer {
        // Prize Pool
        _prizePool = IPrizePool(_prizePoolTarget);

        // Contract/Inheritance Configuration
        // ----------------------------------
        // Initialize ReentrancyGuard
        __ReentrancyGuard_init();

        // Initialize ERC20Token
        __ERC20_init_unchained(
            string(
                abi.encodePacked(
                    "Pod ",
                    ERC20Upgradeable(_prizePool.token()).name()
                )
            ),
            string(
                abi.encodePacked(
                    "p",
                    ERC20Upgradeable(_prizePool.token()).symbol()
                )
            )
        );

        // Initialize Owner
        __Ownable_init_unchained();

        // Setup Decimals - Match Underlying Asset
        _setupDecimals(_decimals);

        // Pod Variable/Reference Configuration
        // ------------------------------------

        // PrizePool Tickets
        address[] memory tickets = _prizePool.tokens();

        // Verify ticket matches a PrizePool Ticket
        require(
            address(_ticket) == address(tickets[0]) ||
                address(_ticket) == address(tickets[1]),
            "Pod:initialize-invalid-ticket"
        );

        // Initialize Core ERC20 Tokens
        token = IERC20Upgradeable(_prizePool.token());
        ticket = IERC20Upgradeable(_ticket);
    }

    /***********************************|
    |   Public/External                 |
    |__________________________________*/

    /**
     * @notice Deposit assets into the Pod in exchange for share tokens
     * @param to The address that shall receive the Pod shares
     * @param tokenAmount The amount of tokens to deposit.  These are the same tokens used to deposit into the underlying prize pool.
     * @return The number of Pod shares minted.
     */
    function depositTo(address to, uint256 tokenAmount)
        external
        override
        pauseDepositsDuringAwarding
        nonReentrant
        returns (uint256)
    {
        require(tokenAmount > 0, "Pod:invalid-amount");

        // Allocate Shares from Deposit To Amount
        uint256 shares = _calculateAllocation(tokenAmount);

        // Transfer Token tokenAmount to msg.sender
        IERC20Upgradeable(token).safeTransferFrom(
            msg.sender,
            address(this),
            tokenAmount
        );

        // Mint User Shares
        _mint(to, shares);

        // Emit Deposited
        emit Deposited(to, tokenAmount, shares);

        // Return Shares Minted
        return shares;
    }

    /**
     * @notice Withdraws a users share of the prize pool.
     * @dev The function should first withdraw from the 'float'; i.e. the funds that have not yet been deposited.
     * @param shareAmount The number of Pod shares to burn.
     * @param maxFee Max fee amount for withdrawl if amount isn't available in float.
     * @return The actual amount of tokens that were transferred to the user.  This is the same as the deposit token.
     */
    function withdraw(uint256 shareAmount, uint256 maxFee)
        external
        override
        nonReentrant
        returns (uint256)
    {
        // Check User Balance
        require(
            balanceOf(msg.sender) >= shareAmount,
            "Pod:insufficient-shares"
        );

        // Burn Shares and Return Tokens
        uint256 tokensReturned =
            _burnSharesAndGetTokensReturned(shareAmount, maxFee);

        // Transfer Deposit Token to Message Sender
        token.safeTransfer(msg.sender, tokensReturned);

        // Emit Withdrawal
        emit Withdrawal(msg.sender, tokensReturned, shareAmount);

        return tokensReturned;
    }

    /**
     * @notice Deposit Pod float into PrizePool.
     * @dev Deposits the current float amount into the PrizePool and claims current POOL rewards.
     */
    function batch() public override returns (uint256) {
        // Pod Token Balance
        uint256 float = _podTokenBalance();

        // Approve Prize Pool
        token.safeApprove(address(_prizePool), float);

        // PrizePool Deposit
        _prizePool.depositTo(
            address(this),
            float,
            address(ticket),
            address(this)
        );

        // Emit Batch
        emit BatchFloat(float);

        return float;
    }

    /**
     * @notice Claims TokenDrop asset for PrizePool Pod deposits
     * @dev Claim TokenDrop asset for PrizePool Pod and transfers token(s) to external Pod TokenDrop.
     * @return uint256 claimed amount
     */
    function drop() public returns (uint256) {
        // Claim asset from TokenFaucet if active
        if (address(faucet) != address(0)) {
            faucet.claim(address(this));
        }

        // Run batch (to eliminate "sandwich" attack) and reduce Pod float to zero.
        batch();

        // Check TokenDrop is set for the Pod.
        if (address(tokenDrop) != address(0)) {
            // TokenDrop Asset
            IERC20Upgradeable _asset = IERC20Upgradeable(tokenDrop.asset());

            // Pod asset balance
            uint256 balance = _asset.balanceOf(address(this));

            // Only Transfer asset to TokenDrop if balance above 0
            if (balance > 0) {
                // Approve TokenDrop to withdraw(transfer) reward balance
                _asset.safeApprove(address(tokenDrop), balance);

                // Add reward token to TokenDrop balance
                tokenDrop.addAssetToken(balance);
            }

            // Emit PodClaimed
            emit PodClaimed(balance);

            return balance;
        } else {
            return 0;
        }
    }

    /**
     * @notice Update the Pod Mangeer
     * @dev Update the Pod Manger responsible for handling liquidations.
     * @return bool true
     */
    function setManager(address newManager)
        public
        virtual
        onlyOwner
        returns (bool)
    {
        // Validate Address
        require(newManager != address(0), "Pod:invalid-manager-address");

        // Update Manager
        manager = newManager;

        // Emit ManagementTransferred
        emit ManagementTransferred(manager, newManager);

        return true;
    }

    /**
     * @notice Set TokenFaucet reference
     * @dev Set TokenFaucet reference (if prizepool faucet is updated)
     * @param _faucet TokenDrop address
     * @return bool true
     */
    function setTokenFaucet(TokenFaucet _faucet)
        external
        onlyOwner
        returns (bool)
    {
        // Set TokenFaucet
        faucet = _faucet;

        // Emit TokenFaucetSet
        emit TokenFaucetSet(_faucet);

        return true;
    }

    /**
     * @notice Setup TokenDrop reference
     * @dev Initialize the Pod Smart Contact
     * @param _tokenDrop TokenDrop address
     * @return bool true
     */
    function setTokenDrop(TokenDrop _tokenDrop)
        external
        onlyOwner
        returns (bool)
    {
        // Set TokenDrop smart contract instance
        tokenDrop = _tokenDrop;

        // Emit TokenDropSet
        emit TokenDropSet(_tokenDrop);

        return true;
    }

    /**
     * @notice Withdraw non-core (token/ticket/tokenDrop.asset) ERC20 to Pod manager.
     * @dev Withdraws an ERC20 token amount from the Pod to the PodManager for liquidation to the token and back to the Pod.
     * @param _target ERC20 token to withdraw.
     * @param amount Amount of ERC20 to transfer/withdraw.
     * @return bool true
     */
    function withdrawERC20(IERC20Upgradeable _target, uint256 amount)
        external
        override
        onlyOwnerOrManager
        returns (bool)
    {
        // Lock token/ticket/pool ERC20 transfers
        require(
            address(_target) != address(token) &&
                address(_target) != address(ticket) &&
                (address(tokenDrop) == address(0) ||
                    address(_target) != address(tokenDrop.asset())),
            "Pod:invalid-target-token"
        );

        // Transfer Token
        _target.safeTransfer(msg.sender, amount);

        emit ERC20Withdrawn(_target, amount);

        return true;
    }

    /**
     * @dev Withdraw ER721 reward tokens
     */
    /**
     * @notice Withdraw ER721 token to the Pod owner.
     * @dev Withdraw ER721 token to the Pod owner, which is responsible for deciding what/how to manage the collectible.
     * @param _target ERC721 token to withdraw.
     * @param tokenId The tokenId of the ERC721 collectible.
     * @return bool true
     */
    function withdrawERC721(IERC721Upgradeable _target, uint256 tokenId)
        external
        override
        onlyOwnerOrManager
        returns (bool)
    {
        // Transfer ERC721
        _target.transferFrom(address(this), msg.sender, tokenId);

        // Emit ERC721Withdrawn
        emit ERC721Withdrawn(_target, tokenId);

        return true;
    }

    /***********************************|
    |   Administration                  |
    |__________________________________*/

    /**
     * @notice Zero out the allowance amount of target address to zero.
     * @dev The safeApprove method throws an error if an allowance IS NOT zero. If this unentiionally occurs, this function will reset an allowance.
     * @param _token ERC20 token.
     * @param _target Address with non-zero allowance.
     */
    function emergencyTokenApproveZero(
        IERC20Upgradeable _token,
        address _target
    ) external onlyOwner {
        _token.safeApprove(_target, 0);
    }

    /***********************************|
    |   Internal                        |
    |__________________________________*/

    /**
     * @dev The internal function for the public depositTo function, which calculates a user's allocated shares from deposited amoint.
     * @param amount Amount of "token" deposited into the Pod.
     * @return uint256 The share allocation amount.
     */
    function _calculateAllocation(uint256 amount) internal returns (uint256) {
        uint256 allocation = 0;
        uint256 _totalSupply = totalSupply();

        // Calculate Allocation
        if (_totalSupply == 0) {
            allocation = amount;
        } else {
            allocation = (amount.mul(_totalSupply)).div(balance());
        }

        // Return Allocation Amount
        return allocation;
    }

    /**
     * @dev The internal function for the public withdraw function, which calculates a user's token allocation from burned shares.
     * @param shares The number of Pod shares to burn.
     * @param maxFee Max fee amount for withdrawl if amount isn't available in float.
     * @return uint256 The token amount returned for the burned shares.
     */
    function _burnSharesAndGetTokensReturned(uint256 shares, uint256 maxFee)
        internal
        returns (uint256)
    {
        // Calculate shares underlying tokens
        uint256 amount = _calculateUnderlyingTokens(shares);

        // Burn Shares
        _burn(msg.sender, shares);

        // Check balance
        uint256 currentBalance = token.balanceOf(address(this));

        uint256 actualAmount;
        // Withdrawal Exceeds Current Token Balance
        if (amount > currentBalance) {
            // Calculate withdrawal request amount
            uint256 withdrawRequest = amount.sub(currentBalance);

            // The total withdrawn amount from the Prize Pool
            uint256 withdrawExecuted =
                _withdrawFromPool(withdrawRequest, maxFee);

            actualAmount = currentBalance.add(withdrawExecuted);
            require(amount.sub(actualAmount) <= maxFee, "Pod:max-fee-exceeded");
        } else {
            actualAmount = amount;
        }

        return actualAmount;
    }

    /**
     * @dev Withdraws from Pod prizePool if the float balance can cover the total withdraw amount.
     * @param amount Amount of tokens to withdraw in exchange for the tickets transfered.
     * @param maxFee Max fee amount for withdrawl if amount isn't available in float.
     * @return uint256 The exit fee paid for withdraw from the prizePool instant withdraw method.
     */
    function _withdrawFromPool(uint256 amount, uint256 maxFee)
        internal
        returns (uint256)
    {
        IERC20Upgradeable _token = token;

        uint256 balanceBefore = _token.balanceOf(address(this));

        // Withdraw from Prize Pool
        _prizePool.withdrawInstantlyFrom(
            address(this),
            amount,
            address(ticket),
            maxFee
        );

        uint256 balanceAfter = _token.balanceOf(address(this));

        // Calculate the total withdrawn from the PrizePool by diffing before/after balances
        uint256 totalWithdrawn = balanceAfter.sub(balanceBefore);

        return totalWithdrawn;
    }

    /**
     * @notice Pod current token balance.
     * @dev Request's the Pod's current token balance by calling balanceOf(address(this)).
     * @return uint256 Pod's current token balance.
     */
    function _podTokenBalance() internal view returns (uint256) {
        return token.balanceOf(address(this));
    }

    /**
     * @notice Pod current ticket balance.
     * @dev Request's the Pod's current ticket balance by calling balanceOf(address(this)).
     * @return uint256 Pod's current ticket balance.
     */
    function _podTicketBalance() internal view returns (uint256) {
        return ticket.balanceOf(address(this));
    }

    /**
     * @notice Calculate underlying tokens via shares input.
     * @dev Using shares as input calculate the underlying tokens
     * @return Underlying tokens
     */
    function _calculateUnderlyingTokens(uint256 _shares)
        internal
        view
        returns (uint256)
    {
        // Check totalSupply to prevent SafeMath: division by zero
        uint256 _totalSupply = totalSupply();
        if (_totalSupply > 0) {
            return balance().mul(_shares).div(_totalSupply);
        } else {
            return _shares;
        }
    }

    /***********************************|
    |  Views                            |
    |__________________________________*/

    /**
     * @notice The Pod PrizePool reference
     * @dev Returns the address of the Pod prizepool
     * @return address The Pod prizepool
     */
    function prizePool() external view override returns (address) {
        return address(_prizePool);
    }

    /**
     * @notice Calculate the cost of withdrawing from the Pod if the
     * @param amount Amount of tokens to withdraw when calculating early exit fee.
     * @dev Based of the Pod's total token/ticket balance and totalSupply it calculates the pricePerShare.
     */
    function getEarlyExitFee(uint256 amount) external returns (uint256) {
        uint256 tokenBalance = _podTokenBalance();
        if (amount <= tokenBalance) {
            return 0;
        } else {
            // Calculate Early Exit Fee
            (uint256 exitFee, ) =
                _prizePool.calculateEarlyExitFee(
                    address(this),
                    address(ticket),
                    amount.sub(tokenBalance)
                );

            // Early Exit Fee
            return exitFee;
        }
    }

    /**
     * @notice Calculate the cost of the Pod's token price per share. Until a Pod has won or been "airdropped" tokens it's 1.
     * @dev Based of the Pod's total token/ticket balance and totalSupply it calculates the pricePerShare.
     */
    function getPricePerShare() external view override returns (uint256) {
        uint256 _decimals = decimals();
        return _calculateUnderlyingTokens(10**_decimals);
    }

    /**
     * @notice Calculate the underlying assets relative to users balance.
     * @dev Converts share amount to asset amount by checking the Pod's token and ticket balance.
     * @param user User account
     * @return amount Total assets relative to share input.
     */
    function balanceOfUnderlying(address user)
        external
        view
        returns (uint256 amount)
    {
        return _calculateUnderlyingTokens(balanceOf(user));
    }

    /**
     * @notice Measure's the Pod's total balance by adding the vaultTokenBalance and _podTicketBalance
     * @dev The Pod's token and ticket balance are equal in terms of "value" and thus are used to calculate's a Pod's true balance.
     * @return uint256 Pod's token and ticket balance.
     */
    function balance() public view returns (uint256) {
        return _podTokenBalance().add(_podTicketBalance());
    }

    /***********************************|
    | ERC20 Overrides                   |
    |__________________________________*/

    /**
     * @notice Add TokenDrop to mint()
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     * @param from Account sending tokens
     * @param to Account recieving tokens
     * @param amount Amount of tokens sent
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual override {
        // If Pod TokenDrop is initalized update calculated balances.
        if (address(tokenDrop) != address(0)) {
            tokenDrop.beforeTokenTransfer(from, to, address(this));
        }
    }
}

File 5 of 27 : TokenDrop.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.8.0;

// External Libraries
import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@pooltogether/fixed-point/contracts/FixedPoint.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol";

// External Interfaces
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

// Local Libraries
import "./libraries/ExtendedSafeCast.sol";

/**
 * @title TokenDrop - Calculates Asset Distribution using Measure Token
 * @notice Calculates distribution of POOL rewards for users deposting into PoolTogether PrizePools using the Pod smart contract.
 * @dev A simplified version of the PoolTogether TokenFaucet that simplifies an asset token distribution using totalSupply calculations.
 * @author Kames Cox-Geraghty
 */
contract TokenDrop is ReentrancyGuardUpgradeable {
    /***********************************|
    |   Libraries                       |
    |__________________________________*/
    using SafeMathUpgradeable for uint128;
    using SafeMathUpgradeable for uint256;
    using ExtendedSafeCast for uint256;
    using SafeERC20Upgradeable for IERC20Upgradeable;

    /***********************************|
    |   Constants                       |
    |__________________________________*/
    /**
     * @notice The token that is being disbursed
     */
    IERC20Upgradeable public asset;

    /**
     * @notice The token that is user to measure a user's portion of disbursed tokens
     */
    IERC20Upgradeable public measure;

    /**
     * @notice The cumulative exchange rate of measure token supply : dripped tokens
     */
    uint112 public exchangeRateMantissa;

    /**
     * @notice The total amount of tokens that have been dripped but not claimed
     */
    uint112 public totalUnclaimed;

    /**
     * @notice The timestamp at which the tokens were last dripped
     */
    uint32 public lastDripTimestamp;

    /***********************************|
    |   Events                          |
    |__________________________________*/
    /**
     * @dev Emitted when the new asset tokens are added to the disbursement reserve
     */
    event Dropped(uint256 newTokens);

    /**
     * @dev Emitted when a User claims disbursed tokens
     */
    event Claimed(address indexed user, uint256 newTokens);

    /***********************************|
    |   Structs                         |
    |__________________________________*/
    struct UserState {
        uint128 lastExchangeRateMantissa;
        uint128 balance;
    }

    /**
     * @notice The data structure that tracks when a user last received tokens
     */
    mapping(address => UserState) public userStates;

    /***********************************|
    |   Initialize                      |
    |__________________________________*/
    /**
     * @notice Initialize TokenDrop Smart Contract
     * @dev Initialize TokenDrop Smart Contract with the measure (i.e. Pod) and asset (i.e. POOL) variables
     * @param _measure The token being tracked to calculate user asset rewards
     * @param _asset The token being rewarded when maintaining a positive balance of the "measure" token
     */
    function initialize(IERC20Upgradeable _measure, IERC20Upgradeable _asset)
        external
        initializer
    {
        require(address(_measure) != address(0), "Pod:invalid-measure-token");
        require(address(_asset) != address(0), "Pod:invalid-asset-token");

        // Initialize ReentrancyGuard
        __ReentrancyGuard_init();

        // Set measure/asset tokens.
        measure = _measure;
        asset = _asset;
    }

    /***********************************|
    |   Public/External                 |
    |__________________________________*/

    /**
     * @notice Should be called before "measure" tokens are transferred or burned
     * @param from The user who is sending the tokens
     * @param to The user who is receiving the tokens
     *@param token The token token they are burning
     */
    function beforeTokenTransfer(
        address from,
        address to,
        address token
    ) external {
        // must be measure and not be minting
        if (token == address(measure)) {
            // Calcuate to tokens balance
            _captureNewTokensForUser(to);

            // If NOT minting calcuate from tokens balance
            if (from != address(0)) {
                _captureNewTokensForUser(from);
            }
        }
    }

    /**
     * @notice Add Asset to TokenDrop and update with drop()
     * @dev Add Asset to TokenDrop and update with drop()
     * @param amount User account
     */
    function addAssetToken(uint256 amount) external returns (bool) {
        // Transfer asset/reward token from msg.sender to TokenDrop
        asset.safeTransferFrom(msg.sender, address(this), amount);

        // Update TokenDrop asset balance
        drop();

        // Return BOOL for transaction gas savings
        return true;
    }

    /**
     * @notice Claim asset rewards
     * @dev Claim asset rewards
     * @param user User account
     */
    function claim(address user) external returns (uint256) {
        UserState memory userState = _computeNewTokensForUser(user);

        uint256 balance = userState.balance;
        userState.balance = 0;
        userStates[user] = userState;

        totalUnclaimed = uint256(totalUnclaimed).sub(balance).toUint112();

        // Internal _nonReentrantTransfer
        _nonReentrantTransfer(user, balance);

        // Emit Claimed
        emit Claimed(user, balance);

        return balance;
    }

    /**
     * @notice Add asset tokens to disburment reserve
     * @dev Should be called immediately before any measure token mints/transfers/burns
     * @return The number of new tokens dropped
     */

    // change to drop
    function drop() public nonReentrant returns (uint256) {
        uint256 assetTotalSupply = asset.balanceOf(address(this));
        uint256 newTokens = assetTotalSupply.sub(totalUnclaimed);

        // if(newTokens > 0)
        if (newTokens > 0) {
            // Check measure token totalSupply()
            uint256 measureTotalSupply = measure.totalSupply();

            // Check measure supply exists
            if (measureTotalSupply > 0) {
                uint256 indexDeltaMantissa =
                    FixedPoint.calculateMantissa(newTokens, measureTotalSupply);
                uint256 nextExchangeRateMantissa =
                    uint256(exchangeRateMantissa).add(indexDeltaMantissa);

                exchangeRateMantissa = nextExchangeRateMantissa.toUint112();
                totalUnclaimed = uint256(totalUnclaimed)
                    .add(newTokens)
                    .toUint112();
                // Emit Dropped
                emit Dropped(newTokens);
            }
        }

        return newTokens;
    }

    /***********************************|
    |   Private/Internal                |
    |__________________________________*/

    /**
     * @dev Transfer asset with reenrancy protection
     * @param user User account
     * @param amount Transfer amount
     */
    function _nonReentrantTransfer(address user, uint256 amount)
        internal
        nonReentrant
    {
        asset.safeTransfer(user, amount);
    }

    /**
     * @notice Captures new tokens for a user
     * @dev This must be called before changes to the user's balance (i.e. before mint, transfer or burns)
     * @param user The user to capture tokens for
     * @return The number of new tokens
     */
    function _captureNewTokensForUser(address user)
        private
        returns (UserState memory)
    {
        UserState memory userState = _computeNewTokensForUser(user);

        userStates[user] = userState;

        return userState;
    }

    /**
     * @notice Compute new token disbursement for a user
     * @dev Calculates a user disbursement via the current measure token balance
     * @param user The user account
     * @return UserState struct
     */
    function _computeNewTokensForUser(address user)
        private
        view
        returns (UserState memory)
    {
        UserState memory userState = userStates[user];
        if (exchangeRateMantissa == userState.lastExchangeRateMantissa) {
            // ignore if exchange rate is same
            return userState;
        }
        uint256 deltaExchangeRateMantissa =
            uint256(exchangeRateMantissa).sub(
                userState.lastExchangeRateMantissa
            );
        uint256 userMeasureBalance = measure.balanceOf(user);
        uint128 newTokens =
            FixedPoint
                .multiplyUintByMantissa(
                userMeasureBalance,
                deltaExchangeRateMantissa
            )
                .toUint128();

        userState = UserState({
            lastExchangeRateMantissa: exchangeRateMantissa,
            balance: userState.balance.add(newTokens).toUint128()
        });

        return userState;
    }
}

File 6 of 27 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

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

File 7 of 27 : SafeMathUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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 SafeMathUpgradeable {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        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;
    }
}

File 8 of 27 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
import "../proxy/Initializable.sol";

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

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

    uint256 private _status;

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

    function __ReentrancyGuard_init_unchained() internal initializer {
        _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;
    }
    uint256[49] private __gap;
}

File 9 of 27 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./IERC20Upgradeable.sol";
import "../../math/SafeMathUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";

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

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

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

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // 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(IERC20Upgradeable 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(IERC20Upgradeable 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(IERC20Upgradeable token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

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

File 10 of 27 : ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../utils/ContextUpgradeable.sol";
import "./IERC20Upgradeable.sol";
import "../../math/SafeMathUpgradeable.sol";
import "../../proxy/Initializable.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable {
    using SafeMathUpgradeable for uint256;

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    function __ERC20_init(string memory name_, string memory symbol_) internal initializer {
        __Context_init_unchained();
        __ERC20_init_unchained(name_, symbol_);
    }

    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return _decimals;
    }

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

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

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

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

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

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

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

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

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

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

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

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

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

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

pragma solidity >=0.6.0 <0.8.0;

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

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

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

    function __Ownable_init_unchained() internal initializer {
        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;
    }
    uint256[49] private __gap;
}

File 12 of 27 : IPod.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.7.0 <0.8.0;

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

/// @title The PoolTogether Pod specification
interface IPod is IERC20Upgradeable {
    /// @notice Returns the address of the prize pool that the pod is bound to
    /// @return The address of the prize pool
    function prizePool() external view returns (address);

    /// @notice Allows a user to deposit into the Pod
    /// @param to The address that shall receive the Pod shares
    /// @param tokenAmount The amount of tokens to deposit.  These are the same tokens used to deposit into the underlying prize pool.
    /// @return The number of Pod shares minted.
    function depositTo(address to, uint256 tokenAmount)
        external
        returns (uint256);

    /// @notice Withdraws a users share of the prize pool.
    /// @dev The function should first withdraw from the 'float'; i.e. the funds that have not yet been deposited.
    /// if the withdraw is for more funds that can be covered by the float, then a withdrawal is made against the underlying
    /// prize pool.  The user will be charged the prize pool's exit fee on the underlying funds.  The fee can be calculated using PrizePool#calculateEarlyExitFee()
    /// @param shareAmount The number of Pod shares to redeem
    /// @param maxFee Max fee amount for withdrawl.
    /// @return The actual amount of tokens that were transferred to the user.  This is the same as the deposit token.
    function withdraw(uint256 shareAmount, uint256 maxFee)
        external
        returns (uint256);

    /// @notice Calculates the token value per Pod share.
    /// @dev This is useful for those who wish to calculate their balance.
    /// @return The token value per Pod share.
    function getPricePerShare() external view returns (uint256);

    /// @notice Allows someone to batch deposit funds into the underlying prize pool.  This should be called periodically.
    /// @dev This function should deposit the float into the prize pool, and claim any POOL tokens and distribute to users (possibly via adaptation of Token Faucet)
    function batch() external returns (uint256);

    /// @notice Allows the owner of the Pod or the asset manager to withdraw tokens from the Pod.
    /// @dev This function should disallow the withdrawal of tickets or POOL to prevent users from being rugged.
    /// @param token The ERC20 token to withdraw.  Must not be prize pool tickets or POOL tokens.
    function withdrawERC20(IERC20Upgradeable token, uint256 amount)
        external
        returns (bool);

    /// @notice Allows the owner of the Pod or the asset manager to withdraw tokens from the Pod.
    /// @dev This is mainly for Loot Boxes; so Loot Boxes that are won can be transferred out.
    /// @param token The address of the ERC721 to withdraw
    /// @param tokenId The token id to withdraw
    function withdrawERC721(IERC721Upgradeable token, uint256 tokenId)
        external
        returns (bool);

    /// @notice Allows a user to claim POOL tokens for an address.  The user will be transferred their share of POOL tokens.
    // function claim(address user) external returns (uint256);
}

File 13 of 27 : IPodManager.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.8.0;

// Interface
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";

interface IPodManager {
    /**
     * @notice liquidate
     * @return uint256 Amount liquidated
     */
    function liquidate(
        address _pod,
        IERC20Upgradeable target,
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path
    ) external returns (bool);

    /**
     * @notice withdrawCollectible
     * @return uint256 Amount liquidated
     */
    function withdrawCollectible(
        address _pod,
        IERC721Upgradeable target,
        uint256 tokenId
    ) external returns (bool);
}

File 14 of 27 : TokenFaucet.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.8.0;

interface TokenFaucet {
    function claim(address user) external returns (uint256);

    function asset() external returns (address);

    function dripRatePerSecond() external returns (uint256);

    function exchangeRateMantissa() external returns (uint112);

    function measure() external returns (address);

    function totalUnclaimed() external returns (uint112);

    function lastDripTimestamp() external returns (uint32);
}

File 15 of 27 : IPrizePool.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.8.0;

import "./ControlledTokenInterface.sol";
import "./TokenListenerInterface.sol";

/// @title Escrows assets and deposits them into a yield source.  Exposes interest to Prize Strategy.  Users deposit and withdraw from this contract to participate in Prize Pool.
/// @notice Accounting is managed using Controlled Tokens, whose mint and burn functions can only be called by this contract.
/// @dev Must be inherited to provide specific yield-bearing asset control, such as Compound cTokens
interface IPrizePool {
    // WARNING: VERIFY THIS VALID PLACE TO INCLUDE FUNCTION
    function prizeStrategy() external returns (address);

    /// @notice Deposit assets into the Prize Pool in exchange for tokens
    /// @param to The address receiving the newly minted tokens
    /// @param amount The amount of assets to deposit
    /// @param controlledToken The address of the type of token the user is minting
    /// @param referrer The referrer of the deposit
    function depositTo(
        address to,
        uint256 amount,
        address controlledToken,
        address referrer
    ) external;

    /// @notice Withdraw assets from the Prize Pool instantly.  A fairness fee may be charged for an early exit.
    /// @param from The address to redeem tokens from.
    /// @param amount The amount of tokens to redeem for assets.
    /// @param controlledToken The address of the token to redeem (i.e. ticket or sponsorship)
    /// @param maximumExitFee The maximum exit fee the caller is willing to pay.  This should be pre-calculated by the calculateExitFee() fxn.
    /// @return The actual exit fee paid
    function withdrawInstantlyFrom(
        address from,
        uint256 amount,
        address controlledToken,
        uint256 maximumExitFee
    ) external returns (uint256);

    /// @notice Withdraw assets from the Prize Pool by placing them into the timelock.
    /// The timelock is used to ensure that the tickets have contributed their fair share of the prize.
    /// @dev Note that if the user has previously timelocked funds then this contract will try to sweep them.
    /// If the existing timelocked funds are still locked, then the incoming
    /// balance is added to their existing balance and the new timelock unlock timestamp will overwrite the old one.
    /// @param from The address to withdraw from
    /// @param amount The amount to withdraw
    /// @param controlledToken The type of token being withdrawn
    /// @return The timestamp from which the funds can be swept
    function withdrawWithTimelockFrom(
        address from,
        uint256 amount,
        address controlledToken
    ) external returns (uint256);

    function withdrawReserve(address to) external returns (uint256);

    /// @notice Returns the balance that is available to award.
    /// @dev captureAwardBalance() should be called first
    /// @return The total amount of assets to be awarded for the current prize
    function awardBalance() external view returns (uint256);

    /// @notice Captures any available interest as award balance.
    /// @dev This function also captures the reserve fees.
    /// @return The total amount of assets to be awarded for the current prize
    function captureAwardBalance() external returns (uint256);

    /// @notice Called by the prize strategy to award prizes.
    /// @dev The amount awarded must be less than the awardBalance()
    /// @param to The address of the winner that receives the award
    /// @param amount The amount of assets to be awarded
    /// @param controlledToken The address of the asset token being awarded
    function award(
        address to,
        uint256 amount,
        address controlledToken
    ) external;

    /// @notice Called by the Prize-Strategy to transfer out external ERC20 tokens
    /// @dev Used to transfer out tokens held by the Prize Pool.  Could be liquidated, or anything.
    /// @param to The address of the winner that receives the award
    /// @param amount The amount of external assets to be awarded
    /// @param externalToken The address of the external asset token being awarded
    function transferExternalERC20(
        address to,
        address externalToken,
        uint256 amount
    ) external;

    /// @notice Called by the Prize-Strategy to award external ERC20 prizes
    /// @dev Used to award any arbitrary tokens held by the Prize Pool
    /// @param to The address of the winner that receives the award
    /// @param amount The amount of external assets to be awarded
    /// @param externalToken The address of the external asset token being awarded
    function awardExternalERC20(
        address to,
        address externalToken,
        uint256 amount
    ) external;

    /// @notice Called by the prize strategy to award external ERC721 prizes
    /// @dev Used to award any arbitrary NFTs held by the Prize Pool
    /// @param to The address of the winner that receives the award
    /// @param externalToken The address of the external NFT token being awarded
    /// @param tokenIds An array of NFT Token IDs to be transferred
    function awardExternalERC721(
        address to,
        address externalToken,
        uint256[] calldata tokenIds
    ) external;

    /// @notice Sweep all timelocked balances and transfer unlocked assets to owner accounts
    /// @param users An array of account addresses to sweep balances for
    /// @return The total amount of assets swept from the Prize Pool
    function sweepTimelockBalances(address[] calldata users)
        external
        returns (uint256);

    /// @notice Calculates a timelocked withdrawal duration and credit consumption.
    /// @param from The user who is withdrawing
    /// @param amount The amount the user is withdrawing
    /// @param controlledToken The type of collateral the user is withdrawing (i.e. ticket or sponsorship)
    /// @return durationSeconds The duration of the timelock in seconds
    function calculateTimelockDuration(
        address from,
        address controlledToken,
        uint256 amount
    ) external returns (uint256 durationSeconds, uint256 burnedCredit);

    /// @notice Calculates the early exit fee for the given amount
    /// @param from The user who is withdrawing
    /// @param controlledToken The type of collateral being withdrawn
    /// @param amount The amount of collateral to be withdrawn
    /// @return exitFee The exit fee
    /// @return burnedCredit The user's credit that was burned
    function calculateEarlyExitFee(
        address from,
        address controlledToken,
        uint256 amount
    ) external returns (uint256 exitFee, uint256 burnedCredit);

    /// @notice Estimates the amount of time it will take for a given amount of funds to accrue the given amount of credit.
    /// @param _principal The principal amount on which interest is accruing
    /// @param _interest The amount of interest that must accrue
    /// @return durationSeconds The duration of time it will take to accrue the given amount of interest, in seconds.
    function estimateCreditAccrualTime(
        address _controlledToken,
        uint256 _principal,
        uint256 _interest
    ) external view returns (uint256 durationSeconds);

    /// @notice Returns the credit balance for a given user.  Not that this includes both minted credit and pending credit.
    /// @param user The user whose credit balance should be returned
    /// @return The balance of the users credit
    function balanceOfCredit(address user, address controlledToken)
        external
        returns (uint256);

    /// @notice Sets the rate at which credit accrues per second.  The credit rate is a fixed point 18 number (like Ether).
    /// @param _controlledToken The controlled token for whom to set the credit plan
    /// @param _creditRateMantissa The credit rate to set.  Is a fixed point 18 decimal (like Ether).
    /// @param _creditLimitMantissa The credit limit to set.  Is a fixed point 18 decimal (like Ether).
    function setCreditPlanOf(
        address _controlledToken,
        uint128 _creditRateMantissa,
        uint128 _creditLimitMantissa
    ) external;

    /// @notice Returns the credit rate of a controlled token
    /// @param controlledToken The controlled token to retrieve the credit rates for
    /// @return creditLimitMantissa The credit limit fraction.  This number is used to calculate both the credit limit and early exit fee.
    /// @return creditRateMantissa The credit rate. This is the amount of tokens that accrue per second.
    function creditPlanOf(address controlledToken)
        external
        view
        returns (uint128 creditLimitMantissa, uint128 creditRateMantissa);

    /// @notice Allows the Governor to set a cap on the amount of liquidity that he pool can hold
    /// @param _liquidityCap The new liquidity cap for the prize pool
    function setLiquidityCap(uint256 _liquidityCap) external;

    /// @notice Sets the prize strategy of the prize pool.  Only callable by the owner.
    /// @param _prizeStrategy The new prize strategy.  Must implement TokenListenerInterface
    function setPrizeStrategy(TokenListenerInterface _prizeStrategy) external;

    /// @dev Returns the address of the underlying ERC20 asset
    /// @return The address of the asset
    function token() external view returns (address);

    /// @notice An array of the Tokens controlled by the Prize Pool (ie. Tickets, Sponsorship)
    /// @return An array of controlled token addresses
    function tokens() external view returns (address[] memory);

    /// @notice The timestamp at which an account's timelocked balance will be made available to sweep
    /// @param user The address of an account with timelocked assets
    /// @return The timestamp at which the locked assets will be made available
    function timelockBalanceAvailableAt(address user)
        external
        view
        returns (uint256);

    /// @notice The balance of timelocked assets for an account
    /// @param user The address of an account with timelocked assets
    /// @return The amount of assets that have been timelocked
    function timelockBalanceOf(address user) external view returns (uint256);

    /// @notice The total of all controlled tokens and timelock.
    /// @return The current total of all tokens and timelock.
    function accountedBalance() external view returns (uint256);
}

File 16 of 27 : IPrizeStrategyMinimal.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.8.0;

interface IPrizeStrategyMinimal {
    function isRngRequested() external returns (bool);
}

File 17 of 27 : Initializable.sol
// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <0.8.0;

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

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {

    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");

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

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /// @dev Returns true if and only if the function is running in the constructor
    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 18 of 27 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    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);
    }

    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);
            }
        }
    }
}

File 19 of 27 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
import "../proxy/Initializable.sol";

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

    function __Context_init_unchained() internal initializer {
    }
    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;
    }
    uint256[50] private __gap;
}

File 20 of 27 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 21 of 27 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

File 22 of 27 : FixedPoint.sol
/**
Copyright 2020 PoolTogether Inc.

This file is part of PoolTogether.

PoolTogether is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation under version 3 of the License.

PoolTogether is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with PoolTogether.  If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.4.0;

import "./external/openzeppelin/OpenZeppelinSafeMath_V3_3_0.sol";

/**
 * @author Brendan Asselstine
 * @notice Provides basic fixed point math calculations.
 *
 * This library calculates integer fractions by scaling values by 1e18 then performing standard integer math.
 */
library FixedPoint {
    using OpenZeppelinSafeMath_V3_3_0 for uint256;

    // The scale to use for fixed point numbers.  Same as Ether for simplicity.
    uint256 internal constant SCALE = 1e18;

    /**
        * Calculates a Fixed18 mantissa given the numerator and denominator
        *
        * The mantissa = (numerator * 1e18) / denominator
        *
        * @param numerator The mantissa numerator
        * @param denominator The mantissa denominator
        * @return The mantissa of the fraction
        */
    function calculateMantissa(uint256 numerator, uint256 denominator) internal pure returns (uint256) {
        uint256 mantissa = numerator.mul(SCALE);
        mantissa = mantissa.div(denominator);
        return mantissa;
    }

    /**
        * Multiplies a Fixed18 number by an integer.
        *
        * @param b The whole integer to multiply
        * @param mantissa The Fixed18 number
        * @return An integer that is the result of multiplying the params.
        */
    function multiplyUintByMantissa(uint256 b, uint256 mantissa) internal pure returns (uint256) {
        uint256 result = mantissa.mul(b);
        result = result.div(SCALE);
        return result;
    }

    /**
    * Divides an integer by a fixed point 18 mantissa
    *
    * @param dividend The integer to divide
    * @param mantissa The fixed point 18 number to serve as the divisor
    * @return An integer that is the result of dividing an integer by a fixed point 18 mantissa
    */
    function divideUintByMantissa(uint256 dividend, uint256 mantissa) internal pure returns (uint256) {
        uint256 result = SCALE.mul(dividend);
        result = result.div(mantissa);
        return result;
    }
}

File 23 of 27 : ExtendedSafeCast.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.8.0;

library ExtendedSafeCast {
    /**
     * @dev Converts an unsigned uint256 into a unsigned uint128.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxUint118.
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value < 2**128, "SafeCast: value doesn't fit in an uint128");
        return uint128(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a unsigned uint112.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxUint112.
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        require(value < 2**112, "SafeCast: value doesn't fit in an uint112");
        return uint112(value);
    }
}

File 24 of 27 : OpenZeppelinSafeMath_V3_3_0.sol
// SPDX-License-Identifier: MIT

// NOTE: Copied from OpenZeppelin Contracts version 3.3.0

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

        return c;
    }

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

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

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

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

        return c;
    }

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

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

        return c;
    }

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

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

File 25 of 27 : ControlledTokenInterface.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.8.0;

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

import "./TokenControllerInterface.sol";

/// @title Controlled ERC20 Token
/// @notice ERC20 Tokens with a controller for minting & burning
interface ControlledTokenInterface is IERC20Upgradeable {
    /// @notice Interface to the contract responsible for controlling mint/burn
    function controller() external view returns (TokenControllerInterface);

    /// @notice Allows the controller to mint tokens for a user account
    /// @dev May be overridden to provide more granular control over minting
    /// @param _user Address of the receiver of the minted tokens
    /// @param _amount Amount of tokens to mint
    function controllerMint(address _user, uint256 _amount) external;

    /// @notice Allows the controller to burn tokens from a user account
    /// @dev May be overridden to provide more granular control over burning
    /// @param _user Address of the holder account to burn tokens from
    /// @param _amount Amount of tokens to burn
    function controllerBurn(address _user, uint256 _amount) external;

    /// @notice Allows an operator via the controller to burn tokens on behalf of a user account
    /// @dev May be overridden to provide more granular control over operator-burning
    /// @param _operator Address of the operator performing the burn action via the controller contract
    /// @param _user Address of the holder account to burn tokens from
    /// @param _amount Amount of tokens to burn
    function controllerBurnFrom(
        address _operator,
        address _user,
        uint256 _amount
    ) external;
}

File 26 of 27 : TokenListenerInterface.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.8.0;

import "@openzeppelin/contracts-upgradeable/introspection/IERC165Upgradeable.sol";

/// @title An interface that allows a contract to listen to token mint, transfer and burn events.
interface TokenListenerInterface is IERC165Upgradeable {
    /// @notice Called when tokens are minted.
    /// @param to The address of the receiver of the minted tokens.
    /// @param amount The amount of tokens being minted
    /// @param controlledToken The address of the token that is being minted
    /// @param referrer The address that referred the minting.
    function beforeTokenMint(
        address to,
        uint256 amount,
        address controlledToken,
        address referrer
    ) external;

    /// @notice Called when tokens are transferred or burned.
    /// @param from The address of the sender of the token transfer
    /// @param to The address of the receiver of the token transfer.  Will be the zero address if burning.
    /// @param amount The amount of tokens transferred
    /// @param controlledToken The address of the token that was transferred
    function beforeTokenTransfer(
        address from,
        address to,
        uint256 amount,
        address controlledToken
    ) external;
}

File 27 of 27 : TokenControllerInterface.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.8.0;

/// @title Controlled ERC20 Token Interface
/// @notice Required interface for Controlled ERC20 Tokens linked to a Prize Pool
/// @dev Defines the spec required to be implemented by a Controlled ERC20 Token
interface TokenControllerInterface {
    /// @dev Controller hook to provide notifications & rule validations on token transfers to the controller.
    /// This includes minting and burning.
    /// @param from Address of the account sending the tokens (address(0x0) on minting)
    /// @param to Address of the account receiving the tokens (address(0x0) on burning)
    /// @param amount Amount of tokens being transferred
    function beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) external;
}

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

Contract ABI

[{"inputs":[{"internalType":"contract TokenDropFactory","name":"_tokenDropFactory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Pod","name":"pod","type":"address"},{"indexed":true,"internalType":"contract TokenDrop","name":"drop","type":"address"}],"name":"LogCreatedPodAndTokenDrop","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"proxy","type":"address"}],"name":"ProxyCreated","type":"event"},{"inputs":[{"internalType":"address","name":"_prizePool","type":"address"},{"internalType":"address","name":"_ticket","type":"address"},{"internalType":"address","name":"_faucet","type":"address"},{"internalType":"address","name":"_manager","type":"address"},{"internalType":"uint8","name":"_decimals","type":"uint8"}],"name":"create","outputs":[{"internalType":"address","name":"pod","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_logic","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"deployMinimal","outputs":[{"internalType":"address","name":"proxy","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"podInstance","outputs":[{"internalType":"contract Pod","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenDropFactory","outputs":[{"internalType":"contract TokenDropFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50604051613f83380380613f838339818101604052602081101561003357600080fd5b50516001600160a01b03811661007a5760405162461bcd60e51b8152600401808060200182810382526025815260200180613f5e6025913960400191505060405180910390fd5b604051610086906100d7565b604051809103906000f0801580156100a2573d6000803e3d6000fd5b50600180546001600160a01b039283166001600160a01b031991821617909155600080549390921692169190911790556100e4565b6136c48061089a83390190565b6107a7806100f36000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063116a39431461005157806350efa2bf146100b7578063b3eeb5e2146100bf578063b8432a2914610175575b600080fd5b61009b600480360360a081101561006757600080fd5b5080356001600160a01b0390811691602081013582169160408201358116916060810135909116906080013560ff1661017d565b604080516001600160a01b039092168252519081900360200190f35b61009b610559565b61009b600480360360408110156100d557600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561010057600080fd5b82018360208201111561011257600080fd5b8035906020019184600183028401116401000000008311171561013457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610568945050505050565b61009b61073e565b600154604080516020810190915260008082529182916101a6916001600160a01b031690610568565b9050806001600160a01b03166389232a008888866040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018260ff1681526020019350505050600060405180830381600087803b15801561021357600080fd5b505af1158015610227573d6000803e3d6000fd5b50505050806001600160a01b031663d0ebdbe7856040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050602060405180830381600087803b15801561027a57600080fd5b505af115801561028e573d6000803e3d6000fd5b505050506040513d60208110156102a457600080fd5b50600090506001600160a01b038616156104b757600086905060008054906101000a90046001600160a01b03166001600160a01b0316633e68680a84836001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561031b57600080fd5b505af115801561032f573d6000803e3d6000fd5b505050506040513d602081101561034557600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301525160448083019260209291908290030181600087803b15801561039757600080fd5b505af11580156103ab573d6000803e3d6000fd5b505050506040513d60208110156103c157600080fd5b505160408051620fd70d60eb1b81526001600160a01b038481166004830152915192945090851691637eb86800916024808201926020929091908290030181600087803b15801561041157600080fd5b505af1158015610425573d6000803e3d6000fd5b505050506040513d602081101561043b57600080fd5b505060408051631621a58960e01b81526001600160a01b038481166004830152915191851691631621a589916024808201926020929091908290030181600087803b15801561048957600080fd5b505af115801561049d573d6000803e3d6000fd5b505050506040513d60208110156104b357600080fd5b5050505b6040805163f2fde38b60e01b815233600482015290516001600160a01b0384169163f2fde38b91602480830192600092919082900301818387803b1580156104fe57600080fd5b505af1158015610512573d6000803e3d6000fd5b50506040516001600160a01b038085169350851691507f3c46040a888d584b68fd2711f7497191a5465a2200e3b3271e8b988037f720c590600090a3509695505050505050565b6000546001600160a01b031681565b6000808360601b9050604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528160148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09250506001600160a01b038216610610576040805162461bcd60e51b815260206004820152601c60248201527f50726f7879466163746f72793a696e76616c69642d6164647265737300000000604482015290519081900360640190fd5b604080516001600160a01b038416815290517efffc2da0b561cae30d9826d37709e9421c4725faebc226cbbb7ef5fc5e73499181900360200190a1825115610737576000826001600160a01b0316846040518082805190602001908083835b6020831061068e5780518252601f19909201916020918201910161066f565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146106f0576040519150601f19603f3d011682016040523d82523d6000602084013e6106f5565b606091505b50509050806107355760405162461bcd60e51b815260040180806020018281038252602481526020018061074e6024913960400191505060405180910390fd5b505b5092915050565b6001546001600160a01b03168156fe50726f7879466163746f72792f636f6e7374727563746f722d63616c6c2d6661696c6564a26469706673582212207e0155206f69163068035cf2dfa97164104e868fa5fd28475252d5834076a35964736f6c63430007000033608060405234801561001057600080fd5b506136a4806100206000396000f3fe608060405234801561001057600080fd5b50600436106102115760003560e01c806389232a0011610125578063d0ebdbe7116100ad578063f3e414f81161007c578063f3e414f814610619578063f751cd8f14610645578063fc0c546a1461064d578063fdb8015914610655578063ffaad6a51461065d57610211565b8063d0ebdbe714610597578063dd62ed3e146105bd578063de5f72fd146105eb578063f2fde38b146105f357610211565b8063a457c2d7116100f4578063a457c2d714610501578063a9059cbb1461052d578063af71356614610559578063b69ef8a814610561578063ccf927381461056957610211565b806389232a001461048b5780638da5cb5b146104c557806395d89b41146104cd578063a1db9782146104d557610211565b80633d68175c116101a85780636cc25db7116101775780636cc25db71461042557806370a082311461042d578063715018a614610453578063719ce73e1461045d5780637eb868001461046557610211565b80633d68175c146103b9578063441a3e70146103c1578063481c6a75146103e457806365deaa671461040857610211565b806323b872dd116101e457806323b872dd14610313578063313ce5671461034957806339509351146103675780633af9e6691461039357610211565b806306fdde0314610216578063095ea7b3146102935780631621a589146102d357806318160ddd146102f9575b600080fd5b61021e610689565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610258578181015183820152602001610240565b50505050905090810190601f1680156102855780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102bf600480360360408110156102a957600080fd5b506001600160a01b038135169060200135610720565b604080519115158252519081900360200190f35b6102bf600480360360208110156102e957600080fd5b50356001600160a01b031661073e565b6103016107f2565b60408051918252519081900360200190f35b6102bf6004803603606081101561032957600080fd5b506001600160a01b038135811691602081013590911690604001356107f8565b610351610880565b6040805160ff9092168252519081900360200190f35b6102bf6004803603604081101561037d57600080fd5b506001600160a01b038135169060200135610889565b610301600480360360208110156103a957600080fd5b50356001600160a01b03166108d7565b6103016108ea565b610301600480360360408110156103d757600080fd5b508035906020013561090c565b6103ec610a34565b604080516001600160a01b039092168252519081900360200190f35b6103016004803603602081101561041e57600080fd5b5035610a43565b6103ec610b14565b6103016004803603602081101561044357600080fd5b50356001600160a01b0316610b23565b61045b610b3e565b005b6103ec610bea565b6102bf6004803603602081101561047b57600080fd5b50356001600160a01b0316610bf9565b61045b600480360360608110156104a157600080fd5b5080356001600160a01b03908116916020810135909116906040013560ff16610cac565b6103ec61140f565b61021e61141e565b6102bf600480360360408110156104eb57600080fd5b506001600160a01b03813516906020013561147f565b6102bf6004803603604081101561051757600080fd5b506001600160a01b03813516906020013561168b565b6102bf6004803603604081101561054357600080fd5b506001600160a01b0381351690602001356116f3565b610301611707565b6103016117e8565b61045b6004803603604081101561057f57600080fd5b506001600160a01b0381358116916020013516611808565b6102bf600480360360208110156105ad57600080fd5b50356001600160a01b0316611883565b610301600480360360408110156105d357600080fd5b506001600160a01b0381358116916020013516611997565b6103ec6119c2565b61045b6004803603602081101561060957600080fd5b50356001600160a01b03166119d1565b6102bf6004803603604081101561062f57600080fd5b506001600160a01b038135169060200135611ad4565b610301611c17565b6103ec611e89565b6103ec611e98565b6103016004803603604081101561067357600080fd5b506001600160a01b038135169060200135611ea7565b60368054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107155780601f106106ea57610100808354040283529160200191610715565b820191906000526020600020905b8154815290600101906020018083116106f857829003601f168201915b505050505090505b90565b600061073461072d6120e8565b84846120ec565b5060015b92915050565b60006107486120e8565b6001600160a01b031661075961140f565b6001600160a01b0316146107a2576040805162461bcd60e51b81526020600482018190526024820152600080516020613560833981519152604482015290519081900360640190fd5b60cc80546001600160a01b0319166001600160a01b0384169081179091556040517f7a48cfaaa18629467c1c1a03e9ca7914885d91200eb368e11069f932cf61eb6b90600090a25060015b919050565b60355490565b60006108058484846121d8565b610875846108116120e8565b61087085604051806060016040528060288152602001613538602891396001600160a01b038a1660009081526034602052604081209061084f6120e8565b6001600160a01b031681526020810191909152604001600020549190612335565b6120ec565b5060015b9392505050565b60385460ff1690565b60006107346108966120e8565b8461087085603460006108a76120e8565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906123cc565b60006107386108e583610b23565b612426565b6000806108f5610880565b60ff16905061090681600a0a612426565b91505090565b600060026097541415610966576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026097558261097533610b23565b10156109c8576040805162461bcd60e51b815260206004820152601760248201527f506f643a696e73756666696369656e742d736861726573000000000000000000604482015290519081900360640190fd5b60006109d48484612466565b60c9549091506109ee906001600160a01b03163383612591565b6040805182815260208101869052815133927fdf273cb619d95419a9cd0ec88123a0538c85064229baa6363788f743fff90deb928290030190a260016097559392505050565b60cd546001600160a01b031681565b600080610a4e6125e8565b9050808311610a615760009150506107ed565b60ce5460ca546000916001600160a01b039081169163888c2b6f91309116610a898887612664565b6040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b0316815260200182815260200193505050506040805180830381600087803b158015610ade57600080fd5b505af1158015610af2573d6000803e3d6000fd5b505050506040513d6040811015610b0857600080fd5b505192506107ed915050565b60ca546001600160a01b031681565b6001600160a01b031660009081526033602052604090205490565b610b466120e8565b6001600160a01b0316610b5761140f565b6001600160a01b031614610ba0576040805162461bcd60e51b81526020600482018190526024820152600080516020613560833981519152604482015290519081900360640190fd5b6065546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3606580546001600160a01b0319169055565b60ce546001600160a01b031690565b6000610c036120e8565b6001600160a01b0316610c1461140f565b6001600160a01b031614610c5d576040805162461bcd60e51b81526020600482018190526024820152600080516020613560833981519152604482015290519081900360640190fd5b60cb80546001600160a01b0319166001600160a01b0384169081179091556040517f1062797e1a541ffcf19764c36deb3ad9960105ec3e52e4ff3bc3503ec35551a490600090a2506001919050565b600054610100900460ff1680610cc55750610cc56126c1565b80610cd3575060005460ff16155b610d0e5760405162461bcd60e51b815260040180806020018281038252602e8152602001806134e9602e913960400191505060405180910390fd5b600054610100900460ff16158015610d39576000805460ff1961ff0019909116610100171660011790555b60ce80546001600160a01b0319166001600160a01b038616179055610d5c6126d2565b60ce5460408051637e062a3560e11b81529051611182926001600160a01b03169163fc0c546a916004808301926020929190829003018186803b158015610da257600080fd5b505afa158015610db6573d6000803e3d6000fd5b505050506040513d6020811015610dcc57600080fd5b5051604080516306fdde0360e01b815290516001600160a01b03909216916306fdde0391600480820192600092909190829003018186803b158015610e1057600080fd5b505afa158015610e24573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610e4d57600080fd5b8101908080516040519392919084640100000000821115610e6d57600080fd5b908301906020820185811115610e8257600080fd5b8251640100000000811182820188101715610e9c57600080fd5b82525081516020918201929091019080838360005b83811015610ec9578181015183820152602001610eb1565b50505050905090810190601f168015610ef65780820380516001836020036101000a031916815260200191505b5060405250505060405160200180806302837b2160e51b81525060040182805190602001908083835b60208310610f3e5780518252601f199092019160209182019101610f1f565b51815160209384036101000a60001901801990921691161790526040805192909401828103601f1901835280855260ce54637e062a3560e11b825294519296506001600160a01b03909416945063fc0c546a936004808201945091929190829003018186803b158015610fb057600080fd5b505afa158015610fc4573d6000803e3d6000fd5b505050506040513d6020811015610fda57600080fd5b5051604080516395d89b4160e01b815290516001600160a01b03909216916395d89b4191600480820192600092909190829003018186803b15801561101e57600080fd5b505afa158015611032573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561105b57600080fd5b810190808051604051939291908464010000000082111561107b57600080fd5b90830190602082018581111561109057600080fd5b82516401000000008111828201881017156110aa57600080fd5b82525081516020918201929091019080838360005b838110156110d75781810151838201526020016110bf565b50505050905090810190601f1680156111045780820380516001836020036101000a031916815260200191505b506040525050506040516020018080600760fc1b81525060010182805190602001908083835b602083106111495780518252601f19909201916020918201910161112a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405261277c565b61118a612854565b6111938261294d565b60ce5460408051634eb1c24560e11b815290516060926001600160a01b031691639d63848a916004808301926000929190829003018186803b1580156111d857600080fd5b505afa1580156111ec573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561121557600080fd5b810190808051604051939291908464010000000082111561123557600080fd5b90830190602082018581111561124a57600080fd5b825186602082028301116401000000008211171561126757600080fd5b82525081516020918201928201910280838360005b8381101561129457818101518382015260200161127c565b505050509050016040525050509050806000815181106112b057fe5b60200260200101516001600160a01b0316846001600160a01b031614806112fc5750806001815181106112df57fe5b60200260200101516001600160a01b0316846001600160a01b0316145b61134d576040805162461bcd60e51b815260206004820152601d60248201527f506f643a696e697469616c697a652d696e76616c69642d7469636b6574000000604482015290519081900360640190fd5b60ce60009054906101000a90046001600160a01b03166001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561139b57600080fd5b505afa1580156113af573d6000803e3d6000fd5b505050506040513d60208110156113c557600080fd5b505160c980546001600160a01b03199081166001600160a01b039384161790915560ca8054909116918616919091179055508015611409576000805461ff00191690555b50505050565b6065546001600160a01b031690565b60378054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107155780601f106106ea57610100808354040283529160200191610715565b60008061148a6120e8565b60cd549091506001600160a01b03808316911614806114c15750806001600160a01b03166114b661140f565b6001600160a01b0316145b61150d576040805162461bcd60e51b8152602060048201526018602482015277141bd90e9b585b9859d95c8b5d5b985d5d1a1bdc9a5e995960421b604482015290519081900360640190fd5b60c9546001600160a01b03858116911614801590611539575060ca546001600160a01b03858116911614155b80156115dd575060cc546001600160a01b031615806115dd575060cc60009054906101000a90046001600160a01b03166001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156115a157600080fd5b505afa1580156115b5573d6000803e3d6000fd5b505050506040513d60208110156115cb57600080fd5b50516001600160a01b03858116911614155b61162e576040805162461bcd60e51b815260206004820152601860248201527f506f643a696e76616c69642d7461726765742d746f6b656e0000000000000000604482015290519081900360640190fd5b6116426001600160a01b0385163385612591565b6040805184815290516001600160a01b038616917f7e2c99819371db0a6fc6f4269fe872496e44f502df19ba3eae594b7a15987460919081900360200190a25060019392505050565b60006107346116986120e8565b846108708560405180606001604052806025815260200161364a60259139603460006116c26120e8565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190612335565b60006107346117006120e8565b84846121d8565b6000806117126125e8565b60ce5460c954919250611732916001600160a01b03908116911683612963565b60ce5460ca546040805163e323f82560e01b81523060048201819052602482018690526001600160a01b03938416604483015260648201529051919092169163e323f82591608480830192600092919082900301818387803b15801561179757600080fd5b505af11580156117ab573d6000803e3d6000fd5b50506040805184815290517f1d026eaf76f56dd6eeb046aab9c5852b4d867e7c74376fe63c06328d27bbdb669350908190036020019150a1905090565b60006118036117f5612a76565b6117fd6125e8565b906123cc565b905090565b6118106120e8565b6001600160a01b031661182161140f565b6001600160a01b03161461186a576040805162461bcd60e51b81526020600482018190526024820152600080516020613560833981519152604482015290519081900360640190fd5b61187f6001600160a01b038316826000612963565b5050565b600061188d6120e8565b6001600160a01b031661189e61140f565b6001600160a01b0316146118e7576040805162461bcd60e51b81526020600482018190526024820152600080516020613560833981519152604482015290519081900360640190fd5b6001600160a01b038216611942576040805162461bcd60e51b815260206004820152601b60248201527f506f643a696e76616c69642d6d616e616765722d616464726573730000000000604482015290519081900360640190fd5b60cd80546001600160a01b0319166001600160a01b0384811691821792839055604051919216907f80f15e9dbc60884fdb59fb8ed4fc48a9a689e028f055e893ed45ca5be67c5c8590600090a3506001919050565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b60cb546001600160a01b031681565b6119d96120e8565b6001600160a01b03166119ea61140f565b6001600160a01b031614611a33576040805162461bcd60e51b81526020600482018190526024820152600080516020613560833981519152604482015290519081900360640190fd5b6001600160a01b038116611a785760405162461bcd60e51b815260040180806020018281038252602681526020018061342a6026913960400191505060405180910390fd5b6065546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3606580546001600160a01b0319166001600160a01b0392909216919091179055565b600080611adf6120e8565b60cd549091506001600160a01b0380831691161480611b165750806001600160a01b0316611b0b61140f565b6001600160a01b0316145b611b62576040805162461bcd60e51b8152602060048201526018602482015277141bd90e9b585b9859d95c8b5d5b985d5d1a1bdc9a5e995960421b604482015290519081900360640190fd5b604080516323b872dd60e01b81523060048201523360248201526044810185905290516001600160a01b038616916323b872dd91606480830192600092919082900301818387803b158015611bb657600080fd5b505af1158015611bca573d6000803e3d6000fd5b50506040805186815290516001600160a01b03881693507f1c5be65d2245c05a955440008d97c579b7046fffdfb8482e1884ae42be57d98d92509081900360200190a25060019392505050565b60cb546000906001600160a01b031615611ca55760cb5460408051630f41a04d60e11b815230600482015290516001600160a01b0390921691631e83409a916024808201926020929091908290030181600087803b158015611c7857600080fd5b505af1158015611c8c573d6000803e3d6000fd5b505050506040513d6020811015611ca257600080fd5b50505b611cad611707565b5060cc546001600160a01b031615611e815760cc54604080516338d52e0f60e01b815290516000926001600160a01b0316916338d52e0f916004808301926020929190829003018186803b158015611d0457600080fd5b505afa158015611d18573d6000803e3d6000fd5b505050506040513d6020811015611d2e57600080fd5b5051604080516370a0823160e01b815230600482015290519192506000916001600160a01b038416916370a08231916024808301926020929190829003018186803b158015611d7c57600080fd5b505afa158015611d90573d6000803e3d6000fd5b505050506040513d6020811015611da657600080fd5b505190508015611e455760cc54611dca906001600160a01b03848116911683612963565b60cc546040805163949e196f60e01b81526004810184905290516001600160a01b039092169163949e196f916024808201926020929091908290030181600087803b158015611e1857600080fd5b505af1158015611e2c573d6000803e3d6000fd5b505050506040513d6020811015611e4257600080fd5b50505b6040805182815290517fa71b671080e0f92a89a9abb935000df04b23c1c31382efb1812bb95dff91bab69181900360200190a1915061071d9050565b50600061071d565b60c9546001600160a01b031681565b60cc546001600160a01b031681565b60ce5460408051634c5f9f5b60e11b815290516000926001600160a01b0316916398bf3eb691600480830192602092919082900301818787803b158015611eed57600080fd5b505af1158015611f01573d6000803e3d6000fd5b505050506040513d6020811015611f1757600080fd5b5051604080516304441c3960e21b815290516001600160a01b039092169163111070e4916004808201926020929091908290030181600087803b158015611f5d57600080fd5b505af1158015611f71573d6000803e3d6000fd5b505050506040513d6020811015611f8757600080fd5b505115611fc55760405162461bcd60e51b815260040180806020018281038252602b8152602001806134be602b913960400191505060405180910390fd5b6002609754141561201d576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260975581612069576040805162461bcd60e51b8152602060048201526012602482015271141bd90e9a5b9d985b1a590b585b5bdd5b9d60721b604482015290519081900360640190fd5b600061207483612ac1565b60c95490915061208f906001600160a01b0316333086612afb565b6120998482612b55565b604080518481526020810183905281516001600160a01b038716927f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca928290030190a260016097559392505050565b3390565b6001600160a01b0383166121315760405162461bcd60e51b81526004018080602001828103825260248152602001806135c66024913960400191505060405180910390fd5b6001600160a01b0382166121765760405162461bcd60e51b81526004018080602001828103825260228152602001806134506022913960400191505060405180910390fd5b6001600160a01b03808416600081815260346020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b03831661221d5760405162461bcd60e51b81526004018080602001828103825260258152602001806135a16025913960400191505060405180910390fd5b6001600160a01b0382166122625760405162461bcd60e51b81526004018080602001828103825260238152602001806133e56023913960400191505060405180910390fd5b61226d838383612c47565b6122aa81604051806060016040528060268152602001613472602691396001600160a01b0386166000908152603360205260409020549190612335565b6001600160a01b0380851660009081526033602052604080822093909355908416815220546122d990826123cc565b6001600160a01b0380841660008181526033602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156123c45760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612389578181015183820152602001612371565b50505050905090810190601f1680156123b65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610879576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000806124316107f2565b9050801561245d576124558161244f856124496117e8565b90612cd1565b90612d2a565b9150506107ed565b829150506107ed565b60008061247284612426565b905061247e3385612d91565b60c954604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156124c957600080fd5b505afa1580156124dd573d6000803e3d6000fd5b505050506040513d60208110156124f357600080fd5b5051905060008183111561258557600061250d8484612664565b9050600061251b8288612e8d565b905061252784826123cc565b9250866125348685612664565b111561257e576040805162461bcd60e51b8152602060048201526014602482015273141bd90e9b585e0b5999594b595e18d95959195960621b604482015290519081900360640190fd5b5050612588565b50815b95945050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526125e390849061302b565b505050565b60c954604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561263357600080fd5b505afa158015612647573d6000803e3d6000fd5b505050506040513d602081101561265d57600080fd5b5051905090565b6000828211156126bb576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60006126cc306130dc565b15905090565b600054610100900460ff16806126eb57506126eb6126c1565b806126f9575060005460ff16155b6127345760405162461bcd60e51b815260040180806020018281038252602e8152602001806134e9602e913960400191505060405180910390fd5b600054610100900460ff1615801561275f576000805460ff1961ff0019909116610100171660011790555b6127676130e2565b8015612779576000805461ff00191690555b50565b600054610100900460ff168061279557506127956126c1565b806127a3575060005460ff16155b6127de5760405162461bcd60e51b815260040180806020018281038252602e8152602001806134e9602e913960400191505060405180910390fd5b600054610100900460ff16158015612809576000805460ff1961ff0019909116610100171660011790555b825161281c906036906020860190613351565b508151612830906037906020850190613351565b506038805460ff1916601217905580156125e3576000805461ff0019169055505050565b600054610100900460ff168061286d575061286d6126c1565b8061287b575060005460ff16155b6128b65760405162461bcd60e51b815260040180806020018281038252602e8152602001806134e9602e913960400191505060405180910390fd5b600054610100900460ff161580156128e1576000805460ff1961ff0019909116610100171660011790555b60006128eb6120e8565b606580546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508015612779576000805461ff001916905550565b6038805460ff191660ff92909216919091179055565b8015806129e9575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156129bb57600080fd5b505afa1580156129cf573d6000803e3d6000fd5b505050506040513d60208110156129e557600080fd5b5051155b612a245760405162461bcd60e51b81526004018080602001828103825260368152602001806136146036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526125e390849061302b565b60ca54604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561263357600080fd5b60008080612acd6107f2565b905080612adc57839150612af4565b612af1612ae76117e8565b61244f8684612cd1565b91505b5092915050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261140990859061302b565b6001600160a01b038216612bb0576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b612bbc60008383612c47565b603554612bc990826123cc565b6035556001600160a01b038216600090815260336020526040902054612bef90826123cc565b6001600160a01b03831660008181526033602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b60cc546001600160a01b0316156125e35760cc54604080516320034ff760e11b81526001600160a01b0386811660048301528581166024830152306044830152915191909216916340069fee91606480830192600092919082900301818387803b158015612cb457600080fd5b505af1158015612cc8573d6000803e3d6000fd5b50505050505050565b600082612ce057506000610738565b82820282848281612ced57fe5b04146108795760405162461bcd60e51b81526004018080602001828103825260218152602001806135176021913960400191505060405180910390fd5b6000808211612d80576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381612d8957fe5b049392505050565b6001600160a01b038216612dd65760405162461bcd60e51b81526004018080602001828103825260218152602001806135806021913960400191505060405180910390fd5b612de282600083612c47565b612e1f81604051806060016040528060228152602001613408602291396001600160a01b0385166000908152603360205260409020549190612335565b6001600160a01b038316600090815260336020526040902055603554612e459082612664565b6035556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b60c954604080516370a0823160e01b815230600482015290516000926001600160a01b031691839183916370a08231916024808301926020929190829003018186803b158015612edc57600080fd5b505afa158015612ef0573d6000803e3d6000fd5b505050506040513d6020811015612f0657600080fd5b505160ce5460ca546040805163a016240b60e01b8152306004820152602481018a90526001600160a01b03928316604482015260648101899052905193945091169163a016240b916084808201926020929091908290030181600087803b158015612f7057600080fd5b505af1158015612f84573d6000803e3d6000fd5b505050506040513d6020811015612f9a57600080fd5b5050604080516370a0823160e01b815230600482015290516000916001600160a01b038516916370a0823191602480820192602092909190829003018186803b158015612fe657600080fd5b505afa158015612ffa573d6000803e3d6000fd5b505050506040513d602081101561301057600080fd5b5051905060006130208284612664565b979650505050505050565b6060613080826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166131889092919063ffffffff16565b8051909150156125e35780806020019051602081101561309f57600080fd5b50516125e35760405162461bcd60e51b815260040180806020018281038252602a8152602001806135ea602a913960400191505060405180910390fd5b3b151590565b600054610100900460ff16806130fb57506130fb6126c1565b80613109575060005460ff16155b6131445760405162461bcd60e51b815260040180806020018281038252602e8152602001806134e9602e913960400191505060405180910390fd5b600054610100900460ff1615801561316f576000805460ff1961ff0019909116610100171660011790555b60016097558015612779576000805461ff001916905550565b6060613197848460008561319f565b949350505050565b6060824710156131e05760405162461bcd60e51b81526004018080602001828103825260268152602001806134986026913960400191505060405180910390fd5b6131e9856130dc565b61323a576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106132795780518252601f19909201916020918201910161325a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146132db576040519150601f19603f3d011682016040523d82523d6000602084013e6132e0565b606091505b5091509150613020828286606083156132fa575081610879565b82511561330a5782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315612389578181015183820152602001612371565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061339257805160ff19168380011785556133bf565b828001600101855582156133bf579182015b828111156133bf5782518255916020019190600101906133a4565b506133cb9291506133cf565b5090565b5b808211156133cb57600081556001016133d056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c43616e6e6f74206465706f736974207768696c65207072697a65206973206265696e672061776172646564496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220071035fcf04263d347cab2f0a875992199115ec4e47a893310a45b2008a119c464736f6c63430007000033506f64466163746f72793a696e76616c69642d746f6b656e2d64726f702d666163746f7279000000000000000000000000f94ee6cdc66172f49a8adf3e60a1cb00c0bb8a59

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

000000000000000000000000f94ee6cdc66172f49a8adf3e60a1cb00c0bb8a59

-----Decoded View---------------
Arg [0] : _tokenDropFactory (address): 0xf94ee6cdc66172f49a8adf3e60a1cb00c0bb8a59

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


Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading

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