Exemplo n.º 1
0
def close(
    auction_address,
    keystore: str,
    jsonrpc: str,
    gas: int,
    gas_price: int,
    nonce: int,
    auto_nonce: bool,
):
    web3 = connect_to_json_rpc(jsonrpc)
    private_key = retrieve_private_key(keystore)
    contracts = get_deployed_auction_contracts(web3, auction_address)

    nonce = get_nonce(web3=web3,
                      nonce=nonce,
                      auto_nonce=auto_nonce,
                      private_key=private_key)

    transaction_options = build_transaction_options(gas=gas,
                                                    gas_price=gas_price,
                                                    nonce=nonce)

    auction_close = contracts.auction.functions.closeAuction()

    send_function_call_transaction(
        auction_close,
        web3=web3,
        transaction_options=transaction_options,
        private_key=private_key,
    )
Exemplo n.º 2
0
def test_cli_release_date_option(runner):
    deploy_result = runner.invoke(
        main,
        args="deploy --release-date '2033-05-18 03:33:21' --jsonrpc test")
    assert deploy_result.exception is None
    assert deploy_result.exit_code == 0
    auction_address = extract_auction_address(deploy_result.output)
    contracts = get_deployed_auction_contracts(test_json_rpc, auction_address)
    release_timestamp = contracts.locker.functions.releaseTimestamp().call()
    # 2033-05-18 03:33:21 is timestamp 2000000001
    assert release_timestamp == 2_000_000_001
Exemplo n.º 3
0
def check_whitelist(whitelist_file: str, auction_address: str,
                    jsonrpc: str) -> None:
    web3 = connect_to_json_rpc(jsonrpc)
    whitelist = read_addresses_in_csv(whitelist_file)
    contracts = get_deployed_auction_contracts(web3, auction_address)

    number_of_missing_addresses = len(
        missing_whitelisted_addresses(contracts.auction, whitelist))

    if number_of_missing_addresses == 0:
        click.echo(f"All {len(whitelist)} addresses have been whitelisted")
    else:
        click.echo(
            f"{number_of_missing_addresses} of {len(whitelist)} addresses have not been whitelisted yet"
        )
Exemplo n.º 4
0
def whitelist(
    whitelist_file: str,
    auction_address: str,
    batch_size: int,
    keystore: str,
    jsonrpc: str,
    gas: int,
    gas_price: int,
    nonce: int,
    auto_nonce: bool,
) -> None:

    web3 = connect_to_json_rpc(jsonrpc)
    whitelist = read_addresses_in_csv(whitelist_file)
    private_key = retrieve_private_key(keystore)

    nonce = get_nonce(web3=web3,
                      nonce=nonce,
                      auto_nonce=auto_nonce,
                      private_key=private_key)

    transaction_options = build_transaction_options(gas=gas,
                                                    gas_price=gas_price,
                                                    nonce=nonce)

    contracts = get_deployed_auction_contracts(web3, auction_address)

    number_of_whitelisted_addresses = whitelist_addresses(
        contracts.auction,
        whitelist,
        batch_size=batch_size,
        web3=web3,
        transaction_options=transaction_options,
        private_key=private_key,
    )
    click.echo("Number of whitelisted addresses: " +
               str(number_of_whitelisted_addresses))
Exemplo n.º 5
0
def status(auction_address, jsonrpc):

    web3 = connect_to_json_rpc(jsonrpc)

    contracts = get_deployed_auction_contracts(web3, auction_address)

    # constants throughout auction
    duration_in_days = contracts.auction.functions.auctionDurationInDays(
    ).call()
    start_price_in_eth = contracts.auction.functions.startPrice().call(
    ) / ETH_IN_WEI
    minimal_number_of_participants = (
        contracts.auction.functions.minimalNumberOfParticipants().call())
    maximal_number_of_participants = (
        contracts.auction.functions.maximalNumberOfParticipants().call())
    locker_address = contracts.locker.address
    locker_initialized = contracts.locker.functions.initialized().call()
    locker_release_timestamp = contracts.locker.functions.releaseTimestamp(
    ).call()

    locker_address_in_auction_contract = (
        contracts.auction.functions.depositLocker().call())
    auction_address_in_locker_contract = (
        contracts.locker.functions.depositorsProxy().call())
    slasher_address_in_locker_contract = contracts.locker.functions.slasher(
    ).call()
    locker_address_in_slasher_contract = ZERO_ADDRESS
    if contracts.slasher is not None:
        locker_address_in_slasher_contract = (
            contracts.slasher.functions.depositContract().call())

    slasher_address = ZERO_ADDRESS
    slasher_initialized = False
    if contracts.slasher is not None:
        slasher_address = contracts.slasher.address
        slasher_initialized = contracts.slasher.functions.initialized().call()

    # variables
    auction_state_value = contracts.auction.functions.auctionState().call()
    auction_state = AuctionState(auction_state_value)
    start_time = contracts.auction.functions.startTime().call()
    close_time = contracts.auction.functions.closeTime().call()
    last_slot_price = contracts.auction.functions.lowestSlotPrice().call()
    current_price_in_eth = 0
    if auction_state == AuctionState.Started:
        current_price_in_eth = (
            contracts.auction.functions.currentPrice().call() / ETH_IN_WEI)

    click.echo("The auction duration is:                " +
               str(duration_in_days) + " days")
    click.echo("The starting price in eth is:           " +
               str(start_price_in_eth) + " eth")
    click.echo("The minimal number of participants is:  " +
               str(minimal_number_of_participants))
    click.echo("The maximal number of participants is:  " +
               str(maximal_number_of_participants))
    click.echo("The address of the locker contract is:  " +
               str(locker_address))
    click.echo("The locker initialized value is:        " +
               str(locker_initialized))
    if contracts.slasher is not None:
        click.echo("The address of the slasher contract is: " +
                   str(slasher_address))
        click.echo("The slasher initialized value is:       " +
                   str(slasher_initialized))
    else:
        click.secho("The slasher contract cannot be found.", fg="red")

    click.echo(
        "------------------------------------    ------------------------------------------"
    )

    click.echo("The auction state is:                   " +
               str(auction_state_value) + " (" + str(auction_state.name) + ")")
    click.echo("The start time is:                      " +
               format_timestamp(start_time))
    click.echo("The close time is:                      " +
               format_timestamp(close_time))
    if auction_state == auction_state.Started:
        click.echo("The current price is:                   " +
                   str(current_price_in_eth) + " eth")
    click.echo("The last slot price is:                  " +
               str(last_slot_price))
    click.echo("Deposits will be locked until:          " +
               format_timestamp(locker_release_timestamp))

    click.echo(
        "------------------------------------    ------------------------------------------"
    )

    if locker_address_in_auction_contract != locker_address:
        click.secho(
            "The locker address in the auction contract does not match to the locker address",
            fg="red",
        )
    if auction_address_in_locker_contract != auction_address:
        click.secho(
            "The auction address in the locker contract does not match the auction address",
            fg="red",
        )
    if slasher_address_in_locker_contract != slasher_address:
        click.secho(
            "The slasher address in the locker contract does not match the slasher address",
            fg="red",
        )
    if locker_address_in_slasher_contract != locker_address:
        click.secho(
            "The locker address in the slasher contract does not match the slasher address",
            fg="red",
        )
