Skip to main content

This library consolidates various functions to efficiently load network data for Lido, validate node operator keys and find key duplicates.

Project description

Lido Lido Python SDK

codecov Code style: black License: MIT

This repo provides a scratch of a Python project. Its purpose is to serve as starting point for the development of a Python project based on a minimal working structure.

Installation

This library is available on PyPi:

pip install lido-sdk

Main Features

Multicall Function Calls

Instead of making network requests one-by-one, this library combines many requests into one RPC call. It uses banteg/multicall.py, a Python wrapper for makerdao/multicall.

Automatic Testnet / Mainnet Switching

Depending on which network is configured in web3 object, a set of contracts will be used. Available networks:

  • Mainnet
  • Görli
  • Ropsten

Helpers Provided

  • lido.get_operators_data() -> operator_data - load node operator data

  • lido.get_operators_keys(operator_data) -> operator_data - fetches and adds keys to operator_data

  • lido.validate_keys(operator_data, strict = False) -> [] - same as validate_keys_multi(), but returns a list of invalid keys
    (IN PROGRESS)

  • lido.validate_key(chain_id, key, withdrawal_credentials) -> Boolean - low-level validation function, doesn't check for correct chain_id and withdrawal_credentials for a Lido deployment. For most use-cases use validate_keys_multi or validate_key_list_multi instead

  • lido.find_duplicates(operator_data) -> operator_data - finds duplicate keys and adds results to operator_data

  • lido.fetch_and_validate() -> operator_data - combines fetching operator data and running all validations on it - useful when you would be running all validations on data anyway

  • lido.get_stats() -> stats - fetches various constants from Lido contract, but you can even pass a list of functions to fetch eg get_stats(["isStopped"])

You can mix and match these functions, but make sure to use get_operators_data() first.

Development

Clone project:

git clone git@github.com:lidofinance/lido-python-sdk.git
cd lido-python-sdk

Create virtual env:

virtualenv .env --python=python3
source .env/bin/activate

Install all dependencies:

  pip install -r requirements.txt
  pip install -r requirements-dev.txt

How to test

Simply run in project root directory:

pytest .

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

lido-sdk-0.2.0.tar.gz (11.1 kB view hashes)

Uploaded Source

Built Distribution

lido_sdk-0.2.0-py2.py3-none-any.whl (11.8 kB view hashes)

Uploaded Python 2 Python 3

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