Skip to content

Commit

Permalink
feat: reards auction proto (#2469)
Browse files Browse the repository at this point in the history
* feat: reards auction proto

* lint

* update genesis

* fix

* add usd rewards

* update params

* add events

* update genesis

* update

* Apply suggestions from code review

Co-authored-by: Sai Kumar <[email protected]>

---------

Co-authored-by: Sai Kumar <[email protected]>
  • Loading branch information
robert-zaremba and gsk967 authored Mar 25, 2024
1 parent 6dccda9 commit 6c5b613
Show file tree
Hide file tree
Showing 12 changed files with 3,814 additions and 1 deletion.
16 changes: 16 additions & 0 deletions proto/umee/auction/v1/auction.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package umee.auction.v1;

import "gogoproto/gogo.proto";

option go_package = "github.com/umee-network/umee/v6/x/auction";
option (gogoproto.goproto_getters_all) = false;

// RewardsParams defines parameters for the rewards auction.
message RewardsParams {
// bid_duration is duration of the bid phase in seconds.
int64 bid_duration = 1;
// Duration (in seconds) at the end of each auction, when we start collecting revenues for
// the next auction.
int64 revenu_collection_shift = 2;
}
18 changes: 18 additions & 0 deletions proto/umee/auction/v1/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";
package umee.auction.v1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/umee-network/umee/v6/x/auction";

option (gogoproto.goproto_getters_all) = false;

// EventRewardsAuctionResult is emitted at the end of each auction that has at least one bidder.
message EventRewardsAuctionResult {
uint32 id = 1;
string bidder = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Auctioned tokens.
repeated cosmos.base.v1beta1.Coin rewards = 4 [(gogoproto.nullable) = false];
}
27 changes: 27 additions & 0 deletions proto/umee/auction/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";
package umee.auction.v1;

import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "umee/auction/v1/auction.proto";

option go_package = "github.com/umee-network/umee/v6/x/auction";

option (gogoproto.goproto_getters_all) = false;
// option (gogoproto.equal_all) = false;

// GenesisState defines the x/auction module's genesis state.
message GenesisState {
RewardsParams rewards_params = 1 [(gogoproto.nullable) = false];
// Latest active (in bid phase) reward auction.
uint32 reward_auction_id = 2;
// Latest highest bid.
string highest_bidder = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Tokens collected for the current auction.
repeated cosmos.base.v1beta1.Coin current_rewards = 4 [(gogoproto.nullable) = false];
// Tokens collected for the next auction, while the current reward auction is still in the
// bid phase.
repeated cosmos.base.v1beta1.Coin next_rewards = 5 [(gogoproto.nullable) = false];
google.protobuf.Timestamp current_rewards_auction_end = 6 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
47 changes: 47 additions & 0 deletions proto/umee/auction/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
syntax = "proto3";
package umee.auction.v1;

import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
import "gogoproto/gogo.proto";
import "umee/auction/v1/auction.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/umee-network/umee/v6/x/auction";

// Query defines the gRPC querier service.
service Query {
// QueryRewardParams queries parameters for the reward auciton.
rpc RewardParams(QueryRewardParams) returns (QueryRewardParamsResponse) {
option (google.api.http).get = "/umee/auction/v1/rewards/params";
}
// RewardAuction queries the information of the auction by ID. If ID is ommitted, returns
// current reward auction params.
rpc RewardAuction(QueryRewardAuction) returns (QueryRewardAuctionResponse) {
option (google.api.http).get = "/umee/auction/v1/rewards";
}
}

// Query type for Query/RewardParams
message QueryRewardParams {}

// Response type for Query/RewardParams
message QueryRewardParamsResponse {
RewardsParams params = 1 [(gogoproto.nullable) = false];
}

// Query type for QueryRewardAuction
message QueryRewardAuction {
// If zero or not present, the current auction is returned
uint32 id = 1;
}

// Response type for Query/RewardAuctionResponse
message QueryRewardAuctionResponse {
uint32 id = 1;
// highest bidder
string bidder = 2;
repeated cosmos.base.v1beta1.Coin rewards = 3 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin usd_rewards = 4 [(gogoproto.nullable) = false];
google.protobuf.Timestamp ends_at = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
50 changes: 50 additions & 0 deletions proto/umee/auction/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
syntax = "proto3";
package umee.auction.v1;

import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "gogoproto/gogo.proto";
import "umee/auction/v1/auction.proto";

option go_package = "github.com/umee-network/umee/v6/x/auction";
option (gogoproto.goproto_getters_all) = false;

// Msg defines the x/auction module's Msg service.
service Msg {
//
// Rewards auction: bid umee for protocol rewards
//

// Allows x/gov to update rewards auction parameters.
rpc GovSetRewardsParams(MsgGovSetRewardsParams) returns (MsgGovSetRewardsParamsResponse);
// Places a bid for a reword auction. Must be higher than the previous bid by at least
// RewardParams.RewardsParams.
rpc RewardsBid(MsgRewardsBid) returns (MsgRewardsBidResponse);
}

// MsgGovSetRewardsParams updates rewards auction parameters.
message MsgGovSetRewardsParams {
option (cosmos.msg.v1.signer) = "authority";

// authority must be the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
RewardsParams params = 2 [(gogoproto.nullable) = false];
}

// MsgGovSetRewardsParamsResponse defines the Msg/GovSetRewardsParams response type.
message MsgGovSetRewardsParamsResponse {}

// MsgRewardsBid places a bid for a reword auction.
message MsgRewardsBid {
option (cosmos.msg.v1.signer) = "sender";

string sender = 1;
// the current auction ID being bid on. Fails if the ID is not an ID of the current auction.
uint32 id = 2;
// amount of the bid in the base tokens
cosmos.base.v1beta1.Coin bid_amount = 3 [(gogoproto.nullable) = false];
}

// MsgRewardsBidResponse response type for Msg/RewardsBid
message MsgRewardsBidResponse {}
2 changes: 1 addition & 1 deletion proto/umee/ugov/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ message MsgGovUpdateInflationParams {
}

// GovUpdateInflationParamsResponse response type.
message GovUpdateInflationParamsResponse {}
message GovUpdateInflationParamsResponse {}
Loading

0 comments on commit 6c5b613

Please sign in to comment.