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

# Integration Guide

> Core concepts, events, and lifecycle for integrating with Alloca

# Integration Guide

Technical guide for aggregators, trading bots, Telegram bots, and analytics platforms.

## Quick Reference

### Deployed Contracts (Monad Mainnet)

```javascript theme={null}
const CONTRACTS = {
  AllocaFactoryMemes: "0x6bf9598B0838FB2d59c51D33fF839EEF6d79E923",
  AllocaTokenImpl: "0x33E0E10D089544D232ba7C0c27B4A3A5e139255e",
  AllocaDexFactory: "0xB88A4dD389c31b225e0ce6017c5AAa66eA894b79",
  AllocaDexRouter02: "0x2a32C0457a84F1e50A035ffE1ecC4F104ed25eC3",
  WMON: "0x3bd359C1119dA7Da1D913D1C4D2B7c461115433A",
};

const CHAIN_ID = 143; // Monad Mainnet
```

### Contract ABIs

ABIs are available via IPFS:

```javascript theme={null}
ABIS = {
  AllocaFactoryMemes: "https://bafybeigd7v65ctexuz4kojry66mgehcltj7hh6rcml3idpidafuhz44owu.ipfs.w3s.link/AllocaFactoryMemes.json",
  AllocaToken: "https://bafybeidh6uoeotkkvxoaewjzdug3jbu3lk4m2xn7x7dvtwrfmria3qlyau.ipfs.w3s.link/AllocaToken.json",
  AllocaDexFactory: "https://bafybeiectiihv3npvnk5lkplghs3qk577532ibim4ruuayrfxjedx7jcb4.ipfs.w3s.link/AllocaDexFactory.json",
  AllocaDexRouter02: "https://bafybeicgh25dubwqfaqqxijnmrxyxmigg7swvrfwoyyiifwh4z3y7jv3c4.ipfs.w3s.link/AllocaDexRouter02.json",
}
```

***

## Core Concepts

### Token Lifecycle

Each token goes through three phases:

```
1. [BONDING CURVE] → 2. [GRADUATION] → 3. [DEX TRADING]
```

<Note>
  Each token is a pool - AllocaToken inherits AllocaPool functionality.
</Note>

### Phase 1: Bonding Curve (Pre-Graduation)

* Tokens trade on internal bonding curve
* Price increases as more tokens are bought
* Target: Raise \~492,566 MON to graduate

### Phase 2: Graduation

* Automatic when bonding curve completes
* Liquidity moves to AllocaDex (Uniswap V2 fork)
* DEX pair created automatically

### Phase 3: DEX Trading

* Trade via AllocaDexRouter02
* Standard Uniswap V2 interface

***

## Events to Track

### 1. New Token Deployments

Listen to `AllocaFactoryMemes` for new token launches:

```solidity theme={null}
event AllocaDeployed(
    address indexed allocaPool,
    address indexed implementation
);
```

### 2. Token Graduation Events

Listen to individual token contracts for graduation:

```solidity theme={null}
event PoolGraduated(
    address indexed token,
    address indexed dexPair,
    uint256 liquidityTokens,
    uint256 liquidityBase,
    uint256 lpTokensMinted
);
```

### 3. Trade Events (Bonding Curve)

```solidity theme={null}
event TokensBought(
    address indexed buyer,
    uint256 amountIn,      // MON spent
    uint256 amountOut,     // Tokens received
    uint256 fee            // Fee paid
);

event TokensSold(
    address indexed seller,
    uint256 amountIn,      // Tokens sold
    uint256 amountOut,     // MON received
    uint256 fee            // Fee paid
);
```

### 4. DEX Trade Events (Post-Graduation)

Listen to the DEX pair contract:

```solidity theme={null}
event Swap(
    address indexed sender,
    uint256 amount0In,
    uint256 amount1In,
    uint256 amount0Out,
    uint256 amount1Out,
    address indexed to
);
```

***

## Determining Token Phase

To check if a token has graduated:

```javascript theme={null}
// Option 1: Check if DEX pair exists
const dexPair = await allocaDexFactory.getPair(tokenAddress, WMON);
const isGraduated = dexPair !== "0x0000000000000000000000000000000000000000";

// Option 2: Check graduated state on token contract
const isGraduated = await allocaToken.graduated();
```

***

**Last Updated:** 2025-12-05
**Monad Mainnet Chain ID:** 143
