diff --git a/packages/dai-plugin-governance/src/GovPollingService.js b/packages/dai-plugin-governance/src/GovPollingService.js index 491c3a2ec..63df6db58 100644 --- a/packages/dai-plugin-governance/src/GovPollingService.js +++ b/packages/dai-plugin-governance/src/GovPollingService.js @@ -301,7 +301,6 @@ export default class GovPollingService extends PrivateService { }); tally.options[optionToEliminate].eliminated = true; - tally.options[optionToEliminate].transfer = BigNumber(0); // a vote needs to be moved if... // 1) it's currently for the eliminated candidate @@ -313,12 +312,18 @@ export default class GovPollingService extends PrivateService { // move votes to the next choice on their preference list votesToBeMoved.forEach(vote => { + const prevChoice = votes[vote.index].choice; votes[vote.index].choice = votes[vote.index].ballot.pop(); if (!tally.options[votes[vote.index].choice]) tally.options[votes[vote.index].choice] = { ...defaultOptionObj }; + tally.options[votes[vote.index].choice].transfer = BigNumber( tally.options[votes[vote.index].choice].transfer ).plus(vote.mkrSupport || 0); + + tally.options[prevChoice].transfer = BigNumber( + tally.options[prevChoice].transfer + ).minus(vote.mkrSupport || 0); }); // look for a candidate with the majority diff --git a/packages/dai-plugin-governance/test/fixtures.js b/packages/dai-plugin-governance/test/fixtures.js index 28a5db5ec..2f6557ed9 100644 --- a/packages/dai-plugin-governance/test/fixtures.js +++ b/packages/dai-plugin-governance/test/fixtures.js @@ -163,7 +163,7 @@ export const dummyBallotNoMajorityExpect = { options: { '1': { firstChoice: '60.025', - transfer: '0', + transfer: '-60.025', winner: false, eliminated: true }, @@ -210,7 +210,7 @@ export const dummyBallotMultipleRoundsExpect = { options: { '1': { firstChoice: '60.025', - transfer: '0', + transfer: '-56.025', winner: false, eliminated: true }, @@ -228,7 +228,7 @@ export const dummyBallotMultipleRoundsExpect = { }, '4': { firstChoice: '4', - transfer: '0', + transfer: '-4', winner: false, eliminated: true }