Skip to content

Conversation

@shoom3301
Copy link
Contributor

@shoom3301 shoom3301 commented Sep 3, 2025

Use native token symbol in notification template message instead of wrapped

Summary by CodeRabbit

  • New Features
    • Trade notifications now support Eth Flow orders, automatically displaying the chain’s native currency as the sell token when applicable for clearer, more accurate messaging.
    • Improved token resolution logic enhances reliability of notifications across supported networks, with no changes required from users and no impact on non-Eth Flow orders.

@shoom3301 shoom3301 requested a review from a team September 3, 2025 08:29
@shoom3301 shoom3301 self-assigned this Sep 3, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 3, 2025

Walkthrough

Adds Eth Flow order awareness to trade notifications: a new isEthFlowOrder flag is propagated from getTradeNotifications to fromTradeToNotification, which uses it to resolve sellToken as the chain native currency for Eth Flow orders; otherwise, it continues fetching the ERC-20 sell token. Imports chain metadata for native currency lookup.

Changes

Cohort / File(s) Summary
Trade notification generation
apps/notification-producer/src/producers/trade/fromTradeToNotification.ts, apps/notification-producer/src/producers/trade/getTradeNotifications.ts
Introduce and propagate isEthFlowOrder. fromTradeToNotification conditionally sets sellToken: native currency via ALL_SUPPORTED_CHAINS_MAP when isEthFlowOrder is true; otherwise fetch via erc20Repository. Updated function signature and parameter destructuring; minor formatting tweak.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant GTN as getTradeNotifications
  participant Repo as erc20Repository
  participant SDK as ALL_SUPPORTED_CHAINS_MAP
  participant FTN as fromTradeToNotification

  Note over GTN: Determine isEthFlowOrder (owner ∈ ethFlowAddresses)
  GTN->>FTN: fromTradeToNotification({..., isEthFlowOrder, sellTokenAddress, chainId, ...})

  alt isEthFlowOrder == true
    FTN->>SDK: Lookup nativeCurrency by chainId
    SDK-->>FTN: nativeCurrency (sellToken)
  else
    FTN->>Repo: getErc20ByAddress(sellTokenAddress)
    Repo-->>FTN: ERC-20 sellToken
  end

  FTN-->>GTN: Notification payload
  Note over FTN,GTN: Control flow unchanged otherwise
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • alfetopito

Poem

A hop, a skip, an Eth-y flow,
I nibble bytes where tokens go.
If native coin, I thump with glee—
No ERC-20 fetch for me!
Notifications, crisp and bright,
I twitch my nose: “All set, alright!” 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/eth-flow-template

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
apps/notification-producer/src/producers/trade/fromTradeToNotification.ts (1)

45-50: Guard against missing chain metadata; provide safe fallback.

If a new chain is introduced without nativeCurrency in ALL_SUPPORTED_CHAINS_MAP, this will throw. Add a fallback to ERC-20 lookup and log once.

-  const sellToken = isEthFlowOrder
-    ? ALL_SUPPORTED_CHAINS_MAP[chainId].nativeCurrency
-    : await erc20Repository.get(
-      chainId,
-      getAddress(sellTokenAddress)
-    );
+  const chainMeta = ALL_SUPPORTED_CHAINS_MAP[chainId];
+  const sellToken = isEthFlowOrder
+    ? (chainMeta?.nativeCurrency ??
+       (await erc20Repository.get(chainId, getAddress(sellTokenAddress))))
+    : await erc20Repository.get(chainId, getAddress(sellTokenAddress));
+  if (isEthFlowOrder && !chainMeta?.nativeCurrency) {
+    logger.warn(`${prefix} Missing nativeCurrency for chainId=${chainId}; fell back to ERC-20 sellTokenAddress.`);
+  }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between eae844e and a7e1ed6.

📒 Files selected for processing (2)
  • apps/notification-producer/src/producers/trade/fromTradeToNotification.ts (4 hunks)
  • apps/notification-producer/src/producers/trade/getTradeNotifications.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: docker (apps/api)
  • GitHub Check: docker (apps/notification-producer)
  • GitHub Check: docker (apps/telegram)
  • GitHub Check: docker (apps/twap)
🔇 Additional comments (3)
apps/notification-producer/src/producers/trade/getTradeNotifications.ts (1)

116-121: Only one call site for fromTradeToNotification and it already includes isEthFlowOrder
Confirmed via project-wide search that getTradeNotifications.ts is the sole caller and it’s updated correctly.

apps/notification-producer/src/producers/trade/fromTradeToNotification.ts (2)

1-1: Import is fine; consider defensive access for chain metadata.

Since ALL_SUPPORTED_CHAINS_MAP is used for runtime lookups, ensure callers only pass SupportedChainId values present in this map.


16-16: All fromTradeToNotification calls include the new isEthFlowOrder prop; downstream compatibility verified.

@shoom3301 shoom3301 enabled auto-merge (squash) September 3, 2025 10:37
@shoom3301 shoom3301 merged commit a0780b6 into main Sep 3, 2025
7 checks passed
@shoom3301 shoom3301 deleted the fix/eth-flow-template branch September 3, 2025 11:03
Comment on lines +46 to +49
? ALL_SUPPORTED_CHAINS_MAP[chainId].nativeCurrency
: await erc20Repository.get(
chainId,
getAddress(sellTokenAddress)
Copy link
Contributor

Choose a reason for hiding this comment

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

erc20 repo already does that behind the scenes.
Just use the 0xeee address instead of the conditional.

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.

4 participants