Skip to content

Conversation

@grarco
Copy link
Collaborator

@grarco grarco commented Aug 14, 2025

Describe your changes

Adds support for an optional masp frontend providers sustainability fees. This fee is supported as both a transparent and a shielded transfer (with the exception of incoming shielding IBC packets). To support it the followings have been changed:

Shielding and (IBC) unshielding

The sdk has been extended to allow specifying the entry for this fee. This is an optional target and a percentage which will be applied to all inputs. The sdk adjusts the input amounts to account for this extra fee.

There's one limitation for the IBC unshielding case. If the transaction ultimately fails (rejected by the target chain or timed out) we refund the amount of the unshielding to a disposable address. The frontend fees are not part of this amount and do not get refunded: to support this we'd need to temporarily escrow those tokens to an internal address and finalize the fee payment only once the target chain has confirmed the transaction to be successful (this would require some protocol support and should probably be done in conjunction with #4726). On top of this, the unshielding refunds are done to a disposable transparent address from which the user might want to reshield the tokens: this would incur in another frontend fee event leading to multiple fees applied to the same overall action.

Incoming IBC shielding packets

The optional target and percentage of the fee can be passed to the gen_ibc_shielding_transfer function. Since IBC is limited to a single token, the asset is automatically inferred to be the same of the transfer and fees are not supported when shielding nfts. The fee amount itself will be encoded as an additional shielded output of the MASP bundle so that we can avoid the need for protocol-breaking changes.

Osmosis swaps

Osmosis swaps are ultimately collapsed to the above ibc cases and so the same rules apply. In case the swap was fully shielded the frontend provider should refrain from charging a fee since this should count as a fully shielded transaction.

Checklist before merging

  • If this PR has some consensus breaking changes, I added the corresponding breaking:: labels
    • This will require 2 reviewers to approve the changes
  • If this PR requires changes to the docs or specs, a corresponding PR is opened in the namada-docs repo
    • Relevant PR if applies:
  • If this PR affects services such as namada-indexer or namada-masp-indexer, a corresponding PR is opened in that repo
    • Relevant PR if applies:

@grarco grarco force-pushed the grarco/frontend-sus-fees branch 2 times, most recently from 82b94e5 to 4514cac Compare August 20, 2025 15:32
grarco added a commit that referenced this pull request Aug 21, 2025
@grarco grarco marked this pull request as ready for review August 21, 2025 16:41
@grarco grarco added enhancement New feature or request IBC MASP SDK breaking:consensus Consensus breaking change that requires a hard-fork breaking:SDK SDK breaking change labels Aug 21, 2025
@github-actions github-actions bot added the breaking:api public API breaking change label Aug 21, 2025
@grarco grarco changed the title Frontend MASP fee Frontend MASP sustainability fee Aug 21, 2025
@mergify
Copy link
Contributor

mergify bot commented Aug 21, 2025

🧪 CI Insights

Here's what we observed from your CI run for a13d611.

✅ Passed Jobs With Interesting Signals

Pipeline Job Signal Health on main Retries 🔍 CI Insights 📄 Logs
Lint 🧹 Build 🛠️ Test 🚦 test-e2e (2) Base branch is broken, but the job passed. Looks like this might be a real fix 💪 Broken 0 View View
test-e2e (3) Base branch is broken, but the job passed. Looks like this might be a real fix 💪 Broken 0 View View
test-integration Base branch is broken, but the job passed. Looks like this might be a real fix 💪 Broken 0 View View
test-unit Base branch is broken, but the job passed. Looks like this might be a real fix 💪 Broken 0 View View

.def()
.help(wrap!("The amount to transfer in decimal.")),
)
.arg(__TEST_FRONTEND_SUS_FEE.def().help(wrap!(
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we bother exposing this in the cli as it's just for testing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes we still need to expose them to run the integration and e2e tests

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a clever way to keep this from showing up in the cli help menu?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hid them in e90c619

grarco added a commit that referenced this pull request Sep 6, 2025
@grarco grarco force-pushed the grarco/frontend-sus-fees branch from cc897ad to abeb496 Compare September 6, 2025 10:12
grarco added a commit that referenced this pull request Sep 6, 2025
@grarco grarco force-pushed the grarco/frontend-sus-fees branch from 9072bfd to b6de931 Compare September 6, 2025 12:50
@grarco grarco removed the breaking:consensus Consensus breaking change that requires a hard-fork label Sep 8, 2025
@grarco grarco requested a review from batconjurer September 8, 2025 13:37
Copy link
Collaborator

@batconjurer batconjurer left a comment

Choose a reason for hiding this comment

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

nits

// NOTE: The frontend fee should NOT account for the masp fee
// payment amount
let sus_fee_amt = namada_token::Amount::from_uint(
validated_amount
Copy link
Collaborator

Choose a reason for hiding this comment

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

this block of code for the percentage calculation isn't nice looking and appears in a few spots. Can we hide it in the amount module?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in 3fe86a7, but the new function does also the validation part and lives in the same module

@brentstone brentstone added this to the Next Release milestone Sep 18, 2025
grarco added a commit that referenced this pull request Sep 25, 2025
@grarco grarco force-pushed the grarco/frontend-sus-fees branch from d3f672b to a13d611 Compare September 29, 2025 12:42
@mergify mergify bot added the queued label Sep 29, 2025
@mergify mergify bot merged commit 58a926b into main Sep 29, 2025
27 checks passed
@mergify mergify bot deleted the grarco/frontend-sus-fees branch September 29, 2025 13:37
@mergify mergify bot removed the queued label Sep 29, 2025
@tzemanovic tzemanovic restored the grarco/frontend-sus-fees branch October 7, 2025 14:34
@tzemanovic tzemanovic added the backport-201.0 Backport to app 201.0 maintenance branch label Oct 7, 2025
mergify bot pushed a commit that referenced this pull request Oct 7, 2025
(cherry picked from commit a13d611)
tzemanovic pushed a commit that referenced this pull request Oct 8, 2025
(cherry picked from commit a13d611)
mergify bot added a commit that referenced this pull request Oct 8, 2025
@tzemanovic tzemanovic added the backport-libs-0.251 Backport libraries to 0.251 maintenance branch label Dec 2, 2025
mergify bot pushed a commit that referenced this pull request Dec 2, 2025
(cherry picked from commit a13d611)

# Conflicts:
#	.changelog/libs-v0.251.2/features/4790-frontend-sus-fees.md
tzemanovic pushed a commit that referenced this pull request Dec 2, 2025
(cherry picked from commit a13d611)
mergify bot added a commit that referenced this pull request Dec 2, 2025
…pr-4790

Frontend MASP sustainability fee (backport #4790)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-201.0 Backport to app 201.0 maintenance branch backport-libs-0.251 Backport libraries to 0.251 maintenance branch breaking:api public API breaking change breaking:SDK SDK breaking change enhancement New feature or request IBC MASP merge Ready to merge - mergifyio bot will add the PR to merge queue when all checks pass SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants