Skip to content
View clankenized's full-sized avatar

Block or report clankenized

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Content in all repositories owned by your account will be closed.
Maximum 250 characters. Please don’t include any personal information such as legal names or email addresses. This note will only be visible to you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
clankenized/README.md

Clankenized

Migrate a token from any launchpad or liquidity pool into a new Clanker v5 token on Base.

Clanker v5 has no migrate() function — every v5 token is a fresh contract with a fresh Uniswap v4 pool. So a migration is built from three on-chain facts:

  1. v5 locks pool liquidity. The hook enables beforeAddLiquidity / beforeRemoveLiquidity, and no Uniswap v4 PositionManager is deployed on Base, so liquidity can never be added or removed after launch. The launch seeding is the only liquidity event, and it is locked forever.
  2. The launch buy is exempt from the anti-snipe premium. The policy starts at a 99% fee for 20 seconds, but the purchase inside createLaunchAndBuy executes at the pool start price plus the configured tax only. Normal swaps inside that window pay a heavy premium.
  3. One swap means one average price. Collecting every holder's old tokens and swapping them in a single transaction gives every holder the same average price.

Flow

1. Holders approve the vault (Permit2 / ERC-20 approve)
2. Vault pulls every old token
3. Vault swaps all of them once  ->  ETH (or USDC)
4. Vault calls createLaunchAndBuy with a single prebuy inside the launch transaction
     fee slot  -> old creator, admin = old admin
     tax       -> chosen by the old creator (1-10%, frozen at launch)
5. Vault distributes the new tokens pro-rata (merkle claim)

Our cut is 1% of the gross prebuy, and we pay the launch gas. Base gas is 0.005 gwei, so a launch costs ~0.00002 ETH.

This repository is the whole app — the contracts, the API and the frontend. The bytecode that runs on Base is byte-identical to a build of this source (see Verify the deployment). Nothing here has been audited by a third party; read it, run it, and tell us what is wrong (see SECURITY.md).

Deploy to Vercel

The project is Vercel-ready as-is: a static site in apps/web plus one serverless function.

# connect the repo in the Vercel dashboard, or:
npx vercel --prod

vercel.json pins the build:

setting value why
framework null the UI is plain HTML/CSS/JS, no framework
buildCommand "" nothing to compile
outputDirectory apps/web the static site
installCommand npm install --omit=dev the root has no dependencies, so this is instant

/api/inspect is deployed as a Node function next to the static site. It has no dependencies (plain fetch + hand-rolled ABI decoding), so it needs no bundler and no runtime packages.

Environment variables (all optional):

variable default use
BASE_RPC_URL https://base-rpc.publicnode.com your own Base RPC (Alchemy / QuickNode / Ankr) — recommended, the public one is rate limited
VERCEL_URL – reserved for your own domain

Set BASE_RPC_URL to a keyed RPC before going live; the public endpoint rate-limits quickly.

Layout

path what
apps/web/ frontend (static, no build step)
api/inspect.js serverless endpoint: reads a Base token live (metadata, supply, pool, Clanker fee slots)
api/quote.js serverless endpoint: the 0x quote for the holders' swap
api/zeroex.js the 0x Swap API client, shared by the quote and the keeper
api/upload.js serverless endpoint: pins the token image to IPFS (Pinata or a self-hosted node)
packages/contracts/ verified Clanker v5 ABIs + Base address registry + policy notes
tools/dryrun-launch.mjs eth_call simulation of a full launch — no gas spent
docs/ flow notes, the measured prebuy impact curve and the creator-terms spec

Local development

# the UI (static)
npm run web                     # http://localhost:8899

# the live inspection endpoint (dev server with /api wired)
node tools/dev-server.mjs        # http://localhost:8899

# the launch dry-run harness
npm --prefix tools install
npm --prefix tools run dryrun -- 0.01,0.1,0.5,1

Dry-run harness

tools/dryrun-launch.mjs simulates createLaunchAndBuy against Base mainnet with eth_call. Nothing is deployed and no gas is spent, but it returns the exact token address, the pool id and the number of tokens the prebuy buys — the pre-flight check the backend should run before any transaction is signed.

