Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export interface AffiliateTiersSDKType {
export interface AffiliateTiers_Tier {
/** Required all-time referred volume in quote quantums. */
reqReferredVolumeQuoteQuantums: Long;
/** Required currently staked native tokens (in whole coins). */
/**
* Required currently staked native tokens (in whole coins).
* This is deprecated
*/

/** @deprecated */

reqStakedWholeCoins: number;
/** Taker fee share in parts-per-million. */
Expand All @@ -29,7 +34,12 @@ export interface AffiliateTiers_Tier {
export interface AffiliateTiers_TierSDKType {
/** Required all-time referred volume in quote quantums. */
req_referred_volume_quote_quantums: Long;
/** Required currently staked native tokens (in whole coins). */
/**
* Required currently staked native tokens (in whole coins).
* This is deprecated
*/

/** @deprecated */

req_staked_whole_coins: number;
/** Taker fee share in parts-per-million. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export interface AffiliateInfoResponse {
/** The affiliate's 30d referred volume in quote quantums. */

referredVolume_30dRolling: Uint8Array;
/** The affiliate's 30d attributed volume in quote quantums (from referees). */

attributedVolume_30dRolling: Uint8Array;
}
/**
* AffiliateInfoResponse is the response type for the Query/AffiliateInfo RPC
Expand Down Expand Up @@ -80,6 +83,9 @@ export interface AffiliateInfoResponseSDKType {
/** The affiliate's 30d referred volume in quote quantums. */

referred_volume_30d_rolling: Uint8Array;
/** The affiliate's 30d attributed volume in quote quantums (from referees). */

attributed_volume_30d_rolling: Uint8Array;
}
/** ReferredByRequest is the request type for the Query/ReferredBy RPC method. */

Expand Down Expand Up @@ -272,7 +278,8 @@ function createBaseAffiliateInfoResponse(): AffiliateInfoResponse {
feeSharePpm: 0,
referredVolume: new Uint8Array(),
stakedAmount: new Uint8Array(),
referredVolume_30dRolling: new Uint8Array()
referredVolume_30dRolling: new Uint8Array(),
attributedVolume_30dRolling: new Uint8Array()
};
}

Expand Down Expand Up @@ -302,6 +309,10 @@ export const AffiliateInfoResponse = {
writer.uint32(50).bytes(message.referredVolume_30dRolling);
}

if (message.attributedVolume_30dRolling.length !== 0) {
writer.uint32(58).bytes(message.attributedVolume_30dRolling);
}

return writer;
},

