Closed altafan closed 1 year ago
BaseAssetPrecision
was added to Market struct in order to store base asset's precision (number of decimals). This value can be obtained by querying TDEX API for an Asset object or using other means if available at runtime (e.g., database) QuoteAssetPrecision
was added to Market struct in order to store quote asset's precision (number of decimals). This value can be obtained by querying TDEX API for an Asset object or using other means if available at runtime (e.g., database)
This updates the marketmaking Formula interface in order to express numbers via
decimal.Decimal
s instead ofuint64
s.Before this change the the formula interface was designed to support satoshis, but this becomes problematic after supporting market assets precision. By changing the representation to
decimal.Decimal
, balances and amounts can be scaled by asset precision before and after applying a formula to calculate a preview amount (in domain layer).This adds test cases to make sure the applied change work as expected.
This also simplify the calc of the min tradable amount of SpotPrice by applying the following formula:
where
minQuoteAmount = 10^(-quoteAssetPrecision)
, ie.precision = 2 -> minQuoteAmount = 0,01
.Please @tiero review this.