Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/update amm v3 sdk #303

Merged
merged 2 commits into from
Jul 24, 2024
Merged

Feat/update amm v3 sdk #303

merged 2 commits into from
Jul 24, 2024

Conversation

vuonghuuhung
Copy link
Member

@vuonghuuhung vuonghuuhung commented Jul 24, 2024

Summary by CodeRabbit

  • New Features

    • Updated version numbers for @oraichain/oraidex-contracts-build and @oraichain/oraidex-contracts-sdk packages.
    • Introduced new incentive management methods within the OraiswapV3 client, enhancing user ability to create, update, and claim incentives.
    • Added support for new contract name "oraiswap-v3" within the system.
    • Expanded incentive-related data structures and query capabilities, improving tracking and management of incentives.
  • Bug Fixes

    • Version updates may include resolved issues to improve overall stability and performance.

Copy link

coderabbitai bot commented Jul 24, 2024

Walkthrough

The recent updates introduce significant changes to the Oraiswap contract ecosystem, including a new version release for both the SDK and build packages. Key enhancements involve expanded incentive management functionalities within the OraiswapV3 client, enabling creation, modification, and claiming of incentives. Additionally, new types and interfaces have been added to support these features, improving the overall handling of incentives and asset information across the platform.

Changes

Files Change Summary
packages/contracts-build/package.json Updated version from 1.0.33 to 1.0.34.
packages/contracts-build/src/index.ts Added "oraiswap-v3" to the ContractName type definition, enhancing contract naming options.
packages/contracts-sdk/package.json Updated version from 1.0.45 to 1.0.46.
packages/contracts-sdk/src/OraiswapV3.client.ts Added new methods for managing incentives: positionIncentives, createIncentive, updateIncentive, and claimIncentive.
packages/contracts-sdk/src/OraiswapV3.types.ts Introduced new message types for incentives (create_incentive, update_incentive, claim_incentive), new types/interfaces for asset and incentive tracking.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant OraiswapV3Interface
    participant OraiswapV3ReadOnlyInterface

    User->>OraiswapV3Interface: createIncentive(params)
    OraiswapV3Interface-->>OraiswapV3ReadOnlyInterface: Incentive created
    User->>OraiswapV3Interface: updateIncentive(params)
    OraiswapV3Interface-->>OraiswapV3ReadOnlyInterface: Incentive updated
    User->>OraiswapV3Interface: claimIncentive(index)
    OraiswapV3Interface-->>User: Incentive claimed
    User->>OraiswapV3ReadOnlyInterface: positionIncentives(index, ownerId)
    OraiswapV3ReadOnlyInterface-->>User: Returns incentive details
Loading

Poem

🐇 In the fields where bunnies play,
New incentives hop and sway,
With contracts strengthened, oh what glee!
For Oraiswap's growth, let's dance with glee!
Each reward a joyful treat,
Hopping high on nimble feet! 🌟


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

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                                     17      17  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                                         157       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                                          959       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                                             107       0  100.00%
packages/oraiswap-v3/src/helpers.ts                                             193      10  94.81%   110-111, 121-122, 147-148, 176-177, 187-188
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                                         1111     552  50.31%   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, 641-651, 654-664, 671-678, 692-770, 774-805, 809-828, 831-848, 852-903, 908-991, 997-1068, 1077-1082, 1101-1102, 1104-1105, 1111, 1115-1130, 1139-1142, 1186-1189, 1196-1204, 1209, 1249-1250, 1280-1291, 1358-1359
packages/universal-swap/src/helper.ts                                           767     244  68.18%   80-82, 218-219, 373-375, 397-403, 427-429, 433-435, 442-468, 523-524, 566-573, 580-621, 635-692, 731-732, 747, 775, 782-803, 805-806, 839-840, 843-846, 856-898, 906-922, 981-991, 1002-1007, 1026
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                71      71  0.00%    1-546
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                                    1624      32  98.02%   239-242, 271-272, 283-284, 289-290, 292-293, 295-296, 1050-1069
packages/universal-swap/tests/smart-router-common.ts                            805       0  100.00%
packages/universal-swap/tests/test-common.ts                                     56       0  100.00%
TOTAL                                                                         10579    2549  75.90%

Diff against main

Filename      Stmts    Miss  Cover
----------  -------  ------  --------
TOTAL             0       0  +100.00%

Results for commit: decdf29

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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bf16163 and decdf29.

