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

Updating incentivized pools #3464

Merged
merged 8 commits into from
Dec 16, 2024
Merged

Updating incentivized pools #3464

merged 8 commits into from
Dec 16, 2024

Conversation

Defi-Moses
Copy link
Collaborator

@Defi-Moses Defi-Moses commented Dec 16, 2024

Description
A clear and concise description of the features you're adding in this pull request.

Additional context
Add any other context about the problem you're solving.

Metadata

  • Fixes #[Link to Issue]

Summary by CodeRabbit

  • New Features

    • Added new endpoints for retrieving transaction statuses: /pending-transactions/missing-claim, /pending-transactions/missing-proof, /pending-transactions/missing-relay, and /pending-transactions/exceed-deadline.
  • Updates

    • The /bridge endpoint now requires originUserAddress and destAddress for generating call data.
    • The /bridgeTxInfo endpoint has been deprecated.
  • Bug Fixes

    • Enhanced error handling and response structures for better consistency across endpoints.
  • Documentation

    • Updated documentation to clarify parameter requirements for the /bridge endpoint and noted the deprecation of the /bridgeTxInfo endpoint.
  • Tests

    • Updated test cases to reflect new parameter requirements and added scenarios for missing parameters.

6a76580: docs preview link
6a76580: synapse-interface preview link
148a337: synapse-interface preview link

Copy link
Contributor

coderabbitai bot commented Dec 16, 2024

Walkthrough

The pull request introduces significant updates to the Synapse Protocol's REST API documentation and implementation. The primary changes involve modifying the /bridge endpoint to require both originUserAddress and destAddress parameters, deprecating the /bridgeTxInfo endpoint, and updating related test cases and documentation. Additionally, the changes include updates to token constants for Canto pool swap tokens, adjusting their incentivization status from true to false.

Changes

File Change Summary
docs/bridge/docs/02-Bridge/02-REST-API.md Updated API documentation, deprecated /bridgeTxInfo endpoint
packages/rest-api/src/controllers/bridgeController.ts Modified logic for handling destAddress and originUserAddress parameters
packages/rest-api/src/routes/bridgeRoute.ts Updated OpenAPI documentation for /bridge endpoint
packages/rest-api/src/tests/bridgeRoute.test.ts Added and modified test cases for bridge route
packages/rest-api/swagger.json Added new endpoints, updated existing endpoint schemas
packages/synapse-constants/src/constants/tokens/poolMaster.ts Changed incentivized property to false for Canto pool swap tokens
packages/synapse-interface/constants/tokens/poolMaster.ts Changed incentivized property to false for Canto pool swap tokens

Sequence Diagram

sequenceDiagram
    participant Client
    participant BridgeRoute
    participant BridgeController
    participant Synapse

    Client->>BridgeRoute: Request bridge with originUserAddress and destAddress
    BridgeRoute->>BridgeController: Validate parameters
    BridgeController->>Synapse: Call bridge function
    Synapse-->>BridgeController: Return bridge quote
    BridgeController-->>BridgeRoute: Generate response
    BridgeRoute-->>Client: Return bridge quote with callData
Loading

Suggested labels

size/s, Sol, Typescript

Suggested reviewers

  • trajan0x

Poem

🐰 Bridging tokens with a hop and a leap,
Parameters dance, no secrets to keep.
From Canto to cosmos, our API sings,
With callData wings and technological springs!
A rabbit's delight in code's sweet embrace! 🌉

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request.


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>, 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.

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 (2)
packages/rest-api/src/controllers/bridgeController.ts (1)

56-68: Consider enhancing error handling for missing parameters.

The logic for generating callData is correct, but consider providing more informative feedback when either parameter is missing.

Consider this enhancement:

 const callData =
   destAddress && originUserAddress
     ? await Synapse.bridge(
         destAddress,
         quote.routerAddress,
         Number(fromChain),
         Number(toChain),
         fromToken,
         amountInWei,
         quote.originQuery,
         quote.destQuery
       )
