vault.protocol_metadata

Documentation for eth_defi.vault.protocol_metadata Python module.

Vault protocol metadata handling.

Read and export vault protocol metadata from YAML files to JSON format for upload to R2 storage.

Functions

build_metadata_json(yaml_path, public_url)

Build a VaultProtocolMetadata dict from a YAML file.

get_available_logos(slug)

Check which logo variants are available for a protocol.

process_and_upload_protocol_metadata(slug, ...)

Process and upload a single protocol's metadata and logos to R2.

read_protocol_metadata(yaml_path)

Read and parse a protocol metadata YAML file.

Classes

VaultProtocolLinks

Links associated with a vault protocol.

VaultProtocolLogos

Logo URLs for a vault protocol.

VaultProtocolMetadata

Complete vault protocol metadata as exported to JSON.

Bases: TypedDict

Links associated with a vault protocol.

All fields are optional and may be None if not available.

__init__(*args, **kwargs)
__new__(**kwargs)
clear()

Remove all items from the dict.

copy()

Return a shallow copy of the dict.

fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items()

Return a set-like object providing a view on the dict’s items.

keys()

Return a set-like object providing a view on the dict’s keys.

pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

Return an object providing a view on the dict’s values.

class VaultProtocolLogos

Bases: TypedDict

Logo URLs for a vault protocol.

Logo URLs point to 256x256 PNG files in R2 storage. None if the logo variant is not available.

__init__(*args, **kwargs)
__new__(**kwargs)
clear()

Remove all items from the dict.

copy()

Return a shallow copy of the dict.

fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items()

Return a set-like object providing a view on the dict’s items.

keys()

Return a set-like object providing a view on the dict’s keys.

pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

Return an object providing a view on the dict’s values.

class VaultProtocolMetadata

Bases: TypedDict

Complete vault protocol metadata as exported to JSON.

This structure is used for frontend consumption and API responses.

__init__(*args, **kwargs)
__new__(**kwargs)
clear()

Remove all items from the dict.

copy()

Return a shallow copy of the dict.

fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items()

Return a set-like object providing a view on the dict’s items.

keys()

Return a set-like object providing a view on the dict’s keys.

pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

Return an object providing a view on the dict’s values.

build_metadata_json(yaml_path, public_url)

Build a VaultProtocolMetadata dict from a YAML file.

Reads the YAML metadata, adds logo URLs based on available formatted logos, and ensures all fields are present (with None for missing values).

Parameters
Returns

Complete VaultProtocolMetadata dict ready for JSON export

Return type

eth_defi.vault.protocol_metadata.VaultProtocolMetadata

get_available_logos(slug)

Check which logo variants are available for a protocol.

Parameters

slug (str) – Protocol slug (e.g., “euler”, “lagoon-finance”)

Returns

Dictionary with ‘dark’ and ‘light’ keys indicating availability

Return type

dict[str, bool]

process_and_upload_protocol_metadata(slug, bucket_name, endpoint_url, access_key_id, secret_access_key, public_url, key_prefix='')

Process and upload a single protocol’s metadata and logos to R2.

Reads the YAML metadata file, builds the JSON with logo URLs, and uploads the JSON and any available logo files to R2.

Parameters
  • slug (str) – Protocol slug (e.g., “euler”, “lagoon-finance”)

  • bucket_name (str) – R2 bucket name

  • endpoint_url (str) – R2 API endpoint URL

  • access_key_id (str) – R2 access key ID

  • secret_access_key (str) – R2 secret access key

  • public_url (str) – Public base URL for constructing logo URLs in metadata

  • key_prefix (str) – Optional prefix for R2 keys (e.g., “test-” for testing)

Returns

The processed VaultProtocolMetadata dict

Return type

eth_defi.vault.protocol_metadata.VaultProtocolMetadata

read_protocol_metadata(yaml_path)

Read and parse a protocol metadata YAML file.

Parameters

yaml_path (pathlib.Path) – Path to the YAML file

Returns

Parsed YAML as a dictionary

Return type

dict