Skip to content
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(poolmanager): taker fee reduction whitelist #6632

Merged
merged 10 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#6468](https://github.com/osmosis-labs/osmosis/pull/6468) feat: remove osmo multihop discount
* [#6420](https://github.com/osmosis-labs/osmosis/pull/6420) feat[CL]: Creates a governance set whitelist of addresses that can bypass the normal pool creation restrictions on concentrated liquidity pools
* [#6632](https://github.com/osmosis-labs/osmosis/pull/6632) Taker fee bypass whitelist

### State Breaking

Expand Down
10 changes: 8 additions & 2 deletions app/upgrades/v20/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
incentivestypes "github.com/osmosis-labs/osmosis/v19/x/incentives/types"
lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types"
poolincenitvestypes "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types"
)

type IncentivizedCFMMDirectWhenMigrationLinkPresentError struct {
Expand All @@ -21,6 +22,8 @@ type IncentivizedCFMMDirectWhenMigrationLinkPresentError struct {
CFMMGaugeID uint64
}

var emptySlice = []string{}

func (e IncentivizedCFMMDirectWhenMigrationLinkPresentError) Error() string {
return fmt.Sprintf("CFMM gauge ID (%d) incentivized CFMM pool (%d) directly when migration link is present with concentrated pool (%d)", e.CFMMGaugeID, e.CFMMPoolID, e.ConcentratedPoolID)
}
Expand All @@ -40,11 +43,14 @@ func CreateUpgradeHandler(
}

// Initialize the newly created param
keepers.ConcentratedLiquidityKeeper.SetParam(ctx, cltypes.KeyUnrestrictedPoolCreatorWhitelist, []string{})
keepers.ConcentratedLiquidityKeeper.SetParam(ctx, cltypes.KeyUnrestrictedPoolCreatorWhitelist, emptySlice)

// Initialize the new params in incentives for group creation.
keepers.IncentivesKeeper.SetParam(ctx, incentivestypes.KeyGroupCreationFee, incentivestypes.DefaultGroupCreationFee)
keepers.IncentivesKeeper.SetParam(ctx, incentivestypes.KeyCreatorWhitelist, []string{})
keepers.IncentivesKeeper.SetParam(ctx, incentivestypes.KeyCreatorWhitelist, emptySlice)

// Initialize new param in the poolmanager module with a whitelist allowing to bypass taker fees.
keepers.PoolManagerKeeper.SetParam(ctx, poolmanagertypes.KeyReducedTakerFeeByWhitelist, emptySlice)

// Converts pool incentive distribution records from concentrated gauges to group gauges.
err = createGroupsForIncentivePairs(ctx, keepers)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ require (
github.com/mattn/go-sqlite3 v1.14.17
github.com/ory/dockertest/v3 v3.10.0
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231003135651-7418f98f1a04
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230929193736-aae32321cac7
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231007115900-2500631de18e
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231007115900-2500631de18e
github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20230911120014-b14342e08daf
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20230911120014-b14342e08daf
github.com/pkg/errors v0.9.1
Expand Down
13 changes: 7 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTM
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
Expand Down Expand Up @@ -797,6 +798,7 @@ github.com/ldez/tagliatelle v0.5.0/go.mod h1:rj1HmWiL1MiKQuOONhd09iySTEkUuE/8+5j
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/leonklingele/grouper v1.1.1 h1:suWXRU57D4/Enn6pXR0QVqqWWrnJ9Osrz+5rjt8ivzU=
github.com/leonklingele/grouper v1.1.1/go.mod h1:uk3I3uDfi9B6PeUjsCKi6ndcf63Uy7snXgR4yDYQVDY=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
Expand Down Expand Up @@ -962,12 +964,10 @@ github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230922030206-734f99fba785 h1:
github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230922030206-734f99fba785/go.mod h1:toI9Pf+e5C4TuWAFpXfkxnkpr1RVFMK2qr7QMdkFrY8=
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 h1:YlmchqTmlwdWSmrRmXKR+PcU96ntOd8u10vTaTZdcNY=
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3/go.mod h1:lV6KnqXYD/ayTe7310MHtM3I2q8Z6bBfMAi+bhwPYtI=
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230924192433-36cf2950dca4 h1:venI3u6DjxKcQbjiCO3V8s0ww/jx+cAZRkpwLHadms8=
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230924192433-36cf2950dca4/go.mod h1:IlCTpM2uoi8SUAigc9r9kAaoz7K5H9O84u7CwaTLDdY=
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231003135651-7418f98f1a04 h1:C8LtPGkhJxfJNj7Xtok1If5yAV53O6XG3USaOJSgeg4=
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231003135651-7418f98f1a04/go.mod h1:jtOM+8RJMOn5e8YIaodzvO0b8kvBcHDgtCVCmWrx6wU=
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230929193736-aae32321cac7 h1:E5rwhxKEt6XOIfLkoLNiqCCFNCymJjiwMYIP+0ABMKM=
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230929193736-aae32321cac7/go.mod h1:YT53hlXr54D4MVKp3eoBxigiiYvy3F+h+xTZuGPW5R8=
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231007115900-2500631de18e h1:jzLtdFKLMvdqq+k3FYwvwCU3y1tzczXAs+R6JD+sxlY=
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231007115900-2500631de18e/go.mod h1:jtOM+8RJMOn5e8YIaodzvO0b8kvBcHDgtCVCmWrx6wU=
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231007115900-2500631de18e h1:TyAleAgHjQeQCXH+2qAgtLix+OcBRqFizIdiJE+r2GU=
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231007115900-2500631de18e/go.mod h1:YT53hlXr54D4MVKp3eoBxigiiYvy3F+h+xTZuGPW5R8=
github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20230911120014-b14342e08daf h1:8lkIsAj3L7zxvOZbqVLNJRpSdDxaYhYfAIG7XjPaJiU=
github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20230911120014-b14342e08daf/go.mod h1:C0Uqe6X4N5ASA+1xZ6guaaJyUVKLcaVJIQa4Q4LG9Vk=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20230911120014-b14342e08daf h1:ZEi+yJJPgpYtmNwZ1bMiP5cMBDQ83FK/YGgmTnWmoAI=
Expand Down Expand Up @@ -1238,6 +1238,7 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs=
github.com/tyler-smith/go-bip39 v1.0.2/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
Expand Down
30 changes: 30 additions & 0 deletions osmoutils/params_validation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package osmoutils

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// ValidateAddressList validates a slice of addresses.
//
// Parameters:
// - i: The parameter to validate.
//
// Returns:
// - An error if any of the strings are not addresses
func ValidateAddressList(i interface{}) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: copied from the x/concentrated-liquidity to reduce code duplication

whitelist, ok := i.([]string)

if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}

for _, a := range whitelist {
if _, err := sdk.AccAddressFromBech32(a); err != nil {
return fmt.Errorf("invalid address")
}
}

return nil
}
10 changes: 10 additions & 0 deletions proto/osmosis/poolmanager/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ message TakerFeeParams {
string community_pool_denom_to_swap_non_whitelisted_assets_to = 5
[ (gogoproto.moretags) =
"yaml:\"community_pool_denom_to_swap_non_whitelisted_assets_to\"" ];

// reduced_fee_whitelist is a list of addresses that are
// allowed to pay a reduce taker fee when performing a swap
// (i.e. swap without paying the taker fee).
// It is intended to be used for integrators who meet qualifying factors
// that are approved by governance.
// Initially, the taker fee is allowed to be bypassed completely. However
// In the future, we will charge a reduced taker fee instead of no fee at all.
repeated string reduced_fee_whitelist = 6
[ (gogoproto.moretags) = "yaml:\"reduced_fee_whitelist\"" ];
}

// TakerFeeDistributionPercentage defines what percent of the taker fee category
Expand Down
29 changes: 3 additions & 26 deletions x/concentrated-liquidity/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/osmoutils"
)

