library AdvancedTokenInteract {
    using TokenInteract for address;

    /**
     * Checks if the spender has some amount of allowance. If it doesn't, then set allowance at
     * the maximum value.
     *
     * @param  token    Address of the ERC20 token
     * @param  spender  Argument of the allowance function
     * @param  amount   The minimum amount of allownce the the spender should be guaranteed
     */
    function ensureAllowance(
        address token,
        address spender,
        uint256 amount
    )
        internal
    {
        if (token.allowance(address(this), spender) < amount) {
            token.approve(spender, MathHelpers.maxUint256());
        }
    }
}
/**
 * @title AdvancedTokenInteract
 * @author dYdX
 *
 * This library contains advanced functions for interacting with ERC20 tokens
 */
function ensureAllowance(
    address token,
    address spender,
    uint256 amount
)
    internal
{
    if (token.allowance(address(this), spender) < amount) {
        token.approve(spender, MathHelpers.maxUint256());
    }
}

/**
 * Checks if the spender has some amount of allowance. If it doesn't, then set allowance at
 * the maximum value.
 *
 * @param  token    Address of the ERC20 token
 * @param  spender  Argument of the allowance function
 * @param  amount   The minimum amount of allownce the the spender should be guaranteed
 */