DEX Zyga UI - Raydium Swap Interface
Next.js UI plus independent TypeScript backend services for Raydium CPMM swaps and Zyga proof generation.
Architecture
apps/web: Next.js 14 UI. It only talks to the public API and signs/sends returned transactions.services/api: public HTTP API for quotes, swap transaction construction, faucet requests, health, and OpenAPI.services/proof-worker: private HTTP worker that owns the Zyga binary/circuit and returns proof instruction bytes.packages/contracts: shared request/response types, runtime parsers, and OpenAPI source.
The proof worker is intentionally isolated so it can be replaced by a Rust service later without changing the public API contract.
API
POST /api/v1/quotesPOST /api/v1/swap-transactionsPOST /api/v1/faucet/requestsGET /healthGET /openapi.json- Internal only:
POST /internal/v1/slippage-proofson the proof worker
Development
pnpm install
cp .env.local.devnet .env.local
pnpm dev:proof-worker
pnpm dev:api
pnpm dev:web
For the compose setup:
./pscripts/start-web.sh
Container Releases
GitHub Actions builds the three service images on pull requests and publishes them to ECR on pushes to main or v* tags.
The publishing workflow requires the repository variable AWS_ROLE_ARN to contain an AWS OIDC role that can push to:
220898748818.dkr.ecr.us-east-1.amazonaws.com/zyga-swap-web220898748818.dkr.ecr.us-east-1.amazonaws.com/zyga-swap-api220898748818.dkr.ecr.us-east-1.amazonaws.com/zyga-swap-proof-worker
Published images are tagged with the short git SHA. Pushes to main also update the main tag, and release tags also publish the matching tag.
Environment
NEXT_PUBLIC_NETWORK=devnet
NETWORK=devnet
NEXT_PUBLIC_API_BASE_URL=/api/v1
NEXT_PUBLIC_HELIUS_API_KEY=your_helius_api_key_here
HELIUS_API_KEY=your_helius_api_key_here
# or RPC_ENDPOINT=https://api.devnet.solana.com
FAUCET_PRIVATE_KEY=[1,2,3,4,5]
PROOF_WORKER_URL=http://localhost:4100
Notes
- The extraction preserves current Zyga proof semantics. The worker validates
actualAmount > minAmount, while the circuit input still provesactualAmount > actualAmount - 1; this is documented in code and should be audited separately. - Next no longer serves backend API routes.
- Nginx proxies
/api/v1/*toservices/apiand keepsservices/proof-workerprivate to the compose network.