Skip to content

Commit 1f06d1b

Browse files
committed
Revert "Integrate commission and overrides to fee tier calculation (Backport) (#3117) (backport #3191) (#3193)"
This reverts commit 6fdcb2e.
1 parent a6ffba0 commit 1f06d1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+653
-892
lines changed

indexer/packages/v4-protos/src/codegen/dydxprotocol/affiliates/affiliates.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ export interface AffiliateParameters {
8181
* Maximum attributable volume for a referred user in a 30d rolling window in
8282
* notional
8383
*/
84-
maximum_30dAttributableVolumePerReferredUserQuoteQuantums: Long;
84+
maximum_30dAttributableVolumePerReferredUserNotional: Long;
8585
/** Referred user automatically gets set to this fee tier */
8686

8787
refereeMinimumFeeTierIdx: number;
8888
/**
89-
* Maximum affiliate revenue for a referred user in a 30d rolling window in
89+
* Maximum attributable revenue for a referred user in a 30d rolling window in
9090
* quote quantums
9191
*/
9292

93-
maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums: Long;
93+
maximum_30dAttributableRevenuePerReferredUserQuoteQuantums: Long;
9494
}
9595
/** AffiliateParameters defines the parameters for the affiliate program. */
9696

@@ -99,16 +99,16 @@ export interface AffiliateParametersSDKType {
9999
* Maximum attributable volume for a referred user in a 30d rolling window in
100100
* notional
101101
*/
102-
maximum_30d_attributable_volume_per_referred_user_quote_quantums: Long;
102+
maximum_30d_attributable_volume_per_referred_user_notional: Long;
103103
/** Referred user automatically gets set to this fee tier */
104104

105105
referee_minimum_fee_tier_idx: number;
106106
/**
107-
* Maximum affiliate revenue for a referred user in a 30d rolling window in
107+
* Maximum attributable revenue for a referred user in a 30d rolling window in
108108
* quote quantums
109109
*/
110110

111-
maximum_30d_affiliate_revenue_per_referred_user_quote_quantums: Long;
111+
maximum_30d_attributable_revenue_per_referred_user_quote_quantums: Long;
112112
}
113113
/** AffiliateOverrides defines the affiliate whitelist. */
114114

