# Integrate

Every comfy-launched token and its trades, from this site's contracts.

## Facts

| | |
| --- | --- |
| Chain | 0G mainnet · `16661` |
| Pair | token / native 0G |
| Token | ERC-20 · no mint · no transfer tax |
| Liquidity | locked · no removal |

## Contracts

| Role | Address | Contract | From block |
| --- | --- | --- | --- |
| launcher | `0x2F74d603f7B7D8B7BFc78ef04E09905B862bE86a` | `AgentLauncher` | 45552863 |
| hook | `0x809ACD73Ac30b4E2D2dFd7d35b1FDA850DCd4334` | `ComfyLaunchHook` | 45552823 |
| pool manager | `0xAabD31f24914B48dAEA998e69683225E289d08b0` | `CLPoolManager` | 45552804 |
| splitter | `0x500AcfBb2199D35ab1Aa87736665D76c56bf633e` | `FeeSplitter` | 45552817 |
| locker | `0x4CD6492b23933FA14Ee12eB4d0a46F5626F3Cbcb` | `ComfyLocker` | 45552863 |

## Launches

```solidity
// topic0 0x20c8f644fcaa2f5b4960a99c98327b3d5bd9838194dae4a67dd914ec9c8249fe
event Launched(bytes32 indexed poolId, address indexed token, address indexed creator, int24 openingTick, uint256 ladderSupply, uint256 launchFee)
```

The pool manager holds other pools, so keep only pool ids from `Launched`.

## Trades

```solidity
// topic0 0x04206ad2b7c0f463bff3dd4f33c5735b0f2957a351e4f79763a4fa9e775dd237
event Swap(bytes32 indexed id, address indexed sender, int128 amount0, int128 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick, uint24 fee, uint16 protocolFee)
// topic0 0x787cb3fc0a69467064364b0ecaef40dee4a3f7e29279d74b70e8ded6e4758a1f
event ChargeTaken(bytes32 indexed poolId, address indexed router, bool isBuy, uint256 quoteAmount, uint256 baseFee, uint256 openingFee, uint256 creatorTax, address currency)
```

```text
charge = ChargeTaken.baseFee
  + ChargeTaken.openingFee
  + ChargeTaken.creatorTax
trader 0G = Swap.amount0 - charge
```

* `Swap.amount0` is 0G. Below zero, the trader paid.
* Pair each `ChargeTaken` with the adjacent `Swap` in its pool where `Swap.sender` is `ChargeTaken.router`. `ChargeTaken.quoteAmount` is `|Swap.amount0|`, plus `charge` when `ChargeTaken` comes first.
* No `ChargeTaken` means no charge.
* `Swap.fee` and `Swap.protocolFee` are not the comfy charge.

## Fees per pool

Fees are set at launch. The creator can change the compute share. A change applies after the pool's next sweep. See [Fees](../trading/fees.md).

```bash
cast call 0x809ACD73Ac30b4E2D2dFd7d35b1FDA850DCd4334 'launchSnapshot(bytes32)((bool,bool,bool,address,uint64,uint64,uint16,uint16,uint32,uint16,uint16,uint32))' <poolId> --rpc-url https://evmrpc.0g.ai
cast call 0x500AcfBb2199D35ab1Aa87736665D76c56bf633e 'splitOf(bytes32)((bool,uint16,uint16,uint16,bytes32))' <poolId> --rpc-url https://evmrpc.0g.ai
```

| Call | Returns |
| --- | --- |
| `launchSnapshot` | registered, initialized, quoteIsCurrency0, creator, launchedAt, launchBlock, baseFeeBps, creatorTaxBps, delaySeconds, openingBps, floorBps, decaySeconds |
| `splitOf` | configured, protocolBps, creatorBps, creatorComputeBps, creatorIdentity |

## Verify

```bash
cast call 0x2F74d603f7B7D8B7BFc78ef04E09905B862bE86a 'isComfyToken(address)(bool)' <token> --rpc-url https://evmrpc.0g.ai
cast logs --from-block 45552863 --to-block 45652862 --address 0x2F74d603f7B7D8B7BFc78ef04E09905B862bE86a 'Launched(bytes32 indexed poolId, address indexed token, address indexed creator, int24 openingTick, uint256 ladderSupply, uint256 launchFee)' --rpc-url https://evmrpc.0g.ai
```

`true` means this launcher made the token. Query 100,000 blocks at a time.
