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

feat(api): bridge limits [SLT-165] #3179

Merged
merged 40 commits into from
Sep 24, 2024
Merged

Conversation

bigboydiamonds
Copy link
Collaborator

@bigboydiamonds bigboydiamonds commented Sep 24, 2024

PR introduces a new /bridgeLimits endpoint that provides the minimum and maximum origin input values for specific bridge routes. The endpoint allows users to query these limits by passing the following parameters:

•	fromChain: The originating chain ID
•	toChain: The destination chain ID
•	fromToken: The address of the token on the originating chain
•	toToken: The address of the token on the destination chain

Adds new /bridgeLimits Endpoint:
• The endpoint determines the min/max input values for a given bridge route.
• The input parameters (fromChain, toChain, fromToken, toToken) are used to match and return the appropriate route limits.
• returns { minOriginValue, maxOriginValue }

Additional context
Will be V1 initially deployed, following up with an optimization for resources.

Summary by CodeRabbit

  • New Features

    • Introduced a new route for managing bridge limits between blockchain networks.
    • Added a controller to handle requests for bridge limits, including validation and response formatting.
    • New script command for generating limits and fetching bridge quotes.
    • Implemented functionality for constructing a JSON representation of swappable tokens across different blockchain networks.
  • Bug Fixes

    • Improved address normalization for token lookups to enhance reliability.
  • Tests

    • Added a test suite for the new bridge limits route to ensure correct functionality and error handling.
  • Documentation

    • Updated package.json files to reflect new scripts and dependencies.

02d77f8: synapse-interface preview link

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Warning

Rate limit exceeded

@bigboydiamonds has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 33 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between c6b5d30 and 30fd0c5.

Walkthrough

This pull request introduces several enhancements to the rest-api and synapse-interface packages. Key changes include the addition of a new controller and route for managing bridge limits, along with new utility functions for fetching bridge quotes and generating limit values. The package.json files for both packages have been updated to include new scripts and dependencies. Additionally, new test cases have been implemented to ensure the functionality of the bridge limits route.

Changes

File Path Change Summary
packages/rest-api/package.json Added new dependency "@ethersproject/address": "^5.7.0" and updated existing dependencies.
packages/rest-api/src/controllers/bridgeLimitsController.ts Introduced bridgeLimitsController to handle requests for bridge limits and validate parameters.
packages/rest-api/src/routes/bridgeLimitsRoute.ts Created a new route for GET requests to /bridgeLimits with validation for query parameters.
packages/rest-api/src/routes/index.ts Registered the new bridgeLimitsRoute under /bridgeLimits.
packages/rest-api/src/tests/bridgeLimitsRoute.test.ts Added tests for the bridgeLimitsRoute to verify functionality and error handling.
packages/rest-api/src/utils/bridgeLimitMapping.ts Added constructJSON function to create a JSON representation of swappable tokens.
packages/rest-api/src/utils/tokenAddressToToken.ts Updated address normalization using @ethersproject/address.
packages/synapse-interface/package.json Added script "limits:generate" for executing limit generation.
packages/synapse-interface/scripts/generateLimits.js Implemented a script to generate limit values for token bridges.
packages/synapse-interface/scripts/utils/fetchBridgeQuote.js Introduced function to fetch bridge quotes from the Synapse Protocol API.

Possibly related PRs

  • REST API Migration #3049: The changes in the main PR involve the addition of a new dependency related to token handling, which aligns with the modifications in the tokenAddressToToken function in this PR that enhances token address normalization.
  • REST API Improvements [SLT-179] #3133: The main PR's updates to the bridgeTxInfoController and swapTxInfoController for handling token addresses relate to the improvements made in this PR for validating token addresses in the respective controllers.
  • Adds /destinationTokens route [SLT-204] #3151: The introduction of the /destinationTokens route in the main PR is directly related to the changes in this PR, which also focuses on enhancing the API's functionality by adding a new route for retrieving destination tokens.
  • fix(synapse-interface): Reorders validation to check existence first #3156: The reordering of validation checks in the main PR to prioritize existence checks is relevant to the changes in this PR, which similarly enhances validation logic across multiple routes.
  • feat(rest-api): Adds Swagger for api docs [SLT-205] #3159: The integration of Swagger for API documentation in the main PR complements the overall improvements in API structure and usability, which is a focus of this PR as well.

Suggested labels

M-docs, M-deps

Suggested reviewers

  • abtestingalpha
  • trajan0x
  • ChiTimesChi
  • Defi-Moses

🐰 In the code we hop and play,
New limits found along the way.
With routes and tests, we pave the path,
For bridging tokens, do the math!
So let’s rejoice, our work is done,
In the world of chains, we’ve just begun! 🌟


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

@github-actions github-actions bot added javascript Pull requests that update Javascript code M-synapse-interface Sol Typescript size/l labels Sep 24, 2024
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: 20

Outside diff range and nitpick comments (8)
packages/rest-api/src/utils/tokenAddressToToken.ts (2)

13-13: Good use of the normalized address.

Using the normalized address to access chainData is consistent with the earlier normalization step. This ensures that token lookups are performed using a standardized address format, reducing the risk of missing token information due to address format inconsistencies.

Consider moving the address normalization closer to where it's used to improve code readability:

 export const tokenAddressToToken = (chain: string, tokenAddress: string) => {
-  const address = getAddress(tokenAddress)
-
   const chainData = BRIDGE_MAP[chain]
   if (!chainData) {
     return null
   }
 
+  const address = getAddress(tokenAddress)
   const tokenInfo = chainData[address]

This change would make the flow of the function more intuitive, as the normalization happens just before it's needed.


20-23: Consistent use of normalized address in the return statement.

Returning the normalized address instead of the original tokenAddress is a good practice. It ensures consistency throughout the function and provides a standardized address format to the caller.

Consider adding a type annotation for the return value to improve code clarity:

interface TokenInfo {
  address: string;
  symbol: string;
  decimals: number;
}

export const tokenAddressToToken = (chain: string, tokenAddress: string): TokenInfo | null => {
  // ... existing code ...

  return {
    address,
    symbol: tokenInfo.symbol,
    decimals: tokenInfo.decimals,
  }
}

This change would make the function's return type explicit, improving code readability and type safety.

packages/rest-api/src/routes/bridgeLimitsRoute.ts (1)

15-26: Minor inconsistency in error messages for chain validations.

There's a slight inconsistency in the error messages for fromChain and toChain validations:

  • For fromChain, the "required" message is first, followed by "unsupported".
  • For toChain, the order is reversed.

Consider standardizing these messages for better consistency:

check('fromChain')
  .exists()
  .withMessage('fromChain is required')
  .isNumeric()
  .custom((value) => CHAINS_ARRAY.some((c) => c.id === Number(value)))
  .withMessage('Unsupported fromChain'),
check('toChain')
  .exists()
  .withMessage('toChain is required')
  .isNumeric()
  .custom((value) => CHAINS_ARRAY.some((c) => c.id === Number(value)))
  .withMessage('Unsupported toChain'),
packages/rest-api/src/tests/bridgeLimitsRoute.test.ts (2)

10-35: LGTM: Good coverage for happy path scenarios.

The tests for USDC and ETH bridging cover the basic functionality well. They check for the correct status code and the presence of expected properties in the response.

Consider adding assertions to check if the returned maxOriginAmount and minOriginAmount are within expected ranges or have specific relationships (e.g., max > min). This would provide more robust validation of the API's behavior.

Example:

expect(Number(response.body.maxOriginAmount)).toBeGreaterThan(Number(response.body.minOriginAmount))
expect(Number(response.body.minOriginAmount)).toBeGreaterThan(0)

62-81: LGTM: Good coverage for missing token parameters.

These test cases effectively validate the API's behavior when required token parameters are missing. The specific error field assertions are good for catching regressions.

Consider enhancing these tests by also asserting the error message, not just the error field. This would provide more comprehensive validation of the API's error responses. For example:

expect(response.body.error).toHaveProperty('message', 'Missing required parameter: fromToken')

This addition would ensure that both the error field and the error message are correct, providing more robust test coverage.

packages/rest-api/src/controllers/bridgeLimitsController.ts (1)

20-28: Consider making the upper limit value configurable

Currently, the upper limit value is hard-coded as '1000000'. For greater flexibility and maintainability, consider making this value configurable, possibly through environment variables or a configuration file, allowing adjustments without code changes.

packages/synapse-interface/scripts/generateLimits.js (2)

157-179: Introduce delay between retries to handle transient errors

In the retryFetchBridgeQuote function, retries happen immediately after a failure. Introducing a delay between retries can help avoid issues caused by transient network errors or API rate limiting.

Apply this diff to add a delay of 1 second between retries:

        } catch (error) {
          attempt++
          console.error(
            `Attempt ${attempt} failed for ${originChainId} ${originTokenAddress} to ${destinationChainId} ${destinationTokenAddress}:`,
            error
          )
+         // Introduce a 1-second delay before the next retry
+         await new Promise((resolve) => setTimeout(resolve, 1000));
          if (attempt === maxRetries) {
            throw new Error(
              `Failed after ${maxRetries} attempts for ${originChainId} ${originTokenAddress} to ${destinationChainId} ${destinationTokenAddress}`
            )
          }
        }

