# Update Swap Queue

#### Swap queues that are initiated by

* [`swap_delegate_stake`](/network/staking/subnet-node-delegate-staking.md#swap-and-queue)
* [`swap_node_delegate_stake`](/network/staking/subnet-node-delegate-staking.md#swap-and-queue)

Swap queues insert the swap into the `SwapCallQueue` queue that can be updated by calling `update_swap_queue`. Both of these functions will emit an event  `SwapCallQueued` (event has the same name as the storage element) that has an ID. This ID can then be used for updating the swap call queue. The storage element `SwapCallQueue` can also be queried to find the ID in relation to the key that owns the stake.

The swap queue is a feature because of subnet slots. This ensures that users cannot arbitrage the emissions of each subnet on each epoch by swapping the balance to each subnet on each block step.

{% hint style="info" %}
A swap queue **cannot** be cancelled.
{% endhint %}

```rust
pub fn update_swap_queue(
    origin: OriginFor<T>,
    id: u32,
    new_call: QueuedSwapCall<T::AccountId>,
)
```

#### Parameters:

* `id`: The ID of the swap queue.
* `new_call`: The swap queue enum format:

  ```rust
  pub enum QueuedSwapCall<AccountId> {
      SwapToSubnetDelegateStake {
          account_id: AccountId,
          to_subnet_id: u32,
          balance: u128,
      },
      SwapToNodeDelegateStake {
          account_id: AccountId,
          to_subnet_id: u32,
          to_subnet_node_id: u32,
          balance: u128,
      },
  }
  ```

  * **Note:** When updating, the `balance` parameter is ignored, and the place in the queue is unchanged.
  * To update the swap queue **to a subnet**, call `update_swap_queue` with `QueuedSwapCall::SwapToSubnetDelegateStake`.
  * To update the swap queue **to a subnet node**, call `update_swap_queue` with `QueuedSwapCall::SwapToNodeDelegateStake`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hypertensor.org/network/staking/update-swap-queue.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
