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.

referencesCOLLECTION.md

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

Fee Collection

Mechanisms for collecting and distributing fees to beneficiaries in locked pools.


FeesManager Base Contract

Abstract contract implementing MasterChef-style fee distribution.

Fee Formula

            (cumulatedFees - lastCumulatedFees) × shares
    fees = ─────────────────────────────────────────────────
                                WAD

Source: FeesManager.sol (lines 48-52)

State Variables

// Total fees accumulated for pool (token0)
mapping(PoolId poolId => uint256) public getCumulatedFees0;

// Total fees accumulated for pool (token1)
mapping(PoolId poolId => uint256) public getCumulatedFees1;

// Last collection checkpoint for beneficiary (token0)
mapping(PoolId => mapping(address => uint256)) public getLastCumulatedFees0;

// Last collection checkpoint for beneficiary (token1)
mapping(PoolId => mapping(address => uint256)) public getLastCumulatedFees1;

// Beneficiary share allocation (WAD-scaled)
mapping(PoolId => mapping(address => uint256)) public getShares;

Source: FeesManager.sol (lines 57-69)


Collection Flow

1. collectFees()

function collectFees(PoolId poolId) external nonReentrant returns (uint128 fees0, uint128 fees1) {
    // 1. Call virtual _collectFees (implemented by subclass)
    BalanceDelta fees = _collectFees(poolId);

    // 2. Update cumulated totals
    getCumulatedFees0[poolId] += fees.amount0();
    getCumulatedFees1[poolId] += fees.amount1();

    // 3. Release fees to caller if they're a beneficiary
    _releaseFees(poolId, msg.sender);
}

Source: FeesManager.sol (lines 80-91)

2. _releaseFees()

function _releaseFees(PoolId poolId, address beneficiary) internal {
    uint256 shares = getShares[poolId][beneficiary];

    if (shares > 0) {
        // Calculate delta since last collection
        uint256 delta0 = getCumulatedFees0[poolId] - getLastCumulatedFees0[poolId][beneficiary];
        uint256 amount0 = delta0 * shares / WAD;

        // Update checkpoint
        getLastCumulatedFees0[poolId][beneficiary] = getCumulatedFees0[poolId];

        // Transfer fees
        if (amount0 > 0) poolKey.currency0.transfer(beneficiary, amount0);

        // Repeat for token1...
    }
}

Source: FeesManager.sol (lines 141-158)


Beneficiary Management

Storing Beneficiaries

function _storeBeneficiaries(
    PoolKey memory poolKey,
    BeneficiaryData[] memory beneficiaries,
    address protocolOwner,
    uint96 protocolOwnerShares
) internal

Source: FeesManager.sol (lines 125-134)

Requirements (from BeneficiaryData.sol):

  1. Addresses sorted ascending
  2. Each share > 0
  3. Total shares == WAD (1e18)
  4. Protocol owner included with >= 5% share

Updating Beneficiary

function updateBeneficiary(PoolId poolId, address newBeneficiary) external {
    // 1. Release pending fees to both parties
    _releaseFees(poolId, msg.sender);
    _releaseFees(poolId, newBeneficiary);

    // 2. Transfer shares
    getShares[poolId][newBeneficiary] += getShares[poolId][msg.sender];
    getShares[poolId][msg.sender] = 0;
}

Source: FeesManager.sol (lines 99-116)


StreamableFeesLocker (V1)

Position-based fee streaming for Uniswap V4 NFT positions.

Architecture

  • Receives positions via onERC721Received()
  • Position locked for lockDuration seconds
  • Fees distributed to beneficiaries pro-rata

Key Functions

// Collect and distribute fees
function distributeFees(uint256 tokenId) external;

// Claim accumulated fees
function releaseFees(uint256 tokenId) external;

Source: StreamableFeesLocker.sol (lines 161, 226)

Position Data

struct PositionData {
    address recipient;           // NFT receiver after unlock
    uint32 startDate;            // Lock start timestamp
    uint32 lockDuration;         // Lock duration in seconds
    bool isUnlocked;             // Unlock status
    BeneficiaryData[] beneficiaries;
}

Source: StreamableFeesLocker.sol (lines 19-25)


StreamableFeesLockerV2

Pool-based fee streaming using FeesManager.

Architecture

  • Extends FeesManager for beneficiary tracking
  • Manages positions directly via MiniV4Manager
  • Virtual fee accumulation (no per-position tracking)

Key Functions

// Lock positions and set beneficiaries
function lock(
    PoolKey memory poolKey,
    uint32 lockDuration,
    address recipient,
    BeneficiaryData[] calldata beneficiaries,
    Position[] calldata positions
) external onlyApprovedMigrator;

Source: StreamableFeesLockerV2.sol (lines 101-126)

Stream Data

struct StreamData {
    PoolKey poolKey;
    address recipient;
    uint32 startDate;
    uint32 lockDuration;
    bool isUnlocked;
    BeneficiaryData[] beneficiaries;
    Position[] positions;
}

Source: StreamableFeesLockerV2.sol (lines 27-35)


Comparison

Feature V1 (StreamableFeesLocker) V2 (StreamableFeesLockerV2)
Position type NFT-based Direct liquidity
Fee tracking Per-position Per-pool (FeesManager)
Gas efficiency Lower Higher
Beneficiary update Per-position Per-pool

Permanent Lock (No-Op Governance)

Set recipient = DEAD_ADDRESS (0xdead) for permanent lock:

// Position permanently locked, beneficiaries collect fees forever
if (recipient != DEAD_ADDRESS) {
    // Normal unlock after lockDuration
} else {
    // Never unlocks, fees stream indefinitely
}

Source: StreamableFeesLocker.sol (lines 144-146)

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