-
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
Feat/zapper 2 #331
Feat/zapper 2 #331
Conversation
Warning Rate limit exceeded@vuonghuuhung has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 58 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThis pull request introduces a new GitHub Actions workflow for automating the build and publication of the Oraiswap v3 package. It updates several configuration files, including Changes
Possibly related PRs
Suggested reviewers
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Code Coverage Summary
Diff against main
Results for commit: 78f7a1b 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: 7
Outside diff range and nitpick comments (4)
packages/oraiswap-v3/tests/zap-consumer.spec.ts (1)
1-61
: LGTM! Consider adding more test cases.The test suite is correctly setting up the DEX environment before each test and is using the Vitest testing framework. The code is well-structured and easy to understand.
However, the test suite currently has a single test case that logs "hello" to the console, which is a placeholder for future tests. Consider adding more test cases to ensure comprehensive coverage of the
ZapConsumer
class.packages/oraiswap-v3/src/main.ts (3)
14-21
: Consider removing the commented-out pool keys.If the commented-out pool keys are no longer needed, it's best to remove them to keep the code clean and maintainable.
37-56
: Consider removing the commented-out code or adding explanatory comments.If the commented-out code is no longer needed, it's best to remove it to keep the code clean and maintainable. If the code is still relevant for future reference or development, consider adding comments to explain its purpose and why it's currently commented out.
13-70
: LGTM, but consider adding more comments.The
main
function provides a clear example of how to interact with the Oraichain DEX for liquidity management using theZapConsumer
class. The code is well-structured and uses appropriate naming conventions.To further improve the code's readability and maintainability, consider adding more comments to explain the purpose of each code block and the significance of the chosen values for variables like
tickSpacing
andcurrentTick
.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
packages/contracts-build/data/zapper.wasm
is excluded by!**/*.wasm
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
Files selected for processing (25)
- .github/workflows/publish_oraiswap_v3.yml (1 hunks)
- .gitignore (1 hunks)
- .yarnrc (1 hunks)
- package.json (1 hunks)
- packages/contracts-build/package.json (1 hunks)
- packages/contracts-build/src/index.ts (1 hunks)
- packages/contracts-sdk/package.json (1 hunks)
- packages/contracts-sdk/src/Zapper.client.ts (1 hunks)
- packages/contracts-sdk/src/Zapper.types.ts (1 hunks)
- packages/contracts-sdk/src/index.ts (1 hunks)
- packages/oraidex-common/package.json (1 hunks)
- packages/oraidex-common/src/constant.ts (1 hunks)
- packages/oraiswap-v3/package.json (1 hunks)
- packages/oraiswap-v3/src/error.ts (1 hunks)
- packages/oraiswap-v3/src/handler.ts (3 hunks)
- packages/oraiswap-v3/src/helpers.ts (3 hunks)
- packages/oraiswap-v3/src/index.ts (1 hunks)
- packages/oraiswap-v3/src/main.ts (1 hunks)
- packages/oraiswap-v3/src/types.ts (2 hunks)
- packages/oraiswap-v3/src/zap-consumer.ts (1 hunks)
- packages/oraiswap-v3/tests/handler.spec.ts (1 hunks)
- packages/oraiswap-v3/tests/zap-consumer.spec.ts (1 hunks)
- packages/oraiswap-v3/tsconfig.json (1 hunks)
- packages/oraiswap-v3/tsconfig.test.json (1 hunks)
- packages/universal-swap/tests/index.spec.ts (1 hunks)
Files skipped from review due to trivial changes (7)
- .yarnrc
- packages/contracts-build/package.json
- packages/contracts-sdk/package.json
- packages/oraidex-common/package.json
- packages/oraidex-common/src/constant.ts
- packages/oraiswap-v3/tests/handler.spec.ts
- packages/universal-swap/tests/index.spec.ts
Additional context used
Biome
packages/contracts-sdk/src/Zapper.types.ts
[error] 90-90: An empty interface is equivalent to {}.
Safe fix: Use a type alias instead.
(lint/suspicious/noEmptyInterface)
[error] 86-86: Don't use '{}' as a type.
Prefer explicitly define the object shape. '{}' means "any non-nullable value".
(lint/complexity/noBannedTypes)
[error] 88-88: Don't use '{}' as a type.
Prefer explicitly define the object shape. '{}' means "any non-nullable value".
(lint/complexity/noBannedTypes)
packages/oraiswap-v3/src/zap-consumer.ts
[error] 189-189: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
actionlint
.github/workflows/publish_oraiswap_v3.yml
24-24: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
26-26: the runner of "actions/setup-node@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
31-31: workflow command "set-output" was deprecated. use
echo "{name}={value}" >> $GITHUB_OUTPUT
instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions(deprecated-commands)
Additional comments not posted (67)
packages/oraiswap-v3/src/error.ts (1)
1-5
: LGTM!The
RouteNotFoundError
class is a well-designed custom error type that extends the built-inError
class. It provides a clear and specific error type for scenarios where a specified route cannot be found.The constructor correctly calls the superclass constructor with a formatted error message that includes the
route
parameter, providing useful context about the error.The class is exported, allowing it to be used in other parts of the codebase to throw and catch this specific error type, which enhances the clarity and maintainability of error management related to routing issues.
packages/oraiswap-v3/src/index.ts (2)
5-5
: LGTM!Exporting the
./zap-consumer
module allows consumers of this package to access its functionality through the main entry point. This is a good practice for maintaining a clean public API.
6-6
: LGTM!Exporting the
./error
module provides consumers of this package access to custom error classes and error handling utilities. This promotes consistent error handling across the application.packages/oraiswap-v3/tsconfig.json (1)
1-11
: LGTM! Verify the impact of excludingsrc/main.ts
.The changes in the
tsconfig.json
file are primarily formatting adjustments and the addition of an exclusion rule forsrc/main.ts
. The exclusion suggests thatsrc/main.ts
may contain code that should not be included in the compiled output, such as development-specific or testing code, or that it is intended to be run directly by Node.js.To verify the impact of excluding
src/main.ts
, consider the following:
- Review the contents of
src/main.ts
to understand its purpose and dependencies.- Ensure that any necessary code from
src/main.ts
is properly imported or integrated into other parts of the project.- Test the build process and the application's functionality to confirm that the exclusion of
src/main.ts
does not introduce any unintended consequences.If you would like me to assist with this verification process, please provide the contents of
src/main.ts
and any additional relevant files.packages/oraiswap-v3/tsconfig.test.json (1)
1-12
: LGTM!The TypeScript configuration file is well-structured and follows best practices:
- Extending the base
tsconfig.json
file promotes configuration reuse and consistency across the project.- The
compilerOptions
section includes essential settings for TypeScript compilation, such asbaseUrl
,outDir
,declaration
,rootDir
, andmodule
.- The
include
andexclude
arrays ensure that only relevant files are compiled, optimizing the build process.The configuration is appropriate for a testing setup, as indicated by the file name
tsconfig.test.json
.packages/oraiswap-v3/package.json (4)
3-3
: LGTM!The version increment from
0.1.6
to0.1.8
is appropriate for a new release with backward-compatible changes.
10-10
: LGTM!Using a separate
tsconfig.test.json
file for tests is a good practice to keep the production and test configurations separate. This change improves the project's organization and maintainability.
15-15
: LGTM!Updating the
@oraichain/oraidex-contracts-sdk
dependency to version^1.0.52
is a good practice to leverage potential new features, bug fixes, or performance improvements while maintaining backward compatibility.
16-16
: LGTM!Changing the
@oraichain/oraidex-common
dependency fromlatest
to a specific version^1.1.6
is a good practice for controlled dependency management. It ensures compatibility and stability with a known version while allowing for backward-compatible updates..gitignore (3)
38-38
: LGTM!Adding
.nx/cache
to.gitignore
is a good practice to prevent the build cache from being tracked by Git. This keeps the repository clean and reduces its size.
39-39
: LGTM!Adding
.nx/workspace-data
to.gitignore
is a good practice to prevent the workspace data from being tracked by Git. This keeps the repository clean and reduces its size.
41-41
: LGTM!Adding
.yarn
to.gitignore
is a good practice to prevent the Yarn internal data from being tracked by Git. This keeps the repository clean and reduces its size.packages/contracts-build/src/index.ts (1)
19-20
: LGTM!The addition of the new contract name
"zapper"
to theContractName
type is a valid change. It expands the set of recognized contract names, potentially allowing for new functionalities or integrations related to the"zapper"
contract within the broader application context.The change is consistent with the existing code style and structure and is unlikely to introduce any bugs or issues.
packages/contracts-sdk/src/index.ts (2)
33-33
: LGTM!The export statement follows the existing pattern and enhances the module's interface by providing access to Zapper-related types.
34-34
: LGTM!The export statement follows the existing pattern and enhances the module's interface by providing access to the Zapper client.
packages/contracts-sdk/src/Zapper.types.ts (14)
1-1
: LGTM!Using a type alias for
string
is a good practice to provide semantic meaning to the type.
2-6
: LGTM!The interface has descriptive property names and appropriate types. The required properties are clearly defined.
7-32
: LGTM!The union type has descriptive member names and appropriate types. The optional properties provide flexibility in contract interactions.
33-33
: LGTM!Using a type alias for
string
is a good practice to provide semantic meaning to the type. The type name suggests that it represents an unsigned 128-bit integer.
34-42
: LGTM!The union type has descriptive member names and appropriate types. The required properties are clearly defined for each member.
43-43
: LGTM!Using a type alias for
string
is a good practice to provide semantic meaning to the type. The type name suggests that it represents liquidity.
44-44
: LGTM!Using a type alias for
number
is a good practice to provide semantic meaning to the type. The type name suggests that it represents a percentage value.
45-55
: LGTM!The union type has descriptive member names and appropriate types. The required properties are clearly defined for each member.
56-64
: LGTM!The union type has descriptive member names and appropriate types. The required properties are clearly defined for each member.
65-65
: LGTM!Using a type alias for
string
is a good practice to provide semantic meaning to the type. The type name suggests that it represents a decimal value.
66-69
: LGTM!The interface has descriptive property names and appropriate types. The required properties are clearly defined.
70-74
: LGTM!The interface has descriptive property names and appropriate types. The required properties are clearly defined.
75-78
: LGTM!The interface has descriptive property names and appropriate types. The required properties are clearly defined.
79-84
: LGTM!The interface has descriptive property names and appropriate types. The required properties are clearly defined, and the optional property is marked as such.
.github/workflows/publish_oraiswap_v3.yml (1)
48-52
: Good use of "continue-on-error" in the publishing steps.The "continue-on-error" configuration allows the workflow to attempt publishing all components, even if one fails. This provides better visibility into the status of each component and prevents a single failure from halting the entire workflow.
Also applies to: 55-59, 62-66
package.json (1)
57-57
: Verify compatibility and test workflows with the upgradednx
package version.The upgrade from
nx
version18.1.2
to19.7.3
is a significant version jump. While this change is in the development dependencies and doesn't directly impact the production code, it's important to ensure that the new version is compatible with the project's current setup and doesn't introduce any breaking changes.Please verify the following:
- Review the
nx
changelog and migration guides to identify any potential breaking changes or required adjustments to the project's nx configuration and workflows.- Test the common development workflows (e.g., building, testing, linting) to ensure they work correctly with the new
nx
version.- Verify that the project's monorepo structure and any custom nx plugins or scripts are compatible with the upgraded version.
If any issues are encountered during the verification process, please document them and consider if additional changes or configuration updates are necessary to maintain compatibility with the new
nx
version.packages/oraiswap-v3/src/main.ts (1)
60-68
: LGTM!The usage of the
processZapInPositionLiquidity
method and its parameters looks good. The necessary pool key, input token, amount, and tick ranges are correctly provided.packages/contracts-sdk/src/Zapper.client.ts (4)
10-14
: LGTM!The
ZapperReadOnlyInterface
is well-defined with appropriate method signatures and return types.
15-36
: LGTM!The
ZapperQueryClient
correctly implements theZapperReadOnlyInterface
and uses theCosmWasmClient
to make the necessary contract queries.
37-78
: LGTM!The
ZapperInterface
is well-defined with appropriate method signatures, parameter types, and return types. The optional transaction metadata parameters provide flexibility for the client.
79-166
: LGTM!The
ZapperClient
correctly implements theZapperInterface
and uses theSigningCosmWasmClient
to execute the necessary contract methods. The transaction metadata is handled appropriately.packages/oraiswap-v3/src/types.ts (11)
189-196
: LGTM!The
ZapConfig
type is well-structured and includes all the necessary properties for configuring a zap operation. The property names are clear and descriptive, and the types are appropriate.
198-206
: LGTM!The
ActionRoute
type is well-structured and includes all the necessary properties for defining an action route in a zap operation. The property names are clear and descriptive, and the types are appropriate.
208-211
: LGTM!The
Path
type is well-structured and includes all the necessary properties for defining a path in a zap operation. The property names are clear and descriptive, and the types are appropriate.
213-225
: LGTM!The
RouteResponse
type is well-structured and includes all the necessary properties for defining a route response in a zap operation. The property names are clear and descriptive, and the types are appropriate. The paths property is an array of objects, which is a good way to represent multiple paths in a route response.
227-231
: LGTM!The
SmartRouteResponse
type is well-structured and includes all the necessary properties for defining a smart route response in a zap operation. The property names are clear and descriptive, and the types are appropriate. The routes property is an array ofRouteResponse
objects, which is a good way to represent multiple routes in a smart route response.
233-233
: LGTM!The
Protocols
type is well-defined and includes all the supported protocols for a zap operation. The use of a union type of string literals is a good way to restrict the possible values for the protocol property.
235-240
: LGTM!The
SmartRouteConfig
type is well-structured and includes all the necessary properties for configuring a smart route in a zap operation. The property names are clear and descriptive, and the types are appropriate. The swap options property is an object with properties for protocols and max splits, which is a good way to represent the options for a smart route.
248-267
: LGTM!The
ZapInLiquidityResponse
type is well-structured and includes all the necessary properties for defining a zap in liquidity response. The property names are clear and descriptive, and the types are appropriate. The result property is of typeZapInResult
, which is an enum that defines the possible results of a zap in operation.
269-280
: LGTM!The
ZapOutLiquidityResponse
type is well-structured and includes all the necessary properties for defining a zap out liquidity response. The property names are clear and descriptive, and the types are appropriate. The result property is of typeZapOutResult
, which is an enum that defines the possible results of a zap out operation.
282-296
: LGTM!The
ZapInResult
enum is well-structured and includes all the possible results of a zap in operation. The enum values are clear and descriptive, and they are grouped into error results and success results with different accuracy levels based on the position and route.
298-305
: LGTM!The
ZapOutResult
enum is well-structured and includes all the possible results of a zap out operation. The enum values are clear and descriptive, and they are grouped into error results and a success result.packages/oraiswap-v3/src/handler.ts (2)
340-355
: LGTM!The
getAllLiquidityTicks
function correctly retrieves all liquidity ticks for a given pool key and tickmap. It efficiently iterates through the bitmap, identifies set bits, calculates tick indexes, and fetches the corresponding liquidity tick results.
357-366
: LGTM!The
getFullTickmap
function correctly generates a complete tickmap for a specified pool key. It efficiently calculates the minimum and maximum ticks, retrieves the tickmap data, and constructs a bitmap mapping each tick to its corresponding value.packages/oraiswap-v3/src/helpers.ts (9)
282-287
: LGTM!The
shiftDecimal
function correctly shifts the decimal point of a bigint value by the specified number of places. The logic is sound and the implementation is clear.
289-297
: LGTM!The
parseAsset
function correctly parses a token and amount into an Asset object. It handles both cases of a token having a contract address or a denom. The logic is straightforward and the implementation is clean.
299-356
: LGTM!The
generateMessageSwapOperation
function correctly generates Route objects from SmartRouteResponse objects. It handles both OraiSwap and OraiSwapV3 swap operations and constructs the appropriate SwapOperation objects for each. The logic is complex but well-structured and the implementation is thorough.
366-376
: LGTM!The
calculatePriceImpact
function correctly calculates the price impact between two sqrt prices. The logic is sound and avoids floating point arithmetic by using a denominator. The implementation is clear and concise.
379-436
: LGTM!The
getPriceImpactAfterSwap
function correctly calculates the price impact of a swap route by simulating each swap operation and accumulating the price impacts. The logic is complex but well-structured and the implementation is thorough. The use of WASM functions for swap simulation is a good optimization.
438-447
: LGTM!The
calculateRewardAmounts
function correctly calculates the reward amounts for a liquidity position by callingcalculateTokenAmounts
and applying the zap fee percentage. The logic is straightforward and the implementation is clear.
449-481
: LGTM!The
buildZapOutMessage
function correctly builds a ZapOutLiquidityResponse message from a ZapOutResult and swap routes. It calculates the minimum receive amounts, generates the swap routes, calculates the total swap fee, and constructs the response object. The logic is clear and the implementation is straightforward.
483-497
: LGTM!The
extractOraidexV3Actions
function correctly extracts OraidexV3 actions from an array of RouteResponse objects. The logic is straightforward and the implementation is clear and concise.
499-523
: LGTM!The
populateMessageZapIn
function correctly populates a ZapInLiquidityResponse message with swap and liquidity data. It sets the asset in, amounts, pool key, sqrt price, tick indexes, and swap routes on the message object. The logic is clear and the implementation is straightforward.packages/oraiswap-v3/src/zap-consumer.ts (9)
53-58
: LGTM!The constructor is correctly initializing the class properties using the provided config object.
64-98
: LGTM!The
getPriceInfo
method is correctly fetching price data for asset swaps and handling edge cases and errors.
100-143
: LGTM!The
findRoute
method is correctly identifying optimal routes for asset swaps and handling edge cases and errors.
145-165
: LGTM!The
findZapOutRoutes
method is correctly finding routes for zap out operations by concurrently callingfindRoute
for both token X and token Y.
167-186
: LGTM!The
findZapInRoutes
method is correctly finding routes for zap in operations by concurrently callingfindRoute
for both token X and token Y.
188-219
: LGTM!The
simulateSwapOffChain
method is correctly simulating swaps off-chain by fetching the necessary data and calling the WASM module.Tools
Biome
[error] 189-189: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
221-331
: LGTM!The
processZapInWithSingleSide
method is correctly processing zap in with a single side by determining the token needed, finding the route, simulating the swap, and populating the zap in message.
333-567
: LGTM!The
processZapInPositionLiquidity
method is correctly processing zap in position liquidity by fetching the pool, calculating the token amounts, finding the routes, simulating the swap, and populating the zap in message.
569-608
: LGTM!The
processZapOutPositionLiquidity
method is correctly processing zap out position liquidity by fetching the position, calculating the reward amounts, finding the routes, and building the zap out message.
} | { | ||
protocol_fee: {}; | ||
}; | ||
export interface MigrateMsg {} |
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.
Use a type alias instead of an empty interface.
An empty interface is equivalent to {}
, which means "any non-nullable value" and does not provide type safety. Consider using a type alias instead.
For example:
-export interface MigrateMsg {}
+export type MigrateMsg = Record<string, never>;
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.
export interface MigrateMsg {} | |
export type MigrateMsg = Record<string, never>; |
Tools
Biome
[error] 90-90: An empty interface is equivalent to {}.
Safe fix: Use a type alias instead.
(lint/suspicious/noEmptyInterface)
export type QueryMsg = { | ||
config: {}; | ||
} | { | ||
protocol_fee: {}; | ||
}; |
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.
Update the type definition to explicitly define the shape of the query messages.
Using {}
as a type is not recommended because it means "any non-nullable value" and does not provide type safety. Consider updating the type definition to explicitly define the shape of the query messages.
For example:
-export type QueryMsg = {
- config: {};
-} | {
- protocol_fee: {};
-};
+export type QueryMsg = {
+ config: {
+ // Define the shape of the config query message
+ };
+} | {
+ protocol_fee: {
+ // Define the shape of the protocol_fee query message
+ };
+};
Committable suggestion was skipped due to low confidence.
Tools
Biome
[error] 86-86: Don't use '{}' as a type.
Prefer explicitly define the object shape. '{}' means "any non-nullable value".
(lint/complexity/noBannedTypes)
[error] 88-88: Don't use '{}' as a type.
Prefer explicitly define the object shape. '{}' means "any non-nullable value".
(lint/complexity/noBannedTypes)
node-version: ${{ matrix.node-version }} | ||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" |
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.
Update the syntax for setting output variables.
The "set-output" command is deprecated and will be removed in the future. Please update to the new syntax to ensure future compatibility.
-run: echo "::set-output name=dir::$(yarn cache dir)"
+run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
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.
run: echo "::set-output name=dir::$(yarn cache dir)" | |
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT |
Tools
actionlint
31-31: workflow command "set-output" was deprecated. use
echo "{name}={value}" >> $GITHUB_OUTPUT
instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions(deprecated-commands)
access_token: ${{ github.token }} | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 |
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.
Update the "actions/setup-node" action to the latest version.
The current version of the "actions/setup-node" action is outdated and may cause compatibility issues. Please update to the latest version to ensure proper functionality.
-uses: actions/setup-node@v2
+uses: actions/setup-node@v3
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.
uses: actions/setup-node@v2 | |
uses: actions/setup-node@v3 |
Tools
actionlint
26-26: the runner of "actions/setup-node@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
uses: styfle/cancel-workflow-action@0.8.0 | ||
with: | ||
access_token: ${{ github.token }} | ||
- uses: actions/checkout@v2 |
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.
Update the "actions/checkout" action to the latest version.
The current version of the "actions/checkout" action is outdated and may cause compatibility issues. Please update to the latest version to ensure proper functionality.
-uses: actions/checkout@v2
+uses: actions/checkout@v3
Committable suggestion was skipped due to low confidence.
Tools
actionlint
24-24: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
packages/oraiswap-v3/src/types.ts
Outdated
export type SmartRouteReponse = { | ||
swapAmount: string; | ||
returnAmount: string; | ||
routes: any[]; | ||
}; |
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 changing the type of the routes property to a specific type.
The SmartRouteReponse
type is well-structured and includes all the necessary properties for defining a smart route response in a zap operation. The property names are clear and descriptive, and the types are appropriate, except for the routes property.
The routes property is an array of any type, which is not a good practice. It should be an array of a specific type, such as RouteResponse
or a new type that defines the structure of a route in a smart route response.
Consider changing the type of the routes property to a specific type, such as RouteResponse
or a new type that defines the structure of a route in a smart route response:
export type SmartRouteReponse = {
swapAmount: string;
returnAmount: string;
- routes: any[];
+ routes: RouteResponse[];
};
Committable suggestion was skipped due to low confidence.
packages/oraiswap-v3/src/helpers.ts
Outdated
export const getFeeRate = (operation: SwapOperation): number => { | ||
if ("orai_swap" in operation) { | ||
return 0.003; | ||
} else { | ||
return operation.swap_v3.pool_key.fee_tier.fee / 10 ** 12; | ||
} | ||
}; |
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.
Handle unknown operation types.
The getFeeRate
function assumes that if the operation is not an OraiSwap operation, it must be an OraiSwapV3 operation. This could lead to errors if a new operation type is introduced in the future.
Consider adding a default case that throws an error for unknown operation types:
export const getFeeRate = (operation: SwapOperation): number => {
if ("orai_swap" in operation) {
return 0.003;
+ } else if ("swap_v3" in operation) {
+ return operation.swap_v3.pool_key.fee_tier.fee / 10 ** 12;
} else {
- return operation.swap_v3.pool_key.fee_tier.fee / 10 ** 12;
+ throw new Error(`Unknown swap operation type: ${JSON.stringify(operation)}`);
}
};
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.
export const getFeeRate = (operation: SwapOperation): number => { | |
if ("orai_swap" in operation) { | |
return 0.003; | |
} else { | |
return operation.swap_v3.pool_key.fee_tier.fee / 10 ** 12; | |
} | |
}; | |
export const getFeeRate = (operation: SwapOperation): number => { | |
if ("orai_swap" in operation) { | |
return 0.003; | |
} else if ("swap_v3" in operation) { | |
return operation.swap_v3.pool_key.fee_tier.fee / 10 ** 12; | |
} else { | |
throw new Error(`Unknown swap operation type: ${JSON.stringify(operation)}`); | |
} | |
}; |
Summary by CodeRabbit
New Features
ZapConsumer
class, enabling "zap in" and "zap out" operations.OraiswapV3Handler
class.Bug Fixes
Documentation
Chores
.gitignore
and added configuration files for improved project structure and dependency management.