Skip to content

[#517] USD price tracking for PLOT token#526

Merged
realproject7 merged 4 commits intomainfrom
task/517-usd-price
Mar 25, 2026
Merged

[#517] USD price tracking for PLOT token#526
realproject7 merged 4 commits intomainfrom
task/517-usd-price

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Created lib/usd-price.ts — server-side PLOT USD price with fallback chain: Mint Club SDK → GeckoTerminal → CoinGecko
    • 2-minute in-memory cache with in-flight request coalescing
  • Created /api/tokens/plot-price API route (ISR + CDN caching)
  • Created usePlotUsdPrice client hook and UsdPriceTag component
  • Added USD display across the app:
    • Story cards: Price and TVL show USD in parentheses
    • Story page: Token price header shows USD
    • Profile portfolio: Total value and per-token values show USD
  • Token page already shows USD via existing useTokenInfo hook
  • Bumped version to 0.1.5

Architecture

  • Only PLOT USD price is tracked (single source of truth)
  • Storyline token USD values derived: token_price_in_PLOT × PLOT_USD
  • Modeled after Dropcast lib/usd-price.ts fallback chain pattern

Test plan

  • /api/tokens/plot-price returns { price: number, timestamp: number }
  • Story cards show TVL with USD value in parentheses
  • Story page header shows token price with USD
  • Profile portfolio shows total value and per-token USD
  • USD gracefully hidden when price unavailable (loading/error)
  • All 104 existing tests pass

Fixes #517

🤖 Generated with Claude Code

- Create lib/usd-price.ts with fallback chain: Mint Club SDK → GeckoTerminal → CoinGecko
  - 2-minute in-memory cache with in-flight request coalescing
- Create /api/tokens/plot-price API route (2-min ISR + CDN cache)
- Create usePlotUsdPrice client hook
- Create UsdPriceTag component for server-rendered pages
- Display USD values on:
  - Story cards (price + TVL with USD in parentheses)
  - Story page header (token price with USD)
  - Profile portfolio (total value + per-token values with USD)
- Bump version to 0.1.5

Fixes #517

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored Mar 25, 2026 8:49am

Request Review

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST CHANGES — one finding:

Duplicated USD formatting logic (4 copies)
The same formatting function is duplicated in 4 places:

  • lib/usd-price.ts:formatUsdValue (exported but never imported by any component)
  • src/components/UsdPriceTag.tsx (inline formatting, lines 13-18)
  • src/components/StoryCardStats.tsx:formatUsd (lines 20-25)
  • src/app/profile/[address]/page.tsx:formatPortfolioUsd (lines 20-25)

All four are identical logic. The components should import formatUsdValue from lib/usd-price.ts instead of duplicating it. The function is pure and safe for client-side import.

Otherwise the architecture is solid — fallback chain with timeouts, request coalescing, ISR + CDN caching, graceful degradation.

…b/usd-price.ts

Remove duplicated formatUsd/formatPortfolioUsd/inline formatting from
StoryCardStats, UsdPriceTag, and profile page. All now import formatUsdValue.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed — all USD formatting now uses the single formatUsdValue from lib/usd-price.ts. Duplicates removed from StoryCardStats, UsdPriceTag, and profile page. APPROVE.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The USD pricing UI wiring is reasonable, but the new server-side price fetcher is hardcoded to Base mainnet sources even though this repo defaults to the Base Sepolia / PL_TEST environment.

Findings

  • [high] The new PLOT USD fetcher is not chain-aware, so the feature returns null in the repo's default testnet setup and the new USD values never appear.
    • File: lib/usd-price.ts:57
    • Suggestion: make the fallback chain respect IS_TESTNET / current chain, or provide a testnet-compatible fallback for PL_TEST instead of always querying Base mainnet endpoints.

Decision

Requesting changes because lib/contracts/constants.ts defaults NEXT_PUBLIC_CHAIN_ID to 84532 (Base Sepolia), but lib/usd-price.ts hardcodes Mint Club network("base"), GeckoTerminal networks/base, and CoinGecko token_price/base. In the current default environment, those sources do not resolve the testnet PL_TEST token, so /api/tokens/plot-price falls through to null and all of the new USD displays stay hidden.

realproject7 and others added 2 commits March 25, 2026 08:46
Testnet tokens have no real USD value; return null immediately on IS_TESTNET.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

Re-reviewed after operator clarification that current feature work targets mainnet only. Under that scope, the USD pricing fallback chain and derived USD displays are aligned with issue #517's intended production behavior.

Findings

  • None.

Decision

Approving because the remaining blocker was based on stale testnet context. With operator-confirmed mainnet scope, the current head's PLOT USD pricing path, caching, API route, and UI displays are acceptable.

@realproject7 realproject7 merged commit ff4b48d into main Mar 25, 2026
5 checks passed
@realproject7 realproject7 deleted the task/517-usd-price branch March 25, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add USD price tracking for PLOT token with storyline token value calculation

2 participants