diff --git a/README.md b/README.md index f4c5e61ab6..bac47a2ec5 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ See [Release procedure](CONTRIBUTING.md#release-procedure) for more information | v6.2.x | ✓ | v0.47.6+ | v7.2.x | --- | umee/v2.3.0 | --- | v1.5.0 | | v6.3.x | ✓ | v0.47.7+ | v7.3.1 | --- | umee/v2.3.0+ | --- | v1.5.0 | | v6.4.x | x | v0.47.10+ | v7.3.2 | --- | umee/v2.4.1+ | --- | v1.5.2 | -| v6.5.x | x | v0.47.10+ | v7.4.x | --- | umee/v2.4.3+ | --- | v1.5.2 | +| v6.5.x | x | v0.47.11+ | v7.5.1 | --- | umee/v2.4.3+ | --- | v1.5.2 | #### Price Feeder diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index f4ec25aa0a..b9938afeca 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,35 +6,29 @@ The Release Procedure is defined in the [CONTRIBUTING](CONTRIBUTING.md#release-procedure) document. -## v6.4.0 +## v6.5.0 Highlights: -- Cosmos SDK v0.47.10 patch update. -- IBC Hooks: we integrated ICS20 Memo handling. -- Integrated Packet Forwarding Middleware. -- Update `uibc/MsgGovUpdateQuota` Msg type to handle the new inflow parameters. -- Update `uibc/QueryAllOutflowsResponse` to include denom symbol (token name) in every outflow. +- Cosmos SDK v0.47.11 update. +- Adding new `auction` module to our app. +- Removing `crisis` module from our app. [CHANGELOG](CHANGELOG.md) -### IBC Hooks +### Auction module -This release brings the first part of the seamless cross-chain money market transactions. At UX, we want to provide the best User Experience for handling lending and leverage. In this release, we support the following `x/leverage` messages: +We propose a new Cosmos SDK module, that will provide mechanism for protocol owned auctions. -- `MsgSupply` -- `MsgSupplyCollateral` -- `MsgLiquidate` +UX Chain will now auction a portion of collected fees and introduce a token burning mechanism, unlocking a way to a potentially deflationary UX token. -The operation can only use tokens that are part of the IBC transfer (after any intermediate deductions) and the supplier / liquidator must be the IBC recipient (acting on someone else's behalf is not allowed). Authz is not supported. The remaining tokens will be credited to the recipient. - -Documentation: [x/uibc/README.md](https://github.com/umee-network/umee/blob/v6.4.0/x/uibc/README.md#ibc-ics20-hooks) +Documentation: [x/auction/README.md](https://github.com/umee-network/umee/blob/v6.5.0/x/auction/README.md) ### Validators -**Upgrade Title** (for Cosmovisor): **v6.4**. +**Upgrade Title** (for Cosmovisor): **v6.5**. -Update Price Feeder to `umee/2.4.1+`. +Update Price Feeder to `umee/2.4.3+`. NOTE: after the upgrade, you should restart your Price Feeder. We observed that Price Feeder doesn't correctly re-established a connection after the chain upgrade. diff --git a/proto/umee/auction/v1/auction.proto b/proto/umee/auction/v1/auction.proto index a20a98cbbb..46871e2907 100644 --- a/proto/umee/auction/v1/auction.proto +++ b/proto/umee/auction/v1/auction.proto @@ -17,7 +17,7 @@ message RewardsParams { // Bid records a user bid message Bid { - bytes bidder = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + 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]; } diff --git a/proto/umee/auction/v1/query.proto b/proto/umee/auction/v1/query.proto index e73af918a8..18cc6eb195 100644 --- a/proto/umee/auction/v1/query.proto +++ b/proto/umee/auction/v1/query.proto @@ -3,6 +3,7 @@ package umee.auction.v1; import "google/protobuf/timestamp.proto"; import "google/api/annotations.proto"; +import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "umee/auction/v1/auction.proto"; import "cosmos/base/v1beta1/coin.proto"; @@ -42,7 +43,7 @@ message QueryRewardsAuction { message QueryRewardsAuctionResponse { uint32 id = 1; // highest bidder - string bidder = 2; + string bidder = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; 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]; diff --git a/x/auction/README.md b/x/auction/README.md new file mode 100644 index 0000000000..844445fdb7 --- /dev/null +++ b/x/auction/README.md @@ -0,0 +1,86 @@ +# Auction + +## Summary + +We propose a new Cosmos SDK module, that will provide mechanism for protocol owned auctions. + +UX Chain will now auction a portion of collected fees and introduce a token burning mechanism, unlocking a way to a potentially deflationary UX token. + +## Rewards Auction + +Rewards Auction will auction portion of protocol collected fees against the UX token. The winner of the auction will receive the rewards, while the bid UX tokens will be burned. This mechanism offers several potential benefits, including: + +- Counter the inflation mechanism. When burn rate is higher than the staking inflation, then the token supply can go into deflation mode. +- The regular burning of UX tokens demonstrates a commitment to the long-term success of the project. +- Access to a privileged functionality: when burning UX tokens, users will access the protocol revenues. + +### Mechanism + +Burn mechanism will be implemented as a part of a new native module. The auction is composed from two phases: + +- bid collection: during this phase, everyone pledges UX tokens to auction revenues basket. At the end of this phase, the EndBlocker executes the auction and rewards the highest bidder. +- revenue collection: time when we collect revenues for each auction. The revenue collection phase for auction `a_(n+1)` starts at the end of auction `a_n`. This way, bidders know exactly the amount of revenues collected for `a_(n+1)` . + +Any UX token holder can place a bid to buy the basket. At the end of the bid collection phase we settle the auction. + +If, during a bid collection phase, we didn’t get any bid, then the revenues are rolled over to the next auction. + +```mermaid +timeline + title Auction Timelines + auction_1 revenue collection + auction_2 revenue collection: auction_1 bids + auction_3 revenue collection: auction_2 bids +``` + +### Parameters + +1. `duration` : time duration when we collect bids for the current auction. Initial value: 7 days. +2. `min_bid` is the minimum increase of the previous bid or the minimum bid if it's the +3. `auction_account`: an account receiving protocol revenues and managing the burn auction. This will be a sub-module account, and used to share with x/leverage and x/metoken modules. + +We also extend leverage and metoken params: + +1. `leverage params.rewards_auction_fee`: the interest increase that will be accrued on borrows that is sent to the auction module for the rewards auction. So, 2% means, that there is additional 2% per year fee collected. +2. `metoken params.rewards_auction_fee_factor`: determines the portion of total fees collected by the metoken module that will go for the rewards auction. 2% means that 2% of collected fees will go to the rewards auction. + +### Storage + +- `last_bid` +- `reward_auction_id` : current auction ID. +- `rewards_auction_end`: current auction end time. + +### Settlement + +The settlement of a given auction occurs when `blockTime ≥ rewards_auction_end`. If a non-zero UX bid was placed during this period (i.e. there exists a bid), the following procedure will take place: + +- The winning UX bid amount is burned. +- The basket of coins held by the auction module is transferred to the winning bidder. +- `EventRewardsAuctionResult` is emitted. +- The `last_bid` is cleared. + +Finally, we do: + +- The `reward_auction_id` is incremented by 1 and the `current_rewards_auction_end` is set to `now + auction_duration`. +- TODO: The accumulated exchange fees are transferred to the `auction` module for the new upcoming auction. + +### Collecting revenues + +#### x/leverage + +Two new x/leverage params will have to be defined (as part of the x/leverage params): + +- `leverage_revenue_rate`: We should take a fraction of the lending fees, and send it to the `auction_account` every day using x/leverage EndBlocker. + - TODO: need to think about the EndBlocker implementation or find something more efficient. + - For example, if the ATOM pool is earning 5% yield every week, we should take 1/5th of that yield ie. 1% and set it aside to be auctioned every week against UMEE (UX token) and UMEE UX will be burnt +- `LeveragePools` affected: + - This should only be applied to the largest pools: Atom, Celestia, USDC + - The logic behind this is that these are the only pools that have enough liquidity to warrant taking a fraction of the lending yield + - Smaller pools do not have enough activity to warrant taking away yield from the lenders + - additionally smaller pools do not have enough borrowers + +#### x/metoken + +All fees generated by meTokens will be allocated to the `auction_account`. + +- This is to replace the reward replacement model proposed above diff --git a/x/auction/auction.pb.go b/x/auction/auction.pb.go index fde9cfb152..a20ee31dfa 100644 --- a/x/auction/auction.pb.go +++ b/x/auction/auction.pb.go @@ -71,7 +71,7 @@ var xxx_messageInfo_RewardsParams proto.InternalMessageInfo // Bid records a user bid type Bid struct { - Bidder []byte `protobuf:"bytes,1,opt,name=bidder,proto3" json:"bidder,omitempty"` + Bidder string `protobuf:"bytes,1,opt,name=bidder,proto3" json:"bidder,omitempty"` Amount cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=cosmossdk.io/math.Int" json:"amount"` } @@ -156,33 +156,33 @@ func init() { func init() { proto.RegisterFile("umee/auction/v1/auction.proto", fileDescriptor_7a7eec280427e7e3) } var fileDescriptor_7a7eec280427e7e3 = []byte{ - // 409 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x34, 0x52, 0xc1, 0x6e, 0x13, 0x31, - 0x10, 0x5d, 0x13, 0x94, 0x80, 0x53, 0x84, 0xb4, 0x2a, 0x52, 0x1a, 0x09, 0x27, 0xe4, 0x14, 0x84, - 0x62, 0x93, 0x20, 0x21, 0x71, 0xe0, 0xd0, 0x2d, 0x12, 0xea, 0x0d, 0x2d, 0x9c, 0xb8, 0x44, 0x76, - 0x6c, 0xb6, 0x56, 0xb1, 0x5d, 0xd9, 0xde, 0x2d, 0x07, 0x6e, 0xfc, 0x40, 0x3f, 0xa6, 0x1f, 0x91, - 0x63, 0xd5, 0x13, 0xe2, 0x50, 0x20, 0xf9, 0x91, 0xca, 0x6b, 0xef, 0xed, 0xcd, 0xbc, 0x79, 0x3b, - 0x6f, 0xde, 0x1a, 0x3e, 0xaf, 0x95, 0x10, 0x84, 0xd6, 0x1b, 0x2f, 0x8d, 0x26, 0xcd, 0xb2, 0x83, - 0xf8, 0xc2, 0x1a, 0x6f, 0xf2, 0xa7, 0x81, 0xc6, 0x5d, 0xaf, 0x59, 0x8e, 0x27, 0x95, 0x31, 0xd5, - 0x77, 0x41, 0x5a, 0x9a, 0xd5, 0xdf, 0x88, 0x97, 0x4a, 0x38, 0x4f, 0xd5, 0x45, 0x54, 0x8c, 0x0f, - 0x2b, 0x53, 0x99, 0x16, 0x92, 0x80, 0x52, 0xf7, 0x68, 0x63, 0x9c, 0x32, 0x6e, 0x1d, 0x89, 0x58, - 0x24, 0x0a, 0xc5, 0x8a, 0x30, 0xea, 0x04, 0x69, 0x96, 0x4c, 0x78, 0xba, 0x24, 0x1b, 0x23, 0x93, - 0x85, 0xd9, 0x0a, 0x3e,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0x65, 0xdb, 0x1d, 0x02, 0x37, 0x3b, 0x04, 0xfe, - 0xed, 0x10, 0xb8, 0xda, 0xa3, 0xec, 0x66, 0x8f, 0xb2, 0xdf, 0x7b, 0x94, 0x7d, 0x7d, 0x59, 0x49, - 0x7f, 0x56, 0x33, 0xbc, 0x31, 0x8a, 0x84, 0x7f, 0xbc, 0xd0, 0xc2, 0x5f, 0x1a, 0x7b, 0xde, 0x16, - 0xa4, 0x79, 0x4b, 0x7e, 0x74, 0x2f, 0x81, 0xf5, 0xdb, 0x75, 0x6f, 0xee, 0x03, 0x00, 0x00, 0xff, - 0xff, 0xa0, 0x8c, 0xc4, 0xb7, 0x2b, 0x02, 0x00, 0x00, + // 407 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x34, 0x92, 0xc1, 0x6e, 0x13, 0x31, + 0x10, 0x86, 0xd7, 0x04, 0x25, 0xe0, 0x80, 0x90, 0x56, 0x45, 0x4a, 0x23, 0xe1, 0x94, 0x9c, 0x8a, + 0x50, 0x6c, 0x12, 0x24, 0x24, 0x0e, 0x1c, 0xba, 0x45, 0x42, 0xbd, 0xa1, 0x85, 0x13, 0x97, 0xc8, + 0x5e, 0x9b, 0xad, 0x55, 0x6c, 0x57, 0xb6, 0x77, 0xcb, 0x81, 0x1b, 0x2f, 0xd0, 0x87, 0xe9, 0x43, + 0xe4, 0x58, 0xf5, 0x84, 0x38, 0x04, 0x48, 0x5e, 0x04, 0x79, 0xed, 0xbd, 0xcd, 0xcc, 0x3f, 0xdf, + 0xce, 0x3f, 0xb3, 0x86, 0xcf, 0x1a, 0x25, 0x04, 0xa1, 0x4d, 0xe5, 0xa5, 0xd1, 0xa4, 0x5d, 0xf6, + 0x21, 0xbe, 0xb4, 0xc6, 0x9b, 0xfc, 0x49, 0x90, 0x71, 0x5f, 0x6b, 0x97, 0xd3, 0x59, 0x6d, 0x4c, + 0xfd, 0x4d, 0x90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 0xa4, 0x2e, 0xee, 0x87, 0x61, 0x65, + 0xdf, 0x9f, 0xbf, 0x83, 0x23, 0xa1, 0xb9, 0x5b, 0xd3, 0x68, 0x66, 0xbc, 0x9a, 0xe2, 0x78, 0x7c, + 0xdc, 0x1f, 0x1f, 0x7f, 0xee, 0x8f, 0x5f, 0x3c, 0x08, 0xec, 0xf5, 0x9f, 0x19, 0x28, 0x87, 0x01, + 0x3a, 0xf1, 0xc5, 0x87, 0xcd, 0x3f, 0x94, 0x6d, 0x76, 0x08, 0xdc, 0xee, 0x10, 0xf8, 0xbb, 0x43, + 0xe0, 0x7a, 0x8f, 0xb2, 0xdb, 0x3d, 0xca, 0x7e, 0xed, 0x51, 0xf6, 0xe5, 0x45, 0x2d, 0xfd, 0x79, + 0xc3, 0x70, 0x65, 0x14, 0x09, 0xff, 0x78, 0xa1, 0x85, 0xbf, 0x32, 0xf6, 0xa2, 0x4b, 0x48, 0xfb, + 0x86, 0x7c, 0xef, 0x5f, 0x02, 0x1b, 0x76, 0xe3, 0x5e, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, 0xc9, + 0x8c, 0x9f, 0x2d, 0x2b, 0x02, 0x00, 0x00, } func (m *RewardsParams) Marshal() (dAtA []byte, err error) { @@ -461,7 +461,7 @@ func (m *Bid) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Bidder", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAuction @@ -471,25 +471,23 @@ func (m *Bid) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAuction } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAuction } if postIndex > l { return io.ErrUnexpectedEOF } - m.Bidder = append(m.Bidder[:0], dAtA[iNdEx:postIndex]...) - if m.Bidder == nil { - m.Bidder = []byte{} - } + m.Bidder = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { diff --git a/x/auction/keeper/genesis_test.go b/x/auction/keeper/genesis_test.go index 3b2bf588d0..4e4a445e94 100644 --- a/x/auction/keeper/genesis_test.go +++ b/x/auction/keeper/genesis_test.go @@ -44,8 +44,8 @@ func TestGenesis(t *testing.T) { {4, auction.Rewards{newCoin(412313), randTime()}}, } gs.RewardsBids = []auction.BidKV{ - {1, auction.Bid{accs.Alice, sdkmath.NewInt(153252)}}, - {2, auction.Bid{accs.Alice, sdkmath.NewInt(8521)}}, + {1, auction.Bid{accs.Alice.String(), sdkmath.NewInt(153252)}}, + {2, auction.Bid{accs.Alice.String(), sdkmath.NewInt(8521)}}, } check(gs) } diff --git a/x/auction/keeper/grpc_query.go b/x/auction/keeper/grpc_query.go index 615ecfab5f..42a8e7bcf2 100644 --- a/x/auction/keeper/grpc_query.go +++ b/x/auction/keeper/grpc_query.go @@ -4,6 +4,8 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/umee-network/umee/v6/util/coin" "github.com/umee-network/umee/v6/x/auction" @@ -34,17 +36,20 @@ func (q Querier) RewardsAuction(goCtx context.Context, msg *auction.QueryRewards *auction.QueryRewardsAuctionResponse, error, ) { ctx := sdk.UnwrapSDKContext(goCtx) - bid, id := q.Keeper(&ctx).getRewardsBid(msg.Id) + k := q.Keeper(&ctx) + rewards, id := k.getRewardsAuction(msg.Id) + if rewards == nil { + return nil, status.Error(codes.NotFound, "wrong ID") + } r := &auction.QueryRewardsAuctionResponse{Id: id} + r.Rewards = rewards.Rewards + r.EndsAt = rewards.EndsAt + + bid := q.Keeper(&ctx).getRewardsBid(id) if bid != nil { - r.Bidder = sdk.AccAddress(bid.Bidder).String() + r.Bidder = bid.Bidder r.Bid = coin.UmeeInt(bid.Amount) } - rewards, _ := q.Keeper(&ctx).getRewardsAuction(msg.Id) - if rewards != nil { - r.Rewards = rewards.Rewards - r.EndsAt = rewards.EndsAt - } return r, nil } diff --git a/x/auction/keeper/rewards.go b/x/auction/keeper/rewards.go index 1ce4914c1b..ce7cce0a96 100644 --- a/x/auction/keeper/rewards.go +++ b/x/auction/keeper/rewards.go @@ -1,7 +1,6 @@ package keeper import ( - "bytes" "errors" "fmt" "strconv" @@ -9,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/umee-network/umee/v6/util" "github.com/umee-network/umee/v6/util/coin" "github.com/umee-network/umee/v6/util/sdkutil" "github.com/umee-network/umee/v6/util/store" @@ -27,10 +25,10 @@ func (k Keeper) FinalizeRewardsAuction() error { return nil } - newCoins := k.bank.GetAllBalances(*k.ctx, k.accs.RewardsCollect) - bid, _ := k.getRewardsBid(id) + bid := k.getRewardsBid(id) if bid != nil && len(bid.Bidder) != 0 { - err := k.sendCoins(k.accs.RewardsCollect, bid.Bidder, a.Rewards) + bidderAccAddr := sdk.MustAccAddressFromBech32(bid.Bidder) + err := k.sendCoins(k.accs.RewardsCollect, bidderAccAddr, a.Rewards) if err != nil { return fmt.Errorf("can't send coins to finalize the auction [%w]", err) } @@ -42,12 +40,10 @@ func (k Keeper) FinalizeRewardsAuction() error { Id: id, Bidder: sdk.AccAddress(bid.Bidder).String(), }) - } else if len(a.Rewards) != 0 { - // rollover the past rewards if there was no bidder - newCoins = newCoins.Add(a.Rewards...) } - return k.initNewAuction(id+1, newCoins) + remainingRewards := k.bank.GetAllBalances(*k.ctx, k.accs.RewardsCollect) + return k.initNewAuction(id+1, remainingRewards) } func (k Keeper) initNewAuction(id uint32, rewards sdk.Coins) error { @@ -79,40 +75,40 @@ func (k Keeper) rewardsBid(msg *auction.MsgRewardsBid) error { return err } - sender, err := sdk.AccAddressFromBech32(msg.Sender) - util.Panic(err) - - if !bytes.Equal(sender, lastBid.Bidder) { - returned := coin.UmeeInt(lastBid.Amount) - if err = k.sendFromModule(lastBid.Bidder, returned); err != nil { - return err - } - if err = k.sendToModule(sender, msg.Amount); err != nil { - return err - } - } else { - diff := msg.Amount.SubAmount(lastBid.Amount) - if err = k.sendToModule(sender, diff); err != nil { - return err + toAuction := msg.Amount + if lastBid != nil { + if msg.Sender == lastBid.Bidder { + // bidder updates his last bid: send only diff + toAuction = msg.Amount.SubAmount(lastBid.Amount) + } else { + returned := coin.UmeeInt(lastBid.Amount) + bidderAccAddr := sdk.MustAccAddressFromBech32(lastBid.Bidder) + if err := k.sendFromModule(bidderAccAddr, returned); err != nil { + return err + } } } - bid := auction.Bid{Bidder: sender, Amount: msg.Amount.Amount} + sender := sdk.MustAccAddressFromBech32(msg.Sender) + if err := k.sendToModule(sender, toAuction); err != nil { + return err + } + + bid := auction.Bid{Bidder: msg.Sender, Amount: msg.Amount.Amount} return store.SetValue(k.store, key, &bid, keyMsg) } -func (k Keeper) getRewardsBid(id uint32) (*auction.Bid, uint32) { +func (k Keeper) getRewardsBid(id uint32) *auction.Bid { if id == 0 { id = k.currentRewardsAuctionID() } keyMsg := "auction.rewards.bid" key := k.keyRewardsBid(id) - return store.GetValue[*auction.Bid](k.store, key, keyMsg), id + return store.GetValue[*auction.Bid](k.store, key, keyMsg) } func (k Keeper) getAllRewardsBids() ([]auction.BidKV, error) { - elems, err := store.LoadAllKV[*store.Uint32, store.Uint32, *auction.Bid]( - k.store, keyPrefixRewardsBid) + elems, err := store.LoadAllKV[*store.Uint32, store.Uint32, *auction.Bid](k.store, keyPrefixRewardsBid) if err != nil { return nil, err } @@ -122,7 +118,6 @@ func (k Keeper) getAllRewardsBids() ([]auction.BidKV, error) { bids[i].Bid = elems[i].Val } return bids, nil - } func (k Keeper) storeAllRewardsBids(elems []auction.BidKV) error { diff --git a/x/auction/module/genesis.go b/x/auction/module/genesis.go deleted file mode 100644 index 4abed50fa0..0000000000 --- a/x/auction/module/genesis.go +++ /dev/null @@ -1,19 +0,0 @@ -package module - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/umee-network/umee/v6/x/incentive" - "github.com/umee-network/umee/v6/x/incentive/keeper" -) - -// InitGenesis initializes the x/incentive module's state from a provided genesis -// state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState incentive.GenesisState) { - k.InitGenesis(ctx, genState) -} - -// ExportGenesis returns the x/incentive module's exported genesis state. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *incentive.GenesisState { - return k.ExportGenesis(ctx) -} diff --git a/x/auction/query.pb.go b/x/auction/query.pb.go index 4eeb13a82e..82ec58f5ee 100644 --- a/x/auction/query.pb.go +++ b/x/auction/query.pb.go @@ -6,6 +6,7 @@ package auction import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -201,38 +202,40 @@ func init() { func init() { proto.RegisterFile("umee/auction/v1/query.proto", fileDescriptor_e1df854d377e58e5) } var fileDescriptor_e1df854d377e58e5 = []byte{ - // 485 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x3f, 0x6f, 0xd4, 0x30, - 0x1c, 0x8d, 0x73, 0xed, 0x15, 0x8c, 0x5a, 0x24, 0x53, 0xa1, 0x90, 0x82, 0xef, 0x08, 0x20, 0x8a, - 0x00, 0x5b, 0x29, 0x12, 0x12, 0x12, 0x0c, 0x3d, 0x06, 0x56, 0x88, 0x98, 0xba, 0x20, 0xe7, 0x62, - 0x82, 0x05, 0x89, 0x43, 0xec, 0x5c, 0x61, 0x65, 0x60, 0x60, 0xaa, 0xc4, 0xcc, 0xf7, 0xb9, 0xb1, - 0x12, 0x0b, 0x13, 0x7f, 0xee, 0xf8, 0x04, 0x7c, 0x02, 0x14, 0xc7, 0xa9, 0xb8, 0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, 0x8e, 0x9d, 0x83, 0x1b, 0xa9, 0xd0, 0x2f, 0xaa, 0x98, - 0x8c, 0x65, 0x66, 0x26, 0xdc, 0xce, 0xb9, 0x3e, 0x94, 0xe5, 0xcb, 0x66, 0xdc, 0xe4, 0x2e, 0x7d, - 0xd3, 0xce, 0x8c, 0xfb, 0xa6, 0x8e, 0x3b, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xda, 0xf4, 0x09, - 0x57, 0xc1, 0x03, 0x00, 0x00, + // 513 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0xb6, 0x9d, 0x36, 0x85, 0x43, 0x2d, 0xd2, 0x91, 0xc1, 0x75, 0xc1, 0x09, 0x06, 0x44, 0x11, + 0xf4, 0x0e, 0x17, 0x09, 0x09, 0x09, 0x86, 0x84, 0x81, 0x15, 0x0c, 0x53, 0x97, 0xea, 0x1c, 0x1f, + 0xe6, 0x04, 0xf6, 0x19, 0xdf, 0x39, 0x85, 0x95, 0x81, 0x01, 0x31, 0x54, 0x62, 0xe6, 0xbf, 0xe0, + 0x8f, 0xc8, 0x58, 0xc1, 0xc2, 0xc4, 0x8f, 0x84, 0x3f, 0x04, 0xf9, 0xee, 0x5c, 0x51, 0x07, 0x50, + 0x36, 0xfb, 0x7d, 0xdf, 0xf7, 0xee, 0x7b, 0xdf, 0x7b, 0x60, 0xab, 0xca, 0x28, 0xc5, 0xa4, 0x1a, + 0x4b, 0xc6, 0x73, 0x3c, 0x09, 0xf1, 0xcb, 0x8a, 0x96, 0xaf, 0x51, 0x51, 0x72, 0xc9, 0xe1, 0xd9, + 0x1a, 0x44, 0x06, 0x44, 0x93, 0xd0, 0xeb, 0xa7, 0x9c, 0xa7, 0x2f, 0x28, 0x56, 0x70, 0x5c, 0x3d, + 0xc5, 0x92, 0x65, 0x54, 0x48, 0x92,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ab, + 0xd6, 0x71, 0xeb, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb6, 0x0a, 0x81, 0x58, 0xf6, 0x03, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/leverage/keeper/oracle.go b/x/leverage/keeper/oracle.go index 872f0a7b2b..88274c1530 100644 --- a/x/leverage/keeper/oracle.go +++ b/x/leverage/keeper/oracle.go @@ -297,7 +297,7 @@ func (k Keeper) fundModules(ctx sdk.Context, toOracle, toAuction sdk.Coins) erro } if !toAuctionCheck.IsZero() { auction.EmitFundRewardsAuction(&ctx, toOracleCheck) - return send(ctx, types.ModuleName, auction.ModuleName, toAuctionCheck) + return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, k.rewardsAuction, toAuctionCheck) } return nil diff --git a/x/uibc/README.md b/x/uibc/README.md index e61039d39a..7611fcfd4c 100644 --- a/x/uibc/README.md +++ b/x/uibc/README.md @@ -1,6 +1,6 @@ # IBC Transfer and Rate Limits for IBC Denoms -## Abstract +## Summary The `x/uibc` is a Cosmos Module providing: