def test_new_sell_orders_taker_amount_success_case(tmpdir):
    bands_file = BandConfig.sample_config_dif_margins(tmpdir)
    bands_config = ReloadableConfig(str(bands_file))
    airswap_bands = AirswapBands.read(bands_config, EmptyFeed(), FixedFeed({'canBuy': True, 'canSell': True}), History())

    # maker_amount -> denominated in WETH
    maker_amount = Wad(0)
    taker_amount = Wad(1770600000000000000)
    our_sell_balance = Wad(1562000000000000000000)
    sell_limit = Wad(1562000000000000000000)
    target_price = WebSocketPriceFeed(FakeFeed({"buyPrice": "120", "sellPrice": "130"})).get_price()

    new_order = airswap_bands._new_side_orders('sell',
                                               maker_amount,
                                               taker_amount,
                                               our_sell_balance,
                                               sell_limit,
                                               airswap_bands.sell_bands[0],
                                               target_price.sell_price)

    # -- pricing logic --
    # sellPrice = 130 * avgMargin = 0.05 = 6.5
    # 130 + 6.5 = 136.5
    # taker_amount = 1.7706 / 136.5 = 0.01297142857142857142857

    assert new_order['maker_amount'].__float__() == 0.01297142857142857142857
    assert new_order['taker_amount'].__float__() == 1.7706
def test_new_sell_orders_maker_amount_fail_case(tmpdir):
    bands_file = BandConfig.sample_config_dif_margins(tmpdir)
    bands_config = ReloadableConfig(str(bands_file))
    airswap_bands = AirswapBands.read(bands_config, EmptyFeed(), FixedFeed({'canBuy': True, 'canSell': True}), History())

    maker_amount = Wad(106200000000000000000)
    taker_amount = Wad(0)
    our_sell_balance = Wad(1562000000000000000)
    sell_limit = Wad(1562000000000000000000)
    target_price = WebSocketPriceFeed(FakeFeed({"buyPrice": "120", "sellPrice": "130"})).get_price()

    new_order = airswap_bands._new_side_orders('sell',
                                               maker_amount,
                                               taker_amount,
                                               our_sell_balance,
                                               sell_limit,
                                               airswap_bands.sell_bands[0],
                                               target_price.sell_price)

    assert new_order == {}