-
Notifications
You must be signed in to change notification settings - Fork 122
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
fix(affiliates): Fix logic in affiliate referred volume aggregation #2623
Conversation
WalkthroughThe changes introduce a new method, Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
protocol/x/affiliates/keeper/keeper.go (1)
Line range hint
346-385
: LGTM! Implementation correctly fixes the volume aggregation bug.The new implementation properly handles the case where maker's volume should be counted towards affiliate's referred volume even when the taker isn't referred. The caching mechanism is also efficient.
Consider adding comments to explain the caching mechanism:
func (k Keeper) AggregateAffiliateReferredVolumeForFills( ctx sdk.Context, ) error { blockStats := k.statsKeeper.GetBlockStats(ctx) + // Cache referred addresses to avoid repeated store lookups referredByCache := make(map[string]string) for _, fill := range blockStats.Fills { + // Process taker's referred volume independently of maker referredByAddrTaker, cached := referredByCache[fill.Taker] ... + // Process maker's referred volume independently of taker referredByAddrMaker, cached := referredByCache[fill.Maker] ... } return nil }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
protocol/x/affiliates/keeper/keeper.go
(1 hunks)protocol/x/affiliates/keeper/keeper_test.go
(1 hunks)
🔇 Additional comments (1)
protocol/x/affiliates/keeper/keeper_test.go (1)
784-806
: LGTM! Test case properly validates the bug fix.
The test case effectively verifies that maker's volume is correctly counted towards affiliate's referred volume even when takers aren't referred. The test setup and assertions are comprehensive.
@Mergifyio backport release/protocol/v8.x |
✅ Backports have been created
|
@Mergifyio backport release/protocol/v7.1.x |
✅ Backports have been created
|
Changelist
Currently, when calculating referred volumes from new fills, if the taker is not referred, the fill is skipped directly so the maker volume (even if referred) does not count towards the affiliate's referred volume.
Fixed by independently adding volume from taker/maker.
This bug may result in protocol-view of affiliate referred volume being smaller than actual, potentially leading to lower than expected affiliate tier.
Test Plan
Unit test
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.Summary by CodeRabbit
New Features
Bug Fixes