Skip to content

Feature/multi peg frontend#96

Open
xerion12 wants to merge 6 commits intoStabilityNexus:mainfrom
xerion12:feature/multi-peg-frontend
Open

Feature/multi peg frontend#96
xerion12 wants to merge 6 commits intoStabilityNexus:mainfrom
xerion12:feature/multi-peg-frontend

Conversation

@xerion12
Copy link
Copy Markdown
Contributor

@xerion12 xerion12 commented Nov 26, 2025

  • Refactors frontend to load peg asset, token tickers, names, and SEO defaults from a centralized protocolConfig.
  • Replaces hardcoded Gold/GAU/GAUC copy in hero, mechanics, navbars, and dashboard stats with config-driven text.
  • Aligns UI labels for GAU/GAUC with generic neutron/proton roles while preserving current Gold deployment semantics.
  • Prepares the UI for future deployments by enabling protocol-specific configs to be swapped in.

Summary by CodeRabbit

  • Refactor

    • UI text, labels and token symbols now come from a central configuration—updates applied to hero copy, feature descriptions, navigation title, stat cards, volumes, and leverage/reserve labels.
    • SEO defaults and social link use configurable values.
    • Swap and transaction displays now show the updated token tickers and related labels consistently.
  • New

    • Added a central protocol configuration to manage site copy, token metadata, and defaults.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 26, 2025

Walkthrough

Replaced many hardcoded UI strings with values sourced from a new centralized protocolConfig; renamed GAU/GAUC identifiers to neutron/proton across reactor swap logic, reactor helper functions, and related public types; added src/lib/config/protocol.ts exporting the config and its type.

Changes

Cohort / File(s) Summary
Config
src/lib/config/protocol.ts
New exported immutable protocolConfig and ProtocolConfig type containing peg metadata, tokens (neutron/proton), seo defaults, and UI labels/mechanics.
Dashboard / Stats
src/lib/components/blocks/dashboard/GluonStats.tsx, src/lib/components/blocks/dashboard/MyStats.tsx
Replaced hardcoded titles, subtitles, token tickers/names, captions and labels with values from protocolConfig.tokens and protocolConfig.ui.labels; presentation-only changes preserved existing rendering and data logic.
Home / Hero / Features
src/lib/components/blocks/home/Features.tsx, src/lib/components/blocks/home/Hero.tsx, src/lib/components/ui/hero-text.tsx
Substituted static hero taglines, feature headings/descriptions and memoized title adjective with protocolConfig.ui.hero, protocolConfig.ui.mechanics and protocolConfig.peg.adjective (useMemo dependency unchanged).
Layout / SEO / Navbar
src/lib/components/layout/BottomNavbar.tsx, src/lib/components/layout/TopNavbar.tsx, src/lib/components/layout/SEO.tsx
Replaced hardcoded navbar title, Telegram link and default SEO props (title, description, keywords, image, url) with values from protocolConfig.ui.labels and protocolConfig.seo.
Swap UI & Reactor Flow
src/lib/components/blockchain/swap/ReactorSwap.tsx
Renamed UI state and displayed fields from gau/gauc → neutron/proton; updated balance lookups, validation, debounced calculations, receipts, and wallet-state capture mapping; maintained storage/backwards-compatibility where comments indicate mapping to gau/gauc.
Reactor Helpers
src/lib/functions/reactor/handleFission.ts, src/lib/functions/reactor/handleFusion.ts, src/lib/functions/reactor/handleTransmutation.ts
Renamed parameters, return fields, logs and ReceiptDetails/outputAmount keys from gau/gauc → neutron/proton; updated function signatures and error/reset payload keys accordingly.
Reactor Types
src/lib/functions/reactor/types.ts
Public interfaces updated: ReceiptDetails.outputAmount keys (gau → neutron, gauc → proton), SwapResult fields (gauAmount → neutronAmount, gaucAmount → protonAmount), and SwapError.resetValues fields renamed similarly.

Sequence Diagram(s)

