Skip to content

Commit

Permalink
[IND-505]: Add TradingRewardEventV1 (#837)
Browse files Browse the repository at this point in the history
* [IND-505]: Add TradingRewardEventV1

* nits

* serializableInt

* fix tests

* regenerate protos

---------

Co-authored-by: Roy Li <[email protected]>
  • Loading branch information
Christopher-Li and roy-dydx authored Dec 7, 2023
1 parent 9b3d1a2 commit f50246e
Show file tree
Hide file tree
Showing 5 changed files with 738 additions and 138 deletions.
20 changes: 16 additions & 4 deletions indexer/packages/v4-protos/src/codegen/cosmos/base/v1beta1/coin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,34 @@ export interface DecCoinSDKType {
denom: string;
amount: string;
}
/** IntProto defines a Protobuf wrapper around an Int object. */
/**
* IntProto defines a Protobuf wrapper around an Int object.
* Deprecated: Prefer to use math.Int directly. It supports binary Marshal and Unmarshal.
*/

export interface IntProto {
int: string;
}
/** IntProto defines a Protobuf wrapper around an Int object. */
/**
* IntProto defines a Protobuf wrapper around an Int object.
* Deprecated: Prefer to use math.Int directly. It supports binary Marshal and Unmarshal.
*/

export interface IntProtoSDKType {
int: string;
}
/** DecProto defines a Protobuf wrapper around a Dec object. */
/**
* DecProto defines a Protobuf wrapper around a Dec object.
* Deprecated: Prefer to use math.LegacyDec directly. It supports binary Marshal and Unmarshal.
*/

export interface DecProto {
dec: string;
}
/** DecProto defines a Protobuf wrapper around a Dec object. */
/**
* DecProto defines a Protobuf wrapper around a Dec object.
* Deprecated: Prefer to use math.LegacyDec directly. It supports binary Marshal and Unmarshal.
*/

export interface DecProtoSDKType {
dec: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,54 @@ export interface UpdatePerpetualEventV1SDKType {

liquidity_tier: number;
}
/**
* TradingRewardEventV1 is communicates all trading rewards for all accounts
* that receive trade rewards in the block.
*/

export interface TradingRewardEventV1 {
/** The list of all trading rewards in the block. */
tradingRewards: AddressTradingReward[];
}
/**
* TradingRewardEventV1 is communicates all trading rewards for all accounts
* that receive trade rewards in the block.
*/

export interface TradingRewardEventV1SDKType {
/** The list of all trading rewards in the block. */
trading_rewards: AddressTradingRewardSDKType[];
}
/**
* AddressTradingReward contains info on an instance of an address receiving a
* reward
*/

export interface AddressTradingReward {
/** The address of the wallet that will receive the trading reward. */
owner: string;
/**
* The trading rewards earned by the address above in denoms. 1e18 denoms is
* equivalent to a single coin.
*/

denoms: Uint8Array;
}
/**
* AddressTradingReward contains info on an instance of an address receiving a
* reward
*/

export interface AddressTradingRewardSDKType {
/** The address of the wallet that will receive the trading reward. */
owner: string;
/**
* The trading rewards earned by the address above in denoms. 1e18 denoms is
* equivalent to a single coin.
*/

denoms: Uint8Array;
}

function createBaseFundingUpdateV1(): FundingUpdateV1 {
return {
Expand Down Expand Up @@ -2849,4 +2897,104 @@ export const UpdatePerpetualEventV1 = {
return message;
}

};

function createBaseTradingRewardEventV1(): TradingRewardEventV1 {
return {
tradingRewards: []
};
}

export const TradingRewardEventV1 = {
encode(message: TradingRewardEventV1, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.tradingRewards) {
AddressTradingReward.encode(v!, writer.uint32(10).fork()).ldelim();
}

return writer;
},

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

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

switch (tag >>> 3) {
case 1:
message.tradingRewards.push(AddressTradingReward.decode(reader, reader.uint32()));
break;

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

return message;
},

fromPartial(object: DeepPartial<TradingRewardEventV1>): TradingRewardEventV1 {
const message = createBaseTradingRewardEventV1();
message.tradingRewards = object.tradingRewards?.map(e => AddressTradingReward.fromPartial(e)) || [];
return message;
}

};

function createBaseAddressTradingReward(): AddressTradingReward {
return {
owner: "",
denoms: new Uint8Array()
};
}

export const AddressTradingReward = {
encode(message: AddressTradingReward, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.owner !== "") {
writer.uint32(10).string(message.owner);
}

if (message.denoms.length !== 0) {
writer.uint32(18).bytes(message.denoms);
}

return writer;
},

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

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

switch (tag >>> 3) {
case 1:
message.owner = reader.string();
break;

case 2:
message.denoms = reader.bytes();
break;

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

return message;
},

fromPartial(object: DeepPartial<AddressTradingReward>): AddressTradingReward {
const message = createBaseAddressTradingReward();
message.owner = object.owner ?? "";
message.denoms = object.denoms ?? new Uint8Array();
return message;
}

};
24 changes: 16 additions & 8 deletions indexer/packages/v4-protos/src/codegen/google/api/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,18 @@ export interface HttpSDKType {
* 1. Leaf request fields (recursive expansion nested messages in the request
* message) are classified into three categories:
* - Fields referred by the path template. They are passed via the URL path.
* - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP
* - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They
* are passed via the HTTP
* request body.
* - All other fields are passed via the URL query parameters, and the
* parameter name is the field path in the request message. A repeated
* field can be represented as multiple query parameters under the same
* name.
* 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields
* 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL
* query parameter, all fields
* are passed via URL path and HTTP request body.
* 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all
* 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP
* request body, all
* fields are passed via URL path and URL query parameters.
*
* ### Path template syntax
Expand Down Expand Up @@ -324,7 +327,8 @@ export interface HttpRule {
/**
* Selects a method to which this rule applies.
*
* Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
* Refer to [selector][google.api.DocumentationRule.selector] for syntax
* details.
*/
selector: string;
/**
Expand Down Expand Up @@ -551,15 +555,18 @@ export interface HttpRule {
* 1. Leaf request fields (recursive expansion nested messages in the request
* message) are classified into three categories:
* - Fields referred by the path template. They are passed via the URL path.
* - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP
* - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They
* are passed via the HTTP
* request body.
* - All other fields are passed via the URL query parameters, and the
* parameter name is the field path in the request message. A repeated
* field can be represented as multiple query parameters under the same
* name.
* 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields
* 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL
* query parameter, all fields
* are passed via URL path and HTTP request body.
* 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all
* 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP
* request body, all
* fields are passed via URL path and URL query parameters.
*
* ### Path template syntax
Expand Down Expand Up @@ -657,7 +664,8 @@ export interface HttpRuleSDKType {
/**
* Selects a method to which this rule applies.
*
* Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
* Refer to [selector][google.api.DocumentationRule.selector] for syntax
* details.
*/
selector: string;
/**
Expand Down
22 changes: 22 additions & 0 deletions proto/dydxprotocol/indexer/events/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,25 @@ message UpdatePerpetualEventV1 {
// Defined in perpetuals.perpetual
uint32 liquidity_tier = 5;
}

// TradingRewardEventV1 is communicates all trading rewards for all accounts
// that receive trade rewards in the block.
message TradingRewardEventV1 {
// The list of all trading rewards in the block.
repeated AddressTradingReward trading_rewards = 1;
}

// AddressTradingReward contains info on an instance of an address receiving a
// reward
message AddressTradingReward {
// The address of the wallet that will receive the trading reward.
string owner = 1;

// The trading rewards earned by the address above in denoms. 1e18 denoms is
// equivalent to a single coin.
bytes denoms = 2 [
(gogoproto.customtype) =
"github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt",
(gogoproto.nullable) = false
];
}
Loading

0 comments on commit f50246e

Please sign in to comment.