Skip to content

Commit

Permalink
Add extra data to trade events in db (#1720)
Browse files Browse the repository at this point in the history
  • Loading branch information
slundqui authored Oct 30, 2024
1 parent 3f3bf02 commit ba7aa56
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
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

0 comments on commit ba7aa56

Please sign in to comment.