diff --git a/pallets/swap/src/pallet/impls.rs b/pallets/swap/src/pallet/impls.rs index 90285b1f4a..a5f489b96e 100644 --- a/pallets/swap/src/pallet/impls.rs +++ b/pallets/swap/src/pallet/impls.rs @@ -322,7 +322,7 @@ impl Pallet { /// /// # Returns /// Returns a [`Result`] with a [`SwapResult`] on success, or a [`DispatchError`] on failure. - /// + /// /// The [`SwapResult`] contains: /// - `amount_paid_out`: The amount of tokens received from the swap. /// - `refund`: Any unswapped portion of the input amount, refunded to the caller. diff --git a/pallets/swap/src/pallet/mod.rs b/pallets/swap/src/pallet/mod.rs index f506174101..10bce8f34d 100644 --- a/pallets/swap/src/pallet/mod.rs +++ b/pallets/swap/src/pallet/mod.rs @@ -451,8 +451,8 @@ mod pallet { // Emit an event Self::deposit_event(Event::LiquidityAdded { - coldkey, - hotkey, + coldkey: coldkey.clone(), + hotkey: hotkey.clone(), netuid, position_id, liquidity: liquidity_delta as u64, @@ -461,20 +461,12 @@ mod pallet { }); } else { // Credit the returned tao and alpha to the account - T::BalanceOps::increase_balance( - &coldkey, - result.tao.saturating_add(result.fee_tao), - ); - T::BalanceOps::increase_stake( - &coldkey, - &hotkey, - netuid, - result.alpha.saturating_add(result.fee_alpha), - )?; + T::BalanceOps::increase_balance(&coldkey, result.tao); + T::BalanceOps::increase_stake(&coldkey, &hotkey, netuid, result.alpha)?; // Emit an event Self::deposit_event(Event::LiquidityRemoved { - coldkey, + coldkey: coldkey.clone(), netuid: netuid.into(), position_id, tao: result.tao, @@ -484,6 +476,14 @@ mod pallet { }); } + // Credit accrued fees to user account (no matter if liquidity is added or removed) + if result.fee_tao > 0 { + T::BalanceOps::increase_balance(&coldkey, result.fee_tao); + } + if result.fee_alpha > 0 { + T::BalanceOps::increase_stake(&coldkey, &hotkey.clone(), netuid, result.fee_alpha)?; + } + Ok(()) } }