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 typeIStTBY
which points to theStTBY
contract address.
Constructor
The
constructor
accepts an address_stTBY
as a parameter which sets thestTBY
state variable. It also initializes the name and symbol for the wrapped token as "Wrapped staked TBY" and "wstTBY" respectively.
Public and External Functions
wrap
Input:
_stTBYAmount
of typeuint256
Output:
uint256
representing the amount ofwstTBY
the user receives after the wrap.This function allows users to convert their
stTBY
tokens intowstTBY
tokens.There are a few requirements:
_stTBYAmount
must be non-zero.Caller (
msg.sender
) must approve at least_stTBYAmount
stTBY
to theWstTBY
contract.Caller must possess at least
_stTBYAmount
ofstTBY
.
The amount of
wstTBY
returned is determined by thegetSharesByUsd
method of thestTBY
contract.
unwrap
Input:
_wstTBYAmount
of typeuint256
Output:
uint256
representing the amount ofstTBY
the user receives after the unwrap.This function allows users to convert their
wstTBY
tokens back intostTBY
tokens.Requirements:
_wstTBYAmount
must be non-zero.Caller (
msg.sender
) must have at least_wstTBYAmount
wstTBY
.
The amount of
stTBY
returned is determined by thegetUsdByShares
method of thestTBY
contract.
getWstTBYByStTBY
Input:
_stTBYAmount
of typeuint256
Output:
uint256
representing the equivalentwstTBY
amount for the provided_stTBYAmount
.This function provides the conversion rate from
stTBY
towstTBY
.
getStTBYByWstTBY
Input:
_wstTBYAmount
of typeuint256
Output:
uint256
representing the equivalentstTBY
amount for the provided_wstTBYAmount
.This function provides the conversion rate from
wstTBY
tostTBY
.
stTBYPerToken
Output:
uint256
representing the amount ofstTBY
for 1wstTBY
.This function provides the conversion rate from 1
wstTBY
to itsstTBY
equivalent.
tokensPerStTby
Output:
uint256
representing the amount ofwstTBY
for 1stTBY
.This function provides the conversion rate from 1
stTBY
to itswstTBY
equivalent.
Last updated