Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMPROVE: [maxapi] update deposit info fields #1814

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/exchange/max/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,11 +948,13 @@ func (e *Exchange) QueryDepositHistory(
Time: types.Time(d.CreatedAt),
Amount: d.Amount,
Asset: toGlobalCurrency(d.Currency),
Address: d.Address, // not supported
AddressTag: "", // not supported
Address: d.Address,
AddressTag: "", // not supported
TransactionID: d.TxID,
Status: toGlobalDepositStatus(d.State),
Confirmation: "",
Confirmation: strconv.FormatInt(d.Confirmations, 10),
Network: d.NetworkProtocol,
RawStatus: fmt.Sprintf("%s (%s: %s)", d.Status, d.State, d.StateReason),
})
}

Expand Down Expand Up @@ -1134,7 +1136,9 @@ func (e *Exchange) QueryKLines(
return kLines, nil
}

func (e *Exchange) QueryDepth(ctx context.Context, symbol string, limit int) (snapshot types.SliceOrderBook, finalUpdateID int64, err error) {
func (e *Exchange) QueryDepth(
ctx context.Context, symbol string, limit int,
) (snapshot types.SliceOrderBook, finalUpdateID int64, err error) {
req := e.v3client.NewGetDepthRequest()
req.Market(symbol)
req.Limit(limit)
Expand Down
53 changes: 0 additions & 53 deletions pkg/exchange/max/maxapi/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,59 +104,6 @@ func (c *RestClient) NewGetAccountsRequest() *GetAccountsRequest {
return &GetAccountsRequest{client: c}
}

type DepositState string

const (
DepositStateSubmitting DepositState = "submitting"
DepositStateCancelled DepositState = "cancelled"
DepositStateSubmitted DepositState = "submitted"
DepositStatePending DepositState = "pending"
DepositStateSuspect DepositState = "suspect"
DepositStateRejected DepositState = "rejected"
DepositStateSuspended DepositState = "suspended"
DepositStateAccepted DepositState = "accepted"
DepositStateChecking DepositState = "checking"

// v3 states
DepositStateProcessing DepositState = "processing"
DepositStateFailed DepositState = "failed"
DepositStateDone DepositState = "done"
)

type Deposit struct {
Currency string `json:"currency"` // "eth"
CurrencyVersion string `json:"currency_version"` // "eth"
NetworkProtocol string `json:"network_protocol"` // "ethereum-erc20"
Amount fixedpoint.Value `json:"amount"`
Fee fixedpoint.Value `json:"fee"`
TxID string `json:"txid"`
State DepositState `json:"state"`
Status string `json:"status"`
Confirmations int64 `json:"confirmations"`
Address string `json:"to_address"` // 0x5c7d23d516f120d322fc7b116386b7e491739138
CreatedAt types.MillisecondTimestamp `json:"created_at"`
UpdatedAt types.MillisecondTimestamp `json:"updated_at"`
}

//go:generate GetRequest -url "v3/deposits" -type GetDepositHistoryRequest -responseType []Deposit
type GetDepositHistoryRequest struct {
client requestgen.AuthenticatedAPIClient

currency *string `param:"currency"`
timestamp *time.Time `param:"timestamp,milliseconds"` // seconds
state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect

order *string `param:"order"`

limit *int `param:"limit"`
}

func (c *RestClient) NewGetDepositHistoryRequest() *GetDepositHistoryRequest {
return &GetDepositHistoryRequest{
client: c,
}
}

// submitted -> accepted -> processing -> sent -> confirmed
type WithdrawState string

Expand Down
67 changes: 67 additions & 0 deletions pkg/exchange/max/maxapi/get_deposit_history_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package max

//go:generate -command GetRequest requestgen -method GET
//go:generate -command PostRequest requestgen -method POST
//go:generate -command DeleteRequest requestgen -method DELETE

import (
"time"

"github.com/c9s/requestgen"

"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
)

type DepositState string

const (
DepositStateSubmitting DepositState = "submitting"
DepositStateCancelled DepositState = "cancelled"
DepositStateSubmitted DepositState = "submitted"
DepositStatePending DepositState = "pending"
DepositStateSuspect DepositState = "suspect"
DepositStateRejected DepositState = "rejected"
DepositStateSuspended DepositState = "suspended"
DepositStateAccepted DepositState = "accepted"
DepositStateChecking DepositState = "checking"

// v3 states
DepositStateProcessing DepositState = "processing"
DepositStateFailed DepositState = "failed"
DepositStateDone DepositState = "done"
)

type Deposit struct {
Currency string `json:"currency"` // "eth"
NetworkProtocol string `json:"network_protocol"` // "ethereum-erc20"
Amount fixedpoint.Value `json:"amount"`
Fee fixedpoint.Value `json:"fee"`
TxID string `json:"txid"`
State DepositState `json:"state"`
StateReason string `json:"state_reason"`
Status string `json:"status"`
Confirmations int64 `json:"confirmations"`
Address string `json:"to_address"` // 0x5c7d23d516f120d322fc7b116386b7e491739138
CreatedAt types.MillisecondTimestamp `json:"created_at"`
UpdatedAt types.MillisecondTimestamp `json:"updated_at"`
}

//go:generate GetRequest -url "v3/deposits" -type GetDepositHistoryRequest -responseType []Deposit
type GetDepositHistoryRequest struct {
client requestgen.AuthenticatedAPIClient

currency *string `param:"currency"`
timestamp *time.Time `param:"timestamp,milliseconds"` // seconds
state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect

order *string `param:"order"`

limit *int `param:"limit"`
}

func (c *RestClient) NewGetDepositHistoryRequest() *GetDepositHistoryRequest {
return &GetDepositHistoryRequest{
client: c,
}
}
Loading