Skip to content

Commit

Permalink
[TRA-433] Add MarketMapperRevShareDetails state and associated functi…
Browse files Browse the repository at this point in the history
…ons (#1744)

Signed-off-by: Shrenuj Bansal <shrenuj@dydx.exchange>
  • Loading branch information
shrenujb authored Jun 21, 2024
1 parent dc316d8 commit 1bc1c73
Show file tree
Hide file tree
Showing 18 changed files with 1,609 additions and 174 deletions.
298 changes: 151 additions & 147 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/lcd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export const createLCDClient = async ({
ratelimit: new (await import("./ratelimit/query.lcd")).LCDQueryClient({
requestClient
}),
revshare: new (await import("./revshare/query.lcd")).LCDQueryClient({
requestClient
}),
rewards: new (await import("./rewards/query.lcd")).LCDQueryClient({
requestClient
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { LCDClient } from "@osmonauts/lcd";
import { QueryMarketMapperRevShareDetails, QueryMarketMapperRevShareDetailsResponseSDKType } from "./query";
export class LCDQueryClient {
req: LCDClient;

constructor({
requestClient
}: {
requestClient: LCDClient;
}) {
this.req = requestClient;
this.marketMapperRevShareDetails = this.marketMapperRevShareDetails.bind(this);
}
/* Queries market mapper revenue share details for a specific market */


async marketMapperRevShareDetails(params: QueryMarketMapperRevShareDetails): Promise<QueryMarketMapperRevShareDetailsResponseSDKType> {
const endpoint = `dydxprotocol/revshare/market_mapper_rev_share_details/${params.marketId}`;
return await this.req.get<QueryMarketMapperRevShareDetailsResponseSDKType>(endpoint);
}

}
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
import { QueryMarketMapperRevShareDetails, QueryMarketMapperRevShareDetailsResponse } from "./query";
/** Query defines the gRPC querier service. */

export interface Query {}
export interface Query {
/** Queries market mapper revenue share details for a specific market */
marketMapperRevShareDetails(request: QueryMarketMapperRevShareDetails): Promise<QueryMarketMapperRevShareDetailsResponse>;
}
export class QueryClientImpl implements Query {
private readonly rpc: Rpc;

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

marketMapperRevShareDetails(request: QueryMarketMapperRevShareDetails): Promise<QueryMarketMapperRevShareDetailsResponse> {
const data = QueryMarketMapperRevShareDetails.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.revshare.Query", "MarketMapperRevShareDetails", data);
return promise.then(data => QueryMarketMapperRevShareDetailsResponse.decode(new _m0.Reader(data)));
}

}
export const createRpcQueryExtension = (base: QueryClient) => {
const rpc = createProtobufRpcClient(base);
const queryService = new QueryClientImpl(rpc);
return {};
return {
marketMapperRevShareDetails(request: QueryMarketMapperRevShareDetails): Promise<QueryMarketMapperRevShareDetailsResponse> {
return queryService.marketMapperRevShareDetails(request);
}

};
};
116 changes: 115 additions & 1 deletion indexer/packages/v4-protos/src/codegen/dydxprotocol/revshare/query.ts
Original file line number Diff line number Diff line change
@@ -1 +1,115 @@
export {}
import { MarketMapperRevShareDetails, MarketMapperRevShareDetailsSDKType } from "./revshare";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** Queries market mapper revenue share details for a specific market */

export interface QueryMarketMapperRevShareDetails {
/** Queries market mapper revenue share details for a specific market */
marketId: number;
}
/** Queries market mapper revenue share details for a specific market */

export interface QueryMarketMapperRevShareDetailsSDKType {
/** Queries market mapper revenue share details for a specific market */
market_id: number;
}
/** Response type for QueryMarketMapperRevShareDetails */

export interface QueryMarketMapperRevShareDetailsResponse {
details?: MarketMapperRevShareDetails;
}
/** Response type for QueryMarketMapperRevShareDetails */

export interface QueryMarketMapperRevShareDetailsResponseSDKType {
details?: MarketMapperRevShareDetailsSDKType;
}

function createBaseQueryMarketMapperRevShareDetails(): QueryMarketMapperRevShareDetails {
return {
marketId: 0
};
}

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

return writer;
},

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

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

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

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

return message;
},

fromPartial(object: DeepPartial<QueryMarketMapperRevShareDetails>): QueryMarketMapperRevShareDetails {
const message = createBaseQueryMarketMapperRevShareDetails();
message.marketId = object.marketId ?? 0;
return message;
}

};

function createBaseQueryMarketMapperRevShareDetailsResponse(): QueryMarketMapperRevShareDetailsResponse {
return {
details: undefined
};
}

export const QueryMarketMapperRevShareDetailsResponse = {
encode(message: QueryMarketMapperRevShareDetailsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.details !== undefined) {
MarketMapperRevShareDetails.encode(message.details, writer.uint32(10).fork()).ldelim();
}

return writer;
},

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

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

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

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

return message;
},

fromPartial(object: DeepPartial<QueryMarketMapperRevShareDetailsResponse>): QueryMarketMapperRevShareDetailsResponse {
const message = createBaseQueryMarketMapperRevShareDetailsResponse();
message.details = object.details !== undefined && object.details !== null ? MarketMapperRevShareDetails.fromPartial(object.details) : undefined;
return message;
}

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import * as _m0 from "protobufjs/minimal";
import { Long, DeepPartial } from "../../helpers";
/**
* MarketMapperRevShareDetails specifies any details associated with the market
* mapper revenue share
*/

export interface MarketMapperRevShareDetails {
/** Unix timestamp recorded when the market revenue share expires */
expirationTs: Long;
}
/**
* MarketMapperRevShareDetails specifies any details associated with the market
* mapper revenue share
*/

export interface MarketMapperRevShareDetailsSDKType {
/** Unix timestamp recorded when the market revenue share expires */
expiration_ts: Long;
}

function createBaseMarketMapperRevShareDetails(): MarketMapperRevShareDetails {
return {
expirationTs: Long.UZERO
};
}

export const MarketMapperRevShareDetails = {
encode(message: MarketMapperRevShareDetails, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (!message.expirationTs.isZero()) {
writer.uint32(8).uint64(message.expirationTs);
}

return writer;
},

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

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

switch (tag >>> 3) {
case 1:
message.expirationTs = (reader.uint64() as Long);
break;

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

return message;
},

fromPartial(object: DeepPartial<MarketMapperRevShareDetails>): MarketMapperRevShareDetails {
const message = createBaseMarketMapperRevShareDetails();
message.expirationTs = object.expirationTs !== undefined && object.expirationTs !== null ? Long.fromValue(object.expirationTs) : Long.UZERO;
return message;
}

};
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 _112 from "./gogo";
export const gogoproto = { ..._112
import * as _113 from "./gogo";
export const gogoproto = { ..._113
};
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 _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";
import * as _114 from "./api/annotations";
import * as _115 from "./api/http";
import * as _116 from "./protobuf/descriptor";
import * as _117 from "./protobuf/duration";
import * as _118 from "./protobuf/timestamp";
import * as _119 from "./protobuf/any";
export namespace google {
export const api = { ..._113,
..._114
export const api = { ..._114,
..._115
};
export const protobuf = { ..._115,
..._116,
export const protobuf = { ..._116,
..._117,
..._118
..._118,
..._119
};
}
20 changes: 19 additions & 1 deletion proto/dydxprotocol/revshare/query.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
syntax = "proto3";
package dydxprotocol.revshare;

import "google/api/annotations.proto";
import "dydxprotocol/revshare/revshare.proto";

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

// Query defines the gRPC querier service.
service Query {}
service Query {
// Queries market mapper revenue share details for a specific market
rpc MarketMapperRevShareDetails(QueryMarketMapperRevShareDetails)
returns (QueryMarketMapperRevShareDetailsResponse) {
option (google.api.http).get =
"/dydxprotocol/revshare/market_mapper_rev_share_details/{market_id}";
}
}

// Queries market mapper revenue share details for a specific market
message QueryMarketMapperRevShareDetails { uint32 market_id = 1; }

// Response type for QueryMarketMapperRevShareDetails
message QueryMarketMapperRevShareDetailsResponse {
MarketMapperRevShareDetails details = 1;
}
11 changes: 11 additions & 0 deletions proto/dydxprotocol/revshare/revshare.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";
package dydxprotocol.revshare;

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

// MarketMapperRevShareDetails specifies any details associated with the market
// mapper revenue share
message MarketMapperRevShareDetails {
// Unix timestamp recorded when the market revenue share expires
uint64 expiration_ts = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package keeper

import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/dydxprotocol/v4-chain/protocol/x/revshare/types"
)

func (k Keeper) MarketMapperRevShareDetails(
ctx context.Context,
req *types.QueryMarketMapperRevShareDetails,
) (*types.QueryMarketMapperRevShareDetailsResponse, error) {
revShareDetails, err := k.GetMarketMapperRevShareDetails(sdk.UnwrapSDKContext(ctx), req.MarketId)
if err != nil {
return nil, err
}
return &types.QueryMarketMapperRevShareDetailsResponse{
Details: &revShareDetails,
}, nil
}
Loading

0 comments on commit 1bc1c73

Please sign in to comment.