Files ignored due to path filters (1)
  • packages/contracts-build/data/oraiswap-v3.wasm is excluded by !**/*.wasm
Files selected for processing (5)
  • 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/OraiswapV3.client.ts (7 hunks)
  • packages/contracts-sdk/src/OraiswapV3.types.ts (7 hunks)
Files skipped from review due to trivial changes (2)
  • packages/contracts-build/package.json
  • packages/contracts-sdk/package.json
Additional context used
Biome
packages/contracts-sdk/src/OraiswapV3.client.ts

[error] 9-9: Do not shadow the global "Boolean" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

Additional comments not posted (25)
packages/contracts-build/src/index.ts (1)

18-19: LGTM! Ensure consistency across the codebase.

The addition of "oraiswap-v3" to the ContractName type is correct.

Verify that all references to ContractName throughout the codebase are updated to handle this new contract name.

Verification successful

Verification successful.

The ContractName type includes "oraiswap-v3", and the functions that use ContractName are designed to handle different contract names dynamically. No issues found with the handling of "oraiswap-v3".

  • packages/contracts-build/src/index.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `ContractName` handle the new "oraiswap-v3" contract name.

# Test: Search for `ContractName` usage. Expect: References to "oraiswap-v3".
rg --type ts 'ContractName'

Length of output: 277


Script:

#!/bin/bash
# Extract and inspect lines around each reference to `ContractName` to verify if "oraiswap-v3" is handled appropriately.

# Extract lines around the definition of `ContractName`
rg --type ts -A 5 -B 5 'export type ContractName' packages/contracts-build/src/index.ts

# Extract lines around the usage of `ContractName` in `getContractDir`
rg --type ts -A 5 -B 5 'getContractDir' packages/contracts-build/src/index.ts

# Extract lines around the usage of `ContractName` in the object with an optional `contractName` property
rg --type ts -A 5 -B 5 'contractName?: ContractName' packages/contracts-build/src/index.ts

Length of output: 1288

packages/contracts-sdk/src/OraiswapV3.types.ts (13)

114-121: New incentive creation message type looks good.

The create_incentive message type is well-defined and includes necessary fields for pool key, reward per second, reward token, and optional fields for start timestamp and total reward.


123-129: New incentive update message type looks good.

The update_incentive message type is well-defined and includes necessary fields for incentive ID, pool key, and optional fields for remaining reward, reward per second, and start timestamp.


131-133: New incentive claim message type looks good.

The claim_incentive message type is well-defined and includes necessary fields for the index.


149-157: New AssetInfo type looks good.

The AssetInfo type is well-defined and can represent either a token or a native token, enhancing asset handling flexibility.


301-304: New position incentives query type looks good.

The position_incentives query type is well-defined and includes necessary fields for index and owner ID.


Line range hint 327-336:
Addition of incentives field to Position interface looks good.

The incentives field in the Position interface is well-defined and allows tracking of incentives associated with each position.


337-341: New PositionIncentives interface looks good.

The PositionIncentives interface is well-defined and includes necessary fields for incentive growth, ID, and pending rewards.


367-372: Addition of incentives field to Pool interface looks good.

The incentives field in the Pool interface is well-defined and allows tracking of incentives related to the pool.


373-381: New IncentiveRecord interface looks good.

The IncentiveRecord interface is well-defined and includes necessary fields for incentive ID, growth metrics, and reward specifics.


418-421: New TickIncentive interface looks good.

The TickIncentive interface is well-defined and includes necessary fields for incentive growth and ID.


387-388: New Uint128 type looks good.

The Uint128 type definition is simple and correct.


388-389: New ArrayOfAsset type looks good.

The ArrayOfAsset type definition is simple and correct.


389-392: New Asset interface looks good.

The Asset interface is well-defined and includes necessary fields for amount and asset info.

packages/contracts-sdk/src/OraiswapV3.client.ts (11)

179-185: New positionIncentives method in OraiswapV3ReadOnlyInterface looks good.

The positionIncentives method is well-defined and includes necessary parameters for index and owner ID.


219-219: Binding the positionIncentives method in OraiswapV3QueryClient looks good.

The positionIncentives method is correctly bound in the OraiswapV3QueryClient constructor.


560-573: Implementation of positionIncentives method in OraiswapV3QueryClient looks good.

The positionIncentives method is correctly implemented and queries the contract for position incentives.


733-745: New createIncentive method in OraiswapV3Interface looks good.

The createIncentive method is well-defined and includes necessary parameters for pool key, reward per second, reward token, start timestamp, and total reward.


746-752: New updateIncentive method in OraiswapV3Interface looks good.

The updateIncentive method is well-defined and includes necessary parameters for incentive ID, pool key, remaining reward, reward per second, and start timestamp.


753-758: New updateIncentive method in OraiswapV3Interface looks good.

The updateIncentive method is well-defined and includes necessary parameters for incentive ID, pool key, remaining reward, reward per second, and start timestamp.


759-763: New claimIncentive method in OraiswapV3Interface looks good.

The claimIncentive method is well-defined and includes necessary parameters for the index.


796-798: Binding the new incentive methods in OraiswapV3Client looks good.

The createIncentive, updateIncentive, and claimIncentive methods are correctly bound in the OraiswapV3Client constructor.


1107-1129: Implementation of createIncentive method in OraiswapV3Client looks good.

The createIncentive method is correctly implemented and sends the appropriate execute message to the contract.


1130-1152: Implementation of updateIncentive method in OraiswapV3Client looks good.

The updateIncentive method is correctly implemented and sends the appropriate execute message to the contract.


1153-1163: Implementation of claimIncentive method in OraiswapV3Client looks good.

The claimIncentive method is correctly implemented and sends the appropriate execute message to the contract.

@@ -6,7 +6,7 @@

import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { Coin, StdFee } from "@cosmjs/amino";
import {Percentage, InstantiateMsg, ExecuteMsg, Addr, Liquidity, SqrtPrice, TokenAmount, Binary, Expiration, Timestamp, Uint64, PoolKey, FeeTier, SwapHop, NftExtensionMsg, QueryMsg, MigrateMsg, FeeGrowth, AllNftInfoResponse, OwnerOfResponse, Approval, NftInfoResponse, Position, TokensResponse, ApprovedForAllResponse, Boolean, ArrayOfFeeTier, ArrayOfLiquidityTick, LiquidityTick, Uint32, NumTokensResponse, Pool, ArrayOfPoolWithPoolKey, PoolWithPoolKey, ArrayOfPositionTick, PositionTick, ArrayOfPosition, QuoteResult, Tick, ArrayOfTupleOfUint16AndUint64} from "./OraiswapV3.types";
import {Percentage, InstantiateMsg, ExecuteMsg, Addr, Liquidity, SqrtPrice, TokenAmount, Binary, Expiration, Timestamp, Uint64, AssetInfo, PoolKey, FeeTier, SwapHop, NftExtensionMsg, QueryMsg, MigrateMsg, FeeGrowth, AllNftInfoResponse, OwnerOfResponse, Approval, NftInfoResponse, Position, PositionIncentives, TokensResponse, ApprovedForAllResponse, Boolean, ArrayOfFeeTier, ArrayOfLiquidityTick, LiquidityTick, Uint32, NumTokensResponse, Pool, IncentiveRecord, ArrayOfPoolWithPoolKey, PoolWithPoolKey, Uint128, ArrayOfAsset, Asset, ArrayOfPositionTick, PositionTick, ArrayOfPosition, QuoteResult, Tick, TickIncentive, ArrayOfTupleOfUint16AndUint64} from "./OraiswapV3.types";
Copy link

Choose a reason for hiding this comment

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

Consider renaming the Boolean type to avoid shadowing the global Boolean property.

Shadowing global properties can lead to confusion and potential bugs.

-  Boolean
+  CustomBoolean
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
import {Percentage, InstantiateMsg, ExecuteMsg, Addr, Liquidity, SqrtPrice, TokenAmount, Binary, Expiration, Timestamp, Uint64, AssetInfo, PoolKey, FeeTier, SwapHop, NftExtensionMsg, QueryMsg, MigrateMsg, FeeGrowth, AllNftInfoResponse, OwnerOfResponse, Approval, NftInfoResponse, Position, PositionIncentives, TokensResponse, ApprovedForAllResponse, Boolean, ArrayOfFeeTier, ArrayOfLiquidityTick, LiquidityTick, Uint32, NumTokensResponse, Pool, IncentiveRecord, ArrayOfPoolWithPoolKey, PoolWithPoolKey, Uint128, ArrayOfAsset, Asset, ArrayOfPositionTick, PositionTick, ArrayOfPosition, QuoteResult, Tick, TickIncentive, ArrayOfTupleOfUint16AndUint64} from "./OraiswapV3.types";
import {Percentage, InstantiateMsg, ExecuteMsg, Addr, Liquidity, SqrtPrice, TokenAmount, Binary, Expiration, Timestamp, Uint64, AssetInfo, PoolKey, FeeTier, SwapHop, NftExtensionMsg, QueryMsg, MigrateMsg, FeeGrowth, AllNftInfoResponse, OwnerOfResponse, Approval, NftInfoResponse, Position, PositionIncentives, TokensResponse, ApprovedForAllResponse, CustomBoolean, ArrayOfFeeTier, ArrayOfLiquidityTick, LiquidityTick, Uint32, NumTokensResponse, Pool, IncentiveRecord, ArrayOfPoolWithPoolKey, PoolWithPoolKey, Uint128, ArrayOfAsset, Asset, ArrayOfPositionTick, PositionTick, ArrayOfPosition, QuoteResult, Tick, TickIncentive, ArrayOfTupleOfUint16AndUint64} from "./OraiswapV3.types";
Tools
Biome

[error] 9-9: Do not shadow the global "Boolean" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

@vuonghuuhung vuonghuuhung merged commit 2533d80 into main Jul 24, 2024
2 checks passed
@vuonghuuhung vuonghuuhung deleted the feat/update_amm_v3_sdk branch July 24, 2024 07:49
@coderabbitai coderabbitai bot mentioned this pull request Sep 11, 2024
@coderabbitai coderabbitai bot mentioned this pull request Sep 19, 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.

3 participants