# Update Swap Queue

#### Swap queues that are initiated by

* [`swap_delegate_stake`](https://docs.hypertensor.org/network/subnet-node-delegate-staking#swap-and-queue)
* [`swap_node_delegate_stake`](https://docs.hypertensor.org/network/subnet-node-delegate-staking#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`.
