🔧Technical documentation

Technical documentation for TenderTokens

tToken Implementation

Overview

tTokens 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

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

unlock(uint256 assets) external returns (uint256 unlockID)
  • Purpose: Initiates the unstaking process.

  • Details:

    • Burns tTokens.

    • Creates an unlock position.

  • Returns: Unique unlock identifier.

Withdraw

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

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.

Last updated