Closed mihneacalugaru closed 1 year ago
HI @mihneacalugaru, First of all these are definitely important questions, so thank you for asking!
The best way to understand base and quote currency multipliers is to understand that their choice affects the range of possible prices your market will support. Prices are stored using a fixed decimal point number that can range from 0 to 4294967296
(2^32), in increments of 1/(2^32). What we want is to map this range of prices to something appropriate for our market.
In your case for instance, if you expect your market price to start at around 10 quote/base. In the underlying representation, since your quote currency has 6 decimals, this would actually be 10^7 raw_quote/base. You would then want the middle of your possible price range (which is the value 1.0) to map to something around 10^7. We can call this price the baseline price.
That is saying that having mul_quote = raw_quote / quote_mutliplier
and mul_base = raw_base / base_multiplier
, we want to solve 1.0 mul_quote / mul_base = 10^7 raw_quote / raw_base
, which simplifies to:
base_multiplier / quote_multiplier = 10 ^ 7
. The simplest solution to this equation is then base_multiplier = 10^7
and quote_multiplier = 1
.
For most use-cases, one of the two multipliers is going to be one.
Tick size is somewhat related but not really : the only constraint is that tick size can't be smaller than (1/2**32) the baseline price, which should be something to consider when dealing with assets with smaller prices. For some use-cases, it might be worth it to lower the baseline price to gain some more precision.
But most of the time my advice here is not to worry too much about it and just check that your max and min prices are sensible for your use-case.
Hello @ellttBen, thank you very much for the answer, really appreciate it!
I have a question though.
Assuming the same case I mentioned above (base mint: 0 decimals & quote mint: 6 decimals), if I create the market with the multipliers you specified (base_multiplier = 10^7
and quote_multiplier = 1
) and the minBaseOrderSize = 1
(because given the fact that I have a 0 decimals base mint I want the users to be able to trade any natural/integer number of these tokens) this should fail when it invokes asset_agnostic_orderbook::instruction::create_market::Params
with min_base_order_size: *min_base_order_size / *base_currency_multiplier
as that division will result in 0, which will trigger the "min_base_order_size and tick_size must be > 0" error
.
Hi @mihneacalugaru,
And you're totally right I mixed up my logic, the equation to solve is actually :
1.0 mul_quote * quote_mutliplier / (mul_base * base_multiplier) = 10^7 raw_quote / raw_base
, which simplifies to quote_multiplier = 10^7
and base_multiplier = 1
. I apologize for the confusion! I'd also like to provide an alternative way of looking at things here, which is more centered on the peculiarities of running an NFT market.
Here you have underlined an additional constraint. In your case the base_currency_multiplier
has to be 1, which served here as a good sanity check.
Let's try and pick the range more carefully by considering the minimum and maximum possible prices. With both multipliers set at 1, the minimum price / tick size becomes 1/(2^32) ~ 10^-9
in raw amount which translates to about 10^-15
with the 6 decimals. In the same way, the maximum price is 2^32 ~ 10^9
in raw amount which translates to about 1k with the 6 decimals.
Here we can see that the prices can get super low but the maximum price isn't that high. We can then play with the quote_multiplier to fix this. One thing to notice here is that since we're always going to be buying these assets one at a time, there is no point in having a minimum possible price much lower than a cent. For more accurate calculations we might want the added precision of a minimum price that is 3 orders of magnitude lower than the 6 decimal precision, or a precision of 10^-9. For that purpose a quote multiplier of 10^6 would work well :
So the recommendation here would be quote_multiplier = 10^6 and base_multiplier = 1.
For perfect price centering around 10 quote/base, the recommendation becomes a quote_multiplier of 10^7, allowing for a higher price ceiling of 10B.
The thing to understand here is that this reasoning is the same as the one we previously had, and the result is similar in terms of centering the possible prices. In general, increasing the quote_multiplier
is a way to decrease price precision in order to allow for higher possible prices. Conversely, increasing the base_multiplier
is a way to increase price precision and to allow for lower possible prices.
Sorry again for the confusion, I guess this shows how finicky this subject can be.
Hello,
I am trying to make sense of the base and quote currency multipliers. I don't think I got why do we use them or how do we use them.
Aren't the decimals numbers of the mints enough?
Let's say I have a market with the following pair:
Sorry if these are silly question, I'm just trying to figure how everything ties together.