-
Notifications
You must be signed in to change notification settings - Fork 607
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
feat: taker fee performance refactor #7555
Conversation
// isDenomWhitelisted checks if the denom provided exists in the list of authorized quote denoms. | ||
// If it does, it returns true, otherwise false. | ||
func isDenomWhitelisted(denom string, authorizedQuoteDenoms []string) bool { | ||
for _, authorizedQuoteDenom := range authorizedQuoteDenoms { | ||
if denom == authorizedQuoteDenom { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
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.
No longer checked at time of swap, moved to epoch logic
expectedTakerFeeToStakers := []sdk.Coin{sdk.NewCoin(tc.expectedResult.Denom, roundup(expectedTakerFeeToStakersAmount))} | ||
expectedTakerFeeToCommunityPool := []sdk.Coin{sdk.NewCoin(tc.expectedResult.Denom, expectedTakerFeeToCommunityPoolAmount.TruncateInt())} | ||
|
||
// Validate results. | ||
s.Require().Equal(tc.expectedResult.String(), tokenInAfterTakerFee.String()) | ||
expectedTakerFeeTrackerForStakersAfter := []sdk.Coin{} | ||
if !expectedTakerFeeToStakers[0].IsZero() { | ||
expectedTakerFeeTrackerForStakersAfter = expectedTakerFeeToStakers | ||
} | ||
s.Require().Equal(expectedTakerFeeTrackerForStakersAfter, takerFeeTrackerForStakersAfter) | ||
expectedTakerFeeTrackerForCommunityPoolAfter := []sdk.Coin{} | ||
if !expectedTakerFeeToCommunityPool[0].IsZero() { | ||
expectedTakerFeeTrackerForCommunityPoolAfter = expectedTakerFeeToCommunityPool |
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.
The tracker is no longer updated at fee charge time, so this does not need to be tested here.
s.Require().Len(communityPoolBalanceDelta, 4) | ||
s.Require().Equal(communityPoolBalanceDelta[0].Denom, otherPreSwapDenom) | ||
s.Require().Equal(communityPoolBalanceDelta[1].Denom, denomWithNoPool) | ||
s.Require().Equal(communityPoolBalanceDelta[2].Denom, preSwapDenom) | ||
s.Require().Equal(communityPoolBalanceDelta[3].Denom, communityPoolDenom) |
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.
All these denoms are whitelisted quote assets, so they are direct sends to the community pool. The denomWithNoProtorevLink is not whitelisted, so it stays in the communityPoolCollectorAddress.
@@ -167,7 +166,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut_Events() { | |||
tokenOut: sdk.NewCoin("foo", osmomath.NewInt(tokenOut)), | |||
tokenInMaxAmount: osmomath.NewInt(tokenInMaxAmount), | |||
expectedSwapEvents: 2, | |||
expectedMessageEvents: 8, // 1 gamm + 7 events emitted by other keeper methods. | |||
expectedMessageEvents: 6, // 1 gamm + 5 events emitted by other keeper methods. |
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.
Good news for other parts of disk size too haha
non_native_fee_collector: osmo1g7ajkk295vactngp74shkfrprvjrdwn662dg26 | ||
non_native_fee_collector_community_pool: osmo1f3xhl0gqmyhnu49c8k3j7fkdv75ug0xjtaqu09 | ||
``` | ||
- Non native taker fees |
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.
Good job on docs, this made this much easier to understand!
Co-authored-by: Dev Ojha <[email protected]>
Co-authored-by: Dev Ojha <[email protected]>
// FeeCollectorName the module account name for the fee collector account address. | ||
FeeCollectorName = "fee_collector" | ||
// NonNativeTxFeeCollectorName is the module account name for the alt fee collector account address (used for auto-swapping non-OSMO tx fees). | ||
NonNativeTxFeeCollectorName = "non_native_fee_collector" |
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.
SLightly worried that this used to be FeeCollectorForStakingRewardsName
and what happens if there are leftover funds in the addr
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.
Not sure I am understanding, @ValarDragon the address is exactly the same, I just changed the reference name of it because it was confusing.
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.
Ahh I understand now, nice job
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.
great job on comments inthis file
Co-authored-by: Dev Ojha <[email protected]>
Co-authored-by: Dev Ojha <[email protected]>
Co-authored-by: Dev Ojha <[email protected]>
Nice job on this! This did definitely take me awhile to review, and I think its because we mixed two things:
If we find review time become painful for things like this, maybe a good idea for us to separate out renames + logic changes next time. I felt like I had to reconsider all the logic for some of the simple rename things due to git diff inadequacy |
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.
This LGTM, though I think we should do a second pass on this code in a second PR and simplify the hooks.go code
Sound good, sorry about that, will try and split PRs like this up more in the future. |
Closes: #7519
What is the purpose of the change
There were three glaring issues with our taker fee implementation:
This PR fixes these issues, drastically reducing the performance overhead that taker fees currently have on Osmosis.