Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Commit

Permalink
update local protos
Browse files Browse the repository at this point in the history
  • Loading branch information
Unique-Divine committed Oct 10, 2022
1 parent 44cf8eb commit 1944c89
Show file tree
Hide file tree
Showing 20 changed files with 392 additions and 306 deletions.
37 changes: 1 addition & 36 deletions proto/epochs/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,10 @@ package nibiru.epochs.v1beta1;
import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "epochs/state.proto";

option go_package = "github.com/NibiruChain/nibiru/x/epochs/types";

message EpochInfo {
// A string identifier for the epoch. e.g. "15min" or "1hour"
string identifier = 1;

// When the epoch repetitino should start.
google.protobuf.Timestamp start_time = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"start_time\""
];

// How long each epoch lasts for.
google.protobuf.Duration duration = 3 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"duration\""
];

// The current epoch number, starting from 1.
int64 current_epoch = 4;

// The start timestamp of the current epoch.
google.protobuf.Timestamp current_epoch_start_time = 5 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"current_epoch_start_time\""
];

// Whether or not this epoch has started. Set to true if current blocktime >= start_time.
bool epoch_counting_started = 6;

// The block height at which the current epoch started at.
int64 current_epoch_start_height = 7;
}

// GenesisState defines the epochs module's genesis state.
message GenesisState {
repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ];
Expand Down
4 changes: 2 additions & 2 deletions proto/epochs/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package nibiru.epochs.v1beta1;
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "epochs/genesis.proto";
import "epochs/state.proto";

option go_package = "github.com/NibiruChain/nibiru/x/epochs/types";

Expand All @@ -27,4 +27,4 @@ message QueryEpochsInfoResponse {
}

message QueryCurrentEpochRequest { string identifier = 1; }
message QueryCurrentEpochResponse { int64 current_epoch = 1; }
message QueryCurrentEpochResponse { uint64 current_epoch = 1; }
45 changes: 45 additions & 0 deletions proto/epochs/state.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
syntax = "proto3";
package nibiru.epochs.v1beta1;

import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/NibiruChain/nibiru/x/epochs/types";

message EpochInfo {
// A string identifier for the epoch. e.g. "15min" or "1hour"
string identifier = 1;

// When the epoch repetitino should start.
google.protobuf.Timestamp start_time = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"start_time\""
];

// How long each epoch lasts for.
google.protobuf.Duration duration = 3 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"duration\""
];

// The current epoch number, starting from 1.
uint64 current_epoch = 4;

// The start timestamp of the current epoch.
google.protobuf.Timestamp current_epoch_start_time = 5 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"current_epoch_start_time\""
];

// Whether or not this epoch has started. Set to true if current blocktime >= start_time.
bool epoch_counting_started = 6;

// The block height at which the current epoch started at.
int64 current_epoch_start_height = 7;
}

1 change: 1 addition & 0 deletions proto/oracle/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ message GenesisState {
repeated AggregateExchangeRatePrevote aggregate_exchange_rate_prevotes = 5 [(gogoproto.nullable) = false];
repeated AggregateExchangeRateVote aggregate_exchange_rate_votes = 6 [(gogoproto.nullable) = false];
repeated Pair pairs = 7 [(gogoproto.nullable) = false];
repeated PairReward pair_rewards = 8 [(gogoproto.nullable) = false];
}

