Configure arbitrage bot

I am trying to configure arbitrage bot:

I followed tutorial and got an error:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //93ad48d9e784fd857d160044772e35.eth.rpc.rivet.cloud/:8545 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7b9ef7cfd0>: Failed to establish a new connection: [Errno -2] Name or service not known',))

This is my .sh settings file:


#!/bin/bash
/home/user/simple-arbitrage-keeper/bin/simple-arbitrage-keeper \
 --rpc-host 'https://93ad48d884d857d160044772e35.eth.rpc.rivet.cloud/' \
 --eth-from '0xD63e5265f0033FA77a316516f768d26F7f879F6a' \
 --eth-key 'key_file=/home/user/.ethereum/keystore/UTC--2020-10-06T15-07-58.672992832Z--d63e5265ffa77a316516f768d26f7f879f6a' \
 --uniswap-entry-exchange '0x47D4Af3BBaEC0dE4dba5F44ae8Ed2761977D32d6' \
 --uniswap-arb-exchange '0x1D79BcC198281C5F9B52bf24F671437BaDd3a688' \
 --oasis-address '0x4A6bC4e803c62081ffEbCc8d227B5a87a58f1F8F' \
 --oasis-api-endpoint 'https://kovan-api.oasisdex.com' \
 --entry-token '0xC4375B7De8af5a38a93548eb8453a498222C4fF2' \
 --arb-token '0xd0A1E359811322d97991E03f863a0C30C2cF029C' \
 --arb-token-name 'WETH' \
 --min-profit 1 \
 --max-engagement 10 \

As far as I understand the problem is with rpc-host settings. What do I do?

I believe Rivet uses geth nodes, which should be compatible as long as the full JSON-RPC API is supported. That said, we haven’t had the opportunity to test compatibility with one of their nodes. You can use https://github.com/makerdao/pymaker/blob/master/tests/manual_test_node.py to check node compatibility first.

The error you’re getting is likely due to Rivet desiring a connection on port 443, though this code suggests the keeper is attempting to use port 8545: https://github.com/makerdao/simple-arbitrage-keeper/blob/master/simple_arbitrage_keeper/simple_arbitrage_keeper.py#L55
You’ll likely need to modify the keeper source to resolve this, since it appends the port to the end of the URL, which isn’t what Rivet expects.

And if you’d like to go the extra mile to submit a PR which resolves the URL issue; here’s some sample code for configuring web3 to support such URLs:

Hello, Ed, thanks for reply!
I’ve edited line 55 in simple_arbitrage_keeper.py

parser.add_argument("--rpc-port", type=int, default=443,#8545
                    help="JSON-RPC port (default: `8545')") 

https://prnt.sc/uvekgy

But I still get the same error
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //93ad48d9e7884f9d857d160044772e35.eth.rpc.rivet.cloud/:443 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c1db789e8>: Failed to establish a new connection: [Errno -2] Name or service not known',))

Any suggestions?

I also tried to use this https://github.com/makerdao/pymaker/blob/master/tests/manual_test_node.py

with following params:

#line43
    endpoint_uri = 'https://93ad48d9e7884f9d857d160044772e35.eth.rpc.rivet.cloud/' #sys.argv[1]              # ex: https://localhost:8545
    web3 = Web3(HTTPProvider(endpoint_uri=endpoint_uri, request_kwargs={"timeout": 30}))
    if len(sys.argv) > 3:
        web3.eth.defaultAccount = '0xD63e5265f0033FA77a316516f768d26F7f879F6a'#sys.argv[2]  # ex: 0x0000000000000000000000000000000aBcdef123
        register_keys(web3, ['key_file=/home/defidragon/.ethereum/keystore/UTC--2020-10-06T15-07-58.672992832Z--d63e5265f0033fa77a316516f768d26f7f879f6a'])      # ex: key_file=~keys/default-account.json,pass_file=~keys/default-account.pass
        our_address = Address(web3.eth.defaultAccount)
        run_transactions = True
    else:
        our_address = Address('0xD63e5265f0033FA77a316516f768d26F7f879F6a')
        run_transactions = False

And it gave me an error:
File “manual_test.py”, line 47, in
mcd = DssDeployment.from_node(web3)
AttributeError: type object ‘DssDeployment’ has no attribute ‘from_node’

Changing the default port isn’t going to be enough. You’ll need to ensure the correct URL is being passed as the endpoint_uri parameter in the Web3 constructor. The sample code I provided should help with this.

You’ll need to update to a newer version of pymaker to gain this feature; a git pull within lib/pymaker should achieve this.

Edit: I submitted a PR to try and clean this up. Changes within might be helpful if you want to get up-and-running before that’s reviewed and merged.

