Skip to content

Events

Plach logs its events through the engine, in Borsh. They arrive in the engine’s dex_events_borsh event, one per call: decode it to a list of DexEventData, and the event of each one with "dex_id": "slimedragon.near/xyk" is a Plach event: a Borsh enum of the events below. DexEventData also has the referrer and user (the caller, or the alleged trader) of the call.

Index Event Logged when
0 PoolUpdated A pool changed: created, swapped in, liquidity, fees, locked or upgraded
1 Swap A swap went through a pool
2 LiquidityAdded Liquidity was added, including the initial liquidity of a new pool
3 LiquidityRemoved Liquidity was removed

In Rust, the type is XykDexEvent in xyk-dex-types.

Field Type
pool_id u32
pool PoolView

The pool as it is after the change. A swap logs one for each pool it went through, after all of its Swap events.

One for each pool of a swap, in the order the pools ran: from the first pool for an exact input, from the last for an exact output.

Field Type Description
pool_id u32
asset_in AssetId What went into the pool
asset_out AssetId What came out
amount_in u128 Including the fees
fees_breakdown Vec<(FeeReceiver, AssetId, u128)> Each fee, its receiver and asset. The protocol fee and referral fee are Account receivers
amount_out u128
Field Type Description
pool_id u32
asset_0, asset_1 AssetId The pool’s assets
added_amount_0, added_amount_1 u128 What was added
minted_shares u128 0 in private pools
new_owned_asset_0, new_owned_asset_1 u128 What the provider’s shares are worth after
new_owned_shares u128 The provider’s shares after
new_total_asset_0, new_total_asset_1 u128 The pool’s balances after
new_total_shares u128 The pool’s shares after

The same fields as LiquidityAdded, with removed_amount_0, removed_amount_1 and burned_shares instead of the added amounts and minted shares. In private pools, the share fields are 0.

Before it logged Borsh, Plach logged JSON events, which the engine wrapped in its dex_event events. They’re only in old transactions. Their standard is "xyk", version 1.0.0, with the same four events in snake case (pool_updated, swap, liquidity_added, liquidity_removed). The JSON swap has the whole request of the swap instead of asset_in and asset_out.