{
    "Function": "provideToSP",
    "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",
        "IBoldToken"
    ],
    "Internal Calls": [
        "getDepositorYieldGain",
        "_getYieldToKeepOrSend",
        "getCompoundedBoldDeposit",
        "_decreaseYieldGainsOwed",
        "_updateTotalBoldDeposits",
        "_updateDepositAndSnapshots",
        "_requireNonZeroAmount",
        "_getNewStashedCollAndCollToSend",
        "_updateYieldRewardsSum",
        "_requireWhitelisted",
        "_sendCollGainToDepositor",
        "getDepositorCollGain",
        "_sendBoldtoDepositor"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function provideToSP(uint256 _topUp, bool _doClaim) external override {\n        IWhitelist _whitelist = whitelist;\n        if (address(_whitelist) != address(0)) {\n            _requireWhitelisted(_whitelist, msg.sender);\n        }\n\n        _requireNonZeroAmount(_topUp);\n\n        activePool.mintAggInterest();\n\n        uint256 initialDeposit = deposits[msg.sender].initialValue;\n\n        uint256 currentCollGain = getDepositorCollGain(msg.sender);\n        uint256 currentYieldGain = getDepositorYieldGain(msg.sender);\n        uint256 compoundedBoldDeposit = getCompoundedBoldDeposit(msg.sender);\n        (uint256 keptYieldGain, uint256 yieldGainToSend) = _getYieldToKeepOrSend(currentYieldGain, _doClaim);\n        uint256 newDeposit = compoundedBoldDeposit + _topUp + keptYieldGain;\n        (uint256 newStashedColl, uint256 collToSend) = _getNewStashedCollAndCollToSend(\n            msg.sender,\n            currentCollGain,\n            _doClaim\n        );\n\n        emit DepositOperation(\n            msg.sender,\n            Operation.provideToSP,\n            initialDeposit - compoundedBoldDeposit,\n            int256(_topUp),\n            currentYieldGain,\n            yieldGainToSend,\n            currentCollGain,\n            collToSend\n        );\n\n        _updateDepositAndSnapshots(msg.sender, newDeposit, newStashedColl);\n        boldToken.sendToPool(msg.sender, address(this), _topUp);\n        _updateTotalBoldDeposits(_topUp + keptYieldGain, 0);\n        _decreaseYieldGainsOwed(currentYieldGain);\n        _sendBoldtoDepositor(msg.sender, yieldGainToSend);\n        _sendCollGainToDepositor(collToSend);\n\n        // If there were pending yields and with the new deposit we are reaching the threshold, let\u2019s move the yield to owed\n        _updateYieldRewardsSum(0);\n    }"
}