osmosis
osmosis copied to clipboard
perf: charge taker fees only once at the end on multi hops / split routes
Closes: #XXX
What is the purpose of the change
We currently charge taker fees at every hop in a multi hop. We can instead just tally the taker fees and charge it once at the very end.
This change does have the slight negative effect of, if someone doesn't have enough for the taker fees on, lets say, the first hop (but enough for the swap itself), the method wont fail early and instead will fail after all hops are complete when the method attempts to charge the user for the taker fees. IMO this is worth the small overhead for the reduced number of swaps and event emissions. Note that this would only happen if someone inputted more than what they have, since the taker fees are taken off the initial input, so this scenario won't be run into in normal circumstances.
Walkthrough
The update introduces a feature to charge taker fees once at the end of multi-hop/split-route swaps within the Osmosis project, enhancing efficiency. It includes renaming and restructuring functions and tests to support this feature, refining the logic to calculate and charge taker fees. Changes also include updates to the governance parameter, trading pair overrides, a bug fix related to fee charging in smart accounts, and enforced constraints on sub-authenticators.
Changes
| File Path | Change Summary |
|---|---|
| CHANGELOG.md | Summarized changes including support for charging taker fees, SDK v50 upgrade, and various fixes. |
| x/poolmanager/msg_server_test.go | Adjusted expectedMessageEvents values in tests to reflect the new logic. |
| x/poolmanager/router.go | Introduced methods to handle taker fees, renamed and refactored existing methods. |
| x/poolmanager/router_test.go | Renamed and added test functions to test internal routing logic. |
| x/poolmanager/taker_fee.go | Restructured taker fee functions into separate calculation and charging functions. |
Sequence Diagrams
Multi-Hop/Route Swap with Taker Fees
sequenceDiagram
participant User
participant Router
participant TakerFeeModule
participant Pools
User->>Router: Initiate Multi-Hop Swap
Router->>Pools: Perform Swaps
loop Per Swap
Pools-->>Router: Return Swap Result
Router->>Router: Accumulate Taker Fees
end
Router->>TakerFeeModule: Charge Accumulated Taker Fees
TakerFeeModule-->>Router: Confirm Fee Charging
Router-->>User: Return Final Swap Result
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?
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
@coderabbitaiin 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
@coderabbitaiin 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 using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you!