Skip to content

Events

Qoq logs its events through the engine, in Borsh. They arrive in the engine’s dex_events_borsh event: decode it to a list of DexEventData, and the event of each one whose dex_id 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 of a deposit) of the call. A swap after an oracle request logs its events in the receipt that runs it, once the oracle responds.

Index Event Logged when
0 PoolUpdated A pool changed: created, swapped in, liquidity, or a setting of its owner
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
4 LiquidityFeePayoutSet A provider registered for a pool, created one, or chose another way to take its fees
5 LiquidityFeesCollected A provider collected fees it earned in a pool

In Rust, the type is AmpDexEvent in amp-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. Events from before rate sources 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: the providers’ part as Pool in asset_in, another Pool entry in asset_out for what was converted 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
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

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

Field Type
pool_id u32
account_id AccountId
payout_type 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.
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.