agent0.chainsync.db.hyperdrive.schema ===================================== .. py:module:: agent0.chainsync.db.hyperdrive.schema .. autoapi-nested-parse:: Database Schemas for the Hyperdrive Contract. .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: agent0.chainsync.db.hyperdrive.schema.FIXED_NUMERIC Classes ------- .. autoapisummary:: agent0.chainsync.db.hyperdrive.schema.DBHyperdriveAddrToName agent0.chainsync.db.hyperdrive.schema.DBPoolConfig agent0.chainsync.db.hyperdrive.schema.DBCheckpointInfo agent0.chainsync.db.hyperdrive.schema.DBPoolInfo agent0.chainsync.db.hyperdrive.schema.DBTradeEvent agent0.chainsync.db.hyperdrive.schema.DBPositionSnapshot Module Contents --------------- .. py:data:: FIXED_NUMERIC .. py:class:: DBHyperdriveAddrToName Bases: :py:obj:`agent0.chainsync.db.base.DBBase` Maps a hyperdrive address to a logical name. .. !! processed by numpydoc !! .. py:attribute:: hyperdrive_address :type: sqlalchemy.orm.Mapped[str] The hyperdrive address .. !! processed by numpydoc !! .. py:attribute:: name :type: sqlalchemy.orm.Mapped[str] The logical name of the hyperdrive address. .. !! processed by numpydoc !! .. py:class:: DBPoolConfig Bases: :py:obj:`agent0.chainsync.db.base.DBBase` Table/dataclass schema for pool config. .. !! processed by numpydoc !! .. py:attribute:: hyperdrive_address :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: base_token :type: sqlalchemy.orm.Mapped[Union[str, None]] .. py:attribute:: vault_shares_token :type: sqlalchemy.orm.Mapped[Union[str, None]] .. py:attribute:: linker_factory :type: sqlalchemy.orm.Mapped[Union[str, None]] .. py:attribute:: initial_vault_share_price :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: minimum_share_reserves :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: minimum_transaction_amount :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: circuit_breaker_delta :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: position_duration :type: sqlalchemy.orm.Mapped[Union[int, None]] .. py:attribute:: checkpoint_duration :type: sqlalchemy.orm.Mapped[Union[int, None]] .. py:attribute:: time_stretch :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: governance :type: sqlalchemy.orm.Mapped[Union[str, None]] .. py:attribute:: fee_collector :type: sqlalchemy.orm.Mapped[Union[str, None]] .. py:attribute:: sweep_collector :type: sqlalchemy.orm.Mapped[Union[str, None]] .. py:attribute:: curve_fee :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: flat_fee :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: governance_lp_fee :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: governance_zombie_fee :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: inv_time_stretch :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:class:: DBCheckpointInfo Bases: :py:obj:`agent0.chainsync.db.base.DBBase` Table/dataclass schema for checkpoint information. .. !! processed by numpydoc !! .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier for the entry to the table. .. !! processed by numpydoc !! .. py:attribute:: hyperdrive_address :type: sqlalchemy.orm.Mapped[str] The hyperdrive address for the entry. .. !! processed by numpydoc !! .. py:attribute:: block_number :type: sqlalchemy.orm.Mapped[int] The block number on which the event was emitted. .. !! processed by numpydoc !! .. py:attribute:: checkpoint_time :type: sqlalchemy.orm.Mapped[int] The seconds epoch time index for this checkpoint. .. !! processed by numpydoc !! .. py:attribute:: checkpoint_vault_share_price :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The share price that was checkpointed in this checkpoint. .. !! processed by numpydoc !! .. py:attribute:: vault_share_price :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The vault share price at the time of checkpoint creation. .. !! processed by numpydoc !! .. py:attribute:: matured_shorts :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The amount of shorts that matured within this checkpoint. .. !! processed by numpydoc !! .. py:attribute:: matured_longs :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The amount of longs that matured within this checkpoint. .. !! processed by numpydoc !! .. py:attribute:: lp_share_price :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The lp share price at the checkpoint. .. !! processed by numpydoc !! .. py:class:: DBPoolInfo Bases: :py:obj:`agent0.chainsync.db.base.DBBase` Table/dataclass schema for pool info. Mapped class that is a data class on the python side, and an declarative base on the sql side. .. !! processed by numpydoc !! .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] .. py:attribute:: hyperdrive_address :type: sqlalchemy.orm.Mapped[str] .. py:attribute:: block_number :type: sqlalchemy.orm.Mapped[int] .. py:attribute:: timestamp :type: sqlalchemy.orm.Mapped[datetime.datetime] .. py:attribute:: epoch_timestamp :type: sqlalchemy.orm.Mapped[Union[int, None]] .. py:attribute:: share_reserves :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: share_adjustment :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: zombie_base_proceeds :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: zombie_share_reserves :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: bond_reserves :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: lp_total_supply :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: vault_share_price :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: longs_outstanding :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: long_average_maturity_time :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: shorts_outstanding :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: short_average_maturity_time :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: withdrawal_shares_ready_to_withdraw :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: withdrawal_shares_proceeds :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: lp_share_price :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: long_exposure :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: total_supply_withdrawal_shares :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: gov_fees_accrued :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: hyperdrive_base_balance :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: hyperdrive_eth_balance :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: variable_rate :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: vault_shares :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: spot_price :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:attribute:: fixed_rate :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] .. py:class:: DBTradeEvent Bases: :py:obj:`agent0.chainsync.db.base.DBBase` Table for storing any transfer events emitted by the Hyperdrive contract. .. !! processed by numpydoc !! .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier for the entry to the table. .. !! processed by numpydoc !! .. py:attribute:: hyperdrive_address :type: sqlalchemy.orm.Mapped[str] The hyperdrive address for the entry. .. !! processed by numpydoc !! .. py:attribute:: transaction_hash :type: sqlalchemy.orm.Mapped[str] The transaction hash for the entry. .. !! processed by numpydoc !! .. py:attribute:: block_number :type: sqlalchemy.orm.Mapped[int] The block number for the entry. .. !! processed by numpydoc !! .. py:attribute:: wallet_address :type: sqlalchemy.orm.Mapped[str] The wallet address for the entry. .. !! processed by numpydoc !! .. py:attribute:: event_type :type: sqlalchemy.orm.Mapped[Union[str, None]] The underlying event type for the entry. Can be one of the following: `Initialize`, `AddLiquidity`, `RemoveLiquidity`, `RedeemWithdrawalShares`, `OpenLong`, `OpenShort`, `CloseLong`, `CloseShort`, or `TransferSingle`. .. !! processed by numpydoc !! .. py:attribute:: token_type :type: sqlalchemy.orm.Mapped[Union[str, None]] The underlying token type for the entry. Can be one of the following: `LONG`, `SHORT, `LP`, or `WITHDRAWAL_SHARE`. .. !! processed by numpydoc !! .. py:attribute:: maturity_time :type: sqlalchemy.orm.Mapped[Union[int, None]] The maturity time of the token for LONG and SHORT tokens. .. !! processed by numpydoc !! .. py:attribute:: token_id :type: sqlalchemy.orm.Mapped[Union[str, None]] The id for the token itself, which consists of the `token_type`, appended with `maturity_time` for LONG and SHORT. For example, `LONG-1715126400`. .. !! processed by numpydoc !! .. py:attribute:: token_delta :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The change in tokens with respect to the wallet address. .. !! processed by numpydoc !! .. py:attribute:: base_delta :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The change in base tokens for the event with respect to the wallet address. .. !! processed by numpydoc !! .. py:attribute:: vault_share_delta :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The change in vault share tokens for the event with respect to the wallet address. .. !! processed by numpydoc !! .. py:attribute:: as_base :type: sqlalchemy.orm.Mapped[Union[bool, None]] A flag defining if the trade was made in units of base or vault shares. .. !! processed by numpydoc !! .. py:attribute:: vault_share_price :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The vault share price at the time of the emitted event. .. !! processed by numpydoc !! .. py:attribute:: extra_data :type: sqlalchemy.orm.Mapped[Union[bytes, None]] .. py:class:: DBPositionSnapshot Bases: :py:obj:`agent0.chainsync.db.base.DBBase` Table/dataclass schema for snapshots of positions This table takes snapshots of open positions and calculates the value and pnl of positions every snapshot. Mapped class that is a data class on the python side, and an declarative base on the sql side. .. !! processed by numpydoc !! .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier for the entry to the table. .. !! processed by numpydoc !! .. py:attribute:: hyperdrive_address :type: sqlalchemy.orm.Mapped[str] The hyperdrive address for the entry. .. !! processed by numpydoc !! .. py:attribute:: block_number :type: sqlalchemy.orm.Mapped[int] The block number for the entry. .. !! processed by numpydoc !! .. py:attribute:: wallet_address :type: sqlalchemy.orm.Mapped[Union[str, None]] The wallet address for the entry. .. !! processed by numpydoc !! .. py:attribute:: token_type :type: sqlalchemy.orm.Mapped[Union[str, None]] The underlying token type for the entry. Can be one of the following: `LONG`, `SHORT, `LP`, or `WITHDRAWAL_SHARE`. .. !! processed by numpydoc !! .. py:attribute:: maturity_time :type: sqlalchemy.orm.Mapped[Union[int, None]] The maturity time of the token for LONG and SHORT tokens. .. !! processed by numpydoc !! .. py:attribute:: token_id :type: sqlalchemy.orm.Mapped[Union[str, None]] The id for the token itself, which consists of the `token_type`, appended with `maturity_time` for LONG and SHORT. For example, `LONG-1715126400`. .. !! processed by numpydoc !! .. py:attribute:: token_balance :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The absolute balance of the position. .. !! processed by numpydoc !! .. py:attribute:: unrealized_value :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The unrealized value of the tokens in units of base, calculated if the position is closed at this block. .. !! processed by numpydoc !! .. py:attribute:: realized_value :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The total change in base for opening/closing this position. NOTE: this doesn't take into account any transfers of tokens outside of hyperdrive trades. .. !! processed by numpydoc !! .. py:attribute:: pnl :type: sqlalchemy.orm.Mapped[Union[decimal.Decimal, None]] The pnl of the position in units of base. `unrealized_value` + `realized_value` = `pnl`. .. !! processed by numpydoc !! .. py:attribute:: last_balance_update_block :type: sqlalchemy.orm.Mapped[Union[int, None]] The last block number that this position's balance was updated. .. !! processed by numpydoc !!