Where do I put this code, you provided?(I guess its faster than waiting for pr request to be approved)
I got confused here because I don’t have

https://github.com/makerdao/auction-keeper/blob/master/auction_keeper/main.py

The main file that I run is https://github.com/makerdao/simple-arbitrage-keeper/blob/master/simple_arbitrage_keeper/simple_arbitrage_keeper.py

I tried to change line 111 at simple_arbitrage_keeper like this

https://prnt.sc/uvgkkg

# from pymaker import Address, web3_via_http
# Configure connection to the chain
self.web3: Web3 = kwargs['web3'] if 'web3' in kwargs else web3_via_http(
    endpoint_uri=self.arguments.rpc_host, timeout=self.arguments.rpc_timeout, http_pool_size=100)
self.web3.eth.defaultAccount = self.arguments.eth_from
# register_keys(self.web3, self.arguments.eth_key)
# Check configuration for retrieving urns/bites

But got and error:
NameError: name 'web3_via_http' is not defined
And when I try to import it like this:
from pymaker import web3_via_http
I get imort error:
ImportError: cannot import name 'web3_via_http'

What do I do?

pushd lib/pymaker
git pull origin master
popd

Did it
Now I have this error:
> Traceback (most recent call last):

      File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/home/defidragon/defidragon/simple-arbitrage-keeper/simple_arbitrage_keeper/simple_arbitrage_keeper.py", line 27, in <module>
        from simple_arbitrage_keeper.uniswap import UniswapWrapper
      File "/home/defidragon/defidragon/simple-arbitrage-keeper/simple_arbitrage_keeper/uniswap.py", line 1, in <module>
        from pymaker import Transact, Address
      File "/home/defidragon/defidragon/simple-arbitrage-keeper/lib/pymaker/pymaker/__init__.py", line 36, in <module>
        from web3._utils.contracts import get_function_info, encode_abi
    ModuleNotFoundError: No module named 'web3._utils'
pip3 install -r lib/pymaker/requirements.txt

once second, doing it

File “/home/defidragon/.local/lib/python3.6/site-packages/requests/adapters.py”, line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘https’, port=443): Max retries exceeded with url: //93ad48d9e7884f9d857d160044772e35.eth.rpc.rivet.cloud/:443 (Caused by NewConnectionError(’<urllib3.connection.HTTPSConnection object at 0x7fa00e6f1be0>: Failed to establish a new connection: [Errno -2] Name or service not known’,))

Two problems with the way it’s parsing your URL:

  • It’s truncating the https for some reason
  • It’s still trying to suffix an explicit port number

The code changes I made here should resolve this.

thanks, I am checking this

The situation is the following:
I am trying to make it work step by step, so firstly I removed tx manager.
I managed to make it run, but it tells only this:

2020-10-08 16:13:45,501 INFO     Keeper connected to RPC connection https://93ad48d9e7884f9d857d160044772e35.eth.rpc.rivet.cloud/
2020-10-08 16:13:45,501 INFO     Keeper operating as 0xD63e5265f0033FA77a316516f768d26F7f879F6a
2020-10-08 16:13:45,824 INFO     Waiting for the node to have at least one peer...

When I try to deploy tx manager dapp create TxManager --password p.txt, it says:

curl: (7) Failed to connect to 127.0.0.1 port 8545: Connection refused
seth-rpc-curl: Please make sure that you are running a local Ethereum node:
seth-rpc-curl:   For example, try running either `parity' or `geth --rpc'.
seth-rpc-curl: You could also try connecting to an external Ethereum node:
seth-rpc-curl:   For example, try `export ETH_RPC_URL=https://mainnet.infura.io'.
seth-rpc-curl:   If you have an Infura API key, add it to the end of the URL.
curl: (7) Failed to connect to 127.0.0.1 port 8545: Connection refused

I tried to export it like this
ETH_RPC_URL=‘https://93ad48d9e7884f9d857d160044772e35.eth.rpc.rivet.cloud

But didn’t help

What do I do?

Just read your errors. Client (curl) tried to connect to the ip address 127.0.0.1 (that is locally - localhost) and it’s port 8545 and was ACTIVELY refused by the host. Probably nothing is listening on this port, i.e. port is not open.

I don’t have a firewall and nothing is on this port.

And I am not sure how to understand this message when I try to launch it without tx manager

2020-10-08 16:13:45,824 INFO     Waiting for the node to have at least one peer...

Hello guys
@Ed_Noepel
any ideas?:slight_smile:

It seems dapp create is looking for a node running on your own machine rather than your Rivet node. I looked at the dapptools documentation but didn’t find how to configure the node endpoint. Hoping someone experienced with that tooling can chime in.