feat: crosschain neutron osmosis lper - #6
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @uditvira, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a new cross-chain liquidity provision program, neutron_to_osmosis_crosschain_lper, enabling the seamless transfer of ATOM and stATOM tokens from Neutron to Osmosis for concentrated liquidity provision and subsequent withdrawal. It significantly expands the project's multi-chain capabilities by adding comprehensive configurations for Juno, Terra, and Osmosis, including Polytone bridge setups and Valence contract deployments. Furthermore, the PR updates core Valence protocol dependencies to a stable release and includes a new example program for on-chain token forwarding.
Highlights
- New Cross-Chain LPer Program: Introduced a new program,
neutron_to_osmosis_crosschain_lper, designed to facilitate cross-chain liquidity provision for ATOM and stATOM tokens between the Neutron and Osmosis chains. This program leverages IBC transfers (via Cosmos Hub and Stride) and Osmosis Concentrated Liquidity pools. - Multi-Chain Configuration Expansion: Expanded the
manager_configsto include comprehensive chain details and Valence contract deployment data for Juno, Terra, and Osmosis. This also includes new Polytone bridge configurations for Neutron-Juno, Neutron-Osmosis, and Neutron-Terra connections. - Dependency Updates: Updated numerous Valence protocol dependencies across the project from Git branches to a stable
v0.1.2tag, improving stability and maintainability. Several unused dependencies were also removed. - New Example Program: Added
osmosis_token_forwarder, a new example program demonstrating bidirectional token forwarding functionality on the Osmosis chain, showcasing the flexibility of the Valence framework.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces a significant new feature: a cross-chain liquidity providing program between Neutron and Osmosis for stATOM/ATOM. It also adds a new token forwarder program on Osmosis, along with extensive configuration updates and dependency version bumps to a stable tag, which is a great improvement.
The new programs are well-documented with README.md files that clearly explain their architecture and usage. The code is generally well-structured. My feedback primarily focuses on improving configuration management by parameterizing hardcoded values, enhancing the robustness of deployment scripts by using expect for safer parsing, and maintaining consistency in configuration files.
| PacketForwardMiddlewareConfig { | ||
| local_to_hop_chain_channel_id: neutron_stride_channel.clone(), | ||
| hop_to_destination_chain_channel_id: stride_osmosis_channel.clone(), | ||
| hop_chain_receiver_address: "stride1qxatg2nkmsf26cymcg2saeh9l2cqp0s2p0eqgx".to_string(), |
There was a problem hiding this comment.
The hop_chain_receiver_address is hardcoded. This makes the program less flexible and harder to configure for different environments (e.g., testnet vs mainnet). Please move this to the program_params/mainnet.toml configuration file by adding a new parameter like stride_hop_receiver_address.
This comment also applies to the hardcoded address on line 193.
| hop_chain_receiver_address: "stride1qxatg2nkmsf26cymcg2saeh9l2cqp0s2p0eqgx".to_string(), | |
| hop_chain_receiver_address: params.get("stride_hop_receiver_address").to_string(), |
| memo: "Transfer ATOM from Neutron to Osmosis via Cosmos Hub".to_string(), | ||
| remote_chain_info: valence_neutron_ibc_transfer_library::msg::RemoteChainInfo { | ||
| channel_id: neutron_cosmos_channel.clone(), | ||
| ibc_transfer_timeout: Some(Uint64::from(ibc_timeout_seconds.parse::<u64>().unwrap_or(3600))), |
There was a problem hiding this comment.
Using unwrap_or can hide configuration errors. If a parameter is missing or malformed in the .toml file, it will silently fall back to the default value, which could lead to an incorrectly configured deployment. It's better to fail fast during deployment by using .expect() to provide a clear error message.
This applies to other uses of unwrap_or and unwrap_or_default in this file when parsing configuration parameters (e.g., lines 135, 153, 157, 158, 175, 217, 239, 259, 263).
| ibc_transfer_timeout: Some(Uint64::from(ibc_timeout_seconds.parse::<u64>().unwrap_or(3600))), | |
| ibc_transfer_timeout: Some(Uint64::from(ibc_timeout_seconds.parse::<u64>().expect("Failed to parse ibc_timeout_seconds"))), |
| prefix = "osmo" | ||
| gas_price = "0.025" | ||
| gas_denom = "uosmo" | ||
| coin_type = "118" No newline at end of file |
| polytone_proxy = 127 | ||
| valence_mars_lending = 1619 | ||
| valence_splitter_library = 1620 | ||
| valence_base_account = 1621 | ||
| valence_forwarder_library = 1622 | ||
| valence_generic_ibc_transfer_library = 1623 | ||
| valence_osmosis_cl_lper = 1624 | ||
| valence_osmosis_cl_withdrawer = 1625 | ||
| valence_osmosis_gamm_lper = 1626 | ||
| valence_osmosis_gamm_withdrawer = 1627 | ||
| valence_processor = 1628 | ||
| valence_reverse_splitter_library = 1629 |
There was a problem hiding this comment.
For consistency and better readability, please align the = signs in the [contracts.code_ids.osmosis] section, similar to how it's done in other sections of this file.
polytone_proxy = 127
valence_mars_lending = 1619
valence_splitter_library = 1620
valence_base_account = 1621
valence_forwarder_library = 1622
valence_generic_ibc_transfer_library = 1623
valence_osmosis_cl_lper = 1624
valence_osmosis_cl_withdrawer = 1625
valence_osmosis_gamm_lper = 1626
valence_osmosis_gamm_withdrawer = 1627
valence_processor = 1628
valence_reverse_splitter_library = 1629
| neutron_stride_channel = "channel-8" # Neutron -> Stride channel | ||
| stride_osmosis_channel = "channel-5" # Stride -> Osmosis channel | ||
| osmosis_stride_channel = "channel-326" # Osmosis -> Stride channel | ||
| stride_neutron_channel = "channel-123" # Stride -> Neutron channel |
There was a problem hiding this comment.
For better readability, please align the inline comments.
neutron_stride_channel = "channel-8" # Neutron -> Stride channel
stride_osmosis_channel = "channel-5" # Stride -> Osmosis channel
osmosis_stride_channel = "channel-326" # Osmosis -> Stride channel
stride_neutron_channel = "channel-123" # Stride -> Neutron channel
|
|
||
| # Maximum amounts for operations | ||
| max_ibc_transfer_amount = "1000000000" # 1000 ATOM in micro units | ||
| max_forward_amount = "100000000" # Maximum forward amount No newline at end of file |
| @@ -0,0 +1 @@ | |||
| owner = "neutron1qxatg2nkmsf26cymcg2saeh9l2cqp0s2xms7xd" No newline at end of file | |||
| }; | ||
|
|
||
| let library_forwarder_a_to_b = builder.add_library(LibraryInfo::new( | ||
| "forwader_A_to_B".to_string(), |
With statom/atom