コード例 #1
0
def main():
    _staff = Staff(CONFIG.STAFF_INDEX)

    pprint(project_items)

    _ventures = list()
    _projects = list()

    for i, prj in enumerate(project_items):
        _venture = Venture(i)
        _ventures.append(_venture)
        _project = _venture.get_project(0, project_name=prj["project_name"])
        _projects.append(_project)

    coins_id = dict()
    coins_id["USDT"] = 1
    for coin in COINS[1:]:
        for p in _projects:
            print("p.short_name:%s vs coin:%s" % (p.short_name, coin))
            if p.short_name == coin.upper():
                coins_id[coin.upper()] = p.coin_id
                break
        else:
            assert 0, "No such coin:%s" % coin

    pprint(coins_id)
    _tenants = list()
    for i, exch in enumerate(exchange_items):
        _tenant = Tenant(i)
        _exchange = _tenant.get_exchange()
        for _project in _projects:
            _tenant.contacts(project_id=_project.project_id,
                             exchange_id=_exchange.exchange_id,
                             sponsor="tenant")
        for market_index, market in enumerate(market_items[i]):
            to_sell = market[0].upper()
            to_buy = market[1].upper()
            print("try to create %s/%s" % (to_sell, to_buy))
            _market = _tenant.get_market(buy=coins_id[to_buy],
                                         sell=coins_id[to_sell])
            if not _market:
                _faucet = Faucet(
                    _tenant.token_mgr.token,
                    _tenant.api_account.api_client.configuration.host)
                _faucet.free_charge(coin_id=coins_id["USDT"],
                                    amount=1000000000)
                _market, order_id = _tenant.create_market(
                    coins_id[to_buy], coins_id[to_sell], "6", "0")
            logger.info(
                "==========  Tenant(%u) create Market(%s) Done ==========" %
                (i, _market.market_id))
コード例 #2
0
def main():
    _venture = Venture(CONFIG.VENTURE_INDEX)
    usdt_id = _venture.get_usdt_coin_id()
    _tenant = Tenant(CONFIG.TENANT_INDEX)
    _faucet = Faucet(CONFIG.FAUCET_INDEX)
    _project = _venture.get_project(CONFIG.PROJECT_INDEX)
    assert _project, "Must have a project first to create market"
    _market = _tenant.get_market(buy=usdt_id, sell=_project.coin_id)
    print("list markets: ", _tenant.list_markets())
    if not _market:
        _faucet.free_charge(coin_id=_venture.get_usdt_coin_id(),
                            account_id=_tenant.account_id)
        logger.info(
            "==========  Faucet(%s) charge Tenant(%u) Done ==========" %
            (CONFIG.FAUCET_INDEX, CONFIG.TENANT_INDEX))
        _market, create_order_id = _tenant.create_market(
            usdt_id, _project.coin_id, "6", "0")
        assert create_order_id, "Market create order id should not be null"
        print(
            "coin verify ==>",
            _tenant.verify_market_trading_coin(buy_coin=usdt_id,
                                               sell_coin=_project.coin_id))
        assert _tenant.list_markets()