Expand Down Expand Up @@ -338,6 +349,10 @@ export const AffiliateInfoResponse = {
message.referredVolume_30dRolling = reader.bytes();
break;

case 7:
message.attributedVolume_30dRolling = reader.bytes();
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -355,6 +370,7 @@ export const AffiliateInfoResponse = {
message.referredVolume = object.referredVolume ?? new Uint8Array();
message.stakedAmount = object.stakedAmount ?? new Uint8Array();
message.referredVolume_30dRolling = object.referredVolume_30dRolling ?? new Uint8Array();
message.attributedVolume_30dRolling = object.attributedVolume_30dRolling ?? new Uint8Array();
return message;
}

Expand Down
191 changes: 188 additions & 3 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/stats/stats.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,82 @@
import { Timestamp } from "../../google/protobuf/timestamp";
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Proto verification failures indicate API mismatch.

All three pipeline failures are from build:verify-proto detecting that the generated TypeScript doesn't match the protobuf definition. This indicates the TypeScript code is missing fields that exist in the proto file.

🧰 Tools
🪛 GitHub Actions: Indexer API Documentation Check

[error] 1-1: Build failed: 'pnpm run build:verify-proto' failed in the v4-protos package during recursive build. Exit code 1. Command: 'pnpm run build:verify-proto && rm -rf build/ && tsc'.

🪛 GitHub Actions: Indexer Build, Test & Coverage

[error] 1-1: Build failed in package 'v4-protos'. Command 'pnpm run build:verify-proto' exited with code 1. ELIFECYCLE: Command failed with exit code 1 during recursive build.

🪛 GitHub Actions: Protobuf

[error] 1-1: build:verify-proto failed. Command 'pnpm run build:proto' exited with code 1 in workspace '@dydxprotocol-indexer/v4-protos'. Proto transpilation produced diffs indicating API changes that require validation (see logs for details).

🤖 Prompt for AI Agents
In indexer/packages/v4-protos/src/codegen/dydxprotocol/stats/stats.ts around
line 1, the generated TypeScript is missing fields compared to the protobuf
definition which causes build:verify-proto failures; open the corresponding
.proto, identify any fields present there but absent in this TS file, and add
those fields to the TypeScript types/interfaces with the correct names and types
(map proto timestamp fields to the imported Timestamp type, preserve
repeated/optional semantics), update any
encode/decode/fromJSON/toJSON/fromPartial helpers to handle the new fields, and
re-run build:verify-proto to confirm the generated code now matches the proto.

import * as _m0 from "protobufjs/minimal";
import { DeepPartial, Long, toTimestamp, fromTimestamp } from "../../helpers";
import { Long, DeepPartial, toTimestamp, fromTimestamp } from "../../helpers";
/** Role indicates whether this attribution is for the taker or maker */

export enum AffiliateAttribution_Role {
ROLE_UNSPECIFIED = 0,
ROLE_TAKER = 1,
ROLE_MAKER = 2,
UNRECOGNIZED = -1,
}
/** Role indicates whether this attribution is for the taker or maker */

export enum AffiliateAttribution_RoleSDKType {
ROLE_UNSPECIFIED = 0,
ROLE_TAKER = 1,
ROLE_MAKER = 2,
UNRECOGNIZED = -1,
}
export function affiliateAttribution_RoleFromJSON(object: any): AffiliateAttribution_Role {
switch (object) {
case 0:
case "ROLE_UNSPECIFIED":
return AffiliateAttribution_Role.ROLE_UNSPECIFIED;

case 1:
case "ROLE_TAKER":
return AffiliateAttribution_Role.ROLE_TAKER;

case 2:
case "ROLE_MAKER":
return AffiliateAttribution_Role.ROLE_MAKER;

case -1:
case "UNRECOGNIZED":
default:
return AffiliateAttribution_Role.UNRECOGNIZED;
}
}
export function affiliateAttribution_RoleToJSON(object: AffiliateAttribution_Role): string {
switch (object) {
case AffiliateAttribution_Role.ROLE_UNSPECIFIED:
return "ROLE_UNSPECIFIED";

case AffiliateAttribution_Role.ROLE_TAKER:
return "ROLE_TAKER";

case AffiliateAttribution_Role.ROLE_MAKER:
return "ROLE_MAKER";

case AffiliateAttribution_Role.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
/** AffiliateAttribution represents the affiliate attribution for a fill. */

export interface AffiliateAttribution {
/** Role of the trader (taker or maker) whose affiliate is being attributed */
role: AffiliateAttribution_Role;
/** Referrer address (the affiliate receiving the fee) */

referrerAddress: string;
/** Referred volume in quote quantums (capped based on 30-day volume limits) */

referredVolumeQuoteQuantums: Long;
}
/** AffiliateAttribution represents the affiliate attribution for a fill. */

export interface AffiliateAttributionSDKType {
/** Role of the trader (taker or maker) whose affiliate is being attributed */
role: AffiliateAttribution_RoleSDKType;
/** Referrer address (the affiliate receiving the fee) */

referrer_address: string;
/** Referred volume in quote quantums (capped based on 30-day volume limits) */

referred_volume_quote_quantums: Long;
}
/** BlockStats is used to store stats transiently within the scope of a block. */

export interface BlockStats {
Expand Down Expand Up @@ -34,6 +110,12 @@ export interface BlockStats_Fill {
*/

affiliateFeeGeneratedQuantums: Long;
/**
* Affiliate revenue attributions for this fill (can include both taker and
* maker)
*/

affiliateAttributions: AffiliateAttribution[];
}
/** Fill records data about a fill on this block. */

Expand All @@ -56,6 +138,12 @@ export interface BlockStats_FillSDKType {
*/

affiliate_fee_generated_quantums: Long;
/**
* Affiliate revenue attributions for this fill (can include both taker and
* maker)
*/

affiliate_attributions: AffiliateAttributionSDKType[];
}
/** StatsMetadata stores metadata for the x/stats module */

Expand Down Expand Up @@ -134,6 +222,12 @@ export interface UserStats {
/** Referred volume in quote quantums with this user being an affiliate */

affiliate_30dReferredVolumeQuoteQuantums: Long;
/**
* Attributed volume in quote quantums - volume from this user (as referee)
* that has been attributed to their affiliate in the last 30 days
*/

affiliate_30dAttributedVolumeQuoteQuantums: Long;
}
/**
* UserStats stores stats for a User. This is the sum of all stats for a user in
Expand All @@ -152,6 +246,12 @@ export interface UserStatsSDKType {
/** Referred volume in quote quantums with this user being an affiliate */

affiliate_30d_referred_volume_quote_quantums: Long;
/**
* Attributed volume in quote quantums - volume from this user (as referee)
* that has been attributed to their affiliate in the last 30 days
*/

affiliate_30d_attributed_volume_quote_quantums: Long;
}
/** CachedStakedBaseTokens stores the last calculated total staked base tokens */

Expand All @@ -178,6 +278,71 @@ export interface CachedStakedBaseTokensSDKType {
cached_at: Long;
}

function createBaseAffiliateAttribution(): AffiliateAttribution {
return {
role: 0,
referrerAddress: "",
referredVolumeQuoteQuantums: Long.UZERO
};
}

export const AffiliateAttribution = {
encode(message: AffiliateAttribution, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.role !== 0) {
writer.uint32(8).int32(message.role);
}

if (message.referrerAddress !== "") {
writer.uint32(18).string(message.referrerAddress);
}

if (!message.referredVolumeQuoteQuantums.isZero()) {
writer.uint32(24).uint64(message.referredVolumeQuoteQuantums);
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): AffiliateAttribution {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAffiliateAttribution();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.role = (reader.int32() as any);
break;

case 2:
message.referrerAddress = reader.string();
break;

case 3:
message.referredVolumeQuoteQuantums = (reader.uint64() as Long);
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<AffiliateAttribution>): AffiliateAttribution {
const message = createBaseAffiliateAttribution();
message.role = object.role ?? 0;
message.referrerAddress = object.referrerAddress ?? "";
message.referredVolumeQuoteQuantums = object.referredVolumeQuoteQuantums !== undefined && object.referredVolumeQuoteQuantums !== null ? Long.fromValue(object.referredVolumeQuoteQuantums) : Long.UZERO;
return message;
}

};

function createBaseBlockStats(): BlockStats {
return {
fills: []
Expand Down Expand Up @@ -228,7 +393,8 @@ function createBaseBlockStats_Fill(): BlockStats_Fill {
taker: "",
maker: "",
notional: Long.UZERO,
affiliateFeeGeneratedQuantums: Long.UZERO
affiliateFeeGeneratedQuantums: Long.UZERO,
affiliateAttributions: []
};
}

Expand All @@ -250,6 +416,10 @@ export const BlockStats_Fill = {
writer.uint32(32).uint64(message.affiliateFeeGeneratedQuantums);
}

for (const v of message.affiliateAttributions) {
AffiliateAttribution.encode(v!, writer.uint32(42).fork()).ldelim();
}

return writer;
},

Expand Down Expand Up @@ -278,6 +448,10 @@ export const BlockStats_Fill = {
message.affiliateFeeGeneratedQuantums = (reader.uint64() as Long);
break;

case 5:
message.affiliateAttributions.push(AffiliateAttribution.decode(reader, reader.uint32()));
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -293,6 +467,7 @@ export const BlockStats_Fill = {
message.maker = object.maker ?? "";
message.notional = object.notional !== undefined && object.notional !== null ? Long.fromValue(object.notional) : Long.UZERO;
message.affiliateFeeGeneratedQuantums = object.affiliateFeeGeneratedQuantums !== undefined && object.affiliateFeeGeneratedQuantums !== null ? Long.fromValue(object.affiliateFeeGeneratedQuantums) : Long.UZERO;
message.affiliateAttributions = object.affiliateAttributions?.map(e => AffiliateAttribution.fromPartial(e)) || [];
return message;
}

Expand Down Expand Up @@ -503,7 +678,8 @@ function createBaseUserStats(): UserStats {
takerNotional: Long.UZERO,
makerNotional: Long.UZERO,
affiliate_30dRevenueGeneratedQuantums: Long.UZERO,
affiliate_30dReferredVolumeQuoteQuantums: Long.UZERO
affiliate_30dReferredVolumeQuoteQuantums: Long.UZERO,
affiliate_30dAttributedVolumeQuoteQuantums: Long.UZERO
};
}

Expand All @@ -525,6 +701,10 @@ export const UserStats = {
writer.uint32(32).uint64(message.affiliate_30dReferredVolumeQuoteQuantums);
}

if (!message.affiliate_30dAttributedVolumeQuoteQuantums.isZero()) {
writer.uint32(40).uint64(message.affiliate_30dAttributedVolumeQuoteQuantums);
}

return writer;
},

Expand Down Expand Up @@ -553,6 +733,10 @@ export const UserStats = {
message.affiliate_30dReferredVolumeQuoteQuantums = (reader.uint64() as Long);
break;

case 5:
message.affiliate_30dAttributedVolumeQuoteQuantums = (reader.uint64() as Long);
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -568,6 +752,7 @@ export const UserStats = {
message.makerNotional = object.makerNotional !== undefined && object.makerNotional !== null ? Long.fromValue(object.makerNotional) : Long.UZERO;
message.affiliate_30dRevenueGeneratedQuantums = object.affiliate_30dRevenueGeneratedQuantums !== undefined && object.affiliate_30dRevenueGeneratedQuantums !== null ? Long.fromValue(object.affiliate_30dRevenueGeneratedQuantums) : Long.UZERO;
message.affiliate_30dReferredVolumeQuoteQuantums = object.affiliate_30dReferredVolumeQuoteQuantums !== undefined && object.affiliate_30dReferredVolumeQuoteQuantums !== null ? Long.fromValue(object.affiliate_30dReferredVolumeQuoteQuantums) : Long.UZERO;
message.affiliate_30dAttributedVolumeQuoteQuantums = object.affiliate_30dAttributedVolumeQuoteQuantums !== undefined && object.affiliate_30dAttributedVolumeQuoteQuantums !== null ? Long.fromValue(object.affiliate_30dAttributedVolumeQuoteQuantums) : Long.UZERO;
return message;
}

Expand Down
3 changes: 2 additions & 1 deletion proto/dydxprotocol/affiliates/affiliates.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ message AffiliateTiers {
// Required all-time referred volume in quote quantums.
uint64 req_referred_volume_quote_quantums = 1;
// Required currently staked native tokens (in whole coins).
uint32 req_staked_whole_coins = 2;
// This is deprecated
uint32 req_staked_whole_coins = 2 [ deprecated = true ];
// Taker fee share in parts-per-million.
uint32 taker_fee_share_ppm = 3;
}
Expand Down
6 changes: 6 additions & 0 deletions proto/dydxprotocol/affiliates/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ message AffiliateInfoResponse {
"github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt",
(gogoproto.nullable) = false
];
// The affiliate's 30d attributed volume in quote quantums (from referees).
bytes attributed_volume_30d_rolling = 7 [
(gogoproto.customtype) =
"github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt",
(gogoproto.nullable) = false
];
}

// ReferredByRequest is the request type for the Query/ReferredBy RPC method.
Expand Down
Loading
Loading