Env: CALLER, OLD_CREATOR, OLD_ADMIN, OUR_REV, TAX_BPS, CREATOR_SHARE, INTEG_SHARE, COMMISSION_BPS, SLOT_MODE, ANTI_SNIPE, RPC. See the header comment in the file.

Measured prebuy impact (1% tax, anti-snipe off, ETH quote)

gross (ETH) commission 1% prebuy tokens received vs start price holders keep
0.01 0.0001 0.0099 3,952,181 +1.41% 98.6%
0.1 0.001 0.099 38,164,321 +5.02% 95.2%
0.5 0.005 0.495 165,549,300 +21.05% 82.6%
1 0.01 0.99 284,070,867 +41.09% 70.9%
4 0.04 3.96 613,473,566 (61% of supply) +161% 38.3%

The creator's terms

The creator signs twice, at two different moments, and both signatures are EIP-712 typed data over the same domain (the vault address on Base):

  1. MigrationTerms — before the collection starts. Locks the tax rate, the fee slot, the minimum share of the old supply and the deadline. Locking the economics early is what stops the creator from raising the tax after seeing how much was collected.
  2. LaunchTerms — just before the launch, with the money already in the vault. Locks the identity of the new token (name, symbol, metadata, the mined salt that decides its address), the launch buy route and the two floors: minSwapOut for the swap of the old tokens and minPrebuyRate for what that ETH buys in the launch pool.

execute() takes no free parameters — the vault rebuilds Clanker's LaunchParams from the stored commitments, so whoever triggers the migration cannot change anything. See docs/creator-terms.md.

The frontend already builds, signs and exports both payloads (apps/web/terms.js); the vault and the factory are deployed on Base — see packages/contracts/README.md.

Environment variables

variable what it is
BASE_RPC_URL the Base RPC — the simulation and the fork tests need it
ZEROX_API_KEY the 0x Swap API key — the backend fetches the swap quote with it
PINATA_API_KEY + PINATA_SECRET_KEY the IPFS pinning (a JWT is minted from them per request, so they never expire) — PINATA_API_KEY_SECRET is accepted as well
PINATA_JWT an alternative to the two above — it expires after an hour
IPFS_API_URL (+ IPFS_API_TOKEN) a self-hosted IPFS node instead of Pinata
VAULT_FACTORY_ADDRESS the VaultFactory on Base — 0xa08F40D8B7Be8f23A9c21e616c4E88a2ACd71B7B
KEEPER_PRIVATE_KEY the swap operator key — the keeper prepares the route and runs the migration (it falls back to CLANKENIZED_PK)
CLANKENIZED_SUPABASE_URL the Supabase project that holds the migration records
CLANKENIZED_SUPABASE_SERVICE_ROLE_KEY the service role key — the only writer of the records table
CLANKENIZED_SUPABASE_PAT the personal access token of that project — used by the tooling for the DDL

Nothing is pinned and no quote is fetched without them: the token launches without an image, and the creator can paste an existing ipfs:// URI instead.

The vault

packages/contracts/src/MigrationVault.sol implements the migration, and packages/contracts/src/VaultFactory.sol deploys one vault per migration with CREATE2 — so the address is known before anything is deployed and the creator can verify the bytecode before signing.

submitMigrationTerms → deposit → submitLaunchTerms → execute → claim

It is dependency-free and execute() takes no arguments — the vault rebuilds the Clanker LaunchParams from the two stored commitments, so whoever triggers the execution cannot change anything. The distribution is a pull payment (share = totalDistributed * deposit / totalDeposited), so there is no merkle tree and no keeper in the middle.

cd packages/contracts && forge test     # 91 tests
node packages/contracts/scripts/verify-frontend-signatures.mjs   # the frontend's signatures fit
node tools/e2e-onchain.mjs                                       # the browser drives the real contracts

See packages/contracts/README.md.

The ecosystem vault

packages/contracts/src/EcosystemVault.sol is the second contract of the project: it stakes CLANKENIZED and shares the ecosystem tokens that the project buys with the Clanker fees it collects. It runs on Base at 0xBE8a04Fc99c1Da8265674c22bd1AEDecD9942613, and its admin is the creator of the CLANKENIZED launch.