コード例 #3
0
def setup():
    logger.info("++  Multi Market  ++")

    _staff = Staff(CONFIG.STAFF_INDEX)
    logger.info("==========  Staff(%u) ready  ==========" % CONFIG.STAFF_INDEX)

    for item in _staff.list_tags():
        if item.name == CONFIG.MY_TAG:
            break
    else:
        _staff.create_tag(tag=CONFIG.MY_TAG,
                          other_language=[{
                              "key": "英语",
                              "value": "public_chain"
                          }])
    logger.info("==========  tag < %s > ready  ==========" % CONFIG.MY_TAG)

    _main = Main(CONFIG.MAIN_INDEX)
    _main.request_individual_cert()
    _staff.verify_individual(identity=_main.identity, approval="approved")
    logger.info("==========  Main(%u) ready  ==========" % CONFIG.MAIN_INDEX)

    sponsor_info = get_templated_attrs(Sponsor, CONFIG.SPONSOR_INDEX)
    logger.info("template result: ", sponsor_info)
    if _staff.create_sponsor(**sponsor_info):
        _sponsor = Sponsor(CONFIG.SPONSOR_INDEX)
    else:
        assert 0, "staff create sponsor failed!"
    logger.info("==========  Sponsor(%u) Done  ==========" %
                CONFIG.SPONSOR_INDEX)

    _tenant = Tenant(CONFIG.TENANT_INDEX)
    _tenant.request_individual_cert()
    _staff.verify_individual(identity=_tenant.identity, approval="approved")
    assert _tenant.audit_accepted()
    logger.info("==========  Tenant(%u) Create Done  ==========" %
                CONFIG.TENANT_INDEX)

    _exchange = _tenant.get_exchange()
    if not _exchange:
        _exchange = _tenant.create_exchange()

    audits = _staff.query_audits_tenant(uid=_tenant.account_id, status="audit")

    for audit in audits:
        _staff.audits_tenants(task_id=audit.id, approval="approved")

        result = _staff.get_tenant_indiv_audits_result(audit_id=audit.id)
        assert result.audit_status == "approved"

    re_audits = _staff.query_audits_tenant(uid=_tenant.account_id,
                                           status="re_audit")
    for re_audit in re_audits:
        _staff.reaudits_tenants(task_id=re_audit.id, approval="approved")

        result = _staff.get_tenant_indiv_re_audits_result(audit_id=re_audit.id)
        assert result.re_status == "approved"

    if _tenant.is_exchange_approved():
        _exchange = _tenant.update_exchange_info()
    else:
        assert 0, "exchange should be approved here"

    logger.info("==========  exchange_id:%s ready ==========" %
                (_exchange.exchange_id))

    _venture = Venture(CONFIG.VENTURE_INDEX)
    _venture.request_individual_cert()
    _staff.verify_individual(identity=_venture.identity, approval="approved")
    assert _venture.audit_accepted()
    logger.info("==========  Venture(%u) Done  ==========" %
                CONFIG.VENTURE_INDEX)

    _project = _venture.get_project(CONFIG.PROJECT_INDEX)
    if not _project:
        _project = _venture.create_project(CONFIG.PROJECT_INDEX)

    logger.info("==========  Project(%u) %s: %s(%s) Done ==========",
                CONFIG.PROJECT_INDEX, _project.project_name,
                _project.full_name, _project.short_name)

    sponsor_id = _venture.query_sponsor_id(_sponsor.name)
    logger.info("sponsor id:%s ============>" % sponsor_id)

    for app in _venture.list_applications():
        _venture.set_sponsor(sponsor_id, app.id)

    app_id = _sponsor.query_project_application_id(_project.project_name)
    if app_id:
        _sponsor.sponsor_project(app_id)

    _project = _venture.update_project_info(CONFIG.PROJECT_INDEX)

    logger.info(
        "==========  Sponsor(%u) $$$ Project(%u) %s: %s(%s) Done ==========" %
        (CONFIG.SPONSOR_INDEX, CONFIG.PROJECT_INDEX, _project.project_name,
         _project.full_name, _project.short_name))

    for config in _staff.get_coins_config_list():
        if config.coin_id == _project.coin_id:
            print("%s config id:%s" % (_project.coin_id, config.id))
            _staff.init_coin(usdt_price=1, config_id=config.id)
            _staff.config_coin_rechargable(config.id, rechargeable=True)
            _staff.config_coin_withdrawable(config.id, withdrawable=True)
    logger.info("==========  Init Project(%u) %s: %s(%s) Done  ==========" %
                (CONFIG.PROJECT_INDEX, _project.project_name,
                 _project.full_name, _project.short_name))

    _venture.contacts(project_id=_project.project_id,
                      exchange_id=_exchange.exchange_id,
                      sponsor="venture")

    for contact in _tenant.list_contacts(_exchange.exchange_id,
                                         status="pending"):
        print("contact_id ====================>", contact.id)
        _tenant.contact_accept(contact_id=contact.id, status="accepted")
    logger.info("==========  Venture(%u) contact Tenant(%u) Done  ==========" %
                (CONFIG.VENTURE_INDEX, CONFIG.TENANT_INDEX))

    usdt_id = _venture.get_usdt_coin_id()
    _market = _tenant.get_market(buy=usdt_id, sell=_project.coin_id)
    _faucet = Faucet(_tenant.token_mgr.token,
                     _tenant.api_account.api_client.configuration.host)
    if not _market:
        _faucet.free_charge(coin_id=_venture.get_usdt_coin_id(),
                            amount=10000000000)
        logger.info(
            "==========  Faucet(%s) charge Tenant(%u) Done ==========" %
            (CONFIG.FAUCET_INDEX, CONFIG.TENANT_INDEX))
        _market, order_id = _tenant.create_market(usdt_id, _project.coin_id,
                                                  "6", "0")
    logger.info("==========  Tenant(%u) create Market(%s) Done ==========" %
                (CONFIG.TENANT_INDEX, _market.market_id))

    logger.info("========== Multi Market End ==========")
    return _staff, _tenant, _venture, _sponsor, _faucet, _exchange