`/accounts/{account-id}/staking-payouts`returning duplicated payouts for some nominators
bee344 opened this issue · comments
Description
In some very specific cases, when the nominator nominated the same account more than once on the same era, querying /accounts/{account-id}/staking-payouts
will result in an erroneous response by returning duplicated payouts
. As it stands now, sidecar will only take one amount staked as the input to calculate the payout and ignore all the others, and return the same payout for every nomination of that validator. This causes these payouts to be inaccurate, since:
- It only returns the payout corresponding to a single staked amount, and
- It returns that same payout several times, as if the nominator was paid that amount multiple times, even though it's not the case.
This behavior is caused by this specific line since it isn't thought for cases where a validator appears more than once in the nominated
list.
Possible solutions
- Add the 2 (or more) stakes, in order to calculate the payout based on the sum and have only one entry per validator.
- Calculate the payout for every nominator's stake and still have multiple entries of the same validator but with different payout amounts.