chore: charge one cent to send USDC - #1412
Conversation
Time Submission Status
Submit or update total time with: Add time on top of previous submission with: See available commands to help comply with our Guidelines. |
📝 WalkthroughWalkthroughThe ERC20 bridge transfer actions now charge 0.01 USDC and 0.01 TT2. Error messages and fee documentation were updated. Hoodi TT2 tests cover deductions, balances, exact-spend transfers, and insufficient-balance errors. ChangesERC20 transfer fee updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
@holdex pr submit-time 3h |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/migrations/erc20-bridge/002-public-transfer-actions.prod.sql`:
- Line 79: Update the fee comment in the migration around the ERC-20 transfer
configuration to describe 10^4 USDC as token base units rather than wei, while
preserving the existing fee value and decimal explanation.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f8b06d84-b650-40e0-8b4e-d74775d7633b
📒 Files selected for processing (4)
internal/migrations/erc20-bridge/002-public-transfer-actions.prod.sqlinternal/migrations/erc20-bridge/002-public-transfer-actions.sqltests/extensions/erc20/erc20_bridge_transfer_actions_test.gotests/streams/transaction_events_ledger_test.go
resolves: https://github.com/trufnetwork/truf-network/issues/1394
What changes
eth_usdc_transfercharges 0.01 USDC instead of 1 USDC, and its testnet counterparthoodi_tt2_transfercharges 0.01 TT2 instead of 1 TT2. That is the figure Vin settled on afterrevising his first suggestion of a tenth of a cent upward:
A dollar to move USDC is the larger half of most transfers anyone actually makes with it. A cent
still makes spamming the action pointless, which is the reason the fee exists at all.
The two files carry different literals for the same cent. USDC has 6 decimals, so a cent is 10^4.
TT2 stands in for USDC on testnet but is an 18-decimal token, so there it is 10^16. The
insufficient-balance messages move from
Requires an extra 1 USDC feetoRequires an extra 0.01 USDC fee, and likewise for TT2.TRUF transfers are untouched:
eth_truf_transfer,ethereum_transfer,sepolia_transferandhoodi_tt_transferall still charge 1 TRUF.002-public-transfer-actions.prod.sqlis a hand-written override rather than one ofgenerate_prod_migrations.py's targets, so both files are edited in place. Both passkwil-cli utils parse.Tests
hoodi_tt2_transferhad no test at all, soTestHoodiTT2TransferFeeis new. It pins the feethrough arithmetic rather than by reading the constant back:
Requires an extra 0.01 TT2 feePutting the 1 TT2 fee back fails the first assertion (
expected: "990000000000000000",actual: "0"), so the test is wired to the number it claims to guard.Run and passing: all 8 tests in
erc20_bridge_transfer_actions_test.go, which covers the fourTRUF transfer actions this leaves alone.
Rollout notes
erc20-bridge/002-public-transfer-actions.prod.sqlwithkwil-cli exec-sql,after
000-extension.prod.sqlsoeth_usdcexists. It isCREATE OR REPLACE ACTIONon twoactions, so no fleet upgrade and no restart.
*.sqlup on the nextscripts/migrate.shrun.in total as of 2026-07-29, from three USDC-holding wallets.
bridgethe action stamps into the event metadatarather than by the amount, so a 10^4 fee still charts as USDC. Its amount-based fallback
(a method-4 fee of exactly 1e6 means USDC) applies only to rows written before the node started
stamping, and those keep their old amounts. Two comments in
indexer/types/fee_types.godescribe the 1 USDC fee in the present tense and go stale with this.
sdk-go/docs/api-reference.md:2859,sdk-js/src/client/client.ts:375andsrc/contracts-api/action.ts:1217,sdk-py/src/trufnetwork_sdk_py/client.py:3267. Each alsotells the caller the action reverts below
amount + 1 token. Separate repos, separate PRs.Summary by CodeRabbit