15-16: Clarify the order of upper limit values

In upperLimitValues, the values are listed in descending order: ['20000000', '1000000']. If the intention is to test larger values first, this is acceptable. However, for clarity, consider sorting the values in ascending order unless there's a specific reason for the current order.

Apply this diff to reorder the upperLimitValues array:

 const lowerLimitValues = ['0.01', '0.1', '1', '10']
-const upperLimitValues = ['20000000', '1000000']
+const upperLimitValues = ['1000000', '20000000']
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0daec70 and 60138d4.

Files selected for processing (10)
  • packages/rest-api/package.json (1 hunks)
  • packages/rest-api/src/controllers/bridgeLimitsController.ts (1 hunks)
  • packages/rest-api/src/routes/bridgeLimitsRoute.ts (1 hunks)
  • packages/rest-api/src/routes/index.ts (2 hunks)
  • packages/rest-api/src/tests/bridgeLimitsRoute.test.ts (1 hunks)
  • packages/rest-api/src/utils/bridgeLimitMapping.ts (1 hunks)
  • packages/rest-api/src/utils/tokenAddressToToken.ts (1 hunks)
  • packages/synapse-interface/package.json (1 hunks)
  • packages/synapse-interface/scripts/generateLimits.js (1 hunks)
  • packages/synapse-interface/scripts/utils/fetchBridgeQuote.js (1 hunks)
Additional context used
Gitleaks
packages/rest-api/src/tests/bridgeLimitsRoute.test.ts

41-41: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


56-56: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

Additional comments not posted (18)
packages/rest-api/src/utils/tokenAddressToToken.ts (1)

1-1: Excellent addition of address normalization!

The introduction of getAddress from '@ethersproject/address' and its usage to normalize the token address is a great improvement. This change enhances the robustness of the function by ensuring consistent formatting of Ethereum addresses, regardless of the input format (checksum, lowercase, etc.).

Also applies to: 6-7

packages/synapse-interface/scripts/utils/fetchBridgeQuote.js (1)

35-35: Module export looks good.

The export of the fetchBridgeQuote function is correct and follows common JavaScript module patterns.

packages/rest-api/src/routes/index.ts (2)

22-22: LGTM! Verify the functionality of the '/bridgeLimits' endpoint

The route registration for /bridgeLimits is correctly implemented and aligns with the PR objectives. It follows the existing code style and uses the imported bridgeLimitsRoute.

To ensure the endpoint is functioning as expected, please consider adding the following tests:

  1. Verify that the endpoint accepts the required parameters: fromChain, toChain, fromToken, and toToken.
  2. Check if the endpoint returns the expected minOriginValue and maxOriginValue for valid input parameters.
  3. Test the endpoint's behavior with invalid or missing parameters.

These tests should be implemented in the appropriate test file for this route.


13-13: Summary: Changes align well with PR objectives

The additions to this file (import statement and route registration) are correctly implemented and necessary for introducing the new /bridgeLimits endpoint. These changes align well with the PR objectives and follow the existing code structure and style.

