8000 fix(volume-fee): remove hardcoded stablecoins check for Safe fee by shoom3301 · Pull Request #5436 · cowprotocol/cowswap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(volume-fee): remove hardcoded stablecoins check for Safe fee #5436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2025

Conversation

shoom3301
Copy link
Collaborator
@shoom3301 shoom3301 commented Feb 17, 2025

Summary

In #5187 we added isSafeAppStableCoinsFeeEnabled flag in order to not add fees to stablecoins in Safe.
But since we have #5427, we don't need this check because it's already covered by the data from CMS.

To Test

  1. Now only CMS decides if a token is a fee free
  2. Fee tier is still calculating based on hardcoded stablecoins list

Summary by CodeRabbit

  • New Features
    • Enhanced fee calculation for safe app transactions: fees are now consistently applied and displayed for transfers involving stablecoins, ensuring more transparent fee details for users.
    • Improved clarity in fee skipping logic for correlated tokens, with additional logging for better context during transactions.

@shoom3301 shoom3301 requested review from a team February 17, 2025 12:36
@shoom3301 shoom3301 self-assigned this Feb 17, 2025
8000 Copy link
vercel bot commented Feb 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cowfi ✅ Ready (Inspect) Visit Preview Feb 17, 2025 1:14pm
explorer-dev ✅ Ready (Inspect) Visit Preview Feb 17, 2025 1:14pm
swap-dev ✅ Ready (Inspect) Visit Preview Feb 17, 2025 1:14pm
3 Skipped Deployments
Name Status Preview Updated (UTC)
cosmos ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 1:14pm
sdk-tools ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 1:14pm
widget-configurator ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2025 1:14pm

Copy link
Contributor
coderabbitai bot commented Feb 17, 2025

Walkthrough

The changes modify the logic within the safeAppFeeAtom function by removing the retrieval of the isSafeAppStableCoinsFeeEnabled flag from featureFlagsAtom. This simplification eliminates the condition that previously checked if stablecoin fees were enabled for safe apps. As a result, the fee calculation now consistently proceeds regardless of the stablecoin fee flag status. Additionally, the shouldSkipFeeAtom function has been updated for improved readability and logging. The public API and exported entities remain unchanged.

Changes

File Path Change Summary
apps/cowswap-frontend/.../safeAppFeeAtom.ts Removed the retrieval of the isSafeAppStableCoinsFeeEnabled flag and simplified related conditionals, allowing fee calculation to always proceed regardless of stablecoin fee status.
apps/cowswap-frontend/.../volumeFeeAtom.ts Introduced isCorrelated variable for clarity in shouldSkipFeeAtom function and added debug logging for skipped fees based on correlated tokens.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant SafeAppFeeAtom
    Caller->>SafeAppFeeAtom: Invoke fee calculation
    SafeAppFeeAtom->>SafeAppFeeAtom: Check if currencies are stable
    SafeAppFeeAtom->>SafeAppFeeAtom: Bypass stablecoin fee flag check
    SafeAppFeeAtom-->>Caller: Return fee calculation result
Loading

Possibly related PRs

Suggested reviewers

  • elena-zh

Poem

In the code barn, the logic's clear,
Removing flags, the path is near.
No more stable checks to hide,
Fees charge on, like a smooth cow ride 🐮.
Happy coding under open sky,
A moo-velous change, oh my!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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/cowswap-frontend/src/modules/volumeFee/state/volumeFeeAtom.ts (1)

60-66: Udderly fantastic addition of debug logging! 🐄

The debug logging will help track fee skipping for correlated tokens, making it easier to diagnose fee-related issues in production.

Consider adding the tradeType to the debug log object to provide more context about the trading scenario:

 console.debug('[Volume Fee] Skipping fee for correlated tokens', {
   inputCurrencyAddress,
   outputCurrencyAddress,
   correlatedTokens,
+  tradeType: tradeState.tradeType,
 })
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4da782 and 4661449.

📒 Files selected for processing (2)
  • apps/cowswap-frontend/src/modules/volumeFee/state/safeAppFeeAtom.ts (2 hunks)
  • apps/cowswap-frontend/src/modules/volumeFee/state/volumeFeeAtom.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/cowswap-frontend/src/modules/volumeFee/state/safeAppFeeAtom.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Setup
  • GitHub Check: Cypress
🔇 Additional comments (2)
apps/cowswap-frontend/src/modules/volumeFee/state/volumeFeeAtom.ts (2)

49-58: MOOving in the right direction with better readability! 🐮

The extraction of the correlation logic into the isCorrelated variable makes the code more self-documenting and easier to understand.


68-68: Clean and COWncise return! 🎯

The simplified return statement maintains the same logic while being more readable.

@shoom3301 shoom3301 merged commit ce77355 into develop Feb 18, 2025
13 of 14 checks passed
@shoom3301 shoom3301 deleted the fix/safe-fee-hardcode branch February 18, 2025 08:04
@github-actions github-actions bot locked and limited conversation to collaborators Feb 18, 2025
Copy link
Contributor
@anxolin anxolin left a comment

Choose a reason for hiding this comment

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

👍

bps,
fiatAmount,
isStableCoinTrade,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

were you intending to add this message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. It's not easy for Elena to test the volume fee calculation, so I added this debug log.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0