PositionChanged
event is the primary event for the protocol that symbolises a trade. Each time a trade occurs, the event is emitted for the counterparties that have a "change" in their underlying position.
for instance, if you place a market order, the event will be emitted for you with the position changed data. and if a limit order is filled, then the event will also be emitted for the limit order maker
The event contains the elements to determine the info on the trade, like whether its a market order, or a limit order fill. infact, one can also determine whether its a new position, update or a close.
Lets look at the raw event as in solidity.
enum TradeType {
TAKER,
TAKER_TRIGGER,
MAKER,
LIQUIDITY_REMOVAL,
LIQUIDATOR,
LIQUIDATEE,
ADL_TAKER,
ADL_MAKER
}
event PositionChanged(
address indexed amm,
address indexed trader,
uint256 margin,
int256 size,
uint256 openNotional,
uint256 exchangedQuote,
int256 exchangedBase,
int256 realizedPnL,
int256 fundingPayment,
uint256 markPrice,
TradeType tradeType
);
params
amm
amm addresstrader
trader addressmargin
updated marginsize
updated sizeopenNotional
updated notionalexchangedQuote
notional exchanged (volume)exchangedBase
size exchangedrealizedPnL
realized pnlfundingPayment
funding paidmarkPrice
updated mark pricetradeType
trade type (uint8)