mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-24 07:45:15 +00:00
fix withdraw state check
This commit is contained in:
parent
4d24a96778
commit
41163346ea
|
@ -11,6 +11,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func waitWithdrawalsComplete(ctx context.Context, client *maxapi.RestClient, currency string, limit int) error {
|
func waitWithdrawalsComplete(ctx context.Context, client *maxapi.RestClient, currency string, limit int) error {
|
||||||
|
var lastState string
|
||||||
|
for {
|
||||||
withdrawals, err := client.WithdrawalService.NewGetWithdrawalHistoryRequest().
|
withdrawals, err := client.WithdrawalService.NewGetWithdrawalHistoryRequest().
|
||||||
Currency(currency).
|
Currency(currency).
|
||||||
Limit(limit).
|
Limit(limit).
|
||||||
|
@ -19,12 +21,14 @@ func waitWithdrawalsComplete(ctx context.Context, client *maxapi.RestClient, cur
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastState string
|
|
||||||
for {
|
|
||||||
pending := false
|
pending := false
|
||||||
for _, withdrawal := range withdrawals {
|
for _, withdrawal := range withdrawals {
|
||||||
if withdrawal.State != lastState {
|
if lastState == "" {
|
||||||
|
log.Printf("-> %s", withdrawal.State)
|
||||||
|
} else if withdrawal.State != lastState {
|
||||||
log.Printf("%s -> %s", lastState, withdrawal.State)
|
log.Printf("%s -> %s", lastState, withdrawal.State)
|
||||||
|
log.Printf("withdrawal %s %s: %s", withdrawal.Amount, withdrawal.Currency, withdrawal.State)
|
||||||
|
log.Printf("\t%+v", withdrawal)
|
||||||
}
|
}
|
||||||
lastState = withdrawal.State
|
lastState = withdrawal.State
|
||||||
|
|
||||||
|
@ -32,13 +36,14 @@ func waitWithdrawalsComplete(ctx context.Context, client *maxapi.RestClient, cur
|
||||||
case "submitting", "submitted", "pending", "processing", "approved":
|
case "submitting", "submitted", "pending", "processing", "approved":
|
||||||
pending = true
|
pending = true
|
||||||
|
|
||||||
log.Printf("there is a pending withdrawal request, waiting\n")
|
log.Printf("there is a pending withdrawal request, waiting...")
|
||||||
log.Printf("%+v", withdrawal)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
case "sent":
|
case "sent", "confirmed":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
case "rejected":
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user