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

# Events & Indexing

> Every launchpad event, with the semantics an indexer needs

## Factory

```solidity theme={null}
event LaunchCreated(
    address indexed launch,
    address indexed token,
    address indexed creator,
    LaunchType launchType,     // uint8, not indexed
    address quoteToken,
    string name,
    string symbol,
    string metadataURI
);

event ImplementationRegistered(LaunchType indexed launchType, address implementation);
event LaunchTypeRetiredChanged(LaunchType indexed launchType, bool retired);
event LaunchDefaultsUpdated(
    uint128 virtualQuote, uint16 tradeFeeBps, uint16 graduationFeeBps, uint16 creatorFeeBps,
    uint128 creationFee, uint128 graduationReward, uint8 graduationPoolType
);
event FeeRecipientUpdated(address indexed feeRecipient);
event CreationPausedChanged(bool paused);
```

`LaunchCreated` is your discovery stream — but it carries **no economics**. Fetch the launch's `config()` once per launch to price its curve. `metadataURI` is **write-once**: there is no setter and no update event, so index it from this log and never re-fetch. Pool creation at graduation logs on the **DEX factory**, not here.

## Launch (one stream per clone)

```solidity theme={null}
event Trade(
    address indexed trader,
    bool isBuy,
    uint256 quoteAmount,   // the change in the curve's reserve, in quote units
    uint256 tokenAmount,
    uint256 fee,
    uint256 reserve,       // post-trade
    uint256 sold           // post-trade
);

event CurveCompleted(uint256 reserve);

event Graduated(
    address indexed pool, uint256 tokenId, uint256 quoteSeeded, uint256 tokensSeeded, uint128 liquidity
);
```

Semantics that are easy to get wrong:

* **The launch is `log.address`.** There is no token or launch field — one contract, one token, one stream.
* **`trader` is asymmetric by design**: on a buy it is the **recipient** (who ends up holding); on a sell it is the **seller** (whose balance moved). The event follows whose balance in the launched token changed.
* **`quoteAmount` is the reserve delta**, whichever entry was used. A buyer paid `quoteAmount + fee` (minus any completion refund); a seller received `quoteAmount − fee`.
* **`sold` is not monotonic** — sells decrease it. It is curve state, not cumulative volume.
* `CurveCompleted` fires on the buy that fills the curve; between it and `Graduated`, trading reverts (the frozen window).

## LaunchToken

```solidity theme={null}
event Graduated();   // zero parameters, emitted once, never again
```

Same name as the launch's `Graduated`, **different topic0** (different parameter lists) — a holder's tooling can watch the token alone.

## Locker

```solidity theme={null}
event Locked(uint256 indexed tokenId, address indexed token, address indexed creator, uint16 creatorBps);
event FeesCollected(uint256 indexed tokenId, address indexed token,
    uint256 creatorAmount0, uint256 creatorAmount1, uint256 protocolAmount0, uint256 protocolAmount1);
event CreatorRecipientUpdated(uint256 indexed tokenId, address indexed recipient);
event ProtocolRecipientUpdated(uint256 indexed tokenId, address indexed recipient);
event FarmingApprovalSet(uint256 indexed tokenId, bool approved);
event EnteredFarming(uint256 indexed tokenId, address indexed virtualPool);
event ExitedFarming(uint256 indexed tokenId);
event RewardsCollected(uint256 indexed tokenId, address indexed token, uint256 creatorAmount, uint256 protocolAmount);
```

## Indexer rules of thumb

1. **Never infer state from balances.** A launch accepts stray native transfers and counts none of them (`receive()` is unguarded for a gas-budget reason); `reserve()` and `protocolFees()` are the truth.
2. **`sweepFees()` emits nothing** — track `protocolFees` deltas if you need it.
3. **One `eth_call` per launch** (`config()`) turns the log stream into a priceable curve; everything after that is pure math.
4. **Handle launch types**: the same `LaunchCreated` stream will carry future implementations. Treat a launch's ABI as a function of its `launchType`.
