{
    "Function": "_setDrips",
    "File": "src/Drips.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [
        "_currTimestamp",
        "_hashDrips",
        "_currTimestamp",
        "_currTimestamp",
        "_updateReceiverStates",
        "_hashDripsHistory",
        "_hashDrips",
        "_currTimestamp",
        "_cycleOf",
        "_dripsStorage",
        "_dripsStorage",
        "_balanceAt",
        "require(bool,string)",
        "_calcMaxEnd",
        "_cycleOf"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function _setDrips(\n        uint256 userId,\n        uint256 assetId,\n        DripsReceiver[] memory currReceivers,\n        int128 balanceDelta,\n        DripsReceiver[] memory newReceivers,\n        // slither-disable-next-line similar-names\n        uint32 maxEndHint1,\n        uint32 maxEndHint2\n    ) internal returns (int128 realBalanceDelta) {\n        DripsState storage state = _dripsStorage().states[assetId][userId];\n        // slither-disable-next-line timestamp\n        require(_hashDrips(currReceivers) == state.dripsHash, \"Invalid current drips list\");\n        uint32 lastUpdate = state.updateTime;\n        uint128 newBalance;\n        uint32 newMaxEnd;\n        {\n            uint32 currMaxEnd = state.maxEnd;\n            int128 currBalance = int128(\n                _balanceAt(state.balance, lastUpdate, currMaxEnd, currReceivers, _currTimestamp())\n            );\n            realBalanceDelta = balanceDelta;\n            // Cap `realBalanceDelta` at withdrawal of the entire `currBalance`\n            if (realBalanceDelta < -currBalance) {\n                realBalanceDelta = -currBalance;\n            }\n            newBalance = uint128(currBalance + realBalanceDelta);\n            newMaxEnd = _calcMaxEnd(newBalance, newReceivers, maxEndHint1, maxEndHint2);\n            _updateReceiverStates(\n                _dripsStorage().states[assetId],\n                currReceivers,\n                lastUpdate,\n                currMaxEnd,\n                newReceivers,\n                newMaxEnd\n            );\n        }\n        state.updateTime = _currTimestamp();\n        state.maxEnd = newMaxEnd;\n        state.balance = newBalance;\n        bytes32 dripsHistory = state.dripsHistoryHash;\n        // slither-disable-next-line timestamp\n        if (dripsHistory != 0 && _cycleOf(lastUpdate) != _cycleOf(_currTimestamp())) {\n            state.currCycleConfigs = 2;\n        } else {\n            state.currCycleConfigs++;\n        }\n        bytes32 newDripsHash = _hashDrips(newReceivers);\n        state.dripsHistoryHash =\n            _hashDripsHistory(dripsHistory, newDripsHash, _currTimestamp(), newMaxEnd);\n        emit DripsSet(userId, assetId, newDripsHash, dripsHistory, newBalance, newMaxEnd);\n        // slither-disable-next-line timestamp\n        if (newDripsHash != state.dripsHash) {\n            state.dripsHash = newDripsHash;\n            for (uint256 i = 0; i < newReceivers.length; i++) {\n                DripsReceiver memory receiver = newReceivers[i];\n                emit DripsReceiverSeen(newDripsHash, receiver.userId, receiver.config);\n            }\n        }\n    }"
}