Skip to content
Verified contractExactMIT

FeeModel

Address0x40c38eb3ae511fa5ec4d2c30a22c7db939dd50dc
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.35

 

Same code

3 more contracts

 

Details

Compiler
solc 0.8.35+commit.47b9dedd
Language
solidity
Optimization
Yes, 200 runs
EVM version
osaka
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,730,835
Creation transaction
0xcd25a29add…655ec449ee

src/fee/FeeModel.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IFeeModel} from "../interfaces/IFeeModel.sol";

/// @title FeeModel
/// @notice 费率计算模块(纯函数,无状态)
/// @dev 由 FeeManager 重命名而来,语义更准确
contract FeeModel is IFeeModel {
    uint256 private constant WAD = 1e18;

    /// @notice 计算入场费 / 退场费
    function calculateInOutFee(
        uint256 assets,
        uint256 feeRate
    ) external pure override returns (uint256 feeAmount) {
        feeAmount = assets * feeRate / WAD;
    }

    /// @notice 结算费用并返回 breakdown(vNext 新增)
    function settle(FeeContext calldata ctx) external pure override returns (FeeResult memory result) {
        // 管理费
        uint256 mgmtFee = ctx.managementFeeRate > 0
            ? ctx.grossNav * ctx.managementFeeRate * ctx.timeDelta / (365 days * WAD)
            : 0;
        if (mgmtFee > ctx.grossNav) mgmtFee = ctx.grossNav;

        // 业绩费(基于 Net-of-mgmt HWM)
        uint256 netNavAfterMgmtFee = ctx.grossNav - mgmtFee;
        uint256 currentSharePrice = ctx.totalSupply > 0
            ? netNavAfterMgmtFee * WAD / ctx.totalSupply
            : 0;
        uint256 profitAboveHighWatermark = ctx.totalSupply > 0
            && currentSharePrice > ctx.lastCheckpointSharePrice
            ? (currentSharePrice - ctx.lastCheckpointSharePrice) * ctx.totalSupply / WAD
            : 0;
        uint256 perfFee = ctx.performanceFeeRate > 0 && profitAboveHighWatermark > 0
            ? profitAboveHighWatermark * ctx.performanceFeeRate / WAD
            : 0;
        if (perfFee > netNavAfterMgmtFee) perfFee = netNavAfterMgmtFee;

        // 更新 HWM
        uint256 nextCheckpointSharePrice = currentSharePrice > ctx.lastCheckpointSharePrice
            ? currentSharePrice
            : ctx.lastCheckpointSharePrice;

        result = FeeResult({
            managementFeeAssets: mgmtFee,
            performanceFeeAssets: perfFee,
            totalFeeAssets: mgmtFee + perfFee,
            profitAboveHighWatermark: profitAboveHighWatermark,
            nextCheckpointSharePrice: nextCheckpointSharePrice
        });
    }
}

src/interfaces/IFeeModel.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/// @title IFeeModel
/// @notice FeeModel 接口 — 费率计算(纯函数,无状态)
/// @dev 由 IFeeManager 重命名而来,语义更准确
interface IFeeModel {

    struct FeeContext {
        uint256 grossNav;
        uint256 timeDelta;
        uint256 totalSupply;
        uint256 managementFeeRate;
        uint256 performanceFeeRate;
        uint256 lastCheckpointSharePrice;
    }

    struct FeeResult {
        uint256 managementFeeAssets;
        uint256 performanceFeeAssets;
        uint256 totalFeeAssets;
        uint256 profitAboveHighWatermark;
        uint256 nextCheckpointSharePrice;
    }

    /// @notice 计算入场费 / 退场费
    /// @param assets   资产金额
    /// @param feeRate  费率(WAD)
    /// @return feeAmount 费用金额
    function calculateInOutFee(
        uint256 assets,
        uint256 feeRate
    ) external pure returns (uint256 feeAmount);

    /// @notice 结算费用并返回 breakdown(vNext 新增)
    /// @param ctx 结算上下文
    /// @return result 费用计算结果
    function settle(FeeContext calldata ctx) external pure returns (FeeResult memory result);
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "osaka",
  "remappings": [
    "@hyper-evm-lib/=lib/hyper-evm-lib/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "forge-std/=lib/forge-std/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "hyper-evm-lib/=lib/hyper-evm-lib/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.