Index of every page on this site: llms.txt
All skills
Run it yourself

Reference for Doppler fee collection, distribution, and configuration across Airlock, FeesManager, locker contracts, and hook-based fee paths.

Use this Skill: https://skilld.dev/gh/whetstoneresearch/doppler-skills/fee-architecture

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesDYNAMIC-FEES.md

≈1.4k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Dynamic Fees

Standard vs dynamic LP fee configuration in Doppler pools.


Fee Modes

Standard Fees

Fixed LP fee set at pool initialization. Cannot be changed after creation.

PoolKey memory poolKey = PoolKey({
    currency0: ...,
    currency1: ...,
    fee: 3000,  // Fixed 0.3% fee
    tickSpacing: 60,
    hooks: IHooks(address(0))
});

Dynamic Fees

Fee can be modified by the hook during pool lifetime.

PoolKey memory poolKey = PoolKey({
    currency0: ...,
    currency1: ...,
    fee: LPFeeLibrary.DYNAMIC_FEE_FLAG,  // Signals dynamic fee mode
    tickSpacing: 60,
    hooks: IHooks(dopplerHook)
});

Source: UniswapV4Initializer.sol (lines 108)


DYNAMIC_FEE_FLAG

A special value indicating the pool uses dynamic fees:

// From Uniswap V4 LPFeeLibrary
uint24 constant DYNAMIC_FEE_FLAG = 0x800000;

When this flag is set:

  • Initial fee is ignored
  • Hook's getFee() determines swap fee
  • Fee can be updated via updateDynamicLPFee()

Updating Dynamic Fees

updateDynamicLPFee()

The hook or authorized contract calls PoolManager:

poolManager.updateDynamicLPFee(poolKey, newLpFee);

Source: Doppler.sol (lines 371)

In DopplerHookInitializer

function updateDynamicLPFee(address asset, uint24 lpFee) external {
    PoolState memory state = getPoolState[asset];
    // Requires configured fee-updater authorization in deployment wiring.
    poolManager.updateDynamicLPFee(state.poolKey, lpFee);
}

Source: DopplerHookInitializer.sol (lines 425-430)


Fee Decay Schedule (Multicurve Decay Variant)

The decay multicurve path uses a hook-managed linear fee schedule:

  • startFee: fee used at schedule start
  • fee (end fee): terminal fee after decay completes
  • durationSeconds: linear decay window
  • startingTime: timestamp when decay begins

Validation constraints in the initializer/hook:

  • startFee <= MAX_LP_FEE
  • fee <= MAX_LP_FEE
  • startFee >= fee
  • If startFee > fee, durationSeconds > 0

Runtime behavior:

  • At schedule set, the hook seeds pool fee to startFee via updateDynamicLPFee.
  • Before startingTime, swaps are allowed and still execute at startFee.
  • During decay, each beforeSwap computes the current fee and updates only when fee has dropped.
  • After startingTime + durationSeconds, fee stays at terminal fee.

Linear interpolation:

feeDelta = (startFee - endFee) * elapsed / durationSeconds;
currentFee = startFee - feeDelta;

Source: DecayMulticurveInitializer.sol (lines 84-91, 126-127)
Source: DecayMulticurveInitializerHook.sol (lines 92-104, 128-146, 164-166)


When to Use Each Mode

Use Case Fee Mode Reason
V3-style static pools Standard No hook overhead
V4 dynamic auctions Dynamic Hook needs fee control
Multicurve without hook Standard Simple fixed fee
Multicurve with DopplerHook Dynamic Hook manages fees

Initial LP Fee

For dynamic fee pools, an initial fee is set after initialization:

// In Doppler.sol afterInitialize
poolManager.updateDynamicLPFee(key, initialLpFee);

Source: Doppler.sol (lines 371)

This sets the starting fee before any swaps occur.


Fee Validation

Uniswap V4 validates fees via LPFeeLibrary:

// Maximum LP fee: 100%
uint24 constant MAX_LP_FEE = 1_000_000;

function validate(uint24 fee) internal pure {
    if (fee > MAX_LP_FEE) revert InvalidFee();
}

Fee in V3 vs V4

Aspect V3 V4
Fee storage Per pool (immutable) In PoolKey or dynamic
Fee tiers Fixed (0.01%, 0.05%, 0.3%, 1%) Any value 0-100%
Runtime changes Not possible Via hook
Tick spacing coupling Yes (fee determines spacing) No (independent)

DopplerHookInitializer Fee Logic

Pools with a DopplerHook use dynamic fees:

PoolKey memory poolKey = PoolKey({
    // ...
    fee: initData.dopplerHook != address(0)
        ? LPFeeLibrary.DYNAMIC_FEE_FLAG  // Dynamic if hook present
        : initData.fee,                   // Standard if no hook
    // ...
});

Source: DopplerHookInitializer.sol (lines 277)


Insufficient Proceeds Fee Override

During insufficient proceeds phase, the Doppler hook overrides fees to 0:

// In beforeSwap when insufficientProceeds = true
return (
    BaseHook.beforeSwap.selector,
    BeforeSwapDeltaLibrary.ZERO_DELTA,
    0  // Zero fee for refund swaps
);

This allows users to sell back tokens without paying fees during the refund period.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo5 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill acts as an architecture reference guide documenting fee collection, distribution, and configuration across the Doppler smart contract ecosystem. All codebase links map properly to the vendor's own verified code storage on GitHub, and no active security risks, prompt injections, or malicious dependencies were identified.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • Runlayer8mo

    4 files scanned · No issues

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 4f654fe. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 8 months ago
metadata
{
  "author": "doppler",
  "version": "2.0"
}

README badge

README badge for whetstoneresearch/doppler-skills/fee-architecture