"""
@generated by mypy-protobuf.  Do not edit manually!
isort:skip_file
"""
import builtins
import collections.abc
import cosmos.base.v1beta1.coin_pb2
import google.protobuf.descriptor
import google.protobuf.internal.containers
import google.protobuf.internal.enum_type_wrapper
import google.protobuf.message
import nibiru.perp.v2.state_pb2
import sys
import typing

if sys.version_info >= (3, 10):
    import typing as typing_extensions
else:
    import typing_extensions

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

@typing_extensions.final
class PositionChangedEvent(google.protobuf.message.Message):
    """Emitted when a position changes."""

    DESCRIPTOR: google.protobuf.descriptor.Descriptor

    FINAL_POSITION_FIELD_NUMBER: builtins.int
    POSITION_NOTIONAL_FIELD_NUMBER: builtins.int
    TRANSACTION_FEE_FIELD_NUMBER: builtins.int
    REALIZED_PNL_FIELD_NUMBER: builtins.int
    BAD_DEBT_FIELD_NUMBER: builtins.int
    FUNDING_PAYMENT_FIELD_NUMBER: builtins.int
    BLOCK_HEIGHT_FIELD_NUMBER: builtins.int
    MARGIN_TO_USER_FIELD_NUMBER: builtins.int
    CHANGE_REASON_FIELD_NUMBER: builtins.int
    EXCHANGED_SIZE_FIELD_NUMBER: builtins.int
    EXCHANGED_NOTIONAL_FIELD_NUMBER: builtins.int
    @property
    def final_position(self) -> nibiru.perp.v2.state_pb2.Position: ...
    position_notional: builtins.str
    """Position notional (in quote units) after the change. In general,
    'notional = baseAmount * priceQuotePerBase', where size is the baseAmount.
    """
    @property
    def transaction_fee(self) -> cosmos.base.v1beta1.coin_pb2.Coin:
        """Transaction fee paid. A "taker" fee."""
    realized_pnl: builtins.str
    """realize profits and losses after the change"""
    @property
    def bad_debt(self) -> cosmos.base.v1beta1.coin_pb2.Coin:
        """Amount of bad debt cleared by the PerpEF during the change.
        Bad debt is negative net margin past the liquidation point of a position.
        """
    funding_payment: builtins.str
    """A funding payment made or received by the trader on the current position.
    'fundingPayment' is positive if 'owner' is the sender and negative if 'owner'
    is the receiver of the payment. Its magnitude is abs(size * fundingRate).
    Funding payments act to converge the mark price and index price
    (average price on major exchanges).
    """
    block_height: builtins.int
    """The block number at which this position was changed."""
    margin_to_user: builtins.str
    """margin_to_user is the amount of collateral received by the trader during
    the position change. A positve value indicates that the trader received
    funds, while a negative value indicates that the trader spent funds.
    """
    change_reason: builtins.str
    """change_reason describes the reason for why the position resulted in a
    change. Change type can take the following values:

    - CHANGE_REASON_UNSPECIFIED: Unspecified change reason.
    - CHANGE_REASON_ADD_MARGIN: Margin was added to the position.
    - CHANGE_REASON_REMOVE_MARGIN: Margin was removed from the position.
    - CHANGE_REASON_OPEN_POSITION: A new position was opened.
    - CHANGE_REASON_CLOSE_POSITION: An existing position was closed.
    """
    exchanged_size: builtins.str
    """exchanged_size represent the change in size for an existing position
    after the change. A positive value indicates that the position size
    increased, while a negative value indicates that the position size
    decreased.
    """
    exchanged_notional: builtins.str
    """exchanged_notional represent the change in notional for an existing
    position after the change. A positive value indicates that the position
    notional increased, while a negative value indicates that the position
    notional decreased.
    """
    def __init__(
        self,
        *,
        final_position: nibiru.perp.v2.state_pb2.Position | None = ...,
        position_notional: builtins.str = ...,
        transaction_fee: cosmos.base.v1beta1.coin_pb2.Coin | None = ...,
        realized_pnl: builtins.str = ...,
        bad_debt: cosmos.base.v1beta1.coin_pb2.Coin | None = ...,
        funding_payment: builtins.str = ...,
        block_height: builtins.int = ...,
        margin_to_user: builtins.str = ...,
        change_reason: builtins.str = ...,
        exchanged_size: builtins.str = ...,
        exchanged_notional: builtins.str = ...,
    ) -> None: ...
    def HasField(self, field_name: typing_extensions.Literal["bad_debt", b"bad_debt", "final_position", b"final_position", "transaction_fee", b"transaction_fee"]) -> builtins.bool: ...
    def ClearField(self, field_name: typing_extensions.Literal["bad_debt", b"bad_debt", "block_height", b"block_height", "change_reason", b"change_reason", "exchanged_notional", b"exchanged_notional", "exchanged_size", b"exchanged_size", "final_position", b"final_position", "funding_payment", b"funding_payment", "margin_to_user", b"margin_to_user", "position_notional", b"position_notional", "realized_pnl", b"realized_pnl", "transaction_fee", b"transaction_fee"]) -> None: ...

