11import { Timestamp } from "../../google/protobuf/timestamp" ;
22import * as _m0 from "protobufjs/minimal" ;
3- import { DeepPartial , Long , toTimestamp , fromTimestamp } from "../../helpers" ;
3+ import { Long , DeepPartial , toTimestamp , fromTimestamp } from "../../helpers" ;
4+ /** Role indicates whether this attribution is for the taker or maker */
5+
6+ export enum AffiliateAttribution_Role {
7+ ROLE_UNSPECIFIED = 0 ,
8+ ROLE_TAKER = 1 ,
9+ ROLE_MAKER = 2 ,
10+ UNRECOGNIZED = - 1 ,
11+ }
12+ /** Role indicates whether this attribution is for the taker or maker */
13+
14+ export enum AffiliateAttribution_RoleSDKType {
15+ ROLE_UNSPECIFIED = 0 ,
16+ ROLE_TAKER = 1 ,
17+ ROLE_MAKER = 2 ,
18+ UNRECOGNIZED = - 1 ,
19+ }
20+ export function affiliateAttribution_RoleFromJSON ( object : any ) : AffiliateAttribution_Role {
21+ switch ( object ) {
22+ case 0 :
23+ case "ROLE_UNSPECIFIED" :
24+ return AffiliateAttribution_Role . ROLE_UNSPECIFIED ;
25+
26+ case 1 :
27+ case "ROLE_TAKER" :
28+ return AffiliateAttribution_Role . ROLE_TAKER ;
29+
30+ case 2 :
31+ case "ROLE_MAKER" :
32+ return AffiliateAttribution_Role . ROLE_MAKER ;
33+
34+ case - 1 :
35+ case "UNRECOGNIZED" :
36+ default :
37+ return AffiliateAttribution_Role . UNRECOGNIZED ;
38+ }
39+ }
40+ export function affiliateAttribution_RoleToJSON ( object : AffiliateAttribution_Role ) : string {
41+ switch ( object ) {
42+ case AffiliateAttribution_Role . ROLE_UNSPECIFIED :
43+ return "ROLE_UNSPECIFIED" ;
44+
45+ case AffiliateAttribution_Role . ROLE_TAKER :
46+ return "ROLE_TAKER" ;
47+
48+ case AffiliateAttribution_Role . ROLE_MAKER :
49+ return "ROLE_MAKER" ;
50+
51+ case AffiliateAttribution_Role . UNRECOGNIZED :
52+ default :
53+ return "UNRECOGNIZED" ;
54+ }
55+ }
56+ /** AffiliateAttribution represents the affiliate attribution for a fill. */
57+
58+ export interface AffiliateAttribution {
59+ /** Role of the trader (taker or maker) whose affiliate is being attributed */
60+ role : AffiliateAttribution_Role ;
61+ /** Referrer address (the affiliate receiving the fee) */
62+
63+ referrerAddress : string ;
64+ /** Referred volume in quote quantums (capped based on 30-day volume limits) */
65+
66+ referredVolumeQuoteQuantums : Long ;
67+ }
68+ /** AffiliateAttribution represents the affiliate attribution for a fill. */
69+
70+ export interface AffiliateAttributionSDKType {
71+ /** Role of the trader (taker or maker) whose affiliate is being attributed */
72+ role : AffiliateAttribution_RoleSDKType ;
73+ /** Referrer address (the affiliate receiving the fee) */
74+
75+ referrer_address : string ;
76+ /** Referred volume in quote quantums (capped based on 30-day volume limits) */
77+
78+ referred_volume_quote_quantums : Long ;
79+ }
480/** BlockStats is used to store stats transiently within the scope of a block. */
581
682export interface BlockStats {
@@ -34,6 +110,12 @@ export interface BlockStats_Fill {
34110 */
35111
36112 affiliateFeeGeneratedQuantums : Long ;
113+ /**
114+ * Affiliate revenue attributions for this fill (can include both taker and
115+ * maker)
116+ */
117+
118+ affiliateAttributions : AffiliateAttribution [ ] ;
37119}
38120/** Fill records data about a fill on this block. */
39121
@@ -56,6 +138,12 @@ export interface BlockStats_FillSDKType {
56138 */
57139
58140 affiliate_fee_generated_quantums : Long ;
141+ /**
142+ * Affiliate revenue attributions for this fill (can include both taker and
143+ * maker)
144+ */
145+
146+ affiliate_attributions : AffiliateAttributionSDKType [ ] ;
59147}
60148/** StatsMetadata stores metadata for the x/stats module */
61149
@@ -134,6 +222,12 @@ export interface UserStats {
134222 /** Referred volume in quote quantums with this user being an affiliate */
135223
136224 affiliate_30dReferredVolumeQuoteQuantums : Long ;
225+ /**
226+ * Attributed volume in quote quantums - volume from this user (as referee)
227+ * that has been attributed to their affiliate in the last 30 days
228+ */
229+
230+ affiliate_30dAttributedVolumeQuoteQuantums : Long ;
137231}
138232/**
139233 * UserStats stores stats for a User. This is the sum of all stats for a user in
@@ -152,6 +246,12 @@ export interface UserStatsSDKType {
152246 /** Referred volume in quote quantums with this user being an affiliate */
153247
154248 affiliate_30d_referred_volume_quote_quantums : Long ;
249+ /**
250+ * Attributed volume in quote quantums - volume from this user (as referee)
251+ * that has been attributed to their affiliate in the last 30 days
252+ */
253+
254+ affiliate_30d_attributed_volume_quote_quantums : Long ;
155255}
156256/** CachedStakedBaseTokens stores the last calculated total staked base tokens */
157257
@@ -178,6 +278,71 @@ export interface CachedStakedBaseTokensSDKType {
178278 cached_at : Long ;
179279}
180280
281+ function createBaseAffiliateAttribution ( ) : AffiliateAttribution {
282+ return {
283+ role : 0 ,
284+ referrerAddress : "" ,
285+ referredVolumeQuoteQuantums : Long . UZERO
286+ } ;
287+ }
288+
289+ export const AffiliateAttribution = {
290+ encode ( message : AffiliateAttribution , writer : _m0 . Writer = _m0 . Writer . create ( ) ) : _m0 . Writer {
291+ if ( message . role !== 0 ) {
292+ writer . uint32 ( 8 ) . int32 ( message . role ) ;
293+ }
294+
295+ if ( message . referrerAddress !== "" ) {
296+ writer . uint32 ( 18 ) . string ( message . referrerAddress ) ;
297+ }
298+
299+ if ( ! message . referredVolumeQuoteQuantums . isZero ( ) ) {
300+ writer . uint32 ( 24 ) . uint64 ( message . referredVolumeQuoteQuantums ) ;
301+ }
302+
303+ return writer ;
304+ } ,
305+
306+ decode ( input : _m0 . Reader | Uint8Array , length ?: number ) : AffiliateAttribution {
307+ const reader = input instanceof _m0 . Reader ? input : new _m0 . Reader ( input ) ;
308+ let end = length === undefined ? reader . len : reader . pos + length ;
309+ const message = createBaseAffiliateAttribution ( ) ;
310+
311+ while ( reader . pos < end ) {
312+ const tag = reader . uint32 ( ) ;
313+
314+ switch ( tag >>> 3 ) {
315+ case 1 :
316+ message . role = ( reader . int32 ( ) as any ) ;
317+ break ;
318+
319+ case 2 :
320+ message . referrerAddress = reader . string ( ) ;
321+ break ;
322+
323+ case 3 :
324+ message . referredVolumeQuoteQuantums = ( reader . uint64 ( ) as Long ) ;
325+ break ;
326+
327+ default :
328+ reader . skipType ( tag & 7 ) ;
329+ break ;
330+ }
331+ }
332+
333+ return message ;
334+ } ,
335+
336+ fromPartial ( object : DeepPartial < AffiliateAttribution > ) : AffiliateAttribution {
337+ const message = createBaseAffiliateAttribution ( ) ;
338+ message . role = object . role ?? 0 ;
339+ message . referrerAddress = object . referrerAddress ?? "" ;
340+ message . referredVolumeQuoteQuantums = object . referredVolumeQuoteQuantums !== undefined && object . referredVolumeQuoteQuantums !== null ? Long . fromValue ( object . referredVolumeQuoteQuantums ) : Long . UZERO ;
341+ return message ;
342+ }
343+
344+ } ;
345+
181346function createBaseBlockStats ( ) : BlockStats {
182347 return {
183348 fills : [ ]
@@ -228,7 +393,8 @@ function createBaseBlockStats_Fill(): BlockStats_Fill {
228393 taker : "" ,
229394 maker : "" ,
230395 notional : Long . UZERO ,
231- affiliateFeeGeneratedQuantums : Long . UZERO
396+ affiliateFeeGeneratedQuantums : Long . UZERO ,
397+ affiliateAttributions : [ ]
232398 } ;
233399}
234400
@@ -250,6 +416,10 @@ export const BlockStats_Fill = {
250416 writer . uint32 ( 32 ) . uint64 ( message . affiliateFeeGeneratedQuantums ) ;
251417 }
252418
419+ for ( const v of message . affiliateAttributions ) {
420+ AffiliateAttribution . encode ( v ! , writer . uint32 ( 42 ) . fork ( ) ) . ldelim ( ) ;
421+ }
422+
253423 return writer ;
254424 } ,
255425
@@ -278,6 +448,10 @@ export const BlockStats_Fill = {
278448 message . affiliateFeeGeneratedQuantums = ( reader . uint64 ( ) as Long ) ;
279449 break ;
280450
451+ case 5 :
452+ message . affiliateAttributions . push ( AffiliateAttribution . decode ( reader , reader . uint32 ( ) ) ) ;
453+ break ;
454+
281455 default :
282456 reader . skipType ( tag & 7 ) ;
283457 break ;
@@ -293,6 +467,7 @@ export const BlockStats_Fill = {
293467 message . maker = object . maker ?? "" ;
294468 message . notional = object . notional !== undefined && object . notional !== null ? Long . fromValue ( object . notional ) : Long . UZERO ;
295469 message . affiliateFeeGeneratedQuantums = object . affiliateFeeGeneratedQuantums !== undefined && object . affiliateFeeGeneratedQuantums !== null ? Long . fromValue ( object . affiliateFeeGeneratedQuantums ) : Long . UZERO ;
470+ message . affiliateAttributions = object . affiliateAttributions ?. map ( e => AffiliateAttribution . fromPartial ( e ) ) || [ ] ;
296471 return message ;
297472 }
298473
@@ -503,7 +678,8 @@ function createBaseUserStats(): UserStats {
503678 takerNotional : Long . UZERO ,
504679 makerNotional : Long . UZERO ,
505680 affiliate_30dRevenueGeneratedQuantums : Long . UZERO ,
506- affiliate_30dReferredVolumeQuoteQuantums : Long . UZERO
681+ affiliate_30dReferredVolumeQuoteQuantums : Long . UZERO ,
682+ affiliate_30dAttributedVolumeQuoteQuantums : Long . UZERO
507683 } ;
508684}
509685
@@ -525,6 +701,10 @@ export const UserStats = {
525701 writer . uint32 ( 32 ) . uint64 ( message . affiliate_30dReferredVolumeQuoteQuantums ) ;
526702 }
527703
704+ if ( ! message . affiliate_30dAttributedVolumeQuoteQuantums . isZero ( ) ) {
705+ writer . uint32 ( 40 ) . uint64 ( message . affiliate_30dAttributedVolumeQuoteQuantums ) ;
706+ }
707+
528708 return writer ;
529709 } ,
530710
@@ -553,6 +733,10 @@ export const UserStats = {
553733 message . affiliate_30dReferredVolumeQuoteQuantums = ( reader . uint64 ( ) as Long ) ;
554734 break ;
555735
736+ case 5 :
737+ message . affiliate_30dAttributedVolumeQuoteQuantums = ( reader . uint64 ( ) as Long ) ;
738+ break ;
739+
556740 default :
557741 reader . skipType ( tag & 7 ) ;
558742 break ;
@@ -568,6 +752,7 @@ export const UserStats = {
568752 message . makerNotional = object . makerNotional !== undefined && object . makerNotional !== null ? Long . fromValue ( object . makerNotional ) : Long . UZERO ;
569753 message . affiliate_30dRevenueGeneratedQuantums = object . affiliate_30dRevenueGeneratedQuantums !== undefined && object . affiliate_30dRevenueGeneratedQuantums !== null ? Long . fromValue ( object . affiliate_30dRevenueGeneratedQuantums ) : Long . UZERO ;
570754 message . affiliate_30dReferredVolumeQuoteQuantums = object . affiliate_30dReferredVolumeQuoteQuantums !== undefined && object . affiliate_30dReferredVolumeQuoteQuantums !== null ? Long . fromValue ( object . affiliate_30dReferredVolumeQuoteQuantums ) : Long . UZERO ;
755+ message . affiliate_30dAttributedVolumeQuoteQuantums = object . affiliate_30dAttributedVolumeQuoteQuantums !== undefined && object . affiliate_30dAttributedVolumeQuoteQuantums !== null ? Long . fromValue ( object . affiliate_30dAttributedVolumeQuoteQuantums ) : Long . UZERO ;
571756 return message ;
572757 }
573758
0 commit comments