diff --git a/pkg/exchange/max/convert.go b/pkg/exchange/max/convert.go index b84484690..28fa41788 100644 --- a/pkg/exchange/max/convert.go +++ b/pkg/exchange/max/convert.go @@ -201,6 +201,11 @@ func toGlobalTradeV3(t v3.Trade) ([]types.Trade, error) { isMargin := t.WalletType == max.WalletTypeMargin side := toGlobalSideType(t.Side) + fee := fixedpoint.Zero + if t.Fee != nil { + fee = *t.Fee + } + trade := types.Trade{ ID: t.ID, OrderID: t.OrderID, @@ -211,7 +216,8 @@ func toGlobalTradeV3(t v3.Trade) ([]types.Trade, error) { Side: side, IsBuyer: t.IsBuyer(), IsMaker: t.IsMaker(), - Fee: t.Fee, + Fee: fee, + FeeProcessing: t.Fee == nil, FeeCurrency: toGlobalCurrency(t.FeeCurrency), FeeDiscounted: t.FeeDiscounted, QuoteQuantity: t.Funds, diff --git a/pkg/exchange/max/maxapi/v3/trade.go b/pkg/exchange/max/maxapi/v3/trade.go index d5569deb6..103d034e8 100644 --- a/pkg/exchange/max/maxapi/v3/trade.go +++ b/pkg/exchange/max/maxapi/v3/trade.go @@ -23,7 +23,7 @@ type Trade struct { CreatedAt types.MillisecondTimestamp `json:"created_at"` Side string `json:"side"` OrderID uint64 `json:"order_id"` - Fee fixedpoint.Value `json:"fee"` // float number as string + Fee *fixedpoint.Value `json:"fee"` // float number in string, could be optional FeeCurrency string `json:"fee_currency"` FeeDiscounted bool `json:"fee_discounted"` Liquidity Liquidity `json:"liquidity"` diff --git a/pkg/types/trade.go b/pkg/types/trade.go index 9d7f57ac0..8cfdfaef6 100644 --- a/pkg/types/trade.go +++ b/pkg/types/trade.go @@ -70,12 +70,13 @@ type Trade struct { QuoteQuantity fixedpoint.Value `json:"quoteQuantity" db:"quote_quantity"` Symbol string `json:"symbol" db:"symbol"` - Side SideType `json:"side" db:"side"` - IsBuyer bool `json:"isBuyer" db:"is_buyer"` - IsMaker bool `json:"isMaker" db:"is_maker"` - Time Time `json:"tradedAt" db:"traded_at"` - Fee fixedpoint.Value `json:"fee" db:"fee"` - FeeCurrency string `json:"feeCurrency" db:"fee_currency"` + Side SideType `json:"side" db:"side"` + IsBuyer bool `json:"isBuyer" db:"is_buyer"` + IsMaker bool `json:"isMaker" db:"is_maker"` + Time Time `json:"tradedAt" db:"traded_at"` + Fee fixedpoint.Value `json:"fee" db:"fee"` + FeeCurrency string `json:"feeCurrency" db:"fee_currency"` + FeeProcessing bool `json:"feeProcessing" db:"-"` // 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