Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "New Asset System (#1295)" #1338

Merged
merged 5 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# Ignore everything but mod.rs in /runtime/common/src/weights/
/runtime/common/src/weights/*
/runtime/common/src/weights/mod.rs @sea212
/zrml/asset-router/ @sea212
/zrml/authorized/ @Chralt98
/zrml/court/ @Chralt98
/zrml/global-disputes/ @Chralt98
Expand Down
53 changes: 0 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ default-members = [
"runtime/battery-station",
"runtime/zeitgeist",
"zrml/authorized",
"zrml/asset-router",
"zrml/court",
"zrml/hybrid-router",
"zrml/global-disputes",
Expand All @@ -33,7 +32,6 @@ members = [
"runtime/battery-station",
"runtime/zeitgeist",
"zrml/authorized",
"zrml/asset-router",
"zrml/court",
"zrml/hybrid-router",
"zrml/global-disputes",
Expand Down Expand Up @@ -167,7 +165,6 @@ frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", b
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
pallet-assets = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
pallet-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
pallet-bounties = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
Expand Down Expand Up @@ -237,7 +234,6 @@ zrml-swaps-rpc = { path = "zrml/swaps/rpc" }
common-runtime = { path = "runtime/common", default-features = false }
zeitgeist-macros = { path = "macros", default-features = false }
zeitgeist-primitives = { path = "primitives", default-features = false }
zrml-asset-router = { path = "zrml/asset-router", default-features = false }
zrml-authorized = { path = "zrml/authorized", default-features = false }
zrml-court = { path = "zrml/court", default-features = false }
zrml-global-disputes = { path = "zrml/global-disputes", default-features = false }
Expand Down Expand Up @@ -269,7 +265,6 @@ arbitrary = { version = "1.3.0", default-features = false }
arrayvec = { version = "0.7.4", default-features = false }
cfg-if = { version = "1.0.0" }
fixed = { version = "=1.15.0", default-features = false, features = ["num-traits"] }
impl-trait-for-tuples = { version = "0.2.2" }
# Using math code directly from the HydraDX node repository as https://github.com/galacticcouncil/hydradx-math is outdated and has been archived in May 2023.
hydra-dx-math = { git = "https://github.com/galacticcouncil/HydraDX-node", package = "hydra-dx-math", tag = "v21.1.1", default-features = false }
# Hashbrown works in no_std by default and default features are used in Rikiddo
Expand Down Expand Up @@ -339,9 +334,6 @@ opt-level = 3
panic = "unwind"

[patch."https://github.com/paritytech/substrate"]
# pallet-asset adjustments (managed asset destruction)
pallet-assets = { git = "https://github.com/zeitgeistpm/substrate.git", branch = "polkadot-v0.9.38-zeitgeist-adjustments" }

# fix that allow to build with recent rustc
substrate-wasm-builder = { git = "https://github.com/zeitgeistpm/substrate.git", branch = "polkadot-v0.9.38-zeitgeist-adjustments" }

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ decentralized court.

## Modules

- [asset-router](./zrml/asset-router) - Routes all asset classes to the
respective pallets and provides a garbage collection for destructible assets.
- [authorized](./zrml/authorized) - Offers authorized resolution of disputes.
- [court](./zrml/court) - An implementation of a court mechanism used to resolve
disputes in a decentralized fashion.
Expand Down
24 changes: 9 additions & 15 deletions docs/changelog_for_devs.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,22 @@ if ztg_supply / campaign_asset_supply >= 100 {
[#1197]: https://github.com/zeitgeistpm/zeitgeist/pull/1197
[#1178]: https://github.com/zeitgeistpm/zeitgeist/pull/1178

### Changed
### Changes

- ⚠️ Move the `zeitgeist_primitives::Pool` struct to `zrml_swaps::types::Pool`
and change the following fields ([#1197]):
- Remove `market_id`
- Make `swap_fee` non-optional
- Remove `total_subsidy`
- Make `total_weight` non-optional
- Make `weights` non-optional
- ⚠️ Change the type of `liquidity_shares_manager` in
`zrml_neo_swaps::types::Pool` from `zrml_neo_swaps::types::SoloLp` to
`zrml_neo_swaps::types::LiquidityTree`. Details on the liquidity tree can be
found in the `README.md` of zrml-neo-swaps and the documentation of the
`LiquidityTree` object ([#1179]).
- ⚠️ Move the `zeitgeist_primitives::Pool` struct to `zrml_swaps::types::Pool` and change the following fields ([#1197]):
- Remove `market_id`
- Make `swap_fee` non-optional
- Remove `total_subsidy`
- Make `total_weight` non-optional
- Make `weights` non-optional
- ⚠️ Change the type of `liquidity_shares_manager` in `zrml_neo_swaps::types::Pool` from `zrml_neo_swaps::types::SoloLp` to `zrml_neo_swaps::types::LiquidityTree`. Details on the liquidity tree can be found in the `README.md` of zrml-neo-swaps and the documentation of the `LiquidityTree` object ([#1179]).

### Migrations

- Closed all CPMM pools. Withdrawals are still allowed. Creating new pools will
be impossible until further updates are deployed. ([#1197])
- Remove all Rikiddo storage elements. ([#1197])
- Migrate neo-swaps `Pools` storage. The market creator's liquidity position is
translated into a position in the liquidity tree of the same value ([#1178]).
- Migrate neo-swaps `Pools` storage. The market creator's liquidity position is translated into a position in the liquidity tree of the same value ([#1178]).

### Removed

Expand Down
8 changes: 4 additions & 4 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ macro_rules! create_b_tree_map {
#[macro_export]
macro_rules! unreachable_non_terminating {
($condition: expr, $message: literal, $($message_args: tt)*) => {
let message = alloc::format!($message, $($message_args)*);
let message = format!($message, $($message_args)*);

#[cfg(test)]
assert!($condition, "{}", message);
Expand All @@ -60,7 +60,7 @@ macro_rules! unreachable_non_terminating {
}
};
($condition: expr, $log_target: ident, $message: literal, $($message_args: tt)*) => {
let message = alloc::format!($message, $($message_args)*);
let message = format!($message, $($message_args)*);

#[cfg(test)]
assert!($condition, "{}", message);
Expand All @@ -70,7 +70,7 @@ macro_rules! unreachable_non_terminating {
}
};
($condition: expr, $extra_code: expr, $message: literal, $($message_args: tt)*) => {
let message = alloc::format!($message, $($message_args)*);
let message = format!($message, $($message_args)*);

#[cfg(test)]
assert!($condition, "{}", message);
Expand All @@ -81,7 +81,7 @@ macro_rules! unreachable_non_terminating {
}
};
($condition: expr, $log_target: ident, $extra_code: expr, $message: literal, $($message_args: tt)*) => {
let message = alloc::format!($message, $($message_args)*);
let message = format!($message, $($message_args)*);

#[cfg(test)]
assert!($condition, "{}", message);
Expand Down
1 change: 0 additions & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ arbitrary = { workspace = true, optional = true }
fixed = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
impl-trait-for-tuples = { workspace = true }
num-traits = { workspace = true }
orml-currencies = { workspace = true }
orml-tokens = { workspace = true }
Expand Down
58 changes: 42 additions & 16 deletions primitives/src/assets.rs → primitives/src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,52 @@
use crate::traits::ZeitgeistAssetEnumerator;
use crate::{
traits::PoolSharesId,
types::{CampaignAssetId, CategoryIndex, CustomAssetId, PoolId},
types::{CategoryIndex, PoolId, SerdeWrapper},
};
use parity_scale_codec::{Compact, CompactAs, Decode, Encode, HasCompact, MaxEncodedLen};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;

pub use all_assets::Asset;
pub use campaign_assets::CampaignAssetClass;
pub use currencies::CurrencyClass;
pub use custom_assets::CustomAssetClass;
pub use market_assets::MarketAssetClass;
pub use subsets::{BaseAssetClass, ParimutuelAssetClass, XcmAssetClass};
/// The `Asset` enum represents all types of assets available in the Zeitgeist
/// system.
#[cfg_attr(feature = "std", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
#[derive(
Clone,
Copy,
Debug,
Decode,
Default,
Eq,
Encode,
MaxEncodedLen,
Ord,
PartialEq,
PartialOrd,
TypeInfo,
)]
pub enum Asset<MarketId> {
CategoricalOutcome(MarketId, CategoryIndex),
ScalarOutcome(MarketId, ScalarPosition),
CombinatorialOutcome,
PoolShare(SerdeWrapper<PoolId>),
#[default]
Ztg,
ForeignAsset(u32),
ParimutuelShare(MarketId, CategoryIndex),
}

mod all_assets;
mod campaign_assets;
mod currencies;
mod custom_assets;
mod market_assets;
mod subsets;
#[cfg(test)]
mod tests;
impl<MarketId: MaxEncodedLen> PoolSharesId<SerdeWrapper<PoolId>> for Asset<MarketId> {
fn pool_shares_id(pool_id: SerdeWrapper<PoolId>) -> Self {
Self::PoolShare(pool_id)
}
}

#[cfg(feature = "runtime-benchmarks")]
impl<MarketId: MaxEncodedLen> ZeitgeistAssetEnumerator<MarketId> for Asset<MarketId> {
fn create_asset_id(t: MarketId) -> Self {
Asset::CategoricalOutcome(t, 0)
}
}

/// In a scalar market, users can either choose a `Long` position,
/// meaning that they think the outcome will be closer to the upper bound
Expand Down
Loading
Loading