# Router

The Router's primary role is to streamline complex staking and swapping processes. It handles the underlying logic for:

* **Staking and Withdrawing SOL**: Allows users to stake and withdraw SOL.
* **Swapping via Stake Accounts**: Facilitates swaps between different LSTs by leveraging stake accounts, acting as a routing layer.

The Router currently only works with active stake accounts.

## Relevant Instructions

The Router Program exposes a comprehensive set of instructions to manage its various functionalities:

* `StakeWrappedSol`: Allows users to stake SOL into a staking pool, receiving an LST in return
* `WithdrawWrappedSol`: Allows users to withdraw undelegated SOL from a stake pool's reserve.
* `WithdrawStake`: Prepares a temporary stake account that will receive SOL from an unstake operation.
* `DepositStake`: Allows users to deposit a stake account directly into a staking pool, receiving an LST in return.
* `SwapViaStake`: Executes a "swap" between two different LSTs. This operation requires that the two stake pools involved in the swap have a validator in common within their validator set.&#x20;

The `SwapViaStake` instruction can also be used in conjunction with [The Reserve](/docs/technical-documentation/reserve.md) to access instant SOL liquidity.

## An Example Swap Flow

When a user swaps `amount_in` LST A for `amount_out` LST B via the Router:

<figure><img src="/files/zIomB6Jx7mfzKPUizXYR" alt=""><figcaption></figcaption></figure>

## Fees

* No fees on `StakeWrappedSol`
* 1bps on `WithdrawWrappedSol`&#x20;
* 10bps on `DepositStake` unless output mint is SOL (via The Reserve) in which case there are no fees

## Security

The Router program is a simple CPI wrapper program that is integrated into Jupiter. Its main purpose is to glue stake pool operations together so that they involve only SPL token inputs and outputs so that it can be treated as an AMM on Jupiter. As such, there is no value at risk.


---

# 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://learn.sanctum.so/docs/technical-documentation/router.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.
