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

Update Defillama stablecoin endpoints #16

Merged
merged 1 commit into from
May 17, 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
52 changes: 16 additions & 36 deletions datamaxi/defillama/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,74 +288,54 @@ def token_price(

@postprocess()
def stablecoin_mcap(
self, stablecoin: str = None, pandas: bool = True
self, stablecoin: str, chain: str = None, pandas: bool = True
) -> Union[List, pd.DataFrame]:
"""Get market cap for given stablecoin
"""Get market cap for given stablecoin and chain

`GET /v1/defillama/stablecoin`
`GET /v1/defillama/stablecoin/mcap`

<https://docs.datamaxiplus.com/defillama/stablecoin-mcap>

Args:
stablecoin (str): stablecoin name
stablecoin (str): Stablecoin name
chain (str): Chain name (optional)
pandas (bool): Return data as pandas DataFrame

Returns:
Timeseries of market cap for given stablecoin
Timeseries of market cap for given stablecoin and chain
"""
check_required_parameter_list(stablecoin, "stablecoin")
check_required_parameter(stablecoin, "stablecoin")
params = {
"stablecoin": stablecoin,
}
return self.query("/v1/defillama/stablecoin", params)

@postprocess()
def stablecoin_chain_mcap(
self, stablecoin: str, chain: str, pandas: bool = True
) -> Union[List, pd.DataFrame]:
"""Get market cap for a given stablecoin on a specific chain

`GET /v1/defillama/stablecoin`

<https://docs.datamaxiplus.com/defillama/stablecoin-mcap>

Args:
stablecoin (str): stablecoin name
chain (str): chain name
pandas (bool): Return data as pandas DataFrame
if chain is not None:
params["chain"] = chain

Returns:
Timeseries of market cap for given stablecoin on a specific chain
"""
check_required_parameters([[stablecoin, "stablecoin"], [chain, "chain"]])
params = {
"stablecoin": stablecoin,
"chain": chain,
}
return self.query("/v1/defillama/stablecoin", params)
return self.query("/v1/defillama/stablecoin/mcap", params)

@postprocess()
def stablecoin_price(
self, stablecoins: Union[str, List[str]] = None, pandas: bool = True
self, stablecoin: str, pandas: bool = True
) -> Union[List, pd.DataFrame]:
"""Get price for given stablecoins
"""Get price for given stablecoin

`GET /v1/defillama/stablecoin/price`

<https://docs.datamaxiplus.com/defillama/stablecoin-price>

Args:
stablecoins (Union[str, List[str]]): single stablecoin or multiple stablecoin names
stablecoin (str): Stablecoin name
pandas (bool): Return data as pandas DataFrame

Returns:
Timeseries of stablecoin prices
"""
stablecoins = make_list(stablecoins)
check_required_parameter_list(stablecoins, "stablecoins")
check_required_parameter(stablecoin, "stablecoin")
params = {
"stablecoins": encode_string_list(stablecoins),
"stablecoin": stablecoin,
}
print(params)
return self.query("/v1/defillama/stablecoin/price", params)

@postprocess()
Expand Down
Loading