feat(templates): add raydium-hello-world community template - #449
Conversation
App shell, wallet connection (devnet-first), and component structure for a Raydium CPMM swap starter. SDK integration marked as TODO(raydium) in use-pool.ts, lib/raydium.ts and swap-card.tsx. README documents the devnet pool-discovery endpoint and faucet guidance.
Bring the template in line with the kit-family design spec: Solana-branded GridBackground (brand colors in the grid only), Inter + Geist Mono, the neutral token set with cream/border-low, shadcn ui primitives, next-themes dark mode with toggle, sonner toasts, wallet-adapter button restyled to neutral, and explorer/ellipsify utils. Cluster is intentionally pinned to devnet, so no ClusterSelect.
Pool fetch from RPC, local CurveCalculator quoting, wallet-signed devnet swap. Applies triple-review findings: quote/amount atomic pairing, swapResult cloned before cpmm.swap (SDK mutates it in place), env.example shipped via gitignore exception, README trued up to the implementation, copy-full-signature affordance, wallet errors surfaced as toasts. Reverts accidental pnpm allowBuilds scaffold in pnpm-workspace.yaml. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Greptile SummaryThe PR adds a devnet-first Raydium CPMM swap template using Next.js, wallet-adapter, and Raydium SDK v2.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant UI as Swap UI
participant P as usePool
participant S as useSwap
participant R as Raydium/Solana
P->>R: Load pool and reserves
R-->>P: Pool bundle
P-->>S: Current bundle
U->>UI: Enter amount
UI->>S: Current amount
S->>S: Compute local quote
S-->>UI: Quote keyed by amount and bundle
U->>UI: Confirm swap
UI->>S: Execute current quote
S->>R: Build, sign, submit, confirm
R-->>S: Transaction signature
S->>P: Refresh pool
P-->>UI: Clear bundle and disable Swap
P->>R: Reload reserves
Reviews (5): Last reviewed commit: "fix(templates): invalidate pool data syn..." | Re-trigger Greptile |
A quote now records the exact input string it was computed for and is only visible (and executable) while it matches the current input. This closes the window where a stale quote stayed on screen with Swap enabled during async recomputation and could execute an amount different from the one displayed. Addresses the Greptile P1 finding. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A quote is now valid only for the exact (amount, bundle) pair it was computed from. The amount-only check left a window after pool refresh (guaranteed after every confirmed swap) where old-reserve math stayed executable against the new bundle. Addresses the second Greptile P1. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Closes the bug class behind the three staleness findings: any value derived from async state must be bound to the inputs that produced it and invalidated the moment those inputs are known-stale. refresh() now clears the bundle synchronously (killing quotes and the Swap button until fresh reserves land — including right after our own swap) and a sequence guard prevents overlapping refreshes landing out of order. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
I reviewed the PR, including the existing Greptile threads and the latest fixes. The stale-quote issues look addressed, and I confirmed the branch merges cleanly into current I would not approve yet only because the required checks are still failing ( One small non-blocking wording suggestion: |
What
New community template: raydium-hello-world — a Next.js + wallet-adapter +
@raydium-io/raydium-sdk-v2starter that swaps on a Raydium CPMM pool, devnet-first. Sibling todrift-hello-worldin the protocol-intro series.What it teaches:
signAllTransactions— no secret keys anywherecpmm.getPoolInfoFromRpc, price derived locallyCurveCalculator(the on-chain constant-product math, zero RPC per keypress)Follows the kit-family design guidelines: Solana-branded grid background, neutral tokens, Inter + Geist Mono, next-themes dark mode, sonner toasts, shadcn primitives.
Deliberate decisions
NEXT_PUBLIC_POOL_ID) and the in-app error state teaches recovery when a devnet pool dies (they do)..env.examplecommitted via a!.env.examplegitignore exception (placeholders only) — it documents the four optional env vars; the template runs with zero config.0.2.60-alpha) — it's an alpha line; caret ranges would break fresh scaffolds on breaking alphas.cpmm.swapbecause the SDK applies the slippage discount by mutating the object passed in (retries would otherwise compound the discount).generate-metadata.yml.Review
Pre-push review ran through a dual-review agent pipeline (two independent reviewers + an external Codex pass auditing the decision log); all blocking findings fixed: quote/amount pairing, swapResult clone,
.env.exampleshipping, README accuracy, full-signature copy affordance, wallet errors surfaced as toasts.Test plan
tsc --noEmit, template eslint,next build, repo lint (structure + prettier),pnpm generate+validate: all pass locally under pnpm 10.5.2