Incorrect implementation of `BPF` leads to kicker losing rewards in a `take` action
The Bond Payment Factor (BPF) is the formula that determines the reward/penalty over the bond of a kicker in each `take` action. According to the whitepaper, the formula is described as:\\n```\\n// If TP < NP\\nBPF = bondFactor * min(1, max(-1, (NP - price) / (NP - TP)))\\n\\n// If TP >= NP\\nBPF = bondFactor     (if price <= NP)\\nBPF = -bondFactor    (if price > NP)\\n```\\n\\n```\\nfunction _bpf(\\n    uint256 debt_,\\n    uint256 collateral_,\\n    uint256 neutralPrice_,\\n    uint256 bondFactor_,\\n    uint256 auctionPrice_\\n) pure returns (int256) {\\n    int256 thresholdPrice = int256(Maths.wdiv(debt_, collateral_));\\n\\n    int256 sign;\\n    if (thresholdPrice < int256(neutralPrice_)) {\\n        // BPF = BondFactor * min(1, max(-1, (neutralPrice - price) / (neutralPrice - thresholdPrice)))\\n        sign = Maths.minInt(\\n            1e18,\\n            Maths.maxInt(\\n                -1 * 1e18,\\n                PRBMathSD59x18.div(\\n                    int256(neutralPrice_) - int256(auctionPrice_),\\n                    int256(neutralPrice_) - thresholdPrice\\n                )\\n            )\\n        );\\n    } else {\\n        int256 val = int256(neutralPrice_) - int256(auctionPrice_);\\n        if (val < 0 )      sign = -1e18;\\n        else if (val != 0) sign = 1e18; // @audit Sign will be zero when NP = auctionPrice\\n    }\\n\\n    return PRBMathSD59x18.mul(int256(bondFactor_), sign);\\n}\\n```\\n\\nThe issue is that the implementation of the `BPF` formula in the code doesn't match the specification, leading to the loss of rewards in that `take` action in cases where `TP >= NP` and `price = NP`.\\nAs showed in the above snippet, in cases where `TP >= NP` and `NP = price` (thus val = 0) the function won't set a value for `sign` (will be `0` by default) so that will result in a computed `BPF` of `0`, instead of `bondFactor` that would be the correct `BPF`.
Change the `_bpf` function to match the specification in order to fairly distribute the rewards in a `take` action:\\n```\\nfunction _bpf(\\n    uint256 debt_,\\n    uint256 collateral_,\\n    uint256 neutralPrice_,\\n    uint256 bondFactor_,\\n    uint256 auctionPrice_\\n) pure returns (int256) {\\n    int256 thresholdPrice = int256(Maths.wdiv(debt_, collateral_));\\n\\n    int256 sign;\\n    if (thresholdPrice < int256(neutralPrice_)) {\\n        // BPF = BondFactor * min(1, max(// Remove the line below\\n1, (neutralPrice // Remove the line below\\n price) / (neutralPrice // Remove the line below\\n thresholdPrice)))\\n        sign = Maths.minInt(\\n            1e18,\\n            Maths.maxInt(\\n                // Remove the line below\\n1 * 1e18,\\n                PRBMathSD59x18.div(\\n                    int256(neutralPrice_) // Remove the line below\\n int256(auctionPrice_),\\n                    int256(neutralPrice_) // Remove the line below\\n thresholdPrice\\n                )\\n            )\\n        );\\n    } else {\\n        int256 val = int256(neutralPrice_) // Remove the line below\\n int256(auctionPrice_);\\n        if (val < 0 )      sign = // Remove the line below\\n1e18;\\n// Remove the line below\\n       else if (val != 0) sign = 1e18;\\n// Add the line below\\n       else               sign = 1e18;\\n    }\\n\\n    return PRBMathSD59x18.mul(int256(bondFactor_), sign);\\n}\\n```\\n
The kicker will lose the rewards in that `take` action if the previous conditions are satisfied.\\nWhile the probability of this conditions to be met is not usual, the impact is the loss of rewards for that kicker and that may cause to lose part of the bond if later a `take` is performed with a negative `BPF`.
```\\n// If TP < NP\\nBPF = bondFactor * min(1, max(-1, (NP - price) / (NP - TP)))\\n\\n// If TP >= NP\\nBPF = bondFactor     (if price <= NP)\\nBPF = -bondFactor    (if price > NP)\\n```\\n