# DegenZ Fun — multichain go-live guide

Step-by-step checklist to deploy **V5 bonding** (factory + router) on every supported EVM chain and push the live website.

## Supported chains

| Chain | Chain ID | Native | DegenZ page | Contracts deployed |
|-------|----------|--------|-------------|-------------------|
| **Robinhood** | 4663 | ETH | [/degenz-fun/robinhood/](https://degenznetwork.com/degenz-fun/robinhood/) | Factory + router + V3 |
| **Ethereum** | 1 | ETH | [/degenz-fun/ethereum/](https://degenznetwork.com/degenz-fun/ethereum/) | Factory + router + V3 |
| **BNB Chain** | 56 | BNB | [/degenz-fun/bsc/](https://degenznetwork.com/degenz-fun/bsc/) | Factory + router + V3 |
| **Base** | 8453 | ETH | [/degenz-fun/base/](https://degenznetwork.com/degenz-fun/base/) | Factory + router + V3 |
| **PulseChain** | 369 | PLS | [/degenz-fun/pulsechain/](https://degenznetwork.com/degenz-fun/pulsechain/) | Coming soon — fee router + V2 tax launchpad (PulseX) |
| **Solana** | — | SOL | [/degenz-fun/solana/](https://degenznetwork.com/degenz-fun/solana/) | Separate Anchor program (not this guide) |

Each EVM deploy creates:

- `DegenZFunBondingCurveFactory` — `createCoin`, graduation $10k–$30k, atomic dev buy
- `DegenZBondingRouter` — integrations pre-grad (counts toward bonding)
- Per-token `MoonRushBondingCurve` (**V6**: 1.5 native virtual + 1.073B virtual tokens) + empty Uniswap V3 pool → LP at graduation

**V6 curve fix (March 2026):** Replaced `0.001` virtual native with **1.5 native** + **1.073B** virtual tokens (pump.fun-style depth). Old factories still work but give distorted dev-buy % — redeploy required for new launches.

---

## Prerequisites

1. **Foundry** — `forge`, `cast` ([install](https://book.getfoundry.sh))
2. **Moon Rush contracts** at `../Tokens/Moon Rush` (or set `MOON_RUSH_DIR`)
3. **Node.js** — for website build
4. **Deployer wallet** with native gas on **each** chain you deploy:
   - Robinhood ETH
   - Ethereum ETH
   - BNB
   - Base ETH
5. **VPS SSH** — for `npm run deploy:vps` / `npm run sync:frontend` (see `scripts/deploy.env`)

---

## AI Launch Agent (Gemini) — enable + deploy

### Get a Gemini API key

1. Open [Google AI Studio](https://aistudio.google.com/apikey) (same Google account as Gemini Pro).
2. Click **Create API key** → pick or create a Google Cloud project if prompted.
3. Copy the key (starts with `AIza…`). Treat it like a password — **server only**, never put it in frontend JS.

### Put the key on your machine + VPS

```bash
cd "/Users/arclight/Desktop/Crypto/Solana Trading Terminal"
nano web/.env
```

Add (or update):

```env
GEMINI_API_KEY=AIzaSy…your_key_here
PUBLIC_SITE_URL=https://degenznetwork.com
# PINATA_JWT=…   # optional but recommended for IPFS metadata
```

### Deploy everything (server + Fun UI)

This feature needs a **full VPS deploy** (not `sync:frontend` alone) because the Gemini call lives on the server.

```bash
cd "/Users/arclight/Desktop/Crypto/Solana Trading Terminal"

# Optional: refresh Fun chain pages locally first
npm run generate:dzf-pages

# Build + upload server, client, docs; syncs GEMINI_API_KEY from web/.env to the VPS
npm run deploy:vps
```

Enter the VPS SSH password when prompted. Wait for Docker rebuild to finish.

### Smoke-test

1. Hard-refresh [degenznetwork.com/degenz-fun/robinhood/](https://degenznetwork.com/degenz-fun/robinhood/) (Cmd+Shift+R).
2. Open **Create** → **AI Launch Agent** → enter a prompt → **Generate**.
3. With **Design a logo** on, you should get name/ticker/bio + logo; then **Launch with AI** (wallet confirm).
4. If you see a `503` / “not configured”, the VPS `.env` still lacks `GEMINI_API_KEY` — set it and redeploy (or SSH and add it under `/opt/degenz/web/.env`, then `docker compose restart app`).

Quick API check from your Mac:

```bash
curl -sS -X POST https://degenznetwork.com/api/fair-launch/ai/suggest \
  -H 'Content-Type: application/json' \
  -d '{"prompt":"chaotic frog chef moon coin","wantLogo":false}' | head -c 400
```

---

## Step 1 — Configure secrets

```bash
cd "/Users/arclight/Desktop/Crypto/Solana Trading Terminal"
cp scripts/deploy.env.example scripts/deploy.env
nano scripts/deploy.env
```

```env
FEE_COLLECTOR=0x52BbC7657b2a12a40b5e2A7D8255bDf8c4FbEa71
PRIVATE_KEY=0xYour64HexDeployerKey

# VPS (for go-live upload)
VPS_HOST=217.216.58.110
VPS_USER=root
# SSH key or password access configured on your Mac
```

Never commit `deploy.env`.

---

## Step 2 — Compile contracts (optional sanity check)

```bash
cd "../Tokens/Moon Rush"
forge build
forge test --match-contract BondingCurveTest
```

Expect **13/13** tests passing.

---

## Step 3 — Deploy factories + routers (all EVM chains)

From the **Trading Terminal repo root**:

```bash
npm run deploy:bonding-factories
```

This runs `scripts/deploy-all-bonding-factories.sh`, which deploys **Robinhood, Ethereum, BNB Chain, and Base** in sequence.

- Prompts for deployer private key (unless `PRIVATE_KEY` is in `deploy.env`)
- Confirms treasury address
- Shows balance on each chain
- Updates `web/server/deployments.json` per successful chain with:
  - `bondingCurveFactory`
  - `bondingRouter`
  - `bondingV3SinglePool`, `bondingDynamicGraduation`, `bondingAtomicDevBuy`
  - V3 addresses (`v3Factory`, `v3PositionManager`, `weth`, `v3PoolFee`)
  - Graduation band wei + USD

### Deploy a single chain only

```bash
./scripts/deploy-degenz-bonding-factory.sh robinhood
./scripts/deploy-degenz-bonding-factory.sh ethereum
./scripts/deploy-degenz-bonding-factory.sh bsc
./scripts/deploy-degenz-bonding-factory.sh base
```

### If one chain fails (BSC/Base skipped)

Deploy order is **robinhood → ethereum → bsc → base**. On failure the script **stops** — later chains are not attempted.

```bash
# Deploy only the chains you still need (Robinhood already done — skip it):
CHAINS="bsc base" npm run deploy:bonding-factories

# Or one at a time:
./scripts/deploy-degenz-bonding-factory.sh bsc
./scripts/deploy-degenz-bonding-factory.sh base
./scripts/deploy-degenz-bonding-factory.sh ethereum   # needs ~0.05+ ETH for gas on mainnet
```

Ethereum mainnet deploys are **expensive** (~2 contract creates + router wire). If ethereum fails, fund the deployer with more ETH and rerun only that chain.

```bash
DEPLOY_CONTINUE=1 npm run deploy:bonding-factories   # retries all chains (skips re-deploy if you use CHAINS=)
```

### Non-interactive (CI / scripted)

```bash
SKIP_CONFIRM=1 PRIVATE_KEY=0x... FEE_COLLECTOR=0x52BbC... npm run deploy:bonding-factories
```

### Optional env overrides

| Variable | Default | Meaning |
|----------|---------|---------|
| `MIN_GRADUATION_USD` | 10000 | Min deployer graduation target |
| `MAX_GRADUATION_USD` | 30000 | Max deployer graduation target |
| `CREATE_FEE_USD` | 5 | Launch fee |
| `AUTO_SEED_TRIGGER_USD` | 0 | Pre-grad V3 seed (0 = off; use router) |
| `NATIVE_USD` | CoinGecko | Skip price fetch |
| `DEPLOY_CONTINUE` | 0 | Set `1` to continue after one chain fails |

---

## Step 4 — Verify deployments.json locally

```bash
cat web/server/deployments.json | python3 -m json.tool
```

Each of `robinhood`, `ethereum`, `bsc`, `base` should have:

- `bondingCurveFactory` — non-zero address
- `bondingRouter` — non-zero address
- `bondingDynamicGraduation: true`
- `bondingV3SinglePool: true`

### Current V6 factory addresses (March 2026)

| Chain | Factory | Router |
|-------|---------|--------|
| Robinhood | `0x719d48c72de4543cc1855b17e1c83725bbd96d9d` | `0x44590798cd835d5d7d2588f4e0345667a4b12356` |
| Ethereum | `0x690979928b159731c8190196d3bc74431b0a606b` | `0x3cab43be2e7c7b942a00d137662d0fc69c9a0dee` |
| BNB Chain | `0x09f21a69c81d871126062c2b36ff3e7347edd6fb` | `0x84264e1eb74a61ae218194029dc176cc73269eb3` |
| Base | `0x84264e1eb74a61ae218194029dc176cc73269eb3` | `0x690979928b159731c8190196d3bc74431b0a606b` |

After creating a test coin, confirm V6 curve:

```bash
cast call $CURVE_ADDR "virtualEthReserve()(uint256)" --rpc-url $RPC
# Expected: 1500000000000000000 (1.5e18)
```

---

## Step 5 — Build website locally

```bash
npm run generate:dzf-pages
cd web/client && npm run build
cd web/server && npm run build
```

Quick check:

```bash
grep -o 'fun-ui-multichain-v[0-9]*' web/client/dist/degenz-fun/robinhood/index.html | head -1
# Should show fun-ui-multichain-v13 or newer
```

---

## Step 6 — Push to production VPS

**Full deploy** (contracts config + API + static site):

```bash
npm run deploy:vps
```

**Frontend + API config only** (after contracts already deployed):

```bash
npm run sync:frontend
```

If SSH fails, fix key access to `root@217.216.58.110` or update `VPS_HOST` in `deploy.env`.

---

## Step 7 — Verify live API

```bash
curl -s https://degenznetwork.com/api/fair-launch/config | python3 -m json.tool
```

For each chain, confirm:

```bash
curl -s https://degenznetwork.com/api/fair-launch/config | jq '.chains[] | {id, bondingCurveFactory, bondingRouter, bondingDynamicGraduation, bondingV3SinglePool, live}'
```

All four EVM chains should show `"live": true` and non-empty factory + router.

---

## Step 8 — Verify live UI

1. Open **incognito** window (bypass cache)
2. Visit [degenznetwork.com/degenz-fun/](https://degenznetwork.com/degenz-fun/)
3. Open each chain: Robinhood, Ethereum, BNB, Base
4. Confirm:
   - Graduation slider ($10k–$30k) in create modal
   - Dev buy estimate sensible (~0.25% for 0.003 native, not 70%+)
   - Create is not blocked by “upgrade factory” errors
5. View page source — `fair-launch.js?v=19+` and `boot.js?v=19+`

---

## Step 9 — Test one launch (testnet or small mainnet)

On **Robinhood** (cheapest gas):

1. Connect wallet on Robinhood Chain
2. Create a test coin with minimal dev buy
3. Buy on website — progress bar moves
4. Optional: bot buy via router:

```bash
# Replace ROUTER, WETH, TOKEN from deployments / create tx
cast send $ROUTER "swapExactETHForTokens(uint256,address[],address,uint256)" \
  0 "[$WETH,$TOKEN]" $YOUR_WALLET $(($(date +%s)+600)) \
  --value 0.001ether --rpc-url https://rpc.mainnet.chain.robinhood.com --private-key $PK
```

5. Confirm `bondingProgressBps()` increased on the curve contract

---

## Step 10 — Bot / Telegram integration (all chains)

Share per chain from API `bondingRouter`:

| Bot setting | Value |
|-------------|--------|
| Router (pre-grad) | `bondingRouter` from config |
| Path | `[WETH, token]` |
| Method | `swapExactETHForTokens` |
| Post-grad | Token’s Uniswap V3 pool (`curve.v3Pool()`) |

**Do not** point bots at the V3 pool pre-grad — those swaps do not count toward graduation.

Full architecture: [web/client/public/docs/BONDING-FLOW.md](client/public/docs/BONDING-FLOW.md)

---

## Step 11 — Docs site

After deploy, docs auto-read live addresses from `/api/fair-launch/config`:

- [degenznetwork.com/docs/](https://degenznetwork.com/docs/) → **Deployed addresses**
- Contract source tabs: `DegenZFunBondingCurveFactory`, `DegenZBondingRouter`, `MoonRushBondingCurve`

---

## Troubleshooting

| Issue | Fix |
|-------|-----|
| Create blocked “upgrade factory” | Redeploy that chain; run `deploy:vps` |
| `Pinata upload failed (401)` | Invalid/expired `PINATA_JWT` — get new key at [Pinata](https://app.pinata.cloud/developers/api-keys), set in `web/.env` or Admin → Settings, run `npm run deploy:vps`. Creates still work via site-hosted metadata until fixed. |
| AI Launch Agent `503` | Set `GEMINI_API_KEY` in `web/.env` (Google AI Studio), then `npm run deploy:vps`. |
| `bondingRouter` empty in API | Redeploy factory script (router deploys with factory) |
| Old UI on live site | `npm run sync:frontend`; hard-refresh / incognito |
| SSH permission denied | Fix VPS key in `~/.ssh`; check `VPS_HOST` |
| One chain deploy failed | `DEPLOY_CONTINUE=1`; redeploy failed chain alone |
| Insufficient gas | Fund deployer on that chain |
| forge “Operation not permitted” | Run deploy from Terminal.app, not sandbox |

---

## Quick reference

```bash
# Full multichain contract deploy
npm run deploy:bonding-factories

# Regenerate chain pages + build + upload
npm run generate:dzf-pages
npm run deploy:vps

# API smoke test
curl -s https://degenznetwork.com/api/fair-launch/config | jq '.chains[].id'
```

**Treasury (all EVM):** `0x52BbC7657b2a12a40b5e2A7D8255bDf8c4FbEa71`
