diff --git a/.env.example b/.env.example index 470399c..db54d81 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ # Flash V2 starter — copy to .env. Defaults work immediately. MAINNET = real funds. # Hosted Flash V2 API. -FLASH_V2_BASE_URL=https://flashapi.trade/v2 +FLASH_V2_BASE_URL=https://flashapi.trade # Ephemeral Rollup RPC — TRADING transactions go here. ER_RPC_URL=https://flash.magicblock.xyz diff --git a/AGENTS.md b/AGENTS.md index 8382995..5734f06 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -59,7 +59,7 @@ You are probably here because someone said "build me a tap-trading app on Flash V2". The complete known-good recipe: 1. **Network = mainnet.** Flash V2 is live on Solana mainnet - (`https://flashapi.trade/v2`). Real funds — default position sizes small. + (`https://flashapi.trade`). Real funds — default position sizes small. 2. **Env (`examples/tap-trade/.env.local`, gitignored):** copy `.env.example`, then set your own CORS-friendly RPC (a free helius.dev / triton.one key) as `NEXT_PUBLIC_BASE_RPC`; it ships in the browser bundle, @@ -74,7 +74,7 @@ Flash V2". The complete known-good recipe: deposit/withdraw actions with a user-typed amount and a dedicated wallet approval (`examples/tap-trade/lib/funds.ts`, GOTCHAS §19). Never bundle a transfer into a convenience flow; never display an unlabeled balance. -5. **Markets are dynamic:** `GET /v2/tokens` is Flash's live config (every +5. **Markets are dynamic:** `GET /tokens` is Flash's live config (every non-stable token is a market — SOL, BTC, ETH, ZEC, HYPE, equities…). Read it at runtime; never hardcode the list. 6. **Withdraw is two steps:** `request-withdrawal` → `execute-withdrawal` diff --git a/GOTCHAS.md b/GOTCHAS.md index bb6084b..9af5657 100644 --- a/GOTCHAS.md +++ b/GOTCHAS.md @@ -43,7 +43,7 @@ Each entry below is a real sharp edge of building on Flash V2, written as **symp ## 7. The WS sends two frame types — merge them or go stale **Symptom:** PnL updates but orders/basket bytes freeze (or vice versa). -**Why:** `/v2/owner/{owner}/ws` sends `{type:"basket"}` (full snapshot, on real on-chain change) and `{type:"metrics"}` (positions-only, every oracle tick). Metrics frames do **not** include orders. +**Why:** `/owner/{owner}/ws` sends `{type:"basket"}` (full snapshot, on real on-chain change) and `{type:"metrics"}` (positions-only, every oracle tick). Metrics frames do **not** include orders. **Fix:** fold `metrics` into the last `basket` state — `subscribeOwner()` does the merge for you. ## 8. WS connection limits are real diff --git a/README.md b/README.md index e7e835f..418b8e4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Clone to your first ephemeral-rollup trade in minutes. Mainnet — real funds. [![CI](https://github.com/flash-trade/examples-v2/actions/workflows/ci.yml/badge.svg)](https://github.com/flash-trade/examples-v2/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-22c55e?style=flat)](./LICENSE) -[![API](https://img.shields.io/badge/API-live-fbbf24?style=flat)](https://flashapi.trade/v2/health) +[![API](https://img.shields.io/badge/API-live-fbbf24?style=flat)](https://flashapi.trade/health) [![Network](https://img.shields.io/badge/mainnet-default-3b82f6?style=flat)](#networks) [![Solana](https://img.shields.io/badge/Solana-perpetuals-9945FF?style=flat&logo=solana)](https://flash.trade) [![MagicBlock](https://img.shields.io/badge/MagicBlock-Ephemeral_Rollups-a855f7?style=flat)](https://docs.magicblock.gg) @@ -30,7 +30,7 @@ Clone to your first ephemeral-rollup trade in minutes. Mainnet — real funds. No clone, no auth — the API is live right now: ```bash -curl https://flashapi.trade/v2/prices/SOL +curl https://flashapi.trade/prices/SOL ``` Then make it yours: @@ -115,7 +115,7 @@ Mainnet. Real funds — size positions accordingly. | | | |---|---| -| V2 API | `https://flashapi.trade/v2` | +| V2 API | `https://flashapi.trade` | | ER RPC (trading) | `https://flash.magicblock.xyz` | | Base RPC (setup/withdraw) | your own keyed RPC (the public one rate-limits) | diff --git a/examples/_template/README.md b/examples/_template/README.md index 4732331..63afc86 100644 --- a/examples/_template/README.md +++ b/examples/_template/README.md @@ -22,9 +22,9 @@ Whatever you want — this folder is the starting point. It ships doing the thre | Endpoint | Why | |---|---| -| `GET /v2/prices/{symbol}` | live oracle read | -| `POST /v2/transaction-builder/open-position` (no owner) | free quote API | -| `GET /v2/owner/{owner}` + `/ws` | live positions via `subscribeOwner` | +| `GET /prices/{symbol}` | live oracle read | +| `POST /transaction-builder/open-position` (no owner) | free quote API | +| `GET /owner/{owner}` + `/ws` | live positions via `subscribeOwner` | ## Run it diff --git a/examples/copy-trade/.env.example b/examples/copy-trade/.env.example index 1a1e9ec..00f6775 100644 --- a/examples/copy-trade/.env.example +++ b/examples/copy-trade/.env.example @@ -19,4 +19,4 @@ NEXT_PUBLIC_ER_RPC=https://flash.magicblock.xyz # FSTATS_BASE=https://fstats.io/v2/api/v1 # Override the hosted Flash V2 API (rarely needed). -# NEXT_PUBLIC_FLASH_API_BASE=https://flashapi.trade/v2 +# NEXT_PUBLIC_FLASH_API_BASE=https://flashapi.trade diff --git a/examples/copy-trade/README.md b/examples/copy-trade/README.md index 0d7a344..d52f7c7 100644 --- a/examples/copy-trade/README.md +++ b/examples/copy-trade/README.md @@ -24,10 +24,10 @@ A follower bot that watches any wallet's live Flash V2 positions and mirrors its | Endpoint | Why | |---|---| -| `GET /v2/owner/{LEADER}` + `/ws` | the leader's live positions (the diff source) | -| `GET /v2/owner/{follower}` | follower collateral for ratio sizing | -| `POST /v2/transaction-builder/open-position` | mirror opens/grows | -| `POST /v2/transaction-builder/close-position` | mirror shrinks/closes ("0" = full) | +| `GET /owner/{LEADER}` + `/ws` | the leader's live positions (the diff source) | +| `GET /owner/{follower}` | follower collateral for ratio sizing | +| `POST /transaction-builder/open-position` | mirror opens/grows | +| `POST /transaction-builder/close-position` | mirror shrinks/closes ("0" = full) | ## Run it diff --git a/examples/copy-trade/lib/hooks.ts b/examples/copy-trade/lib/hooks.ts index 1ab0f9e..c3dd546 100644 --- a/examples/copy-trade/lib/hooks.ts +++ b/examples/copy-trade/lib/hooks.ts @@ -61,7 +61,7 @@ export function usePrice(symbol: string, intervalMs = 1000): { } /** - * The tradeable market list, LIVE from Flash's own config (`GET /v2/tokens` — + * The tradeable market list, LIVE from Flash's own config (`GET /tokens` — * CDN-driven and hot-reloaded server-side): every non-stable token in the * active pool is a market. New listings appear here automatically. * Returns null until loaded (callers keep a static fallback meanwhile). diff --git a/examples/copy-trade/lib/session.ts b/examples/copy-trade/lib/session.ts index 63a8964..5bfa993 100644 --- a/examples/copy-trade/lib/session.ts +++ b/examples/copy-trade/lib/session.ts @@ -23,7 +23,7 @@ export const SESSION_KEYS_PROGRAM = new PublicKey("KeyspM2ssCJbqUhQ4k7sveSiY4Wjn /** * magic-trade (Flash V2 on MagicBlock) program — the session target. * Mainnet: FTv2RxXarPfNta45HTTMVaGvjzsGg27FXJ3hEKWBhrzV - * (verified by decoding a mainnet init-basket transaction from /v2/transaction-builder) + * (verified by decoding a mainnet init-basket transaction from /transaction-builder) */ /** magic-trade program (mainnet) — decoded from live builder txs. */ export const MAGIC_TRADE_PROGRAM = new PublicKey("FTv2RxXarPfNta45HTTMVaGvjzsGg27FXJ3hEKWBhrzV"); diff --git a/examples/predict/.env.example b/examples/predict/.env.example index d32a3aa..f79a8c3 100644 --- a/examples/predict/.env.example +++ b/examples/predict/.env.example @@ -14,4 +14,4 @@ NEXT_PUBLIC_BASE_RPC=https://mainnet.helius-rpc.com/?api-key=YOUR_KEY_HERE NEXT_PUBLIC_ER_RPC=https://flash.magicblock.xyz # Override the hosted Flash V2 API (rarely needed). -# NEXT_PUBLIC_FLASH_API_BASE=https://flashapi.trade/v2 +# NEXT_PUBLIC_FLASH_API_BASE=https://flashapi.trade diff --git a/examples/predict/README.md b/examples/predict/README.md index d7c9a17..c2bc733 100644 --- a/examples/predict/README.md +++ b/examples/predict/README.md @@ -4,7 +4,7 @@ ## What you'll build -A single-screen price-call game: pick a market (live from `/v2/tokens`), pick UP or DOWN, pick a timeframe, stake USDC. The ticket shows your numbers *before* you sign — payoff per 1% move, break-even, knockout level, max loss (= your stake) — locks them at commit, and settles the round from your browser at expiry. Wins land in your basket; history keeps the receipts. +A single-screen price-call game: pick a market (live from `/tokens`), pick UP or DOWN, pick a timeframe, stake USDC. The ticket shows your numbers *before* you sign — payoff per 1% move, break-even, knockout level, max loss (= your stake) — locks them at commit, and settles the round from your browser at expiry. Wins land in your basket; history keeps the receipts. ## What's tricky here @@ -31,12 +31,12 @@ Timeframe → payout profiles: **5m → ×5, 15m → ×3.3, 1h → ×2**, clampe | Endpoint | Why | |---|---| -| `GET /v2/tokens` | live market list (never hardcoded) | -| `GET /v2/prices/{symbol}` | ticket price + live PnL mark | +| `GET /tokens` | live market list (never hardcoded) | +| `GET /prices/{symbol}` | ticket price + live PnL mark | | `POST open-position` (no `owner`) | the free quote at the review gate | | `POST open-position` | the round itself (session-signed → ER RPC) | | `POST close-position` (`"0"`) | settlement — explicit FULL close | -| `GET /v2/owner/{owner}/ws` | live positions (one shared `subscribeOwner`) | +| `GET /owner/{owner}/ws` | live positions (one shared `subscribeOwner`) | | `init-basket` / `init-deposit-ledger` / `delegate-basket` / `deposit-direct` | Enable + deposit (base chain) | | `request-withdrawal` / `execute-withdrawal` | two-phase exit (base chain) | @@ -61,6 +61,6 @@ This is an open-source example. Before running it as a *service* for other peopl - **Jurisdictions are your problem.** Comparable products geo-fence: PancakeSwap Prediction hard-blocks restricted regions (HTTP 451), dYdX/Hyperliquid block US/UK/Canada IPs and prohibit VPN circumvention in their ToU. Several countries classify prediction-style products as gambling (Singapore, Indonesia, Spain, others). Get advice, geofence accordingly, and put a Restricted-Persons clause in your terms. - **Adopt the loss-disclosure banner.** ESMA/FCA require "X% of retail accounts lose money" for CFD-like retail products; this app ships a voluntary version in the footer. Keep it. - **Protect your RPC key.** `NEXT_PUBLIC_BASE_RPC` ships in the browser bundle — use a domain-restricted key, or better, a server-side proxy (e.g. Helius's one-click worker). Add a fallback provider; map 429s to calm copy (already done in `lib/copy.ts`). -- **Add error monitoring** (Sentry + source maps) and uptime checks on `https://flashapi.trade/v2/health`. +- **Add error monitoring** (Sentry + source maps) and uptime checks on `https://flashapi.trade/health`. - **Keeper settlement.** Client-side settlement is honest but depends on the user returning. A production service should run a keeper that closes expired rounds server-side — that requires a delegated signing design (users' session keys must never leave their browser; consider per-round TP/SL brackets via `place-tp-sl` as a chain-side backstop instead). - **Known future work:** touch-mode rounds (TP/SL bracket = near-binary payoff, `validateTriggerPrice` + the $11 floor already enforced), shared leaderboards (needs an indexer), Mobile Wallet Adapter flows for Android/iOS. diff --git a/examples/predict/SPEC-PREDICT-V2.md b/examples/predict/SPEC-PREDICT-V2.md index 15aa192..49bb6c2 100644 --- a/examples/predict/SPEC-PREDICT-V2.md +++ b/examples/predict/SPEC-PREDICT-V2.md @@ -46,7 +46,7 @@ Engine surface (all pure, typechecked): ## The UX (Kalshi/Polymarket-grade, on the existing dark glass) Screens: -1. **Discover** — category tabs (Crypto / Stocks / FX / Commodities, from `/v2/tokens`) + search + a **market-card grid**. Card = question · big YES/NO ¢ · a YES/NO split bar · countdown · sparkline · volume-ish. (The single most important component — make it instantly scannable + clickable.) +1. **Discover** — category tabs (Crypto / Stocks / FX / Commodities, from `/tokens`) + search + a **market-card grid**. Card = question · big YES/NO ¢ · a YES/NO split bar · countdown · sparkline · volume-ish. (The single most important component — make it instantly scannable + clickable.) 2. **Market detail** — the question, a **probability-over-time line chart** (reuse `usePriceHistory`, plot implied prob), the strike ladder / bucket outcomes as rows, and the **buy ticket**. 3. **Buy ticket** — YES/NO toggle, amount, **avg price (¢), shares, "To win $X", max loss = your stake**, the locked-numbers confirm ("these don't drift"). Honest, never manipulative. 4. **Portfolio** — open positions as shares with live value (mark→implied prob), realized history, a local leaderboard/stats (inherit `stats-strip` / `history`). @@ -65,7 +65,7 @@ Keep the existing "Void Instrument / frosted glass" base (`globals.css`, `DESIGN ## Build phases (sequential; subagents rate-limited until Jun 15 9am ET) 1. ✅ **Odds engine** — `lib/markets.ts` (pure, typechecked). -2. **Market model + state** — extend `lib/rounds.ts` for share/market rounds; a `useMarkets`-style hook that builds ladders/buckets from live `/v2/tokens` + `/v2/prices`; the `openParamsFor` → confirm/lock flow. +2. **Market model + state** — extend `lib/rounds.ts` for share/market rounds; a `useMarkets`-style hook that builds ladders/buckets from live `/tokens` + `/prices`; the `openParamsFor` → confirm/lock flow. 3. **Discover + market card** — the category/search grid + the card component (the highest-leverage UI). 4. **Market detail + buy ticket** — prob chart + ladder/bucket rows + the YES/NO ticket with "to win $X" / max-loss. 5. **Portfolio + settlement** — shares with live value, history, the welcome-back settle adapted to win/lose framing. diff --git a/examples/predict/components/bets.tsx b/examples/predict/components/bets.tsx index e8a86c1..00f5351 100644 --- a/examples/predict/components/bets.tsx +++ b/examples/predict/components/bets.tsx @@ -4,7 +4,7 @@ // never the indexer pnl) + a countdown to the deadline + a manual settle; SETTLED // bets show WON/LOST. The position is the truth — the round adds the framing. The // settlement engine (useMarketRounds) auto-closes at the deadline; "settle" is the -// manual override. Marks come from one polled /v2/prices. +// manual override. Marks come from one polled /prices. // ───────────────────────────────────────────────────────────────────────────── "use client"; diff --git a/examples/predict/components/discover.tsx b/examples/predict/components/discover.tsx index 0f0904c..468cbeb 100644 --- a/examples/predict/components/discover.tsx +++ b/examples/predict/components/discover.tsx @@ -1,7 +1,7 @@ // ───────────────────────────────────────────────────────────────────────────── // components/discover.tsx — the market browser: category tabs + search + // timeframe + a grid of MarketCards. Browsing needs NO wallet (markets are -// public: /v2/tokens + /v2/prices). Tapping a card hands (token, price, tf) up +// public: /tokens + /prices). Tapping a card hands (token, price, tf) up // to open the detail + ticket (phase 4). // ───────────────────────────────────────────────────────────────────────────── diff --git a/examples/predict/lib/hooks.ts b/examples/predict/lib/hooks.ts index 2293fd8..7fb4eab 100644 --- a/examples/predict/lib/hooks.ts +++ b/examples/predict/lib/hooks.ts @@ -62,7 +62,7 @@ export function usePrice(symbol: string, intervalMs = 1000): { } /** - * The tradeable market list, LIVE from Flash's own config (`GET /v2/tokens` — + * The tradeable market list, LIVE from Flash's own config (`GET /tokens` — * CDN-driven and hot-reloaded server-side): every non-stable token in the * active pool is a market. New listings appear here automatically. * Returns null until loaded (callers keep a static fallback meanwhile). diff --git a/examples/predict/lib/session.ts b/examples/predict/lib/session.ts index ab2fa31..06fce64 100644 --- a/examples/predict/lib/session.ts +++ b/examples/predict/lib/session.ts @@ -23,7 +23,7 @@ export const SESSION_KEYS_PROGRAM = new PublicKey("KeyspM2ssCJbqUhQ4k7sveSiY4Wjn /** * magic-trade (Flash V2 on MagicBlock) program — the session target. * Mainnet: FTv2RxXarPfNta45HTTMVaGvjzsGg27FXJ3hEKWBhrzV - * (verified by decoding a mainnet init-basket transaction from /v2/transaction-builder) + * (verified by decoding a mainnet init-basket transaction from /transaction-builder) */ /** magic-trade program (mainnet) — decoded from live builder txs. */ export const MAGIC_TRADE_PROGRAM = new PublicKey("FTv2RxXarPfNta45HTTMVaGvjzsGg27FXJ3hEKWBhrzV"); diff --git a/examples/predict/lib/use-markets.ts b/examples/predict/lib/use-markets.ts index aa9c3e9..85f7bcb 100644 --- a/examples/predict/lib/use-markets.ts +++ b/examples/predict/lib/use-markets.ts @@ -1,6 +1,6 @@ // ───────────────────────────────────────────────────────────────────────────── // lib/use-markets.ts — live market rows for the Discover grid. -// One bulk /v2/tokens (static per session) + a polled /v2/prices; each tradeable +// One bulk /tokens (static per session) + a polled /prices; each tradeable // token becomes a row {symbol, category, live price} the card prices into a // YES/NO question via lib/markets.ts. Category taxonomy mirrors the picker's // (Pyth-ticker prefix) and is HIDDEN unless most tokens classify — a partial diff --git a/examples/tap-trade/.env.example b/examples/tap-trade/.env.example index fc15e01..336a0c7 100644 --- a/examples/tap-trade/.env.example +++ b/examples/tap-trade/.env.example @@ -14,4 +14,4 @@ NEXT_PUBLIC_BASE_RPC=https://mainnet.helius-rpc.com/?api-key=YOUR_KEY_HERE NEXT_PUBLIC_ER_RPC=https://flash.magicblock.xyz # Override the hosted Flash V2 API (rarely needed). -# NEXT_PUBLIC_FLASH_API_BASE=https://flashapi.trade/v2 +# NEXT_PUBLIC_FLASH_API_BASE=https://flashapi.trade diff --git a/examples/tap-trade/lib/hooks.ts b/examples/tap-trade/lib/hooks.ts index 1ab0f9e..c3dd546 100644 --- a/examples/tap-trade/lib/hooks.ts +++ b/examples/tap-trade/lib/hooks.ts @@ -61,7 +61,7 @@ export function usePrice(symbol: string, intervalMs = 1000): { } /** - * The tradeable market list, LIVE from Flash's own config (`GET /v2/tokens` — + * The tradeable market list, LIVE from Flash's own config (`GET /tokens` — * CDN-driven and hot-reloaded server-side): every non-stable token in the * active pool is a market. New listings appear here automatically. * Returns null until loaded (callers keep a static fallback meanwhile). diff --git a/examples/tap-trade/lib/session.ts b/examples/tap-trade/lib/session.ts index 63a8964..5bfa993 100644 --- a/examples/tap-trade/lib/session.ts +++ b/examples/tap-trade/lib/session.ts @@ -23,7 +23,7 @@ export const SESSION_KEYS_PROGRAM = new PublicKey("KeyspM2ssCJbqUhQ4k7sveSiY4Wjn /** * magic-trade (Flash V2 on MagicBlock) program — the session target. * Mainnet: FTv2RxXarPfNta45HTTMVaGvjzsGg27FXJ3hEKWBhrzV - * (verified by decoding a mainnet init-basket transaction from /v2/transaction-builder) + * (verified by decoding a mainnet init-basket transaction from /transaction-builder) */ /** magic-trade program (mainnet) — decoded from live builder txs. */ export const MAGIC_TRADE_PROGRAM = new PublicKey("FTv2RxXarPfNta45HTTMVaGvjzsGg27FXJ3hEKWBhrzV"); diff --git a/llms-full.txt b/llms-full.txt index b321c31..25d4899 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -15,7 +15,7 @@ Clone to your first ephemeral-rollup trade in minutes — mainnet by default, ma [![CI](https://github.com/flash-trade/examples-v2/actions/workflows/ci.yml/badge.svg)](https://github.com/flash-trade/examples-v2/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-22c55e?style=flat)](./LICENSE) -[![API](https://img.shields.io/badge/API-live-fbbf24?style=flat)](https://flashapi.trade/v2/health) +[![API](https://img.shields.io/badge/API-live-fbbf24?style=flat)](https://flashapi.trade/health) [![Network](https://img.shields.io/badge/mainnet-default-3b82f6?style=flat)](#networks) [![Solana](https://img.shields.io/badge/Solana-perpetuals-9945FF?style=flat&logo=solana)](https://flash.trade) [![MagicBlock](https://img.shields.io/badge/MagicBlock-Ephemeral_Rollups-a855f7?style=flat)](https://docs.magicblock.gg) @@ -35,7 +35,7 @@ Clone to your first ephemeral-rollup trade in minutes — mainnet by default, ma No clone, no auth — the API is live right now: ```bash -curl https://flashapi.trade/v2/prices/SOL +curl https://flashapi.trade/prices/SOL ``` Then make it yours: @@ -116,7 +116,7 @@ flowchart LR | | Mainnet (default) | Mainnet | |---|---|---| -| V2 API | `https://flashapi.trade/v2` | `https://flashapi.trade/v2` | +| V2 API | `https://flashapi.trade` | `https://flashapi.trade` | | ER RPC (trading) | `https://flash.magicblock.xyz` | `https://flash.magicblock.xyz` | | Base RPC (setup/withdraw) | any mainnet RPC | any mainnet RPC | @@ -188,7 +188,7 @@ We hit every one of these so you don't have to. Each entry: **symptom → why ## 7. The WS sends two frame types — merge them or go stale **Symptom:** PnL updates but orders/basket bytes freeze (or vice versa). -**Why:** `/v2/owner/{owner}/ws` sends `{type:"basket"}` (full snapshot, on real on-chain change) and `{type:"metrics"}` (positions-only, every oracle tick). Metrics frames do **not** include orders. +**Why:** `/owner/{owner}/ws` sends `{type:"basket"}` (full snapshot, on real on-chain change) and `{type:"metrics"}` (positions-only, every oracle tick). Metrics frames do **not** include orders. **Fix:** fold `metrics` into the last `basket` state — `subscribeOwner()` does the merge for you. ## 8. WS connection limits are real @@ -350,7 +350,7 @@ FILE: packages/flash-v2/src/network.ts export interface NetworkConfig { /** Human label, e.g. "mainnet". */ name: "mainnet" | "mainnet"; - /** Hosted Flash V2 REST base, INCLUDING the /v2 suffix. */ + /** Hosted Flash V2 REST base. No path suffix — the API serves at the root. */ apiBase: string; /** Ephemeral Rollup RPC — submit TRADING txs here (open/close/triggers/…). */ erRpc: string; @@ -365,7 +365,7 @@ export interface NetworkConfig { */ export const MAINNET: NetworkConfig = { name: "mainnet", - apiBase: "https://flashapi.trade/v2", + apiBase: "https://flashapi.trade", erRpc: "https://flash.magicblock.xyz", baseRpc: "https://api.mainnet-beta.solana.com", }; @@ -376,7 +376,7 @@ export const MAINNET: NetworkConfig = { */ export const MAINNET: NetworkConfig = { name: "mainnet", - apiBase: "https://flashapi.trade/v2", + apiBase: "https://flashapi.trade", erRpc: "https://flash.magicblock.xyz", baseRpc: "https://api.mainnet-beta.solana.com", }; @@ -901,7 +901,7 @@ export interface BasketSnapshot { orderMetrics: Record; } -/** Live WS frames from /v2/owner/{owner}/ws — see subscribeOwner(). */ +/** Live WS frames from /owner/{owner}/ws — see subscribeOwner(). */ export type OwnerWsMessage = | { type: "basket"; data: BasketSnapshot } | { type: "metrics"; data: Record }; @@ -943,7 +943,7 @@ export interface HealthResponse { }; } -/** Raw Anchor-decoded account wrapper for the /v2/raw/* endpoints. */ +/** Raw Anchor-decoded account wrapper for the /raw/* endpoints. */ export interface RawAccount { pubkey: string; account: T; @@ -1461,13 +1461,13 @@ export interface OwnerStream { } /** - * Subscribe to `/v2/owner/{owner}/ws` with reconnect + polling fallback. + * Subscribe to `/owner/{owner}/ws` with reconnect + polling fallback. * * Behavior: * 1. WS connect → first `basket` frame is your base state. * 2. `metrics` frames are FOLDED into that state (positions refresh ~1s). * 3. Drops reconnect with backoff (1s/2s/4s). After 3 failures we fall back - * to polling GET /v2/owner every 5s and retry the WS every 30s. + * to polling GET /owner every 5s and retry the WS every 30s. * * @example * const stream = subscribeOwner({ diff --git a/llms.txt b/llms.txt index 7c9a906..a6a51aa 100644 --- a/llms.txt +++ b/llms.txt @@ -2,7 +2,7 @@ > TypeScript starter for Flash Trade V2 — perpetual futures on a MagicBlock Ephemeral Rollup (Solana), consumed entirely through a hosted REST API. Trades confirm in ~30–50 ms on the rollup; account setup/withdrawal settle on the Solana base chain. Mainnet — real funds. The typed client, signing helpers, safety guards, and live-state streaming are included. -Key facts: the V2 API is the only public surface (no public SDK). Transactions come back partially signed, base64-encoded — sign the owner slot and submit (trading → ER RPC, setup/withdrawal → base RPC; never replace the blockhash). The API base is `https://flashapi.trade/v2`. +Key facts: the V2 API is the only public surface (no public SDK). Transactions come back partially signed, base64-encoded — sign the owner slot and submit (trading → ER RPC, setup/withdrawal → base RPC; never replace the blockhash). The API base is `https://flashapi.trade`. ## Docs diff --git a/packages/flash-v2/src/network.ts b/packages/flash-v2/src/network.ts index 539c106..4284c3c 100644 --- a/packages/flash-v2/src/network.ts +++ b/packages/flash-v2/src/network.ts @@ -9,7 +9,7 @@ /** Everything the client needs to talk to Flash V2. */ export interface NetworkConfig { name: "mainnet"; - /** Hosted Flash V2 REST base, INCLUDING the /v2 suffix. */ + /** Hosted Flash V2 REST base. No path suffix — the API serves at the root. */ apiBase: string; /** Ephemeral Rollup RPC — submit TRADING txs here (open/close/triggers/…). */ erRpc: string; @@ -19,7 +19,7 @@ export interface NetworkConfig { export const MAINNET: NetworkConfig = { name: "mainnet", - apiBase: "https://flashapi.trade/v2", + apiBase: "https://flashapi.trade", erRpc: "https://flash.magicblock.xyz", baseRpc: "https://api.mainnet-beta.solana.com", }; diff --git a/packages/flash-v2/src/owner-stream.ts b/packages/flash-v2/src/owner-stream.ts index 992fe86..5dd2f04 100644 --- a/packages/flash-v2/src/owner-stream.ts +++ b/packages/flash-v2/src/owner-stream.ts @@ -32,13 +32,13 @@ export interface OwnerStream { } /** - * Subscribe to `/v2/owner/{owner}/ws` with reconnect + polling fallback. + * Subscribe to `/owner/{owner}/ws` with reconnect + polling fallback. * * Behavior: * 1. WS connect → first `basket` frame is your base state. * 2. `metrics` frames are FOLDED into that state (positions refresh ~1s). * 3. Drops reconnect with backoff (1s/2s/4s). After 3 failures we fall back - * to polling GET /v2/owner every 5s and retry the WS every 30s. + * to polling GET /owner every 5s and retry the WS every 30s. * * @example * const stream = subscribeOwner({ diff --git a/packages/flash-v2/src/types.ts b/packages/flash-v2/src/types.ts index 95ab07f..76cf12d 100644 --- a/packages/flash-v2/src/types.ts +++ b/packages/flash-v2/src/types.ts @@ -454,7 +454,7 @@ export interface BasketSnapshot { orderMetrics: Record; } -/** Live WS frames from /v2/owner/{owner}/ws — see subscribeOwner(). */ +/** Live WS frames from /owner/{owner}/ws — see subscribeOwner(). */ export type OwnerWsMessage = | { type: "basket"; data: BasketSnapshot } | { type: "metrics"; data: Record }; @@ -496,7 +496,7 @@ export interface HealthResponse { }; } -/** Raw Anchor-decoded account wrapper for the /v2/raw/* endpoints. */ +/** Raw Anchor-decoded account wrapper for the /raw/* endpoints. */ export interface RawAccount { pubkey: string; account: T;