Exemplo n.º 6
0
def status(auction_address, jsonrpc):

    web3 = connect_to_json_rpc(jsonrpc)

    contracts = get_deployed_auction_contracts(web3, auction_address)

    # constants throughout auction
    duration_in_days = contracts.auction.functions.auctionDurationInDays(
    ).call()
    start_price_in_biggest_unit = (
        contracts.auction.functions.startPrice().call() / ETH_IN_WEI)
    minimal_number_of_participants = (
        contracts.auction.functions.minimalNumberOfParticipants().call())
    maximal_number_of_participants = (
        contracts.auction.functions.maximalNumberOfParticipants().call())
    bid_token_address = get_bid_token_address(web3, auction_address)
    locker_address = contracts.locker.address
    locker_initialized = contracts.locker.functions.initialized().call()
    locker_release_timestamp = contracts.locker.functions.releaseTimestamp(
    ).call()

    slasher_address = ZERO_ADDRESS
    slasher_initialized = False
    if contracts.slasher is not None:
        slasher_address = contracts.slasher.address
        slasher_initialized = contracts.slasher.functions.initialized().call()

    # variables
    auction_state_value = contracts.auction.functions.auctionState().call()
    auction_state = AuctionState(auction_state_value)
    start_time = contracts.auction.functions.startTime().call()
    close_time = contracts.auction.functions.closeTime().call()
    last_slot_price = contracts.auction.functions.lowestSlotPrice().call()
    current_price_in_eth = 0
    if auction_state == AuctionState.Started:
        current_price_in_eth = (
            contracts.auction.functions.currentPrice().call() / ETH_IN_WEI)

    click.echo("The auction duration is:                " +
               str(duration_in_days) + " days")
    click.echo("The starting price is:                  " +
               str(start_price_in_biggest_unit) + " ETH/TLN")
    click.echo("The minimal number of participants is:  " +
               str(minimal_number_of_participants))
    click.echo("The maximal number of participants is:  " +
               str(maximal_number_of_participants))
    if bid_token_address is not None:
        click.echo("The address of the bid token is:        " +
                   str(bid_token_address))
    click.echo("The address of the locker contract is:  " +
               str(locker_address))
    click.echo("The locker initialized value is:        " +
               str(locker_initialized))
    if contracts.slasher is not None:
        click.echo("The address of the slasher contract is: " +
                   str(slasher_address))
        click.echo("The slasher initialized value is:       " +
                   str(slasher_initialized))
    else:
        click.secho("The slasher contract cannot be found.", fg="red")

    click.echo(
        "------------------------------------    ------------------------------------------"
    )

    click.echo("The auction state is:                   " +
               str(auction_state_value) + " (" + str(auction_state.name) + ")")
    click.echo("The start time is:                      " +
               format_timestamp(start_time))
    click.echo("The close time is:                      " +
               format_timestamp(close_time))
    if auction_state == auction_state.Started:
        click.echo("The current price is:                   " +
                   str(current_price_in_eth) + " ETH/TLN")
    click.echo("The last slot price is:                 " +
               str(last_slot_price))
    click.echo("Deposits will be locked until:          " +
               format_timestamp(locker_release_timestamp))

    click.echo(
        "------------------------------------    ------------------------------------------"
    )

    warning_messages = get_errors_messages_on_contracts_links(contracts)
    if warning_messages:
        click.secho(linesep.join(warning_messages), fg="red")
Exemplo n.º 7
0
def contracts(deployed_auction_address) -> DeployedAuctionContracts:
    """return the core.DeployedAuctionContracts object for the currently active auction"""
    return get_deployed_auction_contracts(test_json_rpc,
                                          deployed_auction_address)