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

[Smart Router] - with V3 #304

Merged
merged 18 commits into from
Aug 1, 2024
Merged

[Smart Router] - with V3 #304

merged 18 commits into from
Aug 1, 2024

Conversation

haunv3
Copy link
Contributor

@haunv3 haunv3 commented Jul 25, 2024

Summary by CodeRabbit

  • New Features

    • Updated the @oraichain/oraidex-common package to a stable version (1.1.1) with improved dependency management.
    • Introduced a new constant, MIXED_ROUTER, for enhanced contract interactions.
    • Added dedicated test build scripts for @oraichain/oraidex-universal-swap, contracts-sdk, and contracts-build packages to streamline testing processes.
  • Bug Fixes

    • Improved type safety in Axios adapter configurations, ensuring more reliable request handling.
  • Chores

    • Updated dependencies in oraidex-common-ui and @oraichain/oraidex-universal-swap for better performance and stability.

Copy link

coderabbitai bot commented Jul 25, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The recent updates enhance the oraidex-common, oraidex-common-ui, and other related packages through improved versioning, dependency management, and the introduction of testing configurations. Notable changes include the addition of constants for contract interactions, enhancements in Axios type safety, and streamlined testing build processes. These modifications aim to optimize functionality and ensure better performance and reliability throughout the ecosystem.

Changes

Files Change Summary
packages/oraidex-common/package.json, packages/oraidex-common-ui/package.json Version updated: oraidex-common from 1.0.93-beta.2 to 1.1.1; axios-extensions and axios updated.
packages/oraidex-common-ui/src/components/TVChartContainer/helpers/requests.ts Enhanced Axios import for type safety; minor formatting adjustments made; optimized adapter configuration.
packages/oraidex-common/src/constant.ts Introduced new constant MIXED_ROUTER; updated ORAIB_ORAICHAIN_CHANNELS_TEST with a new value.
packages/universal-swap/package.json Updated version from 1.0.93 to 1.0.94; added a new build script for testing purposes.
packages/universal-swap/tsconfig.test.json Introduced TypeScript configuration file for testing, extending base config for consistency.
packages/contracts-sdk/package.json Added "build:test" script for TypeScript compilation with testing context.
packages/contracts-sdk/tsconfig.test.json, packages/contracts-build/tsconfig.test.json Created TypeScript config files for testing, ensuring consistent compilation settings.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AxiosAdapter
    participant Cache
    participant API

    User->>AxiosAdapter: Send Request
    AxiosAdapter->>Cache: Check Cache for Response
    alt Cache Hit
        Cache-->>AxiosAdapter: Return Cached Response
    else Cache Miss
        AxiosAdapter->>API: Forward Request
        API-->>AxiosAdapter: Return API Response
        AxiosAdapter->>Cache: Store Response
    end
    AxiosAdapter-->>User: Return Final Response
Loading

🐇 In the garden, a rabbit hops free,
With code and updates, as bright as can be.
New paths for requests, swift as a breeze,
Caching and throttling, oh, what a tease!
Celebrate these changes, let joy be the key! 🌿✨


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 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

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

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

github-actions bot commented Jul 25, 2024

badge

Code Coverage Summary