// Parameter store keys.
Expand Down Expand Up @@ -78,7 +79,7 @@ func (p Params) Validate() error {
if err := validateAuthorizedUptimes(p.AuthorizedUptimes); err != nil {
return err
}
if err := validateUnrestrictedPoolCreatorWhitelist(p.UnrestrictedPoolCreatorWhitelist); err != nil {
if err := osmoutils.ValidateAddressList(p.UnrestrictedPoolCreatorWhitelist); err != nil {
return err
}
return nil
Expand All @@ -93,7 +94,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
paramtypes.NewParamSetPair(KeyIsPermisionlessPoolCreationEnabled, &p.IsPermissionlessPoolCreationEnabled, validateIsPermissionLessPoolCreationEnabled),
paramtypes.NewParamSetPair(KeyDiscountRate, &p.BalancerSharesRewardDiscount, validateBalancerSharesDiscount),
paramtypes.NewParamSetPair(KeyAuthorizedUptimes, &p.AuthorizedUptimes, validateAuthorizedUptimes),
paramtypes.NewParamSetPair(KeyUnrestrictedPoolCreatorWhitelist, &p.UnrestrictedPoolCreatorWhitelist, validateUnrestrictedPoolCreatorWhitelist),
paramtypes.NewParamSetPair(KeyUnrestrictedPoolCreatorWhitelist, &p.UnrestrictedPoolCreatorWhitelist, osmoutils.ValidateAddressList),
}
}

