# Events

> Events of Qoq: swaps with their price, pool updates, liquidity changes and liquidity fees, logged in Borsh inside the dex_events_borsh event of Intear DEX.

This page is part of the Qoq docs. Qoq is the DEX `slimedragon.near/amp` on the Intear DEX contract, `dex.intear.near`, and every call goes to that contract. https://docs.intear.tech/qoq/llms-full.txt has all of its pages in one file, and https://docs.intear.tech/llms.txt lists every page of the Intear docs.

Qoq logs its events through the engine, in Borsh. They arrive in the engine's [`dex_events_borsh`](https://docs.intear.tech/intear-dex/reference/events.md#dex_events_borsh) event: decode it to a list of `DexEventData`, and the `event` of each one whose [`dex_id`](https://docs.intear.tech/intear-dex/reference/types.md#borsh) is deployer `slimedragon.near` and id `amp` is a Qoq event: a Borsh enum of the events below. `DexEventData` also has the `referrer` and `user` (the caller, or the [alleged sender](https://docs.intear.tech/intear-dex/guides/dexes.md#what-a-dex-sees) of a deposit) of the call. A swap after an [oracle request](https://docs.intear.tech/qoq/guides/swaps.md#pools-an-oracle-prices) logs its events in the receipt that runs it, once the oracle responds.

| Index | Event | Logged when |
| --- | --- | --- |
| 0 | [`PoolUpdated`](#poolupdated) | A pool changed: created, swapped in, liquidity, or a setting of its owner |
| 1 | [`Swap`](#swap) | A swap went through a pool |
| 2 | [`LiquidityAdded`](#liquidityadded) | Liquidity was added, including the initial liquidity of a new pool |
| 3 | [`LiquidityRemoved`](#liquidityremoved) | Liquidity was removed |
| 4 | [`LiquidityFeePayoutSet`](#liquidityfeepayoutset) | A provider registered for a pool, created one, or chose another way to take its fees |
| 5 | [`LiquidityFeesCollected`](#liquidityfeescollected) | A provider collected fees it earned in a pool |

In Rust, the type is `AmpDexEvent` in [`amp-dex-types`](https://github.com/INTEARnear/dex/tree/main/dexes/amp/types).

## `PoolUpdated`

| Field | Type |
| --- | --- |
| `pool_id` | `u32` |
| `pool` | [`PoolView`](https://docs.intear.tech/qoq/reference/types.md#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 rate sources have the [older pool views](https://docs.intear.tech/qoq/reference/types.md#older-pool-views).

## `Swap`

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](https://docs.intear.tech/qoq/reference/types.md#feereceiver) and the asset it was paid in: the providers' part as `Pool` in `asset_in`, another `Pool` entry in `asset_out` for what was [converted](https://docs.intear.tech/qoq/guides/liquidity.md#fees) if anything was, and the protocol fee, `Protocol`, in `asset_in`, last |
| `amount_out` | `u128` | |
| `price` | `Price` | The price of a whole token of the pool's first asset in its second that the swap was at: the median of the oracle's prices, or the fixed price |

## `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` | |
| `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 |

## `LiquidityRemoved`

The same fields as `LiquidityAdded`, with `removed_amount_0`, `removed_amount_1` and `burned_shares` instead of the added amounts and minted shares.

## `LiquidityFeePayoutSet`

| Field | Type |
| --- | --- |
| `pool_id` | `u32` |
| `account_id` | `AccountId` |
| `payout_type` | [`FeePayoutType`](https://docs.intear.tech/qoq/reference/types.md#feepayouttype) |

Logged when a provider's payout is set:

- by `register_liquidity`, the first time, with `KeepBoth`,
- by `create_pool`, with the owner's `creator_fee_payout_type`, before its `PoolUpdated` and `LiquidityAdded`,
- by `set_liquidity_fee_payout`, after the `LiquidityFeesCollected` of what the provider earned with its old payout.

## `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.
