From 01bd79e1cfa296c293d75aa4ceb9e280c26d6edb Mon Sep 17 00:00:00 2001 From: Martin Kersner Date: Thu, 16 May 2024 20:29:04 +0900 Subject: [PATCH] feat: update stablecoin endpoints --- datamaxi/defillama/__init__.py | 52 +++++++++++----------------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/datamaxi/defillama/__init__.py b/datamaxi/defillama/__init__.py index 324ab65..7796717 100644 --- a/datamaxi/defillama/__init__.py +++ b/datamaxi/defillama/__init__.py @@ -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` 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` - - - 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` 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()