zeitgeist
zeitgeist copied to clipboard
Automatically determine initial swap pool weights / set initial prices
Issue Currently the creator of a swaps pool has to specify the initial weights (see here and here), which determine the price ratio between the assets. In addition to the circumstance, that deploy_swap_pool_for_market does implicitly add the market currency to the assets, but not extend the weights, i.e. expects the user to know that this implicit expansion happens and to manually add the weight, leads to an unintuitive and error-prone situation.
Potential solution TBD. How do we determine the initial weights? Should the user be able to modify them?
The user should be able to specify weights. This is important if they believe one outcome to be much more likely or unlikely than another.
My solution would be to add a base_asset_weight
parameter.
I like your approach @maltekliemann. It's cleaner to separate the asset_weights
and the base_asset_weight
.
Another approach could be to check if the user forgot to specify a weight for the base asset.
let mut assets = Self::outcome_assets(market_id, &market);
ensure!(
weights.len() == assets.len().saturating_add(One::one()),
Error::<T>::WeightsLenMustEqualAssetsLenPlusOneForBaseAsset
);
let base_asset = Asset::Ztg;
assets.push(base_asset);
So the last weight would always be for the base_asset
.
But don't get me wrong, I would go with your solution @maltekliemann, because it's more precise.
Hey @Chralt98. I didn't realize this issue still existed. This is basically solved in #672 by allowing the user to set the weights of the outcome tokens (since this allows them to control the initial price of the tokens), but fixing the weight of the base asset to be the sum of the weights of the outcome tokens. Sorry I didn't mark this issue. Completely forgot about it.
The exact reason for this definition of the weight of the base asset is that the spot prices of all outcome assets add up to 1 (provided that the balances of all assets in the pool are equal, which is the case when the pool is created). Of course, in a prediction market the spot prices should always sum up to 1, and due to the presence of the buy/sell complete set extrinsics, there are arbitrage opportunities if that is not the case. So by forcing the user to set this particular weight for the base asset, we essentially protect them from arbitrageurs. Any other choice for the weight of the base asset is unreasonable.
Let's rewrite this issue a little bit:
- Right now, the weights can be set in the backend, but not the frontend.
- We need a feature which allows users to set initial predictions for their markets.
So the new question is whether or not we should do this with weights, or by letting the user set the initial balances. (Of course, in the frontend, we let the user set the initial prices, then calculate what the weights/balances should be.)
The story thus far is: Setting initial balances creates a temporary bias, while setting the weights to set the price creates a permanent bias. On the other hand, weights are easier to handle and calculate, and don't result in the user holding the tokens whose balances they reduced to increase their price when creating the pool.
We've decided to go with weights for setting the initial price. The UI Team is already on it: zeitgeist/ui#331. There's nothing left for us to do.