This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Batch Rewards] Schema & ETL Process for Sync (#28)
This defined the "schema" for what will be uploaded to Dune. We reused/generalize some common code for the order rewards sync. More or less, this was a minor change. Still remaining todo for parsing the bytea[] type with participants field (since duneV2 uses lower case hex strings). We will want to replace all \x coming from postgres with 0x.
- Loading branch information
Showing
7 changed files
with
146 additions
and
24 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
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
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,38 @@ | ||
"""Model for Batch Rewards Data""" | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from typing import Any | ||
|
||
from pandas import DataFrame | ||
|
||
|
||
@dataclass | ||
class BatchRewards: | ||
""" | ||
This class provides a transformation interface for the Dataframe we fetch from the orderbook | ||
""" | ||
|
||
@classmethod | ||
def from_pdf_to_dune_records(cls, rewards_df: DataFrame) -> list[dict[str, Any]]: | ||
"""Converts Pandas DataFrame into the expected stream type for Dune""" | ||
return [ | ||
{ | ||
"block_number": int(row["block_number"]), | ||
"tx_hash": row["tx_hash"], | ||
"solver": row["solver"], | ||
"data": { | ||
# All the following values are in WEI. | ||
"reward_eth": str(row["reward_eth"]), | ||
"execution_cost": str(row["execution_cost"]), | ||
"surplus": str(row["surplus"]), | ||
"fee": str(row["fee"]), | ||
"winning_score": str(row["winning_score"]), | ||
"reference_score": str(row["reference_score"]), | ||
# TODO - Not sure yet how to parse this bytea[] | ||
# Will need to experiment with this. | ||
"participating_solvers": row["participating_solvers"], | ||
}, | ||
} | ||
for row in rewards_df.to_dict(orient="records") | ||
] |
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
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
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
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