Filename                                                                      Stmts    Miss  Cover    Missing
--------------------------------------------------------------------------  -------  ------  -------  ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
docs/assets/main.js                                                              58      58  0.00%    1-58
docs/assets/search.js                                                             1       1  0.00%    1
packages/ibc-routing/hardhat.config.ts                                           59      59  0.00%    1-75
packages/ibc-routing/src/db.ts                                                  158     158  0.00%    1-263
packages/ibc-routing/src/event.ts                                                85      85  0.00%    1-122
packages/ibc-routing/src/index.ts                                                31      31  0.00%    1-56
packages/ibc-routing/src/machine.ts                                              30      30  0.00%    1-34
packages/ibc-routing/test/mock-eth-ws.ts                                         52      52  0.00%    1-55
packages/ibc-routing/test/mock-tendermint-ws.spec.ts                             25      17  32.00%   7-24
packages/oraidex-common/src/alpha-network.ts                                     61       0  100.00%
packages/oraidex-common/src/axios-request.ts                                     11      11  0.00%    1-20
packages/oraidex-common/src/bigdecimal.ts                                       139      50  64.02%   23-24, 30-33, 40-41, 45-54, 63-65, 71-73, 120-124, 127-146, 149-150, 153-154, 180-181, 184-185
packages/oraidex-common/src/constant.ts                                         160       0  100.00%
packages/oraidex-common/src/helper.ts                                           464     139  70.04%   141-142, 145-156, 159-169, 276-283, 286-299, 309-315, 325-340, 343-350, 353-383, 386-394, 397-399, 402-404, 408-417, 426-440, 446-448, 533-534, 559-562
packages/oraidex-common/src/ibc-info.ts                                         168     168  0.00%    1-200
packages/oraidex-common/src/index.ts                                             13      13  0.00%    1-13
packages/oraidex-common/src/network.ts                                          961       0  100.00%
packages/oraidex-common/src/pairs.ts                                            154       4  97.40%   151-152, 157-158
packages/oraidex-common/src/token.ts                                             71       0  100.00%
packages/oraidex-common/src/wallet.ts                                           146     146  0.00%    1-236
packages/oraidex-common/src/config/chainInfosWithIcon.ts                        196     196  0.00%    1-210
packages/oraidex-common/src/interface/index.ts                                    1       1  0.00%    1
packages/oraidex-common/src/interface/wallet.ts                                  19      19  0.00%    1-20
packages/oraidex-common/tests/bigdecimal.spec.ts                                220       0  100.00%
packages/oraidex-common/tests/helper.spec.ts                                    560       8  98.57%   97-98, 337-338, 628-629, 659-660
packages/oraidex-common/tests/pairs.spec.ts                                      24       0  100.00%
packages/oraiswap-v3/src/const.ts                                                39       0  100.00%
packages/oraiswap-v3/src/handler.ts                                             123      14  88.61%   121-131, 134-136
packages/oraiswap-v3/src/helpers.ts                                             204      20  90.19%   110-111, 121-122, 147-148, 176-177, 187-188, 244-253
packages/oraiswap-v3/src/index.ts                                                 4       0  100.00%
packages/oraiswap-v3/src/types.ts                                                 0       0  100.00%
packages/oraiswap-v3/tests/handler.spec.ts                                       81       0  100.00%
packages/oraiswap-v3/tests/helpers.spec.ts                                      455       0  100.00%
packages/oraiswap-v3/tests/test-common.ts                                        32       0  100.00%
packages/universal-swap/src/handler.ts                                         1159     565  51.25%   77-78, 99-100, 114-116, 122-125, 136-138, 167-189, 268-298, 401-421, 504-514, 533, 535-539, 552-563, 570-616, 680-690, 693-703, 710-717, 731-809, 813-844, 848-867, 870-887, 891-942, 947-1030, 1036-1107, 1116-1121, 1140-1141, 1143-1144, 1150, 1154-1169, 1178-1181, 1193-1205, 1242-1245, 1252-1260, 1265, 1305-1306, 1336-1347, 1414-1415
packages/universal-swap/src/helper.ts                                           774     247  68.08%   80-82, 218-219, 373-375, 397-403, 427-429, 433-435, 442-472, 531-532, 575-582, 589-630, 645-702, 741-742, 757, 785, 792-813, 815-816, 849-850, 853-856, 866-908, 916-932, 991-1001, 1012-1017, 1036
packages/universal-swap/src/index.ts                                              5       5  0.00%    1-5
packages/universal-swap/src/swap-filter.ts                                       40       0  100.00%
packages/universal-swap/src/types.ts                                             10       0  100.00%
packages/universal-swap/src/wrapper.ts                                           79      79  0.00%    1-117
packages/universal-swap/src/proto/proto-gen.ts                                   71       0  100.00%
packages/universal-swap/src/universal-demos/alpha-smart-router.ts                84      84  0.00%    1-601
packages/universal-swap/src/universal-demos/evm-to-evm.ts                        48      48  0.00%    1-63
packages/universal-swap/src/universal-demos/from-cosmos-to-evm.ts                41      41  0.00%    1-53
packages/universal-swap/src/universal-demos/from-oraichain-to-oraichain.ts       49      49  0.00%    1-66
packages/universal-swap/src/universal-demos/ibc-hooks-demo.ts                    40      40  0.00%    1-55
packages/universal-swap/src/universal-demos/neutaro-ibc-demo.ts                  40      40  0.00%    1-47
packages/universal-swap/src/universal-demos/noble-ibc-demo.ts                    41      41  0.00%    1-45
packages/universal-swap/src/universal-demos/offline-wallet.ts                    19      19  0.00%    1-21
packages/universal-swap/tests/helper.spec.ts                                    883      26  97.05%   592-594, 956-978
packages/universal-swap/tests/index.spec.ts                                    1623      32  98.02%   239-242, 270-271, 282-283, 288-289, 291-292, 294-295, 1047-1066
packages/universal-swap/tests/smart-router-common.ts                            864       0  100.00%
packages/universal-swap/tests/test-common.ts                                     56       0  100.00%
TOTAL                                                                         10731    2596  75.80%

Diff against main

Filename                                                             Stmts    Miss  Cover
-----------------------------------------------------------------  -------  ------  --------
packages/oraidex-common/src/axios-request.ts                            -6      -6  +100.00%
packages/oraidex-common/src/constant.ts                                 +3       0  +100.00%
packages/oraidex-common/src/network.ts                                  +2       0  +100.00%
packages/universal-swap/src/handler.ts                                 +48     +13  +0.94%
packages/universal-swap/src/helper.ts                                   +7      +3  -0.10%
packages/universal-swap/src/universal-demos/alpha-smart-router.ts      +13     +13  +100.00%
packages/universal-swap/tests/index.spec.ts                             -1       0  +100.00%
packages/universal-swap/tests/smart-router-common.ts                   +59       0  +100.00%
TOTAL                                                                 +125     +23  +0.06%

Results for commit: 939f712

Minimum allowed coverage is 0%

♻️ This comment has been updated with latest results

Copy link

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

Outside diff range, codebase verification and nitpick comments (2)
packages/universal-swap/src/handler.ts (2)

623-623: Avoid magic strings.

The string "Oraichain" is used directly. Consider defining it as a constant to avoid potential typos and improve maintainability.

