Skip to main content

Observers

An observer is notified once a swap has settled and the fees are distributed. It can record, count and trigger other contracts. It cannot change the trade, take any of its funds, or prevent it.

A coin can run up to four.

Told, not consulted

A fee calculator is asked something before the trade executes, so its answer changes what the trader pays. An observer is notified afterwards. By then the trade is done and paid for, and nothing the observer does reaches back into it.

That is what makes the family open-ended: a block here can be as ambitious as its author likes without becoming a risk for anyone trading the coin.

What they are told

The fee that swap paid, rather than the size of the trade. Fees paid is the fairer measure on a market whose fee moves, and it prices out trading against yourself to farm a reward: wash trading pays the full fee for exactly what it buys.

An observer can also be notified when the pool's fee level changes, which suits a block tracking a coin's regime rather than each individual trade.

Failure and gas

  • An observer that fails is ignored. Its error is swallowed and the swap completes.
  • Observers share one gas budget per swap. A greedy block leaves less for the ones after it, and the creator sets the order.
  • A trader cannot skip one. A transaction too small to notify the observers is also too small to settle the swap, so it fails instead.

Bindings are permanent, like every other part of a coin's configuration.

What they are for

Observers are the layer where counters live. A block can accumulate facts about a market as it runs, such as its age or how many distinct wallets have traded it, and a fee calculator can read those counters later. Combining extensions shows what that produces.

They are also where anything paid out per trade belongs: a reward computed from the fee a swap paid settles after the swap, not during it.

The catalog's observer slots are open to anything a developer writes against the interface. See Developers.

The family

BlockWhat it does
Lotterymints tickets in proportion to the fees each swap paid, and funds a pot from the creator's share — soon