2022-01-03 13:57:36 +01:00
|
|
|
from .utils import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Protocols:
|
|
|
|
|
"""
|
2022-02-17 19:22:17 +01:00
|
|
|
Protocols class.
|
2022-01-03 13:57:36 +01:00
|
|
|
|
2022-02-17 19:22:17 +01:00
|
|
|
Methods
|
|
|
|
|
-------
|
|
|
|
|
__init__(glassnode_client):
|
|
|
|
|
Constructs a Protocols object.
|
|
|
|
|
uniswap_transactions():
|
|
|
|
|
Returns the total number of transactions
|
|
|
|
|
that contains an interaction within Uniswap contracts.
|
|
|
|
|
uniswap_liquidity():
|
|
|
|
|
Returns the current liquidity on Uniswap.
|
|
|
|
|
uniswap_volume():
|
|
|
|
|
Returns the total volume traded on Uniswap.
|
2022-01-03 13:57:36 +01:00
|
|
|
"""
|
2022-02-17 19:22:17 +01:00
|
|
|
|
2022-01-03 13:57:36 +01:00
|
|
|
def __init__(self, glassnode_client):
|
|
|
|
|
self._gc = glassnode_client
|
|
|
|
|
self._endpoints = self._gc.endpoints
|
|
|
|
|
|
|
|
|
|
def uniswap_transactions(self) -> pd.DataFrame:
|
|
|
|
|
"""
|
|
|
|
|
The total number of transactions that contains an interaction within Uniswap contracts.
|
|
|
|
|
Includes Mint, Burn, and Swap events on the Uniswap core contracts.
|
|
|
|
|
`View in Studio <https://studio.glassnode.com/metrics?a=ETH&m=protocols.UniswapTransactionCount>`_
|
|
|
|
|
|
|
|
|
|
:return: A DataFrame containing Uniswap transactions data.
|
|
|
|
|
:rtype: DataFrame
|
|
|
|
|
"""
|
2022-02-17 19:22:17 +01:00
|
|
|
endpoint = "/v1/metrics/protocols/uniswap_transaction_count"
|
2022-01-03 13:57:36 +01:00
|
|
|
if not is_supported_by_endpoint(self._gc, endpoint):
|
|
|
|
|
return pd.DataFrame()
|
|
|
|
|
|
|
|
|
|
return response_to_dataframe(self._gc.get(endpoint))
|
|
|
|
|
|
|
|
|
|
def uniswap_liquidity(self) -> pd.DataFrame:
|
|
|
|
|
"""
|
|
|
|
|
The current liquidity on Uniswap.
|
|
|
|
|
`View in Studio <https://studio.glassnode.com/metrics?a=ETH&m=protocols.UniswapLiquidityLatest>`_
|
|
|
|
|
|
|
|
|
|
:return: A DataFrame containing Uniswap liquidity data.
|
|
|
|
|
:rtype: DataFrame
|
|
|
|
|
"""
|
2022-02-17 19:22:17 +01:00
|
|
|
endpoint = "/v1/metrics/protocols/uniswap_liquidity_latest"
|
2022-01-03 13:57:36 +01:00
|
|
|
if not is_supported_by_endpoint(self._gc, endpoint):
|
|
|
|
|
return pd.DataFrame()
|
|
|
|
|
|
|
|
|
|
return response_to_dataframe(self._gc.get(endpoint))
|
|
|
|
|
|
|
|
|
|
def uniswap_volume(self) -> pd.DataFrame:
|
|
|
|
|
"""
|
|
|
|
|
The total volume traded on Uniswap.
|
|
|
|
|
`View in Studio <https://studio.glassnode.com/metrics?a=ETH&m=protocols.UniswapVolumeSum>`_
|
|
|
|
|
|
|
|
|
|
:return: A DataFrame containing Uniswap volume data.
|
|
|
|
|
:rtype: DataFrame
|
|
|
|
|
"""
|
2022-02-17 19:22:17 +01:00
|
|
|
endpoint = "/v1/metrics/protocols/uniswap_volume_sum"
|
2022-01-03 13:57:36 +01:00
|
|
|
if not is_supported_by_endpoint(self._gc, endpoint):
|
|
|
|
|
return pd.DataFrame()
|
|
|
|
|
|
|
|
|
|
return response_to_dataframe(self._gc.get(endpoint))
|