+ const ORAICHAIN = "Oraichain";
- const isInOraichain = path.chainId === "Oraichain";
+ const isInOraichain = path.chainId === ORAICHAIN;

634-636: Combine the initialization of lastInd and countTypeSwap into a single line.

Combining these initializations can make the code more concise.

- let lastInd = 0;
- let countTypeSwap = 0;
+ let lastInd = 0, countTypeSwap = 0;
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2533d80 and bc14f92.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (8)
  • packages/oraidex-common/package.json (1 hunks)
  • packages/oraidex-common/src/constant.ts (1 hunks)
  • packages/oraidex-common/src/network.ts (3 hunks)
  • packages/universal-swap/package.json (1 hunks)
  • packages/universal-swap/src/handler.ts (3 hunks)
  • packages/universal-swap/src/universal-demos/alpha-smart-router.ts (2 hunks)
  • packages/universal-swap/tests/index.spec.ts (10 hunks)
  • packages/universal-swap/tests/smart-router-common.ts (2 hunks)
Files skipped from review due to trivial changes (3)
  • packages/oraidex-common/package.json
  • packages/oraidex-common/src/constant.ts
  • packages/universal-swap/package.json
Additional context used
Gitleaks
packages/universal-swap/src/universal-demos/alpha-smart-router.ts

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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)

packages/universal-swap/tests/smart-router-common.ts

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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)

Additional comments not posted (14)
packages/universal-swap/src/universal-demos/alpha-smart-router.ts (5)

581-582: Verify the appropriateness of the new swapAmount and returnAmount values.

The swapAmount and returnAmount values have been increased significantly. Ensure that these new amounts are appropriate for the intended scale of operations.


585-667: LGTM! Enhanced handling of complex transactions.

The routing paths have been significantly elaborated, enhancing the router's capability to handle complex multi-step transactions across different chains. The detailed swap information and bridge information improve the functionality and accuracy of token transactions.


671-744: Verify the correct integration and support for new tokens.

The tokens being swapped and bridged have been updated, reflecting a broader integration across various blockchain networks. Ensure that the new tokens like uusdc and ibc tokens are correctly integrated and supported in the routing logic.

Tools
Gitleaks

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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


747-748: LGTM! Detailed swap information enhances accuracy.

The detailed swap information, including poolId references for liquidity pools, enhances the specificity and accuracy of token transactions.


764-764: Verify the correct handling of new token identifiers.

The token lookup logic has been altered to reflect changes in the token identifiers used. Ensure that the new token identifiers are correctly referenced and handled in the routing logic.

packages/universal-swap/tests/smart-router-common.ts (2)

4-27: Verify the correctness of new token amounts, identifiers, and swap actions.

The alphaSmartRoutes constant has been updated with new token amounts and identifiers, including multiple swap actions. Ensure that the new token amounts, identifiers, and swap actions are correct and appropriately defined.

Also applies to: 34-69

Tools
Gitleaks

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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


92-137: Verify the correctness of new swap actions, identifiers, and isLastPath property.

The flattenAlphaSmartRouters constant has been updated with new swap actions and identifiers, including the isLastPath property. Ensure that the new swap actions, identifiers, and isLastPath property are correctly defined and implemented.

Tools
Gitleaks

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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)

packages/oraidex-common/src/network.ts (3)

54-55: LGTM! The import statement for MIXED_ROUTER is correct.

The new constant is correctly imported.


126-126: LGTM! The new property mixer_router is correctly added to the NetworkConfig interface.

The type string is appropriate for this property.


1101-1101: LGTM! The new property mixer_router is correctly added to the network constant.

The value MIXED_ROUTER is appropriately assigned.

packages/universal-swap/src/handler.ts (1)

1176-1176: Ensure the new network.mixer_router is correctly defined and used.

The variable contractAddr has been updated to reference network.mixer_router. Ensure that this change is consistent with the rest of the codebase.

Verification successful

The new network.mixer_router is correctly defined and used.

The variable contractAddr has been updated to reference network.mixer_router, which is consistently defined and used across the codebase.

  • Defined in: packages/oraidex-common/src/network.ts
  • Used in: packages/universal-swap/src/handler.ts
  • Used in: packages/universal-swap/tests/index.spec.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and usage of `network.mixer_router`.

# Test: Search for the definition and usage of `network.mixer_router`. Expect: Correct definition and consistent usage.
rg --type python -A 5 $'mixer_router'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify the definition and usage of `network.mixer_router`.

# Test: Search for the definition and usage of `network.mixer_router`. Expect: Correct definition and consistent usage.
rg --type typescript -A 5 $'mixer_router'

Length of output: 75


Script:

#!/bin/bash
# Description: Verify the definition and usage of `network.mixer_router`.

# Test: Search for the definition and usage of `network.mixer_router`. Expect: Correct definition and consistent usage.
rg --type ts -A 5 $'mixer_router'

Length of output: 3292

packages/universal-swap/tests/index.spec.ts (3)

26-27: LGTM! Import statement change is approved.

The addition of network is necessary for the subsequent test cases.


1101-1102: LGTM! Updated expectation is approved.

The expected length of routesFlatten has been updated from 2 to 3, indicating a change in the expected behavior.

However, ensure that the function behavior aligns with this expectation.

Verification successful