global___PositionChangedEvent = PositionChangedEvent

@typing_extensions.final
class PositionLiquidatedEvent(google.protobuf.message.Message):
    """Emitted when a position is liquidated. Wraps a PositionChanged event since a
    liquidation causes position changes.
    """

    DESCRIPTOR: google.protobuf.descriptor.Descriptor

    POSITION_CHANGED_EVENT_FIELD_NUMBER: builtins.int
    LIQUIDATOR_ADDRESS_FIELD_NUMBER: builtins.int
    FEE_TO_LIQUIDATOR_FIELD_NUMBER: builtins.int
    FEE_TO_ECOSYSTEM_FUND_FIELD_NUMBER: builtins.int
    @property
    def position_changed_event(self) -> global___PositionChangedEvent: ...
    liquidator_address: builtins.str
    """Address of the account that executed the tx."""
    @property
    def fee_to_liquidator(self) -> cosmos.base.v1beta1.coin_pb2.Coin:
        """Commission (in margin units) received by 'liquidator'."""
    @property
    def fee_to_ecosystem_fund(self) -> cosmos.base.v1beta1.coin_pb2.Coin:
        """Commission (in margin units) given to the ecosystem fund."""
    def __init__(
        self,
        *,
        position_changed_event: global___PositionChangedEvent | None = ...,
        liquidator_address: builtins.str = ...,
        fee_to_liquidator: cosmos.base.v1beta1.coin_pb2.Coin | None = ...,
        fee_to_ecosystem_fund: cosmos.base.v1beta1.coin_pb2.Coin | None = ...,
    ) -> None: ...
    def HasField(self, field_name: typing_extensions.Literal["fee_to_ecosystem_fund", b"fee_to_ecosystem_fund", "fee_to_liquidator", b"fee_to_liquidator", "position_changed_event", b"position_changed_event"]) -> builtins.bool: ...
    def ClearField(self, field_name: typing_extensions.Literal["fee_to_ecosystem_fund", b"fee_to_ecosystem_fund", "fee_to_liquidator", b"fee_to_liquidator", "liquidator_address", b"liquidator_address", "position_changed_event", b"position_changed_event"]) -> None: ...

global___PositionLiquidatedEvent = PositionLiquidatedEvent

@typing_extensions.final
class PositionSettledEvent(google.protobuf.message.Message):
    """Emitted when a position is settled."""

    DESCRIPTOR: google.protobuf.descriptor.Descriptor

    PAIR_FIELD_NUMBER: builtins.int
    TRADER_ADDRESS_FIELD_NUMBER: builtins.int
    SETTLED_COINS_FIELD_NUMBER: builtins.int
    pair: builtins.str
    """Identifier for the virtual pool of the position."""
    trader_address: builtins.str
    """Owner of the position."""
    @property
    def settled_coins(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[cosmos.base.v1beta1.coin_pb2.Coin]:
        """Settled coin as dictated by the settlement price of the perp.amm."""
    def __init__(
        self,
        *,
        pair: builtins.str = ...,
        trader_address: builtins.str = ...,
        settled_coins: collections.abc.Iterable[cosmos.base.v1beta1.coin_pb2.Coin] | None = ...,
    ) -> None: ...
    def ClearField(self, field_name: typing_extensions.Literal["pair", b"pair", "settled_coins", b"settled_coins", "trader_address", b"trader_address"]) -> None: ...

global___PositionSettledEvent = PositionSettledEvent

@typing_extensions.final
class FundingRateChangedEvent(google.protobuf.message.Message):
    """Emitted when the funding rate changes for a market."""

    DESCRIPTOR: google.protobuf.descriptor.Descriptor

    PAIR_FIELD_NUMBER: builtins.int
    MARK_PRICE_TWAP_FIELD_NUMBER: builtins.int
    INDEX_PRICE_TWAP_FIELD_NUMBER: builtins.int
    PREMIUM_FRACTION_FIELD_NUMBER: builtins.int
    CUMULATIVE_PREMIUM_FRACTION_FIELD_NUMBER: builtins.int
    pair: builtins.str
    """The pair for which the funding rate was calculated."""
    mark_price_twap: builtins.str
    """The mark price of the pair."""
    index_price_twap: builtins.str
    """The oracle index price of the pair."""
    premium_fraction: builtins.str
    """The latest premium fraction just calculated."""
    cumulative_premium_fraction: builtins.str
    """The market's latest cumulative premium fraction.
    The funding payment a position will pay is the difference between this
    value and the latest cumulative premium fraction on the position,
    multiplied by the position size.
    """
    def __init__(
        self,
        *,
        pair: builtins.str = ...,
        mark_price_twap: builtins.str = ...,
        index_price_twap: builtins.str = ...,
        premium_fraction: builtins.str = ...,
        cumulative_premium_fraction: builtins.str = ...,
    ) -> None: ...
    def ClearField(self, field_name: typing_extensions.Literal["cumulative_premium_fraction", b"cumulative_premium_fraction", "index_price_twap", b"index_price_twap", "mark_price_twap", b"mark_price_twap", "pair", b"pair", "premium_fraction", b"premium_fraction"]) -> None: ...

global___FundingRateChangedEvent = FundingRateChangedEvent

@typing_extensions.final
class LiquidationFailedEvent(google.protobuf.message.Message):
    """Emitted when liquidation fails."""

    DESCRIPTOR: google.protobuf.descriptor.Descriptor

    class _LiquidationFailedReason:
        ValueType = typing.NewType("ValueType", builtins.int)
        V: typing_extensions.TypeAlias = ValueType

    class _LiquidationFailedReasonEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[LiquidationFailedEvent._LiquidationFailedReason.ValueType], builtins.type):  # noqa: F821
        DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
        UNSPECIFIED: LiquidationFailedEvent._LiquidationFailedReason.ValueType  # 0
        POSITION_HEALTHY: LiquidationFailedEvent._LiquidationFailedReason.ValueType  # 1
        """the position is healthy and does not need to be liquidated."""
        NONEXISTENT_PAIR: LiquidationFailedEvent._LiquidationFailedReason.ValueType  # 2
        """the pair does not exist."""
        NONEXISTENT_POSITION: LiquidationFailedEvent._LiquidationFailedReason.ValueType  # 3
        """the position does not exist."""

    class LiquidationFailedReason(_LiquidationFailedReason, metaclass=_LiquidationFailedReasonEnumTypeWrapper): ...
    UNSPECIFIED: LiquidationFailedEvent.LiquidationFailedReason.ValueType  # 0
    POSITION_HEALTHY: LiquidationFailedEvent.LiquidationFailedReason.ValueType  # 1
    """the position is healthy and does not need to be liquidated."""
    NONEXISTENT_PAIR: LiquidationFailedEvent.LiquidationFailedReason.ValueType  # 2
    """the pair does not exist."""
    NONEXISTENT_POSITION: LiquidationFailedEvent.LiquidationFailedReason.ValueType  # 3
    """the position does not exist."""

    PAIR_FIELD_NUMBER: builtins.int
    TRADER_FIELD_NUMBER: builtins.int
    LIQUIDATOR_FIELD_NUMBER: builtins.int
    REASON_FIELD_NUMBER: builtins.int
    pair: builtins.str
    """The pair for which we are trying to liquidate."""
    trader: builtins.str
    """owner of the position."""
    liquidator: builtins.str
    """Address of the account that executed the tx."""
    reason: global___LiquidationFailedEvent.LiquidationFailedReason.ValueType
    """Reason for the liquidation failure."""
    def __init__(
        self,
        *,
        pair: builtins.str = ...,
        trader: builtins.str = ...,
        liquidator: builtins.str = ...,
        reason: global___LiquidationFailedEvent.LiquidationFailedReason.ValueType = ...,
    ) -> None: ...
    def ClearField(self, field_name: typing_extensions.Literal["liquidator", b"liquidator", "pair", b"pair", "reason", b"reason", "trader", b"trader"]) -> None: ...