// FeederDelegation is the address for where oracle feeder authority are
Expand Down
22 changes: 17 additions & 5 deletions proto/oracle/v1beta1/oracle.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@ message Params {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
uint64 reward_distribution_window = 4 [(gogoproto.moretags) = "yaml:\"reward_distribution_window\""];
repeated Pair whitelist = 5 [
repeated Pair whitelist = 4 [
(gogoproto.moretags) = "yaml:\"whitelist\"",
(gogoproto.castrepeated) = "PairList",
(gogoproto.nullable) = false
];
string slash_fraction = 6 [
string slash_fraction = 5 [
(gogoproto.moretags) = "yaml:\"slash_fraction\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
uint64 slash_window = 7 [(gogoproto.moretags) = "yaml:\"slash_window\""];
string min_valid_per_window = 8 [
uint64 slash_window = 6 [(gogoproto.moretags) = "yaml:\"slash_window\""];
string min_valid_per_window = 7 [
(gogoproto.moretags) = "yaml:\"min_valid_per_window\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
Expand Down Expand Up @@ -92,3 +91,16 @@ message ExchangeRateTuple {
(gogoproto.nullable) = false
];
}

// PairReward defines a credit object towards validators
// which provide prices faithfully for different pairs.
message PairReward {
// pair defines the pair for which we incentivize validator to provide prices for.
string pair = 1;
// id uniquely identifies the rewards instance of the pair
uint64 id = 2;
// vote_periods defines the vote periods left in which rewards will be distributed.
uint64 vote_periods = 3;
// coins defines the amount of coins to distribute in a single vote period.
repeated cosmos.base.v1beta1.Coin coins = 4 [(gogoproto.nullable) = false];
}
Binary file added proto/perp/v1/.query.proto.swp
Binary file not shown.
24 changes: 15 additions & 9 deletions proto/perp/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package nibiru.perp.v1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "perp/v1/state.proto";
import "cosmos/base/v1beta1/coin.proto";
import "common/common.proto";
import "perp/v1/state.proto";

option go_package = "github.com/NibiruChain/nibiru/x/perp/types";

Expand Down Expand Up @@ -69,9 +69,9 @@ message PositionChangedEvent {
(gogoproto.nullable) = false
];

// Spot price, synonymous with mark price in this context, is the quotient of
// Mark price, synonymous with mark price in this context, is the quotient of
// the quote reserves and base reserves
string spot_price = 12 [
string mark_price = 12 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
Expand Down Expand Up @@ -212,17 +212,23 @@ message FundingRateChangedEvent {
(gogoproto.nullable) = false
];

// The latest cumulative funding rate.
// The funding rate a position will pay is the difference between this value
// and the latest cumulative funding rate on the position.
string cumulative_funding_rate = 5 [
// The latest premium fraction just calculated.
string latest_premium_fraction = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// The latest cumulative premium fraction.
// The funding payment a position will pay is the difference between this value
// and the latest cumulative premium fraction on the position, multiplied by the position size.
string cumulative_premium_fraction = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// The block number at which the funding rate was calculated.
int64 block_height = 6;
int64 block_height = 7;

// The block time in unix milliseconds at which the funding rate was calculated.
int64 block_time_ms = 7;
int64 block_time_ms = 8;
}
22 changes: 22 additions & 0 deletions proto/perp/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";

package nibiru.perp.v1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/v1beta1/coin.proto";
import "common/common.proto";
import "perp/v1/state.proto";

option go_package = "github.com/NibiruChain/nibiru/x/perp/types";

// GenesisState defines the perp module's genesis state.
message GenesisState {
Params params = 1 [ (gogoproto.nullable) = false ];

repeated PairMetadata pair_metadata = 2 [ (gogoproto.nullable) = false ];

repeated Position positions = 3 [ (gogoproto.nullable) = false ];

repeated PrepaidBadDebt prepaid_bad_debts = 4 [ (gogoproto.nullable) = false ];
}
83 changes: 63 additions & 20 deletions proto/perp/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "perp/v1/state.proto";

option go_package="github.com/NibiruChain/nibiru/x/perp/types";
option go_package = "github.com/NibiruChain/nibiru/x/perp/types";

// Query defines the gRPC querier service.
service Query {
Expand All @@ -15,8 +15,19 @@ service Query {
option (google.api.http).get = "/nibiru/perp/params";
}

rpc QueryTraderPosition(QueryTraderPositionRequest) returns (QueryTraderPositionResponse) {
option (google.api.http).get = "/nibiru/perp/trader_position";
rpc QueryPosition(QueryPositionRequest)
returns (QueryPositionResponse) {
option (google.api.http).get = "/nibiru/perp/position";
}

rpc QueryPositions(QueryPositionsRequest)
returns (QueryPositionsResponse) {
option (google.api.http).get = "/nibiru/perp/positions";
}

rpc FundingRates(QueryFundingRatesRequest)
returns (QueryFundingRatesResponse) {
option (google.api.http).get = "/nibiru/perp/funding_rates";
}
}

Expand All @@ -28,47 +39,79 @@ message QueryParamsRequest {}
// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
Params params = 1 [ (gogoproto.nullable) = false ];
}

// ---------------------------------------- Positions
message QueryPositionsRequest {
string trader = 1;
}

message QueryPositionsResponse {
repeated QueryPositionResponse positions = 1;
}

// ---------------------------------------- TraderPosition
// ---------------------------------------- Position

/* QueryTraderPositionRequest is the request type for the position of the
x/perp module account. */
message QueryTraderPositionRequest {
// QueryPositionRequest is the request type for the position of the x/perp
// module account.
message QueryPositionRequest {
string token_pair = 1;

string trader = 2;
}

message QueryTraderPositionResponse {


message QueryPositionResponse {
// The position as it exists in the blockchain state
Position position = 1;

// The position's current notional value, if it were to be entirely closed (in margin units).
// The position's current notional value, if it were to be entirely closed (in
// margin units).
string position_notional = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false];
(gogoproto.nullable) = false
];

// The position's unrealized PnL.
string unrealized_pnl = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false];
(gogoproto.nullable) = false
];

/* margin ratio of the position based on the mark price, mark TWAP. The higher
value of the possible margin ratios (TWAP and instantaneous) is taken to be
'marginRatioMark'. Calculated from margin, unrealized PnL, and position notional. */
// margin ratio of the position based on the mark price, mark TWAP. The higher
// value of the possible margin ratios (TWAP and instantaneous) is taken to be
// 'marginRatioMark'. Calculated from margin, unrealized PnL, and position
// notional.
string margin_ratio_mark = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false];
(gogoproto.nullable) = false
];

/* margin ratio of the position based on the index price. Calculated from margin,
unrealized PnL, and position notional. */
// margin ratio of the position based on the index price. Calculated from
// margin, unrealized PnL, and position notional.
string margin_ratio_index = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false];
(gogoproto.nullable) = false
];

// BlockNumber is current block number at the time of query.
int64 block_number = 7;
}

// ---------------------------------------- OtherQuery
// ---------------------------------------- FundingPayments

message QueryFundingRatesRequest {
// the pair to query for
string pair = 1;
}

message QueryFundingRatesResponse {
// a historical list of cumulative funding rates, with the most recent one
// last
repeated string cumulative_funding_rates = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
Loading

0 comments on commit 1944c89

Please sign in to comment.