vault_report.logos
Documentation for eth_defi.vault_report.logos Python module.
Brand, protocol and chain logos for report charts.
Brand logos are bundled in
eth_defi/vault_report/assets, copied from the website frontend (src/lib/assets).Benchmark logos (BTC, ETH, US Treasury) are bundled in
eth_defi/vault_report/assets/benchmarks, copied from the website frontend (src/lib/assets/logos/tokens), the same logos as its vault comparison chart.Protocol logos come from this repository’s vault metadata,
eth_defi/data/vaults/formatted_logos/{slug}/{light,dark,generic}.png, for protocols and curators alike.light.pngis for dark backgrounds anddark.pngfor light backgrounds;generic.pngis the fallback when neither exists.Chain logos are downloaded from the website,
https://tradingstrategy.ai/logos/blockchains/{slug}, and cached on disk.
Missing logos are never an error: callers get None and draw the chart without the logo.
Chart logos are passed around as base64 data: URIs rather than file paths
or URLs. Plotly layout images take a URI, and an inline URI makes each figure
self-contained: Kaleido’s headless Chrome draws it without file or network
access. The URI string also serves as the logo’s identity: the report
collects the URIs of all charted vaults, and
eth_defi.vault_report.charts.trim_logos() and
rasterise_logos() key their results by it.
Module Attributes
Benchmark name -> bundled logo file |
|
Chain logo endpoint of the website |
Functions
|
Download a chain logo from the website, caching it on disk. |
|
Load a benchmark logo as a data URI. |
|
Find the protocol logo that suits the theme background. |
|
Load a protocol logo as a data URI. |
|
Encode an image as a data URI for Plotly layout images. |
- PROTOCOL_LOGO_DIR = PosixPath('/home/runner/work/web3-ethereum-defi/web3-ethereum-defi/eth_defi/data/vaults/formatted_logos')
Protocol logos maintained in the vault metadata
- BENCHMARK_LOGO_FILES = {'BTC': 'btc.svg', 'ETH': 'eth.svg', 'US 3M T-bill': 'us-treasury.svg'}
Benchmark name -> bundled logo file
- CHAIN_LOGO_URL = 'https://tradingstrategy.ai/logos/blockchains/{slug}'
Chain logo endpoint of the website
- to_data_uri(data, mime_type)
Encode an image as a data URI for Plotly layout images.
Encoding is deterministic, so the same file always gives the same URI and logos can be deduplicated by their URI.
- load_protocol_logo_path(protocol_slug, theme)
Find the protocol logo that suits the theme background.
The variant names describe the logo, not the background:
light.pngis a light-coloured logo for dark backgrounds. If the preferred variant is missing, the opposite one is still better than no logo, andgeneric.pngcomes last. Curators are looked up the same way, by their curator slug, because their logos live in the same directory.Used directly for the podcast guest tiles, see
eth_defi.vault_report.branding.render_logo_tile(), and throughload_protocol_logo_uri()for the chart logos.- Parameters
protocol_slug (Optional[str]) – Protocol or curator slug from the vault metadata,
protocol_slugorcurator_slug.theme (eth_defi.vault_report.theme.ChartTheme) – Chart theme; dark themes use
light.png, thendark.png, thengeneric.png.
- Returns
PNG path, or
Noneif the protocol has no logo.- Return type
- load_protocol_logo_uri(protocol_slug, theme)
Load a protocol logo as a data URI.
Used for the protocol and curator icons under vault names, and for the protocol rows of the average yield and TVL charts.
- Parameters
theme (eth_defi.vault_report.theme.ChartTheme) – Chart theme.
- Returns
Data URI, or
Noneif the protocol has no logo.- Return type
- fetch_chain_logo_uri(chain_name, cache_dir, timeout=20.0)
Download a chain logo from the website, caching it on disk.
The repository has no chain logo collection, so the website’s logo endpoint is the canonical source. A cached file is reused forever; delete the cache directory to pick up a changed logo. Failures are not cached, so a missing logo is tried again on the next run. The content type check rejects anything but SVG, e.g. an HTML error page served with status 200. A network failure is logged as a warning, a chain without a logo only at info level, because many small chains have none.
eth_defi.vault_report.report.render_report_charts()memoises the result per chain for one run.- Parameters
chain_name (str) – Chain name as in the vault metadata, e.g.
Hypercore.cache_dir (pathlib.Path) – Logo cache directory,
logos/under the report download cache.timeout (float) – HTTP timeout in seconds.
- Returns
SVG data URI, or
Noneif the website has no logo for the chain or the download fails.- Return type
- load_benchmark_logo_uri(benchmark)
Load a benchmark logo as a data URI.
The performance charts draw it in the legend row of the benchmark and at its line end, see
eth_defi.vault_report.charts.create_performance_figure().- Parameters
benchmark (str) – Benchmark name, see
eth_defi.vault_report.benchmarks.- Returns
SVG data URI, or
Nonefor a benchmark without a logo.- Return type