From ddbf22524555f278896a920bd573914ef062939c Mon Sep 17 00:00:00 2001 From: Chandragupta Singh Date: Thu, 16 Jun 2022 11:54:32 +0530 Subject: [PATCH 1/2] dutch changes --- proto/comdex/auction/v1beta1/tx.proto | 8 +- x/auction/client/cli/tx.go | 10 +- x/auction/keeper/dutch.go | 75 ++++++++------- x/auction/keeper/math.go | 3 +- x/auction/keeper/msg_server.go | 2 +- x/auction/types/msg.go | 4 +- x/auction/types/tx.pb.go | 129 ++++++++++++++++++-------- 7 files changed, 147 insertions(+), 84 deletions(-) diff --git a/proto/comdex/auction/v1beta1/tx.proto b/proto/comdex/auction/v1beta1/tx.proto index dd0ab0dd0..62940eea9 100644 --- a/proto/comdex/auction/v1beta1/tx.proto +++ b/proto/comdex/auction/v1beta1/tx.proto @@ -34,10 +34,10 @@ message MsgPlaceDutchBidRequest { uint64 auction_id = 1; string bidder = 2; cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; - // string max= 4 [ - // (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - // (gogoproto.nullable) = false, - // (gogoproto.moretags) = "yaml:\"max\""]; + string max= 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"max\""]; uint64 app_id =5; uint64 auction_mapping_id =6; } diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index 82fb72aea..17893330d 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -105,9 +105,9 @@ func txPlaceDebtBid() *cobra.Command { func txPlaceDutchBid() *cobra.Command { cmd := &cobra.Command{ - Use: "bid-dutch [auction-id] [amount] [app-id] [auction-mapping-id]", + Use: "bid-dutch [auction-id] [amount] [maxamountpercollateraltoken] [app-id] [auction-mapping-id]", Short: "Place a Dutch bid on an auction", - Args: cobra.ExactArgs(4), + Args: cobra.ExactArgs(5), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -131,12 +131,14 @@ func txPlaceDutchBid() *cobra.Command { return fmt.Errorf("auction-id '%s' not a valid uint", args[0]) } - auctionMappingId, err := strconv.ParseUint(args[3], 10, 64) + max := sdk.MustNewDecFromStr(args[3]) + + auctionMappingId, err := strconv.ParseUint(args[4], 10, 64) if err != nil { return fmt.Errorf("auction-id '%s' not a valid uint", args[0]) } - msg := types.NewMsgPlaceDutchBid(clientCtx.GetFromAddress(), auctionId, amt, appId, auctionMappingId) + msg := types.NewMsgPlaceDutchBid(clientCtx.GetFromAddress(), auctionId, amt, max, appId, auctionMappingId) err = msg.ValidateBasic() if err != nil { return err diff --git a/x/auction/keeper/dutch.go b/x/auction/keeper/dutch.go index 5f50ee74f..c871e593d 100644 --- a/x/auction/keeper/dutch.go +++ b/x/auction/keeper/dutch.go @@ -1,7 +1,6 @@ package keeper import ( - "fmt" "time" vaulttypes "github.com/comdex-official/comdex/x/vault/types" @@ -185,7 +184,7 @@ func (k Keeper) StartDutchAuction( return nil } -func (k Keeper) PlaceDutchAuctionBid(ctx sdk.Context, appId, auctionMappingId, auctionId uint64, bidder sdk.AccAddress, bid sdk.Coin) error { +func (k Keeper) PlaceDutchAuctionBid(ctx sdk.Context, appId, auctionMappingId, auctionId uint64, bidder sdk.AccAddress, bid sdk.Coin, max sdk.Dec) error { auction, err := k.GetDutchAuction(ctx, appId, auctionMappingId, auctionId) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrNotFound, "auction id %d not found", auctionId) @@ -197,6 +196,13 @@ func (k Keeper) PlaceDutchAuctionBid(ctx sdk.Context, appId, auctionMappingId, a return sdkerrors.Wrapf(sdkerrors.ErrNotFound, "bid denom can't be greater than collateral available") } + max = k.GetUUSDFromUSD(ctx, max) + + //Here OutflowToken current price is in uusd and max is in uusd + if max.LT(auction.OutflowTokenCurrentPrice.Ceil()) { + return auctiontypes.ErrorInvalidDutchPrice + } + // slice tells amount of collateral user should be given //using ceil as we need extract more from users outFlowTokenCurrentPrice := auction.OutflowTokenCurrentPrice.Ceil().TruncateInt() //cmdx @@ -208,12 +214,15 @@ func (k Keeper) PlaceDutchAuctionBid(ctx sdk.Context, appId, auctionMappingId, a b:= auction.InflowTokenCurrentAmount.Amount tab := a.Sub(b) // extra will be send to collector - extraCoin := sdk.NewCoin(auction.InflowTokenCurrentAmount.Denom, sdk.ZeroInt()) + // extraCoin := sdk.NewCoin(auction.InflowTokenCurrentAmount.Denom, sdk.ZeroInt()) //owe is $cmdx to be given to user owe := slice.Mul(outFlowTokenCurrentPrice) inFlowTokenAmount := owe.Quo(inFlowTokenCurrentPrice) if inFlowTokenAmount.GT(tab) { - extraCoin.Amount = inFlowTokenAmount.Sub(tab) + // extraCoin.Amount = inFlowTokenAmount.Sub(tab) + inFlowTokenAmount = tab + owe = inFlowTokenAmount.Mul(inFlowTokenCurrentPrice) + slice = owe.Quo(outFlowTokenCurrentPrice) } inFlowTokenCoin := sdk.NewCoin(auction.InflowTokenTargetAmount.Denom, inFlowTokenAmount) @@ -270,14 +279,14 @@ func (k Keeper) PlaceDutchAuctionBid(ctx sdk.Context, appId, auctionMappingId, a if err != nil { return err } - err = k.SendCoinsFromModuleToModule(ctx, auctiontypes.ModuleName, collectortypes.ModuleName, sdk.NewCoins(extraCoin)) - if err != nil { - return err - } - err = k.SetNetFeeCollectedData(ctx, auction.AppId, auction.AssetOutId, extraCoin.Amount) - if err != nil { - return err - } + // err = k.SendCoinsFromModuleToModule(ctx, auctiontypes.ModuleName, collectortypes.ModuleName, sdk.NewCoins(extraCoin)) + // if err != nil { + // return err + // } + // err = k.SetNetFeeCollectedData(ctx, auction.AppId, auction.AssetOutId, extraCoin.Amount) + // if err != nil { + // return err + // } //create user bidding biddingId, err := k.CreateNewDutchBid(ctx, appId, auctionMappingId, auctionId, bidder, inFlowTokenCoin, outFlowTokenCoin) if err != nil { @@ -291,7 +300,7 @@ func (k Keeper) PlaceDutchAuctionBid(ctx sdk.Context, appId, auctionMappingId, a //calculate inflow amount and outflow amount if user transaction successfull auction.OutflowTokenCurrentAmount = auction.OutflowTokenCurrentAmount.Sub(outFlowTokenCoin) - auction.InflowTokenCurrentAmount = auction.InflowTokenCurrentAmount.Add(inFlowTokenCoin.Sub(extraCoin)) + auction.InflowTokenCurrentAmount = auction.InflowTokenCurrentAmount.Add(inFlowTokenCoin) //collateral not over but target cmst reached then send remaining collateral to owner //if inflow token current amount >= InflowTokenTargetAmount @@ -307,7 +316,7 @@ func (k Keeper) PlaceDutchAuctionBid(ctx sdk.Context, appId, auctionMappingId, a // if err != nil { // return err // } - auction.ToBurnAmount = auction.ToBurnAmount.Add(inFlowTokenCoin.Sub(extraCoin)) + auction.ToBurnAmount = auction.ToBurnAmount.Add(inFlowTokenCoin) err = k.SetDutchAuction(ctx, auction) if err != nil { @@ -322,7 +331,7 @@ func (k Keeper) PlaceDutchAuctionBid(ctx sdk.Context, appId, auctionMappingId, a } } else if auction.OutflowTokenCurrentAmount.Amount.IsZero() { //entire collateral sold out - auction.ToBurnAmount = auction.ToBurnAmount.Add(inFlowTokenCoin.Sub(extraCoin)) + auction.ToBurnAmount = auction.ToBurnAmount.Add(inFlowTokenCoin) err = k.SetDutchAuction(ctx, auction) if err != nil { @@ -336,7 +345,7 @@ func (k Keeper) PlaceDutchAuctionBid(ctx sdk.Context, appId, auctionMappingId, a return err } } else { - auction.ToBurnAmount = auction.ToBurnAmount.Add(inFlowTokenCoin.Sub(extraCoin)) + auction.ToBurnAmount = auction.ToBurnAmount.Add(inFlowTokenCoin) err = k.SetDutchAuction(ctx, auction) @@ -402,14 +411,19 @@ func (k Keeper) CloseDutchAuction( } //calculate penalty - penaltyCoin := sdk.NewCoin(dutchAuction.InflowTokenCurrentAmount.Denom, sdk.ZeroInt()) + // penaltyCoin := sdk.NewCoin(dutchAuction.InflowTokenCurrentAmount.Denom, sdk.ZeroInt()) // penaltyCoin.Amount = dutchAuction.InflowTokenCurrentAmount.Amount.Mul(dutchAuction.LiquidationPenalty.TruncateInt()) // burn and send target CMST to collector - burnToken := sdk.NewCoin(dutchAuction.InflowTokenCurrentAmount.Denom, sdk.ZeroInt()) + // burnToken := sdk.NewCoin(dutchAuction.InflowTokenCurrentAmount.Denom, sdk.ZeroInt()) + + // penaltyCoin.Amount = (burnToken.Amount.Mul(dutchAuction.LiquidationPenalty.TruncateInt())).Quo(dutchAuction.LiquidationPenalty.TruncateInt().Add(sdk.NewIntFromUint64(1))) + // burnToken.Amount = dutchAuction.ToBurnAmount.Amount.Sub(penaltyCoin.Amount) + + newcmstRecover := sdk.NewCoin(dutchAuction.InflowTokenCurrentAmount.Denom, sdk.ZeroInt()) + cmstRecovered := lockedVault.CollateralToBeAuctioned.Quo(dutchAuction.LiquidationPenalty.Add(sdk.MustNewDecFromStr("1"))) + newcmstRecover.Amount = cmstRecovered.Quo(sdk.NewDec(1000000)).TruncateInt() + sendtoCollector := dutchAuction.ToBurnAmount.Amount.ToDec().Sub(sdk.Dec(newcmstRecover.Amount)) - penaltyCoin.Amount = (burnToken.Amount.Mul(dutchAuction.LiquidationPenalty.TruncateInt())).Quo(dutchAuction.LiquidationPenalty.TruncateInt().Add(sdk.NewIntFromUint64(1))) - burnToken.Amount = dutchAuction.ToBurnAmount.Amount.Sub(penaltyCoin.Amount) - fmt.Print("burnToken amount", burnToken.Amount) //doing burn amount = inflowtokencurrentamount / (1 + liq_penalty) // burnToken.Amount = burnToken.Amount.Add(k.getBurnAmount(dutchAuction.InflowTokenCurrentAmount.Amount, dutchAuction.LiquidationPenalty)) // burnToken.Amount = dutchAuction.InflowTokenCurrentAmount.Amount.Sub(penaltyAmount) @@ -440,27 +454,26 @@ func (k Keeper) CloseDutchAuction( } //burning - err1 := k.BurnCoins(ctx, auctiontypes.ModuleName, burnToken.Sub(penaltyCoin)) + err1 := k.BurnCoins(ctx, auctiontypes.ModuleName, newcmstRecover) if err1 != nil { return err1 } //send penalty - err := k.SendCoinsFromModuleToModule(ctx, auctiontypes.ModuleName, collectortypes.ModuleName, sdk.NewCoins(sdk.NewCoin(penaltyCoin.Denom, penaltyCoin.Amount))) + err := k.SendCoinsFromModuleToModule(ctx, auctiontypes.ModuleName, collectortypes.ModuleName, sdk.NewCoins(sdk.NewCoin(newcmstRecover.Denom, sendtoCollector.TruncateInt()))) if err != nil { return err } //call increase function in collector - err = k.SetNetFeeCollectedData(ctx, dutchAuction.AppId, dutchAuction.AssetInId, penaltyCoin.Amount) + err = k.SetNetFeeCollectedData(ctx, dutchAuction.AppId, dutchAuction.AssetInId, sendtoCollector.TruncateInt()) if err != nil { return err } lockedVault.AmountIn = lockedVault.AmountIn.Sub(dutchAuction.OutflowTokenInitAmount.Amount.Sub(dutchAuction.OutflowTokenCurrentAmount.Amount)) - lockedVault.AmountOut = lockedVault.AmountOut.Sub(burnToken.Amount) - lockedVault.UpdatedAmountOut = lockedVault.UpdatedAmountOut.Sub(burnToken.Amount) - fmt.Println("lockedVault.AmountIn",lockedVault.AmountIn) - fmt.Println("lockedVault.AmountOut",lockedVault.AmountOut) + lockedVault.AmountOut = lockedVault.AmountOut.Sub(newcmstRecover.Amount) + lockedVault.UpdatedAmountOut = lockedVault.UpdatedAmountOut.Sub(newcmstRecover.Amount) + //set sell of history in locked vault outFlowToken := dutchAuction.OutflowTokenInitAmount.Sub(dutchAuction.OutflowTokenCurrentAmount) @@ -471,7 +484,7 @@ func (k Keeper) CloseDutchAuction( dutchAuction.AuctionStatus = auctiontypes.AuctionEnded - err = k.UpdateProtocolData(ctx, dutchAuction, burnToken) + err = k.UpdateProtocolData(ctx, dutchAuction, newcmstRecover) if err != nil { return err } @@ -566,7 +579,7 @@ func (k Keeper) RestartDutchAuctions(ctx sdk.Context, appId uint64) error { return nil } -func (k Keeper) UpdateProtocolData(ctx sdk.Context, auction auctiontypes.DutchAuction, burnToken sdk.Coin ) error { +func (k Keeper) UpdateProtocolData(ctx sdk.Context, auction auctiontypes.DutchAuction, newcmstRecover sdk.Coin ) error { lockedVault, found1 := k.GetLockedVault(ctx, auction.LockedVaultId) if !found1 { return auctiontypes.ErrorVaultNotFound @@ -582,7 +595,7 @@ func (k Keeper) UpdateProtocolData(ctx sdk.Context, auction auctiontypes.DutchAu return sdkerrors.ErrNotFound } - k.UpdateTokenMintedAmountLockerMapping(ctx, appExtendedPairVaultData, ExtendedPairVault.Id, burnToken.Amount, false) + k.UpdateTokenMintedAmountLockerMapping(ctx, appExtendedPairVaultData, ExtendedPairVault.Id, newcmstRecover.Amount, false) k.UpdateCollateralLockedAmountLockerMapping(ctx, appExtendedPairVaultData, ExtendedPairVault.Id, auction.OutflowTokenInitAmount.Amount.Sub(auction.OutflowTokenCurrentAmount.Amount), false) return nil } \ No newline at end of file diff --git a/x/auction/keeper/math.go b/x/auction/keeper/math.go index f6bed05a9..09c2f11a7 100644 --- a/x/auction/keeper/math.go +++ b/x/auction/keeper/math.go @@ -34,7 +34,8 @@ func (k Keeper) getOutflowTokenInitialPrice(price sdk.Int, buffer sdk.Dec) sdk.D } func (k Keeper) getOutflowTokenEndPrice(price, cusp , liquidationPenalty sdk.Dec) sdk.Dec { - result := price.Sub(Multiply(price, liquidationPenalty)) + denomination := liquidationPenalty.Add(sdk.MustNewDecFromStr("1")) + result := price.Quo(denomination) return result } diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index 2cc8fdaa9..6180e3458 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -49,7 +49,7 @@ func (k msgServer) MsgPlaceDutchBid(goCtx context.Context, msg *types.MsgPlaceDu if err != nil { return nil, err } - err = k.PlaceDutchAuctionBid(ctx, msg.AppId, msg.AuctionMappingId, msg.AuctionId, bidder, msg.Amount) + err = k.PlaceDutchAuctionBid(ctx, msg.AppId, msg.AuctionMappingId, msg.AuctionId, bidder, msg.Amount, msg.Max) if err != nil { return nil, err } diff --git a/x/auction/types/msg.go b/x/auction/types/msg.go index a19b4a148..71b952417 100644 --- a/x/auction/types/msg.go +++ b/x/auction/types/msg.go @@ -75,12 +75,12 @@ func (m *MsgPlaceDebtBidRequest) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{from} } -func NewMsgPlaceDutchBid(from sdk.AccAddress, auctionID uint64, amt sdk.Coin, appId, auctionMappingId uint64) *MsgPlaceDutchBidRequest { +func NewMsgPlaceDutchBid(from sdk.AccAddress, auctionID uint64, amt sdk.Coin, max sdk.Dec, appId, auctionMappingId uint64) *MsgPlaceDutchBidRequest { return &MsgPlaceDutchBidRequest{ Bidder: from.String(), AuctionId: auctionID, Amount: amt, - // Max: max, + Max: max, AppId: appId, AuctionMappingId: auctionMappingId, } diff --git a/x/auction/types/tx.pb.go b/x/auction/types/tx.pb.go index 038a80f8b..d84c8c5ca 100644 --- a/x/auction/types/tx.pb.go +++ b/x/auction/types/tx.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -185,15 +186,12 @@ func (m *MsgPlaceDebtBidResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgPlaceDebtBidResponse proto.InternalMessageInfo type MsgPlaceDutchBidRequest struct { - AuctionId uint64 `protobuf:"varint,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"` - Bidder string `protobuf:"bytes,2,opt,name=bidder,proto3" json:"bidder,omitempty"` - Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` - // string max= 4 [ - // (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - // (gogoproto.nullable) = false, - // (gogoproto.moretags) = "yaml:\"max\""]; - AppId uint64 `protobuf:"varint,5,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"` - AuctionMappingId uint64 `protobuf:"varint,6,opt,name=auction_mapping_id,json=auctionMappingId,proto3" json:"auction_mapping_id,omitempty"` + AuctionId uint64 `protobuf:"varint,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"` + Bidder string `protobuf:"bytes,2,opt,name=bidder,proto3" json:"bidder,omitempty"` + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` + Max github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=max,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max" yaml:"max"` + AppId uint64 `protobuf:"varint,5,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"` + AuctionMappingId uint64 `protobuf:"varint,6,opt,name=auction_mapping_id,json=auctionMappingId,proto3" json:"auction_mapping_id,omitempty"` } func (m *MsgPlaceDutchBidRequest) Reset() { *m = MsgPlaceDutchBidRequest{} } @@ -277,38 +275,41 @@ func init() { func init() { proto.RegisterFile("comdex/auction/v1beta1/tx.proto", fileDescriptor_a8457d7b1ca5de6a) } var fileDescriptor_a8457d7b1ca5de6a = []byte{ - // 485 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0xbf, 0x8f, 0xd3, 0x30, - 0x14, 0x4e, 0xfa, 0x23, 0xd2, 0x3d, 0x06, 0x0e, 0x0b, 0x4a, 0x1b, 0x41, 0xae, 0xea, 0xd4, 0x01, - 0x1c, 0x52, 0x06, 0xf6, 0xc2, 0xd2, 0xa1, 0x12, 0xea, 0xc1, 0xc2, 0x82, 0x9c, 0xd8, 0x97, 0xb3, - 0x68, 0x63, 0x13, 0x3b, 0xa8, 0x88, 0x7f, 0x82, 0x89, 0xbf, 0x81, 0x3f, 0xa5, 0x13, 0xea, 0xc8, - 0x84, 0xa0, 0x9d, 0xf9, 0x1f, 0x50, 0x62, 0x17, 0xee, 0xae, 0x77, 0x6a, 0xd1, 0x2d, 0xb7, 0xd5, - 0x7d, 0xdf, 0xfb, 0xde, 0xf7, 0x7d, 0x79, 0x36, 0x1c, 0x25, 0x62, 0x46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27, 0x53, 0x7b, 0x0e, 0xff, 0xbd, 0x97, 0xfa, 0xa3, - 0x64, 0x2a, 0xf6, 0xaa, 0xd7, 0xed, 0xe9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8e, 0xd1, 0x5a, - 0x2e, 0x4e, 0x05, 0x00, 0x00, + // 536 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0x31, 0x8f, 0xd3, 0x30, + 0x18, 0x4d, 0xda, 0x6b, 0xa5, 0x7e, 0x0c, 0x1c, 0x16, 0x94, 0x36, 0x82, 0xb4, 0xea, 0x80, 0x3a, + 0x70, 0x0e, 0x2d, 0x03, 0x12, 0x62, 0x2a, 0xb7, 0x74, 0x28, 0x42, 0x3d, 0x58, 0x58, 0x90, 0x13, + 0xfb, 0x72, 0xd6, 0x35, 0xb1, 0xa9, 0x1d, 0xd4, 0x13, 0x7f, 0x82, 0x89, 0x91, 0x99, 0x9f, 0xd2, + 0xb1, 0x23, 0x62, 0xa8, 0xa0, 0x9d, 0x59, 0xf8, 0x05, 0x28, 0x89, 0x0b, 0xd7, 0xeb, 0x9d, 0x5a, + 0x04, 0x12, 0x53, 0xe2, 0xbc, 0xe7, 0xf7, 0x7d, 0xdf, 0xcb, 0xb3, 0xa1, 0x11, 0x88, 0x88, 0xb2, + 0x89, 0x47, 0x92, 0x40, 0x73, 0x11, 0x7b, 0x6f, 0x3b, 0x3e, 0xd3, 0xa4, 0xe3, 0xe9, 0x09, 0x96, + 0x63, 0xa1, 0x05, 0xaa, 0xe6, 0x04, 0x6c, 0x08, 0xd8, 0x10, 0x9c, 0x9b, 0xa1, 0x08, 0x45, 0x46, + 0xf1, 0xd2, 0xb7, 0x9c, 0xed, 0xb8, 0x81, 0x50, 0x91, 0x50, 0x9e, 0x4f, 0x14, 0xfb, 0xa5, 0x15, + 0x08, 0x1e, 0xe7, 0x78, 0x6b, 0x66, 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, 0xbf, 0x59, 0x78, 0xfc, 0x72, 0x76, 0x5b, 0x3e, 0xfc, 0x19, 0x00, 0x00, 0xff, 0xff, + 0x25, 0xa9, 0x30, 0x36, 0x9e, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -659,6 +660,16 @@ func (m *MsgPlaceDutchBidRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x28 } + { + size := m.Max.Size() + i -= size + if _, err := m.Max.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 { size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -801,6 +812,8 @@ func (m *MsgPlaceDutchBidRequest) Size() (n int) { } l = m.Amount.Size() n += 1 + l + sovTx(uint64(l)) + l = m.Max.Size() + n += 1 + l + sovTx(uint64(l)) if m.AppId != 0 { n += 1 + sovTx(uint64(m.AppId)) } @@ -1415,6 +1428,40 @@ func (m *MsgPlaceDutchBidRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Max", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Max.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field AppId", wireType) From a5df78696f0ebf4604c85917e901579a9d19fe25 Mon Sep 17 00:00:00 2001 From: Chandragupta Singh Date: Thu, 16 Jun 2022 21:00:48 +0530 Subject: [PATCH 2/2] lot size change --- x/auction/keeper/debt.go | 2 +- x/auction/keeper/surplus.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/auction/keeper/debt.go b/x/auction/keeper/debt.go index 402e8709d..50a79ee7c 100644 --- a/x/auction/keeper/debt.go +++ b/x/auction/keeper/debt.go @@ -85,7 +85,7 @@ func (k Keeper) checkStatusOfNetFeesCollectedAndStartDebtAuction(ctx sdk.Context assetInId := collector.CollectorAssetId assetOutId := collector.SecondaryAssetId //net = 200 debtThreshhold = 500 , lotsize = 100 - amount := sdk.NewIntFromUint64(collector.DebtThreshold).Sub(AssetIdToFeeCollected.NetFeesCollected) + amount := sdk.NewIntFromUint64(collector.LotSize) status, outflowToken, inflowToken := k.getDebtSellTokenAmount(ctx, appId, assetInId, assetOutId, amount) if status == auctiontypes.NoAuction { diff --git a/x/auction/keeper/surplus.go b/x/auction/keeper/surplus.go index ea91cbc24..05488b1c4 100644 --- a/x/auction/keeper/surplus.go +++ b/x/auction/keeper/surplus.go @@ -88,7 +88,7 @@ func (k Keeper) checkStatusOfNetFeesCollectedAndStartSurplusAuction(ctx sdk.Cont assetSellId := collector.CollectorAssetId //net = 900 surplusThreshhold = 500 , lotsize = 100 - amount := AssetIdToFeeCollected.NetFeesCollected.Sub(sdk.NewIntFromUint64(collector.SurplusThreshold)) + amount := sdk.NewIntFromUint64(collector.LotSize) status, sellToken, buyToken := k.getSurplusBuyTokenAmount(ctx, appId, assetBuyId, assetSellId, amount)