// Contract: AtomicBlue
// Target function: function approve(Token _token, address _spender, uint _amount) internal
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

contract AtomicTypes{
    struct SwapParams{
        Token sellToken; 
        uint256 input;
        Token buyToken;
        uint minOutput;
    }
    
    struct DistributionParams{
        IAtomicExchange[] exchangeModules;
        bytes[] exchangeData;
        uint256[] chunks;
    }
    
    event Trade(
        address indexed sellToken,
        uint256 sellAmount,
        address indexed buyToken,
        uint256 buyAmount,
        address indexed trader,
        address receiver
    );
}

contract AtomicUtils{    
    // ETH and its wrappers
    address constant WETHAddress = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
    IWETH constant WETH = IWETH(WETHAddress);
    Token constant ETH = Token(address(0));
    address constant EEEAddress = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
    Token constant EEE = Token(EEEAddress);
    
    // Universal function to query this contracts balance, supporting  and Token
    function balanceOf(Token token) internal view returns(uint balance){
        if(isETH(token)){
            return address(this).balance;
        }else{
            return token.balanceOf(address(this));
        }
    }
    
    // Universal send function, supporting ETH and Token
    function send(Token token, address payable recipient, uint amount) internal {
        if(isETH(token)){
            require(
                recipient.send(amount),
                "Sending of ETH failed."
            );
        }else{
            Token(token).transfer(recipient, amount);
            require(
                validateOptionalERC20Return(),
                "ERC20 token transfer failed."
            );
        }
    }
    
    // Universal function to claim tokens from msg.sender
    function claimTokenFromSenderTo(Token _token, uint _amount, address _receiver) internal {
        if (isETH(_token)) {
            require(msg.value == _amount);
            // dont forward ETH
        }else{
            require(msg.value  == 0);
            _token.transferFrom(msg.sender, _receiver, _amount);
        }
    }