> For the complete documentation index, see [llms.txt](https://degen-games-2.gitbook.io/degen-games-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://degen-games-2.gitbook.io/degen-games-docs/developers/events-and-errors.md).

# Events & Errors

What to index, and what each revert means.

## Indexing

Index the **launch factory** to find every coin, then each coin's **curve** for its trade history. Together they rebuild the full state of the arcade without any Degen Games service.

```js
import { parseAbiItem } from "viem";

const launches = await client.getLogs({
  address: "0xa8788400ECe2342F17Faf659E2793a06bc4ad140",
  event: parseAbiItem(
    "event TokenLaunched(address indexed token, address indexed curve, address indexed deployer, address pairToken, uint256 launchConfigId, uint256 graduationThreshold)",
  ),
  fromBlock: 68_378_200n,
  toBlock: "latest",
});

const trades = await client.getLogs({
  address: curve,
  events: [
    parseAbiItem("event CurveBuy(address indexed buyer, address indexed recipient, uint256 quoteIn, uint256 tokensOut, uint256 fee, uint256 tax)"),
    parseAbiItem("event CurveSell(address indexed seller, address indexed recipient, uint256 tokensIn, uint256 quoteOut, uint256 fee, uint256 tax)"),
  ],
  fromBlock: launchBlock,
  toBlock: "latest",
});
```

In `CurveBuy` and `CurveSell`, `fee` is the trading fee and `tax` is the creator tax. On a buy inside the snipe window, the snipe tax is included in `fee`, and a separate `SnipeTaxCharged` event is emitted.

{% hint style="info" %}
Public RPCs time out on wide `eth_getLogs` ranges. Backfill in bounded block chunks.
{% endhint %}

## Events

### Launch factory

| Event                                              | Meaning                                                   |
| -------------------------------------------------- | --------------------------------------------------------- |
| `TokenLaunched`                                    | A new coin, its curve, deployer and raise asset           |
| `LaunchSwept`                                      | The curve closed. The coin entered the Swept phase.       |
| `PoolGraduated`                                    | The pool was created and seeded. Includes `positionId`.   |
| `GraduationTokensBurned`                           | Leftover reserved tokens burned at graduation             |
| `LaunchGraduationRescued`                          | The 7-day safety path returned a stuck graduation's funds |
| `CreatorFeeRecipientUpdated`                       | A coin's fee recipient changed                            |
| `CreatorFeeRecipientChangeProposed` / `…Cancelled` | A protocol takeover was proposed or cancelled             |
| `BuybackEnabledUpdated`                            | Creator buybacks switched on or off                       |

### Bonding curve (one per coin)

| Event                   | Meaning                                                        |
| ----------------------- | -------------------------------------------------------------- |
| `CurveBuy`, `CurveSell` | Trades                                                         |
| `CurveBuyRefunded`      | A clamped final buy returned unspent quote                     |
| `SnipeTaxCharged`       | A buy paid snipe tax                                           |
| `CurveCompleted`        | The curve closed and handed over its balances                  |
| `AutoGraduationFailed`  | Automatic graduation ran out of gas. Treat it as a work queue. |
| `FeesSwept`             | Fees split into protocol, buyback and creator amounts          |
| `BuybackLocked`         | Quote spent on a buyback, and the tokens locked in the vault   |

### Fee escrow

| Event                           | Meaning                                                                                  |
| ------------------------------- | ---------------------------------------------------------------------------------------- |
| `Credited`, `Claimed`           | Native payouts credited and withdrawn                                                    |
| `CreditedToken`, `ClaimedToken` | ERC-20 payouts credited and withdrawn, including every non-ETH payout and released vests |

### Holder rewards

| Event                | Contract        | Meaning                                                          |
| -------------------- | --------------- | ---------------------------------------------------------------- |
| `DistributorCreated` | Rewards factory | A coin got a rewards vault                                       |
| `EpochOpened`        | Distributor     | A new epoch with its root, allocation, snapshot block and expiry |
| `Claimed`            | Distributor     | A holder claimed an epoch                                        |
| `RolledOver`         | Distributor     | An expired epoch's leftovers went back into the pot              |
| `EpochCancelled`     | Distributor     | An epoch was cancelled and its allocation returned               |

## Errors

The contracts use custom errors. These are the ones an app is most likely to show a user.

| Error                                    | Contract            | Meaning                                                               |
| ---------------------------------------- | ------------------- | --------------------------------------------------------------------- |
| `SlippageExceeded`                       | Curve               | The trade couldn't meet the minimum output at the available price     |
| `CurveGraduated`                         | Curve               | The curve is closed. Route to the pool.                               |
| `NativeValueMismatch`                    | Curve / router      | On a native coin, the value sent didn't equal `quoteIn`               |
| `UnexpectedNativeValue`                  | Curve               | Value was sent to an ERC-20-raised coin                               |
| `InternalSwapRequiresOperator`           | Curve               | A sweep needs an internal swap, which only the sweep operator can run |
| `LaunchEconomicsMismatch`                | Factory             | The pinned terms changed. Re-read `previewLaunchEconomics` and retry. |
| `LaunchConfigDisabled`                   | Factory             | That launch config is closed                                          |
| `PairTokenNotApproved`                   | Factory             | The raise asset isn't approved                                        |
| `PairTokenDecimalsMismatch`              | Factory             | The raise asset reports different decimals than recorded              |
| `LaunchFeeNotPaid`                       | Factory             | The value sent didn't match `launchFee()`                             |
| `CreatorTaxTooHigh`                      | Factory             | The creator tax is above `maxCreatorTaxBps()`                         |
| `ExemptionListTooLong`                   | Factory             | Too many snipe-tax exemptions                                         |
| `NotWhitelisted`                         | Factory             | Launching is currently restricted to approved addresses               |
| `NotCreatorFeeRecipient`                 | Factory             | Only the current fee recipient can do that                            |
| `TimelockNotElapsed` / `TimelockExpired` | Factory             | A proposed takeover was executed too early or too late                |
| `WrongGraduationPhase`                   | Factory             | The coin isn't in the phase this call needs                           |
| `GraduationRescueTooEarly`               | Factory             | The 7-day rescue delay hasn't passed                                  |
| `NotApprovedLauncher`                    | Launch & buy router | The caller isn't allowed to launch right now                          |
| `EpochNotClaimable` / `EpochExpired`     | Distributor         | The claim window hasn't opened, or has closed                         |
| `InvalidProof` / `AlreadyClaimed`        | Distributor         | Bad Merkle proof, or already claimed                                  |
| `NoBalance`                              | Fee escrow          | Nothing to claim                                                      |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://degen-games-2.gitbook.io/degen-games-docs/developers/events-and-errors.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
