Skip to content

Commit 7b33e01

Browse files
authored
Merge pull request #2396 from c9s/dboy/max/update-v3
FIX: [max] update withdrawal handling to use v3 API
2 parents 0beccc0 + d456037 commit 7b33e01

File tree

7 files changed

+915
-16
lines changed

7 files changed

+915
-16
lines changed

pkg/exchange/max/convert.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,24 +341,24 @@ func convertWebSocketOrderUpdate(u max.OrderUpdate) (*types.Order, error) {
341341
}, nil
342342
}
343343

344-
func convertWithdrawStatusV3(status max.WithdrawStatus) types.WithdrawStatus {
345-
switch status {
344+
func convertWithdrawStatusV3(state v3.WithdrawState) types.WithdrawStatus {
345+
switch state {
346346

347-
case max.WithdrawStatusPending:
347+
case v3.WithdrawStateProcessing:
348348
return types.WithdrawStatusSent
349349

350-
case max.WithdrawStatusOK:
350+
case v3.WithdrawStateDone:
351351
return types.WithdrawStatusCompleted
352352

353-
case max.WithdrawStatusFailed:
353+
case v3.WithdrawStateFailed:
354354
return types.WithdrawStatusFailed
355355

356-
case max.WithdrawStatusCancelled:
356+
case v3.WithdrawStateCanceled:
357357
return types.WithdrawStatusCancelled
358358

359359
}
360360

361-
return types.WithdrawStatus(status)
361+
return types.WithdrawStatus(state)
362362
}
363363

364364
func convertWithdrawStatusV2(state max.WithdrawState) types.WithdrawStatus {

pkg/exchange/max/exchange.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,15 +530,15 @@ func (e *Exchange) Withdraw(
530530
) error {
531531
asset = toLocalCurrency(asset)
532532

533-
addresses, err := e.client.WithdrawalService.NewGetWithdrawalAddressesRequest().
533+
addresses, err := e.v3client.NewGetWithdrawalAddressesRequest().
534534
Currency(asset).
535535
Do(ctx)
536536

537537
if err != nil {
538538
return err
539539
}
540540

541-
var whitelistAddress maxapi.WithdrawalAddress
541+
var whitelistAddress v3.WithdrawalAddress
542542
for _, a := range addresses {
543543
if a.Address == address {
544544
whitelistAddress = a
@@ -554,7 +554,7 @@ func (e *Exchange) Withdraw(
554554
return errors.New("address UUID can not be empty")
555555
}
556556

557-
response, err := e.client.WithdrawalService.NewWithdrawalRequest().
557+
response, err := e.v3client.NewWithdrawalRequest().
558558
Currency(asset).
559559
Amount(amount.Float64()).
560560
AddressUUID(whitelistAddress.UUID).
@@ -892,7 +892,7 @@ func (e *Exchange) QueryWithdrawHistory(
892892
}
893893

894894
log.Infof("querying withdraw %s: %s <=> %s", asset, startTime, endTime)
895-
req := e.client.NewGetWithdrawalHistoryRequest()
895+
req := e.v3client.NewGetWithdrawalHistoryRequest()
896896
if len(asset) > 0 {
897897
req.Currency(toLocalCurrency(asset))
898898
}
@@ -917,7 +917,7 @@ func (e *Exchange) QueryWithdrawHistory(
917917
continue
918918
}
919919

920-
status := convertWithdrawStatusV2(d.State)
920+
status := convertWithdrawStatusV3(d.State)
921921

922922
txIDs[d.TxID] = struct{}{}
923923
withdraw := types.Withdraw{

pkg/exchange/max/maxapi/v3/get_withdrawal_addresses_request_requestgen.go

Lines changed: 250 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)