Skip to content

FEATURE: [max] add fee processing field #1614

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

Merged
merged 4 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion pkg/exchange/max/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/exchange/max/maxapi/v3/trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
13 changes: 7 additions & 6 deletions pkg/types/trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading