badger-voter-sdk


Namebadger-voter-sdk JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/Badger-Finance/badger-voter-sdk
SummaryShared code for badger autovoters
upload_time2023-05-16 15:54:37
maintainer
docs_urlNone
authorSHAKOTN
requires_python>=3.7,<4
licenseMIT
keywords badger-voter-sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # Badger SDK for autovoters

This is the library for shared code that is used in autovoters, such as cvx autovoter and aura autovoter

| Build  | Coverage | PYPI | 
| ------------- | ------------- | ------------- |
| [![Tests](https://github.com/Badger-Finance/badger-voter-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/Badger-Finance/badger-voter-sdk/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/Badger-Finance/badger-voter-sdk/branch/main/graph/badge.svg?token=UYLO67O4Q9)](https://codecov.io/gh/Badger-Finance/badger-voter-sdk)  | [![PyPI version](https://badge.fury.io/py/badger-voter-sdk.svg)](https://badge.fury.io/py/badger-voter-sdk) |


## List of functional modules:

## Utilities

--- 

### Get web3 instance

```python
import os
from badger_voter_sdk.web3 import get_web3

web3 = get_web3(os.getenv("ETHNODEURL"))
```
Or web3 will be created from default secrets in `constants.py`


### AWS get secret
Getting secret from AWS by id and key

```python
from badger_voter_sdk.aws import get_secret

secret = get_secret(secret_id="SecretId", secret_key="SecretKey")
```


### Json logger
Preconfigured json logger to be shared across voting bots projects

```python
from badger_voter_sdk.json_logger import logger

logger.info()
```

## Snapshot and data collectors

### Get all voters for snapshot

```python
from badger_voter_sdk.collectors.snapshot_collectors import get_voters

voters = get_voters(snapshot_id="some_snapshot_id")
```

### Get vlTOKEN amounts per wallet voted for given snapshot round

```python
from badger_voter_sdk.collectors.api_collectors import get_scores

scores = get_scores(
    "aurafinance.eth", "1", "<SNAPSHOT_ID>",
    ["<ADDRESS1>"],
    [{'name': "erc20-votes", 'network': "1", 'params': {
        'symbol': "<vlTOKEN>", 'address': "<STRATEGY_ADDR>"}}]
)
```

### Get voting choices with voting power
You need to combine two previous functions outputs:

```python
from badger_voter_sdk.collectors.data_processors import extract_voting_power_per_pool

choices_with_votes = extract_voting_power_per_pool(voters={"<wallet>": {"1": 123}}, scores={"<wallet>": 123333.1})
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Badger-Finance/badger-voter-sdk",
    "name": "badger-voter-sdk",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4",
    "maintainer_email": "",
    "keywords": "badger-voter-sdk",
    "author": "SHAKOTN",
    "author_email": "andrii@badger.com",
    "download_url": "https://files.pythonhosted.org/packages/63/60/82e04452ca67de13f6a03ea69d1989f214037a049ac060146cf5b447e889/badger-voter-sdk-0.1.3.tar.gz",
    "platform": null,
    "description": "# Badger SDK for autovoters\n\nThis is the library for shared code that is used in autovoters, such as cvx autovoter and aura autovoter\n\n| Build  | Coverage | PYPI | \n| ------------- | ------------- | ------------- |\n| [![Tests](https://github.com/Badger-Finance/badger-voter-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/Badger-Finance/badger-voter-sdk/actions/workflows/test.yml) | [![codecov](https://codecov.io/gh/Badger-Finance/badger-voter-sdk/branch/main/graph/badge.svg?token=UYLO67O4Q9)](https://codecov.io/gh/Badger-Finance/badger-voter-sdk)  | [![PyPI version](https://badge.fury.io/py/badger-voter-sdk.svg)](https://badge.fury.io/py/badger-voter-sdk) |\n\n\n## List of functional modules:\n\n## Utilities\n\n--- \n\n### Get web3 instance\n\n```python\nimport os\nfrom badger_voter_sdk.web3 import get_web3\n\nweb3 = get_web3(os.getenv(\"ETHNODEURL\"))\n```\nOr web3 will be created from default secrets in `constants.py`\n\n\n### AWS get secret\nGetting secret from AWS by id and key\n\n```python\nfrom badger_voter_sdk.aws import get_secret\n\nsecret = get_secret(secret_id=\"SecretId\", secret_key=\"SecretKey\")\n```\n\n\n### Json logger\nPreconfigured json logger to be shared across voting bots projects\n\n```python\nfrom badger_voter_sdk.json_logger import logger\n\nlogger.info()\n```\n\n## Snapshot and data collectors\n\n### Get all voters for snapshot\n\n```python\nfrom badger_voter_sdk.collectors.snapshot_collectors import get_voters\n\nvoters = get_voters(snapshot_id=\"some_snapshot_id\")\n```\n\n### Get vlTOKEN amounts per wallet voted for given snapshot round\n\n```python\nfrom badger_voter_sdk.collectors.api_collectors import get_scores\n\nscores = get_scores(\n    \"aurafinance.eth\", \"1\", \"<SNAPSHOT_ID>\",\n    [\"<ADDRESS1>\"],\n    [{'name': \"erc20-votes\", 'network': \"1\", 'params': {\n        'symbol': \"<vlTOKEN>\", 'address': \"<STRATEGY_ADDR>\"}}]\n)\n```\n\n### Get voting choices with voting power\nYou need to combine two previous functions outputs:\n\n```python\nfrom badger_voter_sdk.collectors.data_processors import extract_voting_power_per_pool\n\nchoices_with_votes = extract_voting_power_per_pool(voters={\"<wallet>\": {\"1\": 123}}, scores={\"<wallet>\": 123333.1})\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Shared code for badger autovoters",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/Badger-Finance/badger-voter-sdk"
    },
    "split_keywords": [
        "badger-voter-sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "636082e04452ca67de13f6a03ea69d1989f214037a049ac060146cf5b447e889",
                "md5": "381e5e9f2d2e38bbcfc3cc9f49935c5a",
                "sha256": "3b72048d55455208eed79b1bf5c3a8727615c528ee1be600ec5385fe5403ef9a"
            },
            "downloads": -1,
            "filename": "badger-voter-sdk-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "381e5e9f2d2e38bbcfc3cc9f49935c5a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4",
            "size": 11036,
            "upload_time": "2023-05-16T15:54:37",
            "upload_time_iso_8601": "2023-05-16T15:54:37.884921Z",
            "url": "https://files.pythonhosted.org/packages/63/60/82e04452ca67de13f6a03ea69d1989f214037a049ac060146cf5b447e889/badger-voter-sdk-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-16 15:54:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Badger-Finance",
    "github_project": "badger-voter-sdk",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "badger-voter-sdk"
}
        
Elapsed time: 0.52233s