Staking
Last updated
Last updated
The Staking contract handles user staking, unstaking, and reward distribution. Its workflow is as follows:
Users stake tgUSD into the Staking contract.
Based on the current conversion rate between tgUSD and stgUSD, the contract mints the corresponding amount of stgUSD to the user.
stgUSD represents the userโs share in the pool and appreciates in value over time as rewards are distributed.
Users burn their stgUSD to receive the corresponding amount of tgUSD, which includes both principal and accumulated rewards.
Upon receiving the burn notification, the staking contract deploys a dedicated Unstake Account to track the request.
A 7-day cooldown period is required before the tgUSD can be claimed.
If the user initiates another unstake during the cooldown period, the amount is aggregated and the cooldown timer resets.
Yield is distributed to the Staking contract every 7 days.
If rewards are earned on external chains, USDT is bridged back to TON via Stargate or USDT0. If rewards are already on TON, no bridging is required.
The accumulated rewards (USDT) are then sent to the Engine contract, which mints tgUSD and transfers it to the Staking contract as staking rewards.
Upon receiving the rewards, the Staking contract initiates a 7-day linear vesting period, during which the value of stgUSD gradually increases as the rewards accrue.
The cooldown provides the protocol with sufficient time to return tgUSD to the Staking contract.
In the event of a price deviation in the tgUSD/USDT pool, the protocol may temporarily use tgUSD from the Staking contract to perform arbitrage. Once arbitrage is complete, the USDT profit is converted into tgUSD and used to repay what was borrowed from the Staking contract.