{
    "Function": "getDepositorYieldGainWithPending",
    "File": "contracts/src/StabilityPool.sol",
    "Parent Contracts": [
        "contracts/src/Interfaces/IStabilityPoolEvents.sol",
        "contracts/src/Interfaces/IStabilityPool.sol",
        "contracts/src/Interfaces/IBoldRewardsReceiver.sol",
        "contracts/src/Dependencies/LiquityBase.sol",
        "contracts/src/Interfaces/ILiquityBase.sol"
    ],
    "High-Level Calls": [
        "IActivePool",
        "LiquityMath"
    ],
    "Internal Calls": [],
    "Library Calls": [
        "_min"
    ],
    "Low-Level Calls": [],
    "Code": "function getDepositorYieldGainWithPending(address _depositor) external view override returns (uint256) {\n        if (totalBoldDeposits < MIN_BOLD_IN_SP) return 0;\n\n        uint256 initialDeposit = deposits[_depositor].initialValue;\n        if (initialDeposit == 0) return 0;\n\n        Snapshots storage snapshots = depositSnapshots[_depositor];\n        uint256 newYieldGainsOwed = yieldGainsOwed;\n\n        // Yield gains from the same scale in which the deposit was made need no scaling\n        uint256 normalizedGains = scaleToB[snapshots.scale] - snapshots.B;\n\n        // Scale down further yield gains by a power of `SCALE_FACTOR` depending on how many scale changes they span\n        for (uint256 i = 1; i <= SCALE_SPAN; ++i) {\n            normalizedGains += scaleToB[snapshots.scale + i] / SCALE_FACTOR ** i;\n        }\n\n        // Pending gains\n        uint256 pendingSPYield = activePool.calcPendingSPYield();\n        newYieldGainsOwed += pendingSPYield;\n\n        if (currentScale <= snapshots.scale + SCALE_SPAN) {\n            normalizedGains +=\n                (P * pendingSPYield) /\n                totalBoldDeposits /\n                SCALE_FACTOR ** (currentScale - snapshots.scale);\n        }\n\n        return LiquityMath._min((initialDeposit * normalizedGains) / snapshots.P, newYieldGainsOwed);\n    }"
}