contract Maker is ERC20("aHyd", "aHyd"){
    using SafeMath for uint256;
    IERC20 public hydg;

    constructor(IERC20 _hydg) public {
        hydg = _hydg;
    }

    // Pay some hydgs. Earn some shares.
    function enter(uint256 _amount) public {
        uint256 totalHydg = hydg.balanceOf(address(this));
        uint256 totalShares = totalSupply();
        if (totalShares == 0 || totalHydg == 0) {
            _mint(msg.sender, _amount);
        } else {
            uint256 what = _amount.mul(totalShares).div(totalHydg);
            _mint(msg.sender, what);
        }
        hydg.transferFrom(msg.sender, address(this), _amount);
    }

    // Claim back your HYDGs.
    function leave(uint256 _share) public {
        uint256 totalShares = totalSupply();
        uint256 what = _share.mul(hydg.balanceOf(address(this))).div(totalShares);
        _burn(msg.sender, _share);
        hydg.transfer(msg.sender, what);
    }
}
function enter(uint256 _amount) public {
    uint256 totalHydg = hydg.balanceOf(address(this));
    uint256 totalShares = totalSupply();
    if (totalShares == 0 || totalHydg == 0) {
        _mint(msg.sender, _amount);
    } else {
        uint256 what = _amount.mul(totalShares).div(totalHydg);
        _mint(msg.sender, what);
    }
    hydg.transferFrom(msg.sender, address(this), _amount);
}

// Pay some hydgs. Earn some shares.