MCPcopy Create free account
hub / github.com/Sifchain/sifnode / GetCloseCmd

Function GetCloseCmd

x/margin/client/cli/tx.go:111–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

109}
110
111func GetCloseCmd() *cobra.Command {
112 cmd := &cobra.Command{
113 Use: "close",
114 Short: "Close margin position",
115 RunE: func(cmd *cobra.Command, args []string) error {
116 clientCtx, err := client.GetClientTxContext(cmd)
117 if err != nil {
118 return err
119 }
120
121 signer := clientCtx.GetFromAddress()
122 if signer == nil {
123 return errors.New("signer address is missing")
124 }
125
126 id, err := cmd.Flags().GetUint64("id")
127 if err != nil {
128 return err
129 }
130
131 msg := types.MsgClose{
132 Signer: signer.String(),
133 Id: id,
134 }
135
136 return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
137 },
138 }
139 cmd.Flags().Uint64("id", 0, "id of the position")
140 _ = cmd.MarkFlagRequired("id")
141 flags.AddTxFlagsToCmd(cmd)
142 return cmd
143}
144
145func GetForceCloseCmd() *cobra.Command {
146 cmd := &cobra.Command{

Callers 1

GetTxCmdFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected