Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
beeb committed Mar 24, 2022
2 parents c049f2f + a7180ee commit 029c598
Show file tree
Hide file tree
Showing 33 changed files with 2,480 additions and 1,384 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
min_python_version = 3.7.1
max-line-length = 120
exclude = __init__.py,.git,__pycache__,dist,.venv
extend-ignore = E203
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ assignees: ''
- [ ] I have read the entire Readme and followed all installation instructions

**Setup (please complete the following information):**
- OS and version:
- Pancaketrade version:
- OS and version:
- Pancaketrade version:

**Describe the bug**
A clear and concise description of what the bug is.
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ jobs:
with:
python-version: '3.9'
- name: Install poetry
uses: abatilo/actions-poetry@v2.0.0
uses: abatilo/actions-poetry@v2.1.4
with:
poetry-version: '1.1.6'
poetry-version: '1.1.12'
- name: Install deps
run: poetry install
- name: flake8
run: poetry run python -m flake8 --max-line-length=120 --exclude=__init__.py,.git,__pycache__,dist,.venv
- name: mypy
run: poetry run python -m mypy --ignore-missing-imports pancaketrade
- uses: pre-commit/[email protected]
40 changes: 40 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: check-ast
- id: debug-statements
- id: check-docstring-first
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: [--profile=black, --filter-files, --line-length=120]
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black
args: [--line-length=120]
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==22.1.11
- flake8-comprehensions==3.8.0
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
hooks:
- id: mypy
args: [--ignore-missing-imports, pancaketrade]
pass_filenames: false
additional_dependencies:
- types-PyYAML
- types-requests
- types-cachetools
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ENV PYTHONUNBUFFERED=1 \

# install poetry
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
RUN curl -sSL https://install.python-poetry.org | python -

# copy source and install deps
COPY . ./
Expand Down
36 changes: 30 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The bot provides a lot of convenience trading features including:
- Automatic approval for selling
- Assign emoji to each token to differentiate them easily
- Default slippage set on a token basis for faster order creation
- Chart link for each token
- Charts links for each token

## Requirements

Expand All @@ -41,7 +41,7 @@ If you choose to use the Docker image, you'll just need docker installed, see th

If you choose to run the script with Python, you'll need the following:

- Python version between 3.7.1 and 3.9.x
- Python version between 3.7.2 and 3.9.x
- [Poetry](https://github.com/python-poetry/poetry)
- Optional: `git` to clone this repository, you can also download the source from the github website.

Expand All @@ -62,9 +62,18 @@ cp user_data/config.example.yml user_data/config.yml

Next, open the `config.yml` file inside the `user_data` folder with a text editor and populate the `secrets` section.

The bot needs your wallet's private key in order to sign and execute orders on your behalf. You can either run the
command below and enter your private key in the prompt that will be shown, or you can provide an environment variable
named `WALLET_PK` that will be used by the bot.
The bot needs your wallet's private key in order to sign and execute orders on your behalf. You have multiple options
to do so:

- You can run the `poetry run trade` command as-is and enter your private key in the prompt that will be shown each time
the bot is started (only stored in memory)
- You can provide an environment variable named `WALLET_PK`. For this multiple options:
- You can create a `.env` file in the root of the project (same folder as `pyproject.toml`) and enter your private key
in that file (which is excluded from git): `WALLET_PK=123abcd...`
- You can prepend the command with the environment variable (not recommended as this will be stored in your shell
history): `WALLET_PK=123abcd... poetry run trade`
- You can use a service to run the bot, see the [relevant section below](#run-as-a-service)

The private key is **not** the same as the seed words/mnemonic. You need the 64-characters hexadecimal private key.

Your wallet address will be inferred from the private key and doesn't need to be provided.
Expand Down Expand Up @@ -103,6 +112,13 @@ bsc_rpc: 'https://bsc-dataseed.binance.org:443' # you can use any BSC RPC url yo
min_pool_size_bnb: 25 # PancakeSwap LPs that have less than 25 BNB will not be considered
monitor_interval: 5 # the script will check the token prices with this interval in seconds
update_messages: true # status messages will update periodically to show current values
price_in_usd: true # input, show and track prices in USD/token instead of BNB/token
charts: # these are all the chart links that can be included in status messages. Remove the ones you don't need
- poocoin
- bogged
- dexguru
- dextools
- dexscreener
secrets:
telegram_token: 'enter_your:bot_token' # enter your Telegram Bot token
admin_chat_id: 123456 # enter your chat ID/user ID to prevent other users to use the bot
Expand All @@ -127,7 +143,7 @@ Steps to use docker:
2. Create a file named `.env` next to your docker-compose file and insert your private key: `WALLET_PK=123abc...`
3. Create a `user_data` folder if it doesn't already exist, and create your `config.yml` file inside
(see [previous section](#configuration-file)).
4. Run the service with `docker-compose up -d` or `docker compose up -d` depending on your docker version.
4. Run the service with `docker-compose up -d`.

Note: the bot will create a file for the database named `pancaketrade.db` inside the `user_data` folder on your local machine.
Do not delete or move that file because it holds all your token configurations and orders data. This is the file to back
Expand All @@ -152,3 +168,11 @@ Binance Smart Chain networks at the address:
`0x026E539B566DcFF02af980d938deCcb11255d519`

Thanks for your contribution!

## Contribute

In order to contribute, make sure you install dev dependencies with `poetry install`. This repo is setup to use
pre-commit hooks, please install them with `pre-commit install` before committing.

To add your contribution, fork the repo, create a new branch off of `develop` and work in there, then create a pull
request against the `develop` branch of this repo.
6 changes: 3 additions & 3 deletions pancaketrade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
except ModuleNotFoundError:
from importlib_metadata import metadata, version # type: ignore

__version__ = version('pancaketrade')
__doc__ = metadata('pancaketrade')['Summary']
__author__ = metadata('pancaketrade')['Author']
__version__ = version("pancaketrade")
__doc__ = metadata("pancaketrade")["Summary"]
__author__ = metadata("pancaketrade")["Author"]

from .trade import *
2 changes: 1 addition & 1 deletion pancaketrade/abi/bep20.abi
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]
2 changes: 1 addition & 1 deletion pancaketrade/abi/factory.abi
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0","type":"address"},{"indexed":true,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"PairCreated","type":"event"},{"constant":true,"inputs":[],"name":"INIT_CODE_PAIR_HASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allPairs","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"allPairsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"name":"createPair","outputs":[{"internalType":"address","name":"pair","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"feeTo","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feeToSetter","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"getPair","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeTo","type":"address"}],"name":"setFeeTo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"name":"setFeeToSetter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
[{"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0","type":"address"},{"indexed":true,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"PairCreated","type":"event"},{"constant":true,"inputs":[],"name":"INIT_CODE_PAIR_HASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allPairs","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"allPairsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"name":"createPair","outputs":[{"internalType":"address","name":"pair","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"feeTo","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feeToSetter","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"getPair","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeTo","type":"address"}],"name":"setFeeTo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"name":"setFeeToSetter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
Loading

0 comments on commit 029c598

Please sign in to comment.