// SPDX-License-Identifier: MIT
pragma solidity >=0.8.2 <0.9.0;


interface ERC20 {
    function transfer(address to, uint amount) external returns(bool);
    function balanceOf(address a) external returns(uint256);
}


contract Splitter {
    address immutable public a;
    address immutable public b;

    constructor(address _a, address _b) {
        a = _a;
        b = _b;
    }

    // callable by anyone
    function split(ERC20 token, uint amount) public {
        if(amount == 0) {
            amount = token.balanceOf(address(this));
        }

        // round down. leftovers will stay in the contract
        uint half = amount / 2;

        // if token is not standard and does not return true upon success, then sfyl.
        require(token.transfer(a, half));
        require(token.transfer(b, half));        
    }

}