From 424f20beacf86138d69eea0fca270b57753158d6 Mon Sep 17 00:00:00 2001 From: Chandragupta Singh Date: Thu, 23 Jun 2022 03:44:12 +0530 Subject: [PATCH] auction changes --- x/auction/keeper/debt.go | 2 ++ x/auction/keeper/dutch.go | 5 ++++- x/auction/keeper/surplus.go | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/x/auction/keeper/debt.go b/x/auction/keeper/debt.go index cda9e450e..c3e330111 100644 --- a/x/auction/keeper/debt.go +++ b/x/auction/keeper/debt.go @@ -135,6 +135,7 @@ func (k Keeper) startDebtAuction( ActiveBiddingId: 0, Bidder: nil, EndTime: ctx.BlockTime().Add(time.Second * time.Duration(auctionParams.AuctionDurationSeconds)), + BidEndTime: ctx.BlockTime().Add(time.Second * time.Duration(auctionParams.AuctionDurationSeconds)), CurrentBidAmount: sdk.NewCoin(auctionToken.Denom, sdk.NewInt(0)), AuctionStatus: auctiontypes.AuctionStartNoBids, AppId: appID, @@ -190,6 +191,7 @@ func (k Keeper) RestartDebt( } debtAuction.ExpectedUserToken = inflowToken debtAuction.EndTime = ctx.BlockTime().Add(time.Second * time.Duration(auctionParams.AuctionDurationSeconds)) + debtAuction.BidEndTime = ctx.BlockTime().Add(time.Second * time.Duration(auctionParams.AuctionDurationSeconds)) err := k.SetDebtAuction(ctx, debtAuction) if err != nil { return err diff --git a/x/auction/keeper/dutch.go b/x/auction/keeper/dutch.go index 8fc8c077f..32fb17367 100644 --- a/x/auction/keeper/dutch.go +++ b/x/auction/keeper/dutch.go @@ -554,7 +554,10 @@ func (k Keeper) RestartDutchAuctions(ctx sdk.Context, appID uint64) error { inFlowTokenCurrentPrice = ExtendedPairVault.AssetOutPrice } //inFlowTokenCurrentPrice := sdk.MustNewDecFromStr("1") - tau := sdk.NewInt(int64(auctionParams.AuctionDurationSeconds)) + // tau := sdk.NewInt(int64(auctionParams.AuctionDurationSeconds)) + tnume := dutchAuction.OutflowTokenInitialPrice.Mul(sdk.NewDecFromInt(sdk.NewIntFromUint64(auctionParams.AuctionDurationSeconds))) + tdeno := dutchAuction.OutflowTokenInitialPrice.Sub(dutchAuction.OutflowTokenEndPrice) + tau := sdk.Int(tnume.Quo(tdeno)) dur := ctx.BlockTime().Sub(dutchAuction.StartTime) seconds := sdk.NewInt(int64(dur.Seconds())) outFlowTokenCurrentPrice := k.getPriceFromLinearDecreaseFunction(dutchAuction.OutflowTokenInitialPrice, tau, seconds) diff --git a/x/auction/keeper/surplus.go b/x/auction/keeper/surplus.go index 24ab02eb8..762ef9a22 100644 --- a/x/auction/keeper/surplus.go +++ b/x/auction/keeper/surplus.go @@ -139,6 +139,7 @@ func (k Keeper) startSurplusAuction( Bidder: nil, Bid: buyToken, EndTime: ctx.BlockTime().Add(time.Second * time.Duration(auctionParams.AuctionDurationSeconds)), + BidEndTime: ctx.BlockTime().Add(time.Second * time.Duration(auctionParams.AuctionDurationSeconds)), BidFactor: bidFactor, BiddingIds: []*auctiontypes.BidOwnerMapping{}, AuctionStatus: auctiontypes.AuctionStartNoBids, @@ -193,6 +194,7 @@ func (k Keeper) RestartSurplus( surplusAuction.BuyToken = buyToken surplusAuction.Bid = buyToken surplusAuction.EndTime = ctx.BlockTime().Add(time.Second * time.Duration(auctionParams.AuctionDurationSeconds)) + surplusAuction.BidEndTime = ctx.BlockTime().Add(time.Second * time.Duration(auctionParams.AuctionDurationSeconds)) err := k.SetSurplusAuction(ctx, surplusAuction) if err != nil { return err