Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pallets/swap/src/pallet/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl<T: Config> Pallet<T> {
///
/// # 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.
Expand Down
26 changes: 13 additions & 13 deletions pallets/swap/src/pallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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(())
}
}
Expand Down