Skip to content

revert(tokenization): restore additive (on-top) protocol fee#100

Merged
trevormil merged 2 commits into
masterfrom
revert/inclusive-protocol-fee
May 23, 2026
Merged

revert(tokenization): restore additive (on-top) protocol fee#100
trevormil merged 2 commits into
masterfrom
revert/inclusive-protocol-fee

Conversation

@trevormil
Copy link
Copy Markdown
Collaborator

Summary

Reverts PR #80 (e3d62474, feat(tokenization): inclusive protocol fees (#0335)), restoring the original additive / on-top protocol fee method.

About three weeks ago we converted the 0.1% protocol fee from additive to inclusive (deducted out of the transfer amount). This caused problems — most visibly, recipients/escrows received only 99.9% of the quoted amount, breaking 1:1 redeem math (e.g. prediction-market escrows came up short on full-balance redeems).

This restores the pre-#80 behavior:

  • Payer is charged amount + 0.1%; the recipient receives the full quoted amount.
  • Protocol fee is computed post-hoc via the restored CalculateAndDistributeProtocolFees and routed to the community pool.
  • ProtocolFeeDenominator is back to 1000 in transfer_utils.go; the inline sendProtocolFee helper and inclusive deduction in ExecuteCoinTransfers are removed.
  • The inclusive-fee test file (inclusive_protocol_fees_test.go, added in feat(tokenization): inclusive protocol fees (#0335) #80) is removed; pre-feat(tokenization): inclusive protocol fees (#0335) #80 tests are restored.

This is a clean git revert of #80 with no conflicts.

Relationship to PR #99

PR #99 (chore/disable-protocol-fee-local) takes a different tack — it sets ProtocolFeeDenominator = 0 to disable the fee entirely (no protocol revenue) as a local/e2e workaround. This PR instead restores the original revenue-preserving additive method, which is the literal "old method" and also fixes the escrow shortfall (recipients get the full amount again). These two are mutually exclusive approaches to the same problem — picking this one supersedes #99.

Test plan

  • go build -tags=test ./... passes
  • go test -tags=test ./x/tokenization/keeper/... passes (104s)
  • Confirm prediction-market escrow 1:1 redeem flow works end-to-end with additive fee restored

🤖 Generated with Claude Code

trevormil and others added 2 commits May 23, 2026 10:27
…ro fees

The pre-#80 fee coverage in approved_transfers_test.go only transferred 100
ubadge, where 0.1% rounds down to 0 — so the protocol fee was effectively
never exercised. This adds dedicated coverage against the restored additive
method: payer charged amount+fee, recipient gets the full amount, fee lands in
the community pool, multi-transfer per-denom aggregation, and rounds-to-zero.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@trevormil
Copy link
Copy Markdown
Collaborator Author

Added a dedicated additive protocol-fee test suite (x/tokenization/keeper/protocol_fees_test.go).

Context: the pre-#80 fee coverage in approved_transfers_test.go only transferred 100 ubadge, where 0.1% rounds down to 0 — so the fee was never actually exercised with a non-zero value. The new suite asserts all three sides against the restored additive method:

  • TestProtocolFeeChargedOnTopOfTransfer — payer debited amount + 0.1%, recipient gets the full amount, community pool receives the fee.
  • TestProtocolFeeAggregatesAcrossTransfers — fee computed on the summed per-denom total across multiple coin transfers.
  • TestProtocolFeeRoundsToZeroForSmallTransfers — amounts below the denominator pay no fee; community pool unchanged.

All pass under go test -tags=test ./x/tokenization/keeper/... (full suite green, 106s).

@trevormil trevormil merged commit 94cc65b into master May 23, 2026
6 checks passed
@trevormil trevormil deleted the revert/inclusive-protocol-fee branch May 23, 2026 17:47
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