sequenceDiagram
  participant UI as Frontend Components
  participant CFG as protocolConfig
  participant SW as ReactorSwap
  participant RH as Reactor Helpers (fusion/fission/transmutation)
  participant STORE as Wallet/Server Storage

  rect `#DFF3E3`
    UI->>CFG: read labels, tickers, hero/seo text
    CFG-->>UI: provide dynamic strings
  end

  rect `#F6F6FF`
    UI->>SW: user swap input (neutron/proton amounts)
    SW->>RH: calculate & validate (neutron/proton)
    RH-->>SW: ReceiptDetails { outputAmount: {neutron,proton}, ... }
    SW->>STORE: captureWalletState (maps neutron→gau, proton→gauc for storage)
    STORE-->>SW: ack
    SW-->>UI: render receipts and messages (neutron/proton)
  end
Loading

(Note: colors highlight config-read phase and swap calculation flow.)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas needing extra attention:
    • All renamed public types and function signatures in src/lib/functions/reactor/* (ensure downstream callers updated).
    • ReactorSwap.tsx wallet-state mapping and backward-compatibility comments (storage keys mapping neutron↔gau).
    • Memoization in hero-text.tsx (dependency array unchanged but now uses config).
    • SEO defaults mapping in SEO.tsx and Telegram link formatting in BottomNavbar.tsx.

Possibly related PRs

  • SEO datafile changed #90 — overlaps with replacing hardcoded SEO defaults in SEO.tsx and may conflict on default values.
  • fix: "Issue #19 and #21" #45 — related edits to ReactorSwap and ReceiptDetails types; changes to max/precision logic there could intersect.
  • fixed duplicate code #66 — modifications to ReactorSwap and formatting/lint changes may overlap with the rename and type edits.

Suggested reviewers

  • Zahnentferner

Poem

🐇 I hopped through code, swapped names with care,
Neutron and Proton now dance everywhere.
Taglines hum, tickers gleam,
One config stitches the UI dream.
A carrot for the deploy — crunchy and fair 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The PR title 'Feature/multi peg frontend' is vague and does not clearly convey the specific changes made. While it references 'multi peg', the actual scope involves refactoring hardcoded strings into configuration-driven values across multiple components. Consider a more descriptive title like 'Refactor hardcoded UI strings to use protocolConfig' or 'Make frontend configuration-driven via protocolConfig' to better communicate the main change to reviewers.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/lib/config/protocol.ts (1)

59-76: Consider using template literals for full configurability.

The mechanics action descriptions contain hardcoded token symbols ($GAU, $GAUC, $ERG) instead of using the dynamic config values. This limits the reusability goal of the config when switching to different protocol deployments.

If you want full flexibility, consider refactoring to use template literals or a function that interpolates token tickers from the config. However, this adds complexity and may not be necessary if these descriptions are protocol-specific rather than deployment-specific.

src/lib/components/layout/SEO.tsx (1)

21-21: Consider making the site name check configurable.

The siteTitle logic hardcodes "Gluon" in the check. For full protocol flexibility, this could be extracted to the config (e.g., protocolConfig.seo.siteName).

This is a minor concern and can be addressed if/when supporting multiple protocol brands becomes necessary.

src/lib/components/blocks/home/Features.tsx (1)

189-195: Consider removing hardcoded index logic from line break rendering.

The conditional double breaks idx === 1 || idx === 3 tightly couple the UI layout to the specific structure of the current config array. If the config changes (e.g., lines reordered, items added/removed), this logic won't adapt correctly.

Consider one of these alternatives:

Option 1: Add an optional spacing indicator to the config itself:

// In protocol.ts
overviewBody: [
  { text: "Get exposure to Gold with GAU.", spacing: "single" },
  { text: "GAU is the stablecoin pegged to 1g of Gold.", spacing: "double" },
  // ...
]

Option 2: Remove the conditional logic and rely on consistent spacing:

-{protocolConfig.ui.mechanics.overviewBody.map((line, idx) => (
-  <span key={idx}>
+{protocolConfig.ui.mechanics.overviewBody.map((line) => (
+  <span key={line}>
     {line}
     <br />
-    {idx === 1 || idx === 3 ? <br /> : null}
   </span>
 ))}

Option 3: Use CSS classes for spacing instead of hardcoded breaks.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9565760 and 9b5301e.

📒 Files selected for processing (9)
  • src/lib/components/blocks/dashboard/GluonStats.tsx (4 hunks)
  • src/lib/components/blocks/dashboard/MyStats.tsx (2 hunks)
  • src/lib/components/blocks/home/Features.tsx (3 hunks)
  • src/lib/components/blocks/home/Hero.tsx (2 hunks)
  • src/lib/components/layout/BottomNavbar.tsx (2 hunks)
  • src/lib/components/layout/SEO.tsx (2 hunks)
  • src/lib/components/layout/TopNavbar.tsx (2 hunks)
  • src/lib/components/ui/hero-text.tsx (1 hunks)
  • src/lib/config/protocol.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (8)
src/lib/components/layout/BottomNavbar.tsx (1)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-79)
src/lib/components/ui/hero-text.tsx (1)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-79)
src/lib/components/blocks/home/Features.tsx (1)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-79)
src/lib/components/blocks/dashboard/MyStats.tsx (1)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-79)
src/lib/components/layout/SEO.tsx (1)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-79)
src/lib/components/layout/TopNavbar.tsx (1)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-79)
src/lib/components/blocks/dashboard/GluonStats.tsx (1)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-79)
src/lib/components/blocks/home/Hero.tsx (1)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-79)
🔇 Additional comments (11)
src/lib/components/layout/TopNavbar.tsx (1)

12-12: LGTM!

The navbar title is now properly driven by the centralized config, enabling easy customization for different protocol deployments.

Also applies to: 58-58

src/lib/components/layout/SEO.tsx (1)

14-20: LGTM!

SEO defaults are now properly centralized, making it easy to customize metadata for different protocol deployments.

src/lib/components/blocks/home/Hero.tsx (1)

5-5: LGTM!

Hero text is now driven by the centralized config, enabling easy customization of the main landing page messaging.

Also applies to: 25-27

src/lib/components/layout/BottomNavbar.tsx (1)

8-8: LGTM!

The Telegram link is now dynamically constructed from the config, allowing easy customization for different protocol deployments.

Also applies to: 24-24

src/lib/components/ui/hero-text.tsx (1)

7-10: Dynamic hero text integration looks good.

The implementation correctly uses protocolConfig.peg.adjective in the rotating titles. Note that there's a potential casing inconsistency with this value flagged in protocol.ts line 4.

The empty dependency array is appropriate since protocolConfig is a constant with as const assertion.

src/lib/components/blocks/dashboard/MyStats.tsx (1)

15-15: LGTM!

The token display labels are now dynamically driven by the config, using the neutron/proton abstraction correctly. This enables easy customization for different protocol deployments while maintaining the current Gold/GAU/GAUC semantics.

Also applies to: 201-203, 208-210

src/lib/components/blocks/dashboard/GluonStats.tsx (1)

15-15: LGTM!

The stats dashboard is now fully driven by the centralized config across all metrics, labels, and token references. This comprehensive refactoring properly abstracts Gold/GAU/GAUC specifics while preserving current deployment semantics.

Also applies to: 295-320, 335-346, 351-357, 421-421

src/lib/components/blocks/home/Features.tsx (4)

11-11: LGTM: Config import.

The import of protocolConfig correctly enables data-driven content throughout this component.


181-181: LGTM: Dynamic overview title.

Successfully replaced hardcoded title with config-driven value.


200-237: LGTM: Actions successfully migrated to config-driven approach.

All four action items (Fission, Fusion, Transmute To/From Gold) now properly source their titles and descriptions from protocolConfig.ui.mechanics.actions, maintaining functionality while achieving the PR's goal of eliminating hardcoded strings.


245-251: LGTM: TokenFlow titles now config-driven.

All TokenFlow components correctly use titles from protocolConfig.ui.mechanics.actions, successfully replacing hardcoded strings with dynamic values. The token identifiers ("ERG", "GAU", "GAUC") remain hardcoded as technical constants, which is appropriate for this protocol-specific logic.

Comment thread src/lib/config/protocol.ts Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/lib/components/layout/SEO.tsx (1)

14-18: Using protocolConfig.seo for default props keeps SEO metadata consistent

Wiring the destructured defaults to protocolConfig.seo is correct and keeps title, description, keywords, image, and url in sync with the centralized config. This should make future peg deployments easier to rebrand without touching this component.

If you ever need protocol-specific per-route titles, consider exposing small helpers (e.g., buildPageTitle(pageTitle) in the config layer) so the Gluon suffix rule is shared rather than hardcoded here.

src/lib/components/blocks/dashboard/GluonStats.tsx (1)

385-387: Activity and supply labels now config‑driven; consider extending to remaining GAU/GAUC strings

The 14d volume captions and supply labels now use protocolConfig.tokens.*.ticker and protocolConfig.ui.labels.*SupplyLabel, which aligns well with the multi‑peg goal and current neutron/proton abstractions.

Optionally, to fully decouple copy from GAU/GAUC, you might later move the remaining hard‑coded GAU/GAUC mentions in tooltips (e.g., ratio and leverage descriptions) into protocolConfig.ui as well.

Also applies to: 393-395, 401-402, 407-408

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b5301e and ebf28f0.

📒 Files selected for processing (2)
  • src/lib/components/blocks/dashboard/GluonStats.tsx (4 hunks)
  • src/lib/components/layout/SEO.tsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/lib/components/blocks/dashboard/GluonStats.tsx (2)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-79)
src/lib/utils/erg-converter.ts (2)
  • nanoErgsToErgs (133-135)
  • convertFromDecimals (30-33)
src/lib/components/layout/SEO.tsx (1)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-79)
🔇 Additional comments (3)
src/lib/components/layout/SEO.tsx (1)

2-2: Centralizing SEO defaults via protocolConfig import is aligned with the new config model

Importing protocolConfig here cleanly makes SEO a consumer of the shared config, which helps avoid drift between SEO metadata and the rest of the UI copy. No issues spotted.

src/lib/components/blocks/dashboard/GluonStats.tsx (2)

15-15: protocolConfig import wiring looks correct

Import path and usage of protocolConfig in this component are consistent with the new centralized config; no issues here.


318-325: Neutron/Proton price tiles correctly wired to protocolConfig

Both token tiles now pull tickers and subtitles from protocolConfig, while still binding to stats.gauPrice/stats.gaucPrice. This keeps semantics for the current GAU/GAUC deployment while making labels config‑driven.

Looks good as‑is.

Also applies to: 327-334

Comment thread src/lib/components/blocks/dashboard/GluonStats.tsx
Comment thread src/lib/components/blocks/dashboard/GluonStats.tsx
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (7)
src/lib/functions/reactor/handleTransmutation.ts (1)

33-42: Inconsistent indentation in early return block.

The return statement body (lines 34-41) is not properly indented relative to the if block. While this doesn't affect functionality, it reduces readability.

     if (numValue <= 0) {
-    return {
-      error: "Amount must be greater than zero.",
-      resetValues: {
-        neutronAmount: "0",
-        protonAmount: "0",
-        toAmount: "0",
-      },
-    };
+      return {
+        error: "Amount must be greater than zero.",
+        resetValues: {
+          neutronAmount: "0",
+          protonAmount: "0",
+          toAmount: "0",
+        },
+      };
     }
src/lib/components/blocks/dashboard/GluonStats.tsx (1)

346-352: Tooltip text still contains hardcoded "GAU"/"GAUC" references.

While card titles and labels use protocolConfig, the tooltip explanations at lines 346, 352, and 505 still reference hardcoded "GAU"/"GAUC". For full config-driven consistency, consider using protocolConfig.tokens.neutron.ticker and protocolConfig.tokens.proton.ticker in these tooltips as well.

-                <div className="text-sm text-muted-foreground">{renderTooltip("GAU Reserve Allocation", "Percentage of the reserve that is currently backing GAUs. The price of GAU is this reserve portion divided by the GAU supply.")}</div>
+                <div className="text-sm text-muted-foreground">{renderTooltip(`${protocolConfig.tokens.neutron.ticker} Reserve Allocation`, `Percentage of the reserve that is currently backing ${protocolConfig.tokens.neutron.ticker}s. The price of ${protocolConfig.tokens.neutron.ticker} is this reserve portion divided by the ${protocolConfig.tokens.neutron.ticker} supply.`)}</div>
src/lib/components/blockchain/swap/ReactorSwap.tsx (2)

1147-1149: Hardcoded ticker strings in GAU/GAUC card badges.

While line 1471 uses protocolConfig.tokens.neutron.ticker and protocolConfig.tokens.proton.ticker, the badge text in renderGauGaucCard still hardcodes "GAU" and "GAUC". For consistency with the config-driven approach, consider using protocolConfig here as well.

               <motion.div
                 className="flex items-center gap-1.5 rounded-md bg-yellow-800/60 px-3 py-1.5 text-sm font-bold text-white dark:bg-yellow-900/60"
                 whileHover={{ scale: 1.05 }}
                 transition={{ duration: 0.1 }}
               >
-                GAU
+                {protocolConfig.tokens.neutron.ticker}
               </motion.div>

Also applies to: 1182-1184


1584-1585: Hardcoded ticker strings in receipt "You Will Receive" section.

These lines hardcode "GAU" and "GAUC" while line 1471 uses protocolConfig for the same purpose. For consistency:

-                        <div>{formatTokenAmount(formatValue(receiptDetails.outputAmount.neutron))} GAU</div>
-                        <div>{formatTokenAmount(formatValue(receiptDetails.outputAmount.proton))} GAUC</div>
+                        <div>{formatTokenAmount(formatValue(receiptDetails.outputAmount.neutron))} {protocolConfig.tokens.neutron.ticker}</div>
+                        <div>{formatTokenAmount(formatValue(receiptDetails.outputAmount.proton))} {protocolConfig.tokens.proton.ticker}</div>
src/lib/functions/reactor/handleFusion.ts (3)

15-53: Minor clean‑up: avoid double‑wrapping bigint values from convertToDecimals

convertToDecimals already returns a bigint, so wrapping its result in BigInt(...) is redundant:

const neutronAmount = convertToDecimals(neutronBalance);
const protonAmount = convertToDecimals(protonBalance);

This keeps the types clearer without changing behavior, since all math here is already in bigint.


56-117: Fusion amount calculation aligns with updated neutron/proton types; consider precision and inputAmount semantics

The neutron/proton rename is correctly propagated here: calculateFusionAmounts now:

  • Calls calculateMaxErgOutput with neutron/proton balances.
  • Maps neutrons/protons from the SDK to requiredNeutron/requiredProton via convertFromDecimals.
  • Returns neutronAmount / protonAmount and fills resetValues.neutronAmount / resetValues.protonAmount in line with the updated SwapResult/SwapError and ReceiptDetails shapes from types.ts.

Two small points to double‑check:

  1. Precision in ReceiptDetails:
    You currently do:

    inputAmount: parseFloat(requiredNeutron),
    outputAmount: {
      neutron: parseFloat(requiredNeutron),
      proton: parseFloat(requiredProton),
      erg: parseFloat(value),
    },

    Since convertFromDecimals returns a BigNumber, converting to string and then parseFloat constrains you to JS number precision. If downstream UI/logic ever needs exact token amounts (especially for large values or many decimals), consider keeping these as BigNumber instances instead of floats.

  2. inputAmount meaning:
    inputAmount is now derived from requiredNeutron while the user‑specified field here is value (ERG). Make sure this matches how ReceiptDetails.inputAmount is interpreted in the UI and other swap flows (e.g., that components don’t assume it always equals the user‑entered amount).

If both are intentional and the consumers expect numbers, this implementation is fine as‑is.


175-189: Align GAU/GAUC‑style local names with neutron/proton terminology for clarity

In handleFusionSwap, the verification/logging block still uses GAU‑style names:

const requiredGau = convertFromDecimals(BigInt(neutrons)).toString();
const requiredGauc = convertFromDecimals(BigInt(protons)).toString();

tokensToBeConsumed: {
  rawNeutrons: neutrons.toString(),
  rawProtons: protons.toString(),
  displayGau: requiredGau,
  displayGauc: requiredGauc,
}

For consistency with the rest of this refactor, consider renaming these to neutron/proton equivalents (e.g., requiredNeutron, requiredProton, displayNeutron, displayProton). This keeps logs and local variables aligned with the new public types and should make future multi‑peg maintenance easier.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c9d18d and 8ea163e.

📒 Files selected for processing (8)
  • src/lib/components/blockchain/swap/ReactorSwap.tsx (22 hunks)
  • src/lib/components/blocks/dashboard/GluonStats.tsx (5 hunks)
  • src/lib/components/blocks/home/Features.tsx (4 hunks)
  • src/lib/config/protocol.ts (1 hunks)
  • src/lib/functions/reactor/handleFission.ts (4 hunks)
  • src/lib/functions/reactor/handleFusion.ts (6 hunks)
  • src/lib/functions/reactor/handleTransmutation.ts (4 hunks)
  • src/lib/functions/reactor/types.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/lib/config/protocol.ts
  • src/lib/components/blocks/home/Features.tsx
🧰 Additional context used
🧬 Code graph analysis (4)
src/lib/functions/reactor/handleFission.ts (1)
src/lib/utils/erg-converter.ts (2)
  • formatMicroNumber (89-114)
  • convertFromDecimals (30-33)
src/lib/functions/reactor/handleFusion.ts (2)
src/lib/utils/erg-converter.ts (2)
  • convertToDecimals (40-47)
  • convertFromDecimals (30-33)
src/lib/functions/reactor/types.ts (3)
  • SwapResult (48-54)
  • SwapError (56-63)
  • ReceiptDetails (20-35)
src/lib/components/blockchain/swap/ReactorSwap.tsx (5)
src/lib/utils/transaction-listener.ts (2)
  • WalletState (19-25)
  • ExpectedChanges (28-33)
src/lib/constants/token.ts (1)
  • TOKEN_ADDRESS (1-5)
src/lib/utils/erg-converter.ts (1)
  • convertToDecimals (40-47)
src/lib/functions/reactor/handleFusion.ts (1)
  • calculateFusionAmounts (58-117)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-51)
src/lib/components/blocks/dashboard/GluonStats.tsx (3)
src/lib/config/protocol.ts (1)
  • protocolConfig (1-51)
src/lib/components/ui/skeleton.tsx (1)
  • Skeleton (7-7)
src/lib/utils/erg-converter.ts (2)
  • nanoErgsToErgs (133-135)
  • convertFromDecimals (30-33)
🔇 Additional comments (10)
src/lib/functions/reactor/types.ts (1)

22-25: Type renaming from gau/gauc to neutron/proton is consistent and well-structured.

The interface updates properly abstract the token roles (neutron = stable, proton = volatile) while preserving the protocol-level identifiers (TokenSymbol, SwapAction) that still reference GAU/GAUC. This layered approach correctly separates the abstract role concept from the concrete deployment tokens.

Also applies to: 48-54, 56-62

src/lib/functions/reactor/handleTransmutation.ts (1)

103-132: Transmutation output mapping is correctly preserved with new nomenclature.

The logic correctly maps:

  • fromTokenSymbol === "GAUC" → outputs to neutron (GAU)
  • fromTokenSymbol === "GAU" → outputs to proton (GAUC)

This maintains the existing behavior while adopting the new abstract naming.

src/lib/components/blocks/dashboard/GluonStats.tsx (2)

306-331: Config-driven stat cards are well-implemented.

The integration of protocolConfig for dynamic titles, subtitles, and token tickers properly abstracts the deployment-specific values. This enables future multi-peg deployments without code changes.


460-471: Past review issues addressed: BigNumber coercion and label disambiguation.

The code now correctly uses Number(stats.reserveRatio) for arithmetic and the label "Reserve-Implied {ticker} Leverage" clearly distinguishes this from the "GAUC Leverage" card below, addressing the duplicate semantics concern from the previous review.

src/lib/functions/reactor/handleFission.ts (2)

36-44: Helpful inline documentation clarifying token roles.

The comment at line 36 clearly documents the mapping: "neutrons are the stable token (GAU), protons are the leveraged token (GAUC)". This aids maintainability when working with the abstraction layer.


50-72: Fission calculation return values correctly updated to new nomenclature.

The ReceiptDetails.outputAmount and SwapResult fields properly use neutron/proton naming, consistent with the updated types in types.ts.

src/lib/components/blockchain/swap/ReactorSwap.tsx (3)

112-113: State variables appropriately renamed to neutron/proton.

The state naming aligns with the abstract token roles while the underlying logic remains unchanged.


150-163: Well-documented bridge between internal naming and external interface.

The comments at lines 150 and 166 clearly explain that WalletState and ExpectedChanges still use gau/gauc keys for backward compatibility with transaction-listener.ts. The mapping logic correctly translates between the internal neutron/proton naming and the external interface.

Also applies to: 166-205


1197-1254: Swap validation logic correctly updated with neutron/proton naming.

The isSwapDisabled function properly uses the renamed variables (neutronRequired, protonRequired, neutronBalance, protonBalance, neutronInput, protonInput) while maintaining the correct validation logic for each swap type.

src/lib/functions/reactor/handleFusion.ts (1)

6-12: FusionParams neutron/proton balances look consistent with downstream usage

The rename to neutronBalance / protonBalance is wired correctly into calculateFusionAmounts and calculateMaxErgOutput via destructuring and parameter passing; no functional issues here from what’s visible in this file. Just ensure any external call sites constructing FusionParams have been updated to provide the new properties.

Comment thread src/lib/components/blockchain/swap/ReactorSwap.tsx
labels: {
navbarTitle: "GLUON GOLD",
telegramHandle: "GluonGold",
assetPriceTitle: "1 kg of Gold",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line and line 44 seem to be using a text from an old version. See https://gluon.gold to see the text that we are using now.

{isLoading ? <Skeleton className="mx-auto h-8 w-16" /> : hasError ? "—" : convertFromDecimals(protocolMetrics.circulatingSupply.neutrons).toFixed(2)}
</div>
<div className="text-sm text-muted-foreground">GAU Supply</div>
<div className="text-sm text-muted-foreground">{protocolConfig.ui.labels.neutronSupplyLabel}</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here we could use the neutron ticker from config and then " Supply". Then we wouldn't need to define neutronSupplyLabel.

{isLoading ? <Skeleton className="mx-auto h-8 w-16" /> : hasError ? "—" : convertFromDecimals(protocolMetrics.circulatingSupply.protons).toFixed(2)}
</div>
<div className="text-sm text-muted-foreground">GAUC Supply</div>
<div className="text-sm text-muted-foreground">{protocolConfig.ui.labels.protonSupplyLabel}</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here too, for protons.

>
<div className="mb-1 text-4xl font-bold text-foreground">{hasError ? "—" : stats.priceCrashCushion ? Math.round(+stats.priceCrashCushion) : "—" }%</div>
<div className="text-sm font-medium text-muted-foreground">{renderTooltip("Price Crash Cushion", "Maximum drop in the price of ERG w.r.t. Gold that can be tolerated for GAU to remain pegged to Gold. When 0%, GAU depegs to prevent bank runs and maintain non-zero GAUC price.")}</div>
<div className="text-4xl font-bold text-foreground mb-1">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems that, in this code block, some recent changes that iIhad committed are being erased.

Are you sure that you are working on the latest version of the main branch? Remember to always pull and synchronize your branch.

icon: Maximize2,
title: "Fission",
description: "Splits $ERG tokens into $GAU stable tokeons and $GAUC volatile tokeons",
description: "Split ERG into the stable and leveraged tokens of the Gluon protocol.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use the ticker symbols from config?

assetPriceSubtitle: "Oracle Gold Price",
neutronSubtitle: "Gold Pegged Token",
protonSubtitle: "Leveraged Yield Token",
neutronSupplyLabel: "GAU Supply",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See my other comment. Lines 47 adn 48 can be removed.

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.

2 participants