solana-program-library/stake-pool/py
Jon Cinque 3a7914ceba
stake-pool-py: Fix tests for Solana 1.10.33 (#3395)
2022-07-29 22:59:50 +02:00
..
bot stake-pool: Update program to work with minimum delegation (#3127) 2022-05-02 22:45:25 +02:00
spl_token stake-pool-py: Create and deserialize stake pools (#2557) 2021-12-10 00:43:25 +01:00
stake stake-pool: Update program to work with minimum delegation (#3127) 2022-05-02 22:45:25 +02:00
stake_pool stake-pool: Handle force destaked accounts (#3152) 2022-05-19 19:08:50 +02:00
system stake-pool-py: Create and deserialize stake pools (#2557) 2021-12-10 00:43:25 +01:00
tests stake-pool-py: Fix tests for Solana 1.10.33 (#3395) 2022-07-29 22:59:50 +02:00
vote stake-pool-py: Create and deserialize stake pools (#2557) 2021-12-10 00:43:25 +01:00
.flake8 stake-pool-py: Create and deserialize stake pools (#2557) 2021-12-10 00:43:25 +01:00
.gitignore stake-pool-py: Create and deserialize stake pools (#2557) 2021-12-10 00:43:25 +01:00
LICENSE Rename stake-pool/LICENSE to stake-pool/py/LICENSE 2022-07-25 16:55:17 -07:00
README.md stake-pool-py: Add simple rebalance bot (#2630) 2021-12-13 13:17:07 +01:00
requirements.txt stake-pool-py: Fix tests for Solana 1.10.33 (#3395) 2022-07-29 22:59:50 +02:00

README.md

Stake-Pool Python Bindings

Preliminary Python bindings to interact with the stake pool program, enabling simple stake delegation bots.

To do

  • More reference bot implementations
  • Add bindings for all stake pool instructions, see TODOs in stake_pool/instructions.py
  • Finish bindings for vote and stake program
  • Upstream vote and stake program bindings to https://github.com/michaelhly/solana-py

Development

Environment Setup

  1. Ensure that Python 3 is installed with venv: https://www.python.org/downloads/
  2. (Optional, but highly recommended) Setup and activate a virtual environment:
$ python3 -m venv venv
$ source venv/bin/activate
  1. Install requirements
$ pip install -r requirements.txt
  1. Install the Solana tool suite: https://docs.solana.com/cli/install-solana-cli-tools

Test

Testing through pytest:

$ python3 -m pytest

Note: the tests all run against a solana-test-validator with short epochs of 64 slots (25.6 seconds exactly). Some tests wait for epoch changes, so they take time, roughly 90 seconds total at the time of this writing.

Formatting

$ flake8 bot spl_token stake stake_pool system tests vote

Type Checker

$ mypy bot stake stake_pool tests vote spl_token system

Delegation Bots

The ./bot directory contains sample stake pool delegation bot implementations:

  • rebalance: simple bot to make the amount delegated to each validator uniform, while also maintaining some SOL in the reserve if desired. Can be run with the stake pool address, staker keypair, and SOL to leave in the reserve:
$ python3 bot/rebalance.py Zg5YBPAk8RqBR9kaLLSoN5C8Uv7nErBz1WC63HTsCPR staker.json 10.5