def simulation(ctx, **kwargs):
    token_contract_address = ctx.obj.get('token_contract_address', None)
    if token_contract_address is None:
        token_contract_address = kwargs.get('token_contract')
    if token_contract_address is None:
        log.fatal('No token contract address set! Either supply one '
                  'using --token-contract option, or use deploy command')
        sys.exit(1)
    if kwargs['bidders'] < kwargs['wei_bidders']:
        log.fatal(
            '1 wei bidders number must be less or equal as the total number of bidders'
        )
        sys.exit(1)

    auction_contract_address = ctx.obj.get('auction_contract_address', None)
    if auction_contract_address is None:
        auction_contract_address = kwargs.get('auction_contract')
    if auction_contract_address is None:
        log.fatal('No auction contract address set! Either supply one '
                  'using --auction-contract option, or use deploy command')
        sys.exit(1)

    chain = ctx.obj['chain']
    owner = ctx.obj['owner']
    web3 = chain.web3

    Auction = chain.provider.get_contract_factory('DutchAuction')
    Token = chain.provider.get_contract_factory('RaidenToken')

    auction_contract = Auction(address=auction_contract_address)
    token_contract = Token(address=token_contract_address)

    auction_simulation(web3, token_contract, auction_contract, owner, kwargs)
Esempio n. 2
0
def simulation(app: Web3Context, **kwargs):
    bidders = int(kwargs['bidders'])
    bid_start_price = int(kwargs['bid_price'] or 0)
    bid_interval = int(kwargs['bid_interval'] or 0)
    fund_bidders = kwargs['fund']
    sim_claim_tokens = kwargs['claim_tokens']
    if simulation:
        log.info('Starting simulation setup for {0} bidders'.format(bidders))
        bidder_addresses = app.web3.eth.accounts[1:(bidders + 1)]

        # come to daddy
        event_list = [
            gevent.spawn(returnFundsToOwner, app.web3, app.owner, bidder)
            for bidder in bidder_addresses
        ]
        gevent.joinall(event_list)

        log.info(
            'Creating {0} bidder accounts: '.format(bidders -
                                                    len(bidder_addresses)))
        for i in range(len(bidder_addresses), bidders):
            address = app.web3.personal.newAccount(passphrase)
            bidder_addresses.append(address)

        log.info('Simulating {0} bidders: {1}'.format(len(bidder_addresses),
                                                      bidder_addresses))
        if bid_start_price:
            log.info('Bids will start at {0} WEI = {1} ETH  / TKN'.format(
                bid_start_price, app.web3.fromWei(bid_start_price, 'ether')))

        if fund_bidders:
            assignFundsToBidders(app.web3, app.owner, bidder_addresses,
                                 kwargs['distribution_limit'])

        auction_simulation(app.web3, app.wallet_address, app.token_contract,
                           app.auction_contract, app.owner, bidder_addresses,
                           bid_interval, bid_start_price, sim_claim_tokens)
Esempio n. 3
0
def simulation(ctx, **kwargs):
    bidders = int(kwargs['bidders'])
    bid_start_price = int(kwargs['bid_price'] or 0)
    fund_bidders = kwargs['fund']

    token_contract_address = ctx.obj.get('token_contract_address', None)
    if token_contract_address is None:
        token_contract_address = kwargs.get('token_contract')
    if token_contract_address is None:
        log.fatal('No token contract address set! Either supply one '
                  'using --token-contract option, or use deploy command')
        sys.exit(1)
    if kwargs['bidders'] < kwargs['wei_bidders']:
        log.fatal(
            '1 wei bidders number must be less or equal as the total number of bidders'
        )
        sys.exit(1)

    auction_contract_address = ctx.obj.get('auction_contract_address', None)
    if auction_contract_address is None:
        auction_contract_address = kwargs.get('auction_contract')
    if auction_contract_address is None:
        log.fatal('No auction contract address set! Either supply one '
                  'using --auction-contract option, or use deploy command')
        sys.exit(1)

    chain = ctx.obj['chain']
    owner = ctx.obj['owner']
    web3 = chain.web3

    Auction = chain.provider.get_contract_factory('DutchAuction')
    Token = chain.provider.get_contract_factory('RaidenToken')

    auction_contract = Auction(address=auction_contract_address)
    token_contract = Token(address=token_contract_address)

    bidder_addresses = web3.eth.accounts[1:(bidders + 1)]

    # come to daddy
    event_list = [
        gevent.spawn(returnFundsToOwner, web3, owner, bidder)
        for bidder in bidder_addresses
    ]
    gevent.joinall(event_list)

    log.info('Creating {0} bidder accounts: '.format(bidders -
                                                     len(bidder_addresses)))
    for i in range(len(bidder_addresses), bidders):
        address = web3.personal.newAccount(passphrase)
        bidder_addresses.append(address)

    log.info('Simulating {0} bidders: {1}'.format(len(bidder_addresses),
                                                  bidder_addresses))
    if bid_start_price:
        log.info('Bids will start at {0} WEI = {1} ETH  / TKN'.format(
            bid_start_price, web3.fromWei(bid_start_price, 'ether')))

    if fund_bidders:
        assignFundsToBidders(web3, owner, bidder_addresses,
                             kwargs['distribution_limit'])

    ret = auction_simulation(web3, token_contract, auction_contract, owner,
                             bidder_addresses, kwargs)
    if isinstance(ret, int):
        assert ret == ctx.obj['total_supply']