The new endpoint will allow users to query the minimum and maximum origin input values for specific bridge routes, enhancing the API's capabilities as intended.

Also applies to: 22-22

packages/rest-api/package.json (2)

19-19: LGTM: New script for generating bridge limits map.

The addition of the generate:limits-map script aligns well with the PR objectives. It will likely be used to generate the necessary data for the new /bridgeLimits endpoint.


22-22: LGTM: New dependency for Ethereum address handling.

The addition of @ethersproject/address is appropriate for handling Ethereum addresses in the new bridge limits functionality. The version specification (^5.7.0) allows for compatible updates and aligns with other @ethersproject dependencies.

To ensure this dependency is being used, please run the following script:

Verification successful

Verified: @ethersproject/address is properly utilized across the codebase.

The dependency @ethersproject/address is appropriately used in the following files:

  • packages/sdk-router/src/utils/validateAndParseAddress.ts
  • packages/explorer-ui/utils/validateAndParseAddress.ts
  • packages/sdk-router/src/rfq/ticker.ts
  • packages/rest-api/src/utils/tokenAddressToToken.ts

This confirms that the addition of the dependency is necessary and correctly implemented.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of @ethersproject/address in the codebase

# Test: Search for import statements or require calls using @ethersproject/address
rg --type typescript --type javascript 'from\s+["\']@ethersproject/address["\']|require\(["\']@ethersproject/address["\']'

Length of output: 93


Script:

#!/bin/bash
# Description: Verify the usage of @ethersproject/address in the codebase

# Test: Search for import statements or require calls using @ethersproject/address
rg --type typescript --type javascript "from\s+['\"]@ethersproject/address['\"]|require\(['\"]@ethersproject/address['\"]\)"

Length of output: 169


Script:

#!/bin/bash
# Description: Verify the usage of @ethersproject/address in the codebase

# Test: Search for import statements or require calls using @ethersproject/address
rg --glob '*.ts' --glob '*.js' "from\s+['\"]@ethersproject/address['\"]|require\(['\"]@ethersproject/address['\"]\)"

Length of output: 534

packages/rest-api/src/routes/bridgeLimitsRoute.ts (4)

1-8: Imports look good and are well-organized.

The necessary modules and functions are imported, following a logical order from third-party to local modules. All imports appear to be relevant to the implemented functionality.


10-11: Router setup is correct and follows best practices.

The Express router is created correctly, adhering to Express.js best practices.


12-48: GET route implementation is robust and well-structured.

The route is correctly set up with comprehensive validation checks for all query parameters. The use of custom validations and appropriate middleware ordering (validation, error handling, controller) is commendable.


50-50: Export statement is correct.

The router is properly exported as the default export, which is a common practice for Express routers.

packages/rest-api/src/tests/bridgeLimitsRoute.test.ts (4)

1-8: LGTM: Imports and setup are well-structured.

The imports and setup for the test suite are appropriate and follow good practices. Using constants for token addresses is a commendable approach.


37-49: LGTM: Proper error handling for unsupported fromChain.

This test case effectively validates the API's behavior when an unsupported fromChain is provided. The use of a non-existent chain ID and the specific error message assertion are good practices for ensuring robust error handling.

Tools
Gitleaks

41-41: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1-81: Overall, excellent test coverage for the bridgeLimitsRoute.

This test suite provides comprehensive coverage for the /bridgeLimits endpoint, including both happy path scenarios and error handling. The tests are well-structured and follow good practices.

To further enhance the test suite, consider implementing the following suggestions:

  1. Add assertions to check if the returned maxOriginAmount and minOriginAmount are within expected ranges or have specific relationships.
  2. Enhance the error handling tests by asserting both the error field and the error message for more comprehensive validation.

These improvements will make the test suite even more robust and effective at catching potential issues.

Tools
Gitleaks

41-41: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


56-56: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


51-60: LGTM: Proper error handling for unsupported toChain.

This test case effectively validates the API's behavior when an unsupported toChain is provided. The use of a non-existent chain ID and the specific error message assertion are good practices for ensuring robust error handling.

