```\nfunction updateUsedBorrowCapacity(\n    address vault,\n    uint16 currencyId,\n    int256 netfCash\n) internal returns (int256 totalUsedBorrowCapacity) {\n    VaultBorrowCapacityStorage storage cap = LibStorage.getVaultBorrowCapacity()[vault][currencyId];\n\n    // Update the total used borrow capacity, when borrowing this number will increase (netfCash < 0),\n    // when lending this number will decrease (netfCash > 0).\n    totalUsedBorrowCapacity = int256(uint256(cap.totalUsedBorrowCapacity)).sub(netfCash);\n    if (netfCash < 0) {\n        // Always allow lending to reduce the total used borrow capacity to satisfy the case when the max borrow\n        // capacity has been reduced by governance below the totalUsedBorrowCapacity. When borrowing, it cannot\n        // go past the limit.\n        require(totalUsedBorrowCapacity <= int256(uint256(cap.maxBorrowCapacity)), "Max Capacity");\n```\n