diff --git a/appchain/benchmarking/src/mock.rs b/appchain/benchmarking/src/mock.rs index 1943ca3..e7ac5fe 100644 --- a/appchain/benchmarking/src/mock.rs +++ b/appchain/benchmarking/src/mock.rs @@ -302,11 +302,13 @@ impl LposInterface<::AccountId> for MockLp } parameter_types! { - pub const OctopusAppchainPalletId: PalletId = PalletId(*b"py/octps"); - pub const GracePeriod: u32 = 10; - pub const UnsignedPriority: u64 = 1 << 21; - pub const RequestEventLimit: u32 = 10; - pub const UpwardMessagesLimit: u32 = 10; + pub const OctopusAppchainPalletId: PalletId = PalletId(*b"py/octps"); + pub const GracePeriod: u32 = 10; + pub const UnsignedPriority: u64 = 1 << 21; + pub const RequestEventLimit: u32 = 10; + pub const UpwardMessagesLimit: u32 = 10; + pub const NativeTokenDecimals: u128 = 1_000_000_000_000_000_000; + pub const FeeTh: u64 = 300; } impl pallet_octopus_bridge::Config for Test { @@ -323,6 +325,8 @@ impl pallet_octopus_bridge::Config for Test { type ItemId = u128; type Nonfungibles = pallet_octopus_bridge::impls::UnImplementUniques; type Convertor = pallet_octopus_bridge::impls::ExampleConvertor; + type NativeTokenDecimals = NativeTokenDecimals; + type Threshold = FeeTh; type WeightInfo = (); } diff --git a/appchain/src/mock.rs b/appchain/src/mock.rs index 4988524..4154ab5 100644 --- a/appchain/src/mock.rs +++ b/appchain/src/mock.rs @@ -282,6 +282,11 @@ impl pallet_uniques::Config for Test { type Locker = (); } +parameter_types! { + pub const NativeTokenDecimals: u128 = 1_000_000_000_000_000_000; + pub const FeeTh: u64 = 300; +} + impl pallet_octopus_bridge::Config for Test { type RuntimeEvent = RuntimeEvent; type PalletId = OctopusAppchainPalletId; @@ -296,6 +301,8 @@ impl pallet_octopus_bridge::Config for Test { type ItemId = u128; type Nonfungibles = pallet_octopus_bridge::impls::UnImplementUniques; type Convertor = pallet_octopus_bridge::impls::ExampleConvertor; + type NativeTokenDecimals = NativeTokenDecimals; + type Threshold = FeeTh; type WeightInfo = (); } diff --git a/bridge/benchmarking/src/lib.rs b/bridge/benchmarking/src/lib.rs index 1bf4533..79f69a3 100644 --- a/bridge/benchmarking/src/lib.rs +++ b/bridge/benchmarking/src/lib.rs @@ -92,7 +92,7 @@ fn set_oracle_account_and_update_token_price() { let ret = BridgePallet::::set_oracle_account(RawOrigin::Root.into(), source); assert!(ret.is_ok()); let origin = RawOrigin::Signed(caller.clone()); - let ret = BridgePallet::::set_token_price(origin.into(), 100); + let ret = BridgePallet::::set_token_price(origin.into(), 11, 1_000_000_000_000); assert!(ret.is_ok()); } @@ -356,12 +356,13 @@ benchmarks! { let _ = BridgePallet::::set_oracle_account(RawOrigin::Root.into(), source); let origin = RawOrigin::Signed(caller.clone()); }: { - let ret = BridgePallet::::set_token_price(origin.into(), 1_000_000); + let ret = BridgePallet::::set_token_price(origin.into(), 1_000_000, 2000_000); } verify { - assert_last_event::(BridgeEvent::TokenPriceUpdated{ + assert_last_event::(BridgeEvent::PriceUpdated{ who: caller, - price: 1_000_000, + near_price: 1_000_000, + native_token_price: 2000_000, } .into()); } diff --git a/bridge/benchmarking/src/mock.rs b/bridge/benchmarking/src/mock.rs index 0c1fed0..a1703be 100644 --- a/bridge/benchmarking/src/mock.rs +++ b/bridge/benchmarking/src/mock.rs @@ -306,6 +306,8 @@ parameter_types! { pub const UnsignedPriority: u64 = 1 << 21; pub const RequestEventLimit: u32 = 10; pub const UpwardMessagesLimit: u32 = 10; + pub const NativeTokenDecimals: u128 = 1_000_000_000_000_000_000; + pub const Th: u64 = 300; } impl pallet_octopus_bridge::Config for Test { @@ -322,6 +324,8 @@ impl pallet_octopus_bridge::Config for Test { type ItemId = u128; type Nonfungibles = pallet_octopus_bridge::impls::UnImplementUniques; type Convertor = pallet_octopus_bridge::impls::ExampleConvertor; + type NativeTokenDecimals = NativeTokenDecimals; + type Threshold = Th; type WeightInfo = (); } diff --git a/bridge/src/lib.rs b/bridge/src/lib.rs index d7e3e10..83420ee 100644 --- a/bridge/src/lib.rs +++ b/bridge/src/lib.rs @@ -43,7 +43,7 @@ use serde::Deserialize; use serde_json::json; use sp_runtime::{ traits::{AccountIdConversion, CheckedConversion, StaticLookup}, - RuntimeDebug, + Perbill, RuntimeDebug, }; use sp_std::prelude::*; use weights::WeightInfo; @@ -129,6 +129,12 @@ pub mod pallet { type Convertor: ConvertIntoNep171; + #[pallet::constant] + type NativeTokenDecimals: Get; + + #[pallet::constant] + type Threshold: Get; + /// Type representing the weight of this pallet type WeightInfo: WeightInfo; } @@ -328,10 +334,15 @@ pub mod pallet { } #[pallet::weight(::WeightInfo::set_token_price())] - pub fn set_token_price(origin: OriginFor, price: u32) -> DispatchResult { + pub fn set_token_price( + origin: OriginFor, + near_price: u64, + native_token_price: u64, + ) -> DispatchResult { let who = ensure_signed(origin)?; - ensure!(price != 0, Error::::PriceIsZero); + ensure!(near_price != 0, Error::::NearPriceSetedIsZero); + ensure!(native_token_price != 0, Error::::NativeTokenPriceSetedIsZero); let oracle_account = match >::try_get() { Ok(account) => account, @@ -340,13 +351,25 @@ pub mod pallet { ensure!(who == oracle_account, Error::::UpdatePriceWithNoPermissionAccount); - >::put(Some(price)); - Self::calculate_and_update_fee(price); + >::put(Some(native_token_price)); + >::put(Some(near_price)); + + Self::calculate_and_update_fee(near_price, native_token_price); - Self::deposit_event(Event::TokenPriceUpdated { who, price }); + Self::deposit_event(Event::PriceUpdated { who, near_price, native_token_price }); Ok(()) } + + #[pallet::weight(0)] + pub fn set_coef_for_calculate_fee(origin: OriginFor, coef: u32) -> DispatchResult { + ensure_root(origin)?; + ensure!(coef > 0 && coef <= 100, Error::::InvalidCoef); + + >::put(coef); + Self::deposit_event(Event::CoefUpdated { coef }); + Ok(()) + } } #[pallet::event] @@ -416,9 +439,13 @@ pub mod pallet { OracleAccountHasBeenSet { who: T::AccountId, }, - TokenPriceUpdated { + PriceUpdated { who: T::AccountId, - price: u32, + near_price: u64, + native_token_price: u64, + }, + CoefUpdated { + coef: u32, }, } @@ -450,12 +477,16 @@ pub mod pallet { ConvertorNotImplement, /// Not set oracle account. NoOracleAccount, - /// Price is zero. - PriceIsZero, + /// Near price setted by oracle is zero. + NearPriceSetedIsZero, + /// Native token price setted by oracle is zero. + NativeTokenPriceSetedIsZero, /// Update token price must use oracle account. UpdatePriceWithNoPermissionAccount, /// Invalid fee. InvalidFee, + /// Invalid coef. + InvalidCoef, } /// A map from NEAR token account ID to appchain asset ID. @@ -474,7 +505,20 @@ pub mod pallet { /// Token price setted by oracle account. #[pallet::storage] - pub(crate) type TokenPrice = StorageValue<_, Option, ValueQuery>; + pub(crate) type TokenPrice = StorageValue<_, Option, ValueQuery>; + + /// Near price setted by oracle account. + #[pallet::storage] + pub(crate) type NearPrice = StorageValue<_, Option, ValueQuery>; + + #[pallet::type_value] + pub(crate) fn DefaultForCoef() -> u32 { + 3u32 + } + + /// Coef used to calculate fee for cross chain transactions. + #[pallet::storage] + pub(crate) type Coef = StorageValue<_, u32, ValueQuery, DefaultForCoef>; #[pallet::genesis_config] pub struct GenesisConfig { @@ -530,9 +574,50 @@ impl Pallet { T::PalletId::get().into_account_truncating() } - fn calculate_and_update_fee(price: u32) { - let ft_fee: BalanceOf = (price / 4).checked_into().unwrap(); - let nft_fee: BalanceOf = (price / 2).checked_into().unwrap(); + // Calcute: + // coef = >::get() / 100, + // quantity = coef * near_native_token_price / wrapped_appchain_token_price, + // If quantity > threshold, then quantity = threshold. + fn calculate_quantity_of_native_tokens( + near_price: u64, + native_token_price: u64, + ) -> (u64, Perbill) { + // (integer, fraction) = near_native_token_price / wrapped_appchain_token_price + let integer = + if near_price >= native_token_price { near_price / native_token_price } else { 0u64 }; + + let remain = near_price % native_token_price; + let fraction = Perbill::from_rational(remain, native_token_price); + + // (integer1, fraction1) = integer * coef + let value1 = integer * (>::get() as u64); + let integer1 = if value1 >= 100 { value1 / 100 } else { 0u64 }; + + if integer >= T::Threshold::get() { + return (T::Threshold::get(), Perbill::zero()) + } + + let remain1 = value1 % 100; + let fraction1 = Perbill::from_rational(remain1, 100); + + // fraction2 = fraction * coef + let fraction2 = fraction * Perbill::from_rational(>::get() as u64, 100); + + // result = (coef * integer) + (coef * fraction) + // = (integer1, fraction1) + (0, fraction2) + (integer1, fraction1 + fraction2) + } + + fn calculate_and_update_fee(near_price: u64, native_token_price: u64) { + let (integer, fraction) = + Self::calculate_quantity_of_native_tokens(near_price, native_token_price); + + let fee_integer = T::NativeTokenDecimals::get() * (integer as u128); + let fee_fraction = + T::NativeTokenDecimals::get() * (fraction.deconstruct() as u128) / 1_000_000_000; + let ft_fee: BalanceOf = (fee_integer + fee_fraction).checked_into().unwrap(); + // Notes: should modify later. + let nft_fee = ft_fee; >::insert(CrossChainTransferType::Fungible, Some(ft_fee)); >::insert(CrossChainTransferType::Nonfungible, Some(nft_fee)); diff --git a/bridge/src/mock.rs b/bridge/src/mock.rs index 5f695c0..678003f 100644 --- a/bridge/src/mock.rs +++ b/bridge/src/mock.rs @@ -291,6 +291,8 @@ parameter_types! { pub const RequestEventLimit: u32 = 10; pub const UpwardMessagesLimit: u32 = 10; pub const MaxValidators: u32 = 10 ; + pub const NativeTokenDecimals: u128 = 1_000_000_000_000_000_000; + pub const FeeTh: u64 = 300; } impl pallet_octopus_appchain::Config for Test { @@ -322,6 +324,8 @@ impl Config for Test { type ItemId = u128; type Nonfungibles = Uniques; type Convertor = pallet_octopus_bridge::impls::ExampleConvertor; + type NativeTokenDecimals = NativeTokenDecimals; + type Threshold = FeeTh; type WeightInfo = (); } diff --git a/bridge/src/tests.rs b/bridge/src/tests.rs index dca4c56..17d5db3 100644 --- a/bridge/src/tests.rs +++ b/bridge/src/tests.rs @@ -315,29 +315,63 @@ pub fn test_set_token_price() { let origin2 = RuntimeOrigin::signed(bob); new_tester().execute_with(|| { assert_noop!( - OctopusBridge::set_token_price(origin1.clone(), 1000000), + OctopusBridge::set_token_price(origin1.clone(), 1000, 1000), Error::::NoOracleAccount ); assert_ok!(OctopusBridge::set_oracle_account(RuntimeOrigin::root(), source.clone())); assert_noop!( - OctopusBridge::set_token_price(origin2, 1000000), + OctopusBridge::set_token_price(origin2, 1000, 1000), Error::::UpdatePriceWithNoPermissionAccount ); assert_noop!( - OctopusBridge::set_token_price(origin1.clone(), 0), - Error::::PriceIsZero + OctopusBridge::set_token_price(origin1.clone(), 0, 0), + Error::::NearPriceSetedIsZero ); - assert_ok!(OctopusBridge::set_token_price(origin1, 1000000)); + assert_noop!( + OctopusBridge::set_token_price(origin1.clone(), 1000, 0), + Error::::NativeTokenPriceSetedIsZero + ); + assert_ok!(OctopusBridge::set_token_price(origin1.clone(), 1000, 1000)); - assert_eq!(TokenPrice::::get(), Some(1000000)); + assert_eq!(TokenPrice::::get(), Some(1000)); assert_eq!( CrosschainTransferFee::::get(CrossChainTransferType::Fungible).unwrap(), - Some(250000) + Some(30_000_000_000_000_000) ); assert_eq!( CrosschainTransferFee::::get(CrossChainTransferType::Nonfungible).unwrap(), - Some(500000) + Some(30_000_000_000_000_000) + ); + + assert_ok!(OctopusBridge::set_token_price(origin1.clone(), 3_119_000, 6_620_000)); + assert_eq!( + CrosschainTransferFee::::get(CrossChainTransferType::Fungible).unwrap(), + Some(14_134_441_000_000_000) + ); + + assert_ok!(OctopusBridge::set_token_price(origin1.clone(), 3_119_000, 20_535_200_000)); + assert_eq!( + CrosschainTransferFee::::get(CrossChainTransferType::Fungible).unwrap(), + Some(4_556_000_000_000) + ); + + assert_ok!(OctopusBridge::set_token_price(origin1.clone(), 3_119_000, 41_000)); + assert_eq!( + CrosschainTransferFee::::get(CrossChainTransferType::Fungible).unwrap(), + Some(2_282_195_121_000_000_000) + ); + + assert_ok!(OctopusBridge::set_token_price(origin1.clone(), 3_119_000, 1)); + assert_eq!( + CrosschainTransferFee::::get(CrossChainTransferType::Fungible).unwrap(), + Some(300_000_000_000_000_000_000) + ); + + assert_ok!(OctopusBridge::set_token_price(origin1, 3_119_000, 3_119_000)); + assert_eq!( + CrosschainTransferFee::::get(CrossChainTransferType::Fungible).unwrap(), + Some(30_000_000_000_000_000) ); }); } diff --git a/bridge/src/weights.rs b/bridge/src/weights.rs index 3861578..9b38f5b 100644 --- a/bridge/src/weights.rs +++ b/bridge/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_octopus_bridge //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-10-27, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-11-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `andy-VirtualBox`, CPU: `AMD Ryzen 7 5800H with Radeon Graphics` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -73,7 +73,7 @@ impl WeightInfo for SubstrateWeight { // Storage: OctopusUpwardMessages MessageQueue (r:1 w:1) // Storage: OctopusUpwardMessages Nonce (r:1 w:1) fn lock() -> Weight { - Weight::from_ref_time(176_690_000 as u64) + Weight::from_ref_time(166_342_000 as u64) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -86,7 +86,7 @@ impl WeightInfo for SubstrateWeight { // Storage: OctopusUpwardMessages MessageQueue (r:1 w:1) // Storage: OctopusUpwardMessages Nonce (r:1 w:1) fn burn_nep141() -> Weight { - Weight::from_ref_time(270_422_000 as u64) + Weight::from_ref_time(220_224_000 as u64) .saturating_add(T::DbWeight::get().reads(9 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -102,33 +102,33 @@ impl WeightInfo for SubstrateWeight { // Storage: OctopusUniques Account (r:0 w:2) // Storage: OctopusUniques ItemPriceOf (r:0 w:1) fn lock_nonfungible() -> Weight { - Weight::from_ref_time(215_503_000 as u64) + Weight::from_ref_time(207_861_000 as u64) .saturating_add(T::DbWeight::get().reads(9 as u64)) .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: OctopusAppchain IsActivated (r:1 w:0) // Storage: OctopusBridge AssetIdByTokenId (r:3 w:1) fn set_token_id() -> Weight { - Weight::from_ref_time(47_302_000 as u64) + Weight::from_ref_time(44_884_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: OctopusBridge AssetIdByTokenId (r:1 w:1) fn delete_token_id() -> Weight { - Weight::from_ref_time(24_979_000 as u64) + Weight::from_ref_time(24_105_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn force_unlock() -> Weight { - Weight::from_ref_time(98_484_000 as u64) + Weight::from_ref_time(95_870_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: OctopusAssets Asset (r:1 w:1) // Storage: OctopusAssets Account (r:1 w:1) fn force_mint_nep141() -> Weight { - Weight::from_ref_time(88_481_000 as u64) + Weight::from_ref_time(82_385_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -137,22 +137,24 @@ impl WeightInfo for SubstrateWeight { // Storage: OctopusUniques Account (r:0 w:1) // Storage: OctopusUniques ItemPriceOf (r:0 w:1) fn force_unlock_nonfungible() -> Weight { - Weight::from_ref_time(91_368_000 as u64) + Weight::from_ref_time(86_562_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: OctopusBridge OracleAccount (r:0 w:1) fn set_oracle_account() -> Weight { - Weight::from_ref_time(32_688_000 as u64) + Weight::from_ref_time(31_309_000 as u64) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: OctopusBridge OracleAccount (r:1 w:0) + // Storage: OctopusBridge Coef (r:1 w:0) // Storage: OctopusBridge CrosschainTransferFee (r:0 w:2) + // Storage: OctopusBridge NearPrice (r:0 w:1) // Storage: OctopusBridge TokenPrice (r:0 w:1) fn set_token_price() -> Weight { - Weight::from_ref_time(48_595_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + Weight::from_ref_time(51_477_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } } @@ -164,7 +166,7 @@ impl WeightInfo for () { // Storage: OctopusUpwardMessages MessageQueue (r:1 w:1) // Storage: OctopusUpwardMessages Nonce (r:1 w:1) fn lock() -> Weight { - Weight::from_ref_time(176_690_000 as u64) + Weight::from_ref_time(166_342_000 as u64) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -177,7 +179,7 @@ impl WeightInfo for () { // Storage: OctopusUpwardMessages MessageQueue (r:1 w:1) // Storage: OctopusUpwardMessages Nonce (r:1 w:1) fn burn_nep141() -> Weight { - Weight::from_ref_time(270_422_000 as u64) + Weight::from_ref_time(220_224_000 as u64) .saturating_add(RocksDbWeight::get().reads(9 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -193,33 +195,33 @@ impl WeightInfo for () { // Storage: OctopusUniques Account (r:0 w:2) // Storage: OctopusUniques ItemPriceOf (r:0 w:1) fn lock_nonfungible() -> Weight { - Weight::from_ref_time(215_503_000 as u64) + Weight::from_ref_time(207_861_000 as u64) .saturating_add(RocksDbWeight::get().reads(9 as u64)) .saturating_add(RocksDbWeight::get().writes(7 as u64)) } // Storage: OctopusAppchain IsActivated (r:1 w:0) // Storage: OctopusBridge AssetIdByTokenId (r:3 w:1) fn set_token_id() -> Weight { - Weight::from_ref_time(47_302_000 as u64) + Weight::from_ref_time(44_884_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: OctopusBridge AssetIdByTokenId (r:1 w:1) fn delete_token_id() -> Weight { - Weight::from_ref_time(24_979_000 as u64) + Weight::from_ref_time(24_105_000 as u64) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn force_unlock() -> Weight { - Weight::from_ref_time(98_484_000 as u64) + Weight::from_ref_time(95_870_000 as u64) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: OctopusAssets Asset (r:1 w:1) // Storage: OctopusAssets Account (r:1 w:1) fn force_mint_nep141() -> Weight { - Weight::from_ref_time(88_481_000 as u64) + Weight::from_ref_time(82_385_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -228,21 +230,23 @@ impl WeightInfo for () { // Storage: OctopusUniques Account (r:0 w:1) // Storage: OctopusUniques ItemPriceOf (r:0 w:1) fn force_unlock_nonfungible() -> Weight { - Weight::from_ref_time(91_368_000 as u64) + Weight::from_ref_time(86_562_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: OctopusBridge OracleAccount (r:0 w:1) fn set_oracle_account() -> Weight { - Weight::from_ref_time(32_688_000 as u64) + Weight::from_ref_time(31_309_000 as u64) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: OctopusBridge OracleAccount (r:1 w:0) + // Storage: OctopusBridge Coef (r:1 w:0) // Storage: OctopusBridge CrosschainTransferFee (r:0 w:2) + // Storage: OctopusBridge NearPrice (r:0 w:1) // Storage: OctopusBridge TokenPrice (r:0 w:1) fn set_token_price() -> Weight { - Weight::from_ref_time(48_595_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + Weight::from_ref_time(51_477_000 as u64) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) } } diff --git a/lpos/src/mock.rs b/lpos/src/mock.rs index 82022cb..6abc805 100644 --- a/lpos/src/mock.rs +++ b/lpos/src/mock.rs @@ -264,6 +264,11 @@ impl pallet_octopus_appchain::Config for Test { type MaxValidators = MaxValidators; } +parameter_types! { + pub const NativeTokenDecimals: u128 = 1_000_000_000_000_000_000; + pub const FeeTh: u64 = 300; +} + impl pallet_octopus_bridge::Config for Test { type RuntimeEvent = RuntimeEvent; type PalletId = OctopusAppchainPalletId; @@ -278,6 +283,8 @@ impl pallet_octopus_bridge::Config for Test { type ItemId = u128; type Nonfungibles = pallet_octopus_bridge::impls::UnImplementUniques; type Convertor = (); + type NativeTokenDecimals = NativeTokenDecimals; + type Threshold = FeeTh; type WeightInfo = (); }