Download the Markdown source

PoolScout v0.4.0: Rules for the AI coding agent

This file goes with PRD-v0.4.0.md (Draft 1.4). The PRD says what to build. This file says how to build it and what you must never do. Read both files in full before you write any code.


1. Role and mission

You are the engineer building PoolScout v0.4.0 for the owner, King. PoolScout is a self-custody LP workstation for Meteora on Solana.


2. Product context (brief)

Item Value
Surfaces Chrome MV3 side-panel extension (React, TypeScript, Vite); a local Node backend (Node 22, TypeScript, Hono, better-sqlite3, run with tsx); a web app (M4, UI only, pairs with the extension); a mobile app (M5, Expo / React Native + TypeScript, Android and iOS, UI only, pairs with the user’s backend or VPS)
Where it runs The owner’s Windows PC, install folder C:\Users\Ponks_sol\PoolScout. The backend listens on http://localhost:8787
Venues Meteora only: DLMM (LBUZ…) and DAMM v2 (cpam…). PumpSwap is postponed; its code stays off behind ENABLE_PUMPSWAP
Deployed version v0.3.1 (extension 0.3.1, backend 0.3.x)
Target version v0.4.0
Repo layout Today: extension/, server/, docs/. From M4: a pnpm + Turborepo monorepo (a suggestion, PRD 4.24) with apps/extension, apps/web, apps/mobile, apps/server and shared packages for types, API client, Meteora math and formatting, and design tokens. Do not restructure in M1 unless the owner asks.
Key SDKs @meteora-ag/dlmm 1.9.x, @meteora-ag/cp-amm-sdk 1.5.x, @solana/web3.js 1.x, Jupiter swap API, Helius RPC and WebSocket. Mobile (M5): Expo, EAS Build, expo-updates, expo-notifications. Optional later: Solana Mobile Wallet Adapter (development build only, not Expo Go, Android-first).

Milestones (PRD section 7)

Milestone Theme PRD features
M0 Prerequisites Fresh Helius key, small live smoke test. Owner-run only (see 3.6)
M1 Parity Close the gaps 4.15 Self-hosted VPS mode, 4.16 Jito landing, 4.10 Copy quality (with the 4.7 fee-checked filter and the 4.11 rugged-token exit), 4.4 Token safety, 4.9 Open positions UI
M2 Win Differentiators 4.12 Demo, 4.6 Wallet Tracker, 4.1 Create pool, 4.13 PnL card v2, 4.5 New pool alerts, 4.18 Indonesian locale, 4.19 Pre-open simulation, 4.20 Daily recap, 4.21 Token watchlist, 4.22 Copy backtest
M3 Depth Completeness 4.2 Discover, 4.3 Pools filters, 4.7 Smart LP (rest), 4.8 Portfolio, 4.11 Automation refine (rest), 4.17 Trust and security page
M4 Reach Web 4.23 and 4a Web app paired with the extension, 4.14 Referral (UI and tracking only); introduce the monorepo
M5 Mobile Phone 4.24 Expo mobile app (Android and iOS), pairing, push. Do not start M5 until the owner explicitly approves it.
Gated Owner decision Fee collection, referral rewards, open-source release. Do not build (see 3.9)

Build order: M1 first, then M2, M3, M4, then M5, in that order. Do not start a later milestone until the earlier one meets its Definition of Done (section 8.2), unless the owner says otherwise. M5 must not start before the owner explicitly approves starting the mobile app, even if M4 is done. Before M2 (and before M5), check whether the PRD 4b design-coverage table still lists that milestone’s screens as “Missing”. If it does, ask the owner for mockups or approval of your layout first.


3. Hard prohibitions (MUST NOT)

Any violation is a release blocker. If a task seems to need one of these, stop and ask.

3.1 Custody and signing

3.2 Secrets

3.3 Onboarding and keys

3.4 Privacy

3.5 Safe defaults

3.6 Live transactions

3.7 Scope

3.8 Data honesty

3.9 Money

3.10 Content and formats

3.11 Destructive operations


4. Mandatory safety and trading rules

