Skip to content

Commit 06462b0

Browse files
committed
Merge branch 'devnet-ready' into feat/reduce-tx-fees
2 parents a22f76c + 4690aaf commit 06462b0

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

pallets/subtensor/src/macros/dispatches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ mod dispatches {
585585
/// - Errors stemming from transaction pallet.
586586
///
587587
#[pallet::call_index(2)]
588-
#[pallet::weight((Weight::from_parts(345_500_000, 0)
588+
#[pallet::weight((Weight::from_parts(270_800_000, 0)
589589
.saturating_add(T::DbWeight::get().reads(26))
590590
.saturating_add(T::DbWeight::get().writes(15)), DispatchClass::Normal, Pays::Yes))]
591591
pub fn add_stake(
@@ -924,7 +924,7 @@ mod dispatches {
924924

925925
/// User register a new subnetwork via burning token
926926
#[pallet::call_index(7)]
927-
#[pallet::weight((Weight::from_parts(354_400_000, 0)
927+
#[pallet::weight((Weight::from_parts(278_400_000, 0)
928928
.saturating_add(T::DbWeight::get().reads(49))
929929
.saturating_add(T::DbWeight::get().writes(43)), DispatchClass::Normal, Pays::No))]
930930
pub fn burned_register(

pallets/swap/src/pallet/impls.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,20 @@ impl<T: Config> Pallet<T> {
368368
.collect::<sp_std::vec::Vec<_>>();
369369

370370
if let Some(position) = positions.get_mut(0) {
371+
// Claim protocol fees and add them to liquidity
372+
let (tao_fees, alpha_fees) = position.collect_fees();
373+
374+
// Adjust liquidity
371375
let current_sqrt_price = Pallet::<T>::current_price_sqrt(netuid);
372376
let maybe_token_amounts = position.to_token_amounts(current_sqrt_price);
373377
if let Ok((tao, alpha)) = maybe_token_amounts {
374378
// Get updated reserves, calculate liquidity
375-
let new_tao_reserve = tao.saturating_add(tao_delta.to_u64());
376-
let new_alpha_reserve = alpha.saturating_add(alpha_delta.to_u64());
379+
let new_tao_reserve = tao
380+
.saturating_add(tao_delta.to_u64())
381+
.saturating_add(tao_fees);
382+
let new_alpha_reserve = alpha
383+
.saturating_add(alpha_delta.to_u64())
384+
.saturating_add(alpha_fees);
377385
let new_liquidity = helpers_128bit::sqrt(
378386
(new_tao_reserve as u128).saturating_mul(new_alpha_reserve as u128),
379387
) as u64;

0 commit comments

Comments
 (0)