> For the complete documentation index, see [llms.txt](https://docs.satlayer.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.satlayer.xyz/bvs-developers-1/staking-and-delegation.md).

# Staking and Delegation

{% hint style="info" %}
Please view the docs for how to use [leap wallet](/bvs-developers-1/developer-toolbox/wallet-guide.md).
{% endhint %}

### Common User Flows

This document provides several diagrams to help users and BVS developers understand SatLayer core contracts' common user workflow.

#### Deposit Into SatLayer

<figure><img src="https://956158124-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM4kTGNZNYF9sQa92jm8x%2Fuploads%2FM3hloG241cQG6D7DlFlJ%2Fa.png?alt=media&amp;token=3ba11bd6-6379-49b5-9f02-57c88511660c" alt=""><figcaption><p>Deposit CW20 Tokens</p></figcaption></figure>

#### Delegate to an Operator

<figure><img src="https://956158124-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM4kTGNZNYF9sQa92jm8x%2Fuploads%2F0K2487fabX1TsFQ929V7%2Fb.png?alt=media&amp;token=399fd444-01a6-445c-a446-8ca6d3788463" alt=""><figcaption><p><em>Delegate to an Operator</em></p></figcaption></figure>

#### Undelegating or Queueing a Withdrawal

Undelegating from an Operator automatically queues a withdrawal that needs to go through the DelegationManager's withdrawal delay. Stakers that want to withdraw can choose to undelegate, or can simply call queueWithdrawals directly.

<figure><img src="https://956158124-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM4kTGNZNYF9sQa92jm8x%2Fuploads%2FG8Rl1RDLJGSvLnJ9OXLE%2Fc.png?alt=media&amp;token=5e0b59ab-0642-45e8-a35e-80733ef939c8" alt=""><figcaption><p><em>Undelegating or Queueing a Withdrawal</em></p></figcaption></figure>

#### Completing a Withdrawal as Shares

This flow is mostly useful if a Staker wants to change which Operator they are delegated to. The Staker first needs to undelegate (see above). At this point, they can delegate to a different Operator. However, the new Operator will only be awarded shares once the Staker completes their queued withdrawal as `shares`:

<figure><img src="https://956158124-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM4kTGNZNYF9sQa92jm8x%2Fuploads%2FFtRxpsj71SBW8kcWZHUM%2Fd.png?alt=media&amp;token=1c2b22e9-aa2c-487b-a586-1c1467152522" alt=""><figcaption><p><em>Completing a Withdrawal as Shares</em></p></figcaption></figure>

#### Completing a Withdrawal as Tokens

<figure><img src="https://956158124-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM4kTGNZNYF9sQa92jm8x%2Fuploads%2FWm2rdnx27tjoPyt93O3S%2Fe.png?alt=media&amp;token=173160af-bd7f-44a4-b022-5f69a4cb3baa" alt=""><figcaption><p><em>Completing a Withdrawal as Tokens</em></p></figcaption></figure>

### Contracts Introduction

#### DelegationManager

[**DelegationManager**](https://github.com/satlayer/devnet-satlayer-core/tree/main/contracts/delegation-manager) is responsible for managing the delegation relationship between users and operators. Users can register as operators, delegate tokens, undelegate, and request and receive withdrawals. The Delegation Manager ensures the secure and efficient flow of tokens by controlling and recording delegation operations.

#### RewardsCoordinator

[**RewardCoordinator**](https://github.com/satlayer/devnet-satlayer-core/tree/main/contracts/rewards-coordinator) is responsible for ensuring the correct distribution of rewards. It coordinates the process of uploading, calculating, distributing, and claiming rewards through the following steps:

* BVS program uploads rewards
* Off-chain calculation logic
* Upload reward distribution (via reward Merkle tree)
* Users claim rewards

#### Strategy

Strategy consists of [**StrategyManager**](https://github.com/satlayer/devnet-satlayer-core/tree/main/contracts/strategy-manager), [**StrategyFactory**](https://github.com/satlayer/devnet-satlayer-core/tree/main/contracts/strategy-factory), [**StrategyBase**](https://github.com/satlayer/devnet-satlayer-core/tree/main/contracts/strategy-base) and [**StrategyBaseTVLLimits**](https://github.com/satlayer/devnet-satlayer-core/tree/main/contracts/strategy-base-TVLLimits).

Strategy Manager is responsible for managing the deposit and withdrawal of tokens, as well as allocating tokens to specific strategies and operators. It acts as a bridge between liquidity providers and operators within the system.

Strategy Manager manages the flow of tokens through a series of functions. Users can obtain corresponding shares by depositing tokens and allocate these shares to specific strategies and operators. Additionally, users can convert shares back into tokens through withdrawal operations. Strict permission controls ensure the security and stability of the system.

Any CW20-compatible token can be supported by deploying a `StrategyBaseTVLLimits` instance from the `StrategyFactory`. The `StrategyFactory` only allows a strategy to be deployed once per token, and automatically whitelists newly-deployed strategies.

Each supported token has its own instance of `StrategyBaseTVLLimits`, has two main functions (deposit and withdraw), both of which can only be called by the StrategyManager. These `StrategyBaseTVLLimits` contracts are fairly simple deposit/withdraw contracts that hold tokens deposited by Stakers.
