osmosis
osmosis copied to clipboard
feat: taker fee share
Closes: #8227
What is the purpose of the change
This PR implements the taker fee share logic that will be used to skim taker fee shares generated by swap routes that contain denoms that have a taker fee share agreement with the Osmosis protocol.
To review this PR, I recommend the following order:
- Read the README additions here
- Review the taker fee skim logic here
- Review the Begin/EndBlock logic here
- Review the taker fee skim fund clearing logic here and here
- Review the entire store.go file here
- Review all remaining tests/protos/files
Testing and Verifying
Setting a Taker Fee Share Agreement
To set a taker fee share agreement for a denom, use the new gov v1 type, sending a message of type MsgSetTakerFeeShareAgreementForDenom, with [denom] [skim_percent] [skim_address] as inputs. This message can only be executed by the gov module account.
Querying Taker Fee Share Agreements
To query all taker fee share agreements:
osmosisd query poolmanager all-taker-fee-share-agreements
To query the taker fee share agreement for a specific denom:
osmosisd query poolmanager taker-fee-share-agreement-from-denom [denom]
Querying Accrued Value and Accumulators
To query all taker fee share accumulators:
osmosisd query poolmanager all-taker-fee-share-accumulators
To query the accrued value of taker fees for specific denoms:
osmosisd query poolmanager taker-fee-share-denoms-to-accrued-value [takerFeeDenom] [denom]
Registering an Alloyed Pool
To register an alloyed pool for taker fee revenue sharing, use the new gov v1 type, sending a message of type MsgSetRegisteredAlloyedPool, with [pool_id] as the input. This message can only be executed by the gov module account.
Querying an Alloyed Pool
To query all registered alloyed pools:
osmosisd query poolmanager all-registered-alloyed-pools
To query the registered alloyed pool state from a specific denom:
osmosisd query poolmanager registered-alloyed-pool-from-denom [denom]
[!NOTE]
Reviews paused
Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.
Walkthrough
The changes introduce a new feature for taker fee revenue sharing for alloyed assets. This involves adding functions, constants, and message types for managing taker fee share agreements, handling alloyed pools, and updating various components to support these functionalities. The modifications span multiple files, focusing on initializing pools, querying and managing taker fee shares, and updating keeper interfaces.
Changes
| File(s) | Change Summary |
|---|---|
CHANGELOG.md |
Added summary of changes including the introduction of taker fee share feature. |
app/apptesting/cosmwasmpool.go |
Added imports, constants, and functions for managing transmuter pools. Modified existing functions to support new features. |
app/apptesting/test_suite.go |
Added AlloyedPoolID field to SupportedPoolAndGaugeInfo struct and updated pool preparation function. |
app/keepers/keepers.go |
Updated AppKeepers struct to include WasmKeeper and set it in PoolManagerKeeper. |
app/upgrades/v24/upgrades_test.go |
Adjusted indices in twapRecords and updated related test logic. |
ingest/sqs/domain/keepers.go |
Modified SwapExactAmountIn method in PoolManagerKeeper interface to return takerFeeTotal. |
proto/osmosis/cosmwasmpool/v1beta1/model/v3/... |
Introduced InstantiateMsg for alloyed asset pools and added message definitions for pool queries. |
proto/osmosis/poolmanager/v1beta1/query.proto |
Added imports and new RPC methods for taker fee share agreements and alloyed pools. |
proto/osmosis/poolmanager/v1beta1/taker_fee_share.proto |
Introduced message types for managing taker fee share agreements. |
proto/osmosis/poolmanager/v1beta1/tx.proto |
Added new RPC methods and message types for setting taker fee share agreements and registered alloyed pools. |
x/cosmwasmpool/pool_module_test.go |
Modified TestInitializePool to include an additional parameter in validInstantitateMsg. |
x/incentives/keeper/hooks_test.go |
Updated increaseVolumeBySwap function to handle additional return value from SwapExactAmountIn. |
x/pool-incentives/keeper/keeper_test.go |
Changed poolID variable to use AlloyedPoolID in test case. |
x/poolmanager/client/cli/query.go |
Added new query commands for taker fee share agreements and alloyed pools. |
x/poolmanager/client/grpc/grpc_query.go |
Added functions to Querier struct for handling taker fee share and alloyed pool queries. |
x/poolmanager/client/query_proto_wrap.go |
Added functions to handle taker fee share agreements, accumulated values, and registered alloyed pools. |
x/poolmanager/store.go |
Introduced methods for managing taker fee share agreements, accumulators, and registered alloyed pools. |
x/poolmanager/taker_fee.go |
Updated chargeTakerFee function to return an additional value and added TakerFeeSkim function. |
x/poolmanager/types/errors.go |
Added new error constants and types related to governance, caching, key format validation, and pool-related errors. |
Sequence Diagram(s) (Beta)
sequenceDiagram
participant User
participant CLI
participant gRPC
participant Keeper
participant PoolManager
User ->> CLI: Execute taker fee share query
CLI ->> gRPC: Forward query request
gRPC ->> Keeper: Query taker fee share agreements
Keeper ->> PoolManager: Retrieve agreements
PoolManager ->> Keeper: Return agreements
Keeper ->> gRPC: Send response
gRPC ->> CLI: Forward response
CLI ->> User: Display results
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Introduce taker fee logic for alloyed assets (8227) | ✅ | |
| Divert percentage of swaps involving bridged assets to a wallet (8227) | ✅ | |
| Charge fee when exiting an alloy or swapping through an alloy (8227) | ✅ |
Poem
In code we trust, a change so grand,
Taker fees now shared, across the land.
Alloyed assets, a new delight,
Pools are ready, shining bright.
With every swap, a fee to share,
Osmosis grows with utmost care.
Let's celebrate, with code so neat,
This update makes our work complete.
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 as 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.
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.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.
Actionable note: I'd like to add metrics to clearTakerFeeShareAccumulators in the event the clearing of a taker fee share accumulator fails, but that can be in a different PR
@coderabbitai stop
[!TIP] For best results, initiate chat on the files or code changes.
@czarcas7ic, I noticed your command to "stop." Could you please clarify if you'd like to pause or end the current discussion, or if there's a specific action you'd like me to stop? This will help me assist you better.
@coderabbitai stop leaving comments on this PR for now
@czarcas7ic, I will stop leaving comments on this PR as per your request. If you need further assistance in the future, feel free to reach out. Have a great day!
Actions performed
Reviews paused.
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!
Not finished with review yet - please ignore comments for now