UniswapIncentive overflow on pre-transfer hooks
Before a token transfer is performed, `Fei` performs some combination of mint/burn operations via UniswapIncentive.incentivize:\\n```\\nfunction incentivize(\\n address sender,\\n address receiver, \\n address operator,\\n uint amountIn\\n) external override onlyFei {\\n    updateOracle();\\n\\n if (isPair(sender)) {\\n  incentivizeBuy(receiver, amountIn);\\n }\\n\\n if (isPair(receiver)) {\\n        require(isSellAllowlisted(sender) || isSellAllowlisted(operator), "UniswapIncentive: Blocked Fei sender or operator");\\n  incentivizeSell(sender, amountIn);\\n }\\n}\\n```\\n\\nBoth `incentivizeBuy` and `incentivizeSell` calculate buy/sell incentives using overflow-prone math, then mint / burn from the target according to the results. This may have unintended consequences, like allowing a caller to mint tokens before transferring them, or burn tokens from their recipient.\\n`incentivizeBuy` calls `getBuyIncentive` to calculate the final minted value:\\n```\\nfunction incentivizeBuy(address target, uint amountIn) internal ifMinterSelf {\\n if (isExemptAddress(target)) {\\n  return;\\n }\\n\\n    (uint incentive, uint32 weight,\\n    Decimal.D256 memory initialDeviation,\\n    Decimal.D256 memory finalDeviation) = getBuyIncentive(amountIn);\\n\\n    updateTimeWeight(initialDeviation, finalDeviation, weight);\\n    if (incentive != 0) {\\n        fei().mint(target, incentive);        \\n    }\\n}\\n```\\n\\n`getBuyIncentive` calculates price deviations after casting `amount` to an `int256`, which may overflow:\\n```\\nfunction getBuyIncentive(uint amount) public view override returns(\\n    uint incentive,\\n    uint32 weight,\\n    Decimal.D256 memory initialDeviation,\\n    Decimal.D256 memory finalDeviation\\n) {\\n    (initialDeviation, finalDeviation) = getPriceDeviations(-1 \\* int256(amount));\\n```\\n
Resolution\\nThis was addressed in fei-protocol/fei-protocol-core#15.\\nEnsure casts in `getBuyIncentive` and `getSellPenalty` do not overflow.
```\\nfunction incentivize(\\n address sender,\\n address receiver, \\n address operator,\\n uint amountIn\\n) external override onlyFei {\\n    updateOracle();\\n\\n if (isPair(sender)) {\\n  incentivizeBuy(receiver, amountIn);\\n }\\n\\n if (isPair(receiver)) {\\n        require(isSellAllowlisted(sender) || isSellAllowlisted(operator), "UniswapIncentive: Blocked Fei sender or operator");\\n  incentivizeSell(sender, amountIn);\\n }\\n}\\n```\\n