Regarding the static analysis hint about potential API keys in the token addresses:

This script confirms that the flagged address is a valid Ethereum address format, indicating that the static analysis hint is likely a false positive.

Verification successful

LGTM: Proper error handling for unsupported toChain and valid token addresses.

This test case effectively validates the API's behavior when an unsupported toChain is provided. The use of a non-existent chain ID and the specific error message assertion are good practices for ensuring robust error handling.

Regarding the static analysis hint about potential API keys in the token addresses:

  • The address 0x176211869cA2b568f2A7D4EE941E073a821EE1ff is a valid Ethereum address, indicating that the static analysis hint is a false positive.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify if the flagged addresses are valid Ethereum addresses
echo "Checking address: 0x176211869cA2b568f2A7D4EE941E073a821EE1ff"
if [[ "0x176211869cA2b568f2A7D4EE941E073a821EE1ff" =~ ^0x[a-fA-F0-9]{40}$ ]]; then
    echo "Valid Ethereum address"
else
    echo "Invalid Ethereum address"
fi

Length of output: 259

Tools
Gitleaks

56-56: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

packages/synapse-interface/package.json (2)

Line range hint 1-134: Summary: New script added for generating bridge limits data.

The changes in this file are minimal and align well with the PR objectives. A new script command "limits:generate" has been added to facilitate the generation of bridge limits data, which is crucial for the new /bridgeLimits API endpoint. This addition doesn't affect any existing configurations or dependencies.

To ensure smooth integration, consider the following recommendations:

  1. Document the purpose and usage of the new script in the project's README or relevant documentation.
  2. If not already done, add appropriate error handling in the generateLimits.js script to manage potential issues during limit generation.
  3. Consider adding a test case to verify the successful execution of the new script as part of the CI/CD pipeline.

25-25: LGTM! Verify the existence of the generateLimits.js script.

The addition of the "limits:generate" script aligns with the PR objectives for implementing bridge limits functionality. This script will likely be used to generate necessary data or code for the new /bridgeLimits API endpoint.

To ensure the script file exists, run the following command:

If the script is found, consider adding a brief comment in the package.json to describe its purpose:

 "scripts": {
   ...
-  "limits:generate": "node scripts/generateLimits.js",
+  "limits:generate": "node scripts/generateLimits.js", // Generate bridge limits data for the API
   ...
 },
Verification successful

Verified! The limits:generate script has been successfully added, and the generateLimits.js file exists within the codebase.

Consider adding a brief comment in package.json to describe its purpose:

 "scripts": {
   ...
-  "limits:generate": "node scripts/generateLimits.js",
+  "limits:generate": "node scripts/generateLimits.js", // Generates bridge limits data for the API
   ...
 },
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the existence of the generateLimits.js script
fd --type file --full-path "scripts/generateLimits.js"

Length of output: 107

packages/rest-api/src/controllers/bridgeLimitsController.ts (2)

77-85: Verify correct token information retrieval

Double-check that the correct chain IDs and token addresses are used when fetching token information for maxAmountOriginQueryTokenOutInfo and minAmountOriginQueryTokenOutInfo. Any mismatch may lead to incorrect decimal values during amount formatting.


87-95: Validate the correctness of amount formatting

Ensure that maxBridgeAmountQuote.maxAmountOut and minBridgeAmountQuote.feeAmount are correctly formatted using the corresponding token decimals. Incorrect decimals may result in inaccurate amounts returned to the client.

Comment on lines 1 to 2
// URL for Synapse bridge quotes
const BRIDGE_URL = 'https://api.synapseprotocol.com/bridge'
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using environment variables for the API URL.

While using a constant for the API URL is good for maintainability, consider using environment variables to allow for different URLs in various environments (development, staging, production).

You could modify the code as follows:

-const BRIDGE_URL = 'https://api.synapseprotocol.com/bridge'
+const BRIDGE_URL = process.env.SYNAPSE_API_URL || 'https://api.synapseprotocol.com/bridge'

This change allows you to override the URL using an environment variable while maintaining a default value.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// URL for Synapse bridge quotes
const BRIDGE_URL = 'https://api.synapseprotocol.com/bridge'
// URL for Synapse bridge quotes
const BRIDGE_URL = process.env.SYNAPSE_API_URL || 'https://api.synapseprotocol.com/bridge'

