Skip to content

Commit

Permalink
added volumes ep
Browse files Browse the repository at this point in the history
  • Loading branch information
itzmestar committed Apr 11, 2024
1 parent 2b096dc commit a82a38c
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
78 changes: 78 additions & 0 deletions defillama/defillama.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,81 @@ def get_pool(self, pool: str):
path = f'https://yields.llama.fi/chart/{pool}'

return self._get(path, full_url=True)

# ##### Volumes EPs ###### #

def get_dexs(self, excludeTotalDataChart=True, excludeTotalDataChartBreakdown=True, dataType='dailyVolume'):
"""
list all dexs
"""
path = '/overview/dexs'
params = {
'excludeTotalDataChart': excludeTotalDataChart,
'excludeTotalDataChartBreakdown': excludeTotalDataChartBreakdown,
'dataType': dataType
}

return self._get(path, params=params)

def get_chain_dexs(self, chain, excludeTotalDataChart=True, excludeTotalDataChartBreakdown=True, dataType='dailyVolume'):
"""
list all dexs filter by chain
"""
path = f'/overview/dexs/{chain}'
params = {
'excludeTotalDataChart': excludeTotalDataChart,
'excludeTotalDataChartBreakdown': excludeTotalDataChartBreakdown,
'dataType': dataType
}

return self._get(path, params=params)

def get_dex_summary(self, protocol, excludeTotalDataChart=True, excludeTotalDataChartBreakdown=True, dataType='dailyVolume'):
"""
get summary of dex volume with historical data
"""
path = f'/summary/dexs/{protocol}'
params = {
'excludeTotalDataChart': excludeTotalDataChart,
'excludeTotalDataChartBreakdown': excludeTotalDataChartBreakdown,
'dataType': dataType
}

return self._get(path, params=params)

def get_options_dexs(self, excludeTotalDataChart=True, excludeTotalDataChartBreakdown=True, dataType='dailyVolume'):
"""
list all options dexs
"""
path = '/overview/options'
params = {
'excludeTotalDataChart': excludeTotalDataChart,
'excludeTotalDataChartBreakdown': excludeTotalDataChartBreakdown,
'dataType': dataType
}

return self._get(path, params=params)

def get_chain_options_dexs(self, chain, excludeTotalDataChart=True, excludeTotalDataChartBreakdown=True, dataType='dailyVolume'):
"""
list all options dexs
"""
path = f'/overview/options/{chain}'
params = {
'excludeTotalDataChart': excludeTotalDataChart,
'excludeTotalDataChartBreakdown': excludeTotalDataChartBreakdown,
'dataType': dataType
}

return self._get(path, params=params)

def get_options_dex_summary(self, protocol, dataType='dailyPremiumVolume'):
"""
get summary of option dex volume with historical data
"""
path = f'/summary/options/{protocol}'
params = {
'dataType': dataType
}

return self._get(path, params=params)
44 changes: 44 additions & 0 deletions tests/test_defillama.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,47 @@ def test_get_pool(self, llama):
assert type(response) is dict
assert 'status' in response
assert 'data' in response

def test_get_dexs(self, llama):
response = llama.get_dexs()
assert type(response) is dict
assert 'totalDataChart' in response
assert 'totalDataChartBreakdown' in response
assert 'protocols' in response

def test_get_chain_dexs(self, llama):
response = llama.get_dexs('ethereum')
assert type(response) is dict
assert 'totalDataChart' in response
assert 'totalDataChartBreakdown' in response
assert 'protocols' in response

def test_get_dex_summary(self, llama):
response = llama.get_dex_summary('uniswap')
assert type(response) is dict
assert 'id' in response
assert 'name' in response
assert 'url' in response
assert 'totalDataChart' in response

def test_get_options_dexs(self, llama):
response = llama.get_options_dexs()
assert type(response) is dict
assert 'totalDataChart' in response
assert 'totalDataChartBreakdown' in response
assert 'protocols' in response

def test_get_chain_options_dexs(self, llama):
response = llama.get_chain_options_dexs('ethereum')
assert type(response) is dict
assert 'totalDataChart' in response
assert 'totalDataChartBreakdown' in response
assert 'protocols' in response

def test_get_options_dex_summary(self, llama):
response = llama.get_options_dex_summary('lyra')
assert type(response) is dict
assert 'id' in response
assert 'name' in response
assert 'url' in response
assert 'totalDataChart' in response

0 comments on commit a82a38c

Please sign in to comment.