| 44 | } |
| 45 | |
| 46 | func GetAdminCloseCmd() *cobra.Command { |
| 47 | cmd := &cobra.Command{ |
| 48 | Use: "admin-close", |
| 49 | Short: "Force close margin position", |
| 50 | RunE: func(cmd *cobra.Command, args []string) error { |
| 51 | clientCtx, err := client.GetClientTxContext(cmd) |
| 52 | if err != nil { |
| 53 | return err |
| 54 | } |
| 55 | |
| 56 | signer := clientCtx.GetFromAddress() |
| 57 | if signer == nil { |
| 58 | return errors.New("signer address is missing") |
| 59 | } |
| 60 | |
| 61 | MtpAddress, err := cmd.Flags().GetString("mtp_address") |
| 62 | if err != nil { |
| 63 | return err |
| 64 | } |
| 65 | |
| 66 | id, err := cmd.Flags().GetUint64("id") |
| 67 | if err != nil { |
| 68 | return err |
| 69 | } |
| 70 | |
| 71 | takeMarginFund, err := cmd.Flags().GetBool("take_margin_fund") |
| 72 | if err != nil { |
| 73 | return err |
| 74 | } |
| 75 | |
| 76 | msg := types.MsgAdminClose{ |
| 77 | Signer: signer.String(), |
| 78 | MtpAddress: MtpAddress, |
| 79 | Id: id, |
| 80 | TakeMarginFund: takeMarginFund, |
| 81 | } |
| 82 | |
| 83 | return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) |
| 84 | }, |
| 85 | } |
| 86 | cmd.Flags().String("mtp_address", "", "mtp address") |
| 87 | cmd.Flags().Uint64("id", 0, "id of the position") |
| 88 | _ = cmd.MarkFlagRequired("mtp_address") |
| 89 | _ = cmd.MarkFlagRequired("id") |
| 90 | cmd.Flags().Bool("take_margin_fund", true, "boolean value to indicate weather margin fund will be deducted on close") |
| 91 | _ = cmd.MarkFlagRequired("take_margin_fund") |
| 92 | flags.AddTxFlagsToCmd(cmd) |
| 93 | return cmd |
| 94 | } |