Skip to content

Commit

Permalink
Merge branch 'master' into feat/stableswap-pool-creation
Browse files Browse the repository at this point in the history
  • Loading branch information
enthusiastmartin authored Jul 6, 2023
2 parents 8cbd767 + 371a6f4 commit 6362e8c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pallets/stableswap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ pub mod pallet {
///
/// Emits `FeesUpdated` event if successful.
#[pallet::call_index(1)]
#[pallet::weight(<T as Config>::WeightInfo::update_pool())]
#[pallet::weight(<T as Config>::WeightInfo::update_pool_fees())]
#[transactional]
pub fn update_pool_fees(
origin: OriginFor<T>,
Expand Down Expand Up @@ -407,7 +407,7 @@ pub mod pallet {
///
/// Emits `AmplificationUpdated` event if successful.
#[pallet::call_index(2)]
#[pallet::weight(<T as Config>::WeightInfo::update_pool())]
#[pallet::weight(<T as Config>::WeightInfo::update_amplification())]
#[transactional]
pub fn update_amplification(
origin: OriginFor<T>,
Expand All @@ -420,7 +420,7 @@ pub mod pallet {

let current_block = T::BlockNumberProvider::current_block_number();
ensure!(
end_block > start_block && end_block > current_block && start_block >= current_block,
end_block > start_block && start_block >= current_block,
Error::<T>::PastBlock
);

Expand Down
23 changes: 14 additions & 9 deletions pallets/stableswap/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ use sp_std::marker::PhantomData;
/// Weight functions needed for pallet_stableswap.
pub trait WeightInfo {
fn create_pool() -> Weight;
fn update_pool() -> Weight;
fn add_liquidity() -> Weight;
fn remove_liquidity_one_asset() -> Weight;
fn sell() -> Weight;
fn buy() -> Weight;
fn set_asset_tradable_state() -> Weight;
fn update_pool_fees() -> Weight;
fn update_amplification() -> Weight;
}

pub struct BasiliskWeight<T>(PhantomData<T>);
Expand All @@ -63,10 +64,6 @@ impl<T: frame_system::Config> WeightInfo for BasiliskWeight<T> {
.saturating_add(T::DbWeight::get().writes(12 as u64))
}

fn update_pool() -> Weight {
Weight::from_ref_time(0u128 as u64)
}

fn add_liquidity() -> Weight {
Weight::from_ref_time(64_481_000 as u64)
.saturating_add(T::DbWeight::get().reads(10 as u64))
Expand All @@ -87,10 +84,15 @@ impl<T: frame_system::Config> WeightInfo for BasiliskWeight<T> {
.saturating_add(T::DbWeight::get().reads(9 as u64))
.saturating_add(T::DbWeight::get().writes(5 as u64))
}

fn set_asset_tradable_state() -> Weight {
Weight::from_ref_time(0)
}
fn update_pool_fees() -> Weight {
Weight::from_ref_time(0)
}
fn update_amplification() -> Weight {
Weight::from_ref_time(0)
}
}

// For backwards compatibility and tests
Expand All @@ -100,9 +102,6 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(13 as u64))
.saturating_add(RocksDbWeight::get().writes(12 as u64))
}
fn update_pool() -> Weight {
Weight::from_ref_time(0u128 as u64)
}
fn add_liquidity() -> Weight {
Weight::from_ref_time(64_481_000 as u64)
.saturating_add(RocksDbWeight::get().reads(10 as u64))
Expand All @@ -127,4 +126,10 @@ impl WeightInfo for () {
fn set_asset_tradable_state() -> Weight {
Weight::from_ref_time(0)
}
fn update_pool_fees() -> Weight {
Weight::from_ref_time(0)
}
fn update_amplification() -> Weight {
Weight::from_ref_time(0)
}
}

0 comments on commit 6362e8c

Please sign in to comment.