Skip to main content

Shared code for badger autovoters

Project description

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 codecov PyPI version

List of functional modules:

Utilities


Get web3 instance

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

from badger_voter_sdk.aws import get_secret

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

Rich logger

Preconfigured rich logger to be shared across voting bots projects

from badger_voter_sdk.rich_logger import logger

logger.info()

Snapshot and data collectors

Get all voters for snapshot

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

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:

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})

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

badger-voter-sdk-0.0.7.tar.gz (8.6 kB view details)

Uploaded Source

File details

Details for the file badger-voter-sdk-0.0.7.tar.gz.

File metadata

  • Download URL: badger-voter-sdk-0.0.7.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for badger-voter-sdk-0.0.7.tar.gz
Algorithm Hash digest
SHA256 13f6541321a5a967b9f0ef4a268e048ce3b88025a14cf6ee5e7399cbc9ce1588
MD5 9c53a5e86c2d89e34ffe9fc7c6dbefe9
BLAKE2b-256 a6c6139935bbb509ec53d1d1d4b545203e2f82d95f1eded18032bbf3fb4992fb

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