mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
maxapi: improve withdraw status conversion
This commit is contained in:
parent
ab20b6db89
commit
6bc8dffe16
|
@ -340,3 +340,27 @@ func convertWebSocketOrderUpdate(u max.OrderUpdate) (*types.Order, error) {
|
|||
UpdateTime: types.Time(time.Unix(0, u.UpdateTime*int64(time.Millisecond))),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func convertWithdrawStatus(state max.WithdrawState) types.WithdrawStatus {
|
||||
switch state {
|
||||
|
||||
case max.WithdrawStateSent, max.WithdrawStateSubmitting, max.WithdrawStatePending, "accepted", "approved":
|
||||
return types.WithdrawStatusSent
|
||||
|
||||
case max.WithdrawStateProcessing, "delisted_processing", "kgi_manually_processing", "kgi_manually_confirmed", "sygna_verifying":
|
||||
return types.WithdrawStatusProcessing
|
||||
|
||||
case max.WithdrawStateFailed, "kgi_possible_failed", "rejected", "suspect", "retryable":
|
||||
return types.WithdrawStatusFailed
|
||||
|
||||
case max.WithdrawStateCanceled:
|
||||
return types.WithdrawStatusCancelled
|
||||
|
||||
case "confirmed":
|
||||
// make it compatible with binance
|
||||
return types.WithdrawStatusCompleted
|
||||
|
||||
default:
|
||||
return types.WithdrawStatus(state)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -867,23 +867,7 @@ func (e *Exchange) QueryWithdrawHistory(
|
|||
}
|
||||
|
||||
// we can convert this later
|
||||
status := d.State
|
||||
switch d.State {
|
||||
|
||||
case "confirmed":
|
||||
status = "completed" // make it compatible with binance
|
||||
|
||||
case "submitting", "submitted", "accepted",
|
||||
"rejected", "suspect", "approved", "delisted_processing",
|
||||
"processing", "retryable", "sent", "canceled",
|
||||
"failed", "pending",
|
||||
"kgi_manually_processing", "kgi_manually_confirmed", "kgi_possible_failed",
|
||||
"sygna_verifying":
|
||||
|
||||
default:
|
||||
status = d.State
|
||||
|
||||
}
|
||||
status := convertWithdrawStatus(d.State)
|
||||
|
||||
txIDs[d.TxID] = struct{}{}
|
||||
withdraw := types.Withdraw{
|
||||
|
@ -891,14 +875,16 @@ func (e *Exchange) QueryWithdrawHistory(
|
|||
ApplyTime: types.Time(d.CreatedAt),
|
||||
Asset: toGlobalCurrency(d.Currency),
|
||||
Amount: d.Amount,
|
||||
Address: "",
|
||||
Address: d.Address,
|
||||
AddressTag: "",
|
||||
TransactionID: d.TxID,
|
||||
TransactionFee: d.Fee,
|
||||
TransactionFeeCurrency: d.FeeCurrency,
|
||||
Network: d.NetworkProtocol,
|
||||
// WithdrawOrderID: d.WithdrawOrderID,
|
||||
// Network: d.Network,
|
||||
Status: status,
|
||||
OriginalStatus: string(d.State),
|
||||
}
|
||||
allWithdraws = append(allWithdraws, withdraw)
|
||||
}
|
||||
|
|
|
@ -155,7 +155,23 @@ type WithdrawState string
|
|||
|
||||
const (
|
||||
WithdrawStateSubmitting WithdrawState = "submitting"
|
||||
WithdrawStateSubmitted WithdrawState = "submitted"
|
||||
WithdrawStateConfirmed WithdrawState = "confirmed"
|
||||
WithdrawStatePending WithdrawState = "pending"
|
||||
WithdrawStateProcessing WithdrawState = "processing"
|
||||
WithdrawStateCanceled WithdrawState = "canceled"
|
||||
WithdrawStateFailed WithdrawState = "failed"
|
||||
WithdrawStateSent WithdrawState = "sent"
|
||||
WithdrawStateRejected WithdrawState = "rejected"
|
||||
)
|
||||
|
||||
type WithdrawStatus string
|
||||
|
||||
const (
|
||||
WithdrawStatusPending WithdrawStatus = "pending"
|
||||
WithdrawStatusCancelled WithdrawStatus = "cancelled"
|
||||
WithdrawStatusFailed WithdrawStatus = "failed"
|
||||
WithdrawStatusOK WithdrawStatus = "ok"
|
||||
)
|
||||
|
||||
type Withdraw struct {
|
||||
|
@ -167,14 +183,19 @@ type Withdraw struct {
|
|||
FeeCurrency string `json:"fee_currency"`
|
||||
TxID string `json:"txid"`
|
||||
|
||||
NetworkProtocol string `json:"network_protocol"`
|
||||
Address string `json:"to_address"`
|
||||
|
||||
// State can be "submitting", "submitted",
|
||||
// "rejected", "accepted", "suspect", "approved", "delisted_processing",
|
||||
// "processing", "retryable", "sent", "canceled",
|
||||
// "failed", "pending", "confirmed",
|
||||
// "kgi_manually_processing", "kgi_manually_confirmed", "kgi_possible_failed",
|
||||
// "sygna_verifying"
|
||||
State string `json:"state"`
|
||||
Confirmations int `json:"confirmations"`
|
||||
State WithdrawState `json:"state"`
|
||||
|
||||
Status WithdrawStatus `json:"status,omitempty"`
|
||||
|
||||
CreatedAt types.MillisecondTimestamp `json:"created_at"`
|
||||
UpdatedAt types.MillisecondTimestamp `json:"updated_at"`
|
||||
Notes string `json:"notes"`
|
||||
|
|
Loading…
Reference in New Issue
Block a user