# LST Architecture

Endur's liquid staking system employs a three-component architecture:

### **a) LST Contract (Main Contract)**

* Implementation: ERC-4626 vault contract
* Manages deposits and withdrawal requests
* Primary interface for users interacting with the system

### **b) Withdraw Queue Contract**

* Issues unique NFTs for withdrawal requests
* Each NFT represents:
  * Amount of STRK/BTC requested for withdrawal
  * Timestamp of request
  * Position in the queue
* Manages the orderly processing of withdrawals (first come, first serve)
* Fund settlement sources ([learn more here](https://docs.endur.fi/docs/concepts/deposit-withdraw-matching)):
  1. New deposits (prioritized for pending withdrawals)
  2. Unstaked funds from delegators

### **c) Delegator System**

* Multiple delegator contracts manage actual staking with Starknet
* The system acts as an intermediary between the LST system and Starknet's staking system
* It handles the actual staking operations.
* Here's how the fund flows:
  1. Excess funds from LST → Delegators -> stake STRK/BTC
  2. When withdrawing: Unstaked funds -> Withdraw Queue

### **d) Validator registry**

* Responsible for whitelisting validators, supported tokens and delegators
* Handles stake/unstake/restaking rewards

### **e) Swap Extension**

* Responsible for temporarily holding STRK rewards to swap to respective BTC tokens. Not applicable for xSTRK. Receives rewards from delegator, swaps and sends to Validator registry which can be re-staked again.&#x20;

### **Flow chart of interactions:**

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

#### Deposit Flow:

1. User deposits STRK/BTC to LST Contract
2. System checks withdrawal queue demands
3. Excess funds distributed to delegators
4. Delegators stake on Starknet

#### Withdrawal Flow:

1. User requests withdrawal
2. NFT issued to user
3. Protocol either:
   * Matches with available funds
   * OR initiates unstaking through delegators
4. Funds released according to queue position

This architecture ensures:

* Efficient capital utilisation
* Efficient unstaking time through multiple delegators
* Transparent withdrawal process as you can see in withdraw log
* Automated reward distribution
* Failsafe withdrawal mechanisms


---

# 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.endur.fi/docs/concepts/lst-architecture.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.
