Build on the launchpad.
Every launch, trade and payout is a transaction against the contracts below. Index the factory, the hook and the escrow and you have the whole state without depending on any Ballast service. The REST API exists for convenience.
Network and addresses
The launchpad runs on giwa-sepolia (chain id 91342). Addresses change as a whole set when the launchpad is redeployed: tokens from an earlier set keep trading against the hook they were launched with.
- LaunchFactory
- 0xBDBe…7448
- LaunchHook
- 0x4A4c…eaCC
- FeeEscrow
- 0x5358…543b
- SwapRouter
- 0x6711…0FD8
- LaunchBuyAdapter
- 0x61D5…d609
- LaunchTokenDeployer
- 0x0903…0f51
- DividendClaimHelper
- 0xEF4e…8F56
- DividendDeployer / implementation
- 0x5952…7539 / 0x38Aa…9dBF
- AnnouncementRegistry
- 0x8D2a…1459
- DojangGate / Dojang
- 0xA832…0fB4 / 0xd507…17B9
- LaunchOperations (linked library)
- 0x3099…3B25
- PoolManager
- 0xc1A1…3216
- StateView / V4Quoter
- 0xb4DF…8BeE / 0x22F2…ec85
- WETH
- 0x4200…0006
- BALLAST
- 0x27C2…Cccc
- Start block
- 42040099
- Indexer API
- https://api.ballast.exchange
ABIs, addresses and the fee math are in the @ballast/sdk workspace package of the repository (packages/sdk). Its fee functions reproduce the contracts' integer math exactly. The examples use viem.
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { getLaunchpadDeployment, giwaSepolia } from '@ballast/sdk'
const client = createPublicClient({ chain: giwaSepolia, transport: http() })
const wallet = createWalletClient({ chain: giwaSepolia, transport: custom(window.ethereum) })
const d = getLaunchpadDeployment(giwaSepolia.id)! // factory, hook, escrow, swapRouter, quoter, ...Reading policy and quotes
The factory holds the tax policy every new launch must fit, the registered quote assets with their opening tick, and a configVersion that changes with every governance setting. Rates are on PERCENTAGE_SCALE = 1e8 (1e6 = 1%).
import { launchFactoryAbi, NATIVE_QUOTE, openingMarketCap, previewTax } from '@ballast/sdk'
const [policy, configVersion, quote, launchFee] = await Promise.all([
client.readContract({ address: d.factory, abi: launchFactoryAbi, functionName: 'taxPolicy' }),
client.readContract({ address: d.factory, abi: launchFactoryAbi, functionName: 'configVersion' }),
client.readContract({ address: d.factory, abi: launchFactoryAbi, functionName: 'quoteConfig', args: [NATIVE_QUOTE] }),
client.readContract({ address: d.factory, abi: launchFactoryAbi, functionName: 'nativeLaunchFee' }),
])
// quote = [registered, quoteDecimals, startTickToken0Frame]
const opening = openingMarketCap({ startTickToken0Frame: quote[2], quoteUsd: 3000 })
// { startTick, priceInQuote, marketCapInQuote, marketCapUsd }
const tax = { buyTaxRate: 2_000_000, sellTaxRate: 2_000_000, // 2% each way
creatorAllocationShare: 60_000_000, burnAllocationShare: 20_000_000,
dividendAllocationShare: 20_000_000, integratorAllocationShare: 0,
minimumDividendHolding: 10_000n * 10n ** 18n }
const preview = previewTax(tax, policy) // throws FeeMathError('InvalidTaxConfiguration') etc. when it does not fit
// preview.buy.percent = { total, protocol, creator, burn, dividend, integrator, surcharge }
// or ask the factory (same numbers):
await client.readContract({ address: d.factory, abi: launchFactoryAbi, functionName: 'previewTaxConfiguration', args: [tax] })A live pool's frozen terms are in hook.poolConfig(poolId); the rates it charges right now, opening window included, come from hook.effectiveFeeRates(poolId, isBuy), which also says whether exact-output swaps are currently refused.
Launching a token
The factory deploys the token with CREATE2 and requires its address to end in 0xcccc. The salt is scoped to the sending wallet (keccak256(abi.encode(msg.sender, creatorSalt))) and the init code hash covers every launch parameter except the salt, so build the parameters first, read the hash once, then mine. A match takes about 65,000 attempts. Read configVersion right before submitting: if the owner changed a setting in between, the launch reverts with StaleConfig instead of settling on terms you did not see.
import { buildLaunchParams, launchFactoryAbi, mineCreatorSaltAsync } from '@ballast/sdk'
import { zeroHash } from 'viem'
const [me] = await wallet.getAddresses()
const params = buildLaunchParams({
sender: me,
name: 'Example', symbol: 'EXMPL',
contractURI: 'ipfs://…', // metadata JSON, free-form
metadata: { logo: 'ipfs://…', website: 'https://…' },
creatorSalt: zeroHash, // replaced below
configVersion, // factory.configVersion(), read just now
tax, // see above
antiSnipeEnabled: true,
metadataEditable: false,
// feeSlots: [...] up to 7, weights sum to 10,000; empty = one 100% slot for the creator
})
const initCodeHash = await client.readContract({ address: d.factory, abi: launchFactoryAbi, functionName: 'launchTokenInitCodeHash', args: [params] })
const mined = await mineCreatorSaltAsync({ creator: me, deployer: d.tokenDeployer, initCodeHash })
params.creatorSalt = mined!.creatorSalt // mined.token is the address the token will have
const { result } = await client.simulateContract({ account: me, address: d.factory, abi: launchFactoryAbi, functionName: 'createLaunch', args: [params], value: launchFee })
await wallet.writeContract({ account: me, address: d.factory, abi: launchFactoryAbi, functionName: 'createLaunch', args: [params], value: launchFee })
// result = [token, poolId]To buy in the same transaction, call createLaunchAndBuy. The launch-buy adapter swaps through the SwapRouter in the new pool; the funding asset must be the quote, the buy is exempt from the opening-window surcharge (the normal tax applies) and the tokens go to the sending wallet. routeData is the hookData for that swap and must be at least 64 bytes (word 0 is overwritten by the router, word 1 is the trade comment).
import { encodeAbiParameters, parseEther, zeroAddress, zeroHash } from 'viem'
const amountIn = parseEther('0.05')
const buy = {
fundingToken: zeroAddress, // ETH (must equal params.quoteToken)
amountIn,
minAmountOut: 1n, // > 0; size it from a quote of the opening price
routeData: encodeAbiParameters([{ type: 'address' }, { type: 'bytes32' }], [zeroAddress, zeroHash]),
}
await wallet.writeContract({ account: me, address: d.factory, abi: launchFactoryAbi, functionName: 'createLaunchAndBuy', args: [params, buy], value: launchFee + amountIn })Quoting and swapping
A launch pool is a standard Uniswap v4 pool: fee 0, tick spacing 200, hooks = the LaunchHook. Native ETH is address 0 and therefore always currency0. Quote through the V4Quoter (it runs the hook, so the amount is net of tax) and swap through the SwapRouter. The router pays the PoolManager from your wallet (ETH as value, ERC-20 by approval to the router), sends the output to the recipient and refunds unspent ETH.
import { launchHookAbi, launchPoolId, launchPoolKey, quoteIsCurrency0, swapRouterAbi, v4QuoterAbi, NATIVE_QUOTE } from '@ballast/sdk'
const poolKey = launchPoolKey(token, NATIVE_QUOTE, d.hook)
const buyZeroForOne = quoteIsCurrency0(NATIVE_QUOTE, token) // quote in, token out
const amountIn = parseEther('0.01')
const { result: [amountOut] } = await client.simulateContract({
address: d.quoter, abi: v4QuoterAbi, functionName: 'quoteExactInputSingle',
args: [{ poolKey, zeroForOne: buyZeroForOne, exactAmount: amountIn, hookData: '0x' }],
})
await wallet.writeContract({
account: me, address: d.swapRouter, abi: swapRouterAbi, functionName: 'swapExactInputSingle',
args: [{ poolKey, zeroForOne: buyZeroForOne, amountIn, amountOutMinimum: (amountOut * 99n) / 100n,
recipient: me, deadline: BigInt(Math.floor(Date.now() / 1000) + 120), hookData: '0x' }],
value: amountIn,
})
// sell: approve the token to d.swapRouter, then zeroForOne = !buyZeroForOne and no value.
// exact output: swapExactOutputSingle({ poolKey, zeroForOne, amountOut, amountInMaximum, recipient, deadline, hookData })
const [, exactOutputRestricted] = await client.readContract({
address: d.hook, abi: launchHookAbi, functionName: 'effectiveFeeRates', args: [launchPoolId(token, NATIVE_QUOTE, d.hook), true],
})hookData is empty or at least 64 bytes. The router always writes the paying wallet into word 0; word 1 is a free bytes32 comment that the hook emits with the trade. The Dojang exemption in the opening window is granted only for swaps sent by this router. Any other v4 router can trade the pools too; its swaps pay the full opening-window fee and carry whatever hookData it sends.
Two hook rules surface as reverts: exact-output swaps are refused while the opening window is active, and a swap the pool cannot fill completely reverts (PartialFillUnsupported). The router uses the edge of the price range as its limit and enforces your minimum or maximum itself.
Claiming fees
The hook credits every share to the FeeEscrow during the swap. Balances are per recipient and per currency (address 0 = ETH) across all launches. claimFor can be sent by anyone and always pays the recipient; claimTo lets a recipient send its own balance elsewhere.
import { feeEscrowAbi } from '@ballast/sdk'
const owed = await client.readContract({ address: d.escrow, abi: feeEscrowAbi, functionName: 'owed', args: [me, zeroAddress] })
await wallet.writeContract({ account: me, address: d.escrow, abi: feeEscrowAbi, functionName: 'claimFor', args: [me, zeroAddress] })
await wallet.writeContract({ account: me, address: d.escrow, abi: feeEscrowAbi, functionName: 'claimTo', args: [zeroAddress, otherWallet] })Dividends
A launch with a dividend share has its own dividend contract, found through the factory. Shares follow balances on every transfer. For ETH launches the reward token is WETH; withdrawDividends() unwraps it to ETH. The claim helper withdraws from up to 64 launches in one call and lets you choose per launch whether to unwrap.
import { dividendAbi, dividendClaimHelperAbi, launchFactoryAbi } from '@ballast/sdk'
const dividend = await client.readContract({ address: d.factory, abi: launchFactoryAbi, functionName: 'dividendOf', args: [token] })
const pending = await client.readContract({ address: dividend, abi: dividendAbi, functionName: 'withdrawableDividendOf', args: [me] })
await wallet.writeContract({ account: me, address: dividend, abi: dividendAbi, functionName: 'withdrawDividends' })
await wallet.writeContract({
account: me, address: d.claimHelper, abi: dividendClaimHelperAbi, functionName: 'claimDividends',
args: [[{ token: tokenA, unwrapWrappedNative: true }, { token: tokenB, unwrapWrappedNative: false }]],
})Creator actions
The current creator (factory.creatorRights(token)) can move the fee recipient, hand over the rights in two steps, edit metadata when the launch allowed it, and post announcements. Admins of non-creator fee slots manage their own slot on the hook.
import { announcementRegistryAbi, launchFactoryAbi, launchHookAbi } from '@ballast/sdk'
await wallet.writeContract({ account: me, address: d.factory, abi: launchFactoryAbi, functionName: 'setCreatorFeeRecipient', args: [token, newRecipient] })
await wallet.writeContract({ account: me, address: d.factory, abi: launchFactoryAbi, functionName: 'proposeCreatorRightsTransfer', args: [token, newCreator] })
// newCreator then calls acceptCreatorRightsTransfer(token); the creator can cancelCreatorRightsTransfer(token)
await wallet.writeContract({ account: me, address: d.factory, abi: launchFactoryAbi, functionName: 'updateTokenExtraMetadata', args: [token, 'website', 'https://…'] })
await wallet.writeContract({ account: me, address: d.announcements, abi: announcementRegistryAbi, functionName: 'postAnnouncement', args: [token, announcementId, 'Text', 'ipfs://…'] })
await wallet.writeContract({ account: slotAdmin, address: d.hook, abi: launchHookAbi, functionName: 'updateFeeSlotRecipient', args: [poolId, slotIndex, newRecipient] })Events to index
- LaunchFactory
- Launched(token, poolId, originalCreator, quoteToken, launchSupply, tickSpacing), LaunchTaxConfigured(poolId, token, configVersion, admittedPolicy, taxConfiguration, integratorFeeRecipient, antiSnipeEnabled), LaunchBuyExecuted, NativeLaunchFeePaid, QuoteRegistered / QuoteStartTickUpdated / QuoteUnregistered, TaxPolicyUpdated, ConfigVersionUpdated, LaunchCreationEnabledUpdated, CreatorRightsTransferProposed / Cancelled / Transferred, CreatorFeeRecipientUpdated
- LaunchHook
- PoolRegistered, Seeded, FeeSlotCreated / RecipientUpdated / AdminUpdated, CreatorRightsUpdated, and per swap: Trade(poolId, executor, referrer, quoteCurrency, quoteFeeAmount, comment), ProtocolFeeCredited, AntiSnipeFeeCredited, CreatorTaxCredited, DividendTaxCredited, DividendTaxRedirected, IntegratorTaxCredited, BurnTaxCredited(poolId, token, sink, amount)
- FeeEscrow
- Credited(recipient, currency, amount), Claimed(recipient, currency, destination, amount)
- PoolManager
- Initialize and Swap for prices and amounts; filter by the pool ids from Launched
- LaunchToken (each)
- Transfer, NameUpdated, SymbolUpdated, ContractURIUpdated, ExtraMetadataUpdated, DividendInitialized
- Dividend (each)
- DividendShareChanged, DividendsAllocated, DividendPaid, DividendAddressExcluded / Unexcluded
- AnnouncementRegistry
- AnnouncementPosted(token, creator, announcementId, description, announcementURI)
A trade is one PoolManager Swap plus the hook's Trade and BurnTaxCredited of the same swap. The pool id is the keccak of the PoolKey (SDK launchPoolId).
REST API
Read-only JSON at https://api.ballast.exchange, GET only, rate limited per IP. Every bigint is a decimal string; amounts named *Wei are in the token's quote asset, *EthWei in ETH equivalents.
- /lag
- { now, indexed, head, lagSeconds, lagBlocks, lastTradeAt, build }; 503 before the first block is indexed
- /prices
- { ethUsd, at } (display only)
- /stats
- protocol totals
- /stats/series?interval=3600|86400&since=
- activity per bucket, oldest first
- /stats/leaders?since=
- { tokens, traders, creators }
- /quotes
- registered quote assets with their opening tick
- /policy
- tax policy, supply, tick spacing, launch fee, creation switch, band template, launch-buy adapter
- /tokens?sort=new|mcap|volume|volume24h|change24h|active"e=&q=&ids=&limit=&offset=&spark=1
- token rows, each with volume24hWei, volume24hEthWei, trades24h, change24hBps, price24hAgoWei, mcap24hAgoWei (and spark with spark=1)
- /tokens/:address
- { token, pool, feeSlots, dividend, policy }
- /tokens/:address/trades?before=&limit=
- trades newest first
- /tokens/:address/candles?interval=60|300|900|3600|14400|86400&since=
- OHLC candles
- /tokens/:address/holders?protocol=1
- top 100 holders (protocol accounts flagged with protocol=1)
- /tokens/:address/announcements
- the creator’s announcements
- /tokens/:address/fees
- { totals, quote, recipients, feeSlots }
- /trades/recent
- latest trades across all tokens
- /accounts/:address
- { holdings, closed, trades, launches, escrow, dividends, trader, firstSeenAt }
- /accounts/:address/value?range=7d|30d|90d|all
- { interval, start, buckets, quotes }
Errors
- StaleConfig
- configVersion changed since you read it; re-read and rebuild the launch.
- LaunchExpired
- The launch deadline passed.
- InvalidTokenAddressSuffix
- The salt does not give an address ending in 0xcccc for this sender and these parameters.
- LaunchSaltUsed
- This sender already used this salt.
- QuoteNotRegistered / LaunchCreationDisabled
- The quote asset is not accepted / launching is switched off.
- InvalidTaxConfiguration / InvalidMinimumDividendHoldingRequirement
- The tax or the dividend minimum does not fit the policy.
- InvalidNativeLaunchFeePayment / InvalidLaunchBuyPayment
- msg.value is not the launch fee (plus amountIn for an ETH first buy).
- CreatorNotVerified
- The owner restricted launching to Dojang-verified wallets.
- ExactOutputDisabledDuringAntiSnipe
- Exact-output swap inside the opening window; use exact input.
- PartialFillUnsupported
- The pool could not fill the whole amount.
- TooLittleReceived / TooMuchRequested
- Your minimum out or maximum in was not met.
- DeadlinePassed / InvalidValue / InvalidHookData
- Router: expired, wrong msg.value, hookData between 1 and 63 bytes.
- NothingToClaim
- No escrow balance for this recipient and currency.
- NotCurrentCreator / MetadataNotEditable
- Not the current creator / the launch did not allow metadata edits.
- NotSlotAdmin / CreatorSlotManagedByFactory
- Not this slot’s admin / the creator slot follows creator rights.