diff --git a/packages/dai-plugin-governance/src/VoteDelegateService.js b/packages/dai-plugin-governance/src/VoteDelegateService.js index 93395355f..76b95033d 100644 --- a/packages/dai-plugin-governance/src/VoteDelegateService.js +++ b/packages/dai-plugin-governance/src/VoteDelegateService.js @@ -1,5 +1,6 @@ import { LocalService } from '@makerdao/services-core'; import VoteDelegate from './VoteDelegate'; +import BigNumber from 'bignumber.js'; import { MKR, VOTE_DELEGATE_FACTORY, ZERO_ADDRESS } from './utils/constants'; import { fromBuffer, getCurrency } from './utils/helpers'; import voteDelegateAbi from '../contracts/abis/VoteDelegate.json'; @@ -68,7 +69,11 @@ export default class VoteDelegateService extends LocalService { } async getStakedBalanceForAddress(delegateAddress, address) { - return await this._getStakedBalanceForAddress(delegateAddress, address); + const bal = await this._getStakedBalanceForAddress( + delegateAddress, + address + ); + return new BigNumber(bal).shiftedBy(-18); } async getAllDelegates() { diff --git a/packages/dai-plugin-governance/test/VoteDelegateService.test.js b/packages/dai-plugin-governance/test/VoteDelegateService.test.js index c4a08897f..627cffde4 100644 --- a/packages/dai-plugin-governance/test/VoteDelegateService.test.js +++ b/packages/dai-plugin-governance/test/VoteDelegateService.test.js @@ -78,6 +78,16 @@ test('user can lock MKR with a delegate', async () => { expect(postLockDeposits.toNumber()).toBe(amountToLock); }); +test("can check a user's delegated stake", async () => { + const stakedAmt = 3; + const deposits = await vds.getStakedBalanceForAddress( + delegateContractAddress, + maker.currentAccount().address + ); + + expect(deposits.toNumber()).toBe(stakedAmt); +}); + test('delegate can cast an executive vote and retrieve voted on addresses from slate', async () => { maker.useAccountWithAddress(delegateAddress);