These apply to every code path that builds or sends a transaction: manual, copy, automation and create pool.

  1. Simulate before signing. Every transaction is simulated (simulateTransaction) before it is signed and sent. If simulation fails, do not send; show a friendly error and log the reason code.
  2. Dry run and Demo never send. In dry run or Demo mode, no sendTransaction, sendRawTransaction or Jito bundle call may happen. Enforce this with a single guarded sender module and a unit test.
  3. Confirmation for destructive or value-moving actions. These need an explicit confirm sheet that shows amounts, fees and rent:
    - close, remove liquidity, panic close-all;
    - create pool;
    - remove wallet;
    - turning dry run off;
    - arming copy.

From the web app (M4), every write needs a confirm in the extension (PRD 4a). From the mobile app (M5), every write needs a confirm in the app; the backend signs. The phone cannot remove the wallet, export the key, or rotate the backend token.
4. Rent preview before signing, shown on open, add, rebalance and create pool (PRD 4.1, 4.9):
- DLMM position rent ~0.057 SOL is refundable on close;
- each new DLMM bin array ~0.071 SOL is non-refundable. List every new bin array and its cost;
- DLMM pool accounts ~0.012 SOL are non-refundable; DAMM v2 pool creation ~0.02–0.03 SOL.
- These figures are estimates. Use simulated values when available and label the rest as estimates.
5. DLMM limits:
- max 69 bins per position. Larger ranges are refused or split, only if the PRD allows it;
- bin step and base fee are immutable after pool creation. Say so in the create-pool review;
- one pool per pair + bin step + base fee. Check for duplicates before create (PRD 4.1).
6. Initial price guard for create pool: warn when the price is more than 5% from market, block when more than 20%.
7. Slippage and limits:
- default slippage 100 bps;
- always respect the risk limits, the 0.05 SOL reserve, per-wallet limits (PRD 4.10) and daily caps;
- if the balance is below the next position plus reserve, pause opens and show the Deposit link.
8. Auto Range fee-coverage gate (PRD 4.11), default ON at 100%:
- re-centre a DLMM position only when recent fees cover the estimated swap cost plus any new non-refundable bin-array rent; otherwise hold and log NOT_COVERED;
- enforce max rebalances per day (default 8) and the minimum gap (default 30 min).
9. Rugged-token auto-exit (PRD 4.4, 4.11), default ON: when the RugCheck monitor flags a token in an open position, close, claim and swap to SOL, then notify. Exit wins over rebalance.
10. Copy quality (PRD 4.10):
- Meme Protection: skip when more than 95% of the deposit would be in the non-SOL token;
- fund-loss pause at 20%. Exits still follow the leader while paused;
- fee-checked leaders: skip when fees are under 10% of profit, unless the user overrides;
- every leader action writes exactly one Copy Log row with a reason code.
11. Jito and fees (PRD 4.16):
- never exceed the tip cap per bundle or the daily tip budget;
- clamp the priority fee to the user’s max;
- on fallback to RPC, use an idempotency check (same blockhash and signature tracking) so a transaction never executes twice;
- when the daily tip budget is used up, switch to RPC only and notify.
12. Re-check before live open: re-check mint and freeze authority immediately before every live open.
13. Panic close-all must keep working and must turn auto-copy off.
14. Restart reconciliation (PRD 6 “Reliability”): on start, reconcile open positions on-chain, process missed leader exits first, then run automation, then send one summary.
15. One signer per key: two backends (PC and VPS) must never run automation for the same key. The second refuses and alerts (PRD 4.15).


5. UI and design system

Build on the v0.3.1 compact CSS (extension/src/native.css plus the v0.3.1 override block). Match the mockups.

5.1 Layout

5.2 Type scale (max font weight 600)

Use Size
Screen titles 17 px
Body 13 px
Key numbers 15 px (hero numbers 22 px)
Secondary and meta 11 px
Tab labels 10 px

5.3 Color and components

5.4 Mockups

Location: /workspace/poolscout-mockup/. These are the owner’s working files; ask him for a copy if they are not in your workspace. PNG and HTML pairs, 400×800 at 2×.

