pallet-asset-conversion: Decoupling Native Currency Dependancy (#2031)
closes https://github.com/paritytech/polkadot-sdk/issues/1842 Decoupling Pallet from the Concept of Native Currency Currently, the pallet is intrinsically linked with the concept of native currency, requiring users to provide implementations of the `fungible::*` and `fungibles::*` traits to interact with native and non native assets. This incapsulates some non-related to the pallet complexity and makes it less adaptable in contexts where the native currency concept is absent. With this PR, the dependence on `fungible::*` for liquidity-supplying assets has been removed. Instead, the native and non-native currencies' handling is now overseen by a single type that implements the `fungibles::*` traits. To simplify this integration, types have been introduced to facilitate the creation of a union between `fungible::*` and `fungibles::*` implementations, producing a unified `fungibles::*` type. One of the reasons driving these changes is the ambition to create a more user-friendly API for the `SwapCredit` implementation. Given that it interacts with two distinct credit types from `fungible` and `fungibles`, a unified type was introduced. Clients now manage potential conversion failures for those credit types. In certain contexts, it's vital to guarantee that operations are fail-safe, like in this impl - [PR](https://github.com/paritytech/polkadot-sdk/pull/1845), place in [code](https://github.com/paritytech/polkadot-sdk/blob/20b85a5f /cumulus/primitives/utility/src/lib.rs#L429). Additional Updates: - abstracted the pool ID and its account derivation logic via trait bounds, along with common implementation offerings; - removed `inc_providers` on a pool creation for the pool account; - benchmarks: -- swap complexity is N, not const; -- removed `From<u128> + Into<u128>` bound from `T::Balance`; -- removed swap/liquidity/.. amount constants, resolve them dynamically based on pallet configuration; -- migrated to v2 API; - `OnUnbalanced` handler for the pool creation fee, replacing direct transfers to a specified account ID; - renamed `MultiAssetId` to `AssetKind` aligning with naming across frame crates; related PRs: - (depends) https://github.com/paritytech/polkadot-sdk/pull/1677 - (caused) https://github.com/paritytech/polkadot-sdk/pull/2033 - (caused) https://github.com/paritytech/polkadot-sdk/pull/1876 --------- Co-authored-by:joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by:
Liam Aharon <liam.aharon@hotmail.com>
parent
d32f66fb
Showing
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/swap.rs 1 addition, 1 deletion.../emulated/tests/assets/asset-hub-rococo/src/tests/swap.rs
- cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/swap.rs 1 addition, 1 deletion...emulated/tests/assets/asset-hub-westend/src/tests/swap.rs
- cumulus/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs 0 additions, 1480 deletions...us/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs
- cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs 0 additions, 640 deletions...chains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs
- cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs 42 additions, 34 deletions...us/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
- cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_asset_conversion.rs 49 additions, 47 deletions...s/asset-hub-rococo/src/weights/pallet_asset_conversion.rs
- cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs 2 additions, 31 deletions...chains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs
- cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs 43 additions, 148 deletions...s/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
- cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_asset_conversion.rs 50 additions, 50 deletions.../asset-hub-westend/src/weights/pallet_asset_conversion.rs
- cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs 2 additions, 32 deletions...hains/runtimes/assets/asset-hub-westend/src/xcm_config.rs
- cumulus/parachains/runtimes/assets/common/src/benchmarks.rs 44 additions, 0 deletionscumulus/parachains/runtimes/assets/common/src/benchmarks.rs
- cumulus/parachains/runtimes/assets/common/src/lib.rs 2 additions, 0 deletionscumulus/parachains/runtimes/assets/common/src/lib.rs
- cumulus/parachains/runtimes/assets/common/src/local_and_foreign_assets.rs 28 additions, 446 deletions...ns/runtimes/assets/common/src/local_and_foreign_assets.rs
- prdoc/pr_2031.prdoc 29 additions, 0 deletionsprdoc/pr_2031.prdoc
- substrate/bin/node/runtime/src/lib.rs 32 additions, 22 deletionssubstrate/bin/node/runtime/src/lib.rs
- substrate/frame/asset-conversion/src/benchmarking.rs 263 additions, 276 deletionssubstrate/frame/asset-conversion/src/benchmarking.rs
- substrate/frame/asset-conversion/src/lib.rs 203 additions, 331 deletionssubstrate/frame/asset-conversion/src/lib.rs
- substrate/frame/asset-conversion/src/mock.rs 23 additions, 17 deletionssubstrate/frame/asset-conversion/src/mock.rs
- substrate/frame/asset-conversion/src/swap.rs 19 additions, 17 deletionssubstrate/frame/asset-conversion/src/swap.rs
- substrate/frame/asset-conversion/src/tests.rs 646 additions, 603 deletionssubstrate/frame/asset-conversion/src/tests.rs
Please register or sign in to comment