-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe recent updates enhance the Changes
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
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
Code Coverage Summary
Diff against main
Results for commit: 939f712 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
There was a problem hiding this 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 oflastInd
andcountTypeSwap
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
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 newswapAmount
andreturnAmount
values.The
swapAmount
andreturnAmount
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
andibc
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, andisLastPath
property.The
flattenAlphaSmartRouters
constant has been updated with new swap actions and identifiers, including theisLastPath
property. Ensure that the new swap actions, identifiers, andisLastPath
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 forMIXED_ROUTER
is correct.The new constant is correctly imported.
126-126
: LGTM! The new propertymixer_router
is correctly added to theNetworkConfig
interface.The type
string
is appropriate for this property.
1101-1101
: LGTM! The new propertymixer_router
is correctly added to thenetwork
constant.The value
MIXED_ROUTER
is appropriately assigned.packages/universal-swap/src/handler.ts (1)
1176-1176
: Ensure the newnetwork.mixer_router
is correctly defined and used.The variable
contractAddr
has been updated to referencenetwork.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 referencenetwork.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 functionflattenSmartRouters
correctly processes the routes to meet this expectation.
packages/universal-swap/src/handler.ts
: Implementation offlattenSmartRouters
.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 hardcodedcontractAddress
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 hardcodedcontractAddress
enhances maintainability and adaptability.
network
is correctly configured and initialized, including themixer_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 10Length of output: 898
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); | ||
} | ||
}); |
There was a problem hiding this comment.
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.
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", |
There was a problem hiding this comment.
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)
There was a problem hiding this 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 usingmap
instead offorEach
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
: InitializeobjActionSwap
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
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 tonetwork.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 inpackages/oraidex-common/src/network.ts
and assigned the valueMIXED_ROUTER
.- The usage in
packages/universal-swap/src/handler.ts
and the test filepackages/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
There was a problem hiding this 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
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
andreturnAmount
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
andtether
onOraichain
) exist in thecosmosTokens
array and are correctly identified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this 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
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. TheAxiosAdapter
type enhances type safety, and the enhancers improve request handling.
Line range hint
3-17
: Function changes look good!The
getAxios
function now includes thecacheAdapterEnhancer
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
andaxios
packages, avoiding issues related to version incompatibility or breaking changes in future updates.
There was a problem hiding this 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
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
There was a problem hiding this 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
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
There was a problem hiding this 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
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
There was a problem hiding this 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
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 theprotocol
property inoptionRouter
.The
optionRouter
parameter now includes an optionalprotocol
property. Verify that this change is correctly propagated and handled in the function logic.Verification successful
The
protocol
property inoptionRouter
is properly handled in the function logic.The
protocol
property is included in the data object and used appropriately in the function calls withinpackages/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 theprotocol
property inoptionRouter
.The
optionRouter
parameter now includes an optionalprotocol
property. Verify that this change is correctly propagated and handled in the API request data.Verification successful
The
protocol
property inoptionRouter
is properly handled.The
optionRouter
parameter, including itsprotocol
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 theprotocol
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 theprotocol
property inoptionRouter
.The
optionRouter
parameter now includes an optionalprotocol
property. Verify that this change is correctly propagated and handled in the function logic.Verification successful
The
protocol
property inoptionRouter
is properly handled.The
protocol
property is correctly accessed and included in thedata
object for the HTTP POST request within thehelper.ts
file.
- Lines 640-643: The
protocol
property is included in thedata
object sent tooptionRouter.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.tsLength 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.tsLength of output: 2080
480-484
: Verify defaultprotocol
values inoptionRouter
.The default value for
optionRouter
now includes aprotocol
array. Ensure that these default values are appropriate and correctly applied.Verification successful
Verify default
protocol
values inoptionRouter
.The default value for
optionRouter
includes theprotocol
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 expectedprotocol
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
There was a problem hiding this 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
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.
There was a problem hiding this 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
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
andmodule.exports
) in thewebpack.config.js
file is expected and generally acceptable. However, it's crucial to ensure that the rest of the codebase is compatible with thees2020
module system. No other occurrences of CommonJS syntax were found in the codebase.
packages/oraidex-common-ui/webpack.config.js
: Containsrequire
andmodule.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 5Length of output: 1933
There was a problem hiding this 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
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.
There was a problem hiding this 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
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 updatedmodule
option aligns with modern JavaScript practices.Updating the
module
option to"es2020"
enhances compatibility with ES modules and improves tree-shaking capabilities.
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
Summary by CodeRabbit
New Features
@oraichain/oraidex-common
package to a stable version (1.1.1) with improved dependency management.MIXED_ROUTER
, for enhanced contract interactions.@oraichain/oraidex-universal-swap
,contracts-sdk
, andcontracts-build
packages to streamline testing processes.Bug Fixes
Chores
oraidex-common-ui
and@oraichain/oraidex-universal-swap
for better performance and stability.