|
| 1 | +package spot |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "log" |
| 6 | + |
| 7 | + "github.com/UnipayFI/binance-cli/config" |
| 8 | + "github.com/UnipayFI/binance-cli/exchange" |
| 9 | + "github.com/UnipayFI/binance-cli/exchange/spot" |
| 10 | + "github.com/spf13/cobra" |
| 11 | +) |
| 12 | + |
| 13 | +var ( |
| 14 | + feeCmd = &cobra.Command{ |
| 15 | + Use: "fee", |
| 16 | + Short: "BNB payment fee", |
| 17 | + Long: `BNB payment fee.`, |
| 18 | + } |
| 19 | + |
| 20 | + feeBurnStatusCmd = &cobra.Command{ |
| 21 | + Use: "status", |
| 22 | + Aliases: []string{"s"}, |
| 23 | + Short: "Get BNB Burn Status", |
| 24 | + Long: `Get BNB Burn Status. |
| 25 | +
|
| 26 | +Docs Link: https://developers.binance.com/docs/margin_trading/account/Get-BNB-Burn-Status`, |
| 27 | + Run: feeBurnStatus, |
| 28 | + } |
| 29 | + |
| 30 | + feeBurnStatusSetCmd = &cobra.Command{ |
| 31 | + Use: "set", |
| 32 | + Aliases: []string{"c"}, |
| 33 | + Short: "Toggle BNB Burn On Spot Trade And Margin Interest", |
| 34 | + Long: `Toggle BNB Burn On Spot Trade And Margin Interest. |
| 35 | +
|
| 36 | +Docs Link: https://developers.binance.com/docs/wallet/asset/Toggle-BNB-Burn-On-Spot-Trade-And-Margin-Interest`, |
| 37 | + Run: setFeeBurnStatus, |
| 38 | + } |
| 39 | +) |
| 40 | + |
| 41 | +func InitFeeCmds() []*cobra.Command { |
| 42 | + feeBurnStatusSetCmd.Flags().BoolP("spotBNBBurn", "s", false, "Determines whether to use BNB to pay for trading fees on SPOT") |
| 43 | + feeBurnStatusSetCmd.Flags().BoolP("interestBNBBurn", "i", false, "Determines whether to use BNB to pay for margin loan's interest") |
| 44 | + feeBurnStatusSetCmd.MarkFlagRequired("status") |
| 45 | + |
| 46 | + feeCmd.AddCommand(feeBurnStatusCmd, feeBurnStatusSetCmd) |
| 47 | + return []*cobra.Command{feeCmd} |
| 48 | +} |
| 49 | + |
| 50 | +func feeBurnStatus(cmd *cobra.Command, _ []string) { |
| 51 | + client := spot.Client{Client: exchange.NewClient(config.Config.APIKey, config.Config.APISecret)} |
| 52 | + burnStatus, err := client.GetFeeBurnStatus() |
| 53 | + if err != nil { |
| 54 | + log.Fatalf("futures fee burn status error: %v", err) |
| 55 | + } |
| 56 | + fmt.Printf("fee burn spotBNBBurn: %v, interestBNBBurn: %v\n", burnStatus.SpotBNBBurn, burnStatus.InterestBNBBurn) |
| 57 | +} |
| 58 | + |
| 59 | +func setFeeBurnStatus(cmd *cobra.Command, _ []string) { |
| 60 | + spotBNBBurn, _ := cmd.Flags().GetBool("spotBNBBurn") |
| 61 | + interestBNBBurn, _ := cmd.Flags().GetBool("interestBNBBurn") |
| 62 | + client := spot.Client{Client: exchange.NewClient(config.Config.APIKey, config.Config.APISecret)} |
| 63 | + burnStatus, err := client.SetFeeBurnStatus(spotBNBBurn, interestBNBBurn) |
| 64 | + if err != nil { |
| 65 | + log.Fatalf("futures fee burn status change error: %v", err) |
| 66 | + } |
| 67 | + fmt.Printf("fee burn changed to spotBNBBurn: %v, interestBNBBurn: %v\n", burnStatus.SpotBNBBurn, burnStatus.InterestBNBBurn) |
| 68 | +} |
0 commit comments