Skip to content

Quick start ​

This page starts the full exchange on a local Anvil chain. It uses public Anvil test accounts, test USDC, and a test oracle. For each step in detail, see Run the local exchange.

Before you start ​

Install these tools:

  • Node.js 22.12 or later
  • pnpm 11
  • Foundry (forge and anvil)

Run all commands from the repository root. If Foundry is not on the shell path, add ~/.foundry/bin to PATH.

Ports

The local stack uses port 8545 (Anvil), port 3001 (API), and port 3000 (web application). The documentation site uses port 5173.

Start the exchange ​

Use one terminal for each long-running command.

Terminal 1. Start the chain. It mines one block each second.

sh
pnpm install
pnpm local:chain

Terminal 2. Build the contracts. Deploy them. Give the makers collateral. Start the quote loop.

sh
forge build --root contracts
pnpm local:deploy
pnpm demo seed
pnpm demo serve

Terminal 3. Start the API. The relayer key is the key of public Anvil account 9.

sh
DEPLOYMENT_FILE=deployments/local.json RPC_URL=http://127.0.0.1:8545 \
STATE_FILE=.local/local-indexer.json INDEX_BATCH_BLOCKS=1000 INDEX_CONFIRMATIONS=0 \
RELAYER_PRIVATE_KEY=0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 \
pnpm dev:services

Terminal 4. Put the local values in web/.env.local, then start the web application.

sh
NEXT_PUBLIC_API_URL=http://127.0.0.1:3001
NEXT_PUBLIC_CHAIN_ID=31337
NEXT_PUBLIC_CHAIN_NAME=Monad Local Demo
NEXT_PUBLIC_RPC_URL=http://127.0.0.1:8545
sh
pnpm dev:web

Open http://localhost:3000.

Make the first trade ​

  1. Import Anvil account 6 into MetaMask. Add a network with RPC http://127.0.0.1:8545, chain ID 31337, and currency symbol MON.
  2. Connect the wallet.
  3. Select Faucet in the top bar. It mints 10,000 test USDC to the wallet. Confirm the wallet transaction.
  4. Open the Account dialog. Select the market. Enter an amount in the deposit field, then select Approve and deposit. Confirm the approval and the deposit in the wallet.
  5. In the same dialog, select Enable on the trading session row. The main wallet signs one authorization.
  6. Place a small order. The session key signs it. The relayer submits it.

Move the oracle price ​

While pnpm demo serve runs, send a price shock from a fifth terminal:

sh
pnpm demo shock MON -4

The loop applies the percent at the next observation of that market. The squared return shows in the funding of that observation.

Next steps ​

GoalPage
Understand each local step, the accounts, and the optionsRun the local exchange
Run the LP hedge story from the Hedging demo pageHedging demo
Use the public Monad testnetRun on Monad testnet
Run the testsChecks and troubleshooting

Deployed on Monad testnet.