hypersync.utils

Documentation for eth_defi.hypersync.utils Python module.

Hypersync configuration utils.

Functions

configure_hypersync_from_env(web3[, ...])

Helper for scan-vaults and scan-prices scripts to configure Hypersync client from environment variables.

Classes

HypersyncBackendConfig

HypersyncBackendConfig(hypersync_client: 'ThrottledHypersyncClient | None', hypersync_url: 'str | None', scan_backend: str)

class HypersyncBackendConfig

Bases: object

HypersyncBackendConfig(hypersync_client: ‘ThrottledHypersyncClient | None’, hypersync_url: ‘str | None’, scan_backend: str)

__init__(hypersync_client, hypersync_url, scan_backend)
Parameters
Return type

None

configure_hypersync_from_env(web3, hypersync_api_key=None, limiter=None, concurrency=None)

Helper for scan-vaults and scan-prices scripts to configure Hypersync client from environment variables.

  • Some chains support HyperSync, others don’t - autodetect support

  • The returned client is always a ThrottledHypersyncClient that rate-limits every API call. The rate defaults to 150 RPM and can be overridden with the HYPERSYNC_RPM environment variable or by passing an explicit limiter.

  • Stream concurrency defaults to the Hypersync server default (10) and can be overridden with the HYPERSYNC_CONCURRENCY environment variable or via the concurrency parameter.

Parameters
  • hypersync_api_key (Optional[str]) – Use given API key, instead of reading from env.

  • limiter (Optional[pyrate_limiter.limiter.Limiter]) – Optional shared pyrate_limiter.Limiter. Pass the same instance to multiple configure_hypersync_from_env calls (e.g. lead discovery + price scanning) so they coordinate rate limits via one SQLite bucket.

  • concurrency (Optional[int]) – Number of requests in flight for stream tuning. None falls back to the HYPERSYNC_CONCURRENCY env var, then to the Hypersync server default.

  • web3 (web3.main.Web3) –

Returns

A valid Hypersync config if the chain supports HyperSync

Return type

eth_defi.hypersync.utils.HypersyncBackendConfig