Conversation
Tron's canonical USDT (compiled ~0.4.x) declares transfer() returns (bool) but never executes return true, causing SafeTransferLib to revert on every outbound transfer. This PR introduces a targeted bypass in LibAsset for chain ID 728126428 + address 0xa614f803... only, leaving all other tokens and chains on the standard safeTransfer path. All ERC20 transfers in GenericSwapFacetV3, WithdrawablePeriphery, and LiFiDEXAggregator are now routed through LibAsset so the bypass takes effect everywhere. WithdrawablePeriphery also gains a ZeroAmount guard. Rules updated with versioning and test-naming conventions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use GITHUB_TOKEN as fallback when GIT_ACTIONS_BOT_PAT_CLASSIC is not configured (avoids interactive device-flow login in CI) - Extend version regex to match <X.Y.Z-tron> suffixed versions used in this fork Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…erence and improve token handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which Linear task belongs to this PR?
https://linear.app/lifi-linear/issue/EXSC-241/fix-tron-usdt-transfers-failing-on-safetransferlib-return-data-check
Why did I implement it this way?
Problem
Tron's canonical USDT contract
(
TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t/0xa614f803B6FD780986A42c78Ec9c7f77e6DeD13C)was compiled with an older Solidity version (~0.4.x).
Although its
transfer()function is declared asreturns (bool), it does not explicitly returntrue. As a result:The transfer executes successfully and balances update correctly.
However, the return data contains 32 zero bytes (
false) instead of:true(standard ERC20 behavior).This creates incompatibility with
SafeTransferLib.safeTransfer, which enforces strict return validation:Accepts:
returndatasize() == 0, or1Rejects:
0→ reverts withTransferFailedImpact:
All outbound
transfer()calls to Tron USDT reverted inside our contracts (viaLibAsset.transferERC20→SafeTransferLib.safeTransfer), even though the transfer itself succeeded.Important:
transferFrom()is not affected — Tron USDT correctly returnstrue.Inbound flows using
transferFrom()remain safe.Solution
A targeted exception was introduced in
LibAsset.transferERC20:Detect:
chainId = 728126428)In this specific case:
IERC20.transfer()callSafeTransferLibreturn-data validationStill:
All other tokens and chains continue to use
SafeTransferLib.safeTransferunchanged.What Was Done
Core Fix
src/Libraries/LibAsset.sol(v2.1.3-tron)TRON_CHAIN_IDandTRON_USDTconstantstransferERC20to apply the bypass only for Tron USDTContract Updates
src/Facets/GenericSwapFacetV3.sol(v1.0.2-tron)Migrated ERC20 transfer calls to
LibAsset.transferERC20andLibAsset.maxApproveERC20:safeApprove(0)→safeApprove(max)LibAsset.maxApproveERC20Ensures the Tron USDT fix is applied consistently across all swap paths
Allowlist logic unchanged
src/Helpers/WithdrawablePeriphery.sol(v1.0.0-tron)Two changes:
if (amount == 0) revert ZeroAmount()ExternalCallFailedETHTransferFailedon native transfer failuresrc/Periphery/LiFiDEXAggregator.sol(v1.12.0-tron)Migrated all ERC20
transfer/transferFromcalls to:LibAsset.transferERC20LibAsset.transferFromERC20Versioning (tron fork overlay)
LibAsset2.1.32.1.3-tronGenericSwapFacetV31.0.21.0.2-tronWithdrawablePeriphery1.0.01.0.0-tronLiFiDEXAggregator1.12.01.12.0-tronTests & Tooling
Added
MockTronUSDTcontract reproducing the faulty return behavior (transfer()returnsfalse)Added Tron-specific
LibAssettest suite:SafeTransferLibUpdated multiple receiver test files due to error selector changes
Added/updated internal guidelines:
.agents/rules/100-solidity-basics.mdc.agents/rules/400-solidity-tests.mdcContracts Not Modified
src/Periphery/TokenWrapper.solsrc/Periphery/LidoWrapper.solReceiver Contracts
ReceiverAcrossV3.solReceiverChainflip.solReceiverStargateV2.solNot modified because:
Note:
If deployed on Tron in the future:
transfer()must route throughLibAsset.transferERC20transferFrom()usage remains safe (returnstrueon Tron USDT)Checklist before requesting a review
Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)