types: add fee discounted field to the global trade struct

This commit is contained in:
c9s 2023-07-25 13:40:10 +08:00
parent 4de82ccdff
commit fcca3f6432
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
4 changed files with 9 additions and 2 deletions

View File

@ -297,6 +297,7 @@ func convertWebSocketTrade(t max.TradeUpdate) (*types.Trade, error) {
IsMaker: t.Maker, IsMaker: t.Maker,
Fee: t.Fee, Fee: t.Fee,
FeeCurrency: toGlobalCurrency(t.FeeCurrency), FeeCurrency: toGlobalCurrency(t.FeeCurrency),
FeeDiscounted: t.FeeDiscounted,
QuoteQuantity: t.Price.Mul(t.Volume), QuoteQuantity: t.Price.Mul(t.Volume),
Time: types.Time(t.Timestamp.Time()), Time: types.Time(t.Timestamp.Time()),
}, nil }, nil

View File

@ -39,7 +39,7 @@ func Test_parseTradeSnapshotEvent(t *testing.T) {
assert.Equal(t, 1, len(evt.Trades)) assert.Equal(t, 1, len(evt.Trades))
assert.Equal(t, "bid", evt.Trades[0].Side) assert.Equal(t, "bid", evt.Trades[0].Side)
assert.Equal(t, "ethtwd", evt.Trades[0].Market) assert.Equal(t, "ethtwd", evt.Trades[0].Market)
assert.Equal(t, int64(1521726960357), evt.Trades[0].Timestamp) assert.Equal(t, int64(1521726960357), evt.Trades[0].Timestamp.Time().UnixMilli())
assert.Equal(t, "3.2", evt.Trades[0].Fee.String()) assert.Equal(t, "3.2", evt.Trades[0].Fee.String())
assert.Equal(t, "twd", evt.Trades[0].FeeCurrency) assert.Equal(t, "twd", evt.Trades[0].FeeCurrency)
} }

View File

@ -38,7 +38,7 @@ func (g *GetWalletTradesRequest) Limit(limit uint64) *GetWalletTradesRequest {
return g return g
} }
func (g *GetWalletTradesRequest) WalletType(walletType max.WalletType) *GetWalletTradesRequest { func (g *GetWalletTradesRequest) WalletType(walletType WalletType) *GetWalletTradesRequest {
g.walletType = walletType g.walletType = walletType
return g return g
} }

View File

@ -67,6 +67,12 @@ type Trade struct {
Fee fixedpoint.Value `json:"fee" db:"fee"` Fee fixedpoint.Value `json:"fee" db:"fee"`
FeeCurrency string `json:"feeCurrency" db:"fee_currency"` FeeCurrency string `json:"feeCurrency" db:"fee_currency"`
// FeeDiscounted is an optional field which indicates whether the trade is using the platform fee token for discount.
// When FeeDiscounted = true, means the fee is deducted outside the trade
// By default, it's set to false.
// This is only used by the MAX exchange
FeeDiscounted bool `json:"feeDiscounted" db:"-"`
IsMargin bool `json:"isMargin" db:"is_margin"` IsMargin bool `json:"isMargin" db:"is_margin"`
IsFutures bool `json:"isFutures" db:"is_futures"` IsFutures bool `json:"isFutures" db:"is_futures"`
IsIsolated bool `json:"isIsolated" db:"is_isolated"` IsIsolated bool `json:"isIsolated" db:"is_isolated"`