mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-11-04 09:57:27 +00:00 
			
		
		
		
	remove slightly unecessary ID type
This commit is contained in:
		
							parent
							
								
									db3c39aaa5
								
							
						
					
					
						commit
						983de010df
					
				@ -7,8 +7,8 @@ import (
 | 
				
			|||||||
// EndBlocker runs at the end of every block.
 | 
					// EndBlocker runs at the end of every block.
 | 
				
			||||||
func EndBlocker(ctx sdk.Context, k Keeper) {
 | 
					func EndBlocker(ctx sdk.Context, k Keeper) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var expiredAuctions []ID
 | 
						var expiredAuctions []uint64
 | 
				
			||||||
	k.IterateAuctionsByTime(ctx, ctx.BlockTime(), func(id ID) bool {
 | 
						k.IterateAuctionsByTime(ctx, ctx.BlockTime(), func(id uint64) bool {
 | 
				
			||||||
		expiredAuctions = append(expiredAuctions, id)
 | 
							expiredAuctions = append(expiredAuctions, id)
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,6 @@ const (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	// functions aliases
 | 
						// functions aliases
 | 
				
			||||||
	NewIDFromString          = types.NewIDFromString
 | 
					 | 
				
			||||||
	NewForwardAuction        = types.NewForwardAuction
 | 
						NewForwardAuction        = types.NewForwardAuction
 | 
				
			||||||
	NewReverseAuction        = types.NewReverseAuction
 | 
						NewReverseAuction        = types.NewReverseAuction
 | 
				
			||||||
	NewForwardReverseAuction = types.NewForwardReverseAuction
 | 
						NewForwardReverseAuction = types.NewForwardReverseAuction
 | 
				
			||||||
@ -46,7 +45,6 @@ var (
 | 
				
			|||||||
type (
 | 
					type (
 | 
				
			||||||
	Auction               = types.Auction
 | 
						Auction               = types.Auction
 | 
				
			||||||
	BaseAuction           = types.BaseAuction
 | 
						BaseAuction           = types.BaseAuction
 | 
				
			||||||
	ID                    = types.ID
 | 
					 | 
				
			||||||
	ForwardAuction        = types.ForwardAuction
 | 
						ForwardAuction        = types.ForwardAuction
 | 
				
			||||||
	ReverseAuction        = types.ReverseAuction
 | 
						ReverseAuction        = types.ReverseAuction
 | 
				
			||||||
	ForwardReverseAuction = types.ForwardReverseAuction
 | 
						ForwardReverseAuction = types.ForwardReverseAuction
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,7 @@ package cli
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/kava-labs/kava/x/auction/types"
 | 
						"github.com/kava-labs/kava/x/auction/types"
 | 
				
			||||||
	"github.com/spf13/cobra"
 | 
						"github.com/spf13/cobra"
 | 
				
			||||||
@ -39,7 +40,7 @@ func GetCmdPlaceBid(cdc *codec.Codec) *cobra.Command {
 | 
				
			|||||||
			cliCtx := context.NewCLIContext().WithCodec(cdc)
 | 
								cliCtx := context.NewCLIContext().WithCodec(cdc)
 | 
				
			||||||
			txBldr := auth.NewTxBuilderFromCLI().WithTxEncoder(utils.GetTxEncoder(cdc))
 | 
								txBldr := auth.NewTxBuilderFromCLI().WithTxEncoder(utils.GetTxEncoder(cdc))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			id, err := types.NewIDFromString(args[0])
 | 
								id, err := strconv.ParseUint(args[0], 10, 64)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				fmt.Printf("invalid auction id - %s \n", string(args[0]))
 | 
									fmt.Printf("invalid auction id - %s \n", string(args[0]))
 | 
				
			||||||
				return err
 | 
									return err
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,7 @@ import (
 | 
				
			|||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/gorilla/mux"
 | 
						"github.com/gorilla/mux"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -45,7 +46,7 @@ func bidHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
 | 
				
			|||||||
		strBid := vars[restBid]
 | 
							strBid := vars[restBid]
 | 
				
			||||||
		strLot := vars[restLot]
 | 
							strLot := vars[restLot]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		auctionID, err := types.NewIDFromString(strAuctionID)
 | 
							auctionID, err := strconv.ParseUint(strAuctionID, 10, 64)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
 | 
								rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StartForwardAuction starts a normal auction that mints the sold coins.
 | 
					// StartForwardAuction starts a normal auction that mints the sold coins.
 | 
				
			||||||
func (k Keeper) StartForwardAuction(ctx sdk.Context, seller string, lot sdk.Coin, bidDenom string) (types.ID, sdk.Error) {
 | 
					func (k Keeper) StartForwardAuction(ctx sdk.Context, seller string, lot sdk.Coin, bidDenom string) (uint64, sdk.Error) {
 | 
				
			||||||
	// create auction
 | 
						// create auction
 | 
				
			||||||
	auction := types.NewForwardAuction(seller, lot, bidDenom, ctx.BlockTime().Add(types.DefaultMaxAuctionDuration))
 | 
						auction := types.NewForwardAuction(seller, lot, bidDenom, ctx.BlockTime().Add(types.DefaultMaxAuctionDuration))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -28,7 +28,7 @@ func (k Keeper) StartForwardAuction(ctx sdk.Context, seller string, lot sdk.Coin
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StartReverseAuction starts an auction where sellers compete by offering decreasing prices.
 | 
					// StartReverseAuction starts an auction where sellers compete by offering decreasing prices.
 | 
				
			||||||
func (k Keeper) StartReverseAuction(ctx sdk.Context, buyer string, bid sdk.Coin, initialLot sdk.Coin) (types.ID, sdk.Error) {
 | 
					func (k Keeper) StartReverseAuction(ctx sdk.Context, buyer string, bid sdk.Coin, initialLot sdk.Coin) (uint64, sdk.Error) {
 | 
				
			||||||
	// create auction
 | 
						// create auction
 | 
				
			||||||
	auction := types.NewReverseAuction(buyer, bid, initialLot, ctx.BlockTime().Add(types.DefaultMaxAuctionDuration))
 | 
						auction := types.NewReverseAuction(buyer, bid, initialLot, ctx.BlockTime().Add(types.DefaultMaxAuctionDuration))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -46,7 +46,7 @@ func (k Keeper) StartReverseAuction(ctx sdk.Context, buyer string, bid sdk.Coin,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StartForwardReverseAuction starts an auction where bidders bid up to a maxBid, then switch to bidding down on price.
 | 
					// StartForwardReverseAuction starts an auction where bidders bid up to a maxBid, then switch to bidding down on price.
 | 
				
			||||||
func (k Keeper) StartForwardReverseAuction(ctx sdk.Context, seller string, lot sdk.Coin, maxBid sdk.Coin, lotReturnAddrs []sdk.AccAddress, lotReturnWeights []sdk.Int) (types.ID, sdk.Error) {
 | 
					func (k Keeper) StartForwardReverseAuction(ctx sdk.Context, seller string, lot sdk.Coin, maxBid sdk.Coin, lotReturnAddrs []sdk.AccAddress, lotReturnWeights []sdk.Int) (uint64, sdk.Error) {
 | 
				
			||||||
	// create auction
 | 
						// create auction
 | 
				
			||||||
	weightedAddresses, err := types.NewWeightedAddresses(lotReturnAddrs, lotReturnWeights)
 | 
						weightedAddresses, err := types.NewWeightedAddresses(lotReturnAddrs, lotReturnWeights)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
@ -69,7 +69,7 @@ func (k Keeper) StartForwardReverseAuction(ctx sdk.Context, seller string, lot s
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// PlaceBid places a bid on any auction.
 | 
					// PlaceBid places a bid on any auction.
 | 
				
			||||||
// TODO passing bid and lot is weird when only one needed
 | 
					// TODO passing bid and lot is weird when only one needed
 | 
				
			||||||
func (k Keeper) PlaceBid(ctx sdk.Context, auctionID types.ID, bidder sdk.AccAddress, bid sdk.Coin, lot sdk.Coin) sdk.Error {
 | 
					func (k Keeper) PlaceBid(ctx sdk.Context, auctionID uint64, bidder sdk.AccAddress, bid sdk.Coin, lot sdk.Coin) sdk.Error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// get auction from store
 | 
						// get auction from store
 | 
				
			||||||
	auction, found := k.GetAuction(ctx, auctionID)
 | 
						auction, found := k.GetAuction(ctx, auctionID)
 | 
				
			||||||
@ -261,7 +261,7 @@ func (k Keeper) PlaceBidReverse(ctx sdk.Context, a types.ReverseAuction, bidder
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CloseAuction closes an auction and distributes funds to the highest bidder.
 | 
					// CloseAuction closes an auction and distributes funds to the highest bidder.
 | 
				
			||||||
func (k Keeper) CloseAuction(ctx sdk.Context, auctionID types.ID) sdk.Error {
 | 
					func (k Keeper) CloseAuction(ctx sdk.Context, auctionID uint64) sdk.Error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// get the auction from the store
 | 
						// get the auction from the store
 | 
				
			||||||
	auction, found := k.GetAuction(ctx, auctionID)
 | 
						auction, found := k.GetAuction(ctx, auctionID)
 | 
				
			||||||
 | 
				
			|||||||
@ -220,7 +220,7 @@ func TestStartForwardAuction(t *testing.T) {
 | 
				
			|||||||
				// check auction in store and is correct
 | 
									// check auction in store and is correct
 | 
				
			||||||
				require.True(t, found)
 | 
									require.True(t, found)
 | 
				
			||||||
				expectedAuction := types.Auction(types.ForwardAuction{BaseAuction: types.BaseAuction{
 | 
									expectedAuction := types.Auction(types.ForwardAuction{BaseAuction: types.BaseAuction{
 | 
				
			||||||
					ID:         types.ID(0),
 | 
										ID:         0,
 | 
				
			||||||
					Initiator:  tc.args.seller,
 | 
										Initiator:  tc.args.seller,
 | 
				
			||||||
					Lot:        tc.args.lot,
 | 
										Lot:        tc.args.lot,
 | 
				
			||||||
					Bidder:     nil,
 | 
										Bidder:     nil,
 | 
				
			||||||
 | 
				
			|||||||
@ -30,21 +30,21 @@ func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, supplyKeeper types.Suppl
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SetNextAuctionID stores an ID to be used for the next created auction
 | 
					// SetNextAuctionID stores an ID to be used for the next created auction
 | 
				
			||||||
func (k Keeper) SetNextAuctionID(ctx sdk.Context, id types.ID) {
 | 
					func (k Keeper) SetNextAuctionID(ctx sdk.Context, id uint64) {
 | 
				
			||||||
	store := ctx.KVStore(k.storeKey)
 | 
						store := ctx.KVStore(k.storeKey)
 | 
				
			||||||
	store.Set(types.NextAuctionIDKey, id.Bytes())
 | 
						store.Set(types.NextAuctionIDKey, types.Uint64ToBytes(id))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetNextAuctionID reads the next available global ID from store
 | 
					// GetNextAuctionID reads the next available global ID from store
 | 
				
			||||||
// TODO might be nicer to convert not found error to a panic, it's not an error that can be recovered from
 | 
					// TODO might be nicer to convert not found error to a panic, it's not an error that can be recovered from
 | 
				
			||||||
func (k Keeper) GetNextAuctionID(ctx sdk.Context) (types.ID, sdk.Error) {
 | 
					func (k Keeper) GetNextAuctionID(ctx sdk.Context) (uint64, sdk.Error) {
 | 
				
			||||||
	store := ctx.KVStore(k.storeKey)
 | 
						store := ctx.KVStore(k.storeKey)
 | 
				
			||||||
	bz := store.Get(types.NextAuctionIDKey)
 | 
						bz := store.Get(types.NextAuctionIDKey)
 | 
				
			||||||
	if bz == nil {
 | 
						if bz == nil {
 | 
				
			||||||
		//return 0, types.ErrInvalidGenesis(k.codespace, "initial auction ID hasn't been set") // TODO create error
 | 
							//return 0, types.ErrInvalidGenesis(k.codespace, "initial auction ID hasn't been set") // TODO create error
 | 
				
			||||||
		return 0, sdk.ErrInternal("initial auction ID hasn't been set")
 | 
							return 0, sdk.ErrInternal("initial auction ID hasn't been set")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return types.NewIDFromBytes(bz), nil
 | 
						return types.Uint64FromBytes(bz), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// incrementNextAuctionID increments the global ID in the store by 1
 | 
					// incrementNextAuctionID increments the global ID in the store by 1
 | 
				
			||||||
@ -58,7 +58,7 @@ func (k Keeper) IncrementNextAuctionID(ctx sdk.Context) sdk.Error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StoreNewAuction stores an auction, adding a new ID
 | 
					// StoreNewAuction stores an auction, adding a new ID
 | 
				
			||||||
func (k Keeper) StoreNewAuction(ctx sdk.Context, auction types.Auction) (types.ID, sdk.Error) {
 | 
					func (k Keeper) StoreNewAuction(ctx sdk.Context, auction types.Auction) (uint64, sdk.Error) {
 | 
				
			||||||
	newAuctionID, err := k.GetNextAuctionID(ctx)
 | 
						newAuctionID, err := k.GetNextAuctionID(ctx)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
@ -93,7 +93,7 @@ func (k Keeper) SetAuction(ctx sdk.Context, auction types.Auction) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// getAuction gets an auction from the store by auctionID
 | 
					// getAuction gets an auction from the store by auctionID
 | 
				
			||||||
func (k Keeper) GetAuction(ctx sdk.Context, auctionID types.ID) (types.Auction, bool) {
 | 
					func (k Keeper) GetAuction(ctx sdk.Context, auctionID uint64) (types.Auction, bool) {
 | 
				
			||||||
	var auction types.Auction
 | 
						var auction types.Auction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionKeyPrefix)
 | 
						store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionKeyPrefix)
 | 
				
			||||||
@ -107,7 +107,7 @@ func (k Keeper) GetAuction(ctx sdk.Context, auctionID types.ID) (types.Auction,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DeleteAuction removes an auction from the store without any validation
 | 
					// DeleteAuction removes an auction from the store without any validation
 | 
				
			||||||
func (k Keeper) DeleteAuction(ctx sdk.Context, auctionID types.ID) {
 | 
					func (k Keeper) DeleteAuction(ctx sdk.Context, auctionID uint64) {
 | 
				
			||||||
	// remove from index
 | 
						// remove from index
 | 
				
			||||||
	auction, found := k.GetAuction(ctx, auctionID)
 | 
						auction, found := k.GetAuction(ctx, auctionID)
 | 
				
			||||||
	if found {
 | 
						if found {
 | 
				
			||||||
@ -120,13 +120,13 @@ func (k Keeper) DeleteAuction(ctx sdk.Context, auctionID types.ID) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// InsertIntoIndex adds an auction ID and end time into the byTime index
 | 
					// InsertIntoIndex adds an auction ID and end time into the byTime index
 | 
				
			||||||
func (k Keeper) InsertIntoIndex(ctx sdk.Context, endTime time.Time, auctionID types.ID) {
 | 
					func (k Keeper) InsertIntoIndex(ctx sdk.Context, endTime time.Time, auctionID uint64) {
 | 
				
			||||||
	store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
 | 
						store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
 | 
				
			||||||
	store.Set(types.GetAuctionByTimeKey(endTime, auctionID), auctionID.Bytes())
 | 
						store.Set(types.GetAuctionByTimeKey(endTime, auctionID), types.Uint64ToBytes(auctionID)) // TODO
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RemoveFromIndex removes an auction ID and end time from the byTime index
 | 
					// RemoveFromIndex removes an auction ID and end time from the byTime index
 | 
				
			||||||
func (k Keeper) RemoveFromIndex(ctx sdk.Context, endTime time.Time, auctionID types.ID) {
 | 
					func (k Keeper) RemoveFromIndex(ctx sdk.Context, endTime time.Time, auctionID uint64) {
 | 
				
			||||||
	store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
 | 
						store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
 | 
				
			||||||
	store.Delete(types.GetAuctionByTimeKey(endTime, auctionID))
 | 
						store.Delete(types.GetAuctionByTimeKey(endTime, auctionID))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -134,7 +134,7 @@ func (k Keeper) RemoveFromIndex(ctx sdk.Context, endTime time.Time, auctionID ty
 | 
				
			|||||||
// IterateAuctionByTime provides an iterator over auctions ordered by auction.EndTime.
 | 
					// IterateAuctionByTime provides an iterator over auctions ordered by auction.EndTime.
 | 
				
			||||||
// For each auction cb will be callled. If cb returns true the iterator will close and stop.
 | 
					// For each auction cb will be callled. If cb returns true the iterator will close and stop.
 | 
				
			||||||
// TODO can the cutoff time be removed in favour of caller specifying cutoffs in the callback?
 | 
					// TODO can the cutoff time be removed in favour of caller specifying cutoffs in the callback?
 | 
				
			||||||
func (k Keeper) IterateAuctionsByTime(ctx sdk.Context, inclusiveCutoffTime time.Time, cb func(auctionID types.ID) (stop bool)) {
 | 
					func (k Keeper) IterateAuctionsByTime(ctx sdk.Context, inclusiveCutoffTime time.Time, cb func(auctionID uint64) (stop bool)) {
 | 
				
			||||||
	store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
 | 
						store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AuctionByTimeKeyPrefix)
 | 
				
			||||||
	iterator := store.Iterator(
 | 
						iterator := store.Iterator(
 | 
				
			||||||
		nil, // start at the very start of the prefix store
 | 
							nil, // start at the very start of the prefix store
 | 
				
			||||||
@ -144,7 +144,7 @@ func (k Keeper) IterateAuctionsByTime(ctx sdk.Context, inclusiveCutoffTime time.
 | 
				
			|||||||
	defer iterator.Close()
 | 
						defer iterator.Close()
 | 
				
			||||||
	for ; iterator.Valid(); iterator.Next() {
 | 
						for ; iterator.Valid(); iterator.Next() {
 | 
				
			||||||
		// TODO get the auction ID - either read from store, or extract from key
 | 
							// TODO get the auction ID - either read from store, or extract from key
 | 
				
			||||||
		auctionID := types.NewIDFromBytes(iterator.Value())
 | 
							auctionID := types.Uint64FromBytes(iterator.Value())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if cb(auctionID) {
 | 
							if cb(auctionID) {
 | 
				
			||||||
			break
 | 
								break
 | 
				
			||||||
 | 
				
			|||||||
@ -17,7 +17,7 @@ func SetGetDeleteAuction(t *testing.T) {
 | 
				
			|||||||
	keeper := tApp.GetAuctionKeeper()
 | 
						keeper := tApp.GetAuctionKeeper()
 | 
				
			||||||
	ctx := tApp.NewContext(true, abci.Header{})
 | 
						ctx := tApp.NewContext(true, abci.Header{})
 | 
				
			||||||
	someTime := time.Date(43, time.January, 1, 0, 0, 0, 0, time.UTC) // need to specify UTC as tz info is lost on unmarshal
 | 
						someTime := time.Date(43, time.January, 1, 0, 0, 0, 0, time.UTC) // need to specify UTC as tz info is lost on unmarshal
 | 
				
			||||||
	id := types.ID(5)
 | 
						var id uint64 = 5
 | 
				
			||||||
	auction := types.NewForwardAuction("some_module", c("usdx", 100), "kava", someTime).WithID(id)
 | 
						auction := types.NewForwardAuction("some_module", c("usdx", 100), "kava", someTime).WithID(id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// write and read from store
 | 
						// write and read from store
 | 
				
			||||||
@ -28,7 +28,7 @@ func SetGetDeleteAuction(t *testing.T) {
 | 
				
			|||||||
	require.True(t, found)
 | 
						require.True(t, found)
 | 
				
			||||||
	require.Equal(t, auction, readAuction)
 | 
						require.Equal(t, auction, readAuction)
 | 
				
			||||||
	// check auction is in the index
 | 
						// check auction is in the index
 | 
				
			||||||
	keeper.IterateAuctionsByTime(ctx, auction.GetEndTime(), func(readID types.ID) bool {
 | 
						keeper.IterateAuctionsByTime(ctx, auction.GetEndTime(), func(readID uint64) bool {
 | 
				
			||||||
		require.Equal(t, auction.GetID(), readID)
 | 
							require.Equal(t, auction.GetID(), readID)
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
@ -40,7 +40,7 @@ func SetGetDeleteAuction(t *testing.T) {
 | 
				
			|||||||
	_, found = keeper.GetAuction(ctx, id)
 | 
						_, found = keeper.GetAuction(ctx, id)
 | 
				
			||||||
	require.False(t, found)
 | 
						require.False(t, found)
 | 
				
			||||||
	// check auction not in index
 | 
						// check auction not in index
 | 
				
			||||||
	keeper.IterateAuctionsByTime(ctx, time.Unix(999999999, 0), func(readID types.ID) bool {
 | 
						keeper.IterateAuctionsByTime(ctx, time.Unix(999999999, 0), func(readID uint64) bool {
 | 
				
			||||||
		require.Fail(t, "index should be empty", " found auction ID '%s", readID)
 | 
							require.Fail(t, "index should be empty", " found auction ID '%s", readID)
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
@ -53,7 +53,7 @@ func TestIncrementNextAuctionID(t *testing.T) {
 | 
				
			|||||||
	ctx := tApp.NewContext(true, abci.Header{})
 | 
						ctx := tApp.NewContext(true, abci.Header{})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// store id
 | 
						// store id
 | 
				
			||||||
	id := types.ID(123456)
 | 
						var id uint64 = 123456
 | 
				
			||||||
	keeper.SetNextAuctionID(ctx, id)
 | 
						keeper.SetNextAuctionID(ctx, id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	require.NoError(t, keeper.IncrementNextAuctionID(ctx))
 | 
						require.NoError(t, keeper.IncrementNextAuctionID(ctx))
 | 
				
			||||||
@ -101,7 +101,7 @@ func TestIterateAuctionsByTime(t *testing.T) {
 | 
				
			|||||||
	// setup byTime index
 | 
						// setup byTime index
 | 
				
			||||||
	byTimeIndex := []struct {
 | 
						byTimeIndex := []struct {
 | 
				
			||||||
		endTime   time.Time
 | 
							endTime   time.Time
 | 
				
			||||||
		auctionID types.ID
 | 
							auctionID uint64
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{time.Date(0, time.January, 1, 0, 0, 0, 0, time.UTC), 9999},            // distant past
 | 
							{time.Date(0, time.January, 1, 0, 0, 0, 0, time.UTC), 9999},            // distant past
 | 
				
			||||||
		{time.Date(1998, time.January, 1, 11, 59, 59, 999999999, time.UTC), 1}, // just before cutoff
 | 
							{time.Date(1998, time.January, 1, 11, 59, 59, 999999999, time.UTC), 1}, // just before cutoff
 | 
				
			||||||
@ -118,15 +118,15 @@ func TestIterateAuctionsByTime(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// read out values from index up to a cutoff time and check they are as expected
 | 
						// read out values from index up to a cutoff time and check they are as expected
 | 
				
			||||||
	cutoffTime := time.Date(1998, time.January, 1, 12, 0, 0, 0, time.UTC)
 | 
						cutoffTime := time.Date(1998, time.January, 1, 12, 0, 0, 0, time.UTC)
 | 
				
			||||||
	var expectedIndex []types.ID
 | 
						var expectedIndex []uint64
 | 
				
			||||||
	for _, v := range byTimeIndex {
 | 
						for _, v := range byTimeIndex {
 | 
				
			||||||
		if v.endTime.Before(cutoffTime) || v.endTime.Equal(cutoffTime) { // endTime ≤ cutoffTime
 | 
							if v.endTime.Before(cutoffTime) || v.endTime.Equal(cutoffTime) { // endTime ≤ cutoffTime
 | 
				
			||||||
			expectedIndex = append(expectedIndex, v.auctionID)
 | 
								expectedIndex = append(expectedIndex, v.auctionID)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	var readIndex []types.ID
 | 
						var readIndex []uint64
 | 
				
			||||||
	keeper.IterateAuctionsByTime(ctx, cutoffTime, func(id types.ID) bool {
 | 
						keeper.IterateAuctionsByTime(ctx, cutoffTime, func(id uint64) bool {
 | 
				
			||||||
		readIndex = append(readIndex, id)
 | 
							readIndex = append(readIndex, id)
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
				
			|||||||
@ -1,41 +1,17 @@
 | 
				
			|||||||
package types
 | 
					package types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"encoding/binary"
 | 
					 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"strconv"
 | 
					 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sdk "github.com/cosmos/cosmos-sdk/types"
 | 
						sdk "github.com/cosmos/cosmos-sdk/types"
 | 
				
			||||||
	"github.com/cosmos/cosmos-sdk/x/supply"
 | 
						"github.com/cosmos/cosmos-sdk/x/supply"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ID type for auction IDs
 | 
					 | 
				
			||||||
type ID uint64
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// TODO can this be removed?
 | 
					 | 
				
			||||||
// NewIDFromString generate new auction ID from a string
 | 
					 | 
				
			||||||
func NewIDFromString(s string) (ID, error) {
 | 
					 | 
				
			||||||
	n, err := strconv.ParseUint(s, 10, 64) // copied from how the gov module rest handler's parse proposal IDs
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return 0, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return ID(n), nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
func NewIDFromBytes(bz []byte) ID {
 | 
					 | 
				
			||||||
	return ID(binary.BigEndian.Uint64(bz))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
func (id ID) Bytes() []byte {
 | 
					 | 
				
			||||||
	bz := make([]byte, 8)
 | 
					 | 
				
			||||||
	binary.BigEndian.PutUint64(bz, uint64(id))
 | 
					 | 
				
			||||||
	return bz
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Auction is an interface to several types of auction.
 | 
					// Auction is an interface to several types of auction.
 | 
				
			||||||
type Auction interface {
 | 
					type Auction interface {
 | 
				
			||||||
	GetID() ID
 | 
						GetID() uint64
 | 
				
			||||||
	WithID(ID) Auction
 | 
						WithID(uint64) Auction
 | 
				
			||||||
	GetBidder() sdk.AccAddress
 | 
						GetBidder() sdk.AccAddress
 | 
				
			||||||
	GetBid() sdk.Coin
 | 
						GetBid() sdk.Coin
 | 
				
			||||||
	GetLot() sdk.Coin
 | 
						GetLot() sdk.Coin
 | 
				
			||||||
@ -44,7 +20,7 @@ type Auction interface {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// BaseAuction type shared by all Auctions
 | 
					// BaseAuction type shared by all Auctions
 | 
				
			||||||
type BaseAuction struct {
 | 
					type BaseAuction struct {
 | 
				
			||||||
	ID         ID
 | 
						ID         uint64
 | 
				
			||||||
	Initiator  string         // Module that starts the auction. Giving away Lot (aka seller in a forward auction). Restricted to being a module account name rather than any account.
 | 
						Initiator  string         // Module that starts the auction. Giving away Lot (aka seller in a forward auction). Restricted to being a module account name rather than any account.
 | 
				
			||||||
	Lot        sdk.Coin       // Amount of coins up being given by initiator (FA - amount for sale by seller, RA - cost of good by buyer (bid))
 | 
						Lot        sdk.Coin       // Amount of coins up being given by initiator (FA - amount for sale by seller, RA - cost of good by buyer (bid))
 | 
				
			||||||
	Bidder     sdk.AccAddress // Person who bids in the auction. Receiver of Lot. (aka buyer in forward auction, seller in RA)
 | 
						Bidder     sdk.AccAddress // Person who bids in the auction. Receiver of Lot. (aka buyer in forward auction, seller in RA)
 | 
				
			||||||
@ -54,7 +30,7 @@ type BaseAuction struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetID getter for auction ID
 | 
					// GetID getter for auction ID
 | 
				
			||||||
func (a BaseAuction) GetID() ID { return a.ID }
 | 
					func (a BaseAuction) GetID() uint64 { return a.ID }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetBid getter for auction bid
 | 
					// GetBid getter for auction bid
 | 
				
			||||||
func (a BaseAuction) GetBidder() sdk.AccAddress { return a.Bidder }
 | 
					func (a BaseAuction) GetBidder() sdk.AccAddress { return a.Bidder }
 | 
				
			||||||
@ -88,7 +64,7 @@ type ForwardAuction struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WithID returns an auction with the ID set
 | 
					// WithID returns an auction with the ID set
 | 
				
			||||||
func (a ForwardAuction) WithID(id ID) Auction { a.ID = id; return a }
 | 
					func (a ForwardAuction) WithID(id uint64) Auction { a.ID = id; return a }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewForwardAuction creates a new forward auction
 | 
					// NewForwardAuction creates a new forward auction
 | 
				
			||||||
func NewForwardAuction(seller string, lot sdk.Coin, bidDenom string, endTime time.Time) ForwardAuction {
 | 
					func NewForwardAuction(seller string, lot sdk.Coin, bidDenom string, endTime time.Time) ForwardAuction {
 | 
				
			||||||
@ -110,7 +86,7 @@ type ReverseAuction struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WithID returns an auction with the ID set
 | 
					// WithID returns an auction with the ID set
 | 
				
			||||||
func (a ReverseAuction) WithID(id ID) Auction { a.ID = id; return a }
 | 
					func (a ReverseAuction) WithID(id uint64) Auction { a.ID = id; return a }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewReverseAuction creates a new reverse auction
 | 
					// NewReverseAuction creates a new reverse auction
 | 
				
			||||||
func NewReverseAuction(buyerModAccName string, bid sdk.Coin, initialLot sdk.Coin, EndTime time.Time) ReverseAuction {
 | 
					func NewReverseAuction(buyerModAccName string, bid sdk.Coin, initialLot sdk.Coin, EndTime time.Time) ReverseAuction {
 | 
				
			||||||
@ -138,7 +114,7 @@ type ForwardReverseAuction struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WithID returns an auction with the ID set
 | 
					// WithID returns an auction with the ID set
 | 
				
			||||||
func (a ForwardReverseAuction) WithID(id ID) Auction { a.ID = id; return a }
 | 
					func (a ForwardReverseAuction) WithID(id uint64) Auction { a.ID = id; return a }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (a ForwardReverseAuction) String() string {
 | 
					func (a ForwardReverseAuction) String() string {
 | 
				
			||||||
	return fmt.Sprintf(`Auction %d:
 | 
						return fmt.Sprintf(`Auction %d:
 | 
				
			||||||
 | 
				
			|||||||
@ -9,13 +9,13 @@ type GenesisAuctions []Auction
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// GenesisState - auction state that must be provided at genesis
 | 
					// GenesisState - auction state that must be provided at genesis
 | 
				
			||||||
type GenesisState struct {
 | 
					type GenesisState struct {
 | 
				
			||||||
	NextAuctionID ID
 | 
						NextAuctionID uint64 `json:"next_auction_id" yaml:"next_auction_id"`
 | 
				
			||||||
	AuctionParams AuctionParams   `json:"auction_params" yaml:"auction_params"`
 | 
						AuctionParams AuctionParams   `json:"auction_params" yaml:"auction_params"`
 | 
				
			||||||
	Auctions      GenesisAuctions `json:"genesis_auctions" yaml:"genesis_auctions"`
 | 
						Auctions      GenesisAuctions `json:"genesis_auctions" yaml:"genesis_auctions"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewGenesisState returns a new genesis state object for auctions module
 | 
					// NewGenesisState returns a new genesis state object for auctions module
 | 
				
			||||||
func NewGenesisState(nextID ID, ap AuctionParams, ga GenesisAuctions) GenesisState {
 | 
					func NewGenesisState(nextID uint64, ap AuctionParams, ga GenesisAuctions) GenesisState {
 | 
				
			||||||
	return GenesisState{
 | 
						return GenesisState{
 | 
				
			||||||
		NextAuctionID: nextID,
 | 
							NextAuctionID: nextID,
 | 
				
			||||||
		AuctionParams: ap,
 | 
							AuctionParams: ap,
 | 
				
			||||||
@ -25,7 +25,7 @@ func NewGenesisState(nextID ID, ap AuctionParams, ga GenesisAuctions) GenesisSta
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// DefaultGenesisState defines default genesis state for auction module
 | 
					// DefaultGenesisState defines default genesis state for auction module
 | 
				
			||||||
func DefaultGenesisState() GenesisState {
 | 
					func DefaultGenesisState() GenesisState {
 | 
				
			||||||
	return NewGenesisState(ID(0), DefaultAuctionParams(), GenesisAuctions{})
 | 
						return NewGenesisState(0, DefaultAuctionParams(), GenesisAuctions{})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Equal checks whether two GenesisState structs are equivalent
 | 
					// Equal checks whether two GenesisState structs are equivalent
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
package types
 | 
					package types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/binary"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sdk "github.com/cosmos/cosmos-sdk/types"
 | 
						sdk "github.com/cosmos/cosmos-sdk/types"
 | 
				
			||||||
@ -28,10 +29,20 @@ var (
 | 
				
			|||||||
	NextAuctionIDKey = []byte{0x02}
 | 
						NextAuctionIDKey = []byte{0x02}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func GetAuctionKey(auctionID ID) []byte {
 | 
					func GetAuctionKey(auctionID uint64) []byte {
 | 
				
			||||||
	return auctionID.Bytes()
 | 
						return Uint64ToBytes(auctionID)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func GetAuctionByTimeKey(endTime time.Time, auctionID ID) []byte {
 | 
					func GetAuctionByTimeKey(endTime time.Time, auctionID uint64) []byte {
 | 
				
			||||||
	return append(sdk.FormatTimeBytes(endTime), auctionID.Bytes()...)
 | 
						return append(sdk.FormatTimeBytes(endTime), Uint64ToBytes(auctionID)...)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func Uint64FromBytes(bz []byte) uint64 {
 | 
				
			||||||
 | 
						return binary.BigEndian.Uint64(bz)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func Uint64ToBytes(id uint64) []byte {
 | 
				
			||||||
 | 
						bz := make([]byte, 8)
 | 
				
			||||||
 | 
						binary.BigEndian.PutUint64(bz, uint64(id))
 | 
				
			||||||
 | 
						return bz
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -4,14 +4,14 @@ import sdk "github.com/cosmos/cosmos-sdk/types"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// MsgPlaceBid is the message type used to place a bid on any type of auction.
 | 
					// MsgPlaceBid is the message type used to place a bid on any type of auction.
 | 
				
			||||||
type MsgPlaceBid struct {
 | 
					type MsgPlaceBid struct {
 | 
				
			||||||
	AuctionID ID
 | 
						AuctionID uint64
 | 
				
			||||||
	Bidder    sdk.AccAddress // This can be a buyer (who increments bid), or a seller (who decrements lot) TODO rename to be clearer?
 | 
						Bidder    sdk.AccAddress // This can be a buyer (who increments bid), or a seller (who decrements lot) TODO rename to be clearer?
 | 
				
			||||||
	Bid       sdk.Coin
 | 
						Bid       sdk.Coin
 | 
				
			||||||
	Lot       sdk.Coin
 | 
						Lot       sdk.Coin
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewMsgPlaceBid returns a new MsgPlaceBid.
 | 
					// NewMsgPlaceBid returns a new MsgPlaceBid.
 | 
				
			||||||
func NewMsgPlaceBid(auctionID ID, bidder sdk.AccAddress, bid sdk.Coin, lot sdk.Coin) MsgPlaceBid {
 | 
					func NewMsgPlaceBid(auctionID uint64, bidder sdk.AccAddress, bid sdk.Coin, lot sdk.Coin) MsgPlaceBid {
 | 
				
			||||||
	return MsgPlaceBid{
 | 
						return MsgPlaceBid{
 | 
				
			||||||
		AuctionID: auctionID,
 | 
							AuctionID: auctionID,
 | 
				
			||||||
		Bidder:    bidder,
 | 
							Bidder:    bidder,
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,6 @@ import (
 | 
				
			|||||||
	sdk "github.com/cosmos/cosmos-sdk/types"
 | 
						sdk "github.com/cosmos/cosmos-sdk/types"
 | 
				
			||||||
	"github.com/cosmos/cosmos-sdk/x/params/subspace"
 | 
						"github.com/cosmos/cosmos-sdk/x/params/subspace"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/kava-labs/kava/x/auction"
 | 
					 | 
				
			||||||
	"github.com/kava-labs/kava/x/liquidator/types"
 | 
						"github.com/kava-labs/kava/x/liquidator/types"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -33,7 +32,7 @@ func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, paramstore subspace.Subs
 | 
				
			|||||||
// SeizeAndStartCollateralAuction pulls collateral out of a CDP and sells it in an auction for stable coin. Excess collateral goes to the original CDP owner.
 | 
					// SeizeAndStartCollateralAuction pulls collateral out of a CDP and sells it in an auction for stable coin. Excess collateral goes to the original CDP owner.
 | 
				
			||||||
// Known as Cat.bite in maker
 | 
					// Known as Cat.bite in maker
 | 
				
			||||||
// result: stable coin is transferred to module account, collateral is transferred from module account to buyer, (and any excess collateral is transferred to original CDP owner)
 | 
					// result: stable coin is transferred to module account, collateral is transferred from module account to buyer, (and any excess collateral is transferred to original CDP owner)
 | 
				
			||||||
func (k Keeper) SeizeAndStartCollateralAuction(ctx sdk.Context, owner sdk.AccAddress, collateralDenom string) (auction.ID, sdk.Error) {
 | 
					func (k Keeper) SeizeAndStartCollateralAuction(ctx sdk.Context, owner sdk.AccAddress, collateralDenom string) (uint64, sdk.Error) {
 | 
				
			||||||
	// Get CDP
 | 
						// Get CDP
 | 
				
			||||||
	cdp, found := k.cdpKeeper.GetCDP(ctx, owner, collateralDenom)
 | 
						cdp, found := k.cdpKeeper.GetCDP(ctx, owner, collateralDenom)
 | 
				
			||||||
	if !found {
 | 
						if !found {
 | 
				
			||||||
@ -73,7 +72,7 @@ func (k Keeper) SeizeAndStartCollateralAuction(ctx sdk.Context, owner sdk.AccAdd
 | 
				
			|||||||
// StartDebtAuction sells off minted gov coin to raise set amounts of stable coin.
 | 
					// StartDebtAuction sells off minted gov coin to raise set amounts of stable coin.
 | 
				
			||||||
// Known as Vow.flop in maker
 | 
					// Known as Vow.flop in maker
 | 
				
			||||||
// result: minted gov coin moved to highest bidder, stable coin moved to moduleAccount
 | 
					// result: minted gov coin moved to highest bidder, stable coin moved to moduleAccount
 | 
				
			||||||
func (k Keeper) StartDebtAuction(ctx sdk.Context) (auction.ID, sdk.Error) {
 | 
					func (k Keeper) StartDebtAuction(ctx sdk.Context) (uint64, sdk.Error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Ensure amount of seized stable coin is 0 (ie Joy = 0)
 | 
						// Ensure amount of seized stable coin is 0 (ie Joy = 0)
 | 
				
			||||||
	stableCoins := k.bankKeeper.GetCoins(ctx, k.cdpKeeper.GetLiquidatorAccountAddress()).AmountOf(k.cdpKeeper.GetStableDenom())
 | 
						stableCoins := k.bankKeeper.GetCoins(ctx, k.cdpKeeper.GetLiquidatorAccountAddress()).AmountOf(k.cdpKeeper.GetStableDenom())
 | 
				
			||||||
@ -107,7 +106,7 @@ func (k Keeper) StartDebtAuction(ctx sdk.Context) (auction.ID, sdk.Error) {
 | 
				
			|||||||
// StartSurplusAuction sells off excess stable coin in exchange for gov coin, which is burned
 | 
					// StartSurplusAuction sells off excess stable coin in exchange for gov coin, which is burned
 | 
				
			||||||
// Known as Vow.flap in maker
 | 
					// Known as Vow.flap in maker
 | 
				
			||||||
// result: stable coin removed from module account (eventually to buyer), gov coin transferred to module account
 | 
					// result: stable coin removed from module account (eventually to buyer), gov coin transferred to module account
 | 
				
			||||||
// func (k Keeper) StartSurplusAuction(ctx sdk.Context) (auction.ID, sdk.Error) {
 | 
					// func (k Keeper) StartSurplusAuction(ctx sdk.Context) (uint64, sdk.Error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 	// TODO ensure seized debt is 0
 | 
					// 	// TODO ensure seized debt is 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,6 @@ package types
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	sdk "github.com/cosmos/cosmos-sdk/types"
 | 
						sdk "github.com/cosmos/cosmos-sdk/types"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/kava-labs/kava/x/auction"
 | 
					 | 
				
			||||||
	"github.com/kava-labs/kava/x/cdp"
 | 
						"github.com/kava-labs/kava/x/cdp"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -26,7 +25,7 @@ type BankKeeper interface {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// AuctionKeeper expected interface for the auction keeper
 | 
					// AuctionKeeper expected interface for the auction keeper
 | 
				
			||||||
type AuctionKeeper interface {
 | 
					type AuctionKeeper interface {
 | 
				
			||||||
	StartForwardAuction(sdk.Context, sdk.AccAddress, sdk.Coin, sdk.Coin) (auction.ID, sdk.Error)
 | 
						StartForwardAuction(sdk.Context, sdk.AccAddress, sdk.Coin, sdk.Coin) (uint64, sdk.Error)
 | 
				
			||||||
	StartReverseAuction(sdk.Context, sdk.AccAddress, sdk.Coin, sdk.Coin) (auction.ID, sdk.Error)
 | 
						StartReverseAuction(sdk.Context, sdk.AccAddress, sdk.Coin, sdk.Coin) (uint64, sdk.Error)
 | 
				
			||||||
	StartForwardReverseAuction(sdk.Context, sdk.AccAddress, sdk.Coin, sdk.Coin, sdk.AccAddress) (auction.ID, sdk.Error)
 | 
						StartForwardReverseAuction(sdk.Context, sdk.AccAddress, sdk.Coin, sdk.Coin, sdk.AccAddress) (uint64, sdk.Error)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user