The project owns 50% of the creator tax of its own Clanker v5 pool. Pointing that fee slot at the vault is one call by the slot admin; the fees stay in the Clanker FeeEscrow until somebody claims them, and the payout lands in the vault's receive() as buyback reserve. The admin then buys ecosystem tokens through the 0x AllowanceHolder, and the vault splits them between the stakers pro rata.

docs/ecosystem-vault.md describes the whole flow, the limits and the emergency controls.

The API

The browser never encodes calldata — the backend builds the unsigned transaction with viem and the wallet sends it. That keeps one implementation of the ABI.

endpoint what it does
GET /api/inspect?address=0x… read the old token from the chain
GET /api/tx?op=migration&oldToken=0x… the migration id and the vault address it will have
GET /api/tx?op=state&vault=0x…&holder=0x… the vault state: the terms, the collection, the launch, the claim
GET /api/tx?op=balance&token=0x…&holder=0x… a token balance
POST /api/tx the unsigned transaction for a vault call (deployMigration, submitMigrationTerms, submitLaunchTerms, deposit, claim, refund, cancel, approve, prepareSwap, execute, sweepEth, setRewardRecipient, setRewardAdmin, proposeCreatorRightsTransfer, acceptCreatorRights, setCreatorFeeRecipient)
POST /api/keeper the keeper: 0x quote → prepareSwap → execute
GET /api/quote?token=0x…&amount=… what the collected balance is worth in ETH — the basis for the slippage floor
GET /api/prepare?… mine the salt, predict the token, simulate the launch (a slippage floor is required)
GET /api/prepare?…&preview=1 the same simulation without a floor — the preflight, before anything is collected
POST /api/upload pin the image and the metadata JSON to IPFS — only for a migration whose terms are on chain

The migration record

The chain is the source of truth about the money. The migration record is the index: it keeps the signed terms and makes the migrations listable, which the chain cannot do (the free tier caps eth_getLogs at ten blocks).

endpoint what it does
POST /api/migrations store the signed migration terms — the API recovers the signer from the signature and refuses anybody else
POST /api/migrations store the signed launch terms (launchTerms in the body)
GET /api/migrations?id=0x… the record of one migration
GET /api/migrations?list=1 the list of the migrations

The schema is supabase/migrations/20260722_01_migrations_table.sql. The table has row level security: everybody may read a migration, only the service role (the API) may write one.

A migration is addressed by its id, so the holders get a link:

https://<host>/?id=0x79ccd98f…   → the migration, loaded from the record

The creator signs the terms, the record keeps them, and anybody can submit them to the vault — the creator's signature is the permission, not their presence.

The flow

  1. the creator detects the old token — the app asks the factory for the vault address of that migration (CREATE2, so it is known before anything is deployed);
  2. the creator signs the migration terms against that address;
  3. anyone deploys the vault (deployMigration) and submits the signed terms;
  4. the holders approve the vault once and deposit their old tokens;
  5. the creator signs the launch terms, the app submits them;
  6. the keeper fetches the 0x quote, prepares the route and runs execute() — only the keeper and the old creator may call it, and it takes no value;
  7. every holder pulls their share with claim().

The security headers

vercel.json sets a content security policy (the app only loads its own scripts and styles), X-Frame-Options: DENY, HSTS, nosniff, a referrer policy and a permissions policy. The app escapes every value that comes from outside it — the symbol of the old token is whatever its contract returns, the name of an installed wallet comes from the extension — and every transaction and signature is refused unless the wallet is on Base.

Who holds what

Address Role
the vault (MigrationVault, one per migration) the creator of the new token — it launches it, holds the deposits and distributes the new tokens
the vault factory (VaultFactory) deploys one vault per migration and holds the immutable configuration: our commission (1%), its recipient and the keeper
the Clanker v5 factory 0x572e88D3… deploys the token, creates the pool, keeps the creator-rights registry
the hook 0x5E320eA6… the fee slots of every pool — the slot admin can move the recipient
the fee escrow 0x5dd237d1… collects and pays out the tax
the swap executor sells the collected tokens for ETH — it never touches the fee slots

