Skip to content

Commit

Permalink
fix(auction): last bid
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Jun 6, 2024
1 parent 1e0119b commit 370b084
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions x/auction/keeper/rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,21 @@ func (k Keeper) rewardsBid(msg *auction.MsgRewardsBid) error {
sender, err := sdk.AccAddressFromBech32(msg.Sender)
util.Panic(err)

if !bytes.Equal(sender, lastBid.Bidder) {
returned := coin.UmeeInt(lastBid.Amount)
if err = k.sendFromModule(lastBid.Bidder, returned); err != nil {
return err
}
if err = k.sendToModule(sender, msg.Amount); err != nil {
return err
}
} else {
diff := msg.Amount.SubAmount(lastBid.Amount)
if err = k.sendToModule(sender, diff); err != nil {
return err
toAuction := msg.Amount
if lastBid != nil {
if bytes.Equal(sender, lastBid.Bidder) {
// bidder updates his last bid: send only diff
toAuction = msg.Amount.SubAmount(lastBid.Amount)
} else {
returned := coin.UmeeInt(lastBid.Amount)
if err = k.sendFromModule(lastBid.Bidder, returned); err != nil {
return err
}
}
}
if err = k.sendToModule(sender, toAuction); err != nil {
return err
}

bid := auction.Bid{Bidder: sender, Amount: msg.Amount.Amount}
return store.SetValue(k.store, key, &bid, keyMsg)
Expand Down

0 comments on commit 370b084

Please sign in to comment.