> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fade.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Events

> What the program emits, and how to decode it from a transaction.

Fade emits Anchor events through a self-CPI (`emit_cpi!`), not through program logs. Each event is an **inner instruction** to the Fade program whose data is:

```
[ 0xe4, 0x45, 0xa5, 0x2e, 0x51, 0xcb, 0x9a, 0x1d ]   Anchor's event tag, sha256("anchor:event")[..8]
[ 8-byte event discriminator ]
[ Borsh-encoded fields ]
```

Logs can be truncated; inner instructions cannot. Every event carries a `version` field (currently 1) as its first field.

## Decoding

The generated client exports, for each event, a `*_EVENT_DISCRIMINATOR` and a decoder (for example `WAGER_SETTLED_EVENT_DISCRIMINATOR` and `getWagerSettledEventDecoder()`).

```ts theme={null}
import { getBase58Encoder, type Signature } from "@solana/kit";
import { WAGER_SETTLED_EVENT_DISCRIMINATOR, getWagerSettledEventDecoder } from "./generated/fade";
import { PROGRAM, rpc } from "./fade";

const TAG = new Uint8Array([0xe4, 0x45, 0xa5, 0x2e, 0x51, 0xcb, 0x9a, 0x1d]);
const startsWith = (b: Uint8Array, p: ArrayLike<number>) =>
  b.length >= p.length && Array.from(p).every((x, i) => b[i] === x);

export async function settledEvents(signature: Signature) {
  const tx = await rpc
    .getTransaction(signature, { encoding: "json", maxSupportedTransactionVersion: 0, commitment: "confirmed" })
    .send();
  if (!tx?.meta) return [];
  const keys = [
    ...tx.transaction.message.accountKeys,
    ...(tx.meta.loadedAddresses?.writable ?? []),
    ...(tx.meta.loadedAddresses?.readonly ?? []),
  ];
  const out = [];
  for (const group of tx.meta.innerInstructions ?? []) {
    for (const ix of group.instructions) {
      if (keys[ix.programIdIndex] !== PROGRAM) continue;
      const data = new Uint8Array(getBase58Encoder().encode(ix.data));
      if (!startsWith(data, TAG)) continue;
      const body = data.subarray(8);
      if (startsWith(body, WAGER_SETTLED_EVENT_DISCRIMINATOR)) out.push(getWagerSettledEventDecoder().decode(body));
    }
  }
  return out;
}
```

To follow a wager after it closed (its account is gone), list its signatures with `getSignaturesForAddress(wager)` and decode `WagerSettled` or `WagerExpired` from them.

## Wager events

| Event | Emitted by | Fields |
| - | - | - |
| `IntegratorCreated` | the first `open_wager` of an app | `integrator`, `authority`, `fee_account` |
| `WagerOpened` | `open_wager` | `wager`, `integrator`, `nonce`, `beneficiary`, `stake`, `pool_credit`, `payout_max`, `reserved_liability`, `cap`, `paytable_edge_bps`, `integrator_fee_bps`, `open_slot` |
| `RandomnessRequested` | `request_randomness` | `wager`, `request` (ORAO account), `seed`, `entropy_slot` (`s*`) |
| `WagerSettled` | `settle_wager` | `wager`, `integrator`, `bucket` (index of the row drawn), `payout`, `pending` (true when parked in escrow) |
| `WagerExpired` | `expire_wager` | `wager`, `integrator`, `forfeited` (the pool credit kept) |
| `PayoutClaimed` | `claim_payout` | `wager`, `beneficiary`, `payout` |
| `FeeAccountChanged` | `set_fee_account` | `integrator`, `fee_account` |

The paytable itself is not in `WagerOpened`: it is in the `open_wager` instruction data (decode it with `getOpenWagerInstructionDataDecoder()`) and in the wager account while it is open.

## Liquidity events

| Event | Emitted by | Fields |
| - | - | - |
| `DepositRequested` | `request_deposit` | `owner`, `epoch_id`, `amount` |
| `WithdrawRequested` | `request_withdraw` | `owner`, `epoch_id`, `shares` |
| `EpochStruck` | `strike_epoch` | `epoch_id`, `total_assets`, `total_shares` (the price), `deposits`, `shares_minted`, `withdraw_shares`, `assets_owed`, `assets_paid`, `shares_burnt`, `reward` |
| `DepositClaimed` | `claim_deposit` | `owner`, `epoch_id`, `shares`, `delivered` |
| `WithdrawClaimed` | `claim_withdraw` | `owner`, `epoch_id`, `at_epoch_id`, `assets`, `closed`, `delivered` |
| `ClaimDelivered` | a claim delivering what an earlier claim parked | `owner`, `epoch_id`, `deposit`, `amount` |

`EpochStruck` is the pool's price history: each one fixes the price of an epoch from `total_assets` and `total_shares`.

## Governance events

| Event | Emitted by | Fields |
| - | - | - |
| `Initialized` | `initialize` | `council`, `guardian`, `protocol_treasury` |
| `ParamsChanged` | `set_params` | `applied` (at once, or queued), `effective_at` |
| `ParamsApplied` | `apply_params` | `effective_at` |
| `ParamsCancelled` | `cancel_params` | `effective_at` |
| `PauseFlagsChanged` | `set_pause_flags` | `by`, `pause_flags`, `integrator`, `integrator_paused` |

All amounts are in base units: USDC has 6 decimals, shares 9.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.