max: add fee processing field

This commit is contained in:
c9s 2024-04-08 16:10:22 +08:00
parent 5e0ff7afed
commit 0318e08e0f
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 15 additions and 8 deletions

View File

@ -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,

View File

@ -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"`

View File

@ -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