@@ -341,24 +341,24 @@ export const AffiliateWhitelist_Tier = {
341341

342342
function createBaseAffiliateParameters(): AffiliateParameters {
343343
return {
344-
maximum_30dAttributableVolumePerReferredUserQuoteQuantums: Long.UZERO,
344+
maximum_30dAttributableVolumePerReferredUserNotional: Long.UZERO,
345345
refereeMinimumFeeTierIdx: 0,
346-
maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums: Long.UZERO
346+
maximum_30dAttributableRevenuePerReferredUserQuoteQuantums: Long.UZERO
347347
};
348348
}
349349

350350
export const AffiliateParameters = {
351351
encode(message: AffiliateParameters, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
352-
if (!message.maximum_30dAttributableVolumePerReferredUserQuoteQuantums.isZero()) {
353-
writer.uint32(8).uint64(message.maximum_30dAttributableVolumePerReferredUserQuoteQuantums);
352+
if (!message.maximum_30dAttributableVolumePerReferredUserNotional.isZero()) {
353+
writer.uint32(8).uint64(message.maximum_30dAttributableVolumePerReferredUserNotional);
354354
}
355355

356356
if (message.refereeMinimumFeeTierIdx !== 0) {
357357
writer.uint32(16).uint32(message.refereeMinimumFeeTierIdx);
358358
}
359359

360-
if (!message.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums.isZero()) {
361-
writer.uint32(24).uint64(message.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums);
360+
if (!message.maximum_30dAttributableRevenuePerReferredUserQuoteQuantums.isZero()) {
361+
writer.uint32(24).uint64(message.maximum_30dAttributableRevenuePerReferredUserQuoteQuantums);
362362
}
363363

364364
return writer;
@@ -374,15 +374,15 @@ export const AffiliateParameters = {
374374

375375
switch (tag >>> 3) {
376376
case 1:
377-
message.maximum_30dAttributableVolumePerReferredUserQuoteQuantums = (reader.uint64() as Long);
377+
message.maximum_30dAttributableVolumePerReferredUserNotional = (reader.uint64() as Long);
378378
break;
379379

380380
case 2:
381381
message.refereeMinimumFeeTierIdx = reader.uint32();
382382
break;
383383

384384
case 3:
385-
message.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums = (reader.uint64() as Long);
385+
message.maximum_30dAttributableRevenuePerReferredUserQuoteQuantums = (reader.uint64() as Long);
386386
break;
387387

388388
default:
@@ -396,9 +396,9 @@ export const AffiliateParameters = {
396396

397397
fromPartial(object: DeepPartial<AffiliateParameters>): AffiliateParameters {
398398
const message = createBaseAffiliateParameters();
399-
message.maximum_30dAttributableVolumePerReferredUserQuoteQuantums = object.maximum_30dAttributableVolumePerReferredUserQuoteQuantums !== undefined && object.maximum_30dAttributableVolumePerReferredUserQuoteQuantums !== null ? Long.fromValue(object.maximum_30dAttributableVolumePerReferredUserQuoteQuantums) : Long.UZERO;
399+
message.maximum_30dAttributableVolumePerReferredUserNotional = object.maximum_30dAttributableVolumePerReferredUserNotional !== undefined && object.maximum_30dAttributableVolumePerReferredUserNotional !== null ? Long.fromValue(object.maximum_30dAttributableVolumePerReferredUserNotional) : Long.UZERO;
400400
message.refereeMinimumFeeTierIdx = object.refereeMinimumFeeTierIdx ?? 0;
401-
message.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums = object.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums !== undefined && object.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums !== null ? Long.fromValue(object.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums) : Long.UZERO;
401+
message.maximum_30dAttributableRevenuePerReferredUserQuoteQuantums = object.maximum_30dAttributableRevenuePerReferredUserQuoteQuantums !== undefined && object.maximum_30dAttributableRevenuePerReferredUserQuoteQuantums !== null ? Long.fromValue(object.maximum_30dAttributableRevenuePerReferredUserQuoteQuantums) : Long.UZERO;
402402
return message;
403403
}
404404

indexer/packages/v4-protos/src/codegen/dydxprotocol/affiliates/genesis.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1-
import { AffiliateTiers, AffiliateTiersSDKType, AffiliateParameters, AffiliateParametersSDKType } from "./affiliates";
1+
import { AffiliateTiers, AffiliateTiersSDKType } from "./affiliates";
22
import * as _m0 from "protobufjs/minimal";
33
import { DeepPartial } from "../../helpers";
44
/** GenesisState defines generis state of `x/affiliates` */
55

66
export interface GenesisState {
77
/** The list of affiliate tiers */
88
affiliateTiers?: AffiliateTiers;
9-
/** The affiliate parameters */
10-
11-
affiliateParameters?: AffiliateParameters;
129
}
1310
/** GenesisState defines generis state of `x/affiliates` */
1411

1512
export interface GenesisStateSDKType {
1613
/** The list of affiliate tiers */
1714
affiliate_tiers?: AffiliateTiersSDKType;
18-
/** The affiliate parameters */
19-
20-
affiliate_parameters?: AffiliateParametersSDKType;
2115
}
2216

2317
function createBaseGenesisState(): GenesisState {
2418
return {
25-
affiliateTiers: undefined,
26-
affiliateParameters: undefined
19+
affiliateTiers: undefined
2720
};
2821
}
2922

@@ -33,10 +26,6 @@ export const GenesisState = {
3326
AffiliateTiers.encode(message.affiliateTiers, writer.uint32(10).fork()).ldelim();
3427
}
3528

36-
if (message.affiliateParameters !== undefined) {
37-
AffiliateParameters.encode(message.affiliateParameters, writer.uint32(18).fork()).ldelim();
38-
}
39-
4029
return writer;
4130
},
4231

@@ -53,10 +42,6 @@ export const GenesisState = {
5342
message.affiliateTiers = AffiliateTiers.decode(reader, reader.uint32());
5443
break;
5544

56-
case 2:
57-
message.affiliateParameters = AffiliateParameters.decode(reader, reader.uint32());
58-
break;
59-
6045
default:
6146
reader.skipType(tag & 7);
6247
break;
@@ -69,7 +54,6 @@ export const GenesisState = {
6954
fromPartial(object: DeepPartial<GenesisState>): GenesisState {
7055
const message = createBaseGenesisState();
7156
message.affiliateTiers = object.affiliateTiers !== undefined && object.affiliateTiers !== null ? AffiliateTiers.fromPartial(object.affiliateTiers) : undefined;
72-
message.affiliateParameters = object.affiliateParameters !== undefined && object.affiliateParameters !== null ? AffiliateParameters.fromPartial(object.affiliateParameters) : undefined;
7357
return message;
7458
}
7559

indexer/packages/v4-protos/src/codegen/dydxprotocol/affiliates/query.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,10 @@ export interface AffiliateInfoResponse {
3939
feeSharePpm: number;
4040
/** The affiliate's all-time referred volume in quote quantums. */
4141

42-
/** @deprecated */
43-
4442
referredVolume: Uint8Array;
4543
/** The affiliate's currently staked native tokens (in whole coins). */
4644

4745
stakedAmount: Uint8Array;
48-
/** The affiliate's 30d referred volume in quote quantums. */
49-
50-
referredVolume_30dRolling: Uint8Array;
5146
}
5247
/**
5348
* AffiliateInfoResponse is the response type for the Query/AffiliateInfo RPC
@@ -71,15 +66,10 @@ export interface AffiliateInfoResponseSDKType {
7166
fee_share_ppm: number;
7267
/** The affiliate's all-time referred volume in quote quantums. */
7368

74-
/** @deprecated */
75-
7669
referred_volume: Uint8Array;
7770
/** The affiliate's currently staked native tokens (in whole coins). */
7871

7972
staked_amount: Uint8Array;
80-
/** The affiliate's 30d referred volume in quote quantums. */
81-
82-
referred_volume_30d_rolling: Uint8Array;
8373
}
8474
/** ReferredByRequest is the request type for the Query/ReferredBy RPC method. */
8575

@@ -271,8 +261,7 @@ function createBaseAffiliateInfoResponse(): AffiliateInfoResponse {
271261
tier: 0,
272262
feeSharePpm: 0,
273263
referredVolume: new Uint8Array(),
274-
stakedAmount: new Uint8Array(),
275-
referredVolume_30dRolling: new Uint8Array()
264+
stakedAmount: new Uint8Array()
276265
};
277266
}
278267

@@ -298,10 +287,6 @@ export const AffiliateInfoResponse = {
298287
writer.uint32(42).bytes(message.stakedAmount);
299288
}
300289

301-
if (message.referredVolume_30dRolling.length !== 0) {
302-
writer.uint32(50).bytes(message.referredVolume_30dRolling);
303-
}
304-
305290
return writer;
306291
},
307292

@@ -334,10 +319,6 @@ export const AffiliateInfoResponse = {
334319
message.stakedAmount = reader.bytes();
335320
break;
336321

337-
case 6:
338-
message.referredVolume_30dRolling = reader.bytes();
339-
break;
340-
341322
default:
342323
reader.skipType(tag & 7);
343324
break;
@@ -354,7 +335,6 @@ export const AffiliateInfoResponse = {
354335
message.feeSharePpm = object.feeSharePpm ?? 0;
355336
message.referredVolume = object.referredVolume ?? new Uint8Array();
356337
message.stakedAmount = object.stakedAmount ?? new Uint8Array();
357-
message.referredVolume_30dRolling = object.referredVolume_30dRolling ?? new Uint8Array();
358338
return message;
359339
}
360340

indexer/packages/v4-protos/src/codegen/dydxprotocol/stats/stats.ts

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,9 @@ export interface UserStats {
128128
/** Maker USDC in quantums */
129129

130130
makerNotional: Long;
131-
/** Affiliate revenue generated in quantums with this user being a referee */
131+
/** Affiliate revenue generated in quantums */
132132

133-
affiliate_30dRevenueGeneratedQuantums: Long;
134-
/** Referred volume in quote quantums with this user being an affiliate */
135-
136-
affiliate_30dReferredVolumeQuoteQuantums: Long;
133+
affiliateRevenueGeneratedQuantums: Long;
137134
}
138135
/**
139136
* UserStats stores stats for a User. This is the sum of all stats for a user in
@@ -146,12 +143,9 @@ export interface UserStatsSDKType {
146143
/** Maker USDC in quantums */
147144

148145
maker_notional: Long;
149-
/** Affiliate revenue generated in quantums with this user being a referee */
150-
151-
affiliate_30d_revenue_generated_quantums: Long;
152-
/** Referred volume in quote quantums with this user being an affiliate */
146+
/** Affiliate revenue generated in quantums */
153147

154-
affiliate_30d_referred_volume_quote_quantums: Long;
148+
affiliate_revenue_generated_quantums: Long;
155149
}
156150
/** CachedStakeAmount stores the last calculated total staked amount for address */
157151

@@ -502,8 +496,7 @@ function createBaseUserStats(): UserStats {
502496
return {
503497
takerNotional: Long.UZERO,
504498
makerNotional: Long.UZERO,
505-
affiliate_30dRevenueGeneratedQuantums: Long.UZERO,
506-
affiliate_30dReferredVolumeQuoteQuantums: Long.UZERO
499+
affiliateRevenueGeneratedQuantums: Long.UZERO
507500
};
508501
}
509502

@@ -517,12 +510,8 @@ export const UserStats = {
517510
writer.uint32(16).uint64(message.makerNotional);
518511
}
519512

520-
if (!message.affiliate_30dRevenueGeneratedQuantums.isZero()) {
521-
writer.uint32(24).uint64(message.affiliate_30dRevenueGeneratedQuantums);
522-
}
523-
524-
if (!message.affiliate_30dReferredVolumeQuoteQuantums.isZero()) {
525-
writer.uint32(32).uint64(message.affiliate_30dReferredVolumeQuoteQuantums);
513+
if (!message.affiliateRevenueGeneratedQuantums.isZero()) {
514+
writer.uint32(24).uint64(message.affiliateRevenueGeneratedQuantums);
526515
}
527516

528517
return writer;
@@ -546,11 +535,7 @@ export const UserStats = {
546535
break;
547536

548537
case 3:
549-
message.affiliate_30dRevenueGeneratedQuantums = (reader.uint64() as Long);
550-
break;
551-
552-
case 4:
553-
message.affiliate_30dReferredVolumeQuoteQuantums = (reader.uint64() as Long);
538+
message.affiliateRevenueGeneratedQuantums = (reader.uint64() as Long);
554539
break;
555540

556541
default:
@@ -566,8 +551,7 @@ export const UserStats = {
566551
const message = createBaseUserStats();
567552
message.takerNotional = object.takerNotional !== undefined && object.takerNotional !== null ? Long.fromValue(object.takerNotional) : Long.UZERO;
568553
message.makerNotional = object.makerNotional !== undefined && object.makerNotional !== null ? Long.fromValue(object.makerNotional) : Long.UZERO;
569-
message.affiliate_30dRevenueGeneratedQuantums = object.affiliate_30dRevenueGeneratedQuantums !== undefined && object.affiliate_30dRevenueGeneratedQuantums !== null ? Long.fromValue(object.affiliate_30dRevenueGeneratedQuantums) : Long.UZERO;
570-
message.affiliate_30dReferredVolumeQuoteQuantums = object.affiliate_30dReferredVolumeQuoteQuantums !== undefined && object.affiliate_30dReferredVolumeQuoteQuantums !== null ? Long.fromValue(object.affiliate_30dReferredVolumeQuoteQuantums) : Long.UZERO;
554+
message.affiliateRevenueGeneratedQuantums = object.affiliateRevenueGeneratedQuantums !== undefined && object.affiliateRevenueGeneratedQuantums !== null ? Long.fromValue(object.affiliateRevenueGeneratedQuantums) : Long.UZERO;
571555
return message;
572556
}
573557

proto/dydxprotocol/affiliates/affiliates.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ message AffiliateWhitelist {
4040
message AffiliateParameters {
4141
// Maximum attributable volume for a referred user in a 30d rolling window in
4242
// notional
43-
uint64 maximum_30d_attributable_volume_per_referred_user_quote_quantums = 1;
43+
uint64 maximum_30d_attributable_volume_per_referred_user_notional = 1;
4444

4545
// Referred user automatically gets set to this fee tier
4646
uint32 referee_minimum_fee_tier_idx = 2;
4747

48-
// Maximum affiliate revenue for a referred user in a 30d rolling window in
48+
// Maximum attributable revenue for a referred user in a 30d rolling window in
4949
// quote quantums
50-
uint64 maximum_30d_affiliate_revenue_per_referred_user_quote_quantums = 3;
50+
uint64 maximum_30d_attributable_revenue_per_referred_user_quote_quantums = 3;
5151
}
5252

5353
// AffiliateOverrides defines the affiliate whitelist.

proto/dydxprotocol/affiliates/genesis.proto

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@ option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/type
99
message GenesisState {
1010
// The list of affiliate tiers
1111
AffiliateTiers affiliate_tiers = 1 [ (gogoproto.nullable) = false ];
12-
13-
// The affiliate parameters
14-
AffiliateParameters affiliate_parameters = 2 [ (gogoproto.nullable) = false ];
1512
}

proto/dydxprotocol/affiliates/query.proto

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,14 @@ message AffiliateInfoResponse {
6767
bytes referred_volume = 4 [
6868
(gogoproto.customtype) =
6969
"github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt",
70-
(gogoproto.nullable) = false,
71-
deprecated = true
70+
(gogoproto.nullable) = false
7271
];
7372
// The affiliate's currently staked native tokens (in whole coins).
7473
bytes staked_amount = 5 [
7574
(gogoproto.customtype) =
7675
"github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt",
7776
(gogoproto.nullable) = false
7877
];
79-
// The affiliate's 30d referred volume in quote quantums.
80-
bytes referred_volume_30d_rolling = 6 [
81-
(gogoproto.customtype) =
82-
"github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt",
83-
(gogoproto.nullable) = false
84-
];
8578
}
8679

8780
// ReferredByRequest is the request type for the Query/ReferredBy RPC method.

proto/dydxprotocol/stats/stats.proto

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,8 @@ message UserStats {
6868
// Maker USDC in quantums
6969
uint64 maker_notional = 2;
7070

71-
// Affiliate revenue generated in quantums with this user being a referee
72-
uint64 affiliate_30d_revenue_generated_quantums = 3;
73-
74-
// Referred volume in quote quantums with this user being an affiliate
75-
uint64 affiliate_30d_referred_volume_quote_quantums = 4;
71+
// Affiliate revenue generated in quantums
72+
uint64 affiliate_revenue_generated_quantums = 3;
7673
}
7774

7875
// CachedStakeAmount stores the last calculated total staked amount for address

protocol/app/app.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,9 @@ func New(
962962
)
963963
affiliatesModule := affiliatesmodule.NewAppModule(appCodec, app.AffiliatesKeeper)
964964

965+
// Register the affiliates keeper to be notified when stats expire
966+
app.StatsKeeper.AddStatsExpirationHook(&app.AffiliatesKeeper)
967+
965968
app.MarketMapKeeper = *marketmapmodulekeeper.NewKeeper(
966969
runtime.NewKVStoreService(keys[marketmapmoduletypes.StoreKey]),
967970
appCodec,
@@ -993,7 +996,6 @@ func New(
993996
},
994997
app.AffiliatesKeeper,
995998
*app.FeeTiersKeeper,
996-
app.StatsKeeper,
997999
)
9981000
revShareModule := revsharemodule.NewAppModule(appCodec, app.RevShareKeeper)
9991001
app.FeeTiersKeeper.SetRevShareKeeper(app.RevShareKeeper)

0 commit comments

Comments
 (0)