Skip to content

introduce dynamic fee types#403

Open
malteish wants to merge 17 commits intofeat/TokenSwapCoinvestorfrom
feat/newFeeSettings
Open

introduce dynamic fee types#403
malteish wants to merge 17 commits intofeat/TokenSwapCoinvestorfrom
feat/newFeeSettings

Conversation

@malteish
Copy link
Collaborator

@malteish malteish commented Mar 17, 2026

FeeSettings.sol rework

What changed

The fee system has been generalized from three hardcoded fee types to a
dynamic registry
. Previously, FeeSettings had TOKEN, CROWDINVESTING, and
PRIVATE_OFFER baked in as constants with fixed per-type caps (5%, 10%, 5%).
Now, fee types are registered at deployment (or later) with arbitrary names and
caps, and the contract can accommodate new product lines without an upgrade.

How fees work now:

  • Each fee type is identified by a bytes32 key (e.g. keccak256("TOKEN"))
    and configured with a max cap and a default numerator at registration time.
  • Custom per-token discounts and fee collector overrides work the same way as
    before, but are now keyed by (feeType, token) instead of living in
    separate mappings per type.
  • Fee increases still require a 12-week delay, now enforced per fee type
    independently.
  • Owner registers types and sets defaults; managers grant per-token discounts
    — same role separation as before.

What stays compatible

All existing callers (Token, Crowdinvesting, PrivateOffer contracts) continue
to work unchanged. The V1 and V2 interface functions (tokenFee,
crowdinvestingFee, privateOfferFee, and the matching feeCollector
variants) are retained as thin wrappers over the new generic logic. ERC-165
reports support for V1, V2, and the new V3 interface.

What breaks

Any tooling or scripts that call the old management functions by name will need
updating: planFeeChange(Fees), executeFeeChange(), setFeeCollectors(...),
setCustomFee(address, Fees), and the six per-type collector setters/removers
are all replaced by generic equivalents that take a bytes32 feeType as the
first argument. Events have changed accordingly.

@openzeppelin-code
Copy link

openzeppelin-code bot commented Mar 17, 2026

introduce dynamic fee types

Generated at commit: 4724d9a36a20a318f5853e04874b83d6e4199727

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
2
2
0
5
28
37
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@malteish malteish mentioned this pull request Mar 19, 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.

1 participant