How-to guide

Deploy the Trading contracts

Trading needs one factory and one router at addresses derived from the Statoblast deployment. Use this guide to deploy them from the browser on a network where Statoblast is installed, or with the testnet deployer on a local Anvil node.

Before you start

Confirm reviewed Statoblast core code, including its SecurityPoolFactory, for your selected network and Yes or No universe. Use the matching manifest listed in the deployment status reference; planned addresses do not prove the contracts are live. To install the core on a test network first, follow Deploy testnet contracts.

Deploy from the browser

Serve the Trading UI as Set up Trading development describes, from source or in Docker.

  1. Open http://localhost:4163/#/deploy and choose the truthful universe if prompted. To use another network or RPC URL, set it under Settings before connecting.
  2. Select Connect wallet. The Trading contracts panel shows the SecurityPoolFactory address and the status of the Trading factory (TwoWayConstantProductFactory) and Trading router (TwoWayConstantProductRouter).
  3. Select Deploy trading factory and confirm, then select Deploy trading router and confirm. Deployment progress reaches 2 / 2 once both contracts and their links are verified. If you leave and return with the same settings, the flow resumes at the first missing contract.
The Deploy page's Trading contracts panel showing the target network (Browser simulation), the security pool factory address, a note that deployment takes two wallet transactions, Trading factory and Trading router marked Not deployed, deployment progress 0 of 2, a Security pool factory is not deployed badge, disabled Deploy trading factory and Deploy trading router buttons, and a note to deploy Statoblast first with a Deployment guide link.
A missing prerequisite. The SECURITY POOL FACTORY IS NOT DEPLOYED badge and the disabled deploy buttons mean the selected Statoblast SecurityPoolFactory is not deployed.

The factory's trading fee is fixed at 0.30% and cannot be changed after deployment. Creating a trading pool for a market is a separate step; see Your first Trading market.

Use local Anvil

The UIs do not offer Ethereum mainnet, so start Anvil with Sepolia's chain ID, 11155111, and use the Sepolia address profile:

bun run anvil -- --chain-id 11155111 --hardfork osaka
  1. Deploy to the node with the testnet deployer, following Deploy locally with --rpc-url=http://127.0.0.1:8545 and an Anvil account's key. It installs the core and the Trading factory and router. Its final explorer-verification step targets public Sepolia, so a failure there does not mean the local deployment failed.
  2. In your wallet, point the chain 11155111 network at http://127.0.0.1:8545 and import an Anvil account. Once a wallet is connected, the UI reads and sends through the wallet's RPC, so a wallet still on public Sepolia would use the real network.
  3. Start the Trading UI, connect the wallet, and open #/deploy. Deployment progress shows 2 / 2.

Deploy for script and integration tests

The local deployment script deploys independent copies at ordinary CREATE addresses. The UI never finds them, because it looks only at the derived addresses; use them from scripts and integration tests only.

The script needs a node whose chain ID equals the core manifest's, code at that manifest's SecurityPoolFactory, and an unlocked account on the node. For the Sepolia manifest below, complete step 1 of Use local Anvil first.

ZOLTAR_DEPLOYMENT_MANIFEST=docs/sepolia-deployment-addresses.json \
TRADING_RPC_URL=http://127.0.0.1:8545 \
bun run trading:deploy:local

The script deploys TwoWayConstantProductFactory(coreFactory, feeBps) and TwoWayConstantProductRouter(factory), writes a manifest of its inputs, addresses, transaction hashes, and bytecode hashes to solidity/deployments/trading/local.json, and prints it. The configuration reference lists its environment variables and output.