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)
Exemple #2
0
    def setUpClass(cls):
        cls.clock: Clock = Clock(ClockMode.REALTIME)
        cls.erc20_token_address = conf.test_erc20_token_address
        cls.w3 = Web3(Web3.HTTPProvider(conf.test_web3_provider_list[0]))

        cls.wallet_a = Web3Wallet(conf.web3_test_private_key_a,
                                  conf.test_web3_provider_list,
                                  [cls.erc20_token_address])
        cls.wallet_b = Web3Wallet(conf.web3_test_private_key_b,
                                  conf.test_web3_provider_list,
                                  [cls.erc20_token_address])

        cls.erc20_token: ERC20Token = list(
            cls.wallet_a.current_backend.erc20_tokens.values())[0]

        cls.clock.add_iterator(cls.wallet_a)
        cls.clock.add_iterator(cls.wallet_b)
        cls.ev_loop: asyncio.BaseEventLoop = asyncio.get_event_loop()

        next_iteration = (time.time() // 5.0 + 1) * 5
        cls.ev_loop.run_until_complete(cls.clock.run_til(next_iteration))
Exemple #3
0
async def main():
    cmd_args = CmdlineParser().parse_args()
    with open(cmd_args.key_file, "r") as fd:
        encrypted_json: Dict[str, any] = json.load(fd)

    wallet: Web3Wallet = Web3Wallet(
        Account.decrypt(encrypted_json, getpass.getpass("Wallet password: "******"createdAt"], o["id"], o["marketId"]) for o in orders],
            columns=["Created", "OrderID", "Symbol"])
        order_data.Created = order_data.Created.astype(
            "datetime64[ms]").astype("datetime64[ns, UTC]")
        order_data = order_data.set_index("Created")

        while True:
            try:
                sample_ids: List[str] = list(order_data.sample(10).OrderID)
                tasks: List[asyncio.Future] = [
                    market.get_order(order_id) for order_id in sample_ids
                ]
                response_data: List[Dict[str,
                                         any]] = await asyncio.gather(*tasks)

                mismatches: int = 0
                for expected_id, response in zip(sample_ids, response_data):
                    returned_order_id = response["id"]
                    if returned_order_id != expected_id:
                        print(
                            f"    - Error: requested for {expected_id} but got {returned_order_id} back."
                        )
                        mismatches += 1

                if mismatches < 1:
                    print(
                        f"[{str(pd.Timestamp.utcnow())}] All fetches passed.")
                else:
                    print(
                        f"[{str(pd.Timestamp.utcnow())}] {mismatches} out of 10 requests failed."
                    )

                now: float = time.time()
                next_tick: float = now // 1 + 1
                await asyncio.sleep(next_tick - now)
            except asyncio.CancelledError:
                raise
 def setUpClass(cls):
     cls.clock: Clock = Clock(ClockMode.REALTIME)
     cls.wallet = Web3Wallet(private_key=conf.web3_private_key_radar,
                             backend_urls=conf.test_web3_provider_list,
                             erc20_token_addresses=[conf.mn_zerox_token_address, conf.mn_weth_token_address],
                             chain=EthereumChain.MAIN_NET)
     cls.market: RadarRelayMarket = RadarRelayMarket(wallet=cls.wallet,
                                                     web3_url=conf.test_web3_provider_list[0],
                                                     order_book_tracker_data_source_type=
                                                         OrderBookTrackerDataSourceType.EXCHANGE_API,
                                                     symbols=["ZRX-WETH"])
     print("Initializing Radar Relay market... ")
     cls.ev_loop: asyncio.BaseEventLoop = asyncio.get_event_loop()
     cls.clock.add_iterator(cls.wallet)
     cls.clock.add_iterator(cls.market)
     cls.ev_loop.run_until_complete(cls.clock.run_til(time.time() + 1))
     cls.ev_loop.run_until_complete(cls.wait_til_ready())
     print("Ready.")
Exemple #5
0
 def setUpClass(cls):
     cls.clock: Clock = Clock(ClockMode.REALTIME)
     cls.market: CoinbaseProMarket = CoinbaseProMarket(
         web3_url=conf.test_web3_provider_list[0],
         coinbase_pro_api_key=conf.coinbase_pro_api_key,
         coinbase_pro_secret_key=conf.coinbase_pro_secret_key,
         coinbase_pro_passphrase=conf.coinbase_pro_passphrase,
         symbols=["ETH-USDC", "ETH-USD"])
     cls.wallet: Web3Wallet = Web3Wallet(
         private_key=conf.web3_private_key_coinbase_pro,
         backend_urls=conf.test_web3_provider_list,
         erc20_token_addresses=[
             conf.mn_weth_token_address, conf.mn_zerox_token_address
         ],
         chain=EthereumChain.MAIN_NET)
     print(
         "Initializing Coinbase Pro market... this will take about a minute."
     )
     cls.ev_loop: asyncio.BaseEventLoop = asyncio.get_event_loop()
     cls.clock.add_iterator(cls.market)
     cls.clock.add_iterator(cls.wallet)
     cls.ev_loop.run_until_complete(cls.clock.run_til(time.time() + 1))
     cls.ev_loop.run_until_complete(cls.wait_til_ready())
     print("Ready.")
import asyncio
import time

from hummingbot.cli.config.config_helpers import get_erc20_token_addresses
from wings.wallet.web3_wallet import Web3Wallet
from wings.clock import Clock, ClockMode
from wings.market.ddex_market import DDEXMarket
from wings.ethereum_chain import EthereumChain
from wings.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,
                    symbols=["WETH-DAI"])
clock.add_iterator(wallet)
clock.add_iterator(market)


async def main():
    begin = time.time() // 1
    while True:
        now = time.time() // 1
        await clock.run_til(now + 1)

        elapsed = clock.current_timestamp - begin