diff --git a/Cargo.lock b/Cargo.lock index 980e6b0d0..be4e4cf0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -819,6 +819,7 @@ version = "0.8.0" dependencies = [ "bifrost-flexible-fee", "bifrost-flexible-fee-rpc-runtime-api", + "bifrost-lightening-redeem", "bifrost-liquidity-mining", "bifrost-liquidity-mining-rpc-runtime-api", "bifrost-runtime-common", diff --git a/runtime/bifrost/Cargo.toml b/runtime/bifrost/Cargo.toml index c015bb2d9..e247897d1 100644 --- a/runtime/bifrost/Cargo.toml +++ b/runtime/bifrost/Cargo.toml @@ -88,6 +88,7 @@ pallet-vesting = { package = "bifrost-vesting", path = "../../pallets/vesting", bifrost-liquidity-mining = { path = "../../pallets/liquidity-mining", default-features = false } bifrost-liquidity-mining-rpc-runtime-api = { path = "../../pallets/liquidity-mining/rpc/runtime-api", default-features = false } bifrost-token-issuer = { path = "../../pallets/token-issuer", default-features = false } +bifrost-lightening-redeem= { path = "../../pallets/lightening-redeem", default-features = false } xcm-support = { path = "../../xcm-support", default-features = false } # orml @@ -170,6 +171,7 @@ std = [ "bifrost-liquidity-mining/std", "bifrost-liquidity-mining-rpc-runtime-api/std", "bifrost-token-issuer/std", + "bifrost-lightening-redeem/std", "zenlink-protocol/std", "zenlink-protocol-runtime-api/std", "xcm-support/std" @@ -197,6 +199,7 @@ runtime-benchmarks = [ "bifrost-salp/runtime-benchmarks", "bifrost-liquidity-mining/runtime-benchmarks", "bifrost-token-issuer/runtime-benchmarks", + "bifrost-lightening-redeem/runtime-benchmarks", ] try-runtime = [ diff --git a/runtime/bifrost/src/lib.rs b/runtime/bifrost/src/lib.rs index 0be23a527..71d75dd3f 100644 --- a/runtime/bifrost/src/lib.rs +++ b/runtime/bifrost/src/lib.rs @@ -225,6 +225,7 @@ parameter_types! { pub const TreasuryPalletId: PalletId = PalletId(*b"bf/trsry"); pub const BifrostCrowdloanId: PalletId = PalletId(*b"bf/salp#"); pub const LiquidityMiningPalletId: PalletId = PalletId(*b"bf/lm###"); + pub const LighteningRedeemPalletId: PalletId = PalletId(*b"bf/ltnrd"); } impl frame_system::Config for Runtime { @@ -921,7 +922,8 @@ impl Contains for DustRemovalWhitelist { fn contains(a: &AccountId) -> bool { AccountIdConversion::::into_account(&TreasuryPalletId::get()).eq(a) || AccountIdConversion::::into_account(&BifrostCrowdloanId::get()).eq(a) || - LiquidityMiningPalletId::get().check_sub_account::(a) + AccountIdConversion::::into_account(&LighteningRedeemPalletId::get()) + .eq(a) || LiquidityMiningPalletId::get().check_sub_account::(a) } } @@ -1148,6 +1150,15 @@ impl bifrost_token_issuer::Config for Runtime { type WeightInfo = weights::bifrost_token_issuer::WeightInfo; } +impl bifrost_lightening_redeem::Config for Runtime { + type Event = Event; + type MultiCurrency = Tokens; + type ControlOrigin = + EnsureOneOf; + type PalletId = LighteningRedeemPalletId; + type WeightInfo = weights::bifrost_lightening_redeem::WeightInfo; +} + // Bifrost modules end // zenlink runtime start @@ -1319,6 +1330,7 @@ construct_runtime! { Salp: bifrost_salp::{Pallet, Call, Storage, Event} = 105, LiquidityMining: bifrost_liquidity_mining::{Pallet, Call, Storage, Event} = 108, TokenIssuer: bifrost_token_issuer::{Pallet, Call, Storage, Event} = 109, + LighteningRedeem: bifrost_lightening_redeem::{Pallet, Call, Storage, Event} = 110, } } @@ -1565,6 +1577,7 @@ impl_runtime_apis! { list_benchmark!(list, extra, bifrost_salp, Salp); list_benchmark!(list, extra, bifrost_liquidity_mining, LiquidityMining); list_benchmark!(list, extra, bifrost_token_issuer, TokenIssuer); + list_benchmark!(list, extra, bifrost_lightening_redeem, LighteningRedeem); let storage_info = AllPalletsWithSystem::storage_info(); @@ -1599,6 +1612,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, bifrost_salp, Salp); add_benchmark!(params, batches, bifrost_liquidity_mining, LiquidityMining); add_benchmark!(params, batches, bifrost_token_issuer, TokenIssuer); + add_benchmark!(params, batches, bifrost_lightening_redeem, LighteningRedeem); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) diff --git a/runtime/bifrost/src/weights/bifrost_lightening_redeem.rs b/runtime/bifrost/src/weights/bifrost_lightening_redeem.rs new file mode 100644 index 000000000..1aeeaa348 --- /dev/null +++ b/runtime/bifrost/src/weights/bifrost_lightening_redeem.rs @@ -0,0 +1,89 @@ +// This file is part of Bifrost. + +// Copyright (C) 2019-2021 Liebi Technologies (UK) Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Autogenerated weights for `bifrost_lightening_redeem` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-10-09, STEPS: `50`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asgard-local"), DB CACHE: 128 + +// Executed Command: +// target/release/bifrost +// benchmark +// --chain=asgard-local +// --steps=50 +// --repeat=1 +// --pallet=bifrost_lightening_redeem +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./HEADER-GPL3 +// --output=./runtime/asgard/src/weights/bifrost_lightening_redeem.rs + + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for bifrost_lightening_redeem. +pub struct WeightInfo(PhantomData); +impl bifrost_lightening_redeem::WeightInfo for WeightInfo { + // Storage: Tokens Accounts (r:2 w:2) + // Storage: System Account (r:1 w:1) + fn add_ksm_to_pool() -> Weight { + (89_467_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: LighteningRedeem PoolAmount (r:1 w:1) + // Storage: LighteningRedeem ExchangePriceDiscount (r:1 w:0) + // Storage: Tokens Accounts (r:6 w:6) + // Storage: System Account (r:1 w:1) + fn exchange_for_ksm() -> Weight { + (189_565_000 as Weight) + .saturating_add(T::DbWeight::get().reads(9 as Weight)) + .saturating_add(T::DbWeight::get().writes(8 as Weight)) + } + // Storage: LighteningRedeem ExchangePriceDiscount (r:1 w:1) + fn edit_exchange_price() -> Weight { + (25_427_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: LighteningRedeem TokenReleasePerDay (r:1 w:1) + fn edit_release_per_day() -> Weight { + (25_718_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: LighteningRedeem StartEndReleaseBlock (r:1 w:1) + fn edit_release_start_and_end_block() -> Weight { + (25_608_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: LighteningRedeem StartEndReleaseBlock (r:1 w:0) + fn on_initialize() -> Weight { + (5_009_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + } +} diff --git a/runtime/bifrost/src/weights/mod.rs b/runtime/bifrost/src/weights/mod.rs index 78e1625a5..07fdb61a9 100644 --- a/runtime/bifrost/src/weights/mod.rs +++ b/runtime/bifrost/src/weights/mod.rs @@ -21,6 +21,7 @@ //! A list of the different weight modules for our runtime. pub mod bifrost_flexible_fee; +pub mod bifrost_lightening_redeem; pub mod bifrost_liquidity_mining; pub mod bifrost_salp; pub mod bifrost_token_issuer;