Skip to content

Commit

Permalink
enable sending BpMevMatches and ProposalReceiveTime to MEV indexer (#840
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lucas-dydx authored Dec 5, 2023
1 parent 11fd8a0 commit 56d653a
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 43 deletions.
26 changes: 25 additions & 1 deletion indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/mev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export interface ValidatorMevMatchesSDKType {
export interface MevNodeToNodeMetrics {
validatorMevMatches?: ValidatorMevMatches;
clobMidPrices: ClobMidPrice[];
bpMevMatches?: ValidatorMevMatches;
proposalReceiveTime: Long;
}
/**
* MevNodeToNodeMetrics is a data structure for encapsulating all MEV node <>
Expand All @@ -103,6 +105,8 @@ export interface MevNodeToNodeMetrics {
export interface MevNodeToNodeMetricsSDKType {
validator_mev_matches?: ValidatorMevMatchesSDKType;
clob_mid_prices: ClobMidPriceSDKType[];
bp_mev_matches?: ValidatorMevMatchesSDKType;
proposal_receive_time: Long;
}

function createBaseMEVMatch(): MEVMatch {
Expand Down Expand Up @@ -448,7 +452,9 @@ export const ValidatorMevMatches = {
function createBaseMevNodeToNodeMetrics(): MevNodeToNodeMetrics {
return {
validatorMevMatches: undefined,
clobMidPrices: []
clobMidPrices: [],
bpMevMatches: undefined,
proposalReceiveTime: Long.UZERO
};
}

Expand All @@ -462,6 +468,14 @@ export const MevNodeToNodeMetrics = {
ClobMidPrice.encode(v!, writer.uint32(18).fork()).ldelim();
}

if (message.bpMevMatches !== undefined) {
ValidatorMevMatches.encode(message.bpMevMatches, writer.uint32(26).fork()).ldelim();
}

if (!message.proposalReceiveTime.isZero()) {
writer.uint32(32).uint64(message.proposalReceiveTime);
}

return writer;
},

Expand All @@ -482,6 +496,14 @@ export const MevNodeToNodeMetrics = {
message.clobMidPrices.push(ClobMidPrice.decode(reader, reader.uint32()));
break;

case 3:
message.bpMevMatches = ValidatorMevMatches.decode(reader, reader.uint32());
break;

case 4:
message.proposalReceiveTime = (reader.uint64() as Long);
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -495,6 +517,8 @@ export const MevNodeToNodeMetrics = {
const message = createBaseMevNodeToNodeMetrics();
message.validatorMevMatches = object.validatorMevMatches !== undefined && object.validatorMevMatches !== null ? ValidatorMevMatches.fromPartial(object.validatorMevMatches) : undefined;
message.clobMidPrices = object.clobMidPrices?.map(e => ClobMidPrice.fromPartial(e)) || [];
message.bpMevMatches = object.bpMevMatches !== undefined && object.bpMevMatches !== null ? ValidatorMevMatches.fromPartial(object.bpMevMatches) : undefined;
message.proposalReceiveTime = object.proposalReceiveTime !== undefined && object.proposalReceiveTime !== null ? Long.fromValue(object.proposalReceiveTime) : Long.UZERO;
return message;
}

Expand Down
2 changes: 2 additions & 0 deletions proto/dydxprotocol/clob/mev.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ message ValidatorMevMatches {
message MevNodeToNodeMetrics {
ValidatorMevMatches validator_mev_matches = 1;
repeated ClobMidPrice clob_mid_prices = 2 [ (gogoproto.nullable) = false ];
ValidatorMevMatches bp_mev_matches = 3;
uint64 proposal_receive_time = 4;
}
2 changes: 2 additions & 0 deletions protocol/x/clob/keeper/mev.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ func (k Keeper) RecordMevMetrics(
MevNodeToNode: types.MevNodeToNodeMetrics{
ValidatorMevMatches: validatorMevMatches,
ClobMidPrices: mevClobMidPrices,
BpMevMatches: blockProposerMevMatches,
ProposalReceiveTime: uint64(time.Now().Second()),
},
},
)
Expand Down
182 changes: 140 additions & 42 deletions protocol/x/clob/types/mev.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 56d653a

Please sign in to comment.