Skip to main content

PAB is a framework for developing and running custom tasks in crypto blockchains.

Project description

PyAutoBlockchain (PAB)

Tests Python 3.9

PAB is a framework for developing and running custom tasks in crypto blockchains.

For a more in-depth guide see GUIDE.md, the example at examples or a more complex implementation at PolyCompounder.

Installation

Clone the repo and install dependencies.

$ python3 -m venv venv
$ pip install PyAutoBlockchain

Usage

(venv) $ pab create-keyfile [-o keyfile]  # Create keyfile
(venv) $ pab edit-config  # Edit config file
(venv) $ pab list-strategies -v  # List available strategies and parameters
(venv) $ pab run  # Run tasks

Configuration

Configure wallet and RPC

Create project config and keyfile:

(venv) $ pab edit-config
(venv) $ pab create-keyfile

A basic config file without alerts enabled might look like:

{
    "blockchain": "POLYGON",
    "chainId": 137,
    "endpoint": "https://mainnet.infura.io/v3/your_key",
    "myAddress": "0xyour_address"
}

You can get a free RPC endpoint for most known blockchains (e.g. Infura or MaticVigil).

Adding extra contracts

To use contracts in the strategies you first need to add the abi file to abis and modify the contracts.json file to load it.

For example, given the contract for MYTOKEN at 0x12345 create the abifile at abis/mytoken.abi and add to contracts.json the following:

{
    "MYTOKEN": {
        "address": "0x12345",
        "abifile": "mytoken.abi"
    }
}

Adding extra strategies

You can add strategies to execute at strategies.json. For example, the following example defines 1 estrategy to execute, using the strategy BaseStrategy and the contracts BNB, WBTC, PAIR, MASTERCHEF and ROUTER.

[
    {
        "strategy": "BaseStrategy",
        "name": "BNB-WBTC",
        "repeat_every": {
            "days": 1
        },
        "params": {
            "swap_path": ["BNB", "WBTC"],
            "pair": "PAIR",
            "masterchef": "MASTERCHEF",
            "router": "ROUTER",
            "pool_id": 11
        }
    }
]

Strategies are dictionaries with:

  • strategy: Class name of strategy (must be subclass of pab.strategy.BaseStrategy, see pab list-strategies)
  • name: Name, just for logging.
  • params: Dictionary with strategy parameters. (see pab list-strategies -v)
  • repeat_every: Optional. Dictionary with periodicity of the process, same arguments as datetime.timedelta.

Run pab list-strategies -v to see available strategies and parameters.

Email alerts

You can setup email alerts for when something goes wrong. Add the following to your config.json:

{
    "emails": {
        "enabled": true,
        "host": "smtp.host.com",
        "port": 465,
        "address": "email@host.com",
        "password": "password",
        "recipient": "me@host.com"
    }   
}

Developing

For details see ARCHITECTURE.md

Running tests

Using pytest:

(venv) $ pip install -e requirements-dev.txt
(venv) $ ./tests.sh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyAutoBlockchain-0.2.1.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

PyAutoBlockchain-0.2.1-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file PyAutoBlockchain-0.2.1.tar.gz.

File metadata

  • Download URL: PyAutoBlockchain-0.2.1.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for PyAutoBlockchain-0.2.1.tar.gz
Algorithm Hash digest
SHA256 46d93f73bc39146203fec664c34b329ceb32005c399363251a8bee4b7d5174be
MD5 089fbe2a5d5bbd87e9dcd7452eed731b
BLAKE2b-256 10effec563659e21247fca84829b12e031f7c75443c9901a9ddf16b7f34c91cd

See more details on using hashes here.

File details

Details for the file PyAutoBlockchain-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: PyAutoBlockchain-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for PyAutoBlockchain-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d7a290dcf8e09eb03ef7cf7bdf16ae68583b3cb3bedbf4f5a98aa11b6c8a00d6
MD5 f7fb38f8ed37ff8c4e1dd92e6ca69d72
BLAKE2b-256 c534c8040e40216ed5933ed69ae147ed35282f57d5359dee603efc696545fca4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page