Skip to content

Commit

Permalink
[TRA-415] implement market mapper rev share gov msg (#1733)
Browse files Browse the repository at this point in the history
Signed-off-by: Shrenuj Bansal <[email protected]>
  • Loading branch information
shrenujb authored Jun 20, 2024
1 parent dfd4f67 commit cd75f2a
Show file tree
Hide file tree
Showing 29 changed files with 1,737 additions and 191 deletions.
296 changes: 150 additions & 146 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import { MarketMapperRevenueShareParams, MarketMapperRevenueShareParamsSDKType } from "./params";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** GenesisState defines `x/revshare`'s genesis state. */

export interface GenesisState {}
export interface GenesisState {
params?: MarketMapperRevenueShareParams;
}
/** GenesisState defines `x/revshare`'s genesis state. */

export interface GenesisStateSDKType {}
export interface GenesisStateSDKType {
params?: MarketMapperRevenueShareParamsSDKType;
}

function createBaseGenesisState(): GenesisState {
return {};
return {
params: undefined
};
}

export const GenesisState = {
encode(_: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.params !== undefined) {
MarketMapperRevenueShareParams.encode(message.params, writer.uint32(10).fork()).ldelim();
}

return writer;
},

Expand All @@ -25,6 +36,10 @@ export const GenesisState = {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.params = MarketMapperRevenueShareParams.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -34,8 +49,9 @@ export const GenesisState = {
return message;
},

fromPartial(_: DeepPartial<GenesisState>): GenesisState {
fromPartial(object: DeepPartial<GenesisState>): GenesisState {
const message = createBaseGenesisState();
message.params = object.params !== undefined && object.params !== null ? MarketMapperRevenueShareParams.fromPartial(object.params) : undefined;
return message;
}

Expand Down
105 changes: 105 additions & 0 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/params.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** MarketMappeRevenueShareParams represents params for the above message */

export interface MarketMapperRevenueShareParams {
/** The address which will receive the revenue share payouts */
address: string;
/**
* The fraction of the fees which will go to the above mentioned address.
* In parts-per-million
*/

revenueSharePpm: number;
/**
* This parameter defines how many days post market initiation will the
* revenue share be applied for. After valid_days from market initiation
* the revenue share goes down to 0
*/

validDays: number;
}
/** MarketMappeRevenueShareParams represents params for the above message */

export interface MarketMapperRevenueShareParamsSDKType {
/** The address which will receive the revenue share payouts */
address: string;
/**
* The fraction of the fees which will go to the above mentioned address.
* In parts-per-million
*/

revenue_share_ppm: number;
/**
* This parameter defines how many days post market initiation will the
* revenue share be applied for. After valid_days from market initiation
* the revenue share goes down to 0
*/

valid_days: number;
}

function createBaseMarketMapperRevenueShareParams(): MarketMapperRevenueShareParams {
return {
address: "",
revenueSharePpm: 0,
validDays: 0
};
}

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

if (message.revenueSharePpm !== 0) {
writer.uint32(16).uint32(message.revenueSharePpm);
}

if (message.validDays !== 0) {
writer.uint32(24).uint32(message.validDays);
}

return writer;
},

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

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

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

case 2:
message.revenueSharePpm = reader.uint32();
break;

case 3:
message.validDays = reader.uint32();
break;

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

return message;
},

fromPartial(object: DeepPartial<MarketMapperRevenueShareParams>): MarketMapperRevenueShareParams {
const message = createBaseMarketMapperRevenueShareParams();
message.address = object.address ?? "";
message.revenueSharePpm = object.revenueSharePpm ?? 0;
message.validDays = object.validDays ?? 0;
return message;
}

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { MsgSetMarketMapperRevenueShare, MsgSetMarketMapperRevenueShareResponse } from "./tx";
/** Msg defines the Msg service. */

export interface Msg {
/**
* SetMarketMapperRevenueShare sets the revenue share for a market
* mapper.
*/
setMarketMapperRevenueShare(request: MsgSetMarketMapperRevenueShare): Promise<MsgSetMarketMapperRevenueShareResponse>;
}
export class MsgClientImpl implements Msg {
private readonly rpc: Rpc;

constructor(rpc: Rpc) {
this.rpc = rpc;
this.setMarketMapperRevenueShare = this.setMarketMapperRevenueShare.bind(this);
}

setMarketMapperRevenueShare(request: MsgSetMarketMapperRevenueShare): Promise<MsgSetMarketMapperRevenueShareResponse> {
const data = MsgSetMarketMapperRevenueShare.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.revshare.Msg", "SetMarketMapperRevenueShare", data);
return promise.then(data => MsgSetMarketMapperRevenueShareResponse.decode(new _m0.Reader(data)));
}

}
115 changes: 114 additions & 1 deletion indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/tx.ts
Original file line number Diff line number Diff line change
@@ -1 +1,114 @@
export {}
import { MarketMapperRevenueShareParams, MarketMapperRevenueShareParamsSDKType } from "./params";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** Message to set the market mapper revenue share */

export interface MsgSetMarketMapperRevenueShare {
authority: string;
/** Parameters for the revenue share */

params?: MarketMapperRevenueShareParams;
}
/** Message to set the market mapper revenue share */

export interface MsgSetMarketMapperRevenueShareSDKType {
authority: string;
/** Parameters for the revenue share */

params?: MarketMapperRevenueShareParamsSDKType;
}
/** Response to a MsgSetMarketMapperRevenueShare */

export interface MsgSetMarketMapperRevenueShareResponse {}
/** Response to a MsgSetMarketMapperRevenueShare */

export interface MsgSetMarketMapperRevenueShareResponseSDKType {}

function createBaseMsgSetMarketMapperRevenueShare(): MsgSetMarketMapperRevenueShare {
return {
authority: "",
params: undefined
};
}

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

if (message.params !== undefined) {
MarketMapperRevenueShareParams.encode(message.params, writer.uint32(18).fork()).ldelim();
}

return writer;
},

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

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

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

