From 8bf9f5d8ab59fac8e2725a1c3623d72da04cb9bd Mon Sep 17 00:00:00 2001 From: jalbrekt85 Date: Fri, 6 Dec 2024 15:54:08 -0600 Subject: [PATCH 1/2] move vote prep check to be first --- .../BD Vote Template - December 5 2024.csv | 2 +- .../aura_snapshot_voting/review_votes.py | 28 ++++++++++--------- tools/python/aura_snapshot_voting/vote.py | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/MaxiOps/vlaura_voting/2024/W51/input/BD Vote Template - December 5 2024.csv b/MaxiOps/vlaura_voting/2024/W51/input/BD Vote Template - December 5 2024.csv index 9589cf146..38f87460a 100644 --- a/MaxiOps/vlaura_voting/2024/W51/input/BD Vote Template - December 5 2024.csv +++ b/MaxiOps/vlaura_voting/2024/W51/input/BD Vote Template - December 5 2024.csv @@ -39,4 +39,4 @@ APY needed,6%,,, Incentives per 1m,60000,,, Incentives per wk,"$1,154",,, Incentives per 6 wks,"$4,615",,, -Total TVL to support,22,,, \ No newline at end of file +Total TVL to support,22,,, diff --git a/tools/python/aura_snapshot_voting/review_votes.py b/tools/python/aura_snapshot_voting/review_votes.py index 2b47ad70f..16237e682 100644 --- a/tools/python/aura_snapshot_voting/review_votes.py +++ b/tools/python/aura_snapshot_voting/review_votes.py @@ -47,6 +47,21 @@ def review_votes(week_string): csv_file = csv_files[0] vote_df = pd.read_csv(csv_file) + try: + test_df = vote_df.copy() + prop, _, _ = _get_prop_and_determine_date_range() + test_df, vote_choices = prepare_vote_data(test_df, prop) + data = create_vote_payload(vote_choices, prop) + hash = hash_eip712_message(data) + vote_prep = f"\n### Vote Preparation\nSuccessfully simulated vote preparation āœ…\nMessage hash: `0x{hash.hex()}`" + vote_check = True + except Exception as e: + vote_prep = ( + f"\n### Vote Preparation\nāŒ Error simulating vote preparation: {str(e)}" + ) + vote_check = False + + vote_df = vote_df.dropna(subset=["Gauge Address", "Label", "Allocation %"]) gauge_labels = fetch_gauge_labels() @@ -61,19 +76,6 @@ def review_votes(week_string): total_allocation = vote_df["Allocation %"].str.rstrip("%").astype(float).sum() allocation_check = abs(total_allocation - 100) < 0.0001 - try: - prop, _, _ = _get_prop_and_determine_date_range() - vote_df, vote_choices = prepare_vote_data(vote_df, prop) - data = create_vote_payload(vote_choices, prop) - hash = hash_eip712_message(data) - vote_prep = f"\n### Vote Preparation\nSuccessfully simulated vote preparation āœ…\nMessage hash: `0x{hash.hex()}`" - vote_check = True - except Exception as e: - vote_prep = ( - f"\n### Vote Preparation\nāŒ Error simulating vote preparation: {str(e)}" - ) - vote_check = False - report = f"""## vLAURA Votes Review CSV file: `{os.path.relpath(csv_file, project_root)}` diff --git a/tools/python/aura_snapshot_voting/vote.py b/tools/python/aura_snapshot_voting/vote.py index ba8367f1d..e92b03b2a 100644 --- a/tools/python/aura_snapshot_voting/vote.py +++ b/tools/python/aura_snapshot_voting/vote.py @@ -123,7 +123,7 @@ def prepare_vote_data(vote_df, prop): gauge_labels = {to_checksum_address(x["address"]): x["label"] for x in gauge_labels} choice_index_map = {c: x + 1 for x, c in enumerate(choices)} - vote_df = vote_df.dropna(subset=["Gauge Address"]) + vote_df = vote_df.dropna(subset=["Gauge Address", "Label", "Allocation %"]) vote_df["snapshot_label"] = vote_df["Gauge Address"].apply( lambda x: gauge_labels.get(to_checksum_address(x.strip())) From 0598edf80f9273f06f8a4f2303076a7a640b31db Mon Sep 17 00:00:00 2001 From: jalbrekt85 Date: Fri, 6 Dec 2024 21:56:56 +0000 Subject: [PATCH 2/2] style: ci lint with `black` --- tools/python/aura_snapshot_voting/review_votes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/python/aura_snapshot_voting/review_votes.py b/tools/python/aura_snapshot_voting/review_votes.py index 16237e682..4b38fe51a 100644 --- a/tools/python/aura_snapshot_voting/review_votes.py +++ b/tools/python/aura_snapshot_voting/review_votes.py @@ -61,7 +61,6 @@ def review_votes(week_string): ) vote_check = False - vote_df = vote_df.dropna(subset=["Gauge Address", "Label", "Allocation %"]) gauge_labels = fetch_gauge_labels()