Skip to content

Commit

Permalink
update data initialization in pool & position creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jununifi committed May 20, 2024
1 parent 8572b30 commit 404396f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
12 changes: 11 additions & 1 deletion x/liquiditypool/keeper/msg_server_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@ package keeper
import (
"context"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/sunriselayer/sunrise/x/liquiditypool/types"
)

func (k msgServer) CreatePool(goCtx context.Context, msg *types.MsgCreatePool) (*types.MsgCreatePoolResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

var pool = types.Pool{}
var pool = types.Pool{
Id: 0,
DenomBase: msg.DenomBase,
DenomQuote: msg.DenomQuote,
FeeRate: msg.FeeRate,
TickParams: types.TickParams{}, // TODO:
CurrentTick: 0,
CurrentTickLiquidity: math.LegacyZeroDec(),
CurrentSqrtPrice: math.LegacyZeroDec(),
}
id := k.AppendPool(ctx, pool)

return &types.MsgCreatePoolResponse{
Expand Down
6 changes: 5 additions & 1 deletion x/liquiditypool/keeper/msg_server_position.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/sunriselayer/sunrise/x/liquiditypool/types"
Expand All @@ -20,7 +21,10 @@ func (k msgServer) CreatePosition(goCtx context.Context, msg *types.MsgCreatePos
id := k.AppendPosition(ctx, position)

return &types.MsgCreatePositionResponse{
Id: id,
Id: id,
AmountBase: math.ZeroInt(), // TODO:
AmountQuote: math.ZeroInt(), // TODO:
Liquidity: position.Liquidity,
}, nil
}

Expand Down
5 changes: 1 addition & 4 deletions x/liquiditypool/keeper/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ func (k Keeper) SetPoolCount(ctx context.Context, count uint64) {
}

// AppendPool appends a pool in the store with a new id and update the count
func (k Keeper) AppendPool(
ctx context.Context,
pool types.Pool,
) uint64 {
func (k Keeper) AppendPool(ctx context.Context, pool types.Pool) uint64 {
// Create the pool
count := k.GetPoolCount(ctx)

Expand Down
5 changes: 1 addition & 4 deletions x/liquiditypool/keeper/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ func (k Keeper) SetPositionCount(ctx context.Context, count uint64) {
}

// AppendPosition appends a position in the store with a new id and update the count
func (k Keeper) AppendPosition(
ctx context.Context,
position types.Position,
) uint64 {
func (k Keeper) AppendPosition(ctx context.Context, position types.Position) uint64 {
// Create the position
count := k.GetPositionCount(ctx)

Expand Down

0 comments on commit 404396f

Please sign in to comment.