bittensor.core.extrinsics.pallets.swap#

Classes#

Swap

Factory class for creating GenericCall objects for Swap pallet functions.

Module Contents#

class bittensor.core.extrinsics.pallets.swap.Swap#

Bases: bittensor.core.extrinsics.pallets.base.CallBuilder

Factory class for creating GenericCall objects for Swap pallet functions.

This class provides methods to create GenericCall instances for all Swap pallet extrinsics.

Works with both sync (Subtensor) and async (AsyncSubtensor) instances. For async operations, pass an AsyncSubtensor instance and await the result.

Example

# Sync usage call = Swap(subtensor).toggle_user_liquidity(netuid=14, enable=True) response = subtensor.sign_and_send_extrinsic(call=call, …)

# Async usage call = await Swap(subtensor).toggle_user_liquidity(netuid=14, enable=True) response = await async_subtensor.sign_and_send_extrinsic(call=call, …)

add_liquidity(netuid, liquidity, tick_low, tick_high, hotkey=None)#

Returns GenericCall instance for Subtensor function Swap.add_liquidity.

Parameters:
  • netuid (int) – The UID of the target subnet for which the call is being initiated.

  • liquidity (int) – The amount of liquidity in RAO to be added.

  • tick_low (int) – The lower bound of the price tick range.

  • tick_high (int) – The upper bound of the price tick range.

  • hotkey (Optional[str]) – The hotkey with staked TAO in Alpha. If not passed then the wallet hotkey is used.

Returns:

GenericCall instance.

Return type:

bittensor.core.extrinsics.pallets.base.Call

modify_position(netuid, hotkey, position_id, liquidity_delta)#

Returns GenericCall instance for Subtensor function Swap.modify_position.

Parameters:
  • netuid (int) – The UID of the target subnet for which the call is being initiated.

  • hotkey (str) – The hotkey with staked TAO in Alpha. If not passed then the wallet hotkey is used.

  • position_id (int) – The id of the position record in the pool.

  • liquidity_delta (int) – The amount of liquidity in RAO to be added or removed (could be positive or negative).

Returns:

GenericCall instance.

Return type:

bittensor.core.extrinsics.pallets.base.Call

remove_liquidity(netuid, hotkey, position_id)#

Returns GenericCall instance for Subtensor function Swap.remove_liquidity.

Parameters:
  • netuid (int) – The UID of the target subnet for which the call is being initiated.

  • position_id (int) – The id of the position record in the pool.

  • hotkey (str) – The hotkey with staked TAO in Alpha. If not passed then the wallet hotkey is used.

Returns:

GenericCall instance.

Return type:

bittensor.core.extrinsics.pallets.base.Call

toggle_user_liquidity(netuid, enable)#

Returns GenericCall instance for Subtensor function Swap.toggle_user_liquidity.

Parameters:
  • netuid (int) – The UID of the target subnet for which the call is being initiated.

  • enable (bool) – Boolean indicating whether to enable user liquidity.

Returns:

GenericCall instance.

Return type:

bittensor.core.extrinsics.pallets.base.Call