LGTM! Updated expectation is approved.

The expected length of routesFlatten has been updated from 2 to 3, indicating a change in the expected behavior. The function flattenSmartRouters correctly processes the routes to meet this expectation.

  • packages/universal-swap/src/handler.ts: Implementation of flattenSmartRouters.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the behavior of the function that generates `routesFlatten`.

# Test: Search for the implementation of the function that generates `routesFlatten`. Expect: Correct behavior.
rg --type typescript -A 10 $'routesFlatten'

Length of output: 77


Script:

#!/bin/bash
# Description: Verify the behavior of the function that generates `routesFlatten`.

# Test: Search for the implementation of the function that generates `routesFlatten`. Expect: Correct behavior.
rg --type ts -A 10 'routesFlatten'

Length of output: 5513


Line range hint 1429-1433:
LGTM! Dynamic contract address usage is approved.

Using network.mixer_router instead of hardcoded contractAddress enhances maintainability and adaptability.

However, ensure that network is correctly configured and initialized.

Verification successful

LGTM! Dynamic contract address usage is approved.

Using network.mixer_router instead of hardcoded contractAddress enhances maintainability and adaptability.

  • network is correctly configured and initialized, including the mixer_router property.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `network` is correctly configured and initialized.

# Test: Search for the initialization of `network`. Expect: Correct initialization.
rg --type typescript -A 5 $'network'

Length of output: 70


Script:

#!/bin/bash
# Description: Verify that `network` is correctly configured and initialized.

# Test: Search for the initialization of `network`. Expect: Correct initialization.
rg --type ts -A 5 'network'

Length of output: 59504


Script:

#!/bin/bash
# Description: Verify the initialization of `network` and ensure that `mixer_router` is correctly set.

# Locate the initialization of `network` in the relevant file.
rg 'export const network' -A 10

Length of output: 898

Comment on lines 643 to 669
path.actions.forEach((action, actionIndex, actionArray) => {
const isLastAction = !actionArray[actionIndex + 1];
const isSwapType = action.type === "Swap";
const isSwapInOraichain = isSwapType && isInOraichain;

const actionsPath = {
...action,
path: i,
chainId: path.chainId,
isLastPath: isLastPath && isLastAction
};

if (isSwapInOraichain) {
objActionSwap = {
...actionsPath,
...objActionSwap,
tokenOutAmount: action.tokenOutAmount,
swapInfo: objActionSwap.type ? [...objActionSwap.swapInfo, ...action.swapInfo] : [...action.swapInfo]
};

// count type swap in oraichain
if ((countTypeSwap > 1 && lastInd === actionIndex) || countTypeSwap === 1)
routesFlatten.push(objActionSwap);
} else {
routesFlatten.push(actionsPath);
}
});
Copy link

Choose a reason for hiding this comment

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

Consider breaking down the nested forEach loops into smaller functions.

The nested loops make the code harder to read and maintain. Breaking them down into smaller functions can improve readability and modularity.

- path.actions.forEach((action, actionIndex, actionArray) => {
-   const isLastAction = !actionArray[actionIndex + 1];
-   const isSwapType = action.type === "Swap";
-   const isSwapInOraichain = isSwapType && isInOraichain;
-   const actionsPath = {
-     ...action,
-     path: i,
-     chainId: path.chainId,
-     isLastPath: isLastPath && isLastAction
-   };
-   if (isSwapInOraichain) {
-     objActionSwap = {
-       ...actionsPath,
-       ...objActionSwap,
-       tokenOutAmount: action.tokenOutAmount,
-       swapInfo: objActionSwap.type ? [...objActionSwap.swapInfo, ...action.swapInfo] : [...action.swapInfo]
-     };
-     if ((countTypeSwap > 1 && lastInd === actionIndex) || countTypeSwap === 1)
-       routesFlatten.push(objActionSwap);
-   } else {
-     routesFlatten.push(actionsPath);
-   }
- });
+ const processAction = (action, actionIndex, actionArray) => {
+   const isLastAction = !actionArray[actionIndex + 1];
+   const isSwapType = action.type === "Swap";
+   const isSwapInOraichain = isSwapType && isInOraichain;
+   const actionsPath = {
+     ...action,
+     path: i,
+     chainId: path.chainId,
+     isLastPath: isLastPath && isLastAction
+   };
+   if (isSwapInOraichain) {
+     objActionSwap = {
+       ...actionsPath,
+       ...objActionSwap,
+       tokenOutAmount: action.tokenOutAmount,
+       swapInfo: objActionSwap.type ? [...objActionSwap.swapInfo, ...action.swapInfo] : [...action.swapInfo]
+     };
+     if ((countTypeSwap > 1 && lastInd === actionIndex) || countTypeSwap === 1)
+       routesFlatten.push(objActionSwap);
+   } else {
+     routesFlatten.push(actionsPath);
+   }
+ };
+ path.actions.forEach(processAction);
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
path.actions.forEach((action, actionIndex, actionArray) => {
const isLastAction = !actionArray[actionIndex + 1];
const isSwapType = action.type === "Swap";
const isSwapInOraichain = isSwapType && isInOraichain;
const actionsPath = {
...action,
path: i,
chainId: path.chainId,
isLastPath: isLastPath && isLastAction
};
if (isSwapInOraichain) {
objActionSwap = {
...actionsPath,
...objActionSwap,
tokenOutAmount: action.tokenOutAmount,
swapInfo: objActionSwap.type ? [...objActionSwap.swapInfo, ...action.swapInfo] : [...action.swapInfo]
};
// count type swap in oraichain
if ((countTypeSwap > 1 && lastInd === actionIndex) || countTypeSwap === 1)
routesFlatten.push(objActionSwap);
} else {
routesFlatten.push(actionsPath);
}
});
const processAction = (action, actionIndex, actionArray) => {
const isLastAction = !actionArray[actionIndex + 1];
const isSwapType = action.type === "Swap";
const isSwapInOraichain = isSwapType && isInOraichain;
const actionsPath = {
...action,
path: i,
chainId: path.chainId,
isLastPath: isLastPath && isLastAction
};
if (isSwapInOraichain) {
objActionSwap = {
...actionsPath,
...objActionSwap,
tokenOutAmount: action.tokenOutAmount,
swapInfo: objActionSwap.type ? [...objActionSwap.swapInfo, ...action.swapInfo] : [...action.swapInfo]
};
if ((countTypeSwap > 1 && lastInd === actionIndex) || countTypeSwap === 1)
routesFlatten.push(objActionSwap);
} else {
routesFlatten.push(actionsPath);
}
};
path.actions.forEach(processAction);

