---
# System prepended metadata

title: Untitled

---

## Doubts

- We are calculating the rewards for a voter of luganodes using the below code. 
- The reward calculated for the voter is less than the rewards that we get from the trongrid API. The difference is approximately 0.0001 to 0.0008. 
- We want to know if you guys are using any rounding off techniques in reward calculation, that we aren't using in our code shown below? 

## Code

```
const BigNumber = require('bignumber.js');
const totalVotesToLgns = new BigNumber(1372028133)
const total127Votes = new BigNumber(41117855470)
const lgns_ratio = totalVotesToLgns.dividedBy(total127Votes)
const totalBlockCount = new BigNumber(7198)
const lgnsBlockCount = new BigNumber(267)
const blockRwdLgns = lgnsBlockCount.multipliedBy(16)

// const voteRewards = totalBlockCount.multipliedBy(lgns_ratio).multipliedBy(160)
const voteRewards = totalBlockCount.multipliedBy(160)
const totalRewards = blockRwdLgns.plus(voteRewards)
console.log(totalRewards.toString(), voteRewards.toString(), blockRwdLgns.toString(), lgns_ratio.toString())

// voter rewards
const pledgedVotesByVoter = new BigNumber(564786000)
const pledgedVotesInTotal = new BigNumber(1372028031) 
const ratio = pledgedVotesByVoter.dividedBy(pledgedVotesInTotal)
const blockVoterReward = (blockRwdLgns * (new BigNumber(0.9)) * pledgedVotesByVoter) / totalVotesToLgns
const voteVoterReward = (voteRewards * pledgedVotesByVoter * (new BigNumber(0.9))) / total127Votes
const rewardsOfAVoter = blockVoterReward + voteVoterReward`
```



**Answer:**
We have just troubleshot the following problems, which may be caused by.
1. There may be a block loss in practice, and the code is calculated exactly according to the theory, so there may be some small errors in the code calculation results.
2. In the process of calculation, it is recommended to use SUN as the unit, 1TRX=1000000SUN, and the calculation result is rounded down.