Skip to content

Auto fee token improvements#45

Open
MiniRoman wants to merge 3 commits intomainfrom
auto-fee-token-improvements
Open

Auto fee token improvements#45
MiniRoman wants to merge 3 commits intomainfrom
auto-fee-token-improvements

Conversation

@MiniRoman
Copy link
Collaborator

@MiniRoman MiniRoman commented Feb 12, 2026

Summary

This PR delivers two major improvements:

  1. A historical multiplier update log for the BackedAutoFeeToken
  2. A reworked WrappedBackedToken that operates directly on shares of the underlying token rather than transferring tokens

It also extracts the IBackedAutoFeeToken interface and removes the delegate whitelist mechanism from the wrapped token.


Changes

1. New IBackedAutoFeeToken Interface

File: contracts/interfaces/IBackedAutoFeeToken.sol

A new dedicated interface is introduced for the auto-fee token, consolidating:

  • The MultiplierUpdate struct with fields: previousMultiplier, newMultiplier, activationTime
  • All previously inline events: NewMultiplierUpdater, TransferShares, MultiplierUpdated
  • A new MultiplierScheduled event, emitted when a future multiplier activation is queued
  • Full view-function declarations for fee config, multiplier state, share/amount conversions, and share transfers

BackedAutoFeeTokenImplementation now explicitly implements this interface.


2. Multiplier Update History in BackedAutoFeeTokenImplementation

File: contracts/BackedAutoFeeTokenImplementation.sol

  • MultiplierUpdate[] public multiplierUpdates — a new on-chain array that stores every scheduled multiplier change (past and future), enabling historical lookups.
  • _storeScheduledMultiplierUpdate() — internal function called on every multiplier update. If the last stored entry has a future activation time (i.e., not yet applied), it is overridden, since only one scheduled update can be pending at a time. The new entry is then appended.
  • initialize_v4() — a one-time migration initializer that seeds the multiplierUpdates array with a genesis entry (multiplier = 1e18, activationTime = 0) and any historically provided past updates.
  • multiplierUpdatesLength() — a new view function returning the array length.
  • Both updateMultiplierValue() and updateMultiplierValueWithNonce() now call _storeScheduledMultiplierUpdate() after scheduling.
  • The new MultiplierScheduled event is emitted when a future-dated multiplier update is queued.
  • Events previously defined inline are removed in favor of the interface definition.

3. Share-based WrappedBackedToken

File: contracts/WrappedBackedTokenImplementation.sol

The wrapped token is redesigned to operate on shares of the underlying IBackedAutoFeeToken rather than on token balances:

  • totalAssets() — recalculated as the contract's shares balance × current multiplier, ensuring the wrapper's asset accounting always reflects the rebasing of the underlying token.
  • _convertToShares() / _convertToAssets() — now fetch getCurrentMultiplier() from the underlying IBackedAutoFeeToken for all conversions.
  • _deposit() — transfers shares from the user (via transferSharesFrom) instead of ERC20 tokens; mints wrapped tokens 1:1 with shares received.
  • _withdraw() — burns wrapped tokens and transfers shares back to the receiver (via transferShares).
  • previewMint() and previewWithdraw() — overridden to use Rounding.Down to accommodate multiplier math.
  • Delegate whitelist removed: setDelegateWhitelist(), setDelegateMode(), allowedDelegate modifier, and the permit() override are all deleted. delegatedTransfer() and permit() are now open to all callers.
  • Clarified sanctions error messages: WrappedBackedToken: sender is sanctioned / WrappedBackedToken: spender is sanctioned.

4. Factory Fix

File: contracts/WrappedBackedTokenFactory.sol

  • The salt for proxy deployment now includes the underlying token address (previously only name + symbol), preventing salt collisions across different underlying tokens with the same name/symbol.
  • Deployment flow is split: the proxy is first deployed with an empty implementation, then upgradeToAndCall() is used to initialize it, and finally changeAdmin() transfers proxy admin rights — enabling the factory to call initialization within the same transaction.

5. Tests

test/BackedAutoFeeTokenImplementation.ts (+212 lines)

New tests covering:

  • multiplierUpdates array storage and contents
  • initialize_v4 migration initializer
  • MultiplierScheduled event emission
  • multiplierUpdatesLength() view function

test/WrappedBackedTokenImplementation.ts (+599 / -52 lines)

Expanded test suite covering:

  • ERC4626 deposit, mint, withdraw, redeem flows
  • Preview functions (previewDeposit, previewMint, previewWithdraw, previewRedeem)
  • Rounding direction compliance
  • Multiplier changes during operations
  • Sanctions enforcement
  • Pause behavior
  • Ownership management
  • Delegate whitelist tests replaced with open-access tests (whitelist removed)

Stats

Metric Value
Additions 1226
Deletions 131
Files changed 6
Commits 3

Copy link
Collaborator

@jakub-lore jakub-lore left a comment

Choose a reason for hiding this comment

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

.

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.

2 participants