// Contract: MerkleTwoDrop
// Target function: function award(uint _id, address _recipient, uint256 _amount0, uint256 _amount1, bytes32[] calldata _proof) public
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

contract MerkleTwoDrop {

    struct Airdrop {
      bytes32 root;
      mapping(address => bool) awarded;
    }

    /// Events
    event Start(uint id);
    event Award(uint id, address recipient, uint amount0, uint amount1);

    /// State
    mapping(uint => Airdrop) public airdrops;
    ITokenManager public tokenManager0;
    ITokenManager public tokenManager1;
    uint public airdropsCount;
    address public startAuth;

    bool private initialized;

    function initialize(address _tokenManager0, address _tokenManager1, address _startAuth) public {
        require(!initialized, "Already initialized");
        initialized = true;

        require(_tokenManager0 != address(0), "Needs token0 manager");
        require(_tokenManager1 != address(0), "Needs token1 manager");
        require(_startAuth != address(0), "Needs startAuth");

        tokenManager0 = ITokenManager(_tokenManager0);
        tokenManager1 = ITokenManager(_tokenManager1);
        startAuth = _startAuth;
    }

    /**
     * @notice Start a new airdrop `_root`
     * @param _root New airdrop merkle root
     */
    function start(bytes32 _root) public {
        require(msg.sender == startAuth, "Not authorized");
        _start(_root);
    }

    function _start(bytes32 _root) internal returns(uint id){
        id = ++airdropsCount;    // start at 1
        Airdrop storage newAirdrop = airdrops[id];
        newAirdrop.root = _root;
        emit Start(id);
    }