Esempio n. 1
0
 def __init__(self,
              trading_pairs: List[str],
              wallet_private_key: str,
              ethereum_rpc_url: str,
              trading_required: bool = True):
     """
     :param trading_pairs: a list of trading pairs
     :param wallet_private_key: a private key for eth wallet
     :param ethereum_rpc_url: this is usually infura RPC URL
     :param trading_required: Whether actual trading is needed.
     """
     super().__init__()
     self._trading_pairs = trading_pairs
     tokens = set()
     for trading_pair in trading_pairs:
         tokens.update(set(trading_pair.split("-")))
     self._token_addresses = get_erc20_token_addresses(tokens)
     self._wallet_private_key = wallet_private_key
     self._ethereum_rpc_url = ethereum_rpc_url
     self._trading_required = trading_required
     self._ev_loop = asyncio.get_event_loop()
     self._shared_client = None
     self._last_poll_timestamp = 0.0
     self._in_flight_orders = {}
     self._allowances = {}
     self._status_polling_task = None
     self._auto_approve_task = None
     self._real_time_balance_update = False
    def _initialize_wallet(self, token_symbols: List[str]):
        ethereum_rpc_url = global_config_map.get("ethereum_rpc_url").value
        erc20_token_addresses = get_erc20_token_addresses(token_symbols)

        if self.acct is not None:
            self.wallet: Web3Wallet = Web3Wallet(private_key=self.acct.privateKey,
                                                 backend_urls=[ethereum_rpc_url],
                                                 erc20_token_addresses=erc20_token_addresses,
                                                 chain=EthereumChain.MAIN_NET)
    def _initialize_wallet(self, token_trading_pairs: List[str]):
        ethereum_rpc_url = global_config_map.get("ethereum_rpc_url").value
        erc20_token_addresses = get_erc20_token_addresses(token_trading_pairs)

        if self.acct is not None:
            chain_name: str = global_config_map.get("ethereum_chain_name").value
            self.wallet: Web3Wallet = Web3Wallet(
                private_key=self.acct.privateKey,
                backend_urls=[ethereum_rpc_url],
                erc20_token_addresses=erc20_token_addresses,
                chain=getattr(EthereumChain, chain_name),
            )
    def _initialize_wallet(self, token_trading_pairs: List[str]):
        if not using_wallet():
            return

        ethereum_wallet = global_config_map.get("ethereum_wallet").value
        private_key = Security._private_keys[ethereum_wallet]
        ethereum_rpc_url = global_config_map.get("ethereum_rpc_url").value
        erc20_token_addresses = get_erc20_token_addresses(token_trading_pairs)

        chain_name: str = global_config_map.get("ethereum_chain_name").value
        self.wallet: Web3Wallet = Web3Wallet(
            private_key=private_key,
            backend_urls=[ethereum_rpc_url],
            erc20_token_addresses=erc20_token_addresses,
            chain=getattr(EthereumChain, chain_name),
        )
 def token_list():
     return get_erc20_token_addresses()
Esempio n. 6
0
import sys, os
sys.path.insert(0, os.path.realpath(os.path.join(__file__, "../../")))
import logging
logging.basicConfig(level=logging.INFO)

import asyncio
import time

from hummingbot.client.config.config_helpers import get_erc20_token_addresses
from hummingbot.wallet.ethereum.web3_wallet import Web3Wallet
from hummingbot.wallet.ethereum.ethereum_chain import EthereumChain
from hummingbot.core.clock import Clock, ClockMode
from hummingbot.market.ddex.ddex_market import DDEXMarket
from hummingbot.core.data_type.order_book_tracker import OrderBookTrackerDataSourceType

token_addresses = get_erc20_token_addresses(["WETH", "DAI"])
zrx_addr = "0x74622073a4821dbfd046E9AA2ccF691341A076e1"
pkey = "7BB21B1C4C9C0A474BCD08C1BA3C31ACEA8B6840AC72A67EDD38CB32899CBF87"
server = "http://aws-mainnet-1.mainnet-rpc-headless.mainnet:8545"
clock = Clock(ClockMode.REALTIME)
wallet = Web3Wallet(pkey, [server],
                    token_addresses,
                    chain=EthereumChain.MAIN_NET)
market = DDEXMarket(
    wallet,
    server,
    order_book_tracker_data_source_type=OrderBookTrackerDataSourceType.
    EXCHANGE_API,
    trading_pairs=["WETH-DAI"])
clock.add_iterator(wallet)
clock.add_iterator(market)