A ready-to-fork trading interface for builders on Nectar. A builder is a team that runs its own front end on top of Nectar's perpetuals and earns a builder fee on every order its users place.
The kit has three parts:
- Trade: what your traders use. Markets, price chart, order book, recent trades, an order form that shows fees before signing, and order history.
- Builder dashboard: your profile, fees earned, users, trades and fee-rate settings.
- API Explorer and Inspector: every endpoint the kit uses, plus the exact request and response of every call.
The Builder Fee API is not live yet, so the kit runs against a mock backend in the browser by default. It uses the same request format as the real API and checks real wallet signatures. Switching to the real API takes one setting.
You need Node 18+ and Yarn 4 (run corepack enable to get the right version).
yarn install
yarn start # opens on http://localhost:3020Other commands:
yarn test:ci # run tests
yarn tscheck # type check
yarn build # production build to dist/
yarn preview # serve the build- Open Trade and press Sign in. Open the API Inspector at the bottom to see each request.
- Enter a size and press Review long. The form shows the base fee and the builder fee.
- Press Sign & submit. Your order shows as Open, then Executed about 4 seconds later.
- In the header, switch to Demo builder (PerpDesk), open Builder dashboard and sign in. Your trade is at the top of Attributed trades.
- Change the fee rate in Settings, go back to Trade, and place another order. The new rate applies.
Tip: click any endpoint badge (like GET /builders/me/stats 200) to jump to that call in the inspector.
- Sign in. Your interface asks for a sign-in nonce with your builder ID. The trader signs it, and the session now belongs to your builder.
- Prepare. The interface sends the order without fees. The API returns the order with the base fee and your builder fee added.
- Check. The interface confirms the returned order matches what the trader asked for and the fees shown.
- Sign and submit. The trader signs the order exactly as returned. The API relays it, and when it executes, the builder fee goes to your wallet.
Fee formula: builder fee = order size × fee rate (bps) / 10,000. A $10,000 order at 5 bps earns you $5.
Key rules:
- The client never sends fee amounts. The backend adds them.
- Changing the builder means signing in again.
- If a builder is unknown or frozen, sign-in still works, just without a builder.
- Editing a prepared order in any way (fees included) makes the signature fail.
- Fee rate must stay between 0 and your cap, and the cap is at most 10 bps.
| Endpoint | Used for |
|---|---|
GET /auth/nonce, POST /auth/verify |
Sign-in |
GET /auth |
Current session and builder fee rate |
GET /oracle-keeper/prices/tickers, /24h, /candles |
Prices and chart |
GET /orderbooks/:symbol |
Order book |
GET /trades/:symbol |
Recent trades |
GET /accounts/:account/orders |
Your orders |
POST /orders/prepare, POST /orders/submit |
Placing an order |
GET /builders/me, /stats, /users, /trades |
Builder dashboard |
PATCH /builders/:builderId |
Fee-rate settings |
All endpoints are defined in src/api/catalog.ts, and the React hooks are in src/hooks/queries.ts.
The mock lives in src/mock/ and runs entirely in your browser. Sign-in and order signatures are verified for real.
Prices, trades and builders are sample data. Reloading the page resets everything.
Demo wallets (public test keys, never send funds to them):
| Wallet | Address |
|---|---|
| Demo trader | 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 |
| Demo builder (PerpDesk) | 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 |
Sample builders: PerpDesk (default), YieldLens, Orbit Wallet, Kite Mobile (rate limited), Lumen Bot (frozen) and Swiftfill (blacklisted).
Copy .env.example to .env.local and set:
VITE_API_MODE=live
VITE_NECTAR_API_URL=https://api.nectar.finance
VITE_BUILDER_ID=<your builder ID from Nectar>Before you launch:
- The API allows requests from your domain (CORS).
- Use a browser wallet (demo wallets are hidden in live mode).
- Switch your wallet to AssetChain testnet (42421) before signing orders.
- Review the open questions below with the backend team.
- Set
VITE_BUILDER_IDso every sign-in is credited to you. - Share your link from the dashboard:
https://your.app/#/trade?builderId=<id>. - Keep
src/api/,src/lib/andsrc/context/WalletContext.tsx. This is the integration. - Replace
src/pages/with your own design. - Using wagmi or RainbowKit? Implement the
WalletSignerinterface insrc/lib/wallet.ts. - Once live, delete
src/mock/and optionally the API Inspector.
Things the API spec doesn't settle yet. The mock makes a choice for each, so confirm them before going live.
- No collateral amount on
/orders/prepare, so leverage can't be set. - No trigger price, so only market orders are supported.
acceptablePricescaling is unclear.eip712Payloadhas noprimaryTypefield.- No fee history endpoint, so the fees chart pages through trades.
- Pagination differs between
/builders/me/usersand/builders/me/trades. - No positions endpoint, so Trade shows orders only.
- Recent trades don't include a buy/sell side.
- Some auth error codes and builder statuses aren't defined.
| Variable | Default | Purpose |
|---|---|---|
VITE_API_MODE |
mock |
mock or live |
VITE_NECTAR_API_URL |
http://localhost:3333 |
API URL in live mode |
VITE_BUILDER_ID |
PerpDesk in mock mode | Builder that sign-ins are credited to |
Other settings are in src/config.ts.
Built with: React 18, TypeScript, Vite, TanStack Query, Tailwind, viem, lightweight-charts and Recharts.