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

Feature/1151 update osmosis deps #1152

Merged
merged 4 commits into from
Feb 19, 2024
Merged

Conversation

joe-bowman
Copy link
Contributor

@joe-bowman joe-bowman commented Feb 15, 2024

1. Summary

Fixes #1151 - upgrade osmosis types to v22.0.5, in preparation for adding CL pools types to claims.

2.Type of change

  • Update dependencies

3. Implementation details

  • Update types to v22.0.5 - gamm, lockup, osmomath, osmoutils.
  • Add concentrated-liquidity and poolmanager modules.
  • Remove references to tx/amino in pb.go files
  • Update gogoproto to use tm0.34 compatible gotoproto, else types fail to register.

Summary by CodeRabbit

  • New Features

    • Introduced concentrated liquidity management for third-party chain integration, including creating, managing, and withdrawing from liquidity positions.
    • Added governance proposals for concentrated liquidity pools, including creation and tick spacing adjustments.
    • Implemented concentrated liquidity events and incentives tracking.
    • Enhanced mathematical functions for liquidity and price calculations in concentrated liquidity contexts.
    • Updated GAMM module with new pool types, error handling, and event management.
    • Improved pool management with new methods for swaps, liquidity adjustments, and governance controls across various pool models.
  • Refactor

    • Consolidated interface definitions and updated method signatures across the Osmosis protocol to enhance clarity and consistency.
    • Refined error handling and message formatting in GAMM and concentrated liquidity modules.
    • Optimized key generation functions for efficient data storage and retrieval in concentrated liquidity pools.
  • Documentation

    • Added comprehensive documentation on key space format and expectations in the concentrated liquidity module.
  • Bug Fixes

    • Corrected error types and messages to ensure accurate error reporting and handling in the GAMM module.

@joe-bowman joe-bowman added module: participationrewards Participation Rewards Module dependencies Pull requests that update a dependency file labels Feb 15, 2024
@joe-bowman joe-bowman requested a review from faddat as a code owner February 15, 2024 12:50
Copy link

vercel bot commented Feb 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
quicksilver ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2024 9:25am

Copy link
Contributor

coderabbitai bot commented Feb 15, 2024

Walkthrough

The changes introduce comprehensive support for concentrated liquidity (CL) pools in the Osmosis blockchain protocol, including the management of pool parameters, liquidity updates, swaps, and governance proposals. Additionally, updates to the GAMM module enhance pool models and error handling. The upgrade to osmosis-types v22 facilitates these enhancements, aligning with the latest Osmosis features.

Changes

Files Change Summary
.../osmosis-types/concentrated-liquidity/* Introduced concentrated liquidity management, including pool extension, events, errors, governance, and math calculations.
.../osmosis-types/gamm/* Updated GAMM module with changes in codec registrations, constants, errors, events, and pool models for better integration and functionality.
.../osmosis-types/gamm/pool-models/* Modifications in balancer and stableswap pool models, including new functions, parameter updates, and JSON handling.

Assessment against linked issues

Objective Addressed Explanation
Bump osmosis-types to v22 (#1151)

Poem

In the blockchain's vast and open plain,
Where liquidity flows like spring rain,
A rabbit hopped, with a coder's brain,
Bringing pools of concentrated gain.
🌊💻🐇
With each leap, a new feature set,
Osmosis, in its finest form yet.


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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 36

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 704d348 and d4068cb.
Files ignored due to path filters (29)
  • third-party-chains/osmosis-types/concentrated-liquidity/gov.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/concentrated-liquidity/incentive_record.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/concentrated-liquidity/model/pool.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/concentrated-liquidity/model/position.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/concentrated-liquidity/model/tickInfo.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/concentrated-liquidity/model/tx.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/concentrated-liquidity/params.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/concentrated-liquidity/tx.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/gamm/genesis.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/gamm/pool-models/balancer/balancerPool.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/gamm/pool-models/balancer/tx.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/gamm/pool-models/stableswap/stableswap_pool.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/gamm/pool-models/stableswap/tx.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/gamm/query.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/gamm/query.pb.gw.go is excluded by: !**/*.pb.gw.go
  • third-party-chains/osmosis-types/gamm/tx.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/lockup/genesis.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/lockup/lock.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/lockup/params.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/lockup/query.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/lockup/query.pb.gw.go is excluded by: !**/*.pb.gw.go
  • third-party-chains/osmosis-types/lockup/tx.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/osmoutils/accum/accum.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/osmoutils/sumtree/legacy/v101/old_tree.json is excluded by: !**/*.json
  • third-party-chains/osmosis-types/osmoutils/sumtree/tree.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/poolmanager/module_route.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/poolmanager/swap_route.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/poolmanager/tracked_volume.pb.go is excluded by: !**/*.pb.go
  • third-party-chains/osmosis-types/poolmanager/tx.pb.go is excluded by: !**/*.pb.go
