2 min read
Add as a preferred source on Google

OpenZeppelin Details USDT Vault Workaround for TRON Developers

The tutorial covers a TRC-4626 vault with local-node tests and a deployment to TRON’s Nile testnet. Its sample fee contract has not been audited.

Mentioned assets
A plain metal token rests beside an open vault hatch / TokenPost.ai
A plain metal token rests beside an open vault hatch / TokenPost.ai

OpenZeppelin’s documentation includes a tutorial for developers building a TRON vault that accepts Tether (USDT) and issues vUSDT shares. It addresses a payout problem in which USDT can move successfully even though its transfer function returns false to the calling contract.

The walkthrough uses TRC-4626, a vault pattern that represents deposits as shares and returns the underlying asset when users redeem them. Depositors send USDT to the vault and receive vUSDT in return. The example also directs entry and exit fees to a treasury.

The transfer behavior matters when a vault relies on a token’s return value to determine whether a payout succeeded. The tutorial routes withdrawals through SafeTRC20.safeTransferChecked, which checks the change in the vault’s balance instead. Deposits use transferFrom, which behaves normally for USDT on TRON.

An earlier TRC-4626 implementation in OpenZeppelin’s TRON library let users deposit USDT and receive shares, but withdrawals and redemptions reverted. The earlier payout issue was a high-severity bug.

The sample uses six decimal places for USDT. In one example, a 10 USDT deposit produces 9.950248 vUSDT after a 0.5% entry fee; the sample fee contract limits entry and exit fees to 5% each.

The tutorial includes tests on a local TRON node and a deployment to Nile, TRON’s testnet. It also labels the sample TRC4626Fees contract as unaudited, and the deployment described is for a test network.

The walkthrough builds on OpenZeppelin’s expansion of its smart-contract tools to TRON, announced Sept. 24. The tutorial applies those tools to a specific token and vault pattern.

Simon Yoon

Reporter

Simon Yoon reports on blockchain technology for TokenPost. Send corrections or tips to info@tokenpost.com.

Loading…