diff --git a/pkg/types/market.go b/pkg/types/market.go index 99b2f9efb..6b7199798 100644 --- a/pkg/types/market.go +++ b/pkg/types/market.go @@ -70,6 +70,12 @@ func (m Market) TruncateQuantity(quantity fixedpoint.Value) fixedpoint.Value { return fixedpoint.MustNewFromString(qs) } +// RoundDownQuantityByPrecision uses the volume precision to round down the quantity +// This is different from the TruncateQuantity, which uses StepSize (it uses fewer fractions to truncate) +func (m Market) RoundDownQuantityByPrecision(quantity fixedpoint.Value) fixedpoint.Value { + return quantity.Round(m.VolumePrecision, fixedpoint.Down) +} + func (m Market) TruncatePrice(price fixedpoint.Value) fixedpoint.Value { return fixedpoint.MustNewFromString(m.FormatPrice(price)) }