From 8b379cc780d0ff4d0559874bd8d98b0a068cb651 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Wed, 5 Jun 2024 23:02:46 -0500 Subject: [PATCH] Pool initialization fix --- x/market/keeper/msg_server_create_pool.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/x/market/keeper/msg_server_create_pool.go b/x/market/keeper/msg_server_create_pool.go index c69f1e13..d8ab39f5 100644 --- a/x/market/keeper/msg_server_create_pool.go +++ b/x/market/keeper/msg_server_create_pool.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "math/big" "strings" sdk "github.com/cosmos/cosmos-sdk/types" @@ -62,7 +63,13 @@ func (k msgServer) CreatePool(goCtx context.Context, msg *types.MsgCreatePool) ( } // Drops define proportional ownership to the liquidity in the pool - drops := coinPair.AmountOf(denom1).Mul(coinPair.AmountOf(denom2)) + // Constant Product Model + // f(x, y) = value of liquidity + // We will define f(x, y) = sqrt(xy) + // InitDrops = Sqrt(denom1.Amount * denom2.Amount) + tmp := big.NewInt(0) + tmp.Sqrt((coinPair.AmountOf(denom1).Mul(coinPair.AmountOf(denom2))).BigInt()) + drops := sdk.NewIntFromBigInt(tmp) leader := types.Leader{ Address: msg.Creator,