Files selected for processing (51)
  • third-party-chains/osmosis-types/concentrated-liquidity/cl.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/cl_pool_extensionI.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/codec.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/constants.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/errors.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/events.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/gov.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/keys.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/keyspace.md (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/listeners.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/math/math.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/math/precompute.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/math/tick.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/model/codec.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/model/msgs.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/model/pool.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/msgs.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/params.go (1 hunks)
  • third-party-chains/osmosis-types/concentrated-liquidity/pool_hooks.go (1 hunks)
  • third-party-chains/osmosis-types/gamm/codec.go (3 hunks)
  • third-party-chains/osmosis-types/gamm/constants.go (1 hunks)
  • third-party-chains/osmosis-types/gamm/errors.go (2 hunks)
  • third-party-chains/osmosis-types/gamm/events.go (1 hunks)
  • third-party-chains/osmosis-types/gamm/hooks.go (2 hunks)
  • third-party-chains/osmosis-types/gamm/key.go (2 hunks)
  • third-party-chains/osmosis-types/gamm/msg_lp.go (1 hunks)
  • third-party-chains/osmosis-types/gamm/msg_swap.go (1 hunks)
  • third-party-chains/osmosis-types/gamm/msgs.go (14 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/balancer/amm.go (11 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/balancer/codec.go (3 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/balancer/constants.go (2 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/balancer/marshal.go (1 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/balancer/msgs.go (4 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/balancer/pool.go (31 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/balancer/pool_asset.go (4 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/balancer/pool_params.go (3 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/internal/cfmm_common/lp.go (3 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/stableswap/amm.go (2 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/stableswap/codec.go (3 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/stableswap/msgs.go (4 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/stableswap/pool.go (7 hunks)
  • third-party-chains/osmosis-types/gamm/pool-models/stableswap/pool_params.go (1 hunks)
  • third-party-chains/osmosis-types/gamm/pool.go (3 hunks)
  • third-party-chains/osmosis-types/gamm/route.go (3 hunks)
  • third-party-chains/osmosis-types/lockup/codec.go (3 hunks)
  • third-party-chains/osmosis-types/lockup/errors.go (1 hunks)
  • third-party-chains/osmosis-types/lockup/expected_keepers.go (1 hunks)
  • third-party-chains/osmosis-types/lockup/genesis.go (1 hunks)
  • third-party-chains/osmosis-types/lockup/lock.go (3 hunks)
  • third-party-chains/osmosis-types/lockup/msgs.go (8 hunks)
  • third-party-chains/osmosis-types/lockup/params.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • third-party-chains/osmosis-types/gamm/msg_lp.go
Additional comments: 105
third-party-chains/osmosis-types/lockup/genesis.go (1)
  • 13-13: The change to the receiver of the Validate method aligns with Go best practices for method receivers, ensuring consistency and clarity in method definitions.
third-party-chains/osmosis-types/gamm/pool-models/stableswap/pool_params.go (2)
  • 4-5: Updated package imports to use specific types from types and osmomath. Ensure these changes are consistent across the entire module to maintain readability and avoid confusion.
  • 10-22: Adjusted validation logic for ExitFee and SwapFee to use types from osmomath. Confirm that these changes accurately reflect the intended validation logic and that there are no edge cases that have been overlooked.
third-party-chains/osmosis-types/gamm/events.go (1)
  • 4-20: Added new event types and attribute keys to enhance event logging capabilities. Verify that these additions are necessary and correctly implemented to capture specific actions within the system.
third-party-chains/osmosis-types/lockup/errors.go (2)
  • 3-5: Updated import statement for errors to use a more explicit import syntax. This change enhances clarity and maintainability.
  • 11-15: Updated error registration calls to use the new imported module name. Confirm that these changes are correctly implemented and that the error messages are clear and informative.
third-party-chains/osmosis-types/gamm/pool-models/balancer/constants.go (2)
  • 4-4: Replaced sdkmath package with osmomath to ensure consistency with the updated types across the module.
  • 21-21: Introduced a new constant PoolTypeName. Ensure that this constant is used consistently across the module and that its introduction aligns with the system's design requirements.
third-party-chains/osmosis-types/lockup/expected_keepers.go (1)
  • 21-21: Added a new method BurnCoins to the BankKeeper interface. Confirm that this addition is necessary for the system's functionality and that it is correctly implemented.
third-party-chains/osmosis-types/lockup/codec.go (1)
  • 14-16: Added new message types: MsgExtendLockup, MsgForceUnlock, MsgSetRewardReceiverAddress. Verify that these additions are necessary for the system's functionality and that they are correctly implemented.
third-party-chains/osmosis-types/gamm/msg_swap.go (1)
  • 6-6: Replaced SwapMsgRoute interface with an alias from poolmanagertypes. Confirm that this change simplifies the codebase and aligns with the system's design requirements.
third-party-chains/osmosis-types/concentrated-liquidity/model/codec.go (1)
  • 14-25: Updated interface registrations and declarations. Verify that these changes are correctly implemented and align with the system's design requirements.
third-party-chains/osmosis-types/concentrated-liquidity/cl_pool_extensionI.go (1)
  • 12-35: Updated method signatures and added new methods to the ConcentratedPoolExtension interface. Confirm that these changes are necessary for the system's functionality and that they are correctly implemented.
third-party-chains/osmosis-types/lockup/params.go (1)
  • 10-63: Added new parameters and updated validation logic in the Params struct. Verify that these changes are correctly implemented and align with the system's design requirements.
third-party-chains/osmosis-types/gamm/key.go (1)
  • 27-70: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [20-70]

Added new constants and refactored functions to handle GAMMTokenPrefix. Confirm that these changes are correctly implemented and align with the system's design requirements.

third-party-chains/osmosis-types/gamm/pool-models/balancer/codec.go (1)
  • 4-11: Updated package imports and interface registrations. Ensure these changes improve clarity and maintainability.
third-party-chains/osmosis-types/gamm/pool-models/stableswap/codec.go (1)
  • 22-34: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [9-54]

Imported new packages and updated interface registrations. Confirm that these changes are correctly implemented and align with the system's design requirements.

third-party-chains/osmosis-types/gamm/pool-models/balancer/marshal.go (1)
  • 11-65: Added new fields to the balancerPoolPretty struct and implemented new MarshalJSON and UnmarshalJSON methods. Verify that these changes are necessary for the system's functionality and that they are correctly implemented.
third-party-chains/osmosis-types/concentrated-liquidity/codec.go (1)
  • 11-55: Updated interface registrations and declarations. Confirm that these changes are correctly implemented and align with the system's design requirements.
third-party-chains/osmosis-types/gamm/hooks.go (1)
  • 30-55: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [10-53]

Renamed functions and changed parameters to type osmomath.Int. Verify that these changes are necessary for the system's functionality and that they are correctly implemented.

third-party-chains/osmosis-types/gamm/codec.go (1)
  • 38-55: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [13-53]

Updated interface registrations and declarations. Confirm that these changes are correctly implemented and align with the system's design requirements.

third-party-chains/osmosis-types/gamm/pool-models/balancer/pool_params.go (3)
  • 20-20: The error type ErrNegativeExitFee should be checked for its correct definition and usage, considering the context of spread factors.
Verification successful

The ErrNegativeExitFee is defined in errors.go with the message "exit fee is negative" and is used in both the balancer and stableswap pool_params.go files within the context of handling exit fees. This indicates a consistent and appropriate application of the error across different pool models when dealing with negative exit fees. The direct connection to spread factors isn't evident from the grep output, but the usage context suggests it's applied in scenarios where a negative exit fee is encountered, which aligns with the error's definition. Without specific details on the calculations or business logic involving spread factors and exit fees, it's challenging to further assess the contextual correctness beyond this point.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the definition and usage of ErrNegativeExitFee in the context of spread factors.
grep -R "ErrNegativeExitFee" .

Length of output: 392

* 28-28: The error type `ErrNegativeSpreadFactor` should be checked for its correct definition and usage, considering the context of spread factors.
Verification successful

The error ErrNegativeSpreadFactor is defined in errors.go with the description "spread factor is negative," which directly aligns with its intended purpose. Its usage in both the balancer and stableswap pool_params.go files suggests a consistent application across different pool models when dealing with negative spread factors. This confirms that the error type is correctly defined and used within the context of spread factors.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the definition and usage of ErrNegativeSpreadFactor in the context of spread factors.
grep -R "ErrNegativeSpreadFactor" .

Length of output: 412

* 75-75: The method `GetPoolExitFee` is correctly named and implemented based on the context provided.
third-party-chains/osmosis-types/gamm/route.go (6)
  • 3-7: Reorganized imports and updated type declarations are correctly implemented.
  • 9-9: The type declaration for SwapAmountInRoutes has been correctly updated to use poolmanagertypes.SwapAmountInRoute.
  • 26-36: Methods IntermediateDenoms, PoolIds, and Length for SwapAmountInRoutes are correctly implemented and follow best practices.
  • 50-50: The type declaration for SwapAmountOutRoutes has been correctly updated to use poolmanagertypes.SwapAmountOutRoute.
  • 67-89: Methods IntermediateDenoms, PoolIds, and Length for SwapAmountOutRoutes are correctly implemented and follow best practices.
  • 91-95: The MultihopRoute interface is correctly declared and includes essential methods for handling multihop routes.
third-party-chains/osmosis-types/gamm/constants.go (1)
  • 4-41: Added constants and their calculations using osmomath package are correctly implemented and follow best practices.
third-party-chains/osmosis-types/concentrated-liquidity/listeners.go (2)
  • 5-16: The ConcentratedLiquidityListener interface is correctly declared with appropriate method signatures.
  • 18-49: Methods implemented for ConcentratedLiquidityListeners correctly iterate over listeners and call corresponding methods.
third-party-chains/osmosis-types/gamm/pool-models/balancer/msgs.go (4)
  • 4-9: Renamed imports and types related to pool management are correctly implemented.
  • 17-18: The MsgCreateBalancerPool struct correctly implements interfaces from poolmanager types.
  • 35-36: The Route and Type methods in MsgCreateBalancerPool are correctly implemented.
  • 99-99: The CreatePool method in MsgCreateBalancerPool correctly creates a new balancer pool.
third-party-chains/osmosis-types/lockup/lock.go (5)
  • 5-5: The addition of math/big and osmomath imports is correctly implemented.
  • 14-17: The constant DefaultOwnerReceiverPlaceholder is correctly declared and used.
  • 20-31: The NewPeriodLock function correctly handles the reward_address and sets RewardReceiverAddress.
  • 45-48: The IsNil method for SyntheticLock is correctly implemented to check if an instance is nil.
  • 66-85: The SumLocksByDenom function should use osmomath.Int for all operations to ensure consistency with the updated types.
third-party-chains/osmosis-types/gamm/pool-models/balancer/pool_asset.go (4)
  • 10-10: The addition of the osmomath package import is correctly implemented.
  • 20-21: The poolAssetPretty struct correctly uses osmomath.Dec for Weight.
  • 26-26: The validateWeight function correctly checks if the weight is greater than zero using osmomath types.
  • 76-81: The validation logic in validateUserSpecifiedPoolAssets correctly checks the number of pool assets and uses updated error handling.
third-party-chains/osmosis-types/concentrated-liquidity/model/msgs.go (3)
  • 23-36: The NewMsgCreateConcentratedPool function is correctly implemented with appropriate parameters and return type.
  • 39-68: The ValidateBasic method in MsgCreateConcentratedPool correctly validates sender address, tick spacing, denominations, and spread factor.
  • 101-103: The CreatePool method in MsgCreateConcentratedPool correctly creates a new concentrated liquidity pool.
third-party-chains/osmosis-types/concentrated-liquidity/constants.go (1)
  • 9-71: Added constants related to ticks, spot prices, and authorized values are correctly implemented and follow best practices.
third-party-chains/osmosis-types/concentrated-liquidity/events.go (1)
  • 3-51: Added event types and attribute keys are correctly implemented and follow best practices.
third-party-chains/osmosis-types/gamm/errors.go (1)
  • 19-110: Addition of new error types and updates to existing ones improve error handling and clarity. Ensure all new errors are correctly utilized in the codebase.
third-party-chains/osmosis-types/gamm/pool.go (3)
  • 12-60: The introduction of CFMMPoolI interface with methods like JoinPool, JoinPoolNoSwap, ExitPool, etc., replaces the previous PoolI interface. Ensure that all implementations of the old interface are updated to comply with the new interface requirements.
  • 77-115: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [70-101]

The PoolAmountOutExtension interface is introduced, extending CFMMPoolI with methods like CalcTokenInShareAmountOut and JoinPoolTokenInMaxShareAmountOut. This addition suggests a more specialized pool operation capability. Confirm that the pools intended to use this extension are correctly implementing these methods.

  • 104-114: The WeightedPoolExtension interface, extending CFMMPoolI, introduces weight-related methods like PokePool and GetTokenWeight. This change implies a more complex pool management system. Ensure that pools using this extension properly implement these methods and handle weight adjustments.
third-party-chains/osmosis-types/concentrated-liquidity/keys.go (7)
  • 24-56: Constants and key prefixes are well-defined and follow a consistent naming convention. However, ensure that the choice of byte values for prefixes does not conflict with other modules or future expansions.
  • 59-81: The function TickIndexToBytes correctly handles the conversion of tick indexes to byte slices, including handling negative indexes. Ensure comprehensive testing, especially around edge cases like very large or small tick indexes.
  • 83-98: TickIndexFromBytes correctly decodes byte slices back into tick indexes. Pay attention to error handling for invalid lengths and ensure that tests cover scenarios where the input byte slice is malformed.
  • 100-116: KeyTick function logic appears correct, combining pool ID and tick index into a unique key. Consider adding performance benchmarks for key generation functions to ensure they meet efficiency requirements.
  • 118-132: KeyTickPrefixByPoolId is straightforward and uses pre-allocated memory efficiently. This approach is good for performance.
  • 134-149: keyTickPrefixByPoolIdPrealloc demonstrates good use of pre-allocated memory for performance. The concatenation logic is clear and correct.
  • 168-303: The remaining key generation functions follow a consistent pattern and logic. Ensure that all key generation and parsing functions are covered by unit tests, especially focusing on edge cases and error handling.
third-party-chains/osmosis-types/gamm/pool-models/stableswap/amm.go (10)
  • 11-19: The function cfmmConstantMultiNoV correctly implements the CFMM equation for multi-asset pools. Ensure that mathematical operations are accurately represented and tested, especially for edge cases involving large numbers or near-zero values.
  • 33-45: solveCfmm correctly implements the CFMM solving logic. Ensure comprehensive testing for this function, particularly with a variety of remReserves values and edge cases like extremely high or low yIn values.
  • 47-59: targetKCalculator uses precise mathematical operations to calculate target K values. Verify the mathematical accuracy through unit tests, especially testing with boundary values for x0, y0, w, and yf.
  • 61-78: iterKCalculator implements a complex mathematical function. The use of Horner's method for polynomial evaluation is efficient. Ensure the correctness of the implementation with extensive testing, particularly for the calculation of res.
  • 85-109: deriveUpperLowerXFinalReserveBounds calculates bounds for binary search. The logic appears sound, but ensure that the assumptions made for deriving bounds are valid across all expected pool states and configurations.
  • 112-155: solveCFMMBinarySearchMulti integrates several mathematical functions to solve for xOut. The binary search implementation must be thoroughly tested for convergence and accuracy, especially considering the potential for rounding errors and the choice of error tolerance.
  • 182-203: calcOutAmtGivenIn correctly calculates output amounts given an input. The mathematical logic is sound, but ensure that the handling of spreadFactor and the rounding directions are thoroughly tested for accuracy and expected behavior.
  • 205-227: calcInAmtGivenOut calculates the required input amount for a desired output. The logic for handling negative amounts and spread factors is crucial. Test extensively to ensure that the function behaves as expected under various pool conditions and spread factors.
  • 230-252: calcSingleAssetJoinShares calculates LP shares for single-asset joins. The handling of spread factors and the binary search implementation are key areas to focus on. Ensure that the logic correctly accounts for fees and pool share calculations.
  • 254-279: singleAssetJoinSpreadFactorRatio calculates the ratio of input asset liquidity to total liquidity. This function is critical for determining fees on single-asset joins. Validate the mathematical logic and rounding behavior through testing, especially for pools with significant asset ratios.
third-party-chains/osmosis-types/concentrated-liquidity/model/pool.go (1)
  • 123-123: The TODO comment is noted. Based on the learning, it's understood that this is within a vendored directory and can be safely ignored.
third-party-chains/osmosis-types/gamm/pool-models/balancer/pool.go (32)
  • 10-16: Renaming of imported packages and reorganization of imports improve readability and avoid naming conflicts. Ensure that all references to these packages throughout the codebase are updated accordingly.
  • 7-26: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [19-35]

Interface implementations for PoolI, PoolAmountOutExtension, WeightedPoolExtension, and CFMMPoolI are correctly updated to reflect the new functionalities of the pool. This ensures that the pool adheres to the expected behavior defined by these interfaces.

  • 45-47: The NewBalancerPool function correctly initializes a new pool with the provided parameters. Ensure that all input parameters are validated before being used to prevent potential issues with pool creation.
Verification successful

The NewBalancerPool function indeed exists and is responsible for initializing a new pool with the provided parameters. The output from the script shows that the function takes several parameters (poolId, balancerPoolParams, assets, futureGovernor, blockTime) and returns a Pool object along with an error if any occurs during the initialization process.

From the provided output, it's clear that there are validations performed on the input parameters:

  • The pool.SetInitialPoolAssets(assets) method is called, which likely validates the assets parameter.
  • The balancerPoolParams.Validate(sortedPoolAssets) method is called, validating the balancerPoolParams against the sorted pool assets.
  • The pool.setInitialPoolParams(balancerPoolParams, sortedPoolAssets, blockTime) method is also called, which likely involves further validation of the pool parameters and assets based on the provided context.

Given this information, it can be concluded that the review comment is accurate in stating that the NewBalancerPool function initializes a new pool with the provided parameters and that there is evidence of validation for these parameters to prevent potential issues with pool creation.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that input parameters to NewBalancerPool are validated.
ast-grep --lang go --pattern $'func NewBalancerPool($_, $_, $_, $_, $_) ($_,$_){
  $$$
  $_ := $_($_)
  $$$
}'

Length of output: 111



Script:

#!/bin/bash
# Broaden the search to find the NewBalancerPool function regardless of its parameters or body structure.
ast-grep --lang go --pattern $'func NewBalancerPool($$$) $$$'

Length of output: 3456

* 81-81: The `GetAddress` method correctly handles potential errors from `sdk.AccAddressFromBech32`. Using `panic` for error handling in this context is acceptable given the critical nature of address decoding failures. However, consider logging the error for better diagnostics. * 92-92: The `GetSpreadFactor` method's implementation is straightforward and correctly retrieves the pool's spread factor. This is crucial for calculating fees and ensuring fair trades within the pool. * 100-100: The `GetExitFee` method correctly retrieves the pool's exit fee. This is important for calculating the cost of exiting the pool and ensuring that the fee structure is transparent to users. * 108-108: The `GetTotalWeight` method's implementation is correct and efficiently retrieves the total weight of the pool. This is essential for various pool operations, including liquidity management and asset swaps. * 116-120: Methods `AddTotalShares` and `SubTotalShares` correctly modify the pool's total shares. Ensure atomicity in operations involving pool shares to prevent data races in concurrent environments. * 143-143: The validation for non-positive token amounts in `SetInitialPoolAssets` is crucial for ensuring the integrity of pool assets. This prevents the addition of invalid assets to the pool, maintaining its stability. * 183-183: The initialization of `SmoothWeightChangeParams.InitialPoolWeights` with zero amounts is a good practice for setting up weight change parameters. This ensures that the pool's weight change logic starts from a known state. * 229-229: The error handling in `getPoolAssetAndIndex` using `errorsmod.Wrapf` provides detailed error messages, improving debuggability. Ensure that all error paths in asset retrieval and indexing are covered. * 255-260: Error handling in `parsePoolAssetsByDenoms` is clear and informative, providing specific messages for missing assets. This aids in diagnosing issues with asset retrieval in pool operations. * 288-288: The `IncreaseLiquidity` method correctly updates pool asset balances and total shares. Ensure that liquidity changes are consistently applied across all relevant pool operations to maintain the pool's integrity. * 303-303: Validating that the coin amount is not zero or negative in `UpdatePoolAssetBalance` is essential for maintaining the integrity of pool assets. This prevents setting invalid balances for pool assets. * 442-442: The logic for calculating the percentage of duration elapsed in `PokePool` is correct. This is crucial for accurately updating pool weights over time according to the smooth weight change parameters. * 460-460: The `GetTokenWeight` method correctly retrieves the weight of a specific token in the pool. This is essential for various pool operations, including swaps and liquidity management. * 469-469: The `GetTokenBalance` method correctly retrieves the balance of a specific token in the pool. This ensures accurate calculations for swaps and liquidity changes involving that token. * 482-482: The `IsActive` method correctly indicates that the pool is active. This method is essential for determining the pool's availability for operations like swaps and liquidity provisioning. * 486-488: The `GetType` method correctly identifies the pool type as `Balancer`. This is important for handling pool-specific logic and operations within the broader pool management system. * 496-496: The `CalcOutAmtGivenIn` method's implementation for calculating tokens to be swapped out is correct. Ensure that all calculations adhere to the pool's invariant and fee structures for accurate swap outcomes.
Verification successful

Given the initial script did not produce any output, it's essential to verify the existence and signature of the CalcOutAmtGivenIn method in the codebase. Let's adjust our approach to first confirm the method's presence and understand its structure better. This will help in refining the search pattern for a more accurate verification.


Given the confirmation of the CalcOutAmtGivenIn method's existence in both stableswap/pool.go and balancer/pool.go, it's clear that the initial verification script may have been too narrowly focused or incorrectly formatted. To accurately verify the implementation details, particularly how solveConstantFunctionInvariant is utilized within the method, a refined approach is necessary. Let's adjust the verification strategy to better match the method's structure and implementation details.


The search results confirm the use of solveConstantFunctionInvariant within the CalcOutAmtGivenIn method in the balancer/pool.go file, indicating that the method indeed adheres to the pool's invariant and fee structures for calculating swap outcomes. This matches the initial review comment's verification requirement. However, there was no output for stableswap/pool.go, which was not the primary focus of the verification but worth noting for completeness.

Given this information, it can be concluded that the CalcOutAmtGivenIn method in the balancer pool model correctly implements the logic for calculating tokens to be swapped out, adhering to the pool's invariant and fee structures as per the review comment's verification request.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify calculations adhere to pool's invariant and fee structures.
ast-grep --lang go --pattern $'func (p Pool) CalcOutAmtGivenIn($_, $_, $_, $_) ($_,$_){
  $$$
  tokenAmountOut := solveConstantFunctionInvariant($$$)
  $$$
}'

Length of output: 159



Script:

#!/bin/bash
# Verify the existence and signature of CalcOutAmtGivenIn method
rg "func \(p Pool\) CalcOutAmtGivenIn"

Length of output: 359



Script:

#!/bin/bash
# Refine search to verify the use of solveConstantFunctionInvariant within CalcOutAmtGivenIn method
rg "solveConstantFunctionInvariant" third-party-chains/osmosis-types/gamm/pool-models/balancer/pool.go
rg "solveConstantFunctionInvariant" third-party-chains/osmosis-types/gamm/pool-models/stableswap/pool.go

Length of output: 445

* 550-550: The `CalcInAmtGivenOut` method correctly calculates the token amount to be provided for a given swapped out amount. This ensures that swaps are executed fairly according to the pool's rules and fee structures.
Verification successful

The verification process has confirmed the existence of the CalcInAmtGivenOut method within the Pool struct in both the stableswap and balancer pool models. Specifically, for the balancer pool model, which is the focus of the review comment, the method does indeed use solveConstantFunctionInvariant to calculate the token amount in, as outlined in lines 562-564. This method takes into account the pool's rules and fee structures, including the spread factor, to ensure fair execution of swaps. The method also includes steps to handle rounding errors and ensure that the token amount in is positive, further aligning with the comment's assertion about fairness and adherence to pool rules.

Given this context, the review comment is consistent with the codebase, confirming that the CalcInAmtGivenOut method in the balancer pool model calculates the token amount to be provided for a given swapped out amount fairly, according to the pool's rules and fee structures.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify fair execution of swaps according to pool's rules and fee structures.
ast-grep --lang go --pattern $'func (p Pool) CalcInAmtGivenOut($_, $_, $_, $_) ($_,$_){
  $$$
  tokenAmountIn := solveConstantFunctionInvariant($$$)
  $$$
}'

Length of output: 158



Script:

#!/bin/bash
# Confirm the existence of the CalcInAmtGivenOut method within the Pool struct.
ast-grep --lang go --pattern $'func (p Pool) CalcInAmtGivenOut($_, $_, $_, $_) ($_,$_){
  $$$
}'

Length of output: 6272

* 601-601: The `applySwap` method correctly consumes fixed gas per swap to prevent spam and updates pool asset balances accordingly. Ensure that gas consumption and balance updates are consistently applied across all swap operations.
Verification successful

The verification process focused on ensuring that the applySwap method in the pool.go file correctly consumes fixed gas per swap to prevent spam and updates pool asset balances accordingly. The script output confirmed the presence of gas consumption and balance update operations within this method. Subsequent scripts aimed to identify additional swap-related methods that might handle gas consumption and balance updates differently did not produce relevant findings, suggesting that the applySwap method is the primary mechanism for swap operations with these considerations in the examined scope.

Based on the information gathered, it can be concluded that the applySwap method's implementation aligns with the review comment's concerns about consistent application of gas consumption and balance updates across swap operations within the available context. No evidence was found to suggest inconsistencies or the presence of other swap-related methods that deviate from this practice within the examined parts of the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify consistent application of gas consumption and balance updates in swap operations.
ast-grep --lang go --pattern $'func (p *Pool) applySwap($_, $_, $_) $_ {
  $$$
  ctx.GasMeter().ConsumeGas($_, $_)
  $$$
  return p.UpdatePoolAssetBalances($_)
  $$$
}'

Length of output: 1988



Script:

#!/bin/bash
# Search for additional swap-related methods in the pool.go file and elsewhere in the project
# to verify gas consumption and balance update patterns.
rg --glob '!third-party-chains/osmosis-types/gamm/pool-models/balancer/pool.go' 'swap' | grep -E 'func \(.*Pool\) .*swap'
# Additionally, check within the same file for any other swap-related methods not covered by the initial pattern.
rg --glob 'third-party-chains/osmosis-types/gamm/pool-models/balancer/pool.go' 'swap' | grep -E 'func \(.*Pool\) .*swap'

Length of output: 770

* 619-619: The `SpotPrice` method's implementation for calculating the spot price of the pool is correct. This is crucial for providing accurate pricing information for swaps and liquidity management. * 652-652: The `calcSingleAssetJoin` method correctly calculates the number of shares for a single asset join. Ensure that all single asset joins are calculated accurately to maintain fairness in liquidity provisioning.
Verification successful

The broader search successfully identified the calcSingleAssetJoin method within the Pool struct in the balancer/pool.go file, as specified in the original review comment. The method signature and its implementation details, including the call to calcPoolSharesOutGivenSingleAssetIn, match the expectations outlined in the review comment. This method calculates the number of shares for a single asset join, taking into account the token in, spread factor, token in pool asset, and total shares, and returns the calculated number of shares and any potential error.

Given this information, it can be concluded that the calcSingleAssetJoin method is implemented as described, and it correctly calculates the number of shares for a single asset join, which is crucial for maintaining fairness in liquidity provisioning.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify accuracy of single asset join calculations.
ast-grep --lang go --pattern $'func (p *Pool) calcSingleAssetJoin($_, $_, $_, $_) ($_,$_){
  $$$
  return calcPoolSharesOutGivenSingleAssetIn($$$)
  $$$
}'

Length of output: 156



Script:

#!/bin/bash
# Broaden the search to find any method related to single asset join calculations in the Pool struct.
ast-grep --lang go --pattern $'func (p *Pool) $_($_, $_, $_, $_) ($_,$_){
  $$$
}'

Length of output: 11674

* 675-675: The `JoinPool` method correctly calculates and updates liquidity for pool joins. Ensure that liquidity updates are consistently applied and accurately reflect the changes resulting from pool joins. * 825-825: The `ExitPool` method correctly calculates and updates liquidity for pool exits. Ensure that liquidity updates are consistently applied and accurately reflect the changes resulting from pool exits.
Verification successful

Given the lack of output from the initial script, it's necessary to broaden our search to better understand how liquidity updates are handled within the ExitPool method or related functionalities. Let's attempt to find any references to liquidity updates or related operations within the context of the ExitPool method.

This script aims to capture the entire body of the ExitPool method without focusing on a specific pattern of calling another method. This should help us understand how liquidity updates are handled within or around this method.


The provided code snippets from the stableswap and balancer pool models show that both implement a process to calculate and update liquidity for pool exits. In the stableswap model, liquidity updates are explicitly handled by subtracting exitingCoins from p.PoolLiquidity and validating the post-exit liquidity, followed by an update operation. In the balancer model, the liquidity update process is encapsulated within the exitPool method, as indicated by its call with exitingCoins and exitingShares as arguments.

Based on this information, it can be inferred that the ExitPool method in both models is designed to correctly calculate and update liquidity for pool exits, aligning with the review comment's assertion. However, the exact consistency and accuracy of these updates would depend on the internal logic of the mentioned methods, which is not fully visible in the provided snippets but is suggested by their context and usage.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify consistent and accurate application of liquidity updates in pool exits.
ast-grep --lang go --pattern $'func (p *Pool) ExitPool($_, $_, $_) ($_,$_){
  $$$
  if err := p.exitPool($_, $_, $_); err != nil {
    $$$
  }
  $$$
}'

Length of output: 152



Script:

#!/bin/bash
# Broaden the search to find references to liquidity updates in the ExitPool method or related functionalities.
ast-grep --lang go --pattern $'func (p *Pool) ExitPool($_, $_, $_) ($_,$_){
  $$$
}'

Length of output: 2987

* 852-852: The `CalcExitPoolCoinsFromShares` method correctly calculates the coins to be exited from the pool based on shares. This ensures that pool exits are executed fairly according to the pool's rules and fee structures. * 859-859: The `CalcTokenInShareAmountOut` method correctly calculates the token amount for a given share out amount. This is important for accurately determining the cost of obtaining a specific amount of pool shares. * 889-889: The `JoinPoolTokenInMaxShareAmountOut` method correctly calculates the token amount for a given share out amount and updates the pool asset balance. Ensure that balance updates are accurately applied to reflect the join operation.
Verification successful

The JoinPoolTokenInMaxShareAmountOut method in the pool.go file accurately calculates the token amount for a given share out amount and updates the pool asset balance to reflect the join operation, as described in the review comment. The method's implementation, including the calculation of the tokenInAmount and the update of the pool asset balance using the UpdatePoolAssetBalance method, aligns with the expected behavior.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify accurate application of balance updates in join operations.
ast-grep --lang go --pattern $'func (p *Pool) JoinPoolTokenInMaxShareAmountOut($_, $_, $_) ($_,$_){
  $$$
  err = p.UpdatePoolAssetBalance($_)
  $$$
}'

Length of output: 3446

* 922-922: The `ExitSwapExactAmountOut` method correctly calculates the share in amount for a given token out amount. This ensures that exit swaps are executed fairly according to the pool's rules and fee structures. * 953-953: The `AsSerializablePool` method correctly returns the pool as a serializable type. This is important for ensuring that the pool can be serialized and deserialized correctly in various contexts. * 957-957: The `GetPoolDenoms` method correctly retrieves the denominations of assets in the pool. This is crucial for operations that require knowledge of the pool's asset composition.

@faddat
Copy link
Contributor

faddat commented Feb 15, 2024

it is doing the thing again. I cannot figure out why.

@coderabbitai why is only amd64/linux failing?

Copy link
Contributor

coderabbitai bot commented Feb 15, 2024

@faddat, it seems there was an issue with fetching the build logs due to an incorrect command usage. However, I was able to retrieve the list of recent changes made in the PR. The changes involve a significant number of files related to osmosis-types, particularly within the concentrated-liquidity and gamm modules, among others.

Given the scope of these changes, the failure on amd64/linux could be related to platform-specific behavior in the updated dependencies or the newly introduced code. It's also possible that there are Linux-specific compilation or runtime issues introduced by these changes, such as differences in how certain libraries or dependencies are handled on Linux compared to other platforms.

To further diagnose the issue, I recommend checking the build logs for the amd64/linux build directly in your CI system or environment to identify the specific error messages or failures. Look for any errors that could be related to the changes made, especially those affecting platform-specific behavior, dependencies, or compilation.

If you have access to the build logs and can share specific error messages or details, I could provide more targeted advice on resolving the issue.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Fetch the latest build logs for amd64/linux
gh run list --workflow=build.yml --list-files | grep 'amd64/linux' | head -n 1 | awk '{print $1}' | xargs -I {} gh run download {} -D ./build-logs/

# Review recent changes made in the PR that could potentially affect the amd64/linux build
git diff HEAD~1 --name-only

Length of output: 3920

Copy link
Contributor

@faddat faddat left a comment

Choose a reason for hiding this comment

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

I assume that we are importing all of these files, because we are having issues with importing them from upstream?

Does it make sense to upgrade to sdk v0.47.x?

@faddat
Copy link
Contributor

faddat commented Feb 15, 2024

@joe-bowman I made #1153 in order to resolve the platform specific issues.

@joe-bowman joe-bowman enabled auto-merge (squash) February 19, 2024 09:23
@joe-bowman joe-bowman merged commit 244de3e into main Feb 19, 2024
19 of 22 checks passed
@joe-bowman joe-bowman deleted the feature/1151-update-osmosis-deps branch February 21, 2024 23:28
@joe-bowman joe-bowman restored the feature/1151-update-osmosis-deps branch February 21, 2024 23:29
@joe-bowman joe-bowman deleted the feature/1151-update-osmosis-deps branch March 5, 2024 13:34
joe-bowman pushed a commit that referenced this pull request Apr 30, 2024
* update osmosis-types to v22; add concentrated-liquidity and poolmanager

* update osmosis-types usages for v22 types

* ensure pool and math dirs are included; update codecs for inclusion
joe-bowman pushed a commit that referenced this pull request Apr 30, 2024
* update osmosis-types to v22; add concentrated-liquidity and poolmanager
* update osmosis-types usages for v22 types
* ensure pool and math dirs are included; update codecs for inclusion
faddat added a commit that referenced this pull request Apr 30, 2024
* Update osmosis deps (#1152)

* update osmosis-types to v22; add concentrated-liquidity and poolmanager
* update osmosis-types usages for v22 types
* ensure pool and math dirs are included; update codecs for inclusion

* remove wasm references from osmosis-types

* lint

---------

Co-authored-by: Jacob Gadikian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file module: participationrewards Participation Rewards Module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bump osmosis-types to v22
2 participants