Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra data to trade events in db #1720

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/agent0/chainsync/db/hyperdrive/convert_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def convert_trade_events(events: list[dict[str, Any]], wallet_addr: str | None)
"vault_share_delta": "vault_share_delta",
"asBase": "as_base",
"vaultSharePrice": "vault_share_price",
"extraData": "extra_data",
}

events_df = events_df[list(rename_dict.keys())].rename(columns=rename_dict)
Expand Down
3 changes: 2 additions & 1 deletion src/agent0/chainsync/db/hyperdrive/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from decimal import Decimal
from typing import Union

from sqlalchemy import BigInteger, Boolean, DateTime, Integer, Numeric, String
from sqlalchemy import BigInteger, Boolean, DateTime, Integer, LargeBinary, Numeric, String
from sqlalchemy.orm import Mapped, mapped_column

from agent0.chainsync.db.base import DBBase
Expand Down Expand Up @@ -204,6 +204,7 @@ class DBTradeEvent(DBBase):
"""
The vault share price at the time of the emitted event.
"""
extra_data: Mapped[Union[bytes, None]] = mapped_column(LargeBinary, default=None)


## Analysis schemas
Expand Down
10 changes: 6 additions & 4 deletions src/agent0/ethpy/hyperdrive/interface/read_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
MockERC4626Contract,
MockLidoContract,
)
from packaging.version import Version
from web3 import Web3
from web3.constants import ADDRESS_ZERO
from web3.types import BlockData, BlockIdentifier, Timestamp
Expand Down Expand Up @@ -168,10 +169,10 @@ def __init__(
)

# Check version here to ensure the contract is the correct version
hyperdrive_version = self.hyperdrive_contract.functions.version().call()
if not check_hyperdrive_version(hyperdrive_version):
self.hyperdrive_version = self.hyperdrive_contract.functions.version().call()
if not check_hyperdrive_version(self.hyperdrive_version):
raise ValueError(
f"Hyperdrive address {self.hyperdrive_address} is version {hyperdrive_version}, "
f"Hyperdrive address {self.hyperdrive_address} is version {self.hyperdrive_version}, "
f"does not meet minimum versions {get_minimum_hyperdrive_version()}"
)

Expand Down Expand Up @@ -262,7 +263,8 @@ def __init__(
# TODO There's a known issue fixed in Hyperdrive v1.0.17 that causes issues with
# extra data passed to morpho. Remove this when minimum hyperdrive version supported
# >= 1.0.17
self.txn_signature = bytes(0)
if Version(self.hyperdrive_version) < Version("1.0.17"):
self.txn_signature = bytes(0)

else:
# TODO Although the underlying function might not be a MockERC4626Contract,
Expand Down
Loading