packages/rest-api/src/utils/bridgeLimitMapping.ts Outdated Show resolved Hide resolved
packages/rest-api/src/utils/bridgeLimitMapping.ts Outdated Show resolved Hide resolved
packages/synapse-interface/scripts/generateLimits.js Outdated Show resolved Hide resolved
packages/synapse-interface/scripts/generateLimits.js Outdated Show resolved Hide resolved
packages/synapse-interface/scripts/generateLimits.js Outdated Show resolved Hide resolved
Copy link

cloudflare-workers-and-pages bot commented Sep 24, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 30fd0c5
Status: ✅  Deploy successful!
Preview URL: https://5c3b89f1.sanguine-fe.pages.dev
Branch Preview URL: https://api-bridge-limits-v1.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.96419%. Comparing base (9418b40) to head (30fd0c5).
Report is 8 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #3179         +/-   ##
===================================================
- Coverage   41.54443%   37.96419%   -3.58024%     
===================================================
  Files            460         418         -42     
  Lines          25770       24236       -1534     
  Branches         357          82        -275     
===================================================
- Hits           10706        9201       -1505     
+ Misses         14326       14297         -29     
  Partials         738         738                 
Flag Coverage Δ
packages 90.96267% <ø> (ø)
solidity ?

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.

* type: string
*/
router.get(
'/',
Copy link
Collaborator

Choose a reason for hiding this comment

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

See other routes that have normalizeNativeTokenAddress and checksumAddreses middleware.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, updated to use those middleware functions in 30fd0c5

import { BRIDGE_MAP } from '../constants/bridgeMap'

export const tokenAddressToToken = (chain: string, tokenAddress: string) => {
const address = getAddress(tokenAddress)
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Do we need to do this here? (note comment above where middleware will normalize & checksum addresses)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope! Above middleware takes care of this, removed in 30fd0c5

@bigboydiamonds bigboydiamonds merged commit 98362bb into master Sep 24, 2024
36 checks passed
@bigboydiamonds bigboydiamonds deleted the api/bridge-limits-v1 branch September 24, 2024 19:33
abtestingalpha added a commit that referenced this pull request Sep 26, 2024
* update bl

* remove global solidity extension settings

* use monorepo support in global workspace only

* - use Solidity extension for formatting *.sol files
- use `forge fmt` as formatter in Solidity extension

* REST API Improvements [SLT-179] (#3133)

* fix swaptxinfo function

* Updates test coverage command

* migrating to using token addresses instead of symbols

* fix linting errors

* fixing swaptxinfocontroller

* new tests and new functionality

---------

Co-authored-by: abtestingalpha <[email protected]>

* Publish

 - @synapsecns/[email protected]
 - @synapsecns/[email protected]

* fix harmony proxy (#3149)


Co-authored-by: Trajan0x <[email protected]>

* merging rfq indexer into monorepo [SLT-164]  [SLT-176] (#3136)

* merging rfq indexer into monorepo

* nuke .env

* fix commands

* fix package name

* test coverage script

* rough pass at docs and some linting and fixes yarn

* Upgrades wagmi & rainbowkit

* indxer

* Adds invisible but used packages

* +recent-invalid-fills [SLT-188]

* Moves wagmi to root

* new endpoints and clean up linting

---------

Co-authored-by: Trajan0x <[email protected]>
Co-authored-by: abtestingalpha <[email protected]>
Co-authored-by: parodime <[email protected]>

* Publish

 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]

* Adds /destinationTokens route [SLT-204] (#3151)

* Adds /destinationTokens route
* ZeroAddress & NativeGasAddress
* Adds test for native gas tokens
* Checksums incoming token address params

* Publish

 - @synapsecns/[email protected]

* boba pause (#3150)

* boba pause

* only boba to txns

* Publish

 - @synapsecns/[email protected]

* fix(synapse-interface): Reorders validation to check existence first (#3156)

* Reorders validation to check existence first
* Removes duplicates

* Publish

 - @synapsecns/[email protected]

* Fix boba pause (#3158)

* Publish

 - @synapsecns/[email protected]

* update bl

* feat(rest-api): Adds Swagger for api docs [SLT-205] (#3159)

* Adds Swagger for api docs

* Replace prepended verb Get routes with nouns

* Adds dev flag for swagger serverUrl

* Publish

 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]

* Pulls version from package json (#3160)

* Publish

 - @synapsecns/[email protected]

* Require vs import due to file location (#3161)

* Require vs import due to file location

* Publish

 - @synapsecns/[email protected]

* Prevent caching of api docs (#3162)

* Publish

 - @synapsecns/[email protected]

* feat(contracts-rfq): relay/prove/claim with different address [SLT-130] (#3138)

* init. solidity ^. FbV2 relay/prove/claim overloads

* +IFastBridgeV2, explicit address0 cast, func scope & inheritdoc fixes

* pragma lock, contract relabel

* feat: start scoping V2 tests

* test: override relayer role scenarios, no longer enforced by V2

* test: finish the parity test

* test: the management methods

* test: dst chain scenarios

* test: bridge

* test: prove

* test: claim

* test: dispute

* test: refund

* test: bridge reverts

* remove redundant extend. rearrange inherit list

* revert 0.8.20 in favor of user (non-ws) setting

---------

Co-authored-by: ChiTimesChi <[email protected]>

* Publish

 - [email protected]

* fix(promexporter): make spans better (#3164)

* move the errors

* [goreleaser]

* fix v to w

* changing native token address standard [SLT-210] (#3157)

* changing native token address standard

* fixing tests

* normalizeNativeTokenAddress middleware, additional tests

---------

Co-authored-by: abtestingalpha <[email protected]>

* Publish

 - @synapsecns/[email protected]

* Refactoring rfq-indexer API and adding swagger docs [SLT-228] (#3167)

* refactoring and adding swagger

* remove testing scripts

* fix typos and consistency with 404 errors

* Publish

 - @synapsecns/[email protected]

* fix read mes (#3168)

* Publish

 - @synapsecns/[email protected]
 - [email protected]
 - @synapsecns/[email protected]

* fix(opbot): use submitter get tx status [SLT-158] (#3134)

* use experimental logger to debug

* fix lint

* [goreleaser]

* use submitter instead of client

* [goreleaser]

* [goreleaser]

* fix(synapse-interface): Additional checks on screen [SLT-166] (#3152)

* Additional checks on screen

* Adds checks on chain/token changes

* Publish

 - @synapsecns/[email protected]

* feat(synapse-interface): confirm new price [SLT-150]  (#3084)

* add bridge quote history middleware

* request user confirm changes when quoted price updates

* add conditions for displaying confirm change state

* track initial quote initializing confirm change state

* specify output delta threshold

* callback functions to handle initialize/accept/reset confirm changes flow

* quote countdown timer animation to signal refresh

* implement automatic refresh intervals

* mouse move to refresh automatic intervals

* add i8n translations for button text

---------

Co-authored-by: abtestingalpha <[email protected]>

* Publish

 - @synapsecns/[email protected]

* fix: formatted bridge fee amount (#3165)

* Publish

 - @synapsecns/[email protected]

* fix(contracts-rfq): CI workflows [SLT-245] (#3178)

* fix: license, files

* fix: package name

* build: update solhint to latest

* build: remove prettier dependencies

* fix: solhint workflows

* build: update solhint in other packages as well

* chore: solhint rules, exceptions

* fix: silence linter warnings in tests

* chore: forge fmt

* add variable to test linter CI

* Revert "add variable to test linter CI"

This reverts commit 0629309.

* Publish

 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]

* feat(api): bridge limits [SLT-165]  (#3179)

* adds `/bridgeLimits` route, controller

* fetch best sdk quote for min/max origin amounts

* add tests

* implement middleware to normalize addresses

* adds swagger doc

* Publish

 - @synapsecns/[email protected]

* fix(contracts-rfq): limit the amount of solhint warnings [SLT-245] (#3182)

* ci: limit the amount of solhint warnings

* refactor: move the errors into the separate interface

* refactor: errors imports in tests

* Publish

 - @synapsecns/[email protected]

* ci: Solidity gas diff [SLT-259] (#3181)

* ci: run tests w/o coverage first for better visibility

* test: malform the test to check the adjusted workflow

* Revert "test: malform the test to check the adjusted workflow"

This reverts commit e7db6e1.

* ci: add gas-diff workflow

* try changing the contract to trigger gas diffs

* retrigger the workflow

* ci: provide the correct report path

* ci: run on pull requests only

* ci: save gas reports in monorepo root

* Revert "ci: run on pull requests only"

This reverts commit 0a01d60.

* Revert "try changing the contract to trigger gas diffs"

This reverts commit 91bc03e.

* refactor: wrap if statement

* refactor: exclude `solidity-devops` package in a more generic way

* ci: run tests w/o coverage for `solidity-devops`, add comments

* add generic comment to trigger `solidity-devops` workflows

* Revert "add generic comment to trigger `solidity-devops` workflows"

This reverts commit cc35a43.

* Publish

 - @synapsecns/[email protected]

* fix(contracts-core): set very high gas limit for intensive tests [SLT-259] (#3186)

* fix: set very high gas limit for intensive tests

* ci: speed up solidity coverage

* Publish

 - @synapsecns/[email protected]

* feat(rest-api): Adds validateRouteExists validation [SLT-260] (#3180)

* Adds validateRouteExists validation

* Remove timeouts for 400s

* Publish

 - @synapsecns/[email protected]

* add duplicate command warning (#3174)

Co-authored-by: Trajan0x <[email protected]>

* reduce solhint warnings on FbV2 (#3189)

* reduce solhint warnings on FbV2

* fix whitespace

* Publish

 - @synapsecns/[email protected]

* ci: solidity gas diff options [SLT-267] (#3193)

* ci: ignore test files in gas diff report

* add some changes to the test files

* ci: define some options for gas-diff

* try changing the contract to trigger gas diffs

* Revert "try changing the contract to trigger gas diffs"

This reverts commit 4504e3c.

* Revert "add some changes to the test files"

This reverts commit 7e7d6cb.

* prove w/ tx id [SLT-181] (#3169)

* prove w/ tx id SLT-181

* +proveOther tests, forge fmt

* fmt

* fmt

* Publish

 - @synapsecns/[email protected]

* fix(sdk-router): disable ARB airdrop tests (#3195)

* Publish

 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]
 - @synapsecns/[email protected]

* Fixing issue for wallet integration [SLT-270] (#3194)

* slight modification to graphql call

* fixing explorer frontend as well

* Publish

 - @synapsecns/[email protected]
 - @synapsecns/[email protected]

* store relayer on relay [SLT-182] (#3170)

* store relayer on relay [SLT-182]

* +tests, zeroAddr check, fmt

* Publish

 - @synapsecns/[email protected]

* Adjust text to trigger build (#3199)

* Publish

 - @synapsecns/[email protected]

* feat(synapse-interface): refund RFQ transaction [SLT-272] (#3197)

* Txn transaction refund tracking

* Update store to support tracking

* Query FastBridge contract for `bridgeStatuses` to find refund status

* Track bridge transaction `bridgeQuote.routerAddress` in store

* Fetch FastBridge contract address when only provided router address

* add translations

---------

Co-authored-by: aureliusbtc <[email protected]>
Co-authored-by: ChiTimesChi <[email protected]>
Co-authored-by: abtestingalpha <[email protected]>
Co-authored-by: Defi-Moses <[email protected]>
Co-authored-by: trajan0x <[email protected]>
Co-authored-by: Trajan0x <[email protected]>
Co-authored-by: parodime <[email protected]>
Co-authored-by: abtestingalpha <[email protected]>
Co-authored-by: abtestingalpha <[email protected]>
Co-authored-by: parodime <[email protected]>
Co-authored-by: vro <[email protected]>
Co-authored-by: ChiTimesChi <[email protected]>
Co-authored-by: bigboydiamonds <[email protected]>
Co-authored-by: bigboydiamonds <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code size/m Sol Typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants