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))),
|
UpdateTime: types.Time(time.Unix(0, u.UpdateTime*int64(time.Millisecond))),
|
||||||
}, nil
|
}, 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
|
// we can convert this later
|
||||||
status := d.State
|
status := convertWithdrawStatus(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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
txIDs[d.TxID] = struct{}{}
|
txIDs[d.TxID] = struct{}{}
|
||||||
withdraw := types.Withdraw{
|
withdraw := types.Withdraw{
|
||||||
|
@ -891,14 +875,16 @@ func (e *Exchange) QueryWithdrawHistory(
|
||||||
ApplyTime: types.Time(d.CreatedAt),
|
ApplyTime: types.Time(d.CreatedAt),
|
||||||
Asset: toGlobalCurrency(d.Currency),
|
Asset: toGlobalCurrency(d.Currency),
|
||||||
Amount: d.Amount,
|
Amount: d.Amount,
|
||||||
Address: "",
|
Address: d.Address,
|
||||||
AddressTag: "",
|
AddressTag: "",
|
||||||
TransactionID: d.TxID,
|
TransactionID: d.TxID,
|
||||||
TransactionFee: d.Fee,
|
TransactionFee: d.Fee,
|
||||||
TransactionFeeCurrency: d.FeeCurrency,
|
TransactionFeeCurrency: d.FeeCurrency,
|
||||||
|
Network: d.NetworkProtocol,
|
||||||
// WithdrawOrderID: d.WithdrawOrderID,
|
// WithdrawOrderID: d.WithdrawOrderID,
|
||||||
// Network: d.Network,
|
// Network: d.Network,
|
||||||
Status: status,
|
Status: status,
|
||||||
|
OriginalStatus: string(d.State),
|
||||||
}
|
}
|
||||||
allWithdraws = append(allWithdraws, withdraw)
|
allWithdraws = append(allWithdraws, withdraw)
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,23 @@ type WithdrawState string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
WithdrawStateSubmitting WithdrawState = "submitting"
|
WithdrawStateSubmitting WithdrawState = "submitting"
|
||||||
|
WithdrawStateSubmitted WithdrawState = "submitted"
|
||||||
WithdrawStateConfirmed WithdrawState = "confirmed"
|
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 {
|
type Withdraw struct {
|
||||||
|
@ -167,17 +183,22 @@ type Withdraw struct {
|
||||||
FeeCurrency string `json:"fee_currency"`
|
FeeCurrency string `json:"fee_currency"`
|
||||||
TxID string `json:"txid"`
|
TxID string `json:"txid"`
|
||||||
|
|
||||||
|
NetworkProtocol string `json:"network_protocol"`
|
||||||
|
Address string `json:"to_address"`
|
||||||
|
|
||||||
// State can be "submitting", "submitted",
|
// State can be "submitting", "submitted",
|
||||||
// "rejected", "accepted", "suspect", "approved", "delisted_processing",
|
// "rejected", "accepted", "suspect", "approved", "delisted_processing",
|
||||||
// "processing", "retryable", "sent", "canceled",
|
// "processing", "retryable", "sent", "canceled",
|
||||||
// "failed", "pending", "confirmed",
|
// "failed", "pending", "confirmed",
|
||||||
// "kgi_manually_processing", "kgi_manually_confirmed", "kgi_possible_failed",
|
// "kgi_manually_processing", "kgi_manually_confirmed", "kgi_possible_failed",
|
||||||
// "sygna_verifying"
|
// "sygna_verifying"
|
||||||
State string `json:"state"`
|
State WithdrawState `json:"state"`
|
||||||
Confirmations int `json:"confirmations"`
|
|
||||||
CreatedAt types.MillisecondTimestamp `json:"created_at"`
|
Status WithdrawStatus `json:"status,omitempty"`
|
||||||
UpdatedAt types.MillisecondTimestamp `json:"updated_at"`
|
|
||||||
Notes string `json:"notes"`
|
CreatedAt types.MillisecondTimestamp `json:"created_at"`
|
||||||
|
UpdatedAt types.MillisecondTimestamp `json:"updated_at"`
|
||||||
|
Notes string `json:"notes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate GetRequest -url "v2/withdrawals" -type GetWithdrawHistoryRequest -responseType []Withdraw
|
//go:generate GetRequest -url "v2/withdrawals" -type GetWithdrawHistoryRequest -responseType []Withdraw
|
||||||
|
|
Loading…
Reference in New Issue
Block a user