Skip to content

Commit

Permalink
Add drop fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Dusek committed Jun 9, 2024
1 parent fa12690 commit 89de17b
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions x/market/keeper/msg_server_create_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func (k msgServer) CreatePool(goCtx context.Context, msg *types.MsgCreatePool) (
// The sorted pair joined by "," is used as the key for the pool.
denom1 := coinPair.GetDenomByIndex(0)
denom2 := coinPair.GetDenomByIndex(1)
coin1 := coinPair[0]
coin2 := coinPair[1]
pair := strings.Join([]string{denom1, denom2}, ",")

// Test if pool either exists and active or exists and inactive
Expand Down Expand Up @@ -89,14 +91,14 @@ func (k msgServer) CreatePool(goCtx context.Context, msg *types.MsgCreatePool) (
pool.Drops = drops
pool.Leaders = []*types.Leader{&leader}
pool.LastDrop = count
member1.Balance = coinPair.AmountOf(denom1)
member2.Balance = coinPair.AmountOf(denom2)
member1.Balance = coin1.Amount
member2.Balance = coin2.Amount
} else {
pool = types.Pool{
Pair: pair,
Leaders: []*types.Leader{&leader},
Denom1: coinPair.GetDenomByIndex(0),
Denom2: coinPair.GetDenomByIndex(1),
Denom1: denom1,
Denom2: denom2,
Volume1: &types.Volume{
Denom: coinPair.GetDenomByIndex(0),
Amount: sdk.ZeroInt(),
Expand All @@ -114,7 +116,7 @@ func (k msgServer) CreatePool(goCtx context.Context, msg *types.MsgCreatePool) (
Pair: pair,
DenomA: denom2,
DenomB: denom1,
Balance: coinPair.AmountOf(denom1),
Balance: coin1.Amount,
Limit: 0,
Stop: 0,
}
Expand All @@ -123,19 +125,22 @@ func (k msgServer) CreatePool(goCtx context.Context, msg *types.MsgCreatePool) (
Pair: pair,
DenomA: denom1,
DenomB: denom2,
Balance: coinPair.AmountOf(denom2),
Balance: coin2.Amount,
Limit: 0,
Stop: 0,
}
}

var drop = types.Drop{
Uid: count,
Owner: msg.Creator,
Pair: pair,
Drops: drops,
Product: drops,
Active: true,
Uid: count,
Owner: msg.Creator,
Pair: pair,
Drops: drops,
TimeBeg: ctx.BlockHeader().Time.Unix(),
ProductBeg: drops,
Coin1Beg: coin1,
Coin2Beg: coin2,
Active: true,
}

k.SetPool(
Expand Down Expand Up @@ -167,5 +172,12 @@ func (k msgServer) CreatePool(goCtx context.Context, msg *types.MsgCreatePool) (
// Update drop uid count
k.SetUidCount(ctx, count+1)

return &types.MsgCreatePoolResponse{}, nil
return &types.MsgCreatePoolResponse{
Creator: msg.Creator,
DropUid: drop.Uid,
Pair: pair,
Drops: drop.Drops.String(),
Coin1: coin1.String(),
Coin2: coin2.String(),
}, nil
}

0 comments on commit 89de17b

Please sign in to comment.