# Technical documentation

### Liquid Delegation Implementation

#### Overview

Liquid Delegation Tokens (LDTs) are elastic supply ERC-20 tokens that represent staked positions with specific validators. They implement both standard ERC-20 functionality and EIP-2612 for permits, with additional features for handling staking rewards and slashing events.

***

### Core Functions

**Staking**&#x20;

```solidity
function deposit(address receiver, uint256 assets) external returns (uint256)
```

* **Purpose:** Deposits assets and mints tTokens.
* **Returns:** Amount of tTokens minted.
* **Additional Details:** Triggers a rebase before the operation.

**Unstaking**&#x20;

```solidity
unlock(uint256 assets) external returns (uint256 unlockID)
```

* **Purpose:** Initiates the unstaking process.
* **Details:**
  * Burns tTokens.
  * Creates an unlock position.
* **Returns:** Unique unlock identifier.

**Withdraw**

```solidity
withdraw(address receiver, uint256 unlockID) external returns (uint256 amount)
```

* **Purpose:** Completes the unstaking process.
* **Details:**
  * Transfers underlying assets to the specified receiver.
  * Requires the unlock position to mature.

**Conversion Functions**

```solidity
convertToAssets(uint256 shares) public view returns (uint256)
function convertToShares(uint256 assets) public view returns (uint256)
```

* **Purpose:** Handle conversion between shares (tTokens) and assets (underlying tokens).
* **Details:** Accounts for changes in the elastic supply.

***

### Integration Guide **For DeFi Protocols**

**Token Implementation**

* Implements the standard ERC-20 interface.
* Includes an additional rebase mechanism.
* Use `convertToAssets()` for accurate balance calculations.

**Handling Rebases**

* Rebases occur automatically before token transfers.
* External calls should account for supply changes.
* Monitor `Rebase` events for updates to supply.

**Safety Considerations**

* Always check return values for all operations.
* Account for potential slashing events that may affect balances.
* Handle failed operations gracefully to ensure robust integrations.


---

# 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.tenderize.me/staking/technical-documentation.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.
