Conversation
|
Note
|
| Layer / File(s) | Summary |
|---|---|
Dependency Setup and Wiring .gitmodules, lib/tron-contracts, remappings.txt |
Registers OpenZeppelin's tron-contracts library as a Git submodule, updates broadcaster submodule URL, and adds Solidity remappings to resolve tron-contracts/ imports from lib/tron-contracts/contracts/. |
TRON Escrow Settlement Implementation src/input/escrow/InputSettlerEscrowTron.sol |
Implements InputSettlerEscrowTron that overrides _resolveLock to handle USDT transfers via SafeTRC20.safeTransferUSDT (which ignores USDT's false return) while routing other tokens through standard SafeTRC20.safeTransfer. Preserves base order-status guard logic for reentrancy safety. |
Test Infrastructure and USDT Validation test/mocks/MockUSDT.sol, test/input/escrow/InputSettlerEscrowTron.t.sol |
Adds MockUSDT mock that executes transfers but returns false to simulate TRON USDT behavior. Includes harness contracts exposing _resolveLock for testing and a test suite validating that base escrow reverts on USDT, TRON escrow successfully settles USDT, and TRON escrow correctly handles regular tokens. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested reviewers
- pepebndc
- frangio
- reednaa
Poem
🐰 On TRON where transfers misbehave,
A special settler comes to save!
With USDT returning false on success,
SafeTRC20 clears the mess.
Hopping safely through each payout! 🌟
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The pull request title clearly and accurately summarizes the main change: adding InputSettlerEscrowTron, a TRON-specific escrow contract for handling USDT payouts. |
| Description check | ✅ Passed | The description comprehensively explains the problem, solution, dependency, and tests; however, the 'Related Issues' section required by the template is missing. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
tron-usdt
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
reednaa
left a comment
There was a problem hiding this comment.
My personal preference for this implementation is to add a virtual _transfer function to the base contract and then overwrite that here with if (token == USDT) ...
Additionally, Permit2 should also be overwritten.
Problem
TRON USDT (
TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t) returnsfalsefromtransfereven on a successful transfer (while reverting on real failure — verified on mainnet).InputSettlerEscrowpays out escrowed inputs with OpenZeppelin'sSafeERC20.safeTransfer, which reads thatfalseas a failure and reverts — locking USDT in the escrow on finalisation/refund.The inbound
transferFromused onopenis unaffected: USDT'stransferFromcorrectly returnstrue.Change
InputSettlerEscrowTron— a TRON-specificInputSettlerEscrowthat:address(0)disables the special path);SafeTRC20, routing the configured USDT throughSafeTRC20.safeTransferUSDT(which ignores the boolean and verifies the transfer by the recipient's balance delta) and every other token through the regularSafeTRC20.safeTransfer.Only
_resolveLock(used by both finalisation and refunds) is overridden; the reentry guard is preserved.Dependency
SafeTRC20is imported from OpenZeppelin's tron-contracts, added as a git submodule pinned to the commit that introducessafeTransferUSDT(OpenZeppelin/tron-contracts@ae352da, OpenZeppelin/tron-contracts#88). Once that PR merges, the submodule should be repointed to tron-contractsmaster.Tests
InputSettlerEscrowTron.t.sol(with aMockUSDTthat transfers but returnsfalse): the base escrow reverts on USDT, the Tron variant pays out USDT despite the false return, and regular tokens still settle through the standard path.Summary by CodeRabbit
Release Notes
New Features
Tests
Chores