-    : null
+    : {
+        data: null,
+        reason: !destAddress ? 'Missing destAddress' : 'Missing originUserAddress'
+      }
packages/rest-api/src/tests/bridgeRoute.test.ts (1)

Line range hint 177-211: LGTM! Consider adding test case for different addresses.

The test cases effectively verify the callData generation requirements. Consider adding a test case where destAddress and originUserAddress are different valid addresses.

Add this test case:

it('should return bridge quotes with callData when using different addresses', async () => {
  const response = await request(app).get('/bridge').query({
    fromChain: '1',
    toChain: '10',
    fromToken: USDC.addresses[1],
    toToken: USDC.addresses[10],
    amount: '1000',
    destAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
    originUserAddress: '0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5',
  })

  expect(response.status).toBe(200)
  expect(Array.isArray(response.body)).toBe(true)
  expect(response.body.length).toBeGreaterThan(0)
  expect(response.body[0]).toHaveProperty('callData')
})
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3511c73 and c9ec8e1.

📒 Files selected for processing (7)
  • docs/bridge/docs/02-Bridge/02-REST-API.md (1 hunks)
  • packages/rest-api/src/controllers/bridgeController.ts (1 hunks)
  • packages/rest-api/src/routes/bridgeRoute.ts (1 hunks)
  • packages/rest-api/src/tests/bridgeRoute.test.ts (2 hunks)
  • packages/rest-api/swagger.json (1 hunks)
  • packages/synapse-constants/src/constants/tokens/poolMaster.ts (2 hunks)
  • packages/synapse-interface/constants/tokens/poolMaster.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/rest-api/src/routes/bridgeRoute.ts
🔇 Additional comments (5)
packages/rest-api/src/tests/bridgeRoute.test.ts (1)

Line range hint 213-227: LGTM! Test case covers the missing originUserAddress scenario.

The test case effectively verifies that callData is null when originUserAddress is not provided.

docs/bridge/docs/02-Bridge/02-REST-API.md (1)

29-30: LGTM! Documentation clearly communicates API changes.

The documentation effectively communicates both the deprecation of /bridgeTxInfo and the new requirements for /bridge.

packages/synapse-interface/constants/tokens/poolMaster.ts (2)

477-477: Verify the impact of disabling incentives for CANTO_POOL_SWAP_TOKEN

The incentivization status for the Canto NOTE Stableswap Pool is being disabled. Please ensure this change is coordinated with any staking or rewards systems.

✅ Verification successful

Setting incentivized to false for CANTO_POOL_SWAP_TOKEN is safe

The change is safe as the token was already not being used for staking rewards:

  • The token has a miniChefAddress but was already marked as incentivized: false in both interface and constants packages
  • The staking functionality checks the incentivized flag before enabling rewards
  • No active staking or rewards logic was found that specifically depends on this token
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any references to CANTO_POOL_SWAP_TOKEN incentives
rg -A 3 "CANTO_POOL_SWAP_TOKEN.*incentiv"

# Check for any staking-related imports or usage
rg "import.*CANTO_POOL_SWAP_TOKEN" -A 5

Length of output: 85


Script:

#!/bin/bash
# Let's try a broader search for CANTO_POOL_SWAP_TOKEN usage
rg "CANTO_POOL_SWAP_TOKEN" -A 5

# Search for any files importing from poolMaster.ts
fd -e ts -e js -x rg "from.*poolMaster" {} \;

# Look for any staking or rewards related code that might use pool tokens
rg -i "staking|rewards|incentiv" -g "*.ts" -g "*.js" -A 3

Length of output: 29283


526-526: Verify the impact of disabling incentives for CANTO_WRAPPER_POOL_SWAP_TOKEN

The incentivization status for the Canto Wrapper Pool is being disabled. Please ensure this change is coordinated with any staking or rewards systems.

✅ Verification successful

Based on the results from our verification attempts, I can now generate the final response:

Setting incentivized to false for CANTO_WRAPPER_POOL_SWAP_TOKEN appears safe

The codebase analysis shows no direct dependencies between CANTO_WRAPPER_POOL_SWAP_TOKEN and any staking or rewards systems. The token was already configured with incentivized: false and miniChefAddress in its definition, suggesting this is just a configuration update to maintain consistency.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any references to CANTO_WRAPPER_POOL_SWAP_TOKEN incentives
rg -A 3 "CANTO_WRAPPER_POOL_SWAP_TOKEN.*incentiv"

# Check for any staking-related imports or usage
rg "import.*CANTO_WRAPPER_POOL_SWAP_TOKEN" -A 5

Length of output: 101


Script:

#!/bin/bash
# Let's first find where CANTO_WRAPPER_POOL_SWAP_TOKEN is defined and used
rg "CANTO_WRAPPER_POOL_SWAP_TOKEN" -B 2 -A 2

# Check for any staking or rewards related files/systems
fd "stake|reward|incentiv" --type f

# Look for any pool-related incentive configurations
rg "incentivized.*true|incentivized.*false" -B 2 -A 2

Length of output: 92905


Script:

#!/bin/bash
# Let's check for any staking or rewards related code specifically for CANTO pools
rg -B 2 -A 2 "CANTO.*stake|CANTO.*reward|CANTO.*incentiv"

# Check for any references to miniChef (staking contract) for CANTO
rg "CANTO.*miniChef" -B 2 -A 2

# Look for any imports or usage of CANTO_WRAPPER_POOL_SWAP_TOKEN in staking-related files
fd "stake|reward" --type f --exec rg "CANTO_WRAPPER_POOL_SWAP_TOKEN" {} \;

Length of output: 170

packages/synapse-constants/src/constants/tokens/poolMaster.ts (1)

476-476: LGTM! Changes are consistent with interface file

The incentivization changes for both Canto pools are properly synchronized between the interface and implementation files.

Also applies to: 525-525

Copy link

cloudflare-workers-and-pages bot commented Dec 16, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: f2c38b0
Status: ✅  Deploy successful!
Preview URL: https://7cc361a7.sanguine-fe.pages.dev
Branch Preview URL: https://fe-patch-incentivized-pools.sanguine-fe.pages.dev

View logs

Copy link

cloudflare-workers-and-pages bot commented Dec 16, 2024

Deploying sanguine with  Cloudflare Pages  Cloudflare Pages

Latest commit: f2c38b0
Status: ✅  Deploy successful!
Preview URL: https://96dae548.sanguine.pages.dev
Branch Preview URL: https://fe-patch-incentivized-pools.sanguine.pages.dev

View logs

Copy link

codecov bot commented Dec 16, 2024

Bundle Report

Changes will decrease total bundle size by 2.64MB (-7.41%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sdk-router-@synapsecns/sdk-router-esm* 255.26kB 609 bytes (0.24%) ⬆️
sdk-router-@synapsecns/sdk-router-cjs* 527.39kB 410.15kB (349.84%) ⬆️
explorer-ui-server-cjs* 724.31kB 141.75kB (-16.37%) ⬇️
explorer-ui-client-array-push* 2.17MB 146.63kB (-6.34%) ⬇️
synapse-interface-client-array-push* 7.41MB 132.5kB (1.82%) ⬆️
synapse-interface-server-cjs* 1.66MB 160.56kB (10.74%) ⬆️
widget-cjs-esm* 271.27kB 2.03kB (-0.74%) ⬇️
docs-bridge-client-array-push 7.51MB 393.18kB (-4.98%) ⬇️
docs-bridge-server-cjs 11.86MB 3.01MB (-20.25%) ⬇️
synapse-constants-esm-cjs* 174.63kB 174.63kB (100%) ⬆️
synapse-constants-cjs-esm* 174.18kB 174.18kB (100%) ⬆️

ℹ️ *Bundle size includes cached data from a previous commit

@Defi-Moses Defi-Moses merged commit ff03881 into master Dec 16, 2024
33 of 34 checks passed
@Defi-Moses Defi-Moses deleted the fe/patch-incentivized-pools branch December 16, 2024 19:45
@coderabbitai coderabbitai bot mentioned this pull request Dec 29, 2024
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