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

Fix Hybrid Router clippy and tests #1291

Merged
merged 4 commits into from
Mar 29, 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
8 changes: 6 additions & 2 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions primitives/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ pub const GLOBAL_DISPUTES_PALLET_ID: PalletId = PalletId(*b"zge/gldp");
/// Lock identifier, mainly used for the locks on the accounts.
pub const GLOBAL_DISPUTES_LOCK_ID: [u8; 8] = *b"zge/gdlk";

// Hybrid Router
/// Pallet identifier, mainly used for named balance reserves.
pub const HYBRID_ROUTER_PALLET_ID: PalletId = PalletId(*b"zge/hybr");

// Liqudity Mining
/// Pallet identifier, mainly used for named balance reserves.
pub const LM_PALLET_ID: PalletId = PalletId(*b"zge/lymg");
Expand Down
6 changes: 6 additions & 0 deletions primitives/src/constants/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ parameter_types! {
pub const VotingOutcomeFee: Balance = 100 * CENT;
}

// Hybrid Router parameters
parameter_types! {
pub const HybridRouterPalletId: PalletId = PalletId(*b"zge/hybr");
pub const MaxOrders: u32 = 100;
}

// Liquidity Mining parameters
parameter_types! {
pub const LiquidityMiningPalletId: PalletId = PalletId(*b"zge/lymg");
Expand Down
6 changes: 5 additions & 1 deletion runtime/battery-station/src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ parameter_types! {
/// The maximum number of public proposals that can exist at any time.
pub const MaxProposals: u32 = 100;

// Hybrid Router parameters
pub const HybridRouterPalletId: PalletId = HYBRID_ROUTER_PALLET_ID;
/// Maximum number of orders that can be placed in a single trade transaction.
pub const MaxOrders: u32 = 100;

// Identity
/// The amount held on deposit for a registered identity
pub const BasicDeposit: Balance = deposit(1, 258);
Expand Down Expand Up @@ -326,7 +331,6 @@ parameter_types! {

// Orderbook parameters
pub const OrderbookPalletId: PalletId = ORDERBOOK_PALLET_ID;
pub const MaxOrders: u32 = 100;

// Parimutuel parameters
pub const MinBetSize: Balance = 100 * ExistentialDeposit::get();
Expand Down
6 changes: 6 additions & 0 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ macro_rules! decl_common_types {
AuthorizedPalletId::get(),
CourtPalletId::get(),
GlobalDisputesPalletId::get(),
HybridRouterPalletId::get(),
LiquidityMiningPalletId::get(),
OrderbookPalletId::get(),
ParimutuelPalletId::get(),
Expand Down Expand Up @@ -1282,11 +1283,16 @@ macro_rules! impl_config_traits {

impl zrml_hybrid_router::Config for Runtime {
type AssetManager = AssetManager;
#[cfg(feature = "runtime-benchmarks")]
type AmmPoolDeployer = NeoSwaps;
#[cfg(feature = "runtime-benchmarks")]
type CompleteSetOperations = PredictionMarkets;
type MarketCommons = MarketCommons;
type Amm = NeoSwaps;
type OrderBook = Orderbook;
type MaxOrders = MaxOrders;
type RuntimeEvent = RuntimeEvent;
type PalletId = HybridRouterPalletId;
type WeightInfo = zrml_hybrid_router::weights::WeightInfo<Runtime>;
}
};
Expand Down
6 changes: 5 additions & 1 deletion runtime/zeitgeist/src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ parameter_types! {
/// The maximum number of public proposals that can exist at any time.
pub const MaxProposals: u32 = 100;

// Hybrid Router parameters
pub const HybridRouterPalletId: PalletId = HYBRID_ROUTER_PALLET_ID;
/// Maximum number of orders that can be placed in a single trade transaction.
pub const MaxOrders: u32 = 100;

// Identity
/// The amount held on deposit for a registered identity
pub const BasicDeposit: Balance = deposit(1, 258);
Expand Down Expand Up @@ -326,7 +331,6 @@ parameter_types! {

// Orderbook parameters
pub const OrderbookPalletId: PalletId = ORDERBOOK_PALLET_ID;
pub const MaxOrders: u32 = 100;

// Parimutuel parameters
pub const MinBetSize: Balance = 100 * ExistentialDeposit::get();
Expand Down
4 changes: 2 additions & 2 deletions scripts/benchmarks/configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export ORML_PALLETS_STEPS="${ORML_PALLETS_STEPS:-50}"
export ORML_WEIGHT_TEMPLATE="./misc/orml_weight_template.hbs"

export ZEITGEIST_PALLETS=(
zrml_authorized zrml_court zrml_global_disputes zrml_liquidity_mining zrml_neo_swaps \
zrml_orderbook zrml_parimutuel zrml_prediction_markets zrml_swaps zrml_styx \
zrml_authorized zrml_court zrml_global_disputes zrml_hybrid_router zrml_liquidity_mining \
zrml_neo_swaps zrml_orderbook zrml_parimutuel zrml_prediction_markets zrml_swaps zrml_styx \
)
export ZEITGEIST_PALLETS_RUNS="${ZEITGEIST_PALLETS_RUNS:-20}"
export ZEITGEIST_PALLETS_STEPS="${ZEITGEIST_PALLETS_STEPS:-50}"
Expand Down
74 changes: 54 additions & 20 deletions zrml/hybrid-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,68 @@ sp-runtime = { workspace = true }
zeitgeist-primitives = { workspace = true }
zrml-market-commons = { workspace = true }


orml-asset-registry = { workspace = true, optional = true }
orml-currencies = { workspace = true, optional = true }
orml-tokens = { workspace = true, optional = true }
pallet-balances = { workspace = true, optional = true }
pallet-randomness-collective-flip = { workspace = true, optional = true }
pallet-timestamp = { workspace = true, optional = true }
pallet-treasury = { workspace = true, optional = true }
pallet-xcm = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
sp-io = { workspace = true, optional = true }
xcm = { workspace = true, optional = true }
xcm-builder = { workspace = true, optional = true }
zrml-authorized = { workspace = true, optional = true }
zrml-court = { workspace = true, optional = true }
zrml-global-disputes = { workspace = true, optional = true }
zrml-liquidity-mining = { workspace = true, optional = true }
zrml-neo-swaps = { workspace = true, optional = true }
zrml-orderbook = { workspace = true, optional = true }
zrml-prediction-markets = { workspace = true, optional = true }
zrml-simple-disputes = { workspace = true, optional = true }

[dev-dependencies]
env_logger = { workspace = true }
orml-currencies = { workspace = true, features = ["default"] }
orml-tokens = { workspace = true, features = ["default"] }
pallet-balances = { workspace = true, features = ["default"] }
pallet-randomness-collective-flip = { workspace = true, features = ["default"] }
pallet-timestamp = { workspace = true, features = ["default"] }
pallet-treasury = { workspace = true, features = ["default"] }
sp-io = { workspace = true, features = ["default"] }
zeitgeist-primitives = { workspace = true, features = ["mock", "default"] }
zrml-authorized = { workspace = true, features = ["default"] }
zrml-court = { workspace = true, features = ["default"] }
zrml-global-disputes = { workspace = true, features = ["default"] }
zrml-liquidity-mining = { workspace = true, features = ["default"] }
zrml-market-commons = { workspace = true, features = ["default"] }
zrml-neo-swaps = { workspace = true, features = ["default"] }
zrml-orderbook = { workspace = true, features = ["default"] }
zrml-prediction-markets = { workspace = true, features = ["default"] }
zrml-rikiddo = { workspace = true, features = ["default"] }
zrml-simple-disputes = { workspace = true, features = ["default"] }
zrml-swaps = { workspace = true, features = ["default"] }

test-case = { workspace = true }
zrml-hybrid-router = { workspace = true, features = ["mock"] }

[features]
default = ["std"]
mock = [
"orml-asset-registry/default",
"orml-currencies/default",
"orml-tokens/default",
"pallet-balances/default",
"pallet-randomness-collective-flip/default",
"pallet-timestamp/default",
"pallet-treasury/default",
"pallet-xcm/default",
"serde/default",
"sp-io/default",
"xcm/default",
"zeitgeist-primitives/mock",
"zrml-market-commons/default",
"zrml-neo-swaps/default",
"zrml-orderbook/default",
"zrml-prediction-markets/default",
"zrml-prediction-markets/mock",
"zrml-simple-disputes/default",
"zrml-authorized/default",
"zrml-court/default",
"zrml-global-disputes/default",
"zrml-liquidity-mining/default",
]
parachain = [
"zrml-prediction-markets/parachain",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
]
std = [
"frame-benchmarking?/std",
Expand All @@ -47,6 +79,8 @@ std = [
"orml-traits/std",
"parity-scale-codec/std",
"sp-runtime/std",
"xcm-builder/std",
"pallet-xcm/std",
"zeitgeist-primitives/std",
"zrml-market-commons/std",
]
Expand Down
2 changes: 0 additions & 2 deletions zrml/hybrid-router/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ use zeitgeist_primitives::{
};
use zrml_market_commons::MarketCommonsPalletApi;

pub const MIN_SPOT_PRICE: u128 = CENT / 2;

// Same behavior as `assert_ok!`, except that it wraps the call inside a transaction layer. Required
// when calling into functions marked `require_transactional` to avoid a `Transactional(NoLayer)`
// error.
Expand Down
Loading
Loading