-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d6a249
commit 876ab37
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import asyncio | ||
import polars as pl | ||
from mev_commit_sdk_py.hypersync_client import Hypersync | ||
|
||
# Expand Polars DataFrame output | ||
pl.Config.set_fmt_str_lengths(200) | ||
pl.Config.set_fmt_float("full") | ||
|
||
# Create an asynchronous function to manage the queries | ||
|
||
|
||
async def main(): | ||
# Initialize the client | ||
client = Hypersync(url='https://mev-commit.hypersync.xyz') | ||
|
||
# Run the queries concurrently | ||
deposits_df, withdraws_df = await asyncio.gather( | ||
client.get_window_deposits( | ||
address='0xe51EF1836Dbef052BfFd2eB3Fe1314365d23129d'), | ||
client.get_window_withdraws( | ||
address='0xe51EF1836Dbef052BfFd2eB3Fe1314365d23129d') | ||
) | ||
|
||
# Extract DataFrame columns to lists | ||
deposit_windows: list[int] = deposits_df['windowNumber'].to_list() | ||
withdraw_windows: list[int] = withdraws_df['window'].to_list() | ||
|
||
# Take the set difference between deposit_windows and withdraw_windows | ||
windows: list[int] = list(set(deposit_windows) - set(withdraw_windows)) | ||
|
||
# Print windows with funds still locked | ||
print('Windows with funds still locked:') | ||
print(windows) | ||
|
||
# Total the amount of ETH locked | ||
total_deposited = sum(deposits_df.filter( | ||
pl.col('windowNumber').is_in(windows))['depositedAmount'].to_list()) | ||
total_withdrawn = sum(withdraws_df.filter( | ||
pl.col('window').is_in(windows))['amount'].to_list()) | ||
|
||
print(f'Total ETH deposited: {total_deposited / 10**18}') | ||
print(f'Total ETH withdrawn: {total_withdrawn / 10**18}') | ||
print(f'Total ETH locked: {(total_deposited - total_withdrawn) / 10**18}') | ||
|
||
# Run the main function | ||
asyncio.run(main()) |
File renamed without changes.