Expand Down Expand Up @@ -242,27 +243,3 @@ func validateAuthorizedUptimes(i interface{}) error {

return nil
}

// validateUnrestrictedPoolCreatorWhitelist validates a slice of addresses
// that are allowed to bypass the restrictions on permissionless pool creation
//
// Parameters:
// - i: The parameter to validate.
//
// Returns:
// - An error if any of the strings are not addresses
func validateUnrestrictedPoolCreatorWhitelist(i interface{}) error {
whitelist, ok := i.([]string)

if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}

for _, a := range whitelist {
if _, err := sdk.AccAddressFromBech32(a); err != nil {
return fmt.Errorf("invalid address")
}
}

return nil
}
24 changes: 7 additions & 17 deletions x/incentives/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/osmoutils"
epochtypes "github.com/osmosis-labs/osmosis/x/epochs/types"

paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
Expand Down Expand Up @@ -52,6 +53,11 @@ func (p Params) Validate() error {
if err := ValidateGroupCreaionFee(p.GroupCreationFee); err != nil {
return err
}

if err := osmoutils.ValidateAddressList(p.UnrestrictedCreatorWhitelist); err != nil {
return err
}

return nil
}

Expand All @@ -63,22 +69,6 @@ func ValidateGroupCreaionFee(i interface{}) error {
return v.Validate()
}

func ValidateCreatorWhitelist(i interface{}) error {
v, ok := i.([]string)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}

// Validate that addresses are set correctly
for _, creator := range v {
if _, err := sdk.AccAddressFromBech32(creator); err != nil {
return err
}
}

return nil
}

