wstTBY

Overview

The WstTBY contract is a standard ERC20 contract that represents a wrapped version of the StTBY token. This wrapping mechanism allows users to convert their stTBY tokens into wstTBY tokens and vice versa. The conversion rates between stTBY and wstTBY are determined by specific methods provided by the StTBY contract.

Contract Details

State Variables

  • stTBY: This is a public variable of type IStTBY which points to the StTBY contract address.

Constructor

  • The constructor accepts an address _stTBY as a parameter which sets the stTBY state variable. It also initializes the name and symbol for the wrapped token as "Wrapped staked TBY" and "wstTBY" respectively.

Public and External Functions

  1. wrap

    • Input: _stTBYAmount of type uint256

    • Output: uint256 representing the amount of wstTBY the user receives after the wrap.

    • This function allows users to convert their stTBY tokens into wstTBY tokens.

    • There are a few requirements:

      • _stTBYAmount must be non-zero.

      • Caller (msg.sender) must approve at least _stTBYAmount stTBY to the WstTBY contract.

      • Caller must possess at least _stTBYAmount of stTBY.

    • The amount of wstTBY returned is determined by the getSharesByUsd method of the stTBY contract.

  2. unwrap

    • Input: _wstTBYAmount of type uint256

    • Output: uint256 representing the amount of stTBY the user receives after the unwrap.

    • This function allows users to convert their wstTBY tokens back into stTBY tokens.

    • Requirements:

      • _wstTBYAmount must be non-zero.

      • Caller (msg.sender) must have at least _wstTBYAmount wstTBY.

    • The amount of stTBY returned is determined by the getUsdByShares method of the stTBY contract.

  3. getWstTBYByStTBY

    • Input: _stTBYAmount of type uint256

    • Output: uint256 representing the equivalent wstTBY amount for the provided _stTBYAmount.

    • This function provides the conversion rate from stTBY to wstTBY.

  4. getStTBYByWstTBY

    • Input: _wstTBYAmount of type uint256

    • Output: uint256 representing the equivalent stTBY amount for the provided _wstTBYAmount.

    • This function provides the conversion rate from wstTBY to stTBY.

  5. stTBYPerToken

    • Output: uint256 representing the amount of stTBY for 1 wstTBY.

    • This function provides the conversion rate from 1 wstTBY to its stTBY equivalent.

  6. tokensPerStTby

    • Output: uint256 representing the amount of wstTBY for 1 stTBY.

    • This function provides the conversion rate from 1 stTBY to its wstTBY equivalent.

Last updated