Skip to content

Commit 1b33b6f

Browse files
committed
toggle_user_liquidity
1 parent cd565b2 commit 1b33b6f

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

pallets/subtensor/src/subnets/subnet.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@ use subtensor_runtime_common::{NetUid, TaoCurrency};
44
use subtensor_swap_interface::SwapHandler;
55

66
impl<T: Config> Pallet<T> {
7-
/// Fetches the total count of subnets.
8-
///
9-
/// This function retrieves the total number of subnets present on the chain.
10-
///
11-
/// # Returns:
12-
/// * 'u16': The total number of subnets.
13-
///
14-
pub fn get_num_subnets() -> u16 {
15-
TotalNetworks::<T>::get()
16-
}
17-
187
/// Returns true if the subnetwork exists.
198
///
209
/// This function checks if a subnetwork with the given UID exists.
@@ -256,8 +245,7 @@ impl<T: Config> Pallet<T> {
256245
Self::deposit_event(Event::SubnetIdentitySet(netuid_to_register));
257246
}
258247

259-
T::SwapInterface::try_initialize_v3(netuid_to_register)?;
260-
248+
T::SwapInterface::toggle_user_liquidity(netuid_to_register, true);
261249
// --- 18. Emit the NetworkAdded event.
262250
log::info!("NetworkAdded( netuid:{netuid_to_register:?}, mechanism:{mechid:?} )");
263251
Self::deposit_event(Event::NetworkAdded(netuid_to_register, mechid));

pallets/swap-interface/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub trait SwapHandler<AccountId> {
3535
);
3636
fn is_user_liquidity_enabled(netuid: NetUid) -> bool;
3737
fn dissolve_all_liquidity_providers(netuid: NetUid) -> DispatchResult;
38-
fn try_initialize_v3(netuid: NetUid) -> DispatchResult;
38+
fn toggle_user_liquidity(netuid: NetUid, enabled: bool);
3939
}
4040

4141
#[derive(Debug, PartialEq)]

pallets/swap/src/pallet/impls.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,14 +1360,10 @@ impl<T: Config> Pallet<T> {
13601360
/// - **V2 / non‑V3 path**:
13611361
/// * No per‑position records exist; still defensively clear the same V3 storages (safe no‑ops).
13621362
pub fn do_dissolve_all_liquidity_providers(netuid: NetUid) -> DispatchResult {
1363-
let mechid = T::SubnetInfo::mechanism(netuid.into());
1364-
let v3_initialized = SwapV3Initialized::<T>::get(netuid);
13651363
let user_lp_enabled =
13661364
<Self as subtensor_swap_interface::SwapHandler<T::AccountId>>::is_user_liquidity_enabled(netuid);
13671365

1368-
let is_v3_mode = mechid == 1 && v3_initialized;
1369-
1370-
if is_v3_mode {
1366+
if SwapV3Initialized::<T>::get(netuid) {
13711367
// -------- V3: close every position, aggregate refunds, clear state --------
13721368

13731369
// 1) Snapshot all (owner, position_id).
@@ -1575,8 +1571,8 @@ impl<T: Config> SwapHandler<T::AccountId> for Pallet<T> {
15751571
fn dissolve_all_liquidity_providers(netuid: NetUid) -> DispatchResult {
15761572
Self::do_dissolve_all_liquidity_providers(netuid)
15771573
}
1578-
fn try_initialize_v3(netuid: NetUid) -> DispatchResult {
1579-
Self::maybe_initialize_v3(netuid).map_err(|e| e.into())
1574+
fn toggle_user_liquidity(netuid: NetUid, enabled: bool) {
1575+
EnabledUserLiquidity::<T>::insert(netuid, enabled)
15801576
}
15811577
}
15821578

0 commit comments

Comments
 (0)