Skip to content

Commit

Permalink
add authority check in pool creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jununifi committed May 20, 2024
1 parent aa74b7f commit 2c8afc4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions proto/sunrise/liquiditypool/pool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ message Pool {

// PriceRatio^(Tick - BaseOffSet)
message TickParams {
// Basically 1.0001
string price_ratio = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
// basically 0 and (-1,0]. In the 1:1 stable pair, -0.5 would work
string base_offset = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
Expand Down
4 changes: 4 additions & 0 deletions x/liquiditypool/keeper/msg_server_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
func (k msgServer) CreatePool(goCtx context.Context, msg *types.MsgCreatePool) (*types.MsgCreatePoolResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

if msg.Authority != k.authority {
return nil, types.ErrInvalidSigner
}

var pool = types.Pool{
Id: 0,
DenomBase: msg.DenomBase,
Expand Down
9 changes: 5 additions & 4 deletions x/liquiditypool/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (

// x/liquiditypool module sentinel errors
var (
ErrInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message")
ErrPoolNotFound = sdkerrors.Register(ModuleName, 1101, "pool not found")
ErrInvalidBaseDenom = sdkerrors.Register(ModuleName, 1102, "invalid base denom")
ErrInvalidQuoteDenom = sdkerrors.Register(ModuleName, 1103, "invalid quote denom")
ErrInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message")
ErrPoolNotFound = sdkerrors.Register(ModuleName, 1101, "pool not found")
ErrInvalidBaseDenom = sdkerrors.Register(ModuleName, 1102, "invalid base denom")
ErrInvalidQuoteDenom = sdkerrors.Register(ModuleName, 1103, "invalid quote denom")
ErrInvalidTokenAmounts = sdkerrors.Register(ModuleName, 1104, "invalid token amounts")
)

0 comments on commit 2c8afc4

Please sign in to comment.