Skip to content
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

applyBridgeSlippage() applySwapSlippage() applied #1877

Merged
merged 4 commits into from
Jan 17, 2024

Conversation

bigboydiamonds
Copy link
Collaborator

@bigboydiamonds bigboydiamonds commented Jan 17, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced slippage handling for bridge transactions using synapseSDK.applyBridgeSlippage.
    • Improved slippage calculations for swaps with synapseSDK.applySwapSlippage.
  • Refactor

    • Streamlined slippage logic in bridge and swap components for better performance and accuracy.

f192e69858a3514d8d23a1aed8fa40f72df5332c: synapse-interface preview link
f473bf9eb23687a821e73e447b7a1b5daa005257: synapse-interface preview link
6d5263a8cc7ea68e04c1de58127669a260f16d39: synapse-interface preview link

Copy link
Contributor

coderabbitai bot commented Jan 17, 2024

Walkthrough

The recent updates across various components and utilities within the Synapse interface revolve around a unified approach to handling slippage. The StateManagedBridge and StateManagedSwap components, along with the fetchBridgeQuote function, now utilize the synapseSDK.applyBridgeSlippage and synapseSDK.applySwapSlippage methods. This change streamlines the process of calculating slippage for both bridge and swap operations, ensuring consistency and simplifying the control flow.

Changes

File Path Change Summary
.../state-managed-bridge/index.tsx & .../swap/index.tsx Both components now utilize synapseSDK methods to handle slippage directly.
.../utils/actions/fetchBridgeQuotes.tsx Updated to use synapseSDK.applyBridgeSlippage for calculating slippage in bridge quotes.

🐇✨
To the code with care, we hop and we tweak,
Slippage unites, in the SDK we seek.
Through bridge and swap, the numbers now flow,
In Synapse's dance, the decimals glow. 🌉🔄

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c77a619) 51.22032% compared to head (994db31) 51.22032%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##              master       #1877   +/-   ##
=============================================
  Coverage   51.22032%   51.22032%           
=============================================
  Files            397         397           
  Lines          27124       27124           
  Branches         307         307           
=============================================
  Hits           13893       13893           
  Misses         11881       11881           
  Partials        1350        1350           
Flag Coverage Δ
packages 90.97510% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1b95502 and 7d8be3d.
Files selected for processing (3)
  • packages/synapse-interface/pages/state-managed-bridge/index.tsx (2 hunks)
  • packages/synapse-interface/pages/swap/index.tsx (2 hunks)
  • packages/synapse-interface/utils/actions/fetchBridgeQuotes.tsx (2 hunks)
Additional comments: 6
packages/synapse-interface/utils/actions/fetchBridgeQuotes.tsx (2)
  • 64-71: The integration of synapseSDK.applyBridgeSlippage within the fetchBridgeQuote function correctly replaces the previous slippage logic with a standardized method from the SDK.
  • 92-93: The updated references to originQueryWithSlippage and destQueryWithSlippage in the return object of fetchBridgeQuote function are consistent with the new slippage calculation logic.
packages/synapse-interface/pages/swap/index.tsx (2)
  • 162-163: The use of synapseSDK.applySwapSlippage to obtain originQueryWithSlippage directly is a good simplification of the previous logic.
  • 188-188: The quote property in the dispatch call correctly uses originQueryWithSlippage instead of the previously used newOriginQuery.
packages/synapse-interface/pages/state-managed-bridge/index.tsx (2)
  • 235-242: The replacement of the previous slippage logic with synapseSDK.applyBridgeSlippage in the StateManagedBridge component is correctly implemented.
  • 269-270: The updated references to originQueryWithSlippage and destQueryWithSlippage in the return object of the StateManagedBridge component are consistent with the new slippage calculation logic.

Copy link

cloudflare-workers-and-pages bot commented Jan 17, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 994db31
Status: ✅  Deploy successful!
Preview URL: https://e200cb75.sanguine.pages.dev
Branch Preview URL: https://fe-sdk-slippage-method.sanguine.pages.dev

View logs

@ChiTimesChi
Copy link
Collaborator

Cannot read properties of undefined (reading 'swapAdapter')

This error is thrown on a swap attempt in this test build, figuring out if this is present in master (not seeing this in production right now)

@ChiTimesChi
Copy link
Collaborator

Update: not seeing this error in the latest build from master
https://github.com/synapsecns/sanguine/actions/runs/7547206402/job/20546661161#step:8:23

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7d8be3d and 3fe9dc7.
Files selected for processing (1)
  • packages/synapse-interface/pages/swap/index.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/synapse-interface/pages/swap/index.tsx

Copy link
Collaborator

@ChiTimesChi ChiTimesChi left a comment

Choose a reason for hiding this comment

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

LGTM, the fix above appears to be working.

@ChiTimesChi
Copy link
Collaborator

Actually, let's remove unused subtractSlippage imports?
This + the same in two other affected files.

import { subtractSlippage } from '@/utils/slippage'

Can't rip this function entirely yet, as it's still used for slippage on add/remove liquidity operations. Opened an issue for updating the SDK:

@bigboydiamonds
Copy link
Collaborator Author

Actually, let's remove unused subtractSlippage imports? This + the same in two other affected files.

import { subtractSlippage } from '@/utils/slippage'

Can't rip this function entirely yet, as it's still used for slippage on add/remove liquidity operations. Opened an issue for updating the SDK:

Cleaned imports in aca4a49

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3fe9dc7 and 994db31.
Files selected for processing (3)
  • packages/synapse-interface/pages/state-managed-bridge/index.tsx (3 hunks)
  • packages/synapse-interface/pages/swap/index.tsx (3 hunks)
  • packages/synapse-interface/utils/actions/fetchBridgeQuotes.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/synapse-interface/pages/swap/index.tsx
  • packages/synapse-interface/utils/actions/fetchBridgeQuotes.tsx
Additional comments: 2
packages/synapse-interface/pages/state-managed-bridge/index.tsx (2)
  • 234-241: The integration of synapseSDK.applyBridgeSlippage replaces the previous slippage calculation logic. Ensure that this new method is thoroughly tested, especially since it affects financial transactions.
  • 268-269: The new slippage calculation results are being used in the setBridgeQuote dispatch call. Confirm that the rest of the application is compatible with this new structure of originQuery and destQuery to prevent any unintended side effects.

@bigboydiamonds bigboydiamonds merged commit d84eb72 into master Jan 17, 2024
42 checks passed
@bigboydiamonds bigboydiamonds deleted the fe/sdk-slippage-method branch January 17, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants