> For the complete documentation index, see [llms.txt](https://docs.tenderize.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tenderize.me/staking/technical-documentation.md).

# Technical documentation

Technical documentation for TenderTokens

### 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.
