Skip to content

Commit

Permalink
Fix calc of min tradable amount
Browse files Browse the repository at this point in the history
  • Loading branch information
altafan committed Jan 17, 2023
1 parent 205162e commit 836f496
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/core/application/trade_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,16 @@ func (t *tradeService) GetMarketPrice(
return nil, 0, ErrServiceUnavailable
}
spotPrice := &price.QuotePrice
spotPricePrecision := calcPricePrecision(*spotPrice)
delta := int(spotPricePrecision) - int(mkt.QuoteAssetPrecision)
minAmount := uint64(mkt.FixedFee.BaseFee) + 1
if delta > 0 {
minAmount = uint64(math.Pow10(delta))
if minAmount == 1 {
if mkt.BaseAssetPrecision > mkt.QuoteAssetPrecision {
minAmountDec := price.BasePrice.Div(
decimal.NewFromFloat(math.Pow10(int(mkt.QuoteAssetPrecision))),
).Mul(decimal.NewFromFloat(math.Pow10(int(mkt.BaseAssetPrecision))))
if minAmountDec.GreaterThanOrEqual(decimal.NewFromInt(1)) {
minAmount = minAmountDec.BigInt().Uint64()
}
}
}
return spotPrice, minAmount, nil
}
Expand Down

0 comments on commit 836f496

Please sign in to comment.