events

package
v0.4.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

The "events" package implements functions to emit sdk.Events, which are Tendermint application blockchain interface (ABCI) events. These are returned by ABCI methods such as CheckTx, DeliverTx, and Query.

Events allow applications to associate metadata about ABCI method execution with the transactions and blocks this metadata relates to. Events returned via these ABCI methods do not impact Tendermint consensus in any way and instead exist to power subscriptions and queries of Tendermint state.

Index

Constants

View Source
const (
	// from: receiving address of a transfer
	AttributeFromAddr = "from"
	// to: sending address of a transfer
	AttributeToAddr        = "to"
	AttributeTokenAmount   = "amount"
	AttributeTokenDenom    = "denom"
	AttributePositionOwner = "owner"
	AttributeVpool         = "vpool"
)

x/perp attributes used in multiple events

Variables

This section is empty.

Functions

func EmitInternalPositionResponseEvent

func EmitInternalPositionResponseEvent(
	ctx sdk.Context, positionResp *types.PositionResp, function string)
EmitInternalPositionResponseEvent emits an sdk.Event to track the position

response ('PositionResp') outputs returned by: 'closePositionEntirely', 'closeAndOpenReversePosition', 'increasePosition', and 'decreasePosition'.

func EmitMarginChange

func EmitMarginChange(
	ctx sdk.Context,
	traderAddr sdk.AccAddress,
	vpool string,
	marginAmt sdk.Int,
	fundingPayment sdk.Dec,
)
EmitMarginChange emits an event when the protocol margin ratio changes.

Args:

  ctx sdk.Context: Carries information about the current state of the application.
  owner sdk.AccAddress: Owner of the position.
  vpool string: Identifier for the virtual pool of the position.
  marginAmt sdk.Int: Delta of the position margin. If positive, margin was added.
  fundingPayment sdk.Int: The position 'owner' may realize a funding payment if
    there is no bad debt upon margin removal based on the delta of the position
	margin and latest cumulative premium fraction.

func EmitMarginRatioChange

func EmitMarginRatioChange(
	ctx sdk.Context,
	marginRatio sdk.Dec,
)
EmitMarginRatioChange emits an event when the protocol margin ratio changes.

Args:

ctx sdk.Context: Carries information about the current state of the application.
vpool string: Identifier for the virtual pool of the position.

func EmitPositionChange

func EmitPositionChange(
	ctx sdk.Context,
	owner sdk.AccAddress,
	vpool string,
	margin sdk.Int,
	notional sdk.Dec,
	vsizeChange sdk.Dec,
	txFee sdk.Int,
	vsizeAfter sdk.Dec,
	realizedPnlAfter sdk.Dec,
	badDebt sdk.Dec,
	unrealizedPnlAfter sdk.Dec,
	liquidationPenalty sdk.Int,
	vPrice sdk.Dec,
	fundingPayment sdk.Dec,
)
EmitPositionChange emits an event when a position (vpool-trader) is changed.

Args:

  ctx sdk.Context: Carries information about the current state of the application.
  owner sdk.AccAddress: owner of the position.
  vpool string: identifier of the corresponding virtual pool for the position
  margin sdk.Int: amount of quote token (y) backing the position.
  notional sdk.Dec: margin * leverage * vPrice. 'notional' is the virtual size times
    the virtual price on 'vpool'.
  vsizeChange sdk.Dec: magnitude of the change to vsize. The vsize is the amount
  	of base assets for the position, margin * leverage * priceBasePerQuote.
  txFee sdk.Int: transaction fee paid
  vsizeAfter sdk.Dec: position virtual size after the change
  realizedPnlAfter: realize profits and losses after the change
  badDebt sdk.Int: Amount of bad debt cleared by the PerpEF during the change.
    Bad debt is negative net margin past the liquidation point of a position.
  unrealizedPnlAfter: unrealized profits and losses after the change
  liquidationPenalty: amt of margin (y) lost due to liquidation
  vPrice sdk.Dec: vPrice defined as yRes / xRes for a vpool, where yRes is the
    quote reserves and xRes is the base reserves.
  fundingPayment sdk.Dec: 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(vSize * fundingRate). Funding payments act to converge the mark price
	(vPrice) and index price (average price on major exchanges).

