Skip to content

Commit

Permalink
Create Pool Logic finished
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Dusek committed Apr 18, 2024
1 parent 9fd76c0 commit 964eaba
Showing 1 changed file with 49 additions and 7 deletions.
56 changes: 49 additions & 7 deletions x/market/keeper/msg_server_create_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,55 @@ func (k msgServer) CreatePool(goCtx context.Context, msg *types.MsgCreatePool) (
return nil, sdkError
}

_ = member1
_ = member2
_ = pair
_ = pool
_ = found
_ = ctx
_ = creator
// Drops define proportional ownership to the liquidity in the pool
drops := coinPair.AmountOf(denom1).Mul(coinPair.AmountOf(denom2))

leader := types.Leader{
Address: msg.Creator,
Drops: drops,
}

if found {
pool.Drops = drops
pool.Leaders = []*types.Leader{&leader}
member1.Balance = coinPair.AmountOf(denom1)
member2.Balance = coinPair.AmountOf(denom2)
} else {
pool = types.Pool{
Pair: pair,
Leaders: []*types.Leader{&leader},
Denom1: coinPair.GetDenomByIndex(0),
Denom2: coinPair.GetDenomByIndex(1),
Volume1: &types.Volume{
Denom: coinPair.GetDenomByIndex(0),
Amount: math.ZeroInt(),
},
Volume2: &types.Volume{
Denom: coinPair.GetDenomByIndex(1),
Amount: math.ZeroInt(),
},
Drops: drops,
History: uint64(0),
}

member1 = types.Member{
Pair: pair,
DenomA: denom2,
DenomB: denom1,
Balance: coinPair.AmountOf(denom1),
Limit: 0,
Stop: 0,
}

member2 = types.Member{
Pair: pair,
DenomA: denom1,
DenomB: denom2,
Balance: coinPair.AmountOf(denom2),
Limit: 0,
Stop: 0,
}
}

return &types.MsgCreatePoolResponse{}, nil
}

0 comments on commit 964eaba

Please sign in to comment.