func ValidateGroupCreationFee(i interface{}) error {
v, ok := i.(sdk.Coins)
if !ok {
Expand All @@ -92,6 +82,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyDistrEpochIdentifier, &p.DistrEpochIdentifier, epochtypes.ValidateEpochIdentifierInterface),
paramtypes.NewParamSetPair(KeyGroupCreationFee, &p.GroupCreationFee, ValidateGroupCreaionFee),
paramtypes.NewParamSetPair(KeyCreatorWhitelist, &p.UnrestrictedCreatorWhitelist, ValidateCreatorWhitelist),
paramtypes.NewParamSetPair(KeyCreatorWhitelist, &p.UnrestrictedCreatorWhitelist, osmoutils.ValidateAddressList),
}
}
4 changes: 4 additions & 0 deletions x/poolmanager/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ func (k Keeper) CalcTakerFeeExactOut(tokenOut sdk.Coin, takerFee osmomath.Dec) (
func (k Keeper) TrackVolume(ctx sdk.Context, poolId uint64, volumeGenerated sdk.Coin) {
k.trackVolume(ctx, poolId, volumeGenerated)
}

func (k Keeper) ChargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) {
return k.chargeTakerFee(ctx, tokenIn, tokenOutDenom, sender, exactIn)
}
7 changes: 7 additions & 0 deletions x/poolmanager/taker_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,19 @@ func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (

// chargeTakerFee extracts the taker fee from the given tokenIn and sends it to the appropriate
// module account. It returns the tokenIn after the taker fee has been extracted.
// If the sender is in the taker fee reduced whitelisted, it returns the tokenIn without extracting the taker fee.
// In the future, we might charge a lower taker fee as opposed to no fee at all.
func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) {
feeCollectorForStakingRewardsName := txfeestypes.FeeCollectorForStakingRewardsName
feeCollectorForCommunityPoolName := txfeestypes.FeeCollectorForCommunityPoolName
defaultTakerFeeDenom := appparams.BaseCoinUnit
poolManagerParams := k.GetParams(ctx)

// Determine if eligible to bypass taker fee.
if osmoutils.Contains(poolManagerParams.TakerFeeParams.ReducedFeeWhitelist, sender.String()) {
return tokenIn, nil
}

takerFee, err := k.GetTradingPairTakerFee(ctx, tokenIn.Denom, tokenOutDenom)
if err != nil {
return sdk.Coin{}, err
Expand Down
105 changes: 105 additions & 0 deletions x/poolmanager/taker_fee_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package poolmanager_test

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/v19/app/apptesting"
)

// validates that the pool manager keeper can charge taker fees correctly.
// If the sender is whitelisted, then the taker fee is not charged.
// Otherwise, the taker fee is charged.
func (s *KeeperTestSuite) TestChargeTakerFee() {

const (
whitelistedSenderIndex = iota
nonWhitelistedSenderIndex
)

var (
defaultTakerFee = osmomath.MustNewDecFromStr("0.01")
defaultAmount = sdk.NewInt(100)
)

tests := map[string]struct {
shouldSetSenderWhitelist bool
tokenIn sdk.Coin
tokenOutDenom string
senderIndex int
exactIn bool
takerFee osmomath.Dec

expectedResult sdk.Coin
expectError error
}{
"fee charged on token in": {
takerFee: defaultTakerFee,
tokenIn: sdk.NewCoin(apptesting.ETH, defaultAmount),
tokenOutDenom: apptesting.USDC,
senderIndex: whitelistedSenderIndex,
exactIn: true,

expectedResult: sdk.NewCoin(apptesting.ETH, defaultAmount.ToLegacyDec().Mul(osmomath.OneDec().Sub(defaultTakerFee)).TruncateInt()),
},
"fee charged on token in due to different address being whitelisted": {
takerFee: defaultTakerFee,
tokenIn: sdk.NewCoin(apptesting.ETH, defaultAmount),
tokenOutDenom: apptesting.USDC,
senderIndex: nonWhitelistedSenderIndex,
exactIn: true,
shouldSetSenderWhitelist: true,

expectedResult: sdk.NewCoin(apptesting.ETH, defaultAmount.ToLegacyDec().Mul(osmomath.OneDec().Sub(defaultTakerFee)).TruncateInt()),
},
"fee bypassed due to sender being whitelisted": {
takerFee: defaultTakerFee,
tokenIn: sdk.NewCoin(apptesting.ETH, defaultAmount),
tokenOutDenom: apptesting.USDC,
senderIndex: whitelistedSenderIndex,
exactIn: true,
shouldSetSenderWhitelist: true,

expectedResult: sdk.NewCoin(apptesting.ETH, defaultAmount),
},
// TODO: under more test cases
// https://github.com/osmosis-labs/osmosis/issues/6633
// - exactOut: false
// - sender does not have enough coins
}

for name, tc := range tests {
s.Run(name, func() {
s.SetupTest()
poolManager := s.App.PoolManagerKeeper

// Set whitelist.
if tc.shouldSetSenderWhitelist {
poolManagerParams := poolManager.GetParams(s.Ctx)
poolManagerParams.TakerFeeParams.ReducedFeeWhitelist = []string{s.TestAccs[whitelistedSenderIndex].String()}
poolManager.SetParams(s.Ctx, poolManagerParams)
}

// Create pool.
s.PrepareConcentratedPool()

// Set taker fee.
poolManager.SetDenomPairTakerFee(s.Ctx, tc.tokenIn.Denom, tc.tokenOutDenom, tc.takerFee)

// Pre-fund owner.
s.FundAcc(s.TestAccs[tc.senderIndex], sdk.NewCoins(tc.tokenIn))

// System under test.
tokenInAfterTakerFee, err := poolManager.ChargeTakerFee(s.Ctx, tc.tokenIn, tc.tokenOutDenom, s.TestAccs[tc.senderIndex], tc.exactIn)

if tc.expectError != nil {
s.Require().Error(err)
return
}
s.Require().NoError(err)

// Validate results.
s.Require().Equal(tc.expectedResult.String(), tokenInAfterTakerFee.String())
})
}
}
Loading