// TODO Q: Is there a way to split this into different events without creating too // much complexity?

func EmitPositionLiquidate

func EmitPositionLiquidate(
	ctx sdk.Context,
	vpool string,
	owner sdk.AccAddress,
	notional sdk.Dec,
	vsize sdk.Dec,
	liquidator sdk.AccAddress,
	feeToLiquidator sdk.Int,
	feeToPerpEF sdk.Int,
	badDebt sdk.Dec,
)
EmitPositionLiquidate emits an event when a liquidation occurs.

Args:

ctx sdk.Context: Carries information about the current state of the application.
vpool string: identifier of the corresponding virtual pool for the position
owner sdk.AccAddress: owner of the position.
notional sdk.Dec: margin * leverage * vPrice. 'notional' is the virtual size times
  the virtual price on 'vpool'.
vsize sdk.Dec: virtual amount of base assets for the position, which would be
  margin * leverage * priceBasePerQuote.
liquidator sdk.AccAddress: Address of the account that executed the tx.
feeToLiquidator sdk.Int: Commission (in margin units) received by 'liquidator'.
badDebt sdk.Int: Bad debt (margin units) cleared by the PerpEF during the tx.
  Bad debt is negative net margin past the liquidation point of a position.

func EmitPositionSettle

func EmitPositionSettle(
	ctx sdk.Context,
	vpool string,
	trader string,
	settled sdk.Coins,
)
EmitPositionSettle emits an event when a position is settled.

Args:

ctx sdk.Context: Carries information about the current state of the application.
vpool string: Identifier for the virtual pool of the position.
trader string: Owner of the position.
settled sdk.Coin: Settled coin as dictated by the settlement price of the vpool.

func EmitTransfer

func EmitTransfer(
	ctx sdk.Context, coin sdk.Coin, from sdk.AccAddress, to sdk.AccAddress,
)

func NewInternalPositionResponseEvent

func NewInternalPositionResponseEvent(
	positionResp *types.PositionResp, function string,
) sdk.Event
NewInternalPositionResponseEvent returns an sdk.Event to track the position

response ('PositionResp') outputs returned by: 'closePositionEntirely', 'closeAndOpenReversePosition', 'increasePosition', and 'decreasePosition'.

func NewMarginChangeEvent

func NewMarginChangeEvent(
	traderAddr sdk.AccAddress,
	vpool string,
	marginAmt sdk.Int,
	fundingPayment sdk.Dec,
) sdk.Event

func NewMarginRatioChangeEvent

func NewMarginRatioChangeEvent(
	marginRatio sdk.Dec,
) sdk.Event

func NewPositionChangeEvent

func NewPositionChangeEvent(
	owner sdk.AccAddress,
	vpool string,
	margin sdk.Int,
	notional sdk.Dec,
	vsizeChange sdk.Dec,
	txFee sdk.Int,
	vsizeAfter sdk.Dec,
	realizedPnlAfter sdk.Dec,
	badDebt sdk.Dec,
	unrealizedPnlAfter sdk.Dec,
	liquidationPenalty sdk.Int,
	vPrice sdk.Dec,
	fundingPayment sdk.Dec,
) sdk.Event

func NewPositionLiquidateEvent

func NewPositionLiquidateEvent(
	vpool string,
	owner sdk.AccAddress,
	notional sdk.Dec,
	vsize sdk.Dec,
	liquidator sdk.AccAddress,
	feeToLiquidator sdk.Int,
	feeToPerpEF sdk.Int,
	badDebt sdk.Dec,
) sdk.Event

func NewPositionSettleEvent

func NewPositionSettleEvent(
	vpool string,
	trader string,
	settled sdk.Coins,
) sdk.Event

func NewTransferEvent

func NewTransferEvent(
	coin sdk.Coin, from sdk.AccAddress, to sdk.AccAddress,
) sdk.Event

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL