Skip to content

feat: add admin-configurable transaction fees per accepted token - #59

Merged
codebestia merged 1 commit into
ShadeProtocol:mainfrom
KodeSage:feat/fee_management_functionality
Feb 22, 2026
Merged

codebestia merged 1 commit into
ShadeProtocol:mainfrom
KodeSage:feat/fee_management_functionality

Conversation

@KodeSage

@KodeSage KodeSage commented Feb 22, 2026 •

Copy link
Copy Markdown
Contributor

CLOSES #34

Description

Implement admin-configurable transaction fees per accepted token. This allows the protocol to earn revenue from transactions by letting the admin set fee amounts for each token on the accepted tokens list.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Test improvements
  • Other (please describe):

Related Issues

Fixes #

Changes Made

  • Added TokenFee(Address) variant to DataKey enum in types.rs for per-token fee storage
  • Added TokenNotAccepted = 12 error variant to ContractError in errors.rs
  • Added FeeSetEvent struct and publish_fee_set_event helper in events.rs
  • Implemented set_fee in components/admin.rs — admin-only, reentrancy-guarded, validates the token is on the accepted list before saving the fee
  • Implemented get_fee in components/admin.rs — returns the stored fee for a token, defaulting to 0 if unset
  • Extended ShadeTrait in interface.rs with set_fee and get_fee method signatures
  • Wired up set_fee (with pause guard) and get_fee in shade.rs

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • All existing tests pass locally
  • I have tested this manually

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Screenshots (if applicable)

N/A

Additional Notes

  • set_fee enforces that only accepted tokens can have fees configured, panicking with TokenNotAccepted otherwise
  • set_fee is blocked when the contract is paused, consistent with other admin write operations
  • Reentrancy protection is applied to set_fee following the same pattern as add_accepted_token and remove_accepted_token
  • get_fee is a read-only query and does not require pause or reentrancy checks

@codebestia
codebestia merged commit 55d60d4 into ShadeProtocol:main Feb 22, 2026
4 checks passed
Tijesunimi004 pushed a commit to Tijesunimi004/shade-stellar-contract that referenced this pull request Feb 24, 2026
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.

Implement Fee Management Functionality

2 participants