Because the vault is the creator, the creator rights of the new token live in the vault contract. The old creator can hand them over (proposeCreatorRightsTransfer) and the receiver accepts the transfer on the Clanker factory (acceptCreatorRightsTransfer) — two transactions, so the receiver's signature is always needed. The creator's own share of the tax can be moved with setCreatorFeeRecipient.

The keeper's guards

The keeper holds a key, so it is careful about what it signs:

  • the vault has to be a vault of the configured VaultFactory (isMigrationVault) — it never talks to a contract it cannot place;
  • every on-chain precondition (terms set, minimum reached, window open, nothing executed) is checked before a transaction is sent, so a doomed attempt costs no gas;
  • the quote has to meet the minSwapOut the creator signed and has to sell exactly the deposited amount — a donation to the vault is nobody's money and may never change the quote;
  • the attempts are rate limited, per vault and per caller.

Status

The UI reads real chain data through /api/inspect — the token address is typed in by the creator and read from the chain, so the name, symbol, supply, creator, fee slots, pool and liquidity are all real.

/api/prepare goes one step further: it mines the salt off-chain, predicts the new token's address and pool id and simulates the whole createLaunchAndBuy with eth_call, so the numbers on the execute screen come from the factory itself.

The contracts are deployed on Base and the app talks to them: the vault, the terms, the deposits, the launch and the claim are all on chain (see tools/e2e-onchain.mjs).

The migration record backend is built: the signed terms are stored in Supabase (one row per migration) so that a migration can be listed and submitted later, but the chain stays the source of truth about the money — the record only holds the signature and the addresses.

Not built yet: the holder list — the vault stores one number per holder and no list, so the totals are exact but the opt-ins cannot be enumerated without reading the logs.

Audit status

Not audited. No third party has reviewed this code. What is checked automatically on every push: the whole test suite (forge test, 91 tests), the selector of the Clanker call (ClankerInterface.t.sol — a wrong struct width changes the selector and breaks every launch silently), and a simulation of the launch against a real fork of Base (ClankerLaunch.fork.t.sol).

Verify the deployment

The contracts in this repository are the contracts on Base. To check that yourself:

# build the factory with the same constructor arguments and compare the bytecode
node tools/compare-code.mjs <address of the local build>

Identical bytecode means the chain runs this source. The deployed addresses are in packages/contracts/addresses.base.json, and the UI shows them with explorer links.

The contracts are published on Sourcify with a perfect match — the creation bytecode, the runtime bytecode and the constructor arguments all reproduce the code on chain, and the source is the one in this repository:

Contract Address Sourcify
VaultFactory 0xa08F40D8B7Be8f23A9c21e616c4E88a2ACd71B7B source
ZeroExSwapExecutor 0xF69888E6045Da85140d6b199b5F2F0936b1Bd141 source
EcosystemVault 0xBE8a04Fc99c1Da8265674c22bd1AEDecD9942613 source

To publish the same source on BaseScan as well, an Etherscan API key is needed (one free key covers every chain):

export ETHERSCAN_API_KEY=…          # https://etherscan.io/myapikey
node tools/verify-etherscan.mjs      # pushes both contracts to BaseScan
node tools/check-explorer-status.mjs # reads the badge back from BaseScan

Or verify by hand: packages/contracts/verification/ holds the standard JSON input of both contracts, together with the contract name, the compiler version and the constructor arguments that BaseScan asks for. node tools/check-verification-inputs.mjs proves those files are the deployed code — it compiles them and compares the creation bytecode plus the constructor arguments with the input of the deployment transaction, byte for byte.

The script compiles the source with the same solc first and compares it with the bytecode on chain; it only submits when the two are identical. --dry-run stops after that check.

An earlier factory was retired (its vaults called the Clanker factory with the wrong selector, so every execute() reverted) — it is visible in the git history, and it holds no deposits.

Verified Clanker v5 facts (Base, 2026-11-21)

See packages/contracts/README.md for the full list, including the fee-slot rules and the revert reasons that encode them.

License

MIT — see LICENSE.

Popular repositories Loading

  1. clankenized clankenized Public

    Migrate tokens from any launchpad or pool into a new Clanker v5 token on Base

    Solidity 1