mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 08:15:19 +00:00
give auction types more accurate names
This commit is contained in:
parent
08689305cc
commit
c239932297
@ -37,7 +37,7 @@ func TestKeeper_EndBlocker(t *testing.T) {
|
|||||||
ctx := tApp.NewContext(true, abci.Header{})
|
ctx := tApp.NewContext(true, abci.Header{})
|
||||||
keeper := tApp.GetAuctionKeeper()
|
keeper := tApp.GetAuctionKeeper()
|
||||||
|
|
||||||
auctionID, err := keeper.StartForwardReverseAuction(ctx, sellerModName, c("token1", 20), c("token2", 50), returnAddrs, returnWeights)
|
auctionID, err := keeper.StartCollateralAuction(ctx, sellerModName, c("token1", 20), c("token2", 50), returnAddrs, returnWeights)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, keeper.PlaceBid(ctx, auctionID, buyer, c("token2", 30)))
|
require.NoError(t, keeper.PlaceBid(ctx, auctionID, buyer, c("token2", 30)))
|
||||||
|
|
||||||
|
@ -22,24 +22,24 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// functions aliases
|
// functions aliases
|
||||||
NewForwardAuction = types.NewForwardAuction
|
NewSurplusAuction = types.NewSurplusAuction
|
||||||
NewReverseAuction = types.NewReverseAuction
|
NewDebtAuction = types.NewDebtAuction
|
||||||
NewForwardReverseAuction = types.NewForwardReverseAuction
|
NewCollateralAuction = types.NewCollateralAuction
|
||||||
NewWeightedAddresses = types.NewWeightedAddresses
|
NewWeightedAddresses = types.NewWeightedAddresses
|
||||||
RegisterCodec = types.RegisterCodec
|
RegisterCodec = types.RegisterCodec
|
||||||
NewGenesisState = types.NewGenesisState
|
NewGenesisState = types.NewGenesisState
|
||||||
DefaultGenesisState = types.DefaultGenesisState
|
DefaultGenesisState = types.DefaultGenesisState
|
||||||
ValidateGenesis = types.ValidateGenesis
|
ValidateGenesis = types.ValidateGenesis
|
||||||
GetAuctionKey = types.GetAuctionKey
|
GetAuctionKey = types.GetAuctionKey
|
||||||
GetAuctionByTimeKey = types.GetAuctionByTimeKey
|
GetAuctionByTimeKey = types.GetAuctionByTimeKey
|
||||||
Uint64FromBytes = types.Uint64FromBytes
|
Uint64FromBytes = types.Uint64FromBytes
|
||||||
Uint64ToBytes = types.Uint64ToBytes
|
Uint64ToBytes = types.Uint64ToBytes
|
||||||
NewMsgPlaceBid = types.NewMsgPlaceBid
|
NewMsgPlaceBid = types.NewMsgPlaceBid
|
||||||
NewParams = types.NewParams
|
NewParams = types.NewParams
|
||||||
DefaultParams = types.DefaultParams
|
DefaultParams = types.DefaultParams
|
||||||
ParamKeyTable = types.ParamKeyTable
|
ParamKeyTable = types.ParamKeyTable
|
||||||
NewKeeper = keeper.NewKeeper
|
NewKeeper = keeper.NewKeeper
|
||||||
NewQuerier = keeper.NewQuerier
|
NewQuerier = keeper.NewQuerier
|
||||||
|
|
||||||
// variable aliases
|
// variable aliases
|
||||||
ModuleCdc = types.ModuleCdc
|
ModuleCdc = types.ModuleCdc
|
||||||
@ -51,17 +51,17 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Auction = types.Auction
|
Auction = types.Auction
|
||||||
BaseAuction = types.BaseAuction
|
BaseAuction = types.BaseAuction
|
||||||
ForwardAuction = types.ForwardAuction
|
SurplusAuction = types.SurplusAuction
|
||||||
ReverseAuction = types.ReverseAuction
|
DebtAuction = types.DebtAuction
|
||||||
ForwardReverseAuction = types.ForwardReverseAuction
|
CollateralAuction = types.CollateralAuction
|
||||||
WeightedAddresses = types.WeightedAddresses
|
WeightedAddresses = types.WeightedAddresses
|
||||||
SupplyKeeper = types.SupplyKeeper
|
SupplyKeeper = types.SupplyKeeper
|
||||||
Auctions = types.Auctions
|
Auctions = types.Auctions
|
||||||
GenesisState = types.GenesisState
|
GenesisState = types.GenesisState
|
||||||
MsgPlaceBid = types.MsgPlaceBid
|
MsgPlaceBid = types.MsgPlaceBid
|
||||||
Params = types.Params
|
Params = types.Params
|
||||||
QueryResAuctions = types.QueryResAuctions
|
QueryResAuctions = types.QueryResAuctions
|
||||||
Keeper = keeper.Keeper
|
Keeper = keeper.Keeper
|
||||||
)
|
)
|
||||||
|
@ -9,10 +9,10 @@ import (
|
|||||||
"github.com/kava-labs/kava/x/auction/types"
|
"github.com/kava-labs/kava/x/auction/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StartForwardAuction starts a normal auction that mints the sold coins.
|
// StartSurplusAuction starts a normal auction that mints the sold coins.
|
||||||
func (k Keeper) StartForwardAuction(ctx sdk.Context, seller string, lot sdk.Coin, bidDenom string) (uint64, sdk.Error) {
|
func (k Keeper) StartSurplusAuction(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.NewSurplusAuction(seller, lot, bidDenom, ctx.BlockTime().Add(types.DefaultMaxAuctionDuration))
|
||||||
|
|
||||||
// take coins from module account
|
// take coins from module account
|
||||||
err := k.supplyKeeper.SendCoinsFromModuleToModule(ctx, seller, types.ModuleName, sdk.NewCoins(lot))
|
err := k.supplyKeeper.SendCoinsFromModuleToModule(ctx, seller, types.ModuleName, sdk.NewCoins(lot))
|
||||||
@ -27,10 +27,10 @@ func (k Keeper) StartForwardAuction(ctx sdk.Context, seller string, lot sdk.Coin
|
|||||||
return auctionID, nil
|
return auctionID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartReverseAuction starts an auction where sellers compete by offering decreasing prices.
|
// StartDebtAuction 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) (uint64, sdk.Error) {
|
func (k Keeper) StartDebtAuction(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.NewDebtAuction(buyer, bid, initialLot, ctx.BlockTime().Add(types.DefaultMaxAuctionDuration))
|
||||||
|
|
||||||
// This auction type mints coins at close. Need to check module account has minting privileges to avoid potential err in endblocker.
|
// This auction type mints coins at close. Need to check module account has minting privileges to avoid potential err in endblocker.
|
||||||
macc := k.supplyKeeper.GetModuleAccount(ctx, buyer)
|
macc := k.supplyKeeper.GetModuleAccount(ctx, buyer)
|
||||||
@ -45,14 +45,14 @@ func (k Keeper) StartReverseAuction(ctx sdk.Context, buyer string, bid sdk.Coin,
|
|||||||
return auctionID, nil
|
return auctionID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartForwardReverseAuction starts an auction where bidders bid up to a maxBid, then switch to bidding down on price.
|
// StartCollateralAuction 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) (uint64, sdk.Error) {
|
func (k Keeper) StartCollateralAuction(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 {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
auction := types.NewForwardReverseAuction(seller, lot, ctx.BlockTime().Add(types.DefaultMaxAuctionDuration), maxBid, weightedAddresses)
|
auction := types.NewCollateralAuction(seller, lot, ctx.BlockTime().Add(types.DefaultMaxAuctionDuration), maxBid, weightedAddresses)
|
||||||
|
|
||||||
// take coins from module account
|
// take coins from module account
|
||||||
err = k.supplyKeeper.SendCoinsFromModuleToModule(ctx, seller, types.ModuleName, sdk.NewCoins(lot))
|
err = k.supplyKeeper.SendCoinsFromModuleToModule(ctx, seller, types.ModuleName, sdk.NewCoins(lot))
|
||||||
@ -85,19 +85,19 @@ func (k Keeper) PlaceBid(ctx sdk.Context, auctionID uint64, bidder sdk.AccAddres
|
|||||||
var err sdk.Error
|
var err sdk.Error
|
||||||
var updatedAuction types.Auction
|
var updatedAuction types.Auction
|
||||||
switch a := auction.(type) {
|
switch a := auction.(type) {
|
||||||
case types.ForwardAuction:
|
case types.SurplusAuction:
|
||||||
if updatedAuction, err = k.PlaceBidForward(ctx, a, bidder, newAmount); err != nil {
|
if updatedAuction, err = k.PlaceBidSurplus(ctx, a, bidder, newAmount); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case types.ReverseAuction:
|
case types.DebtAuction:
|
||||||
if updatedAuction, err = k.PlaceBidReverse(ctx, a, bidder, newAmount); err != nil {
|
if updatedAuction, err = k.PlaceBidDebt(ctx, a, bidder, newAmount); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case types.ForwardReverseAuction:
|
case types.CollateralAuction:
|
||||||
if !a.IsReversePhase() {
|
if !a.IsReversePhase() {
|
||||||
updatedAuction, err = k.PlaceBidForwardReverseForward(ctx, a, bidder, newAmount)
|
updatedAuction, err = k.PlaceForwardBidCollateral(ctx, a, bidder, newAmount)
|
||||||
} else {
|
} else {
|
||||||
updatedAuction, err = k.PlaceBidForwardReverseReverse(ctx, a, bidder, newAmount)
|
updatedAuction, err = k.PlaceReverseBidCollateral(ctx, a, bidder, newAmount)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -111,7 +111,7 @@ func (k Keeper) PlaceBid(ctx sdk.Context, auctionID uint64, bidder sdk.AccAddres
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) PlaceBidForward(ctx sdk.Context, a types.ForwardAuction, bidder sdk.AccAddress, bid sdk.Coin) (types.ForwardAuction, sdk.Error) {
|
func (k Keeper) PlaceBidSurplus(ctx sdk.Context, a types.SurplusAuction, bidder sdk.AccAddress, bid sdk.Coin) (types.SurplusAuction, sdk.Error) {
|
||||||
// Validate New Bid
|
// Validate New Bid
|
||||||
if bid.Denom != a.Bid.Denom {
|
if bid.Denom != a.Bid.Denom {
|
||||||
return a, sdk.ErrInternal("bid denom doesn't match auction")
|
return a, sdk.ErrInternal("bid denom doesn't match auction")
|
||||||
@ -151,8 +151,7 @@ func (k Keeper) PlaceBidForward(ctx sdk.Context, a types.ForwardAuction, bidder
|
|||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO naming
|
func (k Keeper) PlaceForwardBidCollateral(ctx sdk.Context, a types.CollateralAuction, bidder sdk.AccAddress, bid sdk.Coin) (types.CollateralAuction, sdk.Error) {
|
||||||
func (k Keeper) PlaceBidForwardReverseForward(ctx sdk.Context, a types.ForwardReverseAuction, bidder sdk.AccAddress, bid sdk.Coin) (types.ForwardReverseAuction, sdk.Error) {
|
|
||||||
// Validate new bid
|
// Validate new bid
|
||||||
if bid.Denom != a.Bid.Denom {
|
if bid.Denom != a.Bid.Denom {
|
||||||
return a, sdk.ErrInternal("bid denom doesn't match auction")
|
return a, sdk.ErrInternal("bid denom doesn't match auction")
|
||||||
@ -193,7 +192,7 @@ func (k Keeper) PlaceBidForwardReverseForward(ctx sdk.Context, a types.ForwardRe
|
|||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) PlaceBidForwardReverseReverse(ctx sdk.Context, a types.ForwardReverseAuction, bidder sdk.AccAddress, lot sdk.Coin) (types.ForwardReverseAuction, sdk.Error) {
|
func (k Keeper) PlaceReverseBidCollateral(ctx sdk.Context, a types.CollateralAuction, bidder sdk.AccAddress, lot sdk.Coin) (types.CollateralAuction, sdk.Error) {
|
||||||
// Validate bid
|
// Validate bid
|
||||||
if lot.Denom != a.Lot.Denom {
|
if lot.Denom != a.Lot.Denom {
|
||||||
return a, sdk.ErrInternal("lot denom doesn't match auction")
|
return a, sdk.ErrInternal("lot denom doesn't match auction")
|
||||||
@ -240,7 +239,7 @@ func (k Keeper) PlaceBidForwardReverseReverse(ctx sdk.Context, a types.ForwardRe
|
|||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) PlaceBidReverse(ctx sdk.Context, a types.ReverseAuction, bidder sdk.AccAddress, lot sdk.Coin) (types.ReverseAuction, sdk.Error) {
|
func (k Keeper) PlaceBidDebt(ctx sdk.Context, a types.DebtAuction, bidder sdk.AccAddress, lot sdk.Coin) (types.DebtAuction, sdk.Error) {
|
||||||
// Validate New Bid
|
// Validate New Bid
|
||||||
if lot.Denom != a.Lot.Denom {
|
if lot.Denom != a.Lot.Denom {
|
||||||
return a, sdk.ErrInternal("lot denom doesn't match auction")
|
return a, sdk.ErrInternal("lot denom doesn't match auction")
|
||||||
@ -288,16 +287,16 @@ func (k Keeper) CloseAuction(ctx sdk.Context, auctionID uint64) sdk.Error {
|
|||||||
|
|
||||||
// payout to the last bidder
|
// payout to the last bidder
|
||||||
switch auc := auction.(type) {
|
switch auc := auction.(type) {
|
||||||
case types.ForwardAuction:
|
case types.SurplusAuction:
|
||||||
if err := k.PayoutForwardAuction(ctx, auc); err != nil {
|
if err := k.PayoutSurplusAuction(ctx, auc); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case types.ReverseAuction:
|
case types.DebtAuction:
|
||||||
if err := k.PayoutReverseAuction(ctx, auc); err != nil {
|
if err := k.PayoutDebtAuction(ctx, auc); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case types.ForwardReverseAuction:
|
case types.CollateralAuction:
|
||||||
if err := k.PayoutForwardReverseAuction(ctx, auc); err != nil {
|
if err := k.PayoutCollateralAuction(ctx, auc); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -308,7 +307,7 @@ func (k Keeper) CloseAuction(ctx sdk.Context, auctionID uint64) sdk.Error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) PayoutReverseAuction(ctx sdk.Context, a types.ReverseAuction) sdk.Error {
|
func (k Keeper) PayoutDebtAuction(ctx sdk.Context, a types.DebtAuction) sdk.Error {
|
||||||
err := k.supplyKeeper.MintCoins(ctx, a.Initiator, sdk.NewCoins(a.Lot))
|
err := k.supplyKeeper.MintCoins(ctx, a.Initiator, sdk.NewCoins(a.Lot))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -320,7 +319,7 @@ func (k Keeper) PayoutReverseAuction(ctx sdk.Context, a types.ReverseAuction) sd
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) PayoutForwardAuction(ctx sdk.Context, a types.ForwardAuction) sdk.Error {
|
func (k Keeper) PayoutSurplusAuction(ctx sdk.Context, a types.SurplusAuction) sdk.Error {
|
||||||
err := k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, a.Bidder, sdk.NewCoins(a.Lot))
|
err := k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, a.Bidder, sdk.NewCoins(a.Lot))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -328,7 +327,7 @@ func (k Keeper) PayoutForwardAuction(ctx sdk.Context, a types.ForwardAuction) sd
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) PayoutForwardReverseAuction(ctx sdk.Context, a types.ForwardReverseAuction) sdk.Error {
|
func (k Keeper) PayoutCollateralAuction(ctx sdk.Context, a types.CollateralAuction) sdk.Error {
|
||||||
err := k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, a.Bidder, sdk.NewCoins(a.Lot))
|
err := k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, a.Bidder, sdk.NewCoins(a.Lot))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/kava-labs/kava/x/liquidator"
|
"github.com/kava-labs/kava/x/liquidator"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestForwardAuctionBasic(t *testing.T) {
|
func TestSurplusAuctionBasic(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
_, addrs := app.GeneratePrivKeyAddressPairs(1)
|
_, addrs := app.GeneratePrivKeyAddressPairs(1)
|
||||||
buyer := addrs[0]
|
buyer := addrs[0]
|
||||||
@ -37,7 +37,7 @@ func TestForwardAuctionBasic(t *testing.T) {
|
|||||||
keeper := tApp.GetAuctionKeeper()
|
keeper := tApp.GetAuctionKeeper()
|
||||||
|
|
||||||
// Create an auction (lot: 20 token1, initialBid: 0 token2)
|
// Create an auction (lot: 20 token1, initialBid: 0 token2)
|
||||||
auctionID, err := keeper.StartForwardAuction(ctx, sellerModName, c("token1", 20), "token2") // lot, bid denom
|
auctionID, err := keeper.StartSurplusAuction(ctx, sellerModName, c("token1", 20), "token2") // lot, bid denom
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
// Check seller's coins have decreased
|
// Check seller's coins have decreased
|
||||||
tApp.CheckBalance(t, ctx, sellerAddr, cs(c("token1", 80), c("token2", 100)))
|
tApp.CheckBalance(t, ctx, sellerAddr, cs(c("token1", 80), c("token2", 100)))
|
||||||
@ -60,7 +60,7 @@ func TestForwardAuctionBasic(t *testing.T) {
|
|||||||
tApp.CheckBalance(t, ctx, buyer, cs(c("token1", 120), c("token2", 80)))
|
tApp.CheckBalance(t, ctx, buyer, cs(c("token1", 120), c("token2", 80)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReverseAuctionBasic(t *testing.T) {
|
func TestDebtAuctionBasic(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
_, addrs := app.GeneratePrivKeyAddressPairs(1)
|
_, addrs := app.GeneratePrivKeyAddressPairs(1)
|
||||||
seller := addrs[0]
|
seller := addrs[0]
|
||||||
@ -79,7 +79,7 @@ func TestReverseAuctionBasic(t *testing.T) {
|
|||||||
keeper := tApp.GetAuctionKeeper()
|
keeper := tApp.GetAuctionKeeper()
|
||||||
|
|
||||||
// Start auction
|
// Start auction
|
||||||
auctionID, err := keeper.StartReverseAuction(ctx, buyerModName, c("token1", 20), c("token2", 99999)) // buyer, bid, initialLot
|
auctionID, err := keeper.StartDebtAuction(ctx, buyerModName, c("token1", 20), c("token2", 99999)) // buyer, bid, initialLot
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
// Check buyer's coins have not decreased, as lot is minted at the end
|
// Check buyer's coins have not decreased, as lot is minted at the end
|
||||||
tApp.CheckBalance(t, ctx, buyerAddr, nil) // zero coins
|
tApp.CheckBalance(t, ctx, buyerAddr, nil) // zero coins
|
||||||
@ -98,7 +98,7 @@ func TestReverseAuctionBasic(t *testing.T) {
|
|||||||
tApp.CheckBalance(t, ctx, seller, cs(c("token1", 80), c("token2", 110)))
|
tApp.CheckBalance(t, ctx, seller, cs(c("token1", 80), c("token2", 110)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestForwardReverseAuctionBasic(t *testing.T) {
|
func TestCollateralAuctionBasic(t *testing.T) {
|
||||||
// Setup
|
// Setup
|
||||||
_, addrs := app.GeneratePrivKeyAddressPairs(4)
|
_, addrs := app.GeneratePrivKeyAddressPairs(4)
|
||||||
buyer := addrs[0]
|
buyer := addrs[0]
|
||||||
@ -123,7 +123,7 @@ func TestForwardReverseAuctionBasic(t *testing.T) {
|
|||||||
keeper := tApp.GetAuctionKeeper()
|
keeper := tApp.GetAuctionKeeper()
|
||||||
|
|
||||||
// Start auction
|
// Start auction
|
||||||
auctionID, err := keeper.StartForwardReverseAuction(ctx, sellerModName, c("token1", 20), c("token2", 50), returnAddrs, returnWeights) // seller, lot, maxBid, otherPerson
|
auctionID, err := keeper.StartCollateralAuction(ctx, sellerModName, c("token1", 20), c("token2", 50), returnAddrs, returnWeights) // seller, lot, maxBid, otherPerson
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
// Check seller's coins have decreased
|
// Check seller's coins have decreased
|
||||||
tApp.CheckBalance(t, ctx, sellerAddr, cs(c("token1", 80), c("token2", 100)))
|
tApp.CheckBalance(t, ctx, sellerAddr, cs(c("token1", 80), c("token2", 100)))
|
||||||
@ -158,7 +158,7 @@ func TestForwardReverseAuctionBasic(t *testing.T) {
|
|||||||
tApp.CheckBalance(t, ctx, buyer, cs(c("token1", 115), c("token2", 50)))
|
tApp.CheckBalance(t, ctx, buyer, cs(c("token1", 115), c("token2", 50)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStartForwardAuction(t *testing.T) {
|
func TestStartSurplusAuction(t *testing.T) {
|
||||||
someTime := time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC)
|
someTime := time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||||
type args struct {
|
type args struct {
|
||||||
seller string
|
seller string
|
||||||
@ -211,7 +211,7 @@ func TestStartForwardAuction(t *testing.T) {
|
|||||||
keeper := tApp.GetAuctionKeeper()
|
keeper := tApp.GetAuctionKeeper()
|
||||||
|
|
||||||
// run function under test
|
// run function under test
|
||||||
id, err := keeper.StartForwardAuction(ctx, tc.args.seller, tc.args.lot, tc.args.bidDenom)
|
id, err := keeper.StartSurplusAuction(ctx, tc.args.seller, tc.args.lot, tc.args.bidDenom)
|
||||||
|
|
||||||
// check
|
// check
|
||||||
sk := tApp.GetSupplyKeeper()
|
sk := tApp.GetSupplyKeeper()
|
||||||
@ -224,7 +224,7 @@ func TestStartForwardAuction(t *testing.T) {
|
|||||||
require.Equal(t, initialLiquidatorCoins.Sub(cs(tc.args.lot)), liquidatorCoins)
|
require.Equal(t, initialLiquidatorCoins.Sub(cs(tc.args.lot)), liquidatorCoins)
|
||||||
// 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.SurplusAuction{BaseAuction: types.BaseAuction{
|
||||||
ID: 0,
|
ID: 0,
|
||||||
Initiator: tc.args.seller,
|
Initiator: tc.args.seller,
|
||||||
Lot: tc.args.lot,
|
Lot: tc.args.lot,
|
||||||
|
@ -18,7 +18,7 @@ func SetGetDeleteAuction(t *testing.T) {
|
|||||||
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
|
||||||
var id uint64 = 5
|
var id uint64 = 5
|
||||||
auction := types.NewForwardAuction("some_module", c("usdx", 100), "kava", someTime).WithID(id)
|
auction := types.NewSurplusAuction("some_module", c("usdx", 100), "kava", someTime).WithID(id)
|
||||||
|
|
||||||
// write and read from store
|
// write and read from store
|
||||||
keeper.SetAuction(ctx, auction)
|
keeper.SetAuction(ctx, auction)
|
||||||
@ -73,9 +73,9 @@ func TestIterateAuctions(t *testing.T) {
|
|||||||
ctx := tApp.NewContext(true, abci.Header{})
|
ctx := tApp.NewContext(true, abci.Header{})
|
||||||
|
|
||||||
auctions := []types.Auction{
|
auctions := []types.Auction{
|
||||||
types.NewForwardAuction("sellerMod", c("denom", 12345678), "anotherdenom", time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC)).WithID(0),
|
types.NewSurplusAuction("sellerMod", c("denom", 12345678), "anotherdenom", time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC)).WithID(0),
|
||||||
types.NewReverseAuction("buyerMod", c("denom", 12345678), c("anotherdenom", 12345678), time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC)).WithID(1),
|
types.NewDebtAuction("buyerMod", c("denom", 12345678), c("anotherdenom", 12345678), time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC)).WithID(1),
|
||||||
types.NewForwardReverseAuction("sellerMod", c("denom", 12345678), time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC), c("anotherdenom", 12345678), types.WeightedAddresses{}).WithID(2),
|
types.NewCollateralAuction("sellerMod", c("denom", 12345678), time.Date(1998, time.January, 1, 0, 0, 0, 0, time.UTC), c("anotherdenom", 12345678), types.WeightedAddresses{}).WithID(2),
|
||||||
}
|
}
|
||||||
for _, a := range auctions {
|
for _, a := range auctions {
|
||||||
keeper.SetAuction(ctx, a)
|
keeper.SetAuction(ctx, a)
|
||||||
|
@ -6,8 +6,8 @@ order: 1
|
|||||||
|
|
||||||
Auctions are broken down into three distinct types, which correspond to three specific functionalities within the CDP system.
|
Auctions are broken down into three distinct types, which correspond to three specific functionalities within the CDP system.
|
||||||
|
|
||||||
* **Forward Auction:** An auction in which a fixed lot of coins (c1) is sold for increasing amounts of other coins (c2). Bidders increment the amount of c2 they are willing to pay for the lot of c1. After the completion of a forward auction, the winning bid of c2 is burned, and the bidder receives the lot of c1. As a concrete example, forward auction are used to sell a fixed amount of USDX stable coins in exchange for increasing bids of KAVA governance tokens. The governance tokens are then burned and the winner receives USDX.
|
* **Surplus Auction:** An auction in which a fixed lot of coins (c1) is sold for increasing amounts of other coins (c2). Bidders increment the amount of c2 they are willing to pay for the lot of c1. After the completion of a forward auction, the winning bid of c2 is burned, and the bidder receives the lot of c1. As a concrete example, forward auction are used to sell a fixed amount of USDX stable coins in exchange for increasing bids of KAVA governance tokens. The governance tokens are then burned and the winner receives USDX.
|
||||||
* **Reverse Auction:** An auction in which a fixed amount of coins (c1) is bid for a decreasing lot of other coins (c2). Bidders decrement the lot of c2 they are willing to receive for the fixed amount of c1. As a concrete example, reverse auctions are used to raise a certain amount of USDX stable coins in exchange for decreasing lots of KAVA governance tokens. The USDX tokens are used to recapitalize the cdp system and the winner receives KAVA.
|
* **Debt Auction:** An auction in which a fixed amount of coins (c1) is bid for a decreasing lot of other coins (c2). Bidders decrement the lot of c2 they are willing to receive for the fixed amount of c1. As a concrete example, reverse auctions are used to raise a certain amount of USDX stable coins in exchange for decreasing lots of KAVA governance tokens. The USDX tokens are used to recapitalize the cdp system and the winner receives KAVA.
|
||||||
* **Forward Reverse Auction:** An two phase auction is which a fixed lot of coins (c1) is sold for increasing amounts of other coins (c2). Bidders increment the amount of c2 until a specific `maxBid` is reached. Once `maxBid` is reached, a fixed amount of c2 is bid for a decreasing lot of c1. In the second phase, bidders decrement the lot of c1 they are willing to receive for a fixed amount of c2. As a concrete example. forward reverse auctions are used to sell collateral (ATOM, for example) for up to a `maxBid` amount of USDX. The USDX tokens are used to recapitalize the cdp system and the winner receives the specified lot of ATOM. In the event that the winning lot is smaller than the total lot, the excess ATOM is ratably returned to the original owners of the liquidated CDPs that were collateralized with that ATOM.
|
* **Surplus Reverse Auction:** An two phase auction is which a fixed lot of coins (c1) is sold for increasing amounts of other coins (c2). Bidders increment the amount of c2 until a specific `maxBid` is reached. Once `maxBid` is reached, a fixed amount of c2 is bid for a decreasing lot of c1. In the second phase, bidders decrement the lot of c1 they are willing to receive for a fixed amount of c2. As a concrete example. forward reverse auctions are used to sell collateral (ATOM, for example) for up to a `maxBid` amount of USDX. The USDX tokens are used to recapitalize the cdp system and the winner receives the specified lot of ATOM. In the event that the winning lot is smaller than the total lot, the excess ATOM is ratably returned to the original owners of the liquidated CDPs that were collateralized with that ATOM.
|
||||||
|
|
||||||
Auctions are always initiated by another module, and not directly by users. Auctions start with an expiry, the time at which the auction is guaranteed to end, even if there have been no bidders. After each bid, the auction is extended by a specific amount of time, `BidDuration`. In the case that increasing the auction time by `BidDuration` would cause the auction to go past its expiry, the expiry is chosen as the ending time.
|
Auctions are always initiated by another module, and not directly by users. Auctions start with an expiry, the time at which the auction is guaranteed to end, even if there have been no bidders. After each bid, the auction is extended by a specific amount of time, `BidDuration`. In the case that increasing the auction time by `BidDuration` would cause the auction to go past its expiry, the expiry is chosen as the ending time.
|
||||||
|
@ -51,13 +51,13 @@ type BaseAuction struct {
|
|||||||
MaxEndTime time.Time // Maximum closing time. Auctions can close before this but never after.
|
MaxEndTime time.Time // Maximum closing time. Auctions can close before this but never after.
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForwardAuction type for forward auctions
|
//SurplusAuction type for forward auctions
|
||||||
type ForwardAuction struct {
|
typeSurplusAuction struct {
|
||||||
BaseAuction
|
BaseAuction
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReverseAuction type for reverse auctions
|
// DebtAuction type for reverse auctions
|
||||||
type ReverseAuction struct {
|
type DebtAuction struct {
|
||||||
BaseAuction
|
BaseAuction
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ type WeightedAddresses struct {
|
|||||||
Weights []sdk.Int
|
Weights []sdk.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForwardReverseAuction type for forward reverse auction
|
// CollateralAuction type for forward reverse auction
|
||||||
type ForwardReverseAuction struct {
|
type CollateralAuction struct {
|
||||||
BaseAuction
|
BaseAuction
|
||||||
MaxBid sdk.Coin
|
MaxBid sdk.Coin
|
||||||
LotReturns WeightedAddresses // return addresses to pay out reductions in the lot amount to. Lot is bid down during reverse phase.
|
LotReturns WeightedAddresses // return addresses to pay out reductions in the lot amount to. Lot is bid down during reverse phase.
|
||||||
|
@ -21,14 +21,14 @@ type MsgPlaceBid struct {
|
|||||||
**State Modifications:**
|
**State Modifications:**
|
||||||
|
|
||||||
* Update bidder if different than previous bidder
|
* Update bidder if different than previous bidder
|
||||||
* For forward auctions:
|
* For Surplus auctions:
|
||||||
* Update Bid Amount
|
* Update Bid Amount
|
||||||
* Return bid coins to previous bidder
|
* Return bid coins to previous bidder
|
||||||
* Burn coins equal to the increment in the bid (CurrentBid - PreviousBid)
|
* Burn coins equal to the increment in the bid (CurrentBid - PreviousBid)
|
||||||
* For Reverse auctions:
|
* For Debt auctions:
|
||||||
* Update lot amount
|
* Update lot amount
|
||||||
* Return bid coins to previous bidder
|
* Return bid coins to previous bidder
|
||||||
* For Forward Reverse auctions:
|
* For Collateral auctions:
|
||||||
* Return bid coins to previous bidder
|
* Return bid coins to previous bidder
|
||||||
* If in forward phase:
|
* If in forward phase:
|
||||||
* Update bid amount
|
* Update bid amount
|
||||||
|
@ -46,17 +46,17 @@ func (a BaseAuction) String() string {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForwardAuction type for forward auctions
|
// SurplusAuction type for forward auctions
|
||||||
type ForwardAuction struct {
|
type SurplusAuction struct {
|
||||||
BaseAuction
|
BaseAuction
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithID returns an auction with the ID set
|
// WithID returns an auction with the ID set
|
||||||
func (a ForwardAuction) WithID(id uint64) Auction { a.ID = id; return a }
|
func (a SurplusAuction) WithID(id uint64) Auction { a.ID = id; return a }
|
||||||
|
|
||||||
// NewForwardAuction creates a new forward auction
|
// NewSurplusAuction creates a new forward auction
|
||||||
func NewForwardAuction(seller string, lot sdk.Coin, bidDenom string, endTime time.Time) ForwardAuction {
|
func NewSurplusAuction(seller string, lot sdk.Coin, bidDenom string, endTime time.Time) SurplusAuction {
|
||||||
auction := ForwardAuction{BaseAuction{
|
auction := SurplusAuction{BaseAuction{
|
||||||
// no ID
|
// no ID
|
||||||
Initiator: seller,
|
Initiator: seller,
|
||||||
Lot: lot,
|
Lot: lot,
|
||||||
@ -68,20 +68,20 @@ func NewForwardAuction(seller string, lot sdk.Coin, bidDenom string, endTime tim
|
|||||||
return auction
|
return auction
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReverseAuction type for reverse auctions
|
// DebtAuction type for reverse auctions
|
||||||
type ReverseAuction struct {
|
type DebtAuction struct {
|
||||||
BaseAuction
|
BaseAuction
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithID returns an auction with the ID set
|
// WithID returns an auction with the ID set
|
||||||
func (a ReverseAuction) WithID(id uint64) Auction { a.ID = id; return a }
|
func (a DebtAuction) WithID(id uint64) Auction { a.ID = id; return a }
|
||||||
|
|
||||||
// NewReverseAuction creates a new reverse auction
|
// NewDebtAuction creates a new reverse auction
|
||||||
func NewReverseAuction(buyerModAccName string, bid sdk.Coin, initialLot sdk.Coin, EndTime time.Time) ReverseAuction {
|
func NewDebtAuction(buyerModAccName string, bid sdk.Coin, initialLot sdk.Coin, EndTime time.Time) DebtAuction {
|
||||||
// Note: Bidder is set to the initiator's module account address instead of module name. (when the first bid is placed, it is paid out to the initiator)
|
// Note: Bidder is set to the initiator's module account address instead of module name. (when the first bid is placed, it is paid out to the initiator)
|
||||||
// Setting to the module account address bypasses calling supply.SendCoinsFromModuleToModule, instead calls SendCoinsFromModuleToAccount.
|
// Setting to the module account address bypasses calling supply.SendCoinsFromModuleToModule, instead calls SendCoinsFromModuleToAccount.
|
||||||
// This isn't a problem currently, but if additional logic/validation was added for sending to coins to Module Accounts, it would be bypassed.
|
// This isn't a problem currently, but if additional logic/validation was added for sending to coins to Module Accounts, it would be bypassed.
|
||||||
auction := ReverseAuction{BaseAuction{
|
auction := DebtAuction{BaseAuction{
|
||||||
// no ID
|
// no ID
|
||||||
Initiator: buyerModAccName,
|
Initiator: buyerModAccName,
|
||||||
Lot: initialLot,
|
Lot: initialLot,
|
||||||
@ -93,21 +93,21 @@ func NewReverseAuction(buyerModAccName string, bid sdk.Coin, initialLot sdk.Coin
|
|||||||
return auction
|
return auction
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForwardReverseAuction type for forward reverse auction
|
// CollateralAuction type for forward reverse auction
|
||||||
type ForwardReverseAuction struct {
|
type CollateralAuction struct {
|
||||||
BaseAuction
|
BaseAuction
|
||||||
MaxBid sdk.Coin
|
MaxBid sdk.Coin
|
||||||
LotReturns WeightedAddresses // return addresses to pay out reductions in the lot amount to. Lot is bid down during reverse phase.
|
LotReturns WeightedAddresses // return addresses to pay out reductions in the lot amount to. Lot is bid down during reverse phase.
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithID returns an auction with the ID set
|
// WithID returns an auction with the ID set
|
||||||
func (a ForwardReverseAuction) WithID(id uint64) Auction { a.ID = id; return a }
|
func (a CollateralAuction) WithID(id uint64) Auction { a.ID = id; return a }
|
||||||
|
|
||||||
func (a ForwardReverseAuction) IsReversePhase() bool {
|
func (a CollateralAuction) IsReversePhase() bool {
|
||||||
return a.Bid.IsEqual(a.MaxBid)
|
return a.Bid.IsEqual(a.MaxBid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a ForwardReverseAuction) String() string {
|
func (a CollateralAuction) String() string {
|
||||||
return fmt.Sprintf(`Auction %d:
|
return fmt.Sprintf(`Auction %d:
|
||||||
Initiator: %s
|
Initiator: %s
|
||||||
Lot: %s
|
Lot: %s
|
||||||
@ -123,9 +123,9 @@ func (a ForwardReverseAuction) String() string {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewForwardReverseAuction creates a new forward reverse auction
|
// NewCollateralAuction creates a new forward reverse auction
|
||||||
func NewForwardReverseAuction(seller string, lot sdk.Coin, EndTime time.Time, maxBid sdk.Coin, lotReturns WeightedAddresses) ForwardReverseAuction {
|
func NewCollateralAuction(seller string, lot sdk.Coin, EndTime time.Time, maxBid sdk.Coin, lotReturns WeightedAddresses) CollateralAuction {
|
||||||
auction := ForwardReverseAuction{
|
auction := CollateralAuction{
|
||||||
BaseAuction: BaseAuction{
|
BaseAuction: BaseAuction{
|
||||||
// no ID
|
// no ID
|
||||||
Initiator: seller,
|
Initiator: seller,
|
||||||
|
@ -2,7 +2,7 @@ package types
|
|||||||
|
|
||||||
// // TODO can this be less verbose? Should PlaceBid() be split into smaller functions?
|
// // TODO can this be less verbose? Should PlaceBid() be split into smaller functions?
|
||||||
// // It would be possible to combine all auction tests into one test runner.
|
// // It would be possible to combine all auction tests into one test runner.
|
||||||
// func TestForwardAuction_PlaceBid(t *testing.T) {
|
// func TesSurplusAuction_PlaceBid(t *testing.T) {
|
||||||
// seller := sdk.AccAddress([]byte("a_seller"))
|
// seller := sdk.AccAddress([]byte("a_seller"))
|
||||||
// buyer1 := sdk.AccAddress([]byte("buyer1"))
|
// buyer1 := sdk.AccAddress([]byte("buyer1"))
|
||||||
// buyer2 := sdk.AccAddress([]byte("buyer2"))
|
// buyer2 := sdk.AccAddress([]byte("buyer2"))
|
||||||
@ -17,7 +17,7 @@ package types
|
|||||||
// }
|
// }
|
||||||
// tests := []struct {
|
// tests := []struct {
|
||||||
// name string
|
// name string
|
||||||
// auction ForwardAuction
|
// auction SurplusAuction
|
||||||
// args args
|
// args args
|
||||||
// expectedOutputs []BankOutput
|
// expectedOutputs []BankOutput
|
||||||
// expectedInputs []BankInput
|
// expectedInputs []BankInput
|
||||||
@ -28,7 +28,7 @@ package types
|
|||||||
// }{
|
// }{
|
||||||
// {
|
// {
|
||||||
// "normal",
|
// "normal",
|
||||||
// ForwardAuction{BaseAuction{
|
// SurplusAuction{BaseAuction{
|
||||||
// Initiator: seller,
|
// Initiator: seller,
|
||||||
// Lot: c("usdx", 100),
|
// Lot: c("usdx", 100),
|
||||||
// Bidder: buyer1,
|
// Bidder: buyer1,
|
||||||
@ -46,7 +46,7 @@ package types
|
|||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "lowBid",
|
// "lowBid",
|
||||||
// ForwardAuction{BaseAuction{
|
// SurplusAuction{BaseAuction{
|
||||||
// Initiator: seller,
|
// Initiator: seller,
|
||||||
// Lot: c("usdx", 100),
|
// Lot: c("usdx", 100),
|
||||||
// Bidder: buyer1,
|
// Bidder: buyer1,
|
||||||
@ -64,7 +64,7 @@ package types
|
|||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "equalBid",
|
// "equalBid",
|
||||||
// ForwardAuction{BaseAuction{
|
// SurplusAuction{BaseAuction{
|
||||||
// Initiator: seller,
|
// Initiator: seller,
|
||||||
// Lot: c("usdx", 100),
|
// Lot: c("usdx", 100),
|
||||||
// Bidder: buyer1,
|
// Bidder: buyer1,
|
||||||
@ -82,7 +82,7 @@ package types
|
|||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "timeout",
|
// "timeout",
|
||||||
// ForwardAuction{BaseAuction{
|
// SurplusAuction{BaseAuction{
|
||||||
// Initiator: seller,
|
// Initiator: seller,
|
||||||
// Lot: c("usdx", 100),
|
// Lot: c("usdx", 100),
|
||||||
// Bidder: buyer1,
|
// Bidder: buyer1,
|
||||||
@ -100,7 +100,7 @@ package types
|
|||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "hitMaxEndTime",
|
// "hitMaxEndTime",
|
||||||
// ForwardAuction{BaseAuction{
|
// SurplusAuction{BaseAuction{
|
||||||
// Initiator: seller,
|
// Initiator: seller,
|
||||||
// Lot: c("usdx", 100),
|
// Lot: c("usdx", 100),
|
||||||
// Bidder: buyer1,
|
// Bidder: buyer1,
|
||||||
@ -139,7 +139,7 @@ package types
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// func TestReverseAuction_PlaceBid(t *testing.T) {
|
// func TestDebtAuction_PlaceBid(t *testing.T) {
|
||||||
// buyer := sdk.AccAddress([]byte("a_buyer"))
|
// buyer := sdk.AccAddress([]byte("a_buyer"))
|
||||||
// seller1 := sdk.AccAddress([]byte("seller1"))
|
// seller1 := sdk.AccAddress([]byte("seller1"))
|
||||||
// seller2 := sdk.AccAddress([]byte("seller2"))
|
// seller2 := sdk.AccAddress([]byte("seller2"))
|
||||||
@ -154,7 +154,7 @@ package types
|
|||||||
// }
|
// }
|
||||||
// tests := []struct {
|
// tests := []struct {
|
||||||
// name string
|
// name string
|
||||||
// auction ReverseAuction
|
// auction DebtAuction
|
||||||
// args args
|
// args args
|
||||||
// expectedOutputs []BankOutput
|
// expectedOutputs []BankOutput
|
||||||
// expectedInputs []BankInput
|
// expectedInputs []BankInput
|
||||||
@ -165,7 +165,7 @@ package types
|
|||||||
// }{
|
// }{
|
||||||
// {
|
// {
|
||||||
// "normal",
|
// "normal",
|
||||||
// ReverseAuction{BaseAuction{
|
// DebtAuction{BaseAuction{
|
||||||
// Initiator: buyer,
|
// Initiator: buyer,
|
||||||
// Lot: c("kava", 10),
|
// Lot: c("kava", 10),
|
||||||
// Bidder: seller1,
|
// Bidder: seller1,
|
||||||
@ -183,7 +183,7 @@ package types
|
|||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "highBid",
|
// "highBid",
|
||||||
// ReverseAuction{BaseAuction{
|
// DebtAuction{BaseAuction{
|
||||||
// Initiator: buyer,
|
// Initiator: buyer,
|
||||||
// Lot: c("kava", 10),
|
// Lot: c("kava", 10),
|
||||||
// Bidder: seller1,
|
// Bidder: seller1,
|
||||||
@ -201,7 +201,7 @@ package types
|
|||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "equalBid",
|
// "equalBid",
|
||||||
// ReverseAuction{BaseAuction{
|
// DebtAuction{BaseAuction{
|
||||||
// Initiator: buyer,
|
// Initiator: buyer,
|
||||||
// Lot: c("kava", 10),
|
// Lot: c("kava", 10),
|
||||||
// Bidder: seller1,
|
// Bidder: seller1,
|
||||||
@ -219,7 +219,7 @@ package types
|
|||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "timeout",
|
// "timeout",
|
||||||
// ReverseAuction{BaseAuction{
|
// DebtAuction{BaseAuction{
|
||||||
// Initiator: buyer,
|
// Initiator: buyer,
|
||||||
// Lot: c("kava", 10),
|
// Lot: c("kava", 10),
|
||||||
// Bidder: seller1,
|
// Bidder: seller1,
|
||||||
@ -237,7 +237,7 @@ package types
|
|||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "hitMaxEndTime",
|
// "hitMaxEndTime",
|
||||||
// ReverseAuction{BaseAuction{
|
// DebtAuction{BaseAuction{
|
||||||
// Initiator: buyer,
|
// Initiator: buyer,
|
||||||
// Lot: c("kava", 10),
|
// Lot: c("kava", 10),
|
||||||
// Bidder: seller1,
|
// Bidder: seller1,
|
||||||
@ -276,7 +276,7 @@ package types
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// func TestForwardReverseAuction_PlaceBid(t *testing.T) {
|
// func TestCollateralAuction_PlaceBid(t *testing.T) {
|
||||||
// cdpOwner := sdk.AccAddress([]byte("a_cdp_owner"))
|
// cdpOwner := sdk.AccAddress([]byte("a_cdp_owner"))
|
||||||
// seller := sdk.AccAddress([]byte("a_seller"))
|
// seller := sdk.AccAddress([]byte("a_seller"))
|
||||||
// buyer1 := sdk.AccAddress([]byte("buyer1"))
|
// buyer1 := sdk.AccAddress([]byte("buyer1"))
|
||||||
@ -292,7 +292,7 @@ package types
|
|||||||
// }
|
// }
|
||||||
// tests := []struct {
|
// tests := []struct {
|
||||||
// name string
|
// name string
|
||||||
// auction ForwardReverseAuction
|
// auction CollateralAuction
|
||||||
// args args
|
// args args
|
||||||
// expectedOutputs []BankOutput
|
// expectedOutputs []BankOutput
|
||||||
// expectedInputs []BankInput
|
// expectedInputs []BankInput
|
||||||
@ -304,7 +304,7 @@ package types
|
|||||||
// }{
|
// }{
|
||||||
// {
|
// {
|
||||||
// "normalForwardBid",
|
// "normalForwardBid",
|
||||||
// ForwardReverseAuction{BaseAuction: BaseAuction{
|
// CollateralAuction{BaseAuction: BaseAuction{
|
||||||
// Initiator: seller,
|
// Initiator: seller,
|
||||||
// Lot: c("xrp", 100),
|
// Lot: c("xrp", 100),
|
||||||
// Bidder: buyer1,
|
// Bidder: buyer1,
|
||||||
@ -325,7 +325,7 @@ package types
|
|||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "normalSwitchOverBid",
|
// "normalSwitchOverBid",
|
||||||
// ForwardReverseAuction{BaseAuction: BaseAuction{
|
// CollateralAuction{BaseAuction: BaseAuction{
|
||||||
// Initiator: seller,
|
// Initiator: seller,
|
||||||
// Lot: c("xrp", 100),
|
// Lot: c("xrp", 100),
|
||||||
// Bidder: buyer1,
|
// Bidder: buyer1,
|
||||||
@ -345,8 +345,8 @@ package types
|
|||||||
// true,
|
// true,
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "normalReverseBid",
|
// "normalDebtBid",
|
||||||
// ForwardReverseAuction{BaseAuction: BaseAuction{
|
// CollateralAuction{BaseAuction: BaseAuction{
|
||||||
// Initiator: seller,
|
// Initiator: seller,
|
||||||
// Lot: c("xrp", 99),
|
// Lot: c("xrp", 99),
|
||||||
// Bidder: buyer1,
|
// Bidder: buyer1,
|
||||||
|
@ -17,7 +17,7 @@ func RegisterCodec(cdc *codec.Codec) {
|
|||||||
|
|
||||||
// Register the Auction interface and concrete types
|
// Register the Auction interface and concrete types
|
||||||
cdc.RegisterInterface((*Auction)(nil), nil)
|
cdc.RegisterInterface((*Auction)(nil), nil)
|
||||||
cdc.RegisterConcrete(ForwardAuction{}, "auction/ForwardAuction", nil)
|
cdc.RegisterConcrete(SurplusAuction{}, "auction/SurplusAuction", nil)
|
||||||
cdc.RegisterConcrete(ReverseAuction{}, "auction/ReverseAuction", nil)
|
cdc.RegisterConcrete(DebtAuction{}, "auction/DebtAuction", nil)
|
||||||
cdc.RegisterConcrete(ForwardReverseAuction{}, "auction/ForwardReverseAuction", nil)
|
cdc.RegisterConcrete(CollateralAuction{}, "auction/CollateralAuction", nil)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user