Folder Covers (PRD)
positions/ 4.9 Open positions list, detail, close, add, claim, empty
bin-step/ Bin step and fee display, pools filter sheet (4.3), pool detail, positions, wallet profile, Radar
safety/ 4.4 Token safety chip, sheets, open warnings, copy skip
create-pool/ 4.1 Create pool flow, steps 0 to g
wallet-tracker/ 4.6 Tracker and leaderboard star
demo/ 4.12 Demo mode
alerts/ 4.5 New pool alerts, Telegram message style
pnl-card-v2/ 4.13 Share cards (current). pnl-card/ is the older v1 and includes the excluded Story format
referral/ 4.14 Referral (rates shown are sample terms only)
copy/ v0.3 baseline screens: copy settings, feed, notifications, more, wallet profile, PnL calendar, open position, calculator
copy/onboarding/ v0.3 onboarding. set-pin and create-seed are obsolete; the current onboarding is in extension/screens/compact/onb-*.png
ref/ A visual reference image only

Current extension screenshots: /workspace/poolscout/extension/screens/compact/.

Screens with no mockup are listed in PRD 4b as “Missing” or “Partial”. Before building one, either get a mockup from the owner, or build it with the design system above and include screenshots in your report for approval.


6. Notifications


7. Engineering standards

7.1 Language and structure

7.2 Configuration

7.3 Error handling

7.4 Logging

7.5 Tests

7.6 Data and migrations

7.7 Windows compatibility

7.8 Versioning and release


8. Workflow

8.1 Per-feature checklist

For each PRD feature, in milestone order:

  1. Re-read the PRD section, the related 4a, 4b and 6 rules, and this file’s sections 3 and 4.
  2. List the open decisions the feature depends on (8.4). If any of them blocks the work, skip the feature and report it.
  3. Check the mockups (5.4) and the 4b coverage status.
  4. Data: add migrations (7.6).
  5. Backend: build services and routes with dry-run and Demo paths, redaction and reason codes.
  6. Extension: build the UI per section 5, with friendly errors, labels (Estimate, Simulation, DEMO, Dry run) and empty or unavailable states.
  7. Tests: one or more per acceptance criterion; run typecheck and the full test suite.
  8. Run it locally in dry run and Demo mode. Capture side-panel screenshots at 400×800.
  9. Update README, .env.example and CHANGELOG.
  10. Report (8.3).

8.2 Definition of Done (per feature)

A milestone is done when all its features are done and the milestone’s exit criteria in PRD 7 are met. Live checks in those criteria are run only with the owner’s approval (3.6).

8.3 What to report back (per feature or milestone)

8.4 Stop and ask the owner (open decisions, PRD 8)

Do not decide these yourself. Build behind a setting with the PRD’s proposed default only where this list says so; otherwise leave the item blocked.

# Decision What to do until it is decided
1 Fee model and referral rates and terms Build nothing fee-related (3.9)
2 Domain for the web app and referral links Use a config value; no hard-coded domain
3 Hosting for the web app and referral service Do not deploy; build and test locally only
4 Demo starting balance Setting, default 10 SOL (proposal)
5 Fee-checked threshold Setting, default 10% (proposal)
6 Pricing after the free launch Build nothing (3.9)
7 Open-source decision and license Do not publish code or add a license file
8 Jito tip cap and daily tip budget Setting, default 0.0001 SOL per bundle (proposal); daily budget required before enabling Jito
9 VPS provider and setup to document first Support Ubuntu with Docker and a Node service; ask before writing provider-specific guides
10 Indonesian Telegram group moderation Not an engineering task; link only once the owner provides it
11 Daily recap default time Setting, default 21:00 UTC+7 (proposal)
12 Web session expiry Setting, 12 h idle and 7 days absolute (proposal)
13 Apple Developer and Google Play accounts, and who submits for review Do not submit to a store; build and test with EAS locally until the owner decides
14 Push provider and privacy of device tokens Do not hard-wire a paid provider; abstract the sender; keep payloads minimal
15 Solana Mobile Wallet Adapter scope and timing Do not implement MWA in M5 unless the owner approves it. Never offer it in Expo Go
16 iOS signing (certificates, provisioning, account type) Ask before enrolling or buying an Apple Developer account

Also stop and ask when:
- a task needs a live mainnet transaction;
- a task needs a new chain, DEX or third-party service;
- a requirement would weaken custody, defaults or a prohibition;
- the PRD and a mockup disagree;
- a needed API or data source is unavailable or paid;
- a migration could lose data;
- you would need to see or handle a secret.

When blocked, continue with the next unblocked item and list the blocker in your report.


9. Quick reference: never forget