case 2:
message.params = MarketMapperRevenueShareParams.decode(reader, reader.uint32());
break;

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

return message;
},

fromPartial(object: DeepPartial<MsgSetMarketMapperRevenueShare>): MsgSetMarketMapperRevenueShare {
const message = createBaseMsgSetMarketMapperRevenueShare();
message.authority = object.authority ?? "";
message.params = object.params !== undefined && object.params !== null ? MarketMapperRevenueShareParams.fromPartial(object.params) : undefined;
return message;
}

};

function createBaseMsgSetMarketMapperRevenueShareResponse(): MsgSetMarketMapperRevenueShareResponse {
return {};
}

export const MsgSetMarketMapperRevenueShareResponse = {
encode(_: MsgSetMarketMapperRevenueShareResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
return writer;
},

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

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

switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(_: DeepPartial<MsgSetMarketMapperRevenueShareResponse>): MsgSetMarketMapperRevenueShareResponse {
const message = createBaseMsgSetMarketMapperRevenueShareResponse();
return message;
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const createRPCMsgClient = async ({
perpetuals: new (await import("./perpetuals/tx.rpc.msg")).MsgClientImpl(rpc),
prices: new (await import("./prices/tx.rpc.msg")).MsgClientImpl(rpc),
ratelimit: new (await import("./ratelimit/tx.rpc.msg")).MsgClientImpl(rpc),
revshare: new (await import("./revshare/tx.rpc.msg")).MsgClientImpl(rpc),
rewards: new (await import("./rewards/tx.rpc.msg")).MsgClientImpl(rpc),
sending: new (await import("./sending/tx.rpc.msg")).MsgClientImpl(rpc),
stats: new (await import("./stats/tx.rpc.msg")).MsgClientImpl(rpc),
Expand Down
4 changes: 2 additions & 2 deletions indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as _111 from "./gogo";
export const gogoproto = { ..._111
import * as _112 from "./gogo";
export const gogoproto = { ..._112
};
22 changes: 11 additions & 11 deletions indexer/packages/v4-protos/src/codegen/google/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as _112 from "./api/annotations";
import * as _113 from "./api/http";
import * as _114 from "./protobuf/descriptor";
import * as _115 from "./protobuf/duration";
import * as _116 from "./protobuf/timestamp";
import * as _117 from "./protobuf/any";
import * as _113 from "./api/annotations";
import * as _114 from "./api/http";
import * as _115 from "./protobuf/descriptor";
import * as _116 from "./protobuf/duration";
import * as _117 from "./protobuf/timestamp";
import * as _118 from "./protobuf/any";
export namespace google {
export const api = { ..._112,
..._113
export const api = { ..._113,
..._114
};
export const protobuf = { ..._114,
..._115,
export const protobuf = { ..._115,
..._116,
..._117
..._117,
..._118
};
}
7 changes: 6 additions & 1 deletion proto/dydxprotocol/revshare/genesis.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
syntax = "proto3";
package dydxprotocol.revshare;

import "gogoproto/gogo.proto";
import "dydxprotocol/revshare/params.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/revshare/types";

// GenesisState defines `x/revshare`'s genesis state.
message GenesisState {}
message GenesisState {
MarketMapperRevenueShareParams params = 1 [ (gogoproto.nullable) = false ];
}
21 changes: 21 additions & 0 deletions proto/dydxprotocol/revshare/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";
package dydxprotocol.revshare;

import "cosmos_proto/cosmos.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/revshare/types";

// MarketMappeRevenueShareParams represents params for the above message
message MarketMapperRevenueShareParams {
// The address which will receive the revenue share payouts
string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// The fraction of the fees which will go to the above mentioned address.
// In parts-per-million
uint32 revenue_share_ppm = 2;

// This parameter defines how many days post market initiation will the
// revenue share be applied for. After valid_days from market initiation
// the revenue share goes down to 0
uint32 valid_days = 3;
}
Loading

0 comments on commit cd75f2a

Please sign in to comment.