IFeeManager Interface

The IFeeManager interface defines the contract for dynamic fee computation in VinuSwap.

Source: contracts/core/interfaces/IFeeManager.sol

Interface

interface IFeeManager {
    /// @notice Computes the effective fee for a swap
    /// @param fee The base fee in hundredths of a bip
    /// @return The computed fee in hundredths of a bip
    function computeFee(uint24 fee) external returns (uint24);
}

Purpose

Every VinuSwap pool is deployed with a feeManager address. During swaps, the pool calls:

uint24 effectiveFee = IFeeManager(feeManager).computeFee(fee);

This allows:

  • Dynamic fee discounts based on user attributes

  • Per-pool fee customization

  • Time-based or volume-based fee adjustments

  • Integration with external systems

Parameters

fee

Type
Description

uint24

Base fee in hundredths of a basis point

Fee Encoding:

Return Value

Type
Description

uint24

Computed fee in hundredths of a basis point

Requirements:

  • Must be < 1,000,000 (< 100%)

  • Should generally be ≤ input fee (discounts, not surcharges)

Implementations

NoDiscount

Returns the fee unchanged:

TieredDiscount

Balance-based discounts:

OverridableFeeManager

Routes to per-pool managers:

Creating Custom Fee Managers

Basic Template

Example: Time-Based Fees

Example: Holder-Based Tiers

Example: Volume-Based Fees

Integration Points

Pool Integration

The pool calls the fee manager during swap execution:

Context Available

Inside computeFee(), you have access to:

Context
Description

msg.sender

The pool calling the function

tx.origin

The original transaction sender (user)

block.timestamp

Current block timestamp

block.number

Current block number

Warning: Using tx.origin has security implications. Ensure your logic accounts for contracts calling contracts.

Gas Considerations

Fee managers are called on every swap:

Complexity
Approximate Gas

Passthrough (NoDiscount)

~200

Single storage read

~2,600

Balance check

~2,600

Multiple checks

~5,000-10,000

Keep fee managers simple to minimize swap gas costs.

Security Considerations

Reentrancy

Fee managers should not make external calls that could enable reentrancy:

DOS Prevention

Fee managers should not revert unexpectedly:

Access Control

For updateable fee managers, implement proper access control:

Last updated