// // paths: [
// // {
// // chainId: "Oraichain",
// // tokenIn: "orai15un8msx3n5zf9ahlxmfeqd2kwa5wm0nrpxer304m9nd5q6qq0g6sku5pdd",
Copy link

Choose a reason for hiding this comment

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

Remove Generic API Keys to prevent potential exposure.

Gitleaks detected multiple instances of Generic API Keys, potentially exposing access to various services and sensitive operations. Ensure that no sensitive information is being exposed.

Also applies to: 484-484, 490-490, 492-492, 498-498, 512-512, 514-514, 520-520, 535-535, 540-540, 546-546, 548-548, 557-557, 686-686, 691-691, 697-697

Tools
Gitleaks

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

(generic-api-key)

Copy link

@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

Outside diff range, codebase verification and nitpick comments (4)
packages/universal-swap/src/handler.ts (4)

619-621: Consider using map instead of forEach for better readability and functional programming style.

Using map can make the code more concise and functional. It also avoids the need to manually push elements into an array.

- routers.forEach((routes, i) => {
+ routers.map((routes, i) => {

625-632: Initialize objActionSwap outside the loop if it does not depend on loop variables.

This can improve readability and avoid re-initializing the object in each iteration unnecessarily.

+ let objActionSwap = {
+   type: "Swap",
+   swapInfo: [],
+   tokenIn: "",
+   tokenOut: "",
+   tokenInAmount: "",
+   tokenOutAmount: ""
+ };
- let objActionSwap = {
-   type: "Swap",
-   swapInfo: [],
-   tokenIn: path.tokenIn,
-   tokenOut: path.tokenOut,
-   tokenInAmount: path.tokenInAmount,
-   tokenOutAmount: path.tokenOutAmount
- };

636-664: Refactor the nested loop for better readability.

The nested loop can be refactored to improve readability and maintainability.

- for (let swap of route.swapInfo) {
-   const [tokenX, tokenY, fee, tickSpacing] = swap.poolId.split("-");
-   let tokenOut = parseAssetInfoFromContractAddrOrDenom(swap.tokenOut);
-   if (tokenX && tokenY && fee && tickSpacing) {
-     ops.push({
-       swap_v3: {
-         pool_key: {
-           token_x: tokenX,
-           token_y: tokenY,
-           fee_tier: {
-             fee: Number(fee),
-             tick_spacing: Number(tickSpacing)
-           }
-         },
-         x_to_y: tokenY === swap.tokenOut
-       }
-     });
-   } else {
-     ops.push({
-       orai_swap: {
-         offer_asset_info: currTokenIn,
-         ask_asset_info: tokenOut
-       }
-     });
-   }
-   currTokenIn = tokenOut;
+ const processAction = (action, actionIndex, actionArray) => {
+   const isLastAction = !actionArray[actionIndex + 1];
+   const isSwapType = action.type === "Swap";
+   const isSwapInOraichain = isSwapType && isInOraichain;
+   const actionsPath = {
+     ...action,
+     path: i,
+     chainId: path.chainId,
+     isLastPath: isLastPath && isLastAction
+   };
+   if (isSwapInOraichain) {
+     objActionSwap = {
+       ...actionsPath,
+       ...objActionSwap,
+       tokenOutAmount: action.tokenOutAmount,
+       swapInfo: objActionSwap.type ? [...objActionSwap.swapInfo, ...action.swapInfo] : [...action.swapInfo]
+     };
+     if ((pathsSwapInOraichain.length > 1 && pathsSwapInOraichain.length - 1 === actionIndex) || pathsSwapInOraichain.length === 1)
+       routesFlatten.push(objActionSwap);
+   } else {
+     routesFlatten.push(actionsPath);
+   }
+ };
+ path.actions.forEach(processAction);

1188-1212: Refactor the nested loop for better readability.

The nested loop can be refactored to improve readability and maintainability.

+ const processSwapInfo = (swap) => {
+   const [tokenX, tokenY, fee, tickSpacing] = swap.poolId.split("-");
+   let tokenOut = parseAssetInfoFromContractAddrOrDenom(swap.tokenOut);
+   if (tokenX && tokenY && fee && tickSpacing) {
+     ops.push({
+       swap_v3: {
+         pool_key: {
+           token_x: tokenX,
+           token_y: tokenY,
+           fee_tier: {
+             fee: Number(fee),
+             tick_spacing: Number(tickSpacing)
+           }
+         },
+         x_to_y: tokenY === swap.tokenOut
+       }
+     });
+   } else {
+     ops.push({
+       orai_swap: {
+         offer_asset_info: currTokenIn,
+         ask_asset_info: tokenOut
+       }
+     });
+   }
+   currTokenIn = tokenOut;
+ };
+ route.swapInfo.forEach(processSwapInfo);
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bc14f92 and e53ea25.

Files selected for processing (1)
  • packages/universal-swap/src/handler.ts (3 hunks)
Additional comments not posted (1)
packages/universal-swap/src/handler.ts (1)

1171-1171: Verify the reference to network.mixer_router.

Ensure that network.mixer_router is correctly defined and used in the context of the routing mechanism.

Verification successful

The reference to network.mixer_router is correctly defined and used.

  • network.mixer_router is defined in packages/oraidex-common/src/network.ts and assigned the value MIXED_ROUTER.
  • The usage in packages/universal-swap/src/handler.ts and the test file packages/universal-swap/tests/index.spec.ts confirms its correct implementation.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the reference to `network.mixer_router`.

# Test: Search for the definition of `mixer_router` in the `network` object. Expect: Correct definition and usage.
rg --type js --type ts -A 5 $'mixer_router'

Length of output: 3302

Copy link

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e53ea25 and 915f88b.

Files selected for processing (2)
  • packages/universal-swap/src/handler.ts (3 hunks)
  • packages/universal-swap/src/universal-demos/alpha-smart-router.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/universal-swap/src/handler.ts
Additional context used
Gitleaks
packages/universal-swap/src/universal-demos/alpha-smart-router.ts

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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)


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

(generic-api-key)

Additional comments not posted (2)
packages/universal-swap/src/universal-demos/alpha-smart-router.ts (2)

473-474: Ensure the swap and return amounts are correct.

The swapAmount and returnAmount values have been updated. Verify that these values are correct and align with the intended scale of operations.


568-568: Ensure correct token lookup logic.

Verify that the tokens being looked up (usd-coin and tether on Oraichain) exist in the cosmosTokens array and are correctly identified.

@haunv3 haunv3 changed the title Feat/smart route v3 [Smart Router] - with V3 Jul 25, 2024
trung2891
trung2891 previously approved these changes Jul 25, 2024
Copy link
Member

@trung2891 trung2891 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 915f88b and b7498b6.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (5)
  • package.json (1 hunks)
  • packages/oraidex-common-ui/package.json (1 hunks)
  • packages/oraidex-common-ui/src/components/TVChartContainer/helpers/requests.ts (3 hunks)
  • packages/oraidex-common/package.json (2 hunks)
  • packages/oraidex-common/src/axios-request.ts (2 hunks)
Files skipped from review due to trivial changes (2)
  • packages/oraidex-common-ui/package.json
  • packages/oraidex-common-ui/src/components/TVChartContainer/helpers/requests.ts
Files skipped from review as they are similar to previous changes (1)
  • packages/oraidex-common/package.json
Additional comments not posted (3)
packages/oraidex-common/src/axios-request.ts (2)

1-2: Imports look good!

The imports are necessary for the functionality introduced in the getAxios function. The AxiosAdapter type enhances type safety, and the enhancers improve request handling.


Line range hint 3-17: Function changes look good!

The getAxios function now includes the cacheAdapterEnhancer in the adapter configuration, improving performance and efficiency in handling HTTP requests.

package.json (1)

65-68: Resolution field looks good!

The "resolution" field ensures that the project uses specific versions of the axios-extensions and axios packages, avoiding issues related to version incompatibility or breaking changes in future updates.

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b7498b6 and c5a9aaf.

Files selected for processing (2)
  • packages/oraidex-common/package.json (2 hunks)
  • packages/oraidex-common/src/axios-request.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/oraidex-common/package.json
  • packages/oraidex-common/src/axios-request.ts

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c5a9aaf and b9374d4.

Files selected for processing (1)
  • packages/oraidex-common/src/constant.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/oraidex-common/src/constant.ts

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b9374d4 and 513da5d.

Files selected for processing (1)
  • packages/oraidex-common/package.json (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/oraidex-common/package.json

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 513da5d and 6083f89.

Files selected for processing (2)
  • packages/universal-swap/package.json (1 hunks)
  • packages/universal-swap/src/helper.ts (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/universal-swap/package.json
Additional comments not posted (4)
packages/universal-swap/src/helper.ts (4)

540-543: Ensure proper handling of the protocol property in optionRouter.

The optionRouter parameter now includes an optional protocol property. Verify that this change is correctly propagated and handled in the function logic.

Verification successful

The protocol property in optionRouter is properly handled in the function logic.

The protocol property is included in the data object and used appropriately in the function calls within packages/universal-swap/src/helper.ts.

  • packages/universal-swap/src/helper.ts:545: protocols: optionRouter.protocol
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all instances of `optionRouter` in the function properly handle the `protocol` property.

# Test: Search for all instances of `optionRouter` within the function and ensure the `protocol` property is handled correctly.
rg --type python -A 5 $'optionRouter'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify that all instances of `optionRouter` in the function properly handle the `protocol` property.

# Test: Search for all instances of `optionRouter` within the function and ensure the `protocol` property is handled correctly.
rg --type typescript -A 5 'optionRouter'

Length of output: 75


Script:

#!/bin/bash
# Description: Verify that all instances of `optionRouter` in the function properly handle the `protocol` property.

# Test: Search for all instances of `optionRouter` within the function and ensure the `protocol` property is handled correctly.
rg --type ts -A 5 'optionRouter'

Length of output: 4522


447-462: Ensure proper handling of the protocol property in optionRouter.

The optionRouter parameter now includes an optional protocol property. Verify that this change is correctly propagated and handled in the API request data.

Verification successful

The protocol property in optionRouter is properly handled.

The optionRouter parameter, including its protocol property, is correctly propagated and utilized in the API request data within the codebase.

  • packages/universal-swap/src/helper.ts: Multiple instances confirm the proper handling of the protocol property.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all instances of `optionRouter` in the codebase properly handle the `protocol` property.

# Test: Search for all instances of `optionRouter` and ensure the `protocol` property is handled correctly.
rg --type python -A 5 $'optionRouter'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify that all instances of `optionRouter` in the codebase properly handle the `protocol` property.

# Test: Search for all instances of `optionRouter` and ensure the `protocol` property is handled correctly.
rg --type typescript -A 5 $'optionRouter'

Length of output: 75


Script:

#!/bin/bash
# Description: Verify that all instances of `optionRouter` in the codebase properly handle the `protocol` property.

# Test: Search for all instances of `optionRouter` and ensure the `protocol` property is handled correctly.
rg --type ts -A 5 $'optionRouter'

Length of output: 4522


640-643: Ensure proper handling of the protocol property in optionRouter.

The optionRouter parameter now includes an optional protocol property. Verify that this change is correctly propagated and handled in the function logic.

Verification successful

The protocol property in optionRouter is properly handled.

The protocol property is correctly accessed and included in the data object for the HTTP POST request within the helper.ts file.

  • Lines 640-643: The protocol property is included in the data object sent to optionRouter.path.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all instances of `optionRouter` in the function properly handle the `protocol` property.

# Test: Search for all instances of `optionRouter` within the function and ensure the `protocol` property is handled correctly.
rg --type python -A 5 $'optionRouter'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify that all instances of `optionRouter` in the function properly handle the `protocol` property.

# Test: Search for all instances of `optionRouter` within the helper.ts file and ensure the `protocol` property is handled correctly.
rg --type typescript -A 5 'optionRouter' packages/universal-swap/src/helper.ts

Length of output: 113


Script:

#!/bin/bash
# Description: Verify that all instances of `optionRouter` in the function properly handle the `protocol` property.

# Test: Search for all instances of `optionRouter` within the helper.ts file and ensure the `protocol` property is handled correctly.
rg -A 5 'optionRouter' packages/universal-swap/src/helper.ts

Length of output: 2080


480-484: Verify default protocol values in optionRouter.

The default value for optionRouter now includes a protocol array. Ensure that these default values are appropriate and correctly applied.

Verification successful

Verify default protocol values in optionRouter.

The default value for optionRouter includes the protocol array with values ["Oraidex", "OraidexV3", "Osmosis"]. These values appear to be correctly applied and used in the codebase, as evidenced by the search results.

  • The optionRouter is defined with the expected protocol values.
  • The protocol property is used in the codebase, indicating that the default values are being utilized.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the default values of the `protocol` property in `optionRouter`.

# Test: Search for the default values of `optionRouter` in the codebase and ensure they are correctly applied.
rg --type python -A 5 $'optionRouter: { url: string; path?: string; protocol?: string[] } = {'

Length of output: 263


Script:

#!/bin/bash
# Description: Verify the default values of the `protocol` property in `optionRouter`.

# Test: Search for the default values of `optionRouter` in the TypeScript or JavaScript files and ensure they are correctly applied.
rg --type js --type ts -A 5 'optionRouter: { url: string; path?: string; protocol?: string[] } = {'

Length of output: 269


Script:

#!/bin/bash
# Description: Verify the default values of the `protocol` property in `optionRouter`.

# Test: Search for the default values of `optionRouter` in the TypeScript or JavaScript files and ensure they are correctly applied.
rg --type js --type ts -A 5 'optionRouter: { url: string; path?: string; protocol?: string\[\] } = {'

Length of output: 273


Script:

#!/bin/bash
# Description: Verify the default values of the `protocol` property in `optionRouter`.

# Test: Search for the `optionRouter` definition in the TypeScript or JavaScript files and ensure the `protocol` property is correctly applied.
rg --type js --type ts -A 5 'optionRouter'

Length of output: 4532

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6083f89 and 6eb7160.

Files selected for processing (3)
  • packages/oraidex-common/package.json (2 hunks)
  • packages/oraidex-common/src/constant.ts (3 hunks)
  • packages/oraidex-common/src/network.ts (3 hunks)
Files skipped from review due to trivial changes (1)
  • packages/oraidex-common/package.json
Files skipped from review as they are similar to previous changes (1)
  • packages/oraidex-common/src/network.ts
Additional comments not posted (2)
packages/oraidex-common/src/constant.ts (2)

76-76: Verify the correctness of the new channel configuration.

The value of ORAIB_ORAICHAIN_CHANNELS_TEST has been updated to "channel-6 channel-260". Ensure these channels are correct and consistent with other configurations.


117-117: Verify the correctness of the new contract address.

A new constant MIXED_ROUTER has been added with the value "orai19ffxyc055r6l7nh44dae5fmln2q5quyf2r505w3d36k78hkx4z6qke76q9". Ensure this contract address is correct and consistent with other configurations.

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6eb7160 and d761c70.

Files selected for processing (6)
  • package.json (2 hunks)
  • packages/oraidex-common/package.json (1 hunks)
  • packages/oraidex-common/tsconfig.test.json (1 hunks)
  • packages/universal-swap/package.json (1 hunks)
  • packages/universal-swap/tsconfig.test.json (1 hunks)
  • tsconfig.build.json (1 hunks)
Files skipped from review due to trivial changes (2)
  • packages/oraidex-common/tsconfig.test.json
  • packages/universal-swap/tsconfig.test.json
Files skipped from review as they are similar to previous changes (3)
  • package.json
  • packages/oraidex-common/package.json
  • packages/universal-swap/package.json
Additional comments not posted (1)
tsconfig.build.json (1)

5-5: LGTM! But verify the impact on module imports and exports.

Changing the module system to es2020 aligns the project with modern JavaScript standards, which can enhance compatibility and performance. Ensure that all module imports and exports throughout the codebase are updated as needed to reflect this change.

Verification successful

CommonJS syntax found in webpack.config.js.

The presence of CommonJS syntax (require and module.exports) in the webpack.config.js file is expected and generally acceptable. However, it's crucial to ensure that the rest of the codebase is compatible with the es2020 module system. No other occurrences of CommonJS syntax were found in the codebase.

  • packages/oraidex-common-ui/webpack.config.js: Contains require and module.exports statements.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all module imports and exports are compatible with the new `es2020` module system.

# Test: Search for commonjs module imports and exports. Expect: No occurrences of commonjs syntax.
rg --type js -w "require" -A 5
rg --type js -w "module.exports" -A 5

Length of output: 1933

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d761c70 and f13734a.

Files selected for processing (2)
  • packages/contracts-sdk/package.json (1 hunks)
  • packages/contracts-sdk/tsconfig.test.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/contracts-sdk/tsconfig.test.json
Additional comments not posted (1)
packages/contracts-sdk/package.json (1)

10-11: New script entry added for testing build.

The addition of the build:test script is a good practice for facilitating testing and validation of TypeScript code. This change enhances the development workflow by providing a dedicated script for building the project in a testing context.

@haunv3 haunv3 requested a review from trung2891 August 1, 2024 04:59
Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f13734a and eb53e88.

Files selected for processing (8)
  • packages/contracts-build/package.json (1 hunks)
  • packages/contracts-build/tsconfig.test.json (1 hunks)
  • packages/contracts-sdk/tsconfig.test.json (1 hunks)
  • packages/oraidex-common/package.json (1 hunks)
  • packages/oraidex-common/tsconfig.json (1 hunks)
  • packages/oraidex-common/tsconfig.test.json (1 hunks)
  • packages/universal-swap/tsconfig.test.json (1 hunks)
  • tsconfig.vitest.json (1 hunks)
Files skipped from review due to trivial changes (3)
  • packages/contracts-build/tsconfig.test.json
  • packages/contracts-sdk/tsconfig.test.json
  • packages/oraidex-common/tsconfig.json
Files skipped from review as they are similar to previous changes (3)
  • packages/oraidex-common/package.json
  • packages/oraidex-common/tsconfig.test.json
  • packages/universal-swap/tsconfig.test.json
Additional comments not posted (2)
packages/contracts-build/package.json (1)

7-8: LGTM! The new script command is correctly formatted and beneficial.

The addition of the "build:test" script enhances the build process by providing a dedicated command for testing the TypeScript configuration.

tsconfig.vitest.json (1)

5-5: LGTM! The updated module option aligns with modern JavaScript practices.

Updating the module option to "es2020" enhances compatibility with ES modules and improves tree-shaking capabilities.

Copy link
Member

@meomeocoj meomeocoj left a comment

Choose a reason for hiding this comment

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

LGTM

});
for (let swap of route.swapInfo) {
const [tokenX, tokenY, fee, tickSpacing] = swap.poolId.split("-");
let tokenOut = parseAssetInfoFromContractAddrOrDenom(swap.tokenOut);
Copy link
Member

Choose a reason for hiding this comment

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

should check if(swap.poolId) -> v3 or v2

@haunv3 haunv3 merged commit 118dd44 into main Aug 1, 2024
2 checks passed
@quangdz1704 quangdz1704 deleted the feat/smart-route-v3 branch August 1, 2024 09:28
This was referenced Sep 23, 2024
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.

5 participants