Events
This page is also Markdown, for agents: /plach/reference/events.md, and /llms.txt lists every page.
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 whose dex_id is deployer slimedragon.near and id xyk is a Plach event: a Borsh enum of the events below. DexEventData also has the referrer and user (the caller, or the alleged sender of a deposit) of the call.
| Index | Event | Logged when |
|---|---|---|
| 0 | PoolUpdated |
A pool changed: created, swapped in, liquidity, fees or locked |
| 1 | Swap |
A swap went through a pool |
| 2 | LiquidityAdded |
Liquidity was added, including the initial liquidity of a new public or private pool |
| 3 | LiquidityRemoved |
Liquidity was removed |
| 4 | LiquidityFeePayoutSet |
A provider chose how to take a pool’s fees |
| 5 | LiquidityFeesCollected |
A provider collected fees it earned in a pool |
In Rust, the type is XykDexEvent in xyk-dex-types.
PoolUpdated
Section titled “PoolUpdated”| 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. Events from before Plach’s current version have the older pool views.
One for each pool a route goes through, route by route, in the order the pools ran: from the first pool for an exact input, from the last for an exact output. A pool in two routes logs two.
| 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 the asset it was paid in, after converting it: the pool’s fees in order, and the protocol fee, Protocol, last. A Pool fee has an entry for the part in asset_in, and one for the part converted to asset_out if there is any. Swaps from before the current version list the protocol fee as Account(plach.intear.near), and those from before referral fees moved to the engine also list the referral fees, after the protocol fee, whose entry includes its 20% of them |
amount_out |
u128 |
LiquidityAdded
Section titled “LiquidityAdded”| 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. In private pools, the pool’s balances |
new_owned_shares |
u128 |
The provider’s shares after. 0 in private pools |
new_total_asset_0, new_total_asset_1 |
u128 |
The pool’s balances after |
new_total_shares |
u128 |
The pool’s shares after. 0 in private pools |
LiquidityRemoved
Section titled “LiquidityRemoved”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, every field after the removed amounts is 0, including the pool’s totals. Read the balances from the PoolUpdated event that follows.
LiquidityFeePayoutSet
Section titled “LiquidityFeePayoutSet”| Field | Type |
|---|---|
pool_id |
u32 |
account_id |
AccountId |
payout_type |
FeePayoutType |
Logged by set_liquidity_fee_payout, after the LiquidityFeesCollected of what the provider earned with its old payout.
LiquidityFeesCollected
Section titled “LiquidityFeesCollected”| Field | Type | Description |
|---|---|---|
pool_id |
u32 |
|
account_id |
AccountId |
The provider |
asset_0, asset_1 |
AssetId |
The pool’s assets |
amount_0, amount_1 |
u128 |
What the provider collected of each, now in its collected fees |
Logged when a provider adds or removes liquidity, changes its payout, or calls collect_liquidity_fees, if it earned anything since it last collected.
Older JSON events
Section titled “Older JSON events”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 request of the hop (the pool’s asset_in, asset_out and amount, with the swap’s message and referrer) instead of asset_in and asset_out.