global___LiquidationFailedEvent = LiquidationFailedEvent

@typing_extensions.final
class AmmUpdatedEvent(google.protobuf.message.Message):
    """This event is emitted when the amm is updated, which can be triggered by
    the following events:

    - swap
    - edit price multiplier
    - edit depth
    """

    DESCRIPTOR: google.protobuf.descriptor.Descriptor

    FINAL_AMM_FIELD_NUMBER: builtins.int
    MARK_PRICE_TWAP_FIELD_NUMBER: builtins.int
    INDEX_PRICE_TWAP_FIELD_NUMBER: builtins.int
    @property
    def final_amm(self) -> nibiru.perp.v2.state_pb2.AMM:
        """the final state of the AMM"""
    mark_price_twap: builtins.str
    """The mark price of the pair."""
    index_price_twap: builtins.str
    """The oracle index price of the pair."""
    def __init__(
        self,
        *,
        final_amm: nibiru.perp.v2.state_pb2.AMM | None = ...,
        mark_price_twap: builtins.str = ...,
        index_price_twap: builtins.str = ...,
    ) -> None: ...
    def HasField(self, field_name: typing_extensions.Literal["final_amm", b"final_amm"]) -> builtins.bool: ...
    def ClearField(self, field_name: typing_extensions.Literal["final_amm", b"final_amm", "index_price_twap", b"index_price_twap", "mark_price_twap", b"mark_price_twap"]) -> None: ...

global___AmmUpdatedEvent = AmmUpdatedEvent

@typing_extensions.final
class MarketUpdatedEvent(google.protobuf.message.Message):
    """This event is emitted at the end of every block for persisting market changes
    off-chain

    Market changes are triggered by the following actions:

    - disabling market
    - changing market fees
    - bad debt is prepaid by the ecosystem fund
    """

    DESCRIPTOR: google.protobuf.descriptor.Descriptor

    FINAL_MARKET_FIELD_NUMBER: builtins.int
    @property
    def final_market(self) -> nibiru.perp.v2.state_pb2.Market:
        """the final state of the market"""
    def __init__(
        self,
        *,
        final_market: nibiru.perp.v2.state_pb2.Market | None = ...,
    ) -> None: ...
    def HasField(self, field_name: typing_extensions.Literal["final_market", b"final_market"]) -> builtins.bool: ...
    def ClearField(self, field_name: typing_extensions.Literal["final_market", b"final_market"]) -> None: ...

global___MarketUpdatedEvent = MarketUpdatedEvent
