Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
Landon Gingerich authored and Landon Gingerich committed Sep 12, 2023
1 parent 180ab2b commit 7c7008d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
35 changes: 19 additions & 16 deletions src/defillama_py/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,6 @@ def get_all_chains_current_tvl(

# /fetch/signature
# /fetch/contract/{chain}/{address}



# --- Bridges --- #

Expand Down Expand Up @@ -437,7 +435,6 @@ def get_all_bridge_volume(
else:
return pd.DataFrame(response["bridges"])


def get_bridge_volume(
self, ids: List[str], raw: bool = True
) -> Union[Dict, pd.DataFrame]:
Expand Down Expand Up @@ -521,7 +518,6 @@ def get_bridge_volume(
else:
return pd.concat(dfs, ignore_index=True)


def get_chain_bridge_volume(
self, chains: List[str], params: Dict = None, raw: bool = True
) -> Union[Dict, pd.DataFrame]:
Expand Down Expand Up @@ -581,7 +577,6 @@ def get_chain_bridge_volume(
]
return self._clean_chain_name(df)


def get_bridge_day_stats(
self,
timestamp: int,
Expand Down Expand Up @@ -618,8 +613,12 @@ def get_bridge_day_stats(
else:
results = []
for chain in chains:
data = self._get("BRIDGES", endpoint=f"/bridgedaystats/{timestamp}/{chain}", params=params)

data = self._get(
"BRIDGES",
endpoint=f"/bridgedaystats/{timestamp}/{chain}",
params=params,
)

for token, details in data.get("totalTokensDeposited", {}).items():
details["date"] = data["date"]
details["chain"] = chain
Expand All @@ -633,14 +632,14 @@ def get_bridge_day_stats(
details["token"] = token
details["type"] = "totalTokensWithdrawn"
results.append(details)

for token, details in data.get("totalAddressDeposited", {}).items():
details["date"] = data["date"]
details["chain"] = chain
details["token"] = token
details["type"] = "totalAddressDeposited"
results.append(details)

for token, details in data.get("totalAddressWithdrawn", {}).items():
details["date"] = data["date"]
details["chain"] = chain
Expand All @@ -651,7 +650,6 @@ def get_bridge_day_stats(
df = pd.DataFrame(results)
return df


def get_bridge_transactions(self, id: int, params: Dict = None, raw: bool = True):
"""Get all transactions for a bridge within a date range.
Expand Down Expand Up @@ -680,19 +678,25 @@ def get_bridge_transactions(self, id: int, params: Dict = None, raw: bool = True

if raw:
if len(id) == 1:
return self._get("BRIDGES", endpoint=f"/transactions/{id[0]}", params=params)
return self._get(
"BRIDGES", endpoint=f"/transactions/{id[0]}", params=params
)

results = {}
for bridge_id in id:
results[bridge_id] = self._get("BRIDGES", endpoint=f"/transactions/{bridge_id}", params=params)
results[bridge_id] = self._get(
"BRIDGES", endpoint=f"/transactions/{bridge_id}", params=params
)
return results

else:
results = []

for bridge_id in id:
transactions = self._get("BRIDGES", endpoint=f"/transactions/{bridge_id}", params=params)

transactions = self._get(
"BRIDGES", endpoint=f"/transactions/{bridge_id}", params=params
)

for entry in transactions:
results.append(
{
Expand All @@ -706,14 +710,13 @@ def get_bridge_transactions(self, id: int, params: Dict = None, raw: bool = True
"chain": entry.get("chain"),
"bridge_name": entry.get("bridge_name"),
"usd_value": entry.get("usd_value"),
"sourceChain": entry.get("sourceChain")
"sourceChain": entry.get("sourceChain"),
}
)

df = pd.DataFrame(results)
return df


# --- Volumes --- #

def get_dex_volume(self, params: Dict = None, raw: bool = True):
Expand Down
2 changes: 1 addition & 1 deletion src/defillama_py/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

# ttps://bridges.llama.fi/bridgedaystats/1694347200/ethereum?id=5
# df = obj.get_bridges(params={"includeChains": False}, raw=False)
df = obj.get_chain_bridge_volume('Ethereum', raw=False)
df = obj.get_chain_bridge_volume("Ethereum", raw=False)
# df = obj.get_bridge_day_stats(1694347200, ['ethereum'], raw=True)
# df = obj.get_bridge_transactions([1, 2], raw=False)

Expand Down

0 comments on commit 7c7008d

Please sign in to comment.