Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow single token address only and support change param for token price #14

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions datamaxi/defillama/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def protocol_mcap(

@postprocess()
def token_price(
self, addresses: Union[str, List[str]] = None, pandas: bool = True
self, address: str, change: bool = False, pandas: bool = True
) -> Union[List, pd.DataFrame]:
"""Get token prices

Expand All @@ -263,16 +263,17 @@ def token_price(
<https://docs.datamaxiplus.com/defillama/token-price>

Args:
addresses (Union[str, List[str]]): single address or multiple addresses
address (str): Token address
change (bool): Return price change (default: False)
pandas (bool): Return data as pandas DataFrame

Returns:
Timeseries of token prices
"""
addresses = make_list(addresses)
check_required_parameter_list(addresses, "addresses")
check_required_parameters([[address, "address"], [change, "change"]])
params = {
"addresses": encode_string_list(addresses),
"address": address,
"change": str(change).lower(),
}
return self.query("/v1/defillama/token", params)

Expand Down
Loading