-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MsgCreateMarketPermissionless msg
Signed-off-by: Shrenuj Bansal <shrenuj@dydx.exchange>
- Loading branch information
Showing
9 changed files
with
646 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
protocol/x/listing/keeper/msg_create_market_permissionless.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/dydxprotocol/v4-chain/protocol/lib" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/listing/types" | ||
) | ||
|
||
func (k msgServer) CreateMarketPermissionless( | ||
goCtx context.Context, | ||
msg *types.MsgCreateMarketPermissionless, | ||
) (*types.MsgCreateMarketPermissionlessResponse, error) { | ||
ctx := lib.UnwrapSDKContext(goCtx, types.ModuleName) | ||
|
||
// Check if the number of listed markets is above the hard cap | ||
numPerpetuals := len(k.PerpetualsKeeper.GetAllPerpetuals(ctx)) | ||
if uint32(numPerpetuals) > k.Keeper.GetMarketsHardCap(ctx) { | ||
return nil, types.ErrMarketsHardCapReached | ||
} | ||
|
||
marketId, err := k.Keeper.CreateMarket(ctx, msg.Ticker) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
perpetualId, err := k.Keeper.CreatePerpetual(ctx, marketId, msg.Ticker) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
_, err = k.Keeper.CreateClobPair(ctx, perpetualId) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// TODO: vault deposit for PML | ||
|
||
return &types.MsgCreateMarketPermissionlessResponse{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.