The transferStalk function calculates the number of roots to transfer when transferring stalk between accounts. The current rounding logic is implemented incorrectly.
Notice that a wrong calculation also will impact in the logic for the user sop.
Vulnerability Details
I.e about the current formula:
roots = (stalk - 1) * 500 / 3 + 1;
This is intended to round up but instead produces incorrect results. For example, with stalk = 3 and division = 3, the calculation gives:
roots = (3 - 1) * 500 / 3 + 1 = 334
However, the correct rounding formula should be:
roots = (stalk * 500 - 1) / 3 + 1;
This would result in:
roots = (3 * 500 - 1) / 3 + 1 = 500
Impact Details
Loss of funds for the recipient. The main issue is that the transferStalk removes the silo assets from the sender and adds them to the recipient, right after the transfer of stalk is made with less stalk than it should send to the recipient.
Sender cannot send the right amount of funds for the recipient