Staked TRX

Introduction

Based on Stake 2.0, with TRX Liquid Staking, users can stake TRX to get sTRX tokens and gain high rewards. Compared to traditional staking, TRX Liquid Staking is easier to use and more profitable. Staked TRX will be used automatically for voting and governance, and gain rewards via Energy Rental. The contract StakedTRX used to set up the staked TRX service.

Solidity API

Query Interface

Exchange rate

Query the exchange rate between sTRX and TRX.

function exchangeRate() public view returns (uint256)

Parameter description: None

Returns: Exchange rate, 1 sTRX / 1 TRX exchange rate, scaled by 1e18.


Total TRX assets

Query the total TRX assets managed by contract.

function totalUnderlying() public view returns (uint256)

Parameter description: None

Returns: The total assets of TRX managed by contract, the minimum unit.


User balance in TRX

Query the amount of TRX corresponding to the sTRX held by user

function balanceInTrx(address _account) public view returns (uint256)

Parameter description:

ParameterTypeDescription

_account

address

User address

Returns: The amount of TRX corresponding to the sTRX held by user, the minimum unit.

Write Interface

Deposit TRX

Deposit TRX assets and receive sTRX.

function deposit() external payable returns (uint256)

Parameter description:

ParameterTypeDescription

msg.value

The amount of TRX to deposit

Returns: The amount of sTRX received by user through exchange, the minimum unit.


Withdraw sTRX

specify the amount of sTRX to withdraw, the minimum unit.

function withdraw(uint256 tokenAmount) external returns (uint256)

Parameter description:

ParameterTypeDescription

tokenAmount

uint256

The amount of sTRX to withdraw

Returns: The amount of TRX to be unfrozen when user withdraws, the minimum unit.


Withdraw sTRX (with the amount of TRX specified)

specify the amount of TRX user hopes to obtain through withdrawal, the minimum unit.

function withdrawExact(uint256 trxAmount) external returns (uint256)

Parameter description:

ParameterTypeDescription

tokenAmount

uint256

The amount of sTRX to withdraw

Returns: The amount of sTRX withdrawn by user, the minimum unit.


Claim TRX

Claim the ready-to-be-withdrawn TRX unfrozen in the earliest round.

function claim() external returns (uint256)

Parameter description: None

Returns: The amount of TRX claimed by user in the earliest unfreezing round, the minimum unit.


Claim all unfrozen TRX

Claim all ready-to-be-withdrawn, unfrozen TRX

function claimAll() external returns (uint256)

Parameter description: None

Returns: The amount of TRX claimed by the user for all expired unfreezing rounds, the minimum unit.

Key Events

EventDescription

Deposit(address user, uint256 trxAmount, uint256 strx, uint256 userHoldStrx)

Emits when user successfully deposits TRX

  • trxAmount: the amount of TRX user deposits

  • strx : the amount of sTRX user gets

  • userHoldStrx: the total amount of sTRX held by user after the deposit

Withdraw(address user, uint256 strx, uint256 trxAmount, uint256 userHoldStrx)

Emits when user successfully withdraws sTRX

  • strx : the amount of sTRX user withdraws

  • trxAmount: the amount of TRX user gets

  • userHoldStrx: the total amount of sTRX held by user after the withdrawal

Claim(address user, uint256 trxAmount)

Emits when user successfully claims TRX

  • trxAmount: the amount of TRX user claims

Last updated