Skip to content

chore: charge one cent to send USDC - #1412

Merged
MicBun merged 2 commits into
mainfrom
chore/usdc-transfer-cent-fee
Aug 4, 2026
Merged

chore: charge one cent to send USDC#1412
MicBun merged 2 commits into
mainfrom
chore/usdc-transfer-cent-fee

Conversation

@MicBun

@MicBun MicBun commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

resolves: https://github.com/trufnetwork/truf-network/issues/1394

What changes

eth_usdc_transfer charges 0.01 USDC instead of 1 USDC, and its testnet counterpart
hoodi_tt2_transfer charges 0.01 TT2 instead of 1 TT2. That is the figure Vin settled on after
revising his first suggestion of a tenth of a cent upward:

log: changed the fee amount for USDC (and TT2) to one cent. We don't want to incentivize
micropayments.

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.

$fee := 10000::NUMERIC(78, 0); -- 0.01 USDC with 6 decimals

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 fee to Requires an extra 0.01 USDC fee, and likewise for TT2.

TRUF transfers are untouched: eth_truf_transfer, ethereum_transfer, sepolia_transfer and
hoodi_tt_transfer all still charge 1 TRUF.

002-public-transfer-actions.prod.sql is a hand-written override rather than one of
generate_prod_migrations.py's targets, so both files are edited in place. Both pass
kwil-cli utils parse.

Tests

hoodi_tt2_transfer had no test at all, so TestHoodiTT2TransferFee is new. It pins the fee
through arithmetic rather than by reading the constant back:

  • 1.0 sent out of a 2.0 balance has to leave exactly 0.99, so any other fee fails there
  • the recipient receives 1.0 and never the fee
  • 0.99 sent out of a 1.0 balance succeeds and leaves 0, which the whole-token fee rejected outright
  • an empty wallet's shortfall message has to name Requires an extra 0.01 TT2 fee

Putting 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 four
TRUF transfer actions this leaves alone.

Rollout notes

  1. Mainnet: apply erc20-bridge/002-public-transfer-actions.prod.sql with kwil-cli exec-sql,
    after 000-extension.prod.sql so eth_usdc exists. It is CREATE OR REPLACE ACTION on two
    actions, so no fleet upgrade and no restart.
  2. Testnet picks the dev *.sql up on the next scripts/migrate.sh run.
  3. Nobody can be newly blocked, because the fee only goes down. Mainnet had seen 7 USDC transfers
    in total as of 2026-07-29, from three USDC-holding wallets.
  4. The indexer classifies these rows by the bridge the action stamps into the event metadata
    rather 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.go
    describe the 1 USDC fee in the present tense and go stale with this.
  5. All three SDKs document a one-token fee on every bridge, which becomes wrong for USDC —
    sdk-go/docs/api-reference.md:2859, sdk-js/src/client/client.ts:375 and
    src/contracts-api/action.ts:1217, sdk-py/src/trufnetwork_sdk_py/client.py:3267. Each also
    tells the caller the action reverts below amount + 1 token. Separate repos, separate PRs.

Summary by CodeRabbit

  • New Features
    • Reduced USDC and TT2 bridge transfer fees to 0.01 tokens.
    • Updated insufficient-balance messages to reflect the new fee amounts.
  • Bug Fixes
    • Clarified fee denominations across bridge transfer and ledger information.
  • Tests
    • Added coverage verifying TT2 fees, balance deductions, recipient amounts, exact-spend transfers, and insufficient-balance handling.

@holdex

holdex Bot commented Aug 4, 2026

Copy link
Copy Markdown

Time Submission Status

Member # Time Running Total Status Last Update
MicBun 3h ✅ Submitted Aug 4, 2026, 11:59 AM

Submit or update total time with:

@holdex pr submit-time 2h

Add time on top of previous submission with:

@holdex pr add-time 1h30m

See available commands to help comply with our Guidelines.

@MicBun MicBun self-assigned this Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

ERC20 transfer fee updates

Layer / File(s) Summary
Update bridge transfer fees
internal/migrations/erc20-bridge/002-public-transfer-actions*.sql
The transfer actions now charge 0.01 USDC and 0.01 TT2 in token base units. Insufficient-balance messages use the updated amounts.
Validate fees and ledger descriptions
tests/extensions/erc20/erc20_bridge_transfer_actions_test.go, tests/streams/transaction_events_ledger_test.go
Hoodi TT2 tests validate fee deductions, recipient balances, exact spending, wallet balances, and insufficient-balance errors. Ledger documentation distinguishes the 1 TRUF fee from the 0.01 USDC fee.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: type: chore

Suggested reviewers: pr-time-tracker, outerlook

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The Hoodi TT2 fee changes and tests are not required by linked issue #1394, which only covers USDC transfers. Move the Hoodi TT2 changes to a separate issue or link an issue that explicitly requires the TT2 fee change.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The USDC fee changes implement issue #1394 by applying a 0.01 USDC fee to reduce spam and denial-of-service risk.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the USDC fee change, which is a primary part of the pull request, but it does not mention the related TT2 fee change.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/usdc-transfer-cent-fee

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MicBun

MicBun commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@holdex pr submit-time 3h

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9f04efc and fe11086.

📒 Files selected for processing (4)
  • internal/migrations/erc20-bridge/002-public-transfer-actions.prod.sql
  • internal/migrations/erc20-bridge/002-public-transfer-actions.sql
  • tests/extensions/erc20/erc20_bridge_transfer_actions_test.go
  • tests/streams/transaction_events_ledger_test.go

Comment thread internal/migrations/erc20-bridge/002-public-transfer-actions.prod.sql Outdated
@MicBun MicBun changed the title chore: charge one cent to send USDC instead of a dollar chore: charge one cent to send USDC Aug 4, 2026
@MicBun
MicBun merged commit d53a40f into main Aug 4, 2026
8 checks passed
@MicBun
MicBun deleted the chore/usdc-transfer-cent-fee branch August 4, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant