Skip to content

Commit

Permalink
feat(x/auction) revenues keeper implementation (#2496)
Browse files Browse the repository at this point in the history
* feat(auction): keeper implementation

* params

* update proto

* rewardsBid function

* update keeper

* query

* add coins

* proto: store.Coins

* finish query

* fix wiring

* lint

* coderabbit

* fix
  • Loading branch information
robert-zaremba authored Apr 17, 2024
1 parent 936693c commit e642166
Show file tree
Hide file tree
Showing 22 changed files with 1,169 additions and 229 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ func New(
app.AuctionKeeperB = auctionkeeper.NewBuilder(
appCodec,
keys[auction.StoreKey],
auctionmodule.SubAccounts(),
app.BankKeeper,
app.UGovKeeperB.EmergencyGroup,
)
Expand Down
15 changes: 15 additions & 0 deletions proto/umee/auction/v1/auction.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
syntax = "proto3";
package umee.auction.v1;

import "google/protobuf/timestamp.proto";
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;
Expand All @@ -11,3 +14,15 @@ message RewardsParams {
// bid_duration is duration of the bid phase in seconds.
int64 bid_duration = 1;
}

// Bid records a user bid
message Bid {
string bidder = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string amount = 2 [(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false];
}

// Auction Rewards
message Rewards {
repeated cosmos.base.v1beta1.Coin rewards = 1 [(gogoproto.nullable) = false];
google.protobuf.Timestamp ends_at = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
10 changes: 4 additions & 6 deletions proto/umee/auction/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ syntax = "proto3";
package umee.auction.v1;

import "google/protobuf/timestamp.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "umee/auction/v1/auction.proto";
Expand All @@ -17,14 +16,13 @@ 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"];
cosmos.base.v1beta1.Coin highest_bid = 4 [(gogoproto.nullable) = false];
// Latest highest rewards bid.
Bid highest_rewards_bid = 3 [(gogoproto.nullable) = false];

google.protobuf.Timestamp current_rewards_auction_end = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
// Tokens collected for the current auction.
repeated cosmos.base.v1beta1.Coin current_rewards = 5 [(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 = 6 [(gogoproto.nullable) = false];
google.protobuf.Timestamp current_rewards_auction_end = 7 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
repeated cosmos.base.v1beta1.Coin next_rewards = 6 [(gogoproto.nullable) = false];
}
8 changes: 4 additions & 4 deletions proto/umee/auction/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ message QueryRewardsAuction {
message QueryRewardsAuctionResponse {
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];
string bidder = 2;
cosmos.base.v1beta1.Coin bid = 3 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin rewards = 4 [(gogoproto.nullable) = false];
google.protobuf.Timestamp ends_at = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
14 changes: 14 additions & 0 deletions proto/umee/util/v1/proto.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";
package umee.util.v1;

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

option go_package = "github.com/umee-network/umee/v6/util/store";

option (gogoproto.goproto_getters_all) = false;

// Slice of sdk.Coin
message Coins {
repeated cosmos.base.v1beta1.Coin coins = 1 [(gogoproto.nullable) = false];
}
6 changes: 6 additions & 0 deletions util/coin/fixtures.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package coin

import (
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"

appparams "github.com/umee-network/umee/v6/app/params"
Expand Down Expand Up @@ -46,6 +47,11 @@ func Umee(amount int64) sdk.Coin {
return sdk.NewInt64Coin(umee, amount)
}

// UmeeInt creates a BondDenom sdk.Coin with the given amount
func UmeeInt(amount sdkmath.Int) sdk.Coin {
return sdk.NewCoin(umee, amount)
}

// UmeeCoins creates an Umee (uumee) sdk.Coins with the given amount
func UmeeCoins(amount int64) sdk.Coins {
return sdk.NewCoins(sdk.NewInt64Coin(umee, amount))
Expand Down
Loading

0 comments on commit e642166

Please sign in to comment.