Skip to content

Commit cf47e38

Browse files
jusbar23mergify[bot]
authored andcommitted
Integrate commission and overrides to fee tier calculation (#3117)
(cherry picked from commit 1b53602) # Conflicts: # indexer/packages/v4-protos/src/codegen/dydxprotocol/affiliates/affiliates.ts # indexer/packages/v4-protos/src/codegen/dydxprotocol/stats/stats.ts # proto/dydxprotocol/affiliates/affiliates.proto # proto/dydxprotocol/stats/stats.proto # protocol/scripts/affiliates/update_affiliate_parameters.py # protocol/scripts/genesis/sample_pregenesis.json # protocol/testing/testnet/genesis.json # protocol/x/affiliates/keeper/grpc_query_test.go # protocol/x/affiliates/keeper/keeper.go # protocol/x/affiliates/keeper/keeper_test.go # protocol/x/affiliates/types/affiliates.pb.go # protocol/x/affiliates/types/constants.go # protocol/x/affiliates/types/expected_keepers.go # protocol/x/affiliates/types/keys.go # protocol/x/affiliates/types/query.pb.go # protocol/x/revshare/keeper/revshare.go # protocol/x/revshare/keeper/revshare_test.go # protocol/x/stats/keeper/keeper.go # protocol/x/stats/types/stats.pb.go
1 parent bf7418c commit cf47e38

Some content is hidden

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

49 files changed

+2131
-96
lines changed

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

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,63 @@ export interface AffiliateWhitelist_TierSDKType {
7474

7575
taker_fee_share_ppm: number;
7676
}
77+
<<<<<<< HEAD
78+
=======
79+
/** AffiliateParameters defines the parameters for the affiliate program. */
80+
81+
export interface AffiliateParameters {
82+
/**
83+
* Maximum attributable volume for a referred user in a 30d rolling window in
84+
* notional
85+
*/
86+
maximum_30dAttributableVolumePerReferredUserQuoteQuantums: Long;
87+
/** Referred user automatically gets set to this fee tier */
88+
89+
refereeMinimumFeeTierIdx: number;
90+
/**
91+
* Maximum affiliate revenue for a referred user in a 30d rolling window in
92+
* quote quantums
93+
*/
94+
95+
maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums: Long;
96+
}
97+
/** AffiliateParameters defines the parameters for the affiliate program. */
98+
99+
export interface AffiliateParametersSDKType {
100+
/**
101+
* Maximum attributable volume for a referred user in a 30d rolling window in
102+
* notional
103+
*/
104+
maximum_30d_attributable_volume_per_referred_user_quote_quantums: Long;
105+
/** Referred user automatically gets set to this fee tier */
106+
107+
referee_minimum_fee_tier_idx: number;
108+
/**
109+
* Maximum affiliate revenue for a referred user in a 30d rolling window in
110+
* quote quantums
111+
*/
112+
113+
maximum_30d_affiliate_revenue_per_referred_user_quote_quantums: Long;
114+
}
115+
/** AffiliateOverrides defines the affiliate whitelist. */
116+
117+
export interface AffiliateOverrides {
118+
/**
119+
* List of unique whitelisted addresses.
120+
* These are automatically put at the maximum affiliate tier
121+
*/
122+
addresses: string[];
123+
}
124+
/** AffiliateOverrides defines the affiliate whitelist. */
125+
126+
export interface AffiliateOverridesSDKType {
127+
/**
128+
* List of unique whitelisted addresses.
129+
* These are automatically put at the maximum affiliate tier
130+
*/
131+
addresses: string[];
132+
}
133+
>>>>>>> 1b536022 (Integrate commission and overrides to fee tier calculation (#3117))
77134

78135
function createBaseAffiliateTiers(): AffiliateTiers {
79136
return {
@@ -283,4 +340,117 @@ export const AffiliateWhitelist_Tier = {
283340
return message;
284341
}
285342

343+
<<<<<<< HEAD
344+
=======
345+
};
346+
347+
function createBaseAffiliateParameters(): AffiliateParameters {
348+
return {
349+
maximum_30dAttributableVolumePerReferredUserQuoteQuantums: Long.UZERO,
350+
refereeMinimumFeeTierIdx: 0,
351+
maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums: Long.UZERO
352+
};
353+
}
354+
355+
export const AffiliateParameters = {
356+
encode(message: AffiliateParameters, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
357+
if (!message.maximum_30dAttributableVolumePerReferredUserQuoteQuantums.isZero()) {
358+
writer.uint32(8).uint64(message.maximum_30dAttributableVolumePerReferredUserQuoteQuantums);
359+
}
360+
361+
if (message.refereeMinimumFeeTierIdx !== 0) {
362+
writer.uint32(16).uint32(message.refereeMinimumFeeTierIdx);
363+
}
364+
365+
if (!message.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums.isZero()) {
366+
writer.uint32(24).uint64(message.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums);
367+
}
368+
369+
return writer;
370+
},
371+
372+
decode(input: _m0.Reader | Uint8Array, length?: number): AffiliateParameters {
373+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
374+
let end = length === undefined ? reader.len : reader.pos + length;
375+
const message = createBaseAffiliateParameters();
376+
377+
while (reader.pos < end) {
378+
const tag = reader.uint32();
379+
380+
switch (tag >>> 3) {
381+
case 1:
382+
message.maximum_30dAttributableVolumePerReferredUserQuoteQuantums = (reader.uint64() as Long);
383+
break;
384+
385+
case 2:
386+
message.refereeMinimumFeeTierIdx = reader.uint32();
387+
break;
388+
389+
case 3:
390+
message.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums = (reader.uint64() as Long);
391+
break;
392+
393+
default:
394+
reader.skipType(tag & 7);
395+
break;
396+
}
397+
}
398+
399+
return message;
400+
},
401+
402+
fromPartial(object: DeepPartial<AffiliateParameters>): AffiliateParameters {
403+
const message = createBaseAffiliateParameters();
404+
message.maximum_30dAttributableVolumePerReferredUserQuoteQuantums = object.maximum_30dAttributableVolumePerReferredUserQuoteQuantums !== undefined && object.maximum_30dAttributableVolumePerReferredUserQuoteQuantums !== null ? Long.fromValue(object.maximum_30dAttributableVolumePerReferredUserQuoteQuantums) : Long.UZERO;
405+
message.refereeMinimumFeeTierIdx = object.refereeMinimumFeeTierIdx ?? 0;
406+
message.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums = object.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums !== undefined && object.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums !== null ? Long.fromValue(object.maximum_30dAffiliateRevenuePerReferredUserQuoteQuantums) : Long.UZERO;
407+
return message;
408+
}
409+
410+
};
411+
412+
function createBaseAffiliateOverrides(): AffiliateOverrides {
413+
return {
414+
addresses: []
415+
};
416+
}
417+
418+
export const AffiliateOverrides = {
419+
encode(message: AffiliateOverrides, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
420+
for (const v of message.addresses) {
421+
writer.uint32(10).string(v!);
422+
}
423+
424+
return writer;
425+
},
426+
427+
decode(input: _m0.Reader | Uint8Array, length?: number): AffiliateOverrides {
428+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
429+
let end = length === undefined ? reader.len : reader.pos + length;
430+
const message = createBaseAffiliateOverrides();
431+
432+
while (reader.pos < end) {
433+
const tag = reader.uint32();
434+
435+
switch (tag >>> 3) {
436+
case 1:
437+
message.addresses.push(reader.string());
438+
break;
439+
440+
default:
441+
reader.skipType(tag & 7);
442+
break;
443+
}
444+
}
445+
446+
return message;
447+
},
448+
449+
fromPartial(object: DeepPartial<AffiliateOverrides>): AffiliateOverrides {
450+
const message = createBaseAffiliateOverrides();
451+
message.addresses = object.addresses?.map(e => e) || [];
452+
return message;
453+
}
454+
455+
>>>>>>> 1b536022 (Integrate commission and overrides to fee tier calculation (#3117))
286456
};

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
1-
import { AffiliateTiers, AffiliateTiersSDKType } from "./affiliates";
1+
import { AffiliateTiers, AffiliateTiersSDKType, AffiliateParameters, AffiliateParametersSDKType } 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;
912
}
1013
/** GenesisState defines generis state of `x/affiliates` */
1114

1215
export interface GenesisStateSDKType {
1316
/** The list of affiliate tiers */
1417
affiliate_tiers?: AffiliateTiersSDKType;
18+
/** The affiliate parameters */
19+
20+
affiliate_parameters?: AffiliateParametersSDKType;
1521
}
1622

1723
function createBaseGenesisState(): GenesisState {
1824
return {
19-
affiliateTiers: undefined
25+
affiliateTiers: undefined,
26+
affiliateParameters: undefined
2027
};
2128
}
2229

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

36+
if (message.affiliateParameters !== undefined) {
37+
AffiliateParameters.encode(message.affiliateParameters, writer.uint32(18).fork()).ldelim();
38+
}
39+
2940
return writer;
3041
},
3142

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

56+
case 2:
57+
message.affiliateParameters = AffiliateParameters.decode(reader, reader.uint32());
58+
break;
59+
4560
default:
4661
reader.skipType(tag & 7);
4762
break;
@@ -54,6 +69,7 @@ export const GenesisState = {
5469
fromPartial(object: DeepPartial<GenesisState>): GenesisState {
5570
const message = createBaseGenesisState();
5671
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;
5773
return message;
5874
}
5975

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

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

42+
/** @deprecated */
43+
4244
referredVolume: Uint8Array;
4345
/** The affiliate's currently staked native tokens (in whole coins). */
4446

4547
stakedAmount: Uint8Array;
48+
/** The affiliate's 30d referred volume in quote quantums. */
49+
50+
referredVolume_30dRolling: Uint8Array;
4651
}
4752
/**
4853
* AffiliateInfoResponse is the response type for the Query/AffiliateInfo RPC
@@ -66,10 +71,15 @@ export interface AffiliateInfoResponseSDKType {
6671
fee_share_ppm: number;
6772
/** The affiliate's all-time referred volume in quote quantums. */
6873

74+
/** @deprecated */
75+
6976
referred_volume: Uint8Array;
7077
/** The affiliate's currently staked native tokens (in whole coins). */
7178

7279
staked_amount: Uint8Array;
80+
/** The affiliate's 30d referred volume in quote quantums. */
81+
82+
referred_volume_30d_rolling: Uint8Array;
7383
}
7484
/** ReferredByRequest is the request type for the Query/ReferredBy RPC method. */
7585

@@ -205,7 +215,8 @@ function createBaseAffiliateInfoResponse(): AffiliateInfoResponse {
205215
tier: 0,
206216
feeSharePpm: 0,
207217
referredVolume: new Uint8Array(),
208-
stakedAmount: new Uint8Array()
218+
stakedAmount: new Uint8Array(),
219+
referredVolume_30dRolling: new Uint8Array()
209220
};
210221
}
211222

@@ -231,6 +242,10 @@ export const AffiliateInfoResponse = {
231242
writer.uint32(42).bytes(message.stakedAmount);
232243
}
233244

245+
if (message.referredVolume_30dRolling.length !== 0) {
246+
writer.uint32(50).bytes(message.referredVolume_30dRolling);
247+
}
248+
234249
return writer;
235250
},
236251

@@ -263,6 +278,10 @@ export const AffiliateInfoResponse = {
263278
message.stakedAmount = reader.bytes();
264279
break;
265280

281+
case 6:
282+
message.referredVolume_30dRolling = reader.bytes();
283+
break;
284+
266285
default:
267286
reader.skipType(tag & 7);
268287
break;
@@ -279,6 +298,7 @@ export const AffiliateInfoResponse = {
279298
message.feeSharePpm = object.feeSharePpm ?? 0;
280299
message.referredVolume = object.referredVolume ?? new Uint8Array();
281300
message.stakedAmount = object.stakedAmount ?? new Uint8Array();
301+
message.referredVolume_30dRolling = object.referredVolume_30dRolling ?? new Uint8Array();
282302
return message;
283303
}
284304

0 commit comments

Comments
 (0)