> ## 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.

# Architecture & Discovery

> The factory, the launch clones, and how integrators find them

## One launch, one contract

The launchpad is two contract shapes:

* **`LunyaLaunchFactory`** — the singleton you configure once. It creates launches, keeps the registry, and holds the DEX permission used at graduation.
* **`LunyaLaunch`** — one **clone per launch** (EIP-1167 with immutable args). Each launch holds its own unsold supply and its own raise, and exposes the trading surface. The launched ERC-20 (`LaunchToken`) is deployed by its launch.

<Note>
  Launch addresses are **deterministic and known before creation**. Clones deploy via `CREATE2` with a salt namespaced per creator — `keccak256(abi.encode(creator, salt))` — so a salt only has to be unique among one creator's launches, nobody can take an address someone else was going to use, and mining the salt is how a creator picks a vanity address.
</Note>

## Predicting an address

```solidity theme={null}
function predictLaunch(LaunchType launchType, address quoteToken, address creator, bytes32 salt)
    external view returns (address launch, address token);

function termsHash() external view returns (bytes32);
```

`predictLaunch` returns **both** addresses: a fresh clone's first `CREATE` is at nonce 1, so fixing the launch fixes the token. One caveat, by design: the clone's immutable args include the factory's current terms (fees, virtual reserves, graduation settings), so **the predicted address is only valid while those terms are unchanged**. Read `termsHash()` beside the prediction and pass it back as `expectedTermsHash` at creation — the create then fails cleanly instead of deploying to a different address than the one you published.

## Discovery

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

Reads on the factory:

| Getter                                                 | Returns                                                      |
| ------------------------------------------------------ | ------------------------------------------------------------ |
| `launchOf(address token)`                              | the launch for a token — write-once, `address(0)` if unknown |
| `isLaunch(address)`                                    | whether an address is a launch created here                  |
| `launchCount()` / `launchAt(uint256 i)`                | enumeration                                                  |
| `implementationOf(LaunchType)` / `retired(LaunchType)` | the registry (see versioning below)                          |
| `locker()`                                             | the liquidity locker (deployed by the factory)               |
| `nativeQuoteToken()`, `wrapsNative()`                  | the chain shape, read once                                   |

## A launch's state and config

Mutable state on each launch: `reserve()` (quote raised, in quote units), `sold()` (tokens sold — **not monotonic**: sells decrease it), `phase()`, `pool()` (after graduation), `protocolFees()`.

```solidity theme={null}
enum Phase { None, Trading, ReadyToGraduate, Graduated }
```

The immutable half lives in the clone's code, read via **`config()`** — a struct with the quote token, creator, curve parameters (`virtualQuote`, `virtualToken`, `curveSupply`, `lpSupply`), fees (`tradeFeeBps`, `graduationFeeBps`, `creatorFeeBps`), `graduationReward`, `graduationPoolType`, and the native-handling fields (`nativeDivisor`, `wrapsNative`).

<Warning>
  `LaunchCreated` carries **no economics** — no virtual reserves, no fees, no graduation reward. A log-only indexer must add one `config()` call per launch to price its curve. Parameters are **snapshotted per launch at creation**: later changes to the factory defaults never touch an existing launch.
</Warning>

Supply is fixed per launch: total 1,000,000,000 tokens (18 decimals) — 793,100,000 sold on the curve, 206,900,000 reserved for graduation liquidity.

## Units

**Every amount is in the quote token's own decimals** — reserve, fees, quotes, event fields. On a 6-decimal quote, `2e18` is not "two units". The only exception is [`sellForNative`](/developers/launchpad/trading#native-entries), whose minimum-out is denominated in the native coin.

## Launch types and versioning

`LaunchType` is a `uint8` naming an implementation in an **append-only** registry: a corrected implementation is the next type number, and old types can be `retired` (existing launches keep trading; only creation is blocked). Over time, launches of different types coexist under one factory, all emitting the same `LaunchCreated` — **treat a launch's ABI as a function of its `launchType`**, and read it from the creation log.
