Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
affanv14 committed Sep 23, 2024
1 parent 11f651d commit 6111a9e
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 31 deletions.
3 changes: 0 additions & 3 deletions protocol/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,9 +982,6 @@ func New(
*app.FeeTiersKeeper,
)
revShareModule := revsharemodule.NewAppModule(appCodec, app.RevShareKeeper)

// Set the revshare keeper in the affiliates keeper.
app.AffiliatesKeeper.SetRevShareKeeper(app.RevShareKeeper)
app.FeeTiersKeeper.SetRevShareKeeper(app.RevShareKeeper)

app.PricesKeeper = *pricesmodulekeeper.NewKeeper(
Expand Down
8 changes: 4 additions & 4 deletions protocol/testing/e2e/gov/feetiers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ func TestUpdateFeeTiersModuleParams(t *testing.T) {
Tiers: []*feetierstypes.PerpetualFeeTier{
{
Name: "test_tier_0",
MakerFeePpm: 1_000,
TakerFeePpm: 2_000,
MakerFeePpm: 11_000,
TakerFeePpm: 22_000,
},
{
Name: "test_tier_1",
AbsoluteVolumeRequirement: 200_000,
TotalVolumeShareRequirementPpm: 100_000,
MakerVolumeShareRequirementPpm: 50_000,
MakerFeePpm: 11_000,
TakerFeePpm: 22_000,
MakerFeePpm: 1_000,
TakerFeePpm: 2_000,
},
},
}
Expand Down
1 change: 0 additions & 1 deletion protocol/testutil/keeper/clob.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func NewClobKeepersTestContextWithUninitializedMemStore(
)
revShareKeeper, _, _ := createRevShareKeeper(stateStore, db, cdc, ks.AffiliatesKeeper, ks.FeeTiersKeeper)
ks.FeeTiersKeeper.SetRevShareKeeper(revShareKeeper)
ks.AffiliatesKeeper.SetRevShareKeeper(revShareKeeper)
ks.AffiliatesKeeper.SetFeetiersKeeper(ks.FeeTiersKeeper)
ks.MarketMapKeeper, _ = createMarketMapKeeper(stateStore, db, cdc)
ks.PricesKeeper, _, _, mockTimeProvider = createPricesKeeper(
Expand Down
1 change: 0 additions & 1 deletion protocol/testutil/keeper/subaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func SubaccountsKeepers(t testing.TB, msgSenderEnabled bool) (
vaultKeeper, _ := createVaultKeeper(stateStore, db, cdc, transientStoreKey)
feetiersKeeper, _ := createFeeTiersKeeper(stateStore, statsKeeper, vaultKeeper, affiliatesKeeper, db, cdc)
revShareKeeper, _, _ = createRevShareKeeper(stateStore, db, cdc, affiliatesKeeper, feetiersKeeper)
affiliatesKeeper.SetRevShareKeeper(revShareKeeper)
marketMapKeeper, _ := createMarketMapKeeper(stateStore, db, cdc)
pricesKeeper, _, _, mockTimeProvider = createPricesKeeper(
stateStore,
Expand Down
5 changes: 0 additions & 5 deletions protocol/x/affiliates/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type (
storeKey storetypes.StoreKey
authorities map[string]struct{}
statsKeeper types.StatsKeeper
revShareKeeper types.RevShareKeeper
feetiersKeeper types.FeetiersKeeper
indexerEventManager indexer_manager.IndexerEventManager
}
Expand Down Expand Up @@ -279,10 +278,6 @@ func (k Keeper) UpdateAffiliateTiers(ctx sdk.Context, affiliateTiers types.Affil
return nil
}

func (k *Keeper) SetRevShareKeeper(revShareKeeper types.RevShareKeeper) {
k.revShareKeeper = revShareKeeper
}

func (k *Keeper) SetFeetiersKeeper(feetiersKeeper types.FeetiersKeeper) {
k.feetiersKeeper = feetiersKeeper
}
Expand Down
15 changes: 0 additions & 15 deletions protocol/x/affiliates/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"math/big"

sdk "github.com/cosmos/cosmos-sdk/types"
revsharetypes "github.com/dydxprotocol/v4-chain/protocol/x/revshare/types"
stattypes "github.com/dydxprotocol/v4-chain/protocol/x/stats/types"
)

Expand All @@ -13,20 +12,6 @@ type StatsKeeper interface {
GetBlockStats(ctx sdk.Context) *stattypes.BlockStats
}

type RevShareKeeper interface {
GetUnconditionalRevShareConfigParams(ctx sdk.Context) (revsharetypes.UnconditionalRevShareConfig, error)
GetMarketMapperRevenueShareParams(
ctx sdk.Context,
) revsharetypes.MarketMapperRevenueShareParams
ValidateRevShareSafety(
ctx sdk.Context,
unconditionalRevShareConfig revsharetypes.UnconditionalRevShareConfig,
marketMapperRevShareParams revsharetypes.MarketMapperRevenueShareParams,
lowestTakerFee int32,
lowestMakerFee int32,
) bool
}

type FeetiersKeeper interface {
GetAffiliateRefereeLowestTakerFee(ctx sdk.Context) int32
GetLowestMakerFee(ctx sdk.Context) int32
Expand Down
1 change: 1 addition & 0 deletions protocol/x/feetiers/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func GetAffiliateRefereeLowestTakerFeeFromTiers(tiers []*types.PerpetualFeeTier)
break
}
}

if uint32(len(tiers)) > types.RefereeStartingFeeTier {
return min(takerFeePpm, tiers[types.RefereeStartingFeeTier].TakerFeePpm)
}
Expand Down
4 changes: 2 additions & 2 deletions protocol/x/revshare/keeper/revshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (k Keeper) SetUnconditionalRevShareConfigParams(ctx sdk.Context, config typ

// Check two conditions to ensure rev shares are safe.
// 1. totalUnconditionalRevSharePpm + totalMarketMapperRevSharePpm < 100%
// 2. highestAffilliateTierRevSharePpm/lib.OneMillion - lowest_taker_fee/lowest_maker_fee < 1
// 2. Highest_affiliate_rev_share[protocol constant of 50%] * lowest_taker_fee - lowest_maker_fee < lowest_taker_fee
func (k Keeper) ValidateRevShareSafety(
ctx sdk.Context,
unconditionalRevShareConfig types.UnconditionalRevShareConfig,
Expand All @@ -147,7 +147,7 @@ func (k Keeper) ValidateRevShareSafety(
}

// taker fee can never be 0. Adding a check to ensure lowest_taker_fee is not 0
if lowestTakerFeePpm == 0 || int32(highestAffilliateTierRevSharePpm)*
if int32(highestAffilliateTierRevSharePpm)*
lowestTakerFeePpm-lowestMakerFeePpm*int32(lib.OneMillion) > int32(lib.OneMillion)*lowestTakerFeePpm {
return false
}
Expand Down

0 comments on commit 6111a9e

Please sign in to comment.