zeitgeist
zeitgeist copied to clipboard
Improve `create_pool` by encapsulating optional parameters
There are a lot of optional parameters required for creating Balancer-style pools. From a design point of view, this is a code smell. Either weights
and swap_fee
must both be Some(_)
, or both be None
. Anything in between is questionable.
I suggest the following solution: Remove the ScoringRule
enum from create_pool
and instead use the following parameter:
enum<T> CreatePoolParameters {
Cpmm(BalanceOf<T>, BalanceOf<T>, Vec<u128>, bool),
Rikiddo,
}
This reduces the complexity of create_pool
immensely:
fn create_pool(
who: T::AccountId,
assets: Vec<Asset<T::MarketId>>,
base_asset: Asset<T::MarketId>,
market_id: Self::MarketId,
params: CreatePoolParameters,
) -> Result<PoolId, DispatchError> {
The create_pool
function can then match
the creation parameters accordingly.