Loss of funds during user adjusting
Adjusting a user's total claimable value not working correctly\\nWhenever the owner is adjusting user's total claimable value, the `records[beneficiary].total` is decreased or increased by `uint256 diff = uint256(amount > 0 ? amount : -amount);`.\\nHowever some assumptions made are not correct. Scenario:\\nUser has bought 200 FOO tokens for example.\\nIn `PriceTierVestingSale_2_0.sol` he calls the `initializeDistributionRecord` which sets his `records[beneficiary].total` to the purchased amount || 200. So `records[beneficiary].total` = 200\\nAfter that the owner decides to adjust his `records[beneficiary].total` to 300. So `records[beneficiary].total` = 300\\nUser decides to `claim` his claimable amount which should be equal to 300. He calls the `claim` function in `PriceTierVestingSale_2_0.sol`.\\n```\\nfunction claim(\\n    address beneficiary // the address that will receive tokens\\n  ) external validSaleParticipant(beneficiary) nonReentrant {\\n    uint256 claimableAmount = getClaimableAmount(beneficiary);\\n    uint256 purchasedAmount = getPurchasedAmount(beneficiary);\\n\\n    // effects\\n    uint256 claimedAmount = super._executeClaim(beneficiary, purchasedAmount);\\n\\n    // interactions\\n    super._settleClaim(beneficiary, claimedAmount);\\n  }\\n```\\n\\nAs we can see here the `_executeClaim` is called with the `purchasedAmount` of the user which is still 200.\\n```\\nfunction _executeClaim(\\n    address beneficiary,\\n    uint256 _totalAmount\\n  ) internal virtual returns (uint256) {\\n    uint120 totalAmount = uint120(_totalAmount);\\n\\n    // effects\\n    if (records[beneficiary].total != totalAmount) {\\n      // re-initialize if the total has been updated\\n      _initializeDistributionRecord(beneficiary, totalAmount);\\n    }\\n    \\n    uint120 claimableAmount = uint120(getClaimableAmount(beneficiary));\\n    require(claimableAmount > 0, 'Distributor: no more tokens claimable right now');\\n\\n    records[beneficiary].claimed += claimableAmount;\\n    claimed += claimableAmount;\\n\\n    return claimableAmount;\\n  }\\n```\\n\\nNow check the `if` statement:\\n```\\n if (records[beneficiary].total != totalAmount) {\\n      // re-initialize if the total has been updated\\n      _initializeDistributionRecord(beneficiary, totalAmount);\\n    }\\n```\\n\\nThe point of this is if the `total` of the user has been adjusted, to re-initialize to the corresponding amount, but since it's updated by the input value which is 200, records[beneficiary].total = 200 , the user will lose the 100 added from the owner during the `adjust`
I am not sure if it is enough to just set it the following way:\\n```\\n if (records[beneficiary].total != totalAmount) {\\n      // re-initialize if the total has been updated\\n      `--` _initializeDistributionRecord(beneficiary, totalAmount);\\n     `++` _initializeDistributionRecord(beneficiary, records[beneficiary].total);\\n    }\\n```\\n\\nThink of different scenarios if it is done that way and also keep in mind that the same holds for the decrease of `records[beneficiary].total` by `adjust`
Loss of funds for the user and the protocol
```\\nfunction claim(\\n    address beneficiary // the address that will receive tokens\\n  ) external validSaleParticipant(beneficiary) nonReentrant {\\n    uint256 claimableAmount = getClaimableAmount(beneficiary);\\n    uint256 purchasedAmount = getPurchasedAmount(beneficiary);\\n\\n    // effects\\n    uint256 claimedAmount = super._executeClaim(beneficiary, purchasedAmount);\\n\\n    // interactions\\n    super._settleClaim(